routing.vue 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254
  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. <!-- v-if="attributeData.status != 1 && !isWt" -->
  14. <template v-slot:toolbar>
  15. <el-button
  16. v-if="
  17. attributeData.approvalStatus != 1 &&
  18. attributeData.approvalStatus != 2 &&
  19. !isWt &&
  20. attributeData.parentId == '0' &&
  21. attributeData.id != attributeData.resourceBomId
  22. "
  23. size="small"
  24. type="primary"
  25. icon="el-icon-plus"
  26. class="ele-btn-icon"
  27. @click="add"
  28. >新增</el-button
  29. >
  30. </template>
  31. <!-- 状态列 -->
  32. <template v-slot:status="{ row }">
  33. {{ checkStatus(row) }}
  34. </template>
  35. <template v-slot:routeType="{ row }">
  36. {{
  37. row.routeType == 2
  38. ? '委外'
  39. : row.routeType == 1
  40. ? '生产'
  41. : row.routeType == 3
  42. ? '质检'
  43. : ''
  44. }}
  45. </template>
  46. <template v-slot:action="{ row, $index }">
  47. <el-link
  48. type="danger"
  49. @click="handleDel(row)"
  50. v-if="
  51. attributeData.approvalStatus != 1 &&
  52. attributeData.approvalStatus != 2 &&
  53. attributeData.parentId == '0' &&
  54. attributeData.id != attributeData.resourceBomId
  55. "
  56. >删除</el-link
  57. >
  58. </template>
  59. </ele-pro-table>
  60. </el-card>
  61. <routingDialog ref="routingDialogRef" @reload="reload"></routingDialog>
  62. </div>
  63. </template>
  64. <script>
  65. import { getMbomPage } from '@/api/material/BOM';
  66. import routingDialog from './routingDialog.vue';
  67. import route from '@/api/technology/route';
  68. import { workingProcedureUpdate } from '@/api/material/BOM';
  69. export default {
  70. name: 'technologyRoute',
  71. components: {
  72. routingDialog
  73. },
  74. props: {
  75. taskParam: Object,
  76. resourceBomId: String,
  77. attributeData: {
  78. type: Object,
  79. default: {}
  80. },
  81. isWt: {
  82. type: Boolean,
  83. default: false
  84. }
  85. },
  86. watch: {
  87. attributeData: {
  88. handler(val) {
  89. this.$nextTick(() => {
  90. this.reload();
  91. });
  92. },
  93. deep: true,
  94. immediate: true
  95. }
  96. },
  97. data() {
  98. return {
  99. tableData: [],
  100. selection: [],
  101. versionList: [],
  102. where: {},
  103. // 表格列配置
  104. columns: [
  105. {
  106. prop: 'code',
  107. label: '工艺路线编码',
  108. showOverflowTooltip: true,
  109. align: 'center',
  110. minWidth: 110,
  111. slot: 'code'
  112. },
  113. {
  114. prop: 'name',
  115. label: '工艺路线名称',
  116. showOverflowTooltip: true,
  117. align: 'center',
  118. minWidth: 110
  119. },
  120. {
  121. prop: 'version',
  122. label: '工艺路线版本',
  123. align: 'center',
  124. showOverflowTooltip: true,
  125. minWidth: 110
  126. },
  127. {
  128. prop: 'produceVersionName',
  129. label: '工艺类型',
  130. align: 'center',
  131. showOverflowTooltip: true
  132. },
  133. {
  134. prop: 'status',
  135. label: '状态',
  136. align: 'center',
  137. slot: 'status',
  138. showOverflowTooltip: true,
  139. minWidth: 110
  140. },
  141. {
  142. slot: 'routeType',
  143. label: '类型',
  144. align: 'center',
  145. showOverflowTooltip: true
  146. },
  147. {
  148. prop: 'action',
  149. label: '操作',
  150. align: 'center',
  151. slot: 'action'
  152. }
  153. ],
  154. // 表格选中数据
  155. selection: [],
  156. // 当前编辑数据
  157. current: null,
  158. // 是否显示编辑弹窗
  159. showEdit: false,
  160. detailEdit: false,
  161. statusList: [
  162. { label: '草稿', value: -1 },
  163. { label: '失效', value: 0 },
  164. { label: '生效', value: 1 }
  165. ],
  166. loading: false
  167. };
  168. },
  169. created() {
  170. console.log(this.attributeData, 'attributeDataattributeData');
  171. },
  172. methods: {
  173. add() {
  174. console.log(this.taskParam, this.tableData);
  175. this.$refs.routingDialogRef.open(this.taskParam, this.tableData);
  176. },
  177. search(e) {
  178. this.reload(this.where);
  179. },
  180. /* 表格数据源 */
  181. async datasource({ page, limit, where }) {
  182. let data = await getMbomPage({
  183. ...where,
  184. bomCategoryId: this.resourceBomId,
  185. pageNum: page,
  186. size: limit
  187. });
  188. if (data?.length > 0) {
  189. this.tableData = data[0];
  190. return data[0].processRoute.list || [];
  191. } else {
  192. this.tableData = {};
  193. return [];
  194. }
  195. },
  196. handleDel(row) {
  197. // route.getProcessById([row.id]).then((data) => {
  198. // })
  199. // console.log(row,'41444444',this.tableData.processRoute.list);
  200. // return
  201. this.$confirm('是否删除?', '提示', {
  202. confirmButtonText: '确定',
  203. cancelButtonText: '取消',
  204. type: 'warning'
  205. })
  206. .then(() => {
  207. workingProcedureUpdate({
  208. id: this.tableData.id,
  209. categoryId: this.taskParam.categoryId,
  210. bomCategoryId: this.taskParam.id,
  211. categoryCode: this.taskParam.categoryCode,
  212. isRouting: 1,
  213. processRoute: {
  214. list: this.tableData.processRoute.list.filter(
  215. (item) => item.id !== row.id
  216. )
  217. }
  218. }).then((data) => {
  219. this.$message.success('删除成功');
  220. this.reload();
  221. });
  222. })
  223. .catch(() => console.info('操作取消'));
  224. },
  225. checkStatus(row) {
  226. let obj = this.statusList.find((it) => it.value == row.status);
  227. return obj.label;
  228. },
  229. /* 刷新表格 */
  230. reload(where) {
  231. this.$refs.table.reload({ page: 1, where: where });
  232. }
  233. }
  234. };
  235. </script>