workmanship.vue 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718
  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="24">
  11. <el-col :span="6">
  12. <el-form-item label="工序编码:" label-width="100px">
  13. <el-input
  14. clearable
  15. v-model.trim="where.code"
  16. placeholder="请输入"
  17. />
  18. </el-form-item>
  19. </el-col>
  20. <el-col :span="6">
  21. <el-form-item label="工序名称:" label-width="100px">
  22. <el-input
  23. clearable
  24. v-model.trim="where.name"
  25. placeholder="请输入"
  26. />
  27. </el-form-item>
  28. </el-col>
  29. <el-col :span="6">
  30. <el-form-item label="所属工作中心" label-width="100px">
  31. <el-input
  32. clearable
  33. v-model.trim="where.workCenterName"
  34. placeholder="请输入"
  35. />
  36. </el-form-item>
  37. </el-col>
  38. <el-col :span="4">
  39. <div class="ele-form-actions">
  40. <el-button
  41. type="primary"
  42. class="ele-btn-icon"
  43. size="small"
  44. @click="reload"
  45. >
  46. 查询
  47. </el-button>
  48. <el-button size="small" plain>重置</el-button>
  49. </div>
  50. </el-col>
  51. </el-row>
  52. </el-form>
  53. <!-- 数据表格 -->
  54. <ele-pro-table
  55. class="table_list"
  56. ref="table"
  57. :columns="columns"
  58. :datasource="datasource"
  59. :need-page="false"
  60. row-key="id"
  61. >
  62. <!-- 表头工具栏 -->
  63. <!-- <template v-slot:toolbar>
  64. <el-button
  65. v-if="attributeData.status != 1"
  66. size="small"
  67. type="primary"
  68. icon="el-icon-plus"
  69. class="ele-btn-icon"
  70. @click="openEdit()"
  71. >
  72. 添加工序
  73. </el-button>
  74. </template> -->
  75. <!-- 展开内容 -->
  76. <template v-slot:expand="{ row, $index }">
  77. <div
  78. style="width: 100%; min-height: 60px"
  79. v-if="row.categoryParamStepList"
  80. >
  81. <ele-pro-table
  82. :toolbar="false"
  83. toolsTheme="none"
  84. ref="table2"
  85. :need-page="false"
  86. :datasource="row.categoryParamStepList"
  87. :columns="columns2"
  88. :key="row.code + '-' + $index"
  89. >
  90. <template v-slot:sort="{ row }">
  91. <el-input
  92. @input="(e) => validateNumber(e, row)"
  93. v-model.number="row.sort"
  94. ></el-input>
  95. </template>
  96. <!-- 默认值 -->
  97. <!-- <template v-slot:defaultValue="{ row }">
  98. <el-input
  99. v-if="
  100. row.textType == 1 || row.textType == 4 || row.textType == 5
  101. "
  102. v-model="row.defaultValue"
  103. placeholder="请输入"
  104. ></el-input>
  105. <el-select
  106. v-if="row.textType == 2"
  107. v-model="row.defaultValue"
  108. placeholder="请选择"
  109. >
  110. <el-option label="TRUE" :value="'TRUE'" />
  111. <el-option label="FALSE" :value="'FALSE'" />
  112. </el-select>
  113. </template> -->
  114. <template v-slot:name="{ row }">
  115. <el-input v-model="row.name" placeholder="请输入"></el-input>
  116. </template>
  117. <template v-slot:defaultValue="{ row }">
  118. <el-input
  119. v-model="row.defaultValue"
  120. placeholder="请输入"
  121. ></el-input>
  122. </template>
  123. <!-- 操作列 -->
  124. <template v-slot:action="{ row }">
  125. <!-- <el-link
  126. type="primary"
  127. :underline="false"
  128. icon="el-icon-edit"
  129. @click="editWorkingStep(row)"
  130. >
  131. 修改
  132. </el-link> -->
  133. <el-link
  134. type="primary"
  135. :underline="false"
  136. icon="el-icon-house"
  137. @click="saveWorking(row)"
  138. >
  139. 保存
  140. </el-link>
  141. <el-link
  142. type="primary"
  143. :underline="false"
  144. icon="el-icon-view"
  145. @click="openStepConfigure(row, true)"
  146. >
  147. 详情
  148. </el-link>
  149. <!-- <el-link
  150. type="primary"
  151. :underline="false"
  152. icon="el-icon-setting"
  153. @click="openStepConfigure(row)"
  154. >
  155. 配置
  156. </el-link> -->
  157. <el-popconfirm
  158. class="ele-action"
  159. title="确定要删除当前参数吗?"
  160. @confirm="remove2(row)"
  161. >
  162. <template v-slot:reference>
  163. <el-link
  164. type="danger"
  165. :underline="false"
  166. icon="el-icon-delete"
  167. >
  168. 删除
  169. </el-link>
  170. </template>
  171. </el-popconfirm>
  172. </template>
  173. </ele-pro-table>
  174. </div>
  175. </template>
  176. <!-- 操作列 -->
  177. <template v-slot:action="{ row }">
  178. <!-- <el-link
  179. type="primary"
  180. :underline="false"
  181. icon="el-icon-edit"
  182. @click="editWorkingProcedure(row)"
  183. v-if="attributeData.status != 1"
  184. >
  185. 修改
  186. </el-link> -->
  187. <el-link
  188. type="primary"
  189. :underline="false"
  190. icon="el-icon-view"
  191. @click="openConfigure(row, true)"
  192. >
  193. 详情
  194. </el-link>
  195. <el-link
  196. type="primary"
  197. :underline="false"
  198. icon="el-icon-setting"
  199. @click="openStepSetting(row)"
  200. v-if="attributeData.status != 1"
  201. >
  202. 工步
  203. </el-link>
  204. <el-link
  205. type="primary"
  206. :underline="false"
  207. icon="el-icon-setting"
  208. @click="openConfigure(row)"
  209. >
  210. 配置
  211. </el-link>
  212. <!-- <el-popconfirm
  213. class="ele-action"
  214. title="确定要删除当前工序吗?"
  215. @confirm="remove(row)"
  216. >
  217. <template v-slot:reference>
  218. <el-link v-if="attributeData.status != 1" type="danger" :underline="false" icon="el-icon-delete">
  219. 删除
  220. </el-link>
  221. </template>
  222. </el-popconfirm> -->
  223. </template>
  224. </ele-pro-table>
  225. </el-card>
  226. <ProcessModal
  227. ref="processModalRef"
  228. @chooseProcess="chooseProcess"
  229. ></ProcessModal>
  230. <ParamModal ref="paramRefs" @chooseModal="chooseModal"></ParamModal>
  231. <StepModal ref="stepModalRefs" @chooseModal="chooseStepModal"></StepModal>
  232. <workingProcedure
  233. ref="workingProcedureRef"
  234. @chooseProcess="chooseProcess"
  235. ></workingProcedure>
  236. <workingStep
  237. ref="workingStepRef"
  238. @chooseProcess="chooseProcess"
  239. ></workingStep>
  240. <user-edit
  241. :visible.sync="showEdit"
  242. :data="current"
  243. :controlList="controlList"
  244. :isView="isView"
  245. @done="reload"
  246. ref="userEdit"
  247. :typeList="typeList"
  248. />
  249. </div>
  250. </template>
  251. <script>
  252. import {
  253. workingProcedureUpdate,
  254. getStepListById,
  255. workingStepSave,
  256. workingSingleUpdate
  257. } from '@/api/material/BOM';
  258. import ProcessModal from './processModal.vue';
  259. import ParamModal from './ParamModal.vue';
  260. import StepModal from './StepModal1.vue';
  261. import workingProcedure from './workingProcedure.vue';
  262. import workingStep from './workingStep.vue';
  263. import { getMbomPage, workingStepDelete } from '@/api/material/BOM';
  264. import control from '@/api/technology/control';
  265. import UserEdit from '@/views/technology/stepManagement/components/user-edit.vue';
  266. export default {
  267. name: 'process',
  268. components: {
  269. ProcessModal,
  270. ParamModal,
  271. workingProcedure,
  272. StepModal,
  273. workingStep,
  274. UserEdit
  275. },
  276. props: {
  277. // bom bomCategoryId
  278. resourceBomId: String,
  279. // bom 信息
  280. taskParam: Object,
  281. // bom 信息 和 taskParam是一样的
  282. attributeData: {
  283. type: Object,
  284. default: {}
  285. }
  286. },
  287. watch: {
  288. attributeData: {
  289. handler(val) {
  290. this.$nextTick(() => {
  291. this.reload();
  292. });
  293. },
  294. deep: true,
  295. immediate: true
  296. }
  297. },
  298. data() {
  299. return {
  300. // 表格列配置
  301. columns: [
  302. {
  303. width: 45,
  304. type: 'expand',
  305. columnKey: 'categoryParamStepList',
  306. align: 'center',
  307. slot: 'expand',
  308. className: ''
  309. },
  310. {
  311. prop: 'sort',
  312. label: '排序号',
  313. showOverflowTooltip: true,
  314. align: 'center',
  315. minWidth: 110
  316. },
  317. {
  318. prop: 'code',
  319. label: '工序编码',
  320. showOverflowTooltip: true,
  321. align: 'center',
  322. minWidth: 110
  323. },
  324. {
  325. prop: 'name',
  326. label: '工序名称',
  327. showOverflowTooltip: true,
  328. align: 'center',
  329. minWidth: 110
  330. },
  331. {
  332. align: 'center',
  333. prop: 'controlName',
  334. label: '工序控制码',
  335. showOverflowTooltip: true,
  336. minWidth: 110
  337. },
  338. {
  339. prop: 'workCenterName',
  340. label: '所属工作中心',
  341. align: 'center',
  342. showOverflowTooltip: true,
  343. minWidth: 110
  344. },
  345. {
  346. columnKey: 'action',
  347. label: '操作',
  348. width: 300,
  349. align: 'center',
  350. resizable: false,
  351. slot: 'action',
  352. showOverflowTooltip: true
  353. }
  354. ],
  355. // 表格列配置
  356. columns2: [
  357. {
  358. prop: 'sort',
  359. slot: 'sort',
  360. label: '排序',
  361. minWidth: 60
  362. },
  363. {
  364. prop: 'code',
  365. label: '工步编码',
  366. showOverflowTooltip: true,
  367. align: 'center',
  368. minWidth: 110
  369. },
  370. {
  371. prop: 'name',
  372. slot: 'name',
  373. label: '工步名称',
  374. showOverflowTooltip: true,
  375. align: 'center',
  376. minWidth: 110
  377. },
  378. {
  379. slot: 'defaultValue',
  380. prop: 'defaultValue',
  381. label: '工序内容',
  382. showOverflowTooltip: true,
  383. align: 'center',
  384. minWidth: 110
  385. },
  386. {
  387. prop: 'status',
  388. slot: 'status',
  389. label: '状态',
  390. align: 'center',
  391. showOverflowTooltip: true,
  392. formatter: (_row) => {
  393. return ['生效', '失效'][_row.status];
  394. }
  395. },
  396. {
  397. columnKey: 'action',
  398. label: '操作',
  399. align: 'center',
  400. resizable: false,
  401. slot: 'action',
  402. minWidth: 200,
  403. showOverflowTooltip: true
  404. }
  405. ],
  406. processData: [],
  407. removeList: [],
  408. where: {},
  409. currentTableData: [],
  410. typeList: [
  411. {
  412. value: 1,
  413. label: '普通工步'
  414. },
  415. {
  416. value: 2,
  417. label: '抽样质检工步'
  418. },
  419. {
  420. value: 3,
  421. label: '普通质检工步'
  422. },
  423. {
  424. value: 4,
  425. label: '包装工步'
  426. },
  427. {
  428. value: 5,
  429. label: '入库工步'
  430. },
  431. {
  432. value: 6,
  433. label: '一工一检(常规质检)'
  434. }
  435. ],
  436. showEdit: false,
  437. current: null,
  438. isView: false,
  439. controlList: []
  440. };
  441. },
  442. methods: {
  443. // 单个工步数据保存
  444. saveWorking(row) {
  445. if (!row.name) {
  446. this.$message.warning('请输入工步名称');
  447. return;
  448. }
  449. if (!row.sort) {
  450. this.$message.warning('请输入工步排序');
  451. return;
  452. }
  453. let data = {
  454. stepName: row.name,
  455. id: row.id,
  456. defaultValue: row.defaultValue,
  457. sort: row.sort
  458. };
  459. workingSingleUpdate(data)
  460. .then((res) => {
  461. if (res.data) {
  462. this.$message.success('保存成功');
  463. } else {
  464. this.$message.error('保存失败');
  465. }
  466. })
  467. .catch((err) => {
  468. console.log(err, 'err');
  469. });
  470. },
  471. validateNumber(e, row) {
  472. if (e == 0) {
  473. row.sort = '';
  474. return;
  475. }
  476. let value = '';
  477. value = e.replace(/[^\d]/g, '');
  478. if (value.startsWith('0') && value.length > 1) {
  479. value = value.replace(/^0+/, '');
  480. }
  481. row.sort = value;
  482. },
  483. // expandChange(row, rows) {
  484. // if (rows.length > 0) {
  485. // // 展开
  486. // console.log('展开');
  487. // getStepListById({
  488. // paramId: row.id,
  489. // bomCategoryId: this.taskParam.id
  490. // }).then((data) => {
  491. // row.produceList = data;
  492. // });
  493. // }
  494. // console.log(row);
  495. // console.log(rows);
  496. // },
  497. openConfigure(row, isView) {
  498. this.$refs.workingProcedureRef.open(
  499. row,
  500. this.taskParam,
  501. this.currentTableData,
  502. !!isView,
  503. this.attributeData,
  504. this.resourceBomId
  505. );
  506. },
  507. openStepConfigure(row, isView) {
  508. console.log('123123123', row);
  509. // this.$refs.workingStepRef.open(row, this.taskParam, !!isView);
  510. this.isView = !!isView;
  511. this.getControlList();
  512. this.current = row;
  513. this.showEdit = true;
  514. this.$refs.userEdit.$refs.form &&
  515. this.$refs.userEdit.$refs.form.clearValidate();
  516. },
  517. getControlList() {
  518. const params = {
  519. pageNum: 1,
  520. size: -1
  521. };
  522. control.list().then((res) => {
  523. this.controlList = res.list;
  524. });
  525. },
  526. search() {},
  527. /*配置工艺参数 */
  528. openSetting(row) {
  529. this.current = row;
  530. this.$refs.paramRefs.open(row.produceList, this.current);
  531. },
  532. openStepSetting(row) {
  533. getStepListById({
  534. paramId: row.id,
  535. bomCategoryId: this.taskParam.id
  536. }).then((data) => {
  537. this.$refs.stepModalRefs.open(data, row, '新增');
  538. });
  539. },
  540. /* 表格数据源 */
  541. async datasource({ page, limit, where }) {
  542. let data = await getMbomPage({
  543. ...where,
  544. bomCategoryId: this.resourceBomId,
  545. categoryCode: this.attributeData.categoryCode,
  546. pageNum: page,
  547. size: limit
  548. });
  549. if (data?.length > 0) {
  550. this.currentTableData = data[0];
  551. let dataList = [];
  552. if (data[0].taskParam.length != 0) {
  553. dataList = data[0].taskParam.sort(
  554. (it, ie) => Number(it.sort) - Number(ie.sort)
  555. );
  556. }
  557. return dataList;
  558. // return data[0].taskParam;
  559. } else {
  560. return [];
  561. }
  562. },
  563. editWorkingProcedure(row) {
  564. this.$refs.processModalRef.open(
  565. this.taskParam,
  566. this.currentTableData,
  567. '修改',
  568. row
  569. );
  570. },
  571. openEdit() {
  572. this.$refs.processModalRef.open(
  573. this.taskParam,
  574. this.currentTableData,
  575. '新增'
  576. );
  577. },
  578. editWorkingStep(row) {
  579. this.$refs.stepModalRefs.open([], row, '修改');
  580. },
  581. reload(where) {
  582. this.$refs.table.reload({ where });
  583. },
  584. chooseProcess(data) {
  585. // let _arr = [...data, ...this.$refs.table.getData()];
  586. // this.$refs.table.setData([...data, ...this.$refs.table.getData()]);
  587. // this.$emit('chooseProcess', _arr);
  588. this.reload();
  589. },
  590. chooseModal(data, current) {
  591. data.map((m) => {
  592. m.parentId = current.id;
  593. return {
  594. ...m
  595. };
  596. });
  597. let tableList = [];
  598. let clonedArray = [];
  599. tableList = this.$refs.table.getData();
  600. clonedArray = JSON.parse(JSON.stringify(tableList));
  601. clonedArray.forEach((e) => {
  602. if (e.id == current.id) {
  603. if (e.hasOwnProperty('produceList')) {
  604. e.produceList = [...e.produceList, ...data];
  605. } else {
  606. e.produceList = [...data];
  607. }
  608. }
  609. });
  610. this.$refs.table.setData([...clonedArray]);
  611. this.$emit('chooseProcess', clonedArray);
  612. this.$nextTick(() => {
  613. this.$refs.table.toggleRowExpansionAll();
  614. this.$forceUpdate();
  615. });
  616. },
  617. chooseStepModal(data, current) {
  618. console.log(data, 'data');
  619. console.log(current, 'current');
  620. if (data?.length > 0) {
  621. let params = data.map((item) => {
  622. const itemData = {
  623. ...item,
  624. paramId: current.id,
  625. stepId: item.id,
  626. categoryId: this.taskParam.categoryId,
  627. bomCategoryId: this.taskParam.id,
  628. categoryCode: this.taskParam.categoryCode
  629. };
  630. // itemData.type = item.type.code;
  631. return itemData;
  632. });
  633. workingStepSave(params).then((data) => {
  634. this.$message.success('保存成功');
  635. this.reload();
  636. });
  637. }
  638. // this.reload();
  639. console.log(data);
  640. console.log(current);
  641. },
  642. /* 删除 */
  643. remove(row) {
  644. workingProcedureUpdate({
  645. id: this.currentTableData.id,
  646. categoryId: this.taskParam.categoryId,
  647. bomCategoryId: this.taskParam.id,
  648. categoryCode: this.taskParam.categoryCode,
  649. taskParam: this.currentTableData.taskParam.filter(
  650. (item) => item.id !== row.id
  651. )
  652. }).then((data) => {
  653. this.$message.success('删除成功');
  654. this.reload();
  655. });
  656. },
  657. remove2(row) {
  658. workingStepDelete([row.id]).then(() => {
  659. this.$message.success('删除成功');
  660. this.reload();
  661. });
  662. this.$forceUpdate();
  663. }
  664. }
  665. };
  666. </script>
  667. <style lang="scss">
  668. .workmanship {
  669. height: 100%;
  670. .el-card {
  671. height: 100%;
  672. .el-card__body {
  673. height: 100%;
  674. display: flex;
  675. flex-direction: column;
  676. overflow: auto;
  677. .table_list {
  678. flex: 1;
  679. display: flex;
  680. flex-direction: column;
  681. .el-table {
  682. flex: 1;
  683. overflow-y: auto !important;
  684. display: flex;
  685. flex-direction: column;
  686. .el-table__body-wrapper {
  687. flex: 1;
  688. }
  689. }
  690. }
  691. }
  692. }
  693. }
  694. </style>