index.vue 35 KB

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