index.vue 42 KB

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