index.vue 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920
  1. <template>
  2. <div class="ele-body">
  3. <el-card v-loading="loading" shadow="never">
  4. <order-search ref="searchRef" @search="reload"></order-search>
  5. <!-- <el-tabs v-model="activeName" type="card">
  6. <el-tab-pane label="未完成工单" name="first"></el-tab-pane>
  7. <el-tab-pane label="已完成工单" name="second"></el-tab-pane>
  8. </el-tabs> -->
  9. <!-- 数据表格 -->
  10. <!-- <plan-statistics></plan-statistics> -->
  11. <!-- <ele-pro-table
  12. ref="table"
  13. :columns="newColumns"
  14. :datasource="datasource"
  15. cache-key="workOrderTable"
  16. row-key="code"
  17. @sort-change="onSortChange"
  18. height="calc(100vh - 380px)"
  19. autoAmendPage
  20. :parse-data="parseData"
  21. > -->
  22. <ele-pro-table
  23. ref="table"
  24. :cache-key="cacheKeyUrl"
  25. :columns="newColumns"
  26. :datasource="datasource"
  27. :parse-data="parseData"
  28. autoAmendPage
  29. cache-key="workOrderTable"
  30. row-key="id"
  31. @sort-change="onSortChange"
  32. @columns-change="handleColumnChange"
  33. @select-all="selectAll"
  34. default-expand-all
  35. >
  36. <!-- :key="activeName" -->
  37. <!-- :selection.sync="selection" -->
  38. <!-- @update:selection="handleSelectionChange" -->
  39. <template v-slot:toolbar>
  40. <el-button
  41. class="ele-btn-icon"
  42. icon="el-icon-truck"
  43. size="small"
  44. type="primary"
  45. v-if="$hasPermission('aps:batchReleaseWorkOrder:release')"
  46. @click="batchDispatch"
  47. >批量派单
  48. <!-- -->
  49. </el-button>
  50. </template>
  51. <template v-slot:selection="{ row }">
  52. <el-checkbox
  53. :disabled="!dispatchPermission(row)"
  54. :value="checkRowData(row)"
  55. class="batch_checked"
  56. @change="(e) => selectRow(e, row)"
  57. ></el-checkbox>
  58. </template>
  59. <template v-slot:code="{ row }">
  60. <el-link type="primary" :underline="false" style="padding-left: 16px">
  61. <el-tag type="success" size="mini" v-if="row.originalCode">
  62. 拆</el-tag
  63. >
  64. {{ row.code }}
  65. </el-link>
  66. </template>
  67. <template v-slot:formingWeight="{ row }">
  68. {{ row.formingWeight }} {{ row.newWeightUnit }}
  69. </template>
  70. <template v-slot:priority="{ row }">
  71. <div style="display: flex">
  72. <el-input
  73. v-model="row.priority"
  74. :max="10"
  75. :min="0"
  76. size="mini"
  77. style="width: 80px"
  78. type="number"
  79. @change="priorityChange(row)"
  80. ></el-input>
  81. <el-popover
  82. content="数值越大优先级越高(0-3普通, 4-6优先, 7-10紧急)"
  83. placement="right"
  84. trigger="hover"
  85. width="200"
  86. >
  87. <div slot="reference" class="sort-wrap">
  88. <i class="el-icon-caret-top" @click="sortTop(row)"></i>
  89. <i class="el-icon-caret-bottom" @click="sortBottom(row)"></i>
  90. </div>
  91. </el-popover>
  92. </div>
  93. </template>
  94. <template v-slot:status="{ row }">
  95. <span :class="{ 'ele-text-danger': row.status == 3 }">
  96. {{ statusFormatter(row.status) }}
  97. </span>
  98. </template>
  99. <!-- 操作列 -->
  100. <template v-slot:selectionHeader="{ column }">
  101. <span>123</span>
  102. </template>
  103. <template v-slot:action="{ row }">
  104. <el-link
  105. v-if="unpackShow(row)"
  106. :underline="false"
  107. type="primary"
  108. @click="toUnpack(row)"
  109. >
  110. 拆单
  111. </el-link>
  112. <el-link
  113. v-if="dispatchPermission(row)"
  114. :underline="false"
  115. icon="el-icon-truck"
  116. type="primary"
  117. @click="toReleaseOpen(row)"
  118. >
  119. 派单
  120. </el-link>
  121. <el-popconfirm
  122. class="ele-action"
  123. title="确定要删除此子单吗?"
  124. @confirm="remove(row)"
  125. v-if="removeShow(row)"
  126. >
  127. <template v-slot:reference>
  128. <el-link type="danger" :underline="false" icon="el-icon-delete">
  129. 删除
  130. </el-link>
  131. </template>
  132. </el-popconfirm>
  133. </template>
  134. </ele-pro-table>
  135. </el-card>
  136. <!-- <el-dialog :visible.sync="visible" title="派单" width="500px">-->
  137. <!-- <el-form-->
  138. <!-- ref="form"-->
  139. <!-- :model="form"-->
  140. <!-- :rules="rules"-->
  141. <!-- label-position="left"-->
  142. <!-- label-width="100px"-->
  143. <!-- >-->
  144. <!-- <el-form-item label="报工类型:" prop="singleReport">-->
  145. <!-- <el-radio-group v-model="form.singleReport">-->
  146. <!-- <el-radio v-if="clientEnvironmentId != 2" :label="1"-->
  147. <!-- >单件报工-->
  148. <!-- </el-radio>-->
  149. <!-- <el-radio :label="0">批量报工</el-radio>-->
  150. <!-- </el-radio-group>-->
  151. <!-- </el-form-item>-->
  152. <!-- <el-form-item label="指定:" prop="assignType">-->
  153. <!-- <el-radio-group-->
  154. <!-- v-model="form.assignType"-->
  155. <!-- size="mini"-->
  156. <!-- @change="assignTypeFn"-->
  157. <!-- >-->
  158. <!-- <el-radio-button :label="1">工位</el-radio-button>-->
  159. <!-- <el-radio-button :label="2">人员</el-radio-button>-->
  160. <!-- </el-radio-group>-->
  161. <!-- </el-form-item>-->
  162. <!-- <el-form-item label="班组:" prop="teamId">-->
  163. <!-- <el-select-->
  164. <!-- v-model="form.teamId"-->
  165. <!-- class="ele-block"-->
  166. <!-- filterable-->
  167. <!-- placeholder="请选择班组"-->
  168. <!-- size="mini"-->
  169. <!-- @change="stationChange"-->
  170. <!-- >-->
  171. <!-- <el-option-->
  172. <!-- v-for="item in teamsList"-->
  173. <!-- :key="item.id"-->
  174. <!-- :label="item.name + '(' + item.code + ')'"-->
  175. <!-- :value="item.id"-->
  176. <!-- >-->
  177. <!-- </el-option>-->
  178. <!-- </el-select>-->
  179. <!-- </el-form-item>-->
  180. <!-- <el-form-item-->
  181. <!-- v-if="form.assignType == 1"-->
  182. <!-- label="工位:"-->
  183. <!-- prop="workstationIds"-->
  184. <!-- >-->
  185. <!-- <el-select-->
  186. <!-- v-model="form.workstationIds"-->
  187. <!-- class="ele-block"-->
  188. <!-- filterable-->
  189. <!-- multiple-->
  190. <!-- placeholder="请选择工位"-->
  191. <!-- size="mini"-->
  192. <!-- >-->
  193. <!-- <el-option-->
  194. <!-- v-for="item in stationList"-->
  195. <!-- :key="item.id"-->
  196. <!-- :label="item.name + '(' + item.code + ')'"-->
  197. <!-- :value="item.id"-->
  198. <!-- >-->
  199. <!-- </el-option>-->
  200. <!-- </el-select>-->
  201. <!-- </el-form-item>-->
  202. <!-- <el-form-item v-if="form.assignType == 2" label="人员:" prop="crewIds">-->
  203. <!-- <el-select-->
  204. <!-- v-model="form.crewIds"-->
  205. <!-- class="ele-block"-->
  206. <!-- filterable-->
  207. <!-- multiple-->
  208. <!-- placeholder="请选择人员"-->
  209. <!-- size="mini"-->
  210. <!-- >-->
  211. <!-- <el-option-->
  212. <!-- v-for="item in crewList"-->
  213. <!-- :key="item.id"-->
  214. <!-- :label="item.name"-->
  215. <!-- :value="item.id"-->
  216. <!-- >-->
  217. <!-- </el-option>-->
  218. <!-- </el-select>-->
  219. <!-- </el-form-item>-->
  220. <!-- </el-form>-->
  221. <!-- <div slot="footer" class="footer">-->
  222. <!-- <el-button @click="close">取消</el-button>-->
  223. <!-- <el-button v-click-once type="primary" @click="confirm">确定</el-button>-->
  224. <!-- </div>-->
  225. <!-- </el-dialog>-->
  226. <unpackDialog ref="unpackRef" @success="createSuccess" />
  227. <releaseDialog
  228. v-if="dispatchVisible"
  229. ref="releaseRef"
  230. :current="dispatchRow"
  231. :dispatchVisible.sync="dispatchVisible"
  232. @createSuccess="createSuccess"
  233. />
  234. <BatchDialog ref="batchRef" @createSuccess="createSuccess" />
  235. </div>
  236. </template>
  237. <script>
  238. import {
  239. getList,
  240. releaseWorkOrder,
  241. updatePriority,
  242. unpackDel
  243. } from '@/api/workOrder/index.js';
  244. import {
  245. listByFirstTaskId,
  246. listByWorkCenterId,
  247. listUserByIds
  248. } from '@/api/mainData/index.js';
  249. import OrderSearch from './components/order-search.vue';
  250. import unpackDialog from './components/unpackDialog.vue';
  251. import releaseDialog from './components/releaseDialog.vue';
  252. import { fieldModel } from '@/api/saleOrder';
  253. import { debounce } from 'lodash';
  254. import PlanStatistics from '@/components/statistics/PlanStatistics.vue';
  255. import tabMixins from '@/mixins/tableColumnsMixin';
  256. import BatchDialog from '@/views/workOrder/components/batchDialog.vue';
  257. export default {
  258. mixins: [tabMixins],
  259. components: {
  260. PlanStatistics,
  261. OrderSearch,
  262. unpackDialog,
  263. releaseDialog,
  264. BatchDialog
  265. },
  266. data() {
  267. return {
  268. visible: false,
  269. loading: false,
  270. form: {
  271. assignType: 1,
  272. crewIds: '',
  273. workstationIds: '',
  274. teamId: '',
  275. singleReport: ''
  276. },
  277. rules: {
  278. singleReport: [
  279. {
  280. required: true,
  281. message: '请选择报工类型',
  282. trigger: ['blur', 'change']
  283. }
  284. ],
  285. workstationIds: [
  286. {
  287. required: true,
  288. message: '请选择工位',
  289. trigger: ['blur']
  290. }
  291. ],
  292. teamId: [
  293. {
  294. required: true,
  295. message: '请选择班组',
  296. trigger: ['blur']
  297. }
  298. ]
  299. },
  300. teamList: [],
  301. statusOpt: [
  302. { label: '待生产', value: 4 },
  303. { label: '生产中', value: 5 },
  304. { label: '待下达', value: 8 }
  305. ],
  306. newColumns: [],
  307. stationList: [],
  308. teamsList: [],
  309. crewList: [],
  310. current: null,
  311. cacheKeyUrl: '3cbbdff9-aps-workOrder',
  312. columnsVersion: 1,
  313. dispatchRow: {},
  314. dispatchVisible: false,
  315. selectionMap: {}
  316. };
  317. },
  318. computed: {
  319. // 派单按钮显示
  320. dispatchPermission() {
  321. return (row) => {
  322. if (!row.firstTaskId) {
  323. return false;
  324. }
  325. return (
  326. (row.isSplit != 1 &&
  327. this.clientEnvironmentId != '4' &&
  328. row.status == 8) ||
  329. (this.clientEnvironmentId == '4' &&
  330. !row.productName.includes('板材') &&
  331. row.status == 8)
  332. );
  333. };
  334. },
  335. // 删除按钮显示
  336. removeShow() {
  337. return (row) => {
  338. return row.originalCode && !row.mesStatus;
  339. };
  340. },
  341. // 拆单按钮显示
  342. unpackShow() {
  343. return (row) => {
  344. if (row.originalCode) return false;
  345. return (
  346. (this.clientEnvironmentId != '4' && row.status == 8) ||
  347. (this.clientEnvironmentId == '4' &&
  348. !row.productName.includes('板材') &&
  349. row.status == 8)
  350. );
  351. };
  352. },
  353. teamId() {
  354. return this.$store.state.user.info.teamId;
  355. },
  356. clientEnvironmentId() {
  357. return this.$store.state.user.info.clientEnvironmentId;
  358. },
  359. // 表格列配置
  360. columns() {
  361. // const num = this.columnsVersion;
  362. return [
  363. {
  364. width: 45,
  365. type: 'selection',
  366. columnKey: 'selection',
  367. align: 'center',
  368. slot: 'selection',
  369. fixed: 'left',
  370. headerSlot: 'selectionHeader'
  371. // selectable: (row, index) => {
  372. // if (row.children) {
  373. // }
  374. // return this.dispatchPermission(row);
  375. // }
  376. },
  377. {
  378. columnKey: 'index',
  379. slot: 'index',
  380. label: '序号',
  381. type: 'index',
  382. width: 55,
  383. align: 'center',
  384. showOverflowTooltip: true,
  385. fixed: 'left'
  386. },
  387. {
  388. slot: 'code',
  389. label: '生产订单号',
  390. align: 'center',
  391. minWidth: 220,
  392. sortable: true
  393. },
  394. {
  395. prop: 'taskName',
  396. action: 'taskName',
  397. label: '工序进度',
  398. align: 'center',
  399. minWidth: 160
  400. },
  401. {
  402. prop: 'mesStatusName',
  403. label: '状态',
  404. align: 'center',
  405. minWidth: 160
  406. },
  407. {
  408. prop: 'productionPlanCode',
  409. label: '计划编号',
  410. align: 'center',
  411. minWidth: 150
  412. },
  413. {
  414. prop: 'productType',
  415. label: '生产类型',
  416. align: 'center',
  417. width: 120,
  418. formatter: (row) => {
  419. if (row.produceType == 2) {
  420. return '加工(MBOM)';
  421. }
  422. if (row.produceType == 3) {
  423. return '装配(ABOM)';
  424. }
  425. return '';
  426. }
  427. },
  428. {
  429. prop: 'bomCategoryName',
  430. label: 'BOM版本',
  431. align: 'center',
  432. width: 130,
  433. showOverflowTooltip: true,
  434. formatter: (row) => {
  435. if (row.bomCategoryName) {
  436. return `${row.bomCategoryName} (V${row.bomCategoryVersions}.0)`;
  437. }
  438. return '';
  439. }
  440. },
  441. {
  442. prop: 'produceRoutingName',
  443. label: '工艺路线',
  444. align: 'center',
  445. minWidth: 170
  446. },
  447. {
  448. prop: 'productCode',
  449. label: '编码',
  450. align: 'center',
  451. minWidth: 120
  452. },
  453. {
  454. prop: 'productName',
  455. label: '名称',
  456. align: 'center',
  457. minWidth: 170
  458. },
  459. {
  460. prop: 'productionCodes',
  461. label: '生产编号',
  462. align: 'center',
  463. minWidth: 150,
  464. showOverflowTooltip: true
  465. },
  466. {
  467. prop: 'brandNo',
  468. label: '牌号',
  469. align: 'center'
  470. },
  471. {
  472. prop: 'batchNo',
  473. label: '批次号',
  474. align: 'center',
  475. minWidth: 100,
  476. showOverflowTooltip: true
  477. },
  478. {
  479. prop: 'model',
  480. label: '型号',
  481. align: 'center',
  482. showOverflowTooltip: true
  483. },
  484. {
  485. prop: 'priority',
  486. label: '优先级',
  487. align: 'center',
  488. minWidth: 120,
  489. slot: 'priority',
  490. sortable: 'custom'
  491. },
  492. {
  493. prop: 'formingNum',
  494. label: '要求生产数量',
  495. align: 'center',
  496. showOverflowTooltip: true,
  497. minWidth: 110
  498. },
  499. {
  500. prop: 'formingWeight',
  501. label: '要求生产重量',
  502. align: 'center',
  503. showOverflowTooltip: true,
  504. minWidth: 110,
  505. slot: 'formingWeight'
  506. },
  507. {
  508. prop: 'planStartTime',
  509. label: '计划开始时间',
  510. align: 'center',
  511. showOverflowTooltip: true,
  512. minWidth: 110
  513. },
  514. {
  515. prop: 'planCompleteTime',
  516. label: '计划结束时间',
  517. align: 'center',
  518. showOverflowTooltip: true,
  519. minWidth: 110
  520. },
  521. {
  522. prop: 'workCenterName',
  523. label: '工作中心',
  524. align: 'center',
  525. minWidth: 110,
  526. showOverflowTooltip: true
  527. },
  528. {
  529. prop: 'firstTaskName',
  530. label: '首工序',
  531. align: 'center',
  532. minWidth: 110,
  533. showOverflowTooltip: true
  534. },
  535. {
  536. prop: 'createTime',
  537. label: '创建时间',
  538. align: 'center',
  539. showOverflowTooltip: true,
  540. minWidth: 110,
  541. sortable: 'custom'
  542. },
  543. // {
  544. // slot: 'status',
  545. // label: '状态',
  546. // align: 'center',
  547. // formatter: (row) => {
  548. // const obj = this.statusOpt.find((i) => i.value == row.status);
  549. // return obj && obj.label;
  550. // }
  551. // },
  552. {
  553. prop: 'customerName',
  554. label: '客户名称',
  555. align: 'center',
  556. showOverflowTooltip: true
  557. },
  558. {
  559. prop: 'serialNo',
  560. label: '客户代号',
  561. align: 'center',
  562. showOverflowTooltip: true
  563. },
  564. {
  565. prop: 'simpleName',
  566. label: '客户简称',
  567. align: 'center',
  568. showOverflowTooltip: true
  569. }
  570. ];
  571. },
  572. checkRowData() {
  573. return (row) => {
  574. return row.checkedata ? true : false;
  575. };
  576. }
  577. },
  578. created() {
  579. this.getFieldModel();
  580. },
  581. methods: {
  582. // 全选/取消全选
  583. selectAll(selection) {
  584. if (selection.length == 0) { // 取消全选
  585. let list = this.$refs.table._data.tableData;
  586. list.map((el) => {
  587. this.$set(el, 'checkedata', false);
  588. if (el.children && el.children.length > 0) {
  589. el.children.map((item) => {
  590. this.$set(item, 'checkedata', false);
  591. delete this.selectionMap[item.id];
  592. });
  593. }
  594. delete this.selectionMap[el.id];
  595. });
  596. return;
  597. }
  598. // 全选
  599. let list = [];
  600. selection.map((item) => {
  601. let flag = this.dispatchPermission(item);
  602. this.$set(item, 'checkedata', flag);
  603. if (flag) {
  604. list.push(item);
  605. }
  606. if (item.children && item.children.length > 0) {
  607. item.children.map((el) => {
  608. let flags = this.dispatchPermission(el);
  609. this.$set(el, 'checkedata', flags);
  610. if (flags) {
  611. list.push(el);
  612. }
  613. });
  614. }
  615. list.map((row) => {
  616. this.selectionMap[row.id] = {
  617. id: row.id,
  618. firstTaskId: row.firstTaskId,
  619. productName: row.productName,
  620. productCode: row.productCode,
  621. code: row.code,
  622. productionPlanCode: row.productionPlanCode,
  623. batchNo: row.batchNo,
  624. formingNum: row.formingNum
  625. };
  626. });
  627. });
  628. },
  629. // 单选数据
  630. selectRow(e, row) {
  631. this.$set(row, 'checkedata', e);
  632. if (e) {
  633. this.selectionMap[row.id] = {
  634. id: row.id,
  635. firstTaskId: row.firstTaskId,
  636. productName: row.productName,
  637. productCode: row.productCode,
  638. code: row.code,
  639. productionPlanCode: row.productionPlanCode,
  640. batchNo: row.batchNo,
  641. formingNum: row.formingNum
  642. };
  643. } else {
  644. delete this.selectionMap[row.id];
  645. }
  646. },
  647. // 批量派单
  648. batchDispatch() {
  649. let list = Object.values(this.selectionMap);
  650. if (list.length === 0) {
  651. this.$message.warning('请至少选择一条派单的数据');
  652. return;
  653. }
  654. if (list.length > 1) {
  655. for (let i = 1; i < list.length; i++) {
  656. let el = list[i];
  657. if (list[0].firstTaskId !== el.firstTaskId) {
  658. this.$message.warning('请选择首工序相同的数据进行批量派单');
  659. return;
  660. }
  661. }
  662. }
  663. this.$refs.batchRef.open(list);
  664. },
  665. // 删除拆单数据
  666. remove(row) {
  667. unpackDel(row.id).then((res) => {
  668. if (res) {
  669. this.$message.success('操作成功');
  670. this.createSuccess();
  671. }
  672. });
  673. },
  674. // assignTypeFn(e) {},
  675. statusFormatter(status) {
  676. const obj = this.statusOpt.find((i) => i.value == status);
  677. return obj && obj.label;
  678. },
  679. /* 表格数据源 */
  680. datasource({ page, limit, where }) {
  681. this.selectionMap = {};
  682. if (where.status) {
  683. where.statusList = [];
  684. where.statusList.push(where.status);
  685. }
  686. return getList({
  687. pageNum: page,
  688. size: limit,
  689. ...where,
  690. ...this.sort
  691. });
  692. },
  693. /* 数据转为树形结构 */
  694. parseData(data) {
  695. const obj = {
  696. ...data,
  697. list: this.$util.toTreeData({
  698. data: data.list,
  699. count: data.total,
  700. idField: 'code',
  701. parentIdField: 'originalCode'
  702. })
  703. };
  704. return obj;
  705. },
  706. getFieldModel() {
  707. fieldModel({ fieldModel: 't_main_category' }).then((res) => {
  708. const privateColumn = [
  709. {
  710. columnKey: 'action',
  711. label: '操作',
  712. width: 140,
  713. align: 'center',
  714. resizable: false,
  715. fixed: 'right',
  716. slot: 'action'
  717. }
  718. ];
  719. let newRes = res.map((m) => {
  720. return {
  721. prop: 'extField.' + m.prop,
  722. label: m.label,
  723. align: 'center',
  724. showOverflowTooltip: true
  725. };
  726. });
  727. this.newColumns = [...this.columns, ...newRes, ...privateColumn];
  728. this.$forceUpdate();
  729. });
  730. },
  731. // 下达
  732. toRelease(row) {
  733. this.current = row;
  734. this.visible = true;
  735. this.FirstTaskIdFn();
  736. this.WorkCenterIdFn();
  737. this.form.singleReport = this.clientEnvironmentId == 2 ? 0 : 1;
  738. },
  739. // 下达
  740. confirm() {
  741. this.$refs.form.validate((valid) => {
  742. if (valid) {
  743. const loading = this.$loading({ text: '加载中...' });
  744. if (this.form.assignType * 1 == 2) {
  745. this.form.workstationIds = [];
  746. } else {
  747. this.form.crewIds = [];
  748. }
  749. releaseWorkOrder({
  750. id: this.current.id,
  751. ...this.form
  752. })
  753. .then((res) => {
  754. if (res) {
  755. this.$message.success('成功');
  756. this.reData();
  757. this.reload();
  758. this.visible = false;
  759. }
  760. })
  761. .finally(() => {
  762. loading.close();
  763. });
  764. }
  765. });
  766. },
  767. close() {
  768. this.visible = false;
  769. this.reData();
  770. },
  771. reData() {
  772. this.form = {
  773. assignType: 1,
  774. crewIds: '',
  775. workstationIds: '',
  776. teamId: '',
  777. singleReport: this.clientEnvironmentId == 2 ? 0 : 1
  778. };
  779. },
  780. /* 刷新表格 */
  781. reload(where) {
  782. this.$nextTick(() => {
  783. this.$refs.table.reload({ page: 1, where });
  784. });
  785. },
  786. onSortChange(e) {
  787. let sort = {
  788. orderBy: e.order,
  789. sortName: e.prop
  790. };
  791. this.sort = sort;
  792. this.reload();
  793. },
  794. sortTop(row) {
  795. row.priority = Number(row.priority) + 1;
  796. this.priorityChange(row);
  797. },
  798. sortBottom(row) {
  799. if (row.priority <= 1) {
  800. return;
  801. }
  802. row.priority = Number(row.priority) - 1;
  803. this.priorityChange(row);
  804. },
  805. FirstTaskIdFn() {
  806. listByFirstTaskId(this.current.firstTaskId).then((res) => {
  807. this.stationList = res;
  808. });
  809. },
  810. WorkCenterIdFn() {
  811. listByWorkCenterId(this.current.workCenterId).then((res) => {
  812. this.teamsList = res;
  813. this.$nextTick(() => {
  814. if (this.teamId) {
  815. this.$set(this.form, 'teamId', this.teamId);
  816. this.stationChange();
  817. }
  818. // this.$refs.form.clearValidate();
  819. });
  820. });
  821. },
  822. // 拆分
  823. toUnpack(row) {
  824. this.$refs.unpackRef.open(row);
  825. },
  826. //派单
  827. toReleaseOpen(row) {
  828. this.dispatchRow = { ...row };
  829. this.dispatchRow.initialWeight = row.formingWeight
  830. ? row.formingWeight + row.newWeightUnit
  831. : '';
  832. this.dispatchVisible = true;
  833. // getTaskIdByInstanceId(row.firstTaskId)
  834. // .then((res) => {
  835. // if (res) {
  836. // }
  837. // })
  838. // .catch((err) => {
  839. // this.$message.error(err.message);
  840. // });
  841. },
  842. createSuccess() {
  843. this.reload();
  844. },
  845. stationChange() {
  846. this.crewList = [];
  847. this.crewIds = [];
  848. listUserByIds([this.form.teamId]).then((res) => {
  849. this.crewList = res;
  850. });
  851. },
  852. priorityChange(row) {
  853. if (row.priority > 10) {
  854. row.priority = 10; // 如果大于 10,则设置为 10
  855. } else if (row.priority < 0) {
  856. row.priority = 0; // 如果小于 0,则设置为 0
  857. }
  858. this.priorityFn(row);
  859. },
  860. priorityFn: debounce(function (row) {
  861. let params = {
  862. id: row.id,
  863. priority: row.priority
  864. };
  865. updatePriority(params).then((res) => {});
  866. }, 800)
  867. }
  868. };
  869. </script>
  870. <style lang="scss" scoped>
  871. // ::v-deep .el-table__row {
  872. // height: 51px !important;
  873. // }
  874. </style>