index.vue 28 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026
  1. <template>
  2. <div class="ele-body">
  3. <el-card shadow="never" v-loading="loading">
  4. <seek-page :seekList="seekList" @search="search"></seek-page>
  5. <!-- <produceOrder-search @search="reload" ref="searchRef" :statusOpt="statusOpt" :planType="planType"
  6. :activeName="activeName">
  7. </produceOrder-search> -->
  8. <el-tabs v-model="tabValue" type="card" @tab-click="handleTabClick">
  9. <!-- <el-tab-pane label="未完成工单" name="first"></el-tab-pane>
  10. <el-tab-pane label="已完成工单" name="second"></el-tab-pane> -->
  11. <el-tab-pane label="生产中" name="5"></el-tab-pane>
  12. <el-tab-pane label="待生产" name="4"></el-tab-pane>
  13. <el-tab-pane label="已完成" name="6"></el-tab-pane>
  14. <el-tab-pane label="已延期" name="7"></el-tab-pane>
  15. </el-tabs>
  16. <!-- 数据表格 -->
  17. <ele-pro-table
  18. ref="table"
  19. :key="activeName"
  20. :initLoad="false"
  21. :columns="newColumns"
  22. :datasource="datasource"
  23. row-key="code"
  24. :cache-key="cacheKeyUrl"
  25. :selection.sync="selection"
  26. @sort-change="onSortChange"
  27. autoAmendPage
  28. :parse-data="parseData"
  29. @columns-change="handleColumnChange"
  30. >
  31. <template v-slot:toolbar>
  32. <!-- <el-button type="success">新建</el-button> -->
  33. <el-button type="success" @click="toPause()">暂停</el-button>
  34. <el-button type="success" @click="toTermination()">终止</el-button>
  35. <!-- <el-button type="primary">工单刷新</el-button> -->
  36. <!-- <el-button type="success" @click="handlePicking">领料</el-button> -->
  37. <el-button type="success" @click="toEnd()">批量完结</el-button>
  38. <!-- <el-button type="success" @click="handleCreate">创建工单</el-button> -->
  39. <!-- <el-button type="success">工单操作控制</el-button> -->
  40. <el-button type="success" @click="allPrinting()"
  41. >批量打印二维码</el-button
  42. >
  43. </template>
  44. <template v-slot:code="{ row }">
  45. <el-link type="primary" :underline="false" @click="goDetail(row)">
  46. {{ row.code }}
  47. </el-link>
  48. </template>
  49. <template v-slot:QRcode="{ row }">
  50. <el-link type="primary" :underline="false" @click="handleQRcode(row)"
  51. >生成二维码
  52. </el-link>
  53. </template>
  54. <template v-slot:apsWorkOrderCode="{ row }">
  55. <label>{{ row.apsWorkOrderCode || '' }}</label>
  56. </template>
  57. <template v-slot:priority="{ row }">
  58. <div style="display: flex">
  59. <el-input
  60. v-model="row.priority"
  61. type="number"
  62. size="mini"
  63. :min="0"
  64. :max="10"
  65. @change="priorityChange(row)"
  66. style="width: 80px"
  67. ></el-input>
  68. <el-popover
  69. placement="right"
  70. width="200"
  71. trigger="hover"
  72. content="数值越大优先级越高(0-3普通, 4-6优先, 7-10紧急)"
  73. >
  74. <div class="sort-wrap" slot="reference">
  75. <i class="el-icon-caret-top" @click="sortTop(row)"></i>
  76. <i class="el-icon-caret-bottom" @click="sortBottom(row)"></i>
  77. </div>
  78. </el-popover>
  79. </div>
  80. </template>
  81. <template v-slot:formingNum="{ row }">
  82. <span> {{ row.formingNum }} </span>
  83. </template>
  84. <template v-slot:formingWeight="{ row }">
  85. <span> {{ row.formingWeight }} {{ row.weightUnit }} </span>
  86. </template>
  87. <template v-slot:status="{ row }">
  88. <span :class="{ 'ele-text-danger': row.status == 3 }">
  89. {{ statusFormatter(row.status) }}
  90. </span>
  91. </template>
  92. <!-- 操作列 -->
  93. <template v-slot:action="{ row }">
  94. <template v-if="activeName == 'second'">
  95. <el-link
  96. type="primary"
  97. :underline="false"
  98. icon="el-icon-truck"
  99. v-if="row.status == 6"
  100. @click="toCancel(row)"
  101. >
  102. 取消完结
  103. </el-link></template
  104. >
  105. <el-link
  106. v-if="row.clientEnvironmentId == 21"
  107. type="primary"
  108. :underline="false"
  109. @click="routing(row)"
  110. >
  111. 更改工艺路线
  112. </el-link>
  113. <template>
  114. <el-link type="primary" :underline="false" @click="toView(row)">
  115. 序列号
  116. </el-link></template
  117. >
  118. <template v-if="activeName != 'second'">
  119. <el-link
  120. v-if="row.status == 4 && row.isSplit == 0"
  121. type="primary"
  122. :underline="false"
  123. icon="el-icon-truck"
  124. @click="handleOrderPublish(1, row)"
  125. >
  126. 报工
  127. </el-link>
  128. <el-link
  129. v-if="row.status == 4 && row.isSplit == 0"
  130. type="primary"
  131. :underline="false"
  132. @click="toUnpack(row)"
  133. >
  134. 拆分
  135. </el-link>
  136. <el-link
  137. v-if="row.status == 4 && row.isSplit == 0"
  138. type="primary"
  139. :underline="false"
  140. @click="toEnd(row)"
  141. >
  142. 完结
  143. </el-link>
  144. <el-link
  145. v-if="dispatchBtn(row)"
  146. type="primary"
  147. :underline="false"
  148. @click="toReleaseOpen(row)"
  149. >
  150. 派单
  151. </el-link>
  152. </template>
  153. </template>
  154. </ele-pro-table>
  155. </el-card>
  156. <print ref="printRef"></print>
  157. <printSr ref="printSrRef"></printSr>
  158. <printTg ref="printTgRef"></printTg>
  159. <createDialog ref="createRef" @success="createSuccess" />
  160. <unpackDialog ref="unpackRef" @success="createSuccess" />
  161. <pickingDialog ref="PickingRef" />
  162. <detailsPop ref="detailsRef"> </detailsPop>
  163. <EquipmentDialog ref="equipmentRef" @choose="choose"></EquipmentDialog>
  164. <xlhView ref="xlhRef"></xlhView>
  165. <releaseDialog
  166. ref="releaseRef"
  167. :current="dispatchRow"
  168. :dispatchVisible.sync="dispatchVisible"
  169. @createSuccess="createSuccess"
  170. v-if="dispatchVisible"
  171. />
  172. </div>
  173. </template>
  174. <script>
  175. import releaseDialog from './components/releaseDialog';
  176. import {
  177. getPage,
  178. batchCompletion,
  179. cancelCompletion,
  180. updatePriority,
  181. update,
  182. getTaskIdByInstanceId,
  183. updateStatusPause,
  184. updateStatusTerminate
  185. } from '@/api/produceOrder/index.js';
  186. import xlhView from './components/xlhView.vue';
  187. import { fieldModel } from '@/api/produceWord/index.js';
  188. import produceOrderSearch from './components/produceOrder-search.vue';
  189. import createDialog from './components/createDialog.vue';
  190. import unpackDialog from './components/unpackDialog.vue';
  191. import pickingDialog from './components/pickingDialog.vue';
  192. import print from './components/print.vue';
  193. import printSr from './components/printSr';
  194. import printTg from './components/printTg';
  195. import EquipmentDialog from './components/EquipmentDialog.vue';
  196. import detailsPop from './components/details/index.vue';
  197. import { debounce } from 'lodash';
  198. import tableColumnsMixin from '@/mixins/tableColumnsMixin';
  199. export default {
  200. mixins: [tableColumnsMixin],
  201. components: {
  202. releaseDialog,
  203. produceOrderSearch,
  204. pickingDialog,
  205. createDialog,
  206. unpackDialog,
  207. print,
  208. printSr,
  209. printTg,
  210. detailsPop,
  211. EquipmentDialog,
  212. xlhView
  213. },
  214. data() {
  215. return {
  216. activeName: 'first',
  217. tabValue: '5',
  218. id: '',
  219. where: {},
  220. // 加载状态
  221. loading: false,
  222. pageType: 'add',
  223. dialogTitle: '',
  224. isBindPlan: false,
  225. statusOpt: {
  226. first: [
  227. { label: '所有状态', value: '5,4' },
  228. { label: '待生产', value: '4' },
  229. { label: '生产中', value: '5' }
  230. // { label: '已延期', value: '7' }
  231. ],
  232. second: [{ label: '已完成', value: '6' }]
  233. },
  234. planType: [
  235. { label: '所有计划类型', value: null },
  236. { label: '内销计划', value: '1' },
  237. { label: '外销计划', value: '2' },
  238. { label: '预制计划', value: '3' }
  239. ],
  240. selection: [],
  241. newColumns: [],
  242. cacheKeyUrl: '7cc8e5d2-mes-produceOrder',
  243. columnsVersion: 0,
  244. dispatchVisible: false,
  245. dispatchRow: {}
  246. };
  247. },
  248. computed: {
  249. // 表格列配置
  250. seekList() {
  251. return [
  252. {
  253. label: '关键字:',
  254. value: 'keyWord',
  255. type: 'input',
  256. placeholder: ''
  257. },
  258. {
  259. label: '生产工单号:',
  260. value: 'code',
  261. type: 'input',
  262. placeholder: '',
  263. labelWidth: 100
  264. },
  265. {
  266. label: '生产订单号:',
  267. value: 'apsWorkOrderCode',
  268. type: 'input',
  269. labelWidth: 100
  270. },
  271. {
  272. label: '计划编码:',
  273. value: 'productionPlanCode',
  274. type: 'input',
  275. placeholder: ''
  276. },
  277. {
  278. label: '计划类型:',
  279. value: 'planType',
  280. type: 'select',
  281. placeholder: '',
  282. width: 240,
  283. // 加载状态
  284. planList: this.planType
  285. },
  286. {
  287. label: '工艺路线',
  288. value: 'produceRoutingName',
  289. type: 'input',
  290. placeholder: '',
  291. width: 240
  292. },
  293. {
  294. label: '产品编码',
  295. value: 'productCode',
  296. type: 'input',
  297. placeholder: '',
  298. width: 240
  299. },
  300. {
  301. label: '产品名称:',
  302. value: 'productName',
  303. type: 'input',
  304. placeholder: '',
  305. width: 240
  306. },
  307. {
  308. label: '牌号',
  309. value: 'brandNo',
  310. type: 'input',
  311. placeholder: '',
  312. width: 240
  313. },
  314. {
  315. label: '型号',
  316. value: 'model',
  317. type: 'input',
  318. placeholder: '',
  319. width: 240
  320. },
  321. // {
  322. // label: "状态:",
  323. // value: 'status',
  324. // type: "select",
  325. // placeholder: '',
  326. // width: 240,
  327. // // 加载状态
  328. // planList: this.statusOpt.first
  329. // },
  330. {
  331. label: '班组:',
  332. value: 'teamId',
  333. type: 'select',
  334. multiple: false, // 是否多选
  335. filterable: true, // 是否可搜索
  336. placeholder: '',
  337. width: 240,
  338. // 加载状态
  339. planList: this.statusOpt.first
  340. },
  341. {
  342. label: '创建时间:',
  343. value: 'createTime',
  344. type: 'date',
  345. dateType: 'daterange',
  346. placeholder: '',
  347. width: 240,
  348. // 加载状态
  349. planList: this.statusOpt.first
  350. }
  351. ];
  352. },
  353. columns() {
  354. const num = this.columnsVersion;
  355. const opt = {
  356. first: [
  357. // {
  358. // prop: 'deliveryTime',
  359. // label: '预测交货日期',
  360. // align: 'center',
  361. // showOverflowTooltip: true,
  362. // minWidth: 110
  363. // }
  364. ],
  365. second: [
  366. {
  367. prop: 'completeTime',
  368. label: '完成时间',
  369. align: 'center'
  370. },
  371. {
  372. prop: 'cycle',
  373. label: '生产周期',
  374. align: 'center'
  375. }
  376. ]
  377. };
  378. return [
  379. {
  380. width: 45,
  381. type: 'selection',
  382. columnKey: 'selection',
  383. align: 'center',
  384. fixed: 'left'
  385. },
  386. // {
  387. // prop: 'batchNo',
  388. // label: '批次号',
  389. // align: 'center',
  390. // minWidth: 130
  391. // },
  392. {
  393. slot: 'code',
  394. label: '生产工单号',
  395. align: 'center',
  396. minWidth: 110
  397. },
  398. // {
  399. // prop: 'originalCode',
  400. // label: '原始工单号',
  401. // align: 'center',
  402. // minWidth: 110
  403. // },
  404. {
  405. slot: 'QRcode',
  406. label: '二维码',
  407. align: 'center',
  408. minWidth: 110
  409. },
  410. {
  411. label: '生产订单号',
  412. slot: 'apsWorkOrderCode',
  413. align: 'center',
  414. minWidth: 110
  415. },
  416. {
  417. prop: 'productionPlanCode',
  418. label: '计划编号',
  419. align: 'center',
  420. minWidth: 110
  421. },
  422. {
  423. prop: 'planType',
  424. label: '计划类型',
  425. align: 'center',
  426. formatter: (row) => {
  427. const obj = this.planType.find((i) => i.value == row.planType);
  428. return obj && obj.label;
  429. }
  430. },
  431. {
  432. prop: 'produceRoutingName',
  433. label: '工艺路线',
  434. align: 'center'
  435. },
  436. {
  437. prop: 'productCode',
  438. label: '编码',
  439. align: 'center'
  440. },
  441. {
  442. prop: 'productName',
  443. label: '名称',
  444. align: 'center'
  445. },
  446. {
  447. prop: 'model',
  448. label: '型号',
  449. align: 'center'
  450. },
  451. {
  452. prop: 'productionCodes',
  453. label: '生产编号',
  454. align: 'center',
  455. minWidth: 150,
  456. showOverflowTooltip: true
  457. },
  458. {
  459. prop: 'brandNo',
  460. label: '牌号',
  461. align: 'center'
  462. },
  463. {
  464. prop: 'priority',
  465. label: '优先级',
  466. align: 'center',
  467. minWidth: 120,
  468. slot: 'priority',
  469. sortable: 'custom'
  470. },
  471. {
  472. prop: 'formingNum',
  473. label: '要求生产数量',
  474. align: 'center',
  475. slot: 'formingNum',
  476. showOverflowTooltip: true,
  477. minWidth: 110
  478. },
  479. {
  480. prop: 'formingWeight',
  481. label: '要求生产重量',
  482. slot: 'formingWeight',
  483. align: 'center',
  484. showOverflowTooltip: true,
  485. minWidth: 110
  486. },
  487. {
  488. prop: 'formedNum',
  489. label: '已生产数量',
  490. align: 'center',
  491. showOverflowTooltip: true,
  492. minWidth: 110
  493. },
  494. {
  495. prop: 'formedWeight',
  496. label: '已生产重量',
  497. align: 'center',
  498. showOverflowTooltip: true,
  499. minWidth: 110
  500. },
  501. {
  502. prop: 'planStartTime',
  503. label: '计划开始时间',
  504. align: 'center',
  505. showOverflowTooltip: true,
  506. minWidth: 150,
  507. sortable: 'custom'
  508. },
  509. {
  510. prop: 'planCompleteTime',
  511. label: '计划结束时间',
  512. align: 'center',
  513. showOverflowTooltip: true,
  514. minWidth: 150,
  515. sortable: 'custom'
  516. },
  517. {
  518. prop: 'startTime',
  519. label: '实际开始时间',
  520. align: 'center',
  521. showOverflowTooltip: true,
  522. minWidth: 150,
  523. sortable: 'custom'
  524. },
  525. ...opt[this.activeName],
  526. {
  527. prop: 'createTime',
  528. label: '创建时间',
  529. align: 'center',
  530. showOverflowTooltip: true,
  531. minWidth: 150,
  532. sortable: 'custom'
  533. },
  534. // {
  535. // prop: 'status',
  536. // slot: 'status',
  537. // label: '状态',
  538. // align: 'center',
  539. // formatter: (row) => {
  540. // const obj = this.statusOpt[this.activeName].find(
  541. // (i) => i.value == row.status
  542. // );
  543. // return obj && obj.label;
  544. // }
  545. // },
  546. {
  547. prop: 'deviceName',
  548. slot: 'deviceName',
  549. label: '设备名称',
  550. align: 'center',
  551. showOverflowTooltip: true
  552. },
  553. {
  554. prop: 'crewNames',
  555. slot: 'crewNames',
  556. label: '报工人员',
  557. align: 'center',
  558. showOverflowTooltip: true
  559. },
  560. {
  561. prop: 'teamName',
  562. label: '班组',
  563. align: 'center',
  564. showOverflowTooltip: true
  565. }
  566. ];
  567. },
  568. dispatchBtn() {
  569. return (row) => {
  570. return !!row.taskId;
  571. };
  572. },
  573. clientEnvironmentId() {
  574. return this.$store.state.user.info.clientEnvironmentId;
  575. }
  576. },
  577. watch: {
  578. activeName: {
  579. handler() {
  580. if (this.activeName) {
  581. this.where.status = this.statusOpt[this.activeName][0].value;
  582. this.reload();
  583. }
  584. },
  585. immediate: true
  586. },
  587. tabValue: {
  588. handler(newVal) {
  589. if (newVal === '6') {
  590. this.newColumns.splice(3, 1);
  591. } else {
  592. if (this.newColumns[3].label !== '生产订单号') {
  593. this.newColumns.splice(3, 0, {
  594. label: '生产订单号',
  595. slot: 'apsWorkOrderCode',
  596. align: 'center',
  597. minWidth: 110
  598. });
  599. }
  600. }
  601. },
  602. immediate: true
  603. }
  604. },
  605. created() {
  606. this.getFieldModel();
  607. },
  608. mounted() {
  609. this.reload();
  610. },
  611. methods: {
  612. //派单
  613. toReleaseOpen(row) {
  614. getTaskIdByInstanceId(row.taskId)
  615. .then((res) => {
  616. if (res) {
  617. this.dispatchRow = { ...row };
  618. this.dispatchRow.initialWeight = row.formingWeight
  619. ? row.formingWeight + row.weightUnit
  620. : '';
  621. this.dispatchRow.taskInstanceId = res;
  622. this.dispatchVisible = true;
  623. }
  624. })
  625. .catch((err) => {
  626. this.$message.error(err.message);
  627. });
  628. },
  629. search(e) {
  630. if (Array.isArray(e.createTime) && e.createTime.length) {
  631. e.createTimeStart = e.createTime[0];
  632. e.createTimeEnd = e.createTime[1];
  633. }
  634. this.reload(e);
  635. },
  636. // 查看序列号
  637. toView(row) {
  638. this.$refs.xlhRef.open(row);
  639. },
  640. handlePicking() {
  641. this.$router.push({
  642. path: '/produceOrder/picking'
  643. });
  644. },
  645. statusFormatter(status) {
  646. const obj = this.statusOpt[this.activeName].find(
  647. (i) => i.value == status
  648. );
  649. return obj && obj.label;
  650. },
  651. routing(row) {
  652. this.id = row.id;
  653. this.$refs.equipmentRef.open();
  654. },
  655. handleTabClick() {
  656. if (this.tabValue == '6') {
  657. this.activeName = 'second';
  658. } else {
  659. this.activeName = 'first';
  660. }
  661. this.reload();
  662. },
  663. /* 表格数据源 */
  664. async datasource({ page, limit, where, order }) {
  665. // console.log('1123',where)
  666. where.statusList = [this.tabValue];
  667. let res = await getPage({
  668. ...where,
  669. ...order,
  670. pageNum: page,
  671. size: limit,
  672. ...this.sort
  673. });
  674. // res['list'] = this.flattenArray(res.list)
  675. return res;
  676. },
  677. onSortChange(e) {
  678. let sort = {
  679. orderBy: e.order,
  680. sortName: e.prop
  681. };
  682. this.sort = sort;
  683. this.reload();
  684. },
  685. flattenArray(arr) {
  686. var result = []; // 存放结果的数组
  687. for (let i = 0; i < arr.length; i++) {
  688. if (Array.isArray(arr[i].subWorkOrder)) {
  689. let _arr = [];
  690. _arr = _arr.concat(arr[i].subWorkOrder);
  691. delete arr[i].subWorkOrder;
  692. result.push(arr[i]);
  693. result.push(..._arr);
  694. } else {
  695. result.push(arr[i]);
  696. }
  697. }
  698. return result;
  699. },
  700. /* 数据转为树形结构 */
  701. parseData(data) {
  702. return {
  703. ...data,
  704. list: this.$util.toTreeData({
  705. data: data.list,
  706. count: data.total,
  707. idField: 'code',
  708. parentIdField: 'originalCode'
  709. })
  710. };
  711. },
  712. /* 数据转为树形结构 */
  713. createSuccess() {
  714. this.reload();
  715. },
  716. handleCreate() {
  717. this.$refs.createRef.open(0);
  718. },
  719. // 发布工单
  720. handleOrderPublish(type, row) {
  721. // this.$router.push({
  722. // path: '/produce',
  723. // query: {
  724. // workOrderId: row.id
  725. // }
  726. // });
  727. this.$router.push({
  728. path: '/produceOrder/workReport',
  729. query: {
  730. workOrderId: row.id
  731. }
  732. });
  733. },
  734. getFieldModel() {
  735. fieldModel({ fieldModel: 't_main_category' }).then((res) => {
  736. const privateColumn = [
  737. {
  738. columnKey: 'action',
  739. label: '操作',
  740. width: 250,
  741. align: 'center',
  742. resizable: false,
  743. fixed: 'right',
  744. slot: 'action',
  745. showOverflowTooltip: true
  746. }
  747. ];
  748. let newRes = res.map((m) => {
  749. return {
  750. prop: 'extField.' + m.prop,
  751. label: m.label,
  752. align: 'center',
  753. showOverflowTooltip: true
  754. };
  755. });
  756. this.newColumns = [...this.columns, ...newRes, ...privateColumn];
  757. this.getTabColumns();
  758. this.$forceUpdate();
  759. });
  760. },
  761. toPause() {
  762. if (!this.selection.length) {
  763. return this.$message.warning('请至少选择一条工单!');
  764. }
  765. let ids = [];
  766. this.selection.forEach((item) => {
  767. ids.push(item.id);
  768. });
  769. this.$confirm(`是否要暂停工单?`, '提醒', {
  770. confirmButtonText: '确认',
  771. cancelButtonText: '取消',
  772. type: 'warning'
  773. })
  774. .then(() => {
  775. updateStatusPause(ids).then((res) => {
  776. this.$message.success('成功');
  777. this.reload();
  778. });
  779. })
  780. .catch(() => {});
  781. },
  782. toTermination() {
  783. if (!this.selection.length) {
  784. return this.$message.warning('请至少选择一条工单!');
  785. }
  786. let ids = [];
  787. this.selection.forEach((item) => {
  788. ids.push(item.id);
  789. });
  790. this.$confirm(`是否要终止工单?`, '提醒', {
  791. confirmButtonText: '确认',
  792. cancelButtonText: '取消',
  793. type: 'warning'
  794. })
  795. .then(() => {
  796. updateStatusTerminate(ids).then((res) => {
  797. this.$message.success('成功');
  798. this.reload();
  799. });
  800. })
  801. .catch(() => {});
  802. },
  803. // 完结与批量完结
  804. toEnd(row) {
  805. if (row) {
  806. this.$confirm(`是否要完结工单【${row.code}】?`, '提醒', {
  807. confirmButtonText: '确认',
  808. cancelButtonText: '取消',
  809. type: 'warning'
  810. })
  811. .then(() => {
  812. batchCompletion([row.id]).then((res) => {
  813. this.$message.success('成功');
  814. this.reload();
  815. });
  816. })
  817. .catch(() => {});
  818. } else {
  819. if (!this.selection.length) {
  820. return this.$message.warning('请至少选择一条工单!');
  821. }
  822. const ids = [];
  823. this.selection.map((item) => {
  824. ids.push(item.id);
  825. });
  826. const h = this.$createElement;
  827. this.$msgbox({
  828. title: '提醒',
  829. message: h('p', null, [
  830. h('span', null, '是否要完结 '),
  831. h(
  832. 'span',
  833. { style: 'color: #70B603' },
  834. `${this.selection.length}`
  835. ),
  836. h('span', null, ' 条工单?')
  837. ]),
  838. showCancelButton: true,
  839. confirmButtonText: '确认',
  840. cancelButtonText: '取消',
  841. type: 'warning'
  842. })
  843. .then(() => {
  844. batchCompletion(ids).then((res) => {
  845. this.$message.success('成功');
  846. this.reload();
  847. });
  848. })
  849. .catch(() => {});
  850. }
  851. },
  852. // 取消完结
  853. toCancel(row) {
  854. cancelCompletion([row.id]).then((res) => {
  855. this.$message.success('成功');
  856. this.reload();
  857. });
  858. },
  859. // 拆分
  860. toUnpack(row) {
  861. this.$refs.unpackRef.open(row);
  862. },
  863. handleTabChange() {
  864. this.$refs.searchRef.reset();
  865. },
  866. /* 刷新表格 */
  867. reload(where = {}) {
  868. this.$nextTick(() => {
  869. where.statusList = (
  870. where.status || this.statusOpt[this.activeName][0].value
  871. ).split(',');
  872. this.$refs.table.reload({ page: 1, where });
  873. });
  874. },
  875. // 生产工单跳转
  876. goDetail(row) {
  877. this.$refs.detailsRef.open(row);
  878. },
  879. handleDelete({ id }) {
  880. this.$confirm('确定删除当前数据?', '提示').then(async () => {
  881. await del(id);
  882. this.$message.success('删除成功!');
  883. this.reload();
  884. });
  885. },
  886. handleQRcode(row) {
  887. if (this.clientEnvironmentId == 2) {
  888. this.$refs.printSrRef.open([row.id]);
  889. } else if (this.clientEnvironmentId == 3) {
  890. this.$refs.printTgRef.open([row.id]);
  891. } else {
  892. this.$refs.printRef.open([row.id]);
  893. }
  894. },
  895. allPrinting() {
  896. let ids = this.findAllIds(this.selection);
  897. if (this.clientEnvironmentId == 2) {
  898. this.$refs.printSrRef.open(ids);
  899. } else if (this.clientEnvironmentId == 3) {
  900. this.$refs.printTgRef.open(ids);
  901. } else {
  902. this.$refs.printRef.open(ids);
  903. }
  904. },
  905. findAllIds(nodes) {
  906. let ids = [];
  907. nodes.forEach((node) => {
  908. ids.push(node.id); // 添加当前节点的id
  909. if (node.children && node.children.length > 0) {
  910. // 递归调用自身来处理子节点
  911. ids = ids.concat(this.findAllIds(node.children));
  912. }
  913. });
  914. return ids;
  915. },
  916. choose(row) {
  917. this.updateFn(row);
  918. },
  919. async updateFn(row) {
  920. let req = {
  921. id: this.id, //工艺路线id false
  922. produceRoutingId: row[0].id, //工艺路线id false
  923. produceRoutingName: row[0].name
  924. };
  925. const res = await update(req);
  926. this.reload();
  927. },
  928. sortTop(row) {
  929. row.priority = Number(row.priority) + 1;
  930. this.priorityChange(row);
  931. },
  932. sortBottom(row) {
  933. if (row.priority <= 1) {
  934. return;
  935. }
  936. row.priority = Number(row.priority) - 1;
  937. this.priorityChange(row);
  938. },
  939. priorityChange(row) {
  940. if (row.priority > 10) {
  941. row.priority = 10; // 如果大于 10,则设置为 10
  942. } else if (row.priority < 0) {
  943. row.priority = 0; // 如果小于 0,则设置为 0
  944. }
  945. this.priorityFn(row);
  946. },
  947. priorityFn: debounce(function (row) {
  948. let params = {
  949. id: row.id,
  950. priority: row.priority
  951. };
  952. updatePriority(params).then((res) => {});
  953. }, 800)
  954. }
  955. };
  956. </script>