workmanship.vue 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720
  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. v-if="
  209. attributeData.approvalStatus != 2 &&
  210. attributeData.approvalStatus != 1
  211. "
  212. @click="openConfigure(row)"
  213. >
  214. 配置
  215. </el-link>
  216. <!-- <el-popconfirm
  217. class="ele-action"
  218. title="确定要删除当前工序吗?"
  219. @confirm="remove(row)"
  220. >
  221. <template v-slot:reference>
  222. <el-link v-if="attributeData.status != 1" type="danger" :underline="false" icon="el-icon-delete">
  223. 删除
  224. </el-link>
  225. </template>
  226. </el-popconfirm> -->
  227. </template>
  228. </ele-pro-table>
  229. </el-card>
  230. <ProcessModal
  231. ref="processModalRef"
  232. @chooseProcess="chooseProcess"
  233. ></ProcessModal>
  234. <ParamModal ref="paramRefs" @chooseModal="chooseModal"></ParamModal>
  235. <StepModal ref="stepModalRefs" @chooseModal="chooseStepModal"></StepModal>
  236. <workingProcedure
  237. ref="workingProcedureRef"
  238. @chooseProcess="chooseProcess"
  239. ></workingProcedure>
  240. <workingStep
  241. ref="workingStepRef"
  242. @chooseProcess="chooseProcess"
  243. ></workingStep>
  244. <user-edit
  245. :visible.sync="showEdit"
  246. :data="current"
  247. :controlList="controlList"
  248. :isView="isView"
  249. @done="reload"
  250. ref="userEdit"
  251. :typeList="typeList"
  252. />
  253. </div>
  254. </template>
  255. <script>
  256. import {
  257. workingProcedureUpdate,
  258. getStepListById,
  259. workingStepSave,
  260. workingSingleUpdate
  261. } from '@/api/material/BOM';
  262. import ProcessModal from './processModal.vue';
  263. import ParamModal from './ParamModal.vue';
  264. import StepModal from './StepModal1.vue';
  265. import workingProcedure from './workingProcedure.vue';
  266. import workingStep from './workingStep.vue';
  267. import { getMbomPage, workingStepDelete } from '@/api/material/BOM';
  268. import control from '@/api/technology/control';
  269. import UserEdit from '@/views/technology/stepManagement/components/user-edit.vue';
  270. export default {
  271. name: 'process',
  272. components: {
  273. ProcessModal,
  274. ParamModal,
  275. workingProcedure,
  276. StepModal,
  277. workingStep,
  278. UserEdit
  279. },
  280. props: {
  281. // bom bomCategoryId
  282. resourceBomId: String,
  283. // bom 信息
  284. taskParam: Object,
  285. // bom 信息 和 taskParam是一样的
  286. attributeData: {
  287. type: Object,
  288. default: {}
  289. }
  290. },
  291. watch: {
  292. attributeData: {
  293. handler(val) {
  294. this.$nextTick(() => {
  295. this.reload();
  296. });
  297. },
  298. deep: true,
  299. immediate: true
  300. }
  301. },
  302. data() {
  303. return {
  304. // 表格列配置
  305. columns: [
  306. {
  307. width: 45,
  308. type: 'expand',
  309. columnKey: 'categoryParamStepList',
  310. align: 'center',
  311. slot: 'expand',
  312. className: ''
  313. },
  314. {
  315. prop: 'sort',
  316. label: '排序号',
  317. showOverflowTooltip: true,
  318. align: 'center',
  319. minWidth: 110
  320. },
  321. {
  322. prop: 'code',
  323. label: '工序编码',
  324. showOverflowTooltip: true,
  325. align: 'center',
  326. minWidth: 110
  327. },
  328. {
  329. prop: 'name',
  330. label: '工序名称',
  331. showOverflowTooltip: true,
  332. align: 'center',
  333. minWidth: 110
  334. },
  335. {
  336. align: 'center',
  337. prop: 'controlName',
  338. label: '工序控制码',
  339. showOverflowTooltip: true,
  340. minWidth: 110
  341. },
  342. {
  343. prop: 'workCenterName',
  344. label: '所属工作中心',
  345. align: 'center',
  346. showOverflowTooltip: true,
  347. minWidth: 110
  348. },
  349. {
  350. columnKey: 'action',
  351. label: '操作',
  352. width: 300,
  353. align: 'center',
  354. resizable: false,
  355. slot: 'action',
  356. showOverflowTooltip: true
  357. }
  358. ],
  359. // 表格列配置
  360. columns2: [
  361. {
  362. prop: 'sort',
  363. slot: 'sort',
  364. label: '排序',
  365. minWidth: 60
  366. },
  367. {
  368. prop: 'code',
  369. label: '工步编码',
  370. showOverflowTooltip: true,
  371. align: 'center',
  372. minWidth: 110
  373. },
  374. {
  375. prop: 'name',
  376. slot: 'name',
  377. label: '工步名称',
  378. showOverflowTooltip: true,
  379. align: 'center',
  380. minWidth: 110
  381. },
  382. {
  383. slot: 'defaultValue',
  384. prop: 'defaultValue',
  385. label: '工序内容',
  386. showOverflowTooltip: true,
  387. align: 'center',
  388. minWidth: 110
  389. },
  390. {
  391. prop: 'status',
  392. slot: 'status',
  393. label: '状态',
  394. align: 'center',
  395. showOverflowTooltip: true,
  396. formatter: (_row) => {
  397. return ['生效', '失效'][_row.status];
  398. }
  399. },
  400. {
  401. columnKey: 'action',
  402. label: '操作',
  403. align: 'center',
  404. resizable: false,
  405. slot: 'action',
  406. minWidth: 200,
  407. showOverflowTooltip: true
  408. }
  409. ],
  410. processData: [],
  411. removeList: [],
  412. where: {},
  413. currentTableData: [],
  414. typeList: [
  415. {
  416. value: 1,
  417. label: '普通工步'
  418. },
  419. {
  420. value: 2,
  421. label: '抽样质检工步'
  422. },
  423. {
  424. value: 3,
  425. label: '普通质检工步'
  426. },
  427. {
  428. value: 4,
  429. label: '包装工步'
  430. },
  431. {
  432. value: 5,
  433. label: '入库工步'
  434. },
  435. {
  436. value: 6,
  437. label: '一工一检(常规质检)'
  438. }
  439. ],
  440. showEdit: false,
  441. current: null,
  442. isView: false,
  443. controlList: []
  444. };
  445. },
  446. methods: {
  447. // 单个工步数据保存
  448. saveWorking(row) {
  449. if (!row.name) {
  450. this.$message.warning('请输入工步名称');
  451. return;
  452. }
  453. if (!row.sort) {
  454. this.$message.warning('请输入工步排序');
  455. return;
  456. }
  457. let data = {
  458. stepName: row.name,
  459. id: row.id,
  460. defaultValue: row.defaultValue,
  461. sort: row.sort
  462. };
  463. workingSingleUpdate(data)
  464. .then((res) => {
  465. if (res.data) {
  466. this.$message.success('保存成功');
  467. } else {
  468. this.$message.error('保存失败');
  469. }
  470. })
  471. .catch((err) => {
  472. console.log(err, 'err');
  473. });
  474. },
  475. validateNumber(e, row) {
  476. if (e == 0) {
  477. row.sort = '';
  478. return;
  479. }
  480. let value = '';
  481. value = e.replace(/[^\d]/g, '');
  482. if (value.startsWith('0') && value.length > 1) {
  483. value = value.replace(/^0+/, '');
  484. }
  485. row.sort = value;
  486. },
  487. // expandChange(row, rows) {
  488. // if (rows.length > 0) {
  489. // // 展开
  490. // console.log('展开');
  491. // getStepListById({
  492. // paramId: row.id,
  493. // bomCategoryId: this.taskParam.id
  494. // }).then((data) => {
  495. // row.produceList = data;
  496. // });
  497. // }
  498. // console.log(row);
  499. // console.log(rows);
  500. // },
  501. openConfigure(row, isView) {
  502. this.$refs.workingProcedureRef.open(
  503. row,
  504. this.taskParam,
  505. this.currentTableData,
  506. !!isView,
  507. this.attributeData,
  508. this.resourceBomId
  509. );
  510. },
  511. openStepConfigure(row, isView) {
  512. console.log('123123123', row);
  513. // this.$refs.workingStepRef.open(row, this.taskParam, !!isView);
  514. this.isView = !!isView;
  515. this.getControlList();
  516. this.current = row;
  517. this.showEdit = true;
  518. this.$refs.userEdit.$refs.form &&
  519. this.$refs.userEdit.$refs.form.clearValidate();
  520. },
  521. getControlList() {
  522. const params = {
  523. pageNum: 1,
  524. size: -1
  525. };
  526. control.list().then((res) => {
  527. this.controlList = res.list;
  528. });
  529. },
  530. search() {},
  531. /*配置工艺参数 */
  532. openSetting(row) {
  533. this.current = row;
  534. this.$refs.paramRefs.open(row.produceList, this.current);
  535. },
  536. openStepSetting(row) {
  537. getStepListById({
  538. paramId: row.id,
  539. bomCategoryId: this.taskParam.id
  540. }).then((data) => {
  541. this.$refs.stepModalRefs.open(data, row, '新增');
  542. });
  543. },
  544. /* 表格数据源 */
  545. async datasource({ page, limit, where }) {
  546. let data = await getMbomPage({
  547. ...where,
  548. bomCategoryId: this.resourceBomId,
  549. categoryCode: this.attributeData.categoryCode,
  550. pageNum: page,
  551. size: limit
  552. });
  553. if (data?.length > 0) {
  554. this.currentTableData = data[0];
  555. let dataList = [];
  556. if (data[0].taskParam.length != 0) {
  557. dataList = data[0].taskParam.sort(
  558. (it, ie) => Number(it.sort) - Number(ie.sort)
  559. );
  560. }
  561. return dataList;
  562. // return data[0].taskParam;
  563. } else {
  564. return [];
  565. }
  566. },
  567. editWorkingProcedure(row) {
  568. this.$refs.processModalRef.open(
  569. this.taskParam,
  570. this.currentTableData,
  571. '修改',
  572. row
  573. );
  574. },
  575. openEdit() {
  576. this.$refs.processModalRef.open(
  577. this.taskParam,
  578. this.currentTableData,
  579. '新增'
  580. );
  581. },
  582. editWorkingStep(row) {
  583. this.$refs.stepModalRefs.open([], row, '修改');
  584. },
  585. reload(where) {
  586. this.$refs.table.reload({ where });
  587. },
  588. chooseProcess(data) {
  589. // let _arr = [...data, ...this.$refs.table.getData()];
  590. // this.$refs.table.setData([...data, ...this.$refs.table.getData()]);
  591. // this.$emit('chooseProcess', _arr);
  592. this.reload();
  593. },
  594. chooseModal(data, current) {
  595. data.map((m) => {
  596. m.parentId = current.id;
  597. return {
  598. ...m
  599. };
  600. });
  601. let tableList = [];
  602. let clonedArray = [];
  603. tableList = this.$refs.table.getData();
  604. clonedArray = JSON.parse(JSON.stringify(tableList));
  605. clonedArray.forEach((e) => {
  606. if (e.id == current.id) {
  607. if (e.hasOwnProperty('produceList')) {
  608. e.produceList = [...e.produceList, ...data];
  609. } else {
  610. e.produceList = [...data];
  611. }
  612. }
  613. });
  614. this.$refs.table.setData([...clonedArray]);
  615. this.$emit('chooseProcess', clonedArray);
  616. this.$nextTick(() => {
  617. this.$refs.table.toggleRowExpansionAll();
  618. this.$forceUpdate();
  619. });
  620. },
  621. chooseStepModal(data, current) {
  622. if (data?.length > 0) {
  623. let params = data.map((item) => {
  624. const itemData = {
  625. ...item,
  626. paramId: current.id,
  627. stepId: item.id,
  628. categoryId: this.taskParam.categoryId,
  629. bomCategoryId: this.taskParam.id,
  630. categoryCode: this.taskParam.categoryCode
  631. };
  632. itemData.type = item.type.code;
  633. return itemData;
  634. });
  635. workingStepSave(params).then((data) => {
  636. this.$message.success('保存成功');
  637. this.reload();
  638. });
  639. }
  640. // this.reload();
  641. console.log(data);
  642. console.log(current);
  643. },
  644. /* 删除 */
  645. remove(row) {
  646. workingProcedureUpdate({
  647. id: this.currentTableData.id,
  648. categoryId: this.taskParam.categoryId,
  649. bomCategoryId: this.taskParam.id,
  650. categoryCode: this.taskParam.categoryCode,
  651. taskParam: this.currentTableData.taskParam.filter(
  652. (item) => item.id !== row.id
  653. )
  654. }).then((data) => {
  655. this.$message.success('删除成功');
  656. this.reload();
  657. });
  658. },
  659. remove2(row) {
  660. workingStepDelete([row.id]).then(() => {
  661. this.$message.success('删除成功');
  662. this.reload();
  663. });
  664. this.$forceUpdate();
  665. }
  666. }
  667. };
  668. </script>
  669. <style lang="scss">
  670. .workmanship {
  671. height: 100%;
  672. .el-card {
  673. height: 100%;
  674. .el-card__body {
  675. height: 100%;
  676. display: flex;
  677. flex-direction: column;
  678. overflow: auto;
  679. .table_list {
  680. flex: 1;
  681. display: flex;
  682. flex-direction: column;
  683. .el-table {
  684. flex: 1;
  685. overflow-y: auto !important;
  686. display: flex;
  687. flex-direction: column;
  688. .el-table__body-wrapper {
  689. flex: 1;
  690. }
  691. }
  692. }
  693. }
  694. }
  695. }
  696. </style>