index.vue 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680
  1. <template>
  2. <div class="ele-body">
  3. <el-card v-loading="loading" shadow="never">
  4. <task-search @search="reload"></task-search>
  5. <!-- <taskDialog-search></taskDialog-search> -->
  6. <el-tabs v-model="tabValue" type="card" @tab-click="handleTabClick">
  7. <el-tab-pane label="我的任务" name="1"></el-tab-pane>
  8. <el-tab-pane
  9. label="全部任务"
  10. name="2"
  11. v-if="$hasPermission('mes:taskreport:allorder')"
  12. ></el-tab-pane>
  13. <el-tab-pane
  14. label="班组任务"
  15. name="3"
  16. v-if="$hasPermission('mes:taskreport:teamorder')"
  17. ></el-tab-pane>
  18. <!-- <el-tab-pane label="我的任务" name="1"></el-tab-pane>
  19. <el-tab-pane label="全部任务" name="2"></el-tab-pane> -->
  20. </el-tabs>
  21. <ele-pro-table
  22. ref="table"
  23. :columns="columns"
  24. :datasource="datasource"
  25. :pageSize="20"
  26. cache-key="workOrderTable"
  27. class="my_pro_table"
  28. row-key="id"
  29. :height="tableHeight"
  30. @fullscreen-change="fullscreenChange"
  31. >
  32. <template v-slot:assignCode="{ row }">
  33. <el-link
  34. :underline="false"
  35. type="primary"
  36. @click="details('assign', row)"
  37. >{{ row.assignCode }}
  38. </el-link>
  39. </template>
  40. <template v-slot:workOrderCode="{ row }">
  41. <el-link
  42. :underline="false"
  43. type="primary"
  44. @click="details('assign', row)"
  45. >{{ row.workOrderCode }}
  46. </el-link>
  47. </template>
  48. <template v-slot:disposalStatus="{ row }">
  49. <el-tag v-if="row.disposalStatus == 1" type="success">已接受</el-tag>
  50. <el-tag v-if="row.disposalStatus == 2" type="danger">已拒绝</el-tag>
  51. </template>
  52. <template v-slot:action="{ row }">
  53. <el-link
  54. v-if="tabValue == '2' && row.disposalStatus == '2'"
  55. :underline="false"
  56. type="primary"
  57. @click="reassignTask(row)"
  58. >转派
  59. </el-link>
  60. <el-link
  61. :underline="false"
  62. type="primary"
  63. @click="details('report', row)"
  64. v-if="row.disposalStatus == '1' || tabValue == '2'"
  65. >报工
  66. </el-link>
  67. <el-link
  68. :underline="false"
  69. type="primary"
  70. @click="viewRecords(row.id)"
  71. v-if="row.disposalStatus == '1' || tabValue == '2'"
  72. >报工记录
  73. </el-link>
  74. <el-popconfirm
  75. icon="el-icon-info"
  76. title="确定接收任务吗?"
  77. @confirm="receiveTask(row.id, '1')"
  78. v-if="
  79. row.disposalStatus != '1' &&
  80. row.disposalStatus != '2' &&
  81. tabValue != '2'
  82. "
  83. >
  84. <el-button slot="reference" type="text">接收任务</el-button>
  85. </el-popconfirm>
  86. <el-popconfirm
  87. icon="el-icon-info"
  88. title="确定拒绝任务吗?"
  89. @confirm="receiveTask(row.id, '2')"
  90. v-if="
  91. row.disposalStatus != '1' &&
  92. row.disposalStatus != '2' &&
  93. tabValue != '2'
  94. "
  95. >
  96. <el-button slot="reference" type="text">拒绝任务</el-button>
  97. </el-popconfirm>
  98. <!-- <el-link
  99. :underline="false"
  100. type="primary"
  101. @click="receiveTask(row)"
  102. v-if="row.disposalStatus != '1'"
  103. >接收任务
  104. </el-link> -->
  105. <!-- <el-link
  106. :underline="false"
  107. type="primary"
  108. @click="rejectTask(row)"
  109. v-if="row.disposalStatus != '1'"
  110. >拒绝任务
  111. </el-link> -->
  112. </template>
  113. </ele-pro-table>
  114. </el-card>
  115. <modifyDialog ref="modifyRef" />
  116. <Ddtails ref="detailsRef" @success="reload" />
  117. <el-dialog
  118. title="选择人员"
  119. :visible.sync="dialogFormVisible"
  120. v-if="dialogFormVisible"
  121. width="30%"
  122. center
  123. >
  124. <el-form :model="form">
  125. <el-form-item label="人员">
  126. <el-select
  127. size="mini"
  128. class="content_num"
  129. filterable
  130. v-model="form.userId"
  131. placeholder="请选择任务人员"
  132. >
  133. <el-option
  134. v-for="item in teamList"
  135. :label="item.name"
  136. :value="item.id"
  137. :key="item.id"
  138. >
  139. </el-option>
  140. </el-select>
  141. </el-form-item>
  142. </el-form>
  143. <div slot="footer" class="dialog-footer">
  144. <el-button @click="dialogFormVisible = false">取 消</el-button>
  145. <el-button type="primary" @click="chooseUser">确 定</el-button>
  146. </div>
  147. </el-dialog>
  148. </div>
  149. </template>
  150. <script>
  151. import TaskSearch from './components/task-search.vue';
  152. import Ddtails from './components/Ddtails.vue';
  153. import modifyDialog from '@/views/taskList/components/modifyDialog.vue';
  154. import { getteampage } from '@/api/produceWord/index.js';
  155. import {
  156. pageByCurrentUser,
  157. pageByCurrentUserLeader,
  158. listUpdateRealTimeRecord,
  159. taskManagement,
  160. transferTasks,
  161. pageByCurrentCurrentUserTeam
  162. } from '@/api/workOrderList';
  163. import { revokeWork } from '@/api/manufacture/spreadWorkOrder';
  164. export default {
  165. components: { TaskSearch, Ddtails, modifyDialog },
  166. data() {
  167. return {
  168. loading: false,
  169. tabValue: '1',
  170. statusOpt: [
  171. { label: '待生产', value: 4 },
  172. { label: '生产中', value: 5 },
  173. { label: '待下达', value: 8 }
  174. ],
  175. form: {
  176. userId: '',
  177. id: ''
  178. },
  179. dialogFormVisible: false,
  180. teamList: [],
  181. tableHeight: 'calc(100vh - 380px)'
  182. };
  183. },
  184. computed: {
  185. // 表格列配置
  186. columns() {
  187. return [
  188. {
  189. columnKey: 'index',
  190. label: '序号',
  191. type: 'index',
  192. width: 55,
  193. align: 'center',
  194. showOverflowTooltip: true,
  195. fixed: 'left'
  196. },
  197. {
  198. slot: 'assignCode',
  199. prop: 'assignCode',
  200. label: '任务编码',
  201. align: 'center',
  202. showOverflowTooltip: true,
  203. width: 210
  204. },
  205. {
  206. slot: 'workOrderCode',
  207. prop: 'workOrderCode',
  208. label: '生产订单编码',
  209. align: 'center',
  210. showOverflowTooltip: true,
  211. width: 210
  212. },
  213. {
  214. prop: 'mesWorkOrderCode',
  215. label: '生产工单编码',
  216. align: 'center',
  217. showOverflowTooltip: true,
  218. width: 210
  219. },
  220. {
  221. prop: 'productionPlanCode',
  222. label: '计划编号',
  223. align: 'center',
  224. showOverflowTooltip: true,
  225. width: 170
  226. },
  227. {
  228. prop: 'assigneeType',
  229. label: '执行类型',
  230. align: 'center',
  231. showOverflowTooltip: true,
  232. width: 120,
  233. formatter: (row) => {
  234. if (!row.assigneeType) return '';
  235. return row.assigneeType.desc;
  236. }
  237. },
  238. {
  239. prop: 'assigneeName',
  240. label: '执行对象名称',
  241. align: 'center',
  242. showOverflowTooltip: true,
  243. width: 180
  244. },
  245. {
  246. prop: 'workCenterName',
  247. label: '工作中心',
  248. align: 'center',
  249. width: 180,
  250. showOverflowTooltip: true
  251. },
  252. {
  253. prop: 'assignTeamName',
  254. label: '班组名称',
  255. align: 'center',
  256. showOverflowTooltip: true,
  257. width: 180
  258. },
  259. {
  260. prop: 'taskName',
  261. label: '工序名称',
  262. align: 'center',
  263. showOverflowTooltip: true,
  264. width: 150
  265. },
  266. {
  267. prop: 'produceRoutingName',
  268. label: '工艺路线',
  269. align: 'center',
  270. showOverflowTooltip: true,
  271. width: 170
  272. },
  273. {
  274. prop: 'productCode',
  275. label: '产品编码',
  276. align: 'center',
  277. showOverflowTooltip: true,
  278. width: 170
  279. },
  280. {
  281. prop: 'productName',
  282. label: '产品名称',
  283. align: 'center',
  284. showOverflowTooltip: true,
  285. width: 200
  286. },
  287. {
  288. prop: 'productionCodes',
  289. label: '生产编号',
  290. align: 'center',
  291. showOverflowTooltip: true,
  292. width: 170
  293. },
  294. {
  295. prop: 'brandNo',
  296. label: '牌号',
  297. align: 'center',
  298. showOverflowTooltip: true,
  299. width: 170
  300. },
  301. {
  302. prop: 'batchNo',
  303. label: '批次号',
  304. align: 'center',
  305. width: 100,
  306. showOverflowTooltip: true
  307. },
  308. {
  309. prop: 'model',
  310. label: '型号',
  311. align: 'center',
  312. width: 200,
  313. showOverflowTooltip: true
  314. },
  315. {
  316. prop: 'quantity',
  317. label: '任务数量',
  318. align: 'center',
  319. showOverflowTooltip: true,
  320. width: 110
  321. },
  322. {
  323. prop: 'weight',
  324. label: '任务重量(kg)',
  325. align: 'center',
  326. showOverflowTooltip: true,
  327. width: 110
  328. },
  329. {
  330. prop: 'planStartTime',
  331. label: '计划开始时间',
  332. align: 'center',
  333. showOverflowTooltip: true,
  334. width: 180
  335. },
  336. {
  337. prop: 'planCompleteTime',
  338. label: '计划结束时间',
  339. align: 'center',
  340. showOverflowTooltip: true,
  341. width: 180
  342. },
  343. {
  344. prop: 'startTime',
  345. label: '任务开始时间',
  346. align: 'center',
  347. showOverflowTooltip: true,
  348. width: 180
  349. },
  350. {
  351. prop: 'endTime',
  352. label: '任务结束时间',
  353. align: 'center',
  354. showOverflowTooltip: true,
  355. width: 180
  356. },
  357. {
  358. label: '实际开始时间',
  359. prop: 'realStartTime',
  360. minWidth: 150,
  361. align: 'center',
  362. showOverflowTooltip: true
  363. },
  364. {
  365. label: '实际结束时间',
  366. prop: 'realEndTime',
  367. minWidth: 150,
  368. align: 'center',
  369. showOverflowTooltip: true
  370. },
  371. {
  372. label: '工时',
  373. prop: 'durationText',
  374. width: 150,
  375. align: 'center',
  376. showOverflowTooltip: true
  377. },
  378. {
  379. prop: 'firstTaskName',
  380. label: '首工序',
  381. align: 'center',
  382. width: 180,
  383. showOverflowTooltip: true
  384. },
  385. {
  386. prop: 'createTime',
  387. label: '创建时间',
  388. align: 'center',
  389. showOverflowTooltip: true,
  390. width: 180
  391. },
  392. {
  393. prop: 'statusText',
  394. label: '状态',
  395. align: 'center',
  396. // formatter: (row) => {
  397. // const obj = this.statusOpt.find((i) => i.value == row.status);
  398. // return obj && obj.label;
  399. // },
  400. width: 120
  401. },
  402. {
  403. prop: 'disposalStatus',
  404. label: '任务接收状态',
  405. align: 'center',
  406. slot: 'disposalStatus',
  407. width: 120
  408. },
  409. {
  410. prop: 'customerName',
  411. label: '客户名称',
  412. align: 'center',
  413. showOverflowTooltip: true,
  414. width: 180
  415. },
  416. {
  417. prop: 'serialNo',
  418. label: '客户代号',
  419. align: 'center',
  420. showOverflowTooltip: true,
  421. width: 180
  422. },
  423. {
  424. prop: 'simpleName',
  425. label: '客户简称',
  426. align: 'center',
  427. showOverflowTooltip: true,
  428. width: 180
  429. },
  430. {
  431. columnKey: 'action',
  432. label: '操作',
  433. width: 200,
  434. align: 'center',
  435. resizable: false,
  436. fixed: 'right',
  437. slot: 'action'
  438. }
  439. ];
  440. }
  441. },
  442. created() {},
  443. mounted() {
  444. // if (this.$hasPermission('mes:taskreport:allorder')) {
  445. // this.tabValue = '2';
  446. // }
  447. // if (this.$hasPermission('mes:taskreport:myorder')) {
  448. // this.tabValue = '1';
  449. // }
  450. // if (
  451. // !this.$hasPermission('mes:taskreport:myorder') &&
  452. // !this.$hasPermission('mes:taskreport:allorder')
  453. // ) {
  454. // this.tabValue = '';
  455. // }
  456. },
  457. methods: {
  458. handleTabClick(e) {
  459. this.tabValue = e.name;
  460. this.reload();
  461. },
  462. /* 表格数据源 */
  463. datasource({ page, limit, where }) {
  464. if (this.tabValue && this.tabValue != 0) {
  465. let api =
  466. this.tabValue === '1'
  467. ? pageByCurrentUser
  468. : this.tabValue == '2'
  469. ? pageByCurrentUserLeader
  470. : pageByCurrentCurrentUserTeam;
  471. let params = {
  472. ...where,
  473. pageNum: page,
  474. size: limit
  475. };
  476. if (this.tabValue === '3') {
  477. params.teamIdsStr = this.$store.state.user.info?.teamId;
  478. // if (teamId) {
  479. // const ids = teamId
  480. // .split(',')
  481. // .map((i) => i.trim())
  482. // .filter(Boolean);
  483. // params.teamIds = ids; // 不要加 []
  484. // }
  485. }
  486. console.log(params);
  487. return api(params);
  488. } else {
  489. return [];
  490. }
  491. // if (
  492. // (this.$hasPermission('mes:taskreport:myorder') &&
  493. // this.$hasPermission('mes:taskreport:allorder')) ||
  494. // (this.$hasPermission('mes:taskreport:myorder') &&
  495. // !this.$hasPermission('mes:taskreport:allorder'))
  496. // ) {
  497. // let api = pageByCurrentUser;
  498. // return api({
  499. // ...where,
  500. // pageNum: page,
  501. // size: limit
  502. // });
  503. // } else if (
  504. // this.$hasPermission('mes:taskreport:myorder') &&
  505. // !this.$hasPermission('mes:taskreport:allorder')
  506. // ) {
  507. // let api = pageByCurrentUserLeader;
  508. // return api({
  509. // ...where,
  510. // pageNum: page,
  511. // size: limit
  512. // });
  513. // } else {
  514. // return [];
  515. // }
  516. // if()
  517. },
  518. async chooseUser() {
  519. if (!this.form.userId) {
  520. return this.$message.warning('请选择转派人员');
  521. }
  522. const data = this.teamList.find((it) => it.id == this.form.userId);
  523. await transferTasks({
  524. assigneeId: data.id,
  525. assigneeName: data.name,
  526. id: this.form.id
  527. }).then((res) => {
  528. console.log(res);
  529. });
  530. this.dialogFormVisible = false;
  531. this.reload();
  532. },
  533. async receiveTask(id, type) {
  534. await taskManagement({
  535. id,
  536. disposalStatus: Number(type)
  537. }).then((res) => {
  538. console.log(res);
  539. this.reload();
  540. });
  541. },
  542. // async receiveTask(item) {
  543. // await taskManagement({
  544. // id: item.id,
  545. // disposalStatus: 1
  546. // }).then((res) => {
  547. // console.log(res);
  548. // this.reload();
  549. // });
  550. // },
  551. // async rejectTask(item) {
  552. // await taskManagement({
  553. // id: item.id,
  554. // disposalStatus: 2
  555. // }).then((res) => {
  556. // console.log(res);
  557. // this.reload();
  558. // });
  559. // },
  560. async reassignTask(item) {
  561. this.form.userId = '';
  562. this.form.id = item.id;
  563. await getteampage({ name: item.assignTeamName }).then((res) => {
  564. this.teamList = res.list[0].userVOList;
  565. });
  566. this.dialogFormVisible = true;
  567. },
  568. fullscreenChange(fullscreen) {
  569. if (fullscreen) {
  570. this.tableHeight = 'calc(100vh - 120px)';
  571. } else {
  572. this.tableHeight = 'calc(100vh - 380px)';
  573. }
  574. },
  575. reload(where) {
  576. this.$refs.table.reload({ page: 1, where });
  577. },
  578. details(type, row) {
  579. let currentRow = {
  580. assignCode: row.assignCode,
  581. mesWorkOrderCode: row.mesWorkOrderCode,
  582. workOrderCode: row.workOrderCode,
  583. productionPlanCode: row.productionPlanCode,
  584. produceRoutingName: row.produceRoutingName,
  585. formingNum: row.formingNum,
  586. assignTeamName: row.assignTeamName,
  587. formingWeight: row.formingWeight,
  588. planStartTime: row.planStartTime,
  589. planCompleteTime: row.planCompleteTime,
  590. startTime: row.startTime,
  591. firstTaskId: row.firstTaskId,
  592. endTime: row.endTime,
  593. taskName: row.taskName,
  594. firstTaskName: row.firstTaskName,
  595. assigneeType: row.assigneeType ? row.assigneeType.desc : '',
  596. assigneeName: row.assigneeName,
  597. weight: row.weight,
  598. quantity: row.quantity,
  599. durationText: row.durationText,
  600. apsAssigneeId: row.id,
  601. batchNo: row.batchNo,
  602. productCode: row.productCode,
  603. productName: row.productName,
  604. specification: row.specification,
  605. newWeightUnit: row.newWeightUnit,
  606. measuringUnit: row.measuringUnit
  607. };
  608. let form = {
  609. realEndTime: row.realEndTime,
  610. realStartTime: row.realStartTime,
  611. unqualifiedWeight: row.unqualifiedWeight,
  612. unqualifiedQuantity: row.unqualifiedQuantity,
  613. qualifiedWeight: row.qualifiedWeight,
  614. remark: row.assigneeRemark,
  615. qualifiedQuantity: row.qualifiedQuantity,
  616. reportQuantity: row.reportQuantity,
  617. lossQuantity: row.lossQuantity
  618. };
  619. this.$refs.detailsRef.open(type, currentRow, form);
  620. },
  621. viewRecords(apsAssigneeId) {
  622. listUpdateRealTimeRecord(apsAssigneeId)
  623. .then((res) => {
  624. if (res && res.length > 0) {
  625. this.$refs.modifyRef.open(res);
  626. } else {
  627. this.$message.warning('暂无修改历史记录数据');
  628. }
  629. })
  630. .catch((err) => {
  631. this.$message.error(err.message);
  632. });
  633. }
  634. }
  635. };
  636. </script>
  637. <style lang="scss" scoped>
  638. .ele-body {
  639. height: 100%;
  640. // .my_pro_table {
  641. // height: calc(100% - 136px);
  642. // }
  643. }
  644. // ::v-deep .el-table {
  645. // height: calc(100% - 96px);
  646. // }
  647. </style>