workmanship.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555
  1. <template>
  2. <div class="workmanship">
  3. <el-card shadow="never">
  4. <el-form
  5. label-width="77px"
  6. class="ele-form-search"
  7. @keyup.enter.native="search"
  8. @submit.native.prevent
  9. >
  10. <el-row type="flex" :gutter="15">
  11. <el-col :span="6">
  12. <el-form-item label="工序编码:" label-width="100px">
  13. <el-input clearable v-model.trim="where.code" placeholder="请输入" />
  14. </el-form-item>
  15. </el-col>
  16. <el-col :span="6">
  17. <el-form-item label="工序名称:" label-width="100px">
  18. <el-input clearable v-model.trim="where.name" placeholder="请输入" />
  19. </el-form-item>
  20. </el-col>
  21. <el-col :span="6">
  22. <el-form-item label="版本:" label-width="100px">
  23. <el-input
  24. clearable
  25. v-model.trim="where.versions"
  26. placeholder="请输入"
  27. />
  28. </el-form-item>
  29. </el-col>
  30. </el-row>
  31. <el-row type="flex" :gutter="15">
  32. <el-col :span="6">
  33. <el-form-item label="所属工作中心" label-width="100px">
  34. <el-input clearable v-model.trim="where.workCenterName" placeholder="请输入" />
  35. </el-form-item>
  36. </el-col>
  37. <el-col :span="18">
  38. <div class="ele-form-actions">
  39. <el-button
  40. type="primary"
  41. class="ele-btn-icon"
  42. size="small"
  43. @click="reload"
  44. >
  45. 查询
  46. </el-button>
  47. <el-button size="small" plain>重置</el-button>
  48. </div>
  49. </el-col>
  50. </el-row>
  51. </el-form>
  52. <!-- 数据表格 -->
  53. <ele-pro-table
  54. class="table_list"
  55. ref="table"
  56. :columns="columns"
  57. :datasource="datasource"
  58. :need-page="false"
  59. row-key="id"
  60. >
  61. <!-- 表头工具栏 -->
  62. <template v-slot:toolbar>
  63. <el-button
  64. size="small"
  65. type="primary"
  66. icon="el-icon-plus"
  67. class="ele-btn-icon"
  68. @click="openEdit()"
  69. >
  70. 添加工序
  71. </el-button>
  72. </template>
  73. <!-- 展开内容 -->
  74. <template v-slot:expand="{ row, $index }">
  75. <div
  76. style="width: 100%; min-height: 60px"
  77. v-if="row.categoryParamStepList"
  78. >
  79. <ele-pro-table
  80. :toolbar="false"
  81. toolsTheme="none"
  82. ref="table2"
  83. :need-page="false"
  84. :datasource="row.categoryParamStepList"
  85. :columns="columns2"
  86. :key="row.code + '-' + $index"
  87. >
  88. <template v-slot:sort="{ row }">
  89. <el-input v-model="row.sort"></el-input>
  90. </template>
  91. <!-- 默认值 -->
  92. <template v-slot:defaultValue="{ row }">
  93. <el-input
  94. v-if="
  95. row.textType == 1 || row.textType == 4 || row.textType == 5
  96. "
  97. v-model="row.defaultValue"
  98. placeholder="请输入"
  99. ></el-input>
  100. <el-select
  101. v-if="row.textType == 2"
  102. v-model="row.defaultValue"
  103. placeholder="请选择"
  104. >
  105. <el-option label="TRUE" :value="'TRUE'" />
  106. <el-option label="FALSE" :value="'FALSE'" />
  107. </el-select>
  108. </template>
  109. <!-- 操作列 -->
  110. <template v-slot:action="{ row }">
  111. <el-link
  112. type="primary"
  113. :underline="false"
  114. icon="el-icon-edit"
  115. @click="editWorkingStep(row)"
  116. >
  117. 修改
  118. </el-link>
  119. <el-link
  120. type="primary"
  121. :underline="false"
  122. icon="el-icon-view"
  123. @click="openStepConfigure(row, true)"
  124. >
  125. 详情
  126. </el-link>
  127. <el-link
  128. type="primary"
  129. :underline="false"
  130. icon="el-icon-setting"
  131. @click="openStepConfigure(row)"
  132. >
  133. 配置
  134. </el-link>
  135. <el-popconfirm
  136. class="ele-action"
  137. title="确定要删除当前参数吗?"
  138. @confirm="remove2(row)"
  139. >
  140. <template v-slot:reference>
  141. <el-link
  142. type="danger"
  143. :underline="false"
  144. icon="el-icon-delete"
  145. >
  146. 删除
  147. </el-link>
  148. </template>
  149. </el-popconfirm>
  150. </template>
  151. </ele-pro-table>
  152. </div>
  153. </template>
  154. <!-- 操作列 -->
  155. <template v-slot:action="{ row }">
  156. <el-link
  157. type="primary"
  158. :underline="false"
  159. icon="el-icon-edit"
  160. @click="editWorkingProcedure(row)"
  161. >
  162. 修改
  163. </el-link>
  164. <el-link
  165. type="primary"
  166. :underline="false"
  167. icon="el-icon-view"
  168. @click="openConfigure(row, true)"
  169. >
  170. 详情
  171. </el-link>
  172. <el-link
  173. type="primary"
  174. :underline="false"
  175. icon="el-icon-setting"
  176. @click="openStepSetting(row)"
  177. >
  178. 工步
  179. </el-link>
  180. <el-link
  181. type="primary"
  182. :underline="false"
  183. icon="el-icon-setting"
  184. @click="openConfigure(row)"
  185. >
  186. 配置
  187. </el-link>
  188. <el-popconfirm
  189. class="ele-action"
  190. title="确定要删除当前工序吗?"
  191. @confirm="remove(row)"
  192. >
  193. <template v-slot:reference>
  194. <el-link type="danger" :underline="false" icon="el-icon-delete">
  195. 删除
  196. </el-link>
  197. </template>
  198. </el-popconfirm>
  199. </template>
  200. </ele-pro-table>
  201. </el-card>
  202. <ProcessModal
  203. ref="processModalRef"
  204. @chooseProcess="chooseProcess"
  205. ></ProcessModal>
  206. <ParamModal ref="paramRefs" @chooseModal="chooseModal"></ParamModal>
  207. <StepModal ref="stepModalRefs" @chooseModal="chooseStepModal"></StepModal>
  208. <workingProcedure
  209. ref="workingProcedureRef"
  210. @chooseProcess="chooseProcess"
  211. ></workingProcedure>
  212. <workingStep
  213. ref="workingStepRef"
  214. @chooseProcess="chooseProcess"
  215. ></workingStep>
  216. </div>
  217. </template>
  218. <script>
  219. import {
  220. workingProcedureUpdate,
  221. getStepListById,
  222. workingStepSave
  223. } from '@/api/material/BOM';
  224. import ProcessModal from './processModal.vue';
  225. import ParamModal from './ParamModal.vue';
  226. import StepModal from './StepModal1.vue';
  227. import workingProcedure from './workingProcedure.vue';
  228. import workingStep from './workingStep.vue';
  229. import { getMbomPage, workingStepDelete } from '@/api/material/BOM';
  230. export default {
  231. name: 'process',
  232. components: {
  233. ProcessModal,
  234. ParamModal,
  235. workingProcedure,
  236. StepModal,
  237. workingStep
  238. },
  239. props: {
  240. taskParam: Object
  241. },
  242. data() {
  243. return {
  244. // 表格列配置
  245. columns: [
  246. {
  247. width: 45,
  248. type: 'expand',
  249. columnKey: 'categoryParamStepList',
  250. align: 'center',
  251. slot: 'expand',
  252. className: ''
  253. },
  254. {
  255. prop: 'code',
  256. label: '工序编码',
  257. showOverflowTooltip: true,
  258. align: 'center',
  259. minWidth: 110
  260. },
  261. {
  262. prop: 'name',
  263. label: '工序名称',
  264. showOverflowTooltip: true,
  265. align: 'center',
  266. minWidth: 110
  267. },
  268. {
  269. prop: 'versions',
  270. label: '版本',
  271. showOverflowTooltip: true,
  272. align: 'center',
  273. minWidth: 110
  274. },
  275. {
  276. align: 'center',
  277. prop: 'controlName',
  278. label: '工序控制码',
  279. showOverflowTooltip: true,
  280. minWidth: 110
  281. },
  282. {
  283. prop: 'workCenterName',
  284. label: '所属工作中心',
  285. align: 'center',
  286. showOverflowTooltip: true,
  287. minWidth: 110
  288. },
  289. {
  290. columnKey: 'action',
  291. label: '操作',
  292. width: 300,
  293. align: 'center',
  294. resizable: false,
  295. slot: 'action',
  296. showOverflowTooltip: true
  297. }
  298. ],
  299. // 表格列配置
  300. columns2: [
  301. {
  302. prop: 'sort',
  303. slot: 'sort',
  304. label: '排序',
  305. minWidth: 60
  306. },
  307. {
  308. prop: 'code',
  309. label: '工步类型',
  310. showOverflowTooltip: true,
  311. align: 'center',
  312. minWidth: 110
  313. },
  314. {
  315. prop: 'name',
  316. label: '工步编码',
  317. showOverflowTooltip: true,
  318. align: 'center',
  319. minWidth: 110
  320. },
  321. {
  322. prop: 'name',
  323. label: '工序名称',
  324. showOverflowTooltip: true,
  325. align: 'center',
  326. minWidth: 110
  327. },
  328. {
  329. prop: 'status',
  330. slot: 'status',
  331. label: '状态',
  332. align: 'center',
  333. showOverflowTooltip: true,
  334. formatter: (_row) => {
  335. return ['生效', '失效'][_row.status];
  336. }
  337. },
  338. {
  339. columnKey: 'action',
  340. label: '操作',
  341. align: 'center',
  342. resizable: false,
  343. slot: 'action',
  344. minWidth: 200,
  345. showOverflowTooltip: true
  346. }
  347. ],
  348. processData: [],
  349. removeList: [],
  350. where: {},
  351. currentTableData: []
  352. };
  353. },
  354. methods: {
  355. // expandChange(row, rows) {
  356. // if (rows.length > 0) {
  357. // // 展开
  358. // console.log('展开');
  359. // getStepListById({
  360. // paramId: row.id,
  361. // bomCategoryId: this.taskParam.id
  362. // }).then((data) => {
  363. // row.produceList = data;
  364. // });
  365. // }
  366. // console.log(row);
  367. // console.log(rows);
  368. // },
  369. openConfigure(row, isView) {
  370. this.$refs.workingProcedureRef.open(
  371. row,
  372. this.taskParam,
  373. this.currentTableData,
  374. !!isView
  375. );
  376. },
  377. openStepConfigure(row, isView) {
  378. this.$refs.workingStepRef.open(row, this.taskParam, !!isView);
  379. },
  380. search() {},
  381. /*配置工艺参数 */
  382. openSetting(row) {
  383. this.current = row;
  384. this.$refs.paramRefs.open(row.produceList, this.current);
  385. },
  386. openStepSetting(row) {
  387. getStepListById({
  388. paramId: row.id,
  389. bomCategoryId: this.taskParam.id
  390. }).then((data) => {
  391. this.$refs.stepModalRefs.open(data, row, '新增');
  392. });
  393. },
  394. /* 表格数据源 */
  395. async datasource({ page, limit, where }) {
  396. let data = await getMbomPage({
  397. ...where,
  398. bomCategoryId: this.taskParam.id,
  399. pageNum: page,
  400. size: limit
  401. });
  402. if (data?.length > 0) {
  403. this.currentTableData = data[0];
  404. return data[0].taskParam;
  405. } else {
  406. return [];
  407. }
  408. },
  409. editWorkingProcedure(row) {
  410. this.$refs.processModalRef.open(
  411. this.taskParam,
  412. this.currentTableData,
  413. '修改',
  414. row
  415. );
  416. },
  417. openEdit() {
  418. this.$refs.processModalRef.open(
  419. this.taskParam,
  420. this.currentTableData,
  421. '新增'
  422. );
  423. },
  424. editWorkingStep(row) {
  425. this.$refs.stepModalRefs.open([], row, '修改');
  426. },
  427. reload(where) {
  428. this.$refs.table.reload({ where });
  429. },
  430. chooseProcess(data) {
  431. // let _arr = [...data, ...this.$refs.table.getData()];
  432. // this.$refs.table.setData([...data, ...this.$refs.table.getData()]);
  433. // this.$emit('chooseProcess', _arr);
  434. this.reload();
  435. },
  436. chooseModal(data, current) {
  437. data.map((m) => {
  438. m.parentId = current.id;
  439. return {
  440. ...m
  441. };
  442. });
  443. let tableList = [];
  444. let clonedArray = [];
  445. tableList = this.$refs.table.getData();
  446. clonedArray = JSON.parse(JSON.stringify(tableList));
  447. clonedArray.forEach((e) => {
  448. if (e.id == current.id) {
  449. if (e.hasOwnProperty('produceList')) {
  450. e.produceList = [...e.produceList, ...data];
  451. } else {
  452. e.produceList = [...data];
  453. }
  454. }
  455. });
  456. this.$refs.table.setData([...clonedArray]);
  457. this.$emit('chooseProcess', clonedArray);
  458. this.$nextTick(() => {
  459. this.$refs.table.toggleRowExpansionAll();
  460. this.$forceUpdate();
  461. });
  462. },
  463. chooseStepModal(data, current) {
  464. if (data?.length > 0) {
  465. let params = data.map((item) => {
  466. return {
  467. ...item,
  468. paramId: current.id,
  469. stepId: item.id,
  470. categoryId: this.taskParam.categoryId,
  471. bomCategoryId: this.taskParam.id,
  472. categoryCode: this.taskParam.categoryCode
  473. };
  474. });
  475. workingStepSave(params).then((data) => {
  476. this.$message.success('保存成功');
  477. });
  478. }
  479. this.reload();
  480. console.log(data);
  481. console.log(current);
  482. },
  483. /* 删除 */
  484. remove(row) {
  485. workingProcedureUpdate({
  486. id: this.currentTableData.id,
  487. categoryId: this.taskParam.categoryId,
  488. bomCategoryId: this.taskParam.id,
  489. categoryCode: this.taskParam.categoryCode,
  490. taskParam: this.currentTableData.taskParam.filter(
  491. (item) => item.id !== row.id
  492. )
  493. }).then((data) => {
  494. this.$message.success('删除成功');
  495. this.reload();
  496. });
  497. },
  498. remove2(row) {
  499. workingStepDelete([row.id]).then(() => {
  500. this.$message.success('删除成功');
  501. this.reload();
  502. });
  503. this.$forceUpdate();
  504. }
  505. }
  506. };
  507. </script>
  508. <style lang="scss">
  509. .workmanship {
  510. height: 100%;
  511. .el-card {
  512. height: 100%;
  513. .el-card__body {
  514. height: 100%;
  515. display: flex;
  516. flex-direction: column;
  517. overflow: auto;
  518. .table_list {
  519. flex: 1;
  520. display: flex;
  521. flex-direction: column;
  522. .el-table {
  523. flex: 1;
  524. overflow-y: auto !important;
  525. display: flex;
  526. flex-direction: column;
  527. .el-table__body-wrapper {
  528. flex: 1;
  529. }
  530. }
  531. }
  532. }
  533. }
  534. }
  535. </style>