index.vue 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204
  1. <template>
  2. <div class="ele-body">
  3. <el-card shadow="never">
  4. <search ref="search" @search="search" :options_groupId="dict.groupId" :options_factory="dict.factory"></search>
  5. <ele-pro-table ref="table" :columns="columns" :datasource="datasource" cache-key="systemRoleTable">
  6. <!-- 表头工具栏 -->
  7. <template v-slot:toolbar>
  8. <el-button size="small" type="primary" icon="el-icon-plus" class="ele-btn-icon" @click="openEdit('add')">
  9. 添加
  10. </el-button>
  11. </template>
  12. <template v-slot:workshop="{ row }">
  13. {{ showWorkshop(row) }}
  14. </template>
  15. <template v-slot:parent="{ row }">
  16. {{ showgfactory(row, 2) }}
  17. </template>
  18. <template v-slot:factory="{ row }">
  19. {{ showgfactory(row, 1) }}
  20. </template>
  21. <template v-slot:enabled="{ row }">
  22. {{ dict.enabled[row.enabled] }}
  23. </template>
  24. <!-- 操作列 -->
  25. <template v-slot:action="{ row }">
  26. <el-link type="primary" :underline="false" icon="el-icon-edit" @click="openEdit('edit', row)">
  27. 修改
  28. </el-link>
  29. <el-popconfirm class="ele-action" title="确定要删除此角色吗?" @confirm="remove(row)">
  30. <template v-slot:reference>
  31. <el-link type="danger" :underline="false" icon="el-icon-delete">
  32. 删除
  33. </el-link>
  34. </template>
  35. </el-popconfirm>
  36. </template>
  37. </ele-pro-table>
  38. </el-card>
  39. <edit ref="edit" @done="done" :options_groupId="dict.groupId" :options_factory="dict.factory"></edit>
  40. </div>
  41. </template>
  42. <script>
  43. import search from './components/search.vue';
  44. import edit from './components/edit.vue';
  45. import { getFactoryarea, deletefactoryarea } from '@/api/factoryModel';
  46. import { listOrganizations } from '@/api/system/organization';
  47. export default {
  48. components: {
  49. search,
  50. edit
  51. },
  52. data() {
  53. return {
  54. columns: [
  55. {
  56. width: 45,
  57. type: 'index',
  58. columnKey: 'index',
  59. align: 'center'
  60. },
  61. {
  62. prop: 'code',
  63. label: '产线编码'
  64. },
  65. {
  66. label: '产线名称',
  67. prop: 'name'
  68. },
  69. {
  70. label: '工厂编码',
  71. prop: 'parentCode',
  72. slot: 'parent'
  73. },
  74. {
  75. label: '所属工厂',
  76. prop: 'extInfo.factoryId',
  77. slot: 'factory'
  78. },
  79. {
  80. label: '所属车间',
  81. prop: 'parentId',
  82. slot: 'workshop'
  83. },
  84. {
  85. label: '省/市/区',
  86. prop: 'extInfo.location'
  87. },
  88. {
  89. label: '详细地址',
  90. prop: 'extInfo.locationDetail'
  91. },
  92. {
  93. label: '状态',
  94. prop: 'enabled',
  95. slot: 'enabled'
  96. },
  97. {
  98. columnKey: 'action',
  99. label: '操作',
  100. width: 220,
  101. align: 'center',
  102. resizable: false,
  103. slot: 'action',
  104. showOverflowTooltip: true
  105. }
  106. ],
  107. dict: {
  108. groupId: [],
  109. factory: [],
  110. enabled: {
  111. 1: '生效',
  112. 0: '未生效'
  113. }
  114. }
  115. };
  116. },
  117. created() {
  118. this.getGs();
  119. this.getFactoryarea();
  120. },
  121. methods: {
  122. datasource({ page, where, limit }) {
  123. return getFactoryarea({
  124. ...where,
  125. pageNum: page,
  126. size: limit,
  127. type: 4
  128. });
  129. },
  130. search(where) {
  131. this.$refs.table.reload({
  132. where: where,
  133. page: 1
  134. });
  135. },
  136. openEdit(type, row) {
  137. if (row) {
  138. if (typeof row.mainFactoryCapacityList == 'string') {
  139. this.$set(row, 'mainFactoryCapacityList', [])
  140. }
  141. }
  142. this.$refs.edit.open(type, row);
  143. },
  144. // 获取公司数据
  145. getGs() {
  146. listOrganizations().then((list) => {
  147. console.log(list);
  148. this.dict.groupId = list;
  149. });
  150. },
  151. // 回显工厂名称
  152. showgfactory(row, type) {
  153. let result = row.parent.find((n) => n.id == row.extInfo.factoryId);
  154. if (result && type == 1) {
  155. return result.name;
  156. } else if (result && type == 2) {
  157. return result.code;
  158. }
  159. else {
  160. return '';
  161. }
  162. },
  163. // 回显车间
  164. showWorkshop(row) {
  165. let result = row.parent.find((n) => n.id == row.parentId);
  166. if (result) {
  167. return result.name;
  168. } else {
  169. return '';
  170. }
  171. },
  172. // 获取工厂数据
  173. getFactoryarea() {
  174. let par = {
  175. type: 2,
  176. size: 9999
  177. };
  178. getFactoryarea(par).then((res) => {
  179. this.dict.factory = res.list;
  180. });
  181. },
  182. remove(row) {
  183. deletefactoryarea(row.id)
  184. .then((message) => {
  185. this.$message.success(message);
  186. this.done();
  187. })
  188. .catch((e) => {
  189. this.$message.error(e.message);
  190. });
  191. },
  192. done() {
  193. this.$refs.search.search();
  194. }
  195. }
  196. };
  197. </script>