index.vue 33 KB

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