index.vue 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254
  1. <template>
  2. <div class="ele-body">
  3. <el-card shadow="never">
  4. <search
  5. ref="search"
  6. @search="search"
  7. :options_groupId="dict.groupId"
  8. :options_factory="dict.factory"
  9. ></search>
  10. <ele-pro-table
  11. ref="table"
  12. :columns="columns"
  13. :datasource="datasource"
  14. :page-size="pageSize"
  15. @columns-change="handleColumnChange"
  16. :cache-key="cacheKeyUrl"
  17. @filter-change="selectType"
  18. >
  19. <!-- 表头工具栏 -->
  20. <template v-slot:toolbar>
  21. <el-button
  22. size="small"
  23. type="primary"
  24. icon="el-icon-plus"
  25. class="ele-btn-icon"
  26. @click="openEdit('add')"
  27. v-if="$hasPermission('main:factoryarea:saveOrUpdate')"
  28. >
  29. 添加
  30. </el-button>
  31. </template>
  32. <template v-slot:enabled="{ row }">
  33. {{ dict.enabled[row.enabled] }}
  34. </template>
  35. <template v-slot:workCenterList="{ row }">
  36. <p v-for="item in row.workCenterList">
  37. {{ item.name }}
  38. </p>
  39. <!-- {{ row.workCenterList }} -->
  40. </template>
  41. <!-- 操作列 -->
  42. <template v-slot:action="{ row }">
  43. <el-link
  44. type="primary"
  45. :underline="false"
  46. icon="el-icon-edit"
  47. @click="openEdit('copy', row)"
  48. v-if="$hasPermission('main:factoryarea:saveOrUpdate')"
  49. >
  50. 复制
  51. </el-link>
  52. <el-link
  53. type="primary"
  54. :underline="false"
  55. icon="el-icon-edit"
  56. @click="openEdit('edit', row)"
  57. v-if="$hasPermission('main:factoryarea:saveOrUpdate')"
  58. >
  59. 修改
  60. </el-link>
  61. <el-popconfirm
  62. class="ele-action"
  63. title="确定要删除此产线吗?"
  64. @confirm="remove(row)"
  65. v-if="$hasPermission('main:factoryarea:delete')"
  66. >
  67. <template v-slot:reference>
  68. <el-link type="danger" :underline="false" icon="el-icon-delete">
  69. 删除
  70. </el-link>
  71. </template>
  72. </el-popconfirm>
  73. </template>
  74. </ele-pro-table>
  75. </el-card>
  76. <edit
  77. ref="edit"
  78. @done="done"
  79. :options_groupId="dict.groupId"
  80. :options_factory="dict.factory"
  81. ></edit>
  82. </div>
  83. </template>
  84. <script>
  85. import tabMixins from '@/mixins/tableColumnsMixin';
  86. import search from './components/search.vue';
  87. import edit from './components/edit.vue';
  88. import { getFactoryarea, deletefactoryarea } from '@/api/factoryModel';
  89. import { listOrganizations } from '@/api/system/organization';
  90. export default {
  91. mixins: [tabMixins],
  92. components: {
  93. search,
  94. edit
  95. },
  96. data() {
  97. return {
  98. columns: [
  99. {
  100. width: 45,
  101. type: 'index',
  102. columnKey: 'index',
  103. align: 'center'
  104. },
  105. {
  106. prop: 'code',
  107. label: '产线编码'
  108. },
  109. {
  110. label: '产线名称',
  111. prop: 'name'
  112. },
  113. {
  114. label: '所属工厂',
  115. prop: 'factoryName'
  116. },
  117. {
  118. label: '所属厂房',
  119. prop: 'workshopPlanName'
  120. },
  121. {
  122. label: '所属车间',
  123. prop: 'workshopName'
  124. },
  125. {
  126. label: '工作中心',
  127. prop: 'workCenterList',
  128. slot: 'workCenterList'
  129. },
  130. {
  131. label: '所属区域',
  132. prop: 'areaName'
  133. },
  134. {
  135. label: '省/市/区',
  136. prop: 'extInfo.location'
  137. },
  138. {
  139. label: '详细地址',
  140. prop: 'extInfo.locationDetail'
  141. },
  142. {
  143. //修改此prop名称时,请同步修改columnKey属性和下方selectType方法
  144. label: '状态',
  145. prop: 'enabled',
  146. slot: 'enabled',
  147. filters: [
  148. { value: 1, text: '生效' },
  149. { value: 0, text: '未生效' }
  150. ],
  151. filterMultiple: false,
  152. columnKey: 'enabled'
  153. },
  154. {
  155. columnKey: 'action',
  156. label: '操作',
  157. width: 220,
  158. align: 'center',
  159. resizable: false,
  160. slot: 'action',
  161. showOverflowTooltip: true
  162. }
  163. ],
  164. dict: {
  165. groupId: [],
  166. factory: [],
  167. enabled: {
  168. 1: '生效',
  169. 0: '未生效'
  170. }
  171. },
  172. pageSize: this.$store.state.tablePageSize,
  173. cacheKeyUrl: '015ef54f-factoryModel-productionLine'
  174. };
  175. },
  176. created() {
  177. this.getGs();
  178. this.getFactoryarea();
  179. },
  180. methods: {
  181. selectType(value) {
  182. let where = {};
  183. if (value.enabled.length > 0) {
  184. where['enable'] = value.enabled[0];
  185. }
  186. this.search(where);
  187. },
  188. datasource({ page, where, limit }) {
  189. return getFactoryarea({
  190. ...where,
  191. pageNum: page,
  192. size: limit,
  193. type: 4
  194. });
  195. },
  196. search(where) {
  197. this.$refs.table.reload({
  198. where: where,
  199. page: 1
  200. });
  201. },
  202. openEdit(type, row) {
  203. if (row) {
  204. if (typeof row.mainFactoryCapacityList == 'string') {
  205. this.$set(row, 'mainFactoryCapacityList', []);
  206. }
  207. }
  208. this.$refs.edit.open(type, row);
  209. },
  210. // 获取公司数据
  211. getGs() {
  212. listOrganizations().then((list) => {
  213. console.log(list);
  214. this.dict.groupId = list;
  215. });
  216. },
  217. // 获取工厂数据
  218. getFactoryarea() {
  219. let par = {
  220. type: 2,
  221. size: 9999
  222. };
  223. getFactoryarea(par).then((res) => {
  224. this.dict.factory = res.list;
  225. });
  226. },
  227. remove(row) {
  228. deletefactoryarea(row.id)
  229. .then((message) => {
  230. this.$message.success(message);
  231. this.done();
  232. })
  233. .catch((e) => {
  234. this.$message.error(e.message);
  235. });
  236. },
  237. done() {
  238. this.$refs.search.search();
  239. }
  240. }
  241. };
  242. </script>