routing.vue 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185
  1. <template>
  2. <div class="ele-body">
  3. <el-card shadow="never">
  4. <!-- 数据表格 -->
  5. <ele-pro-table
  6. ref="table"
  7. :columns="columns"
  8. :datasource="datasource"
  9. :selection.sync="selection"
  10. row-key="id"
  11. >
  12. <!-- 表头工具栏 -->
  13. <template v-slot:toolbar>
  14. <el-button
  15. size="small"
  16. type="primary"
  17. icon="el-icon-plus"
  18. class="ele-btn-icon"
  19. @click="add"
  20. >新增</el-button
  21. >
  22. </template>
  23. <!-- 状态列 -->
  24. <template v-slot:status="{ row }">
  25. {{ checkStatus(row) }}
  26. </template>
  27. <template v-slot:routeType="{ row }">
  28. {{ row.routeType == 2 ? '委外' : row.routeType == 1 ? '生产' : row.routeType == 3 ? '质检' : ''}}
  29. </template>
  30. <template v-slot:action="{ row, $index }">
  31. <el-link type="danger" @click="handleDel(row)">删除</el-link>
  32. </template>
  33. </ele-pro-table>
  34. </el-card>
  35. <routingDialog ref="routingDialogRef" @reload="reload"></routingDialog>
  36. </div>
  37. </template>
  38. <script>
  39. import { getMbomPage } from '@/api/material/BOM';
  40. import routingDialog from './routingDialog.vue';
  41. import { workingProcedureUpdate } from '@/api/material/BOM';
  42. export default {
  43. name: 'technologyRoute',
  44. components: {
  45. routingDialog
  46. },
  47. props: {
  48. taskParam: Object
  49. },
  50. data() {
  51. return {
  52. tableData: [],
  53. selection: [],
  54. versionList: [],
  55. where: {},
  56. // 表格列配置
  57. columns: [
  58. {
  59. prop: 'code',
  60. label: '工艺路线组编码',
  61. showOverflowTooltip: true,
  62. align: 'center',
  63. minWidth: 110,
  64. slot: 'code'
  65. },
  66. {
  67. prop: 'name',
  68. label: '工艺路线名称',
  69. showOverflowTooltip: true,
  70. align: 'center',
  71. minWidth: 110
  72. },
  73. {
  74. prop: 'version',
  75. label: '工艺路线版本',
  76. align: 'center',
  77. showOverflowTooltip: true,
  78. minWidth: 110
  79. },
  80. {
  81. prop: 'produceVersionName',
  82. label: '生产版本',
  83. align: 'center',
  84. showOverflowTooltip: true
  85. },
  86. {
  87. prop: 'status',
  88. label: '状态',
  89. align: 'center',
  90. slot: 'status',
  91. showOverflowTooltip: true,
  92. minWidth: 110
  93. },
  94. {
  95. slot: 'routeType',
  96. label: '类型',
  97. align: 'center',
  98. showOverflowTooltip: true
  99. },
  100. {
  101. prop: 'action',
  102. label: '操作',
  103. align: 'center',
  104. slot: 'action'
  105. }
  106. ],
  107. // 表格选中数据
  108. selection: [],
  109. // 当前编辑数据
  110. current: null,
  111. // 是否显示编辑弹窗
  112. showEdit: false,
  113. detailEdit: false,
  114. statusList: [
  115. { label: '草稿', value: -1 },
  116. { label: '失效', value: 0 },
  117. { label: '生效', value: 1 }
  118. ],
  119. loading: false
  120. };
  121. },
  122. methods: {
  123. add() {
  124. this.$refs.routingDialogRef.open(this.taskParam, this.tableData);
  125. },
  126. search() {
  127. this.reload(this.where);
  128. },
  129. /* 表格数据源 */
  130. async datasource({ page, limit, where }) {
  131. let data = await getMbomPage({
  132. ...where,
  133. bomCategoryId: this.taskParam.id,
  134. pageNum: page,
  135. size: limit
  136. });
  137. if (data?.length > 0) {
  138. this.tableData = data[0];
  139. return data[0].processRoute.list || [];
  140. } else {
  141. this.tableData = {};
  142. return [];
  143. }
  144. },
  145. handleDel(row) {
  146. workingProcedureUpdate({
  147. id: this.tableData.id,
  148. categoryId: this.taskParam.categoryId,
  149. bomCategoryId: this.taskParam.id,
  150. categoryCode: this.taskParam.categoryCode,
  151. processRoute: {
  152. list: this.tableData.processRoute.list.filter(
  153. (item) => item.id !== row.id
  154. )
  155. }
  156. }).then((data) => {
  157. this.$message.success('删除成功');
  158. this.reload();
  159. });
  160. },
  161. checkStatus(row) {
  162. let obj = this.statusList.find((it) => it.value == row.status);
  163. return obj.label;
  164. },
  165. /* 刷新表格 */
  166. reload(where) {
  167. this.$refs.table.reload({ page: 1, where: where });
  168. }
  169. }
  170. };
  171. </script>