index.vue 31 KB

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