index.vue 32 KB

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