index.vue 32 KB

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