index.vue 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685
  1. <template>
  2. <div class="ele-body">
  3. <el-card shadow="never" v-loading="loading">
  4. <!-- <order-search @search="reload" ref="searchRef"> </order-search> -->
  5. <seek-page :seekList="seekList" @search="search"></seek-page>
  6. <div class="btn_box">
  7. <!-- <el-button type="primary" @click="salesToProductionOpen(2)"
  8. >转生产订单</el-button
  9. > -->
  10. <el-button type="primary" @click="salesToProductionOpen(1)"
  11. >转生产计划</el-button
  12. >
  13. </div>
  14. <el-tabs v-model="tabValue" type="card" @tab-click="handleTabClick">
  15. <el-tab-pane label="受托任务" name="1"></el-tab-pane>
  16. <el-tab-pane label="预处理任务" name="2"></el-tab-pane>
  17. </el-tabs>
  18. <ele-pro-table
  19. ref="table"
  20. :columns="columns"
  21. :datasource="datasource"
  22. :current.sync="current"
  23. highlight-current-row
  24. row-key="id"
  25. cache-key="beEntrusted"
  26. :pageSize="20"
  27. :height="tableHeight"
  28. :selection.sync="selection"
  29. @fullscreen-change="fullscreenChange"
  30. >
  31. <template v-slot:type="{ row }">
  32. <span> {{ getDictValue('请托类型', row.type + '') }}</span>
  33. </template>
  34. <template v-slot:totalCount="{ row }">
  35. <span> {{ row.totalCount }}{{ row.measuringUnit }}</span>
  36. </template>
  37. <template v-slot:receiveQuantity="{ row }">
  38. <span> {{ row.receiveQuantity || 0 }}{{ row.measuringUnit }}</span>
  39. </template>
  40. <template v-slot:changeType="{ row }">
  41. <el-tag v-if="row.changeType == 0 || !row.changeType">未转</el-tag>
  42. <el-tag v-else-if="row.changeType == 1" type="success"
  43. >已转生产订单</el-tag
  44. >
  45. <el-tag v-else-if="row.changeType == 2" type="success"
  46. >已转生产工单</el-tag
  47. >
  48. <el-tag v-else-if="row.changeType == 3" type="success"
  49. >已转生产计划</el-tag
  50. >
  51. </template>
  52. <template v-slot:status="{ row }">
  53. <el-tag v-if="row.status == 0 || !row.status">未提交</el-tag>
  54. <el-tag v-else-if="row.status == 1" type="success">已提交</el-tag>
  55. <el-tag v-else-if="row.status == 2" type="success">已发布</el-tag>
  56. <el-tag v-else-if="row.status == 4" type="success">待生产</el-tag>
  57. <el-tag v-else-if="row.status == 5" type="success">生产中</el-tag>
  58. <el-tag v-else-if="row.status == 6" type="success">已完成</el-tag>
  59. <el-tag v-else-if="row.status == 7" type="success">已延期</el-tag>
  60. <el-tag v-else-if="row.status == 8" type="success">待下达</el-tag>
  61. </template>
  62. <template v-slot:sendStatus="{ row }">
  63. <el-tag v-if="row.sendStatus == 0 || !row.sendStatus">{{
  64. '未收货'
  65. }}</el-tag>
  66. <el-tag v-else-if="row.sendStatus == 1" type="success">{{
  67. '已发货'
  68. }}</el-tag>
  69. <el-tag v-else-if="row.sendStatus == 2" type="success">{{
  70. '已收货'
  71. }}</el-tag>
  72. <el-tag v-else-if="row.sendStatus == 3" type="success">{{
  73. '受托已发'
  74. }}</el-tag>
  75. <el-tag v-else-if="row.sendStatus == 4" type="success">{{
  76. '请托已收'
  77. }}</el-tag>
  78. <el-tag v-else-if="row.sendStatus == 5" type="success">{{
  79. '受托拒收'
  80. }}</el-tag>
  81. <el-tag v-else-if="row.sendStatus == 6" type="success">{{
  82. '请托拒收'
  83. }}</el-tag>
  84. <el-tag v-else-if="row.sendStatus == 8" type="success">{{
  85. '部分收货'
  86. }}</el-tag>
  87. <el-tag v-else-if="row.sendStatus == 9" type="success">{{
  88. '部分驳回'
  89. }}</el-tag>
  90. </template>
  91. <template v-slot:approvalStatus="{ row }">
  92. <el-tag v-if="row.approvalStatus == 0">未提交</el-tag>
  93. <el-tag v-if="row.approvalStatus == 1" type="warning">审核中</el-tag>
  94. <el-tag v-if="row.approvalStatus == 2" type="success"
  95. >审核通过</el-tag
  96. >
  97. <el-tag v-if="row.approvalStatus == 3" type="danger"
  98. >审核不通过</el-tag
  99. >
  100. </template>
  101. <template v-slot:code="{ row }">
  102. <el-link
  103. type="primary"
  104. :underline="false"
  105. @click="open('detail', row)"
  106. >
  107. {{ row.code }}
  108. </el-link>
  109. </template>
  110. <template v-slot:action="{ row }">
  111. <el-link
  112. type="primary"
  113. :underline="false"
  114. @click="receiveGoos(row, 'add')"
  115. v-if="row.approvalStatus == 2 && (row.sendStatus == 1 || row.sendStatus == 8)"
  116. >
  117. 收货
  118. </el-link>
  119. <el-link
  120. type="primary"
  121. :underline="false"
  122. @click="receiveGoos(row, 'send')"
  123. v-if="
  124. row.approvalStatus == 2 &&
  125. (row.sendStatus == 3 || row.sendStatus == 4)
  126. "
  127. >
  128. 发货详情
  129. </el-link>
  130. <el-link
  131. type="primary"
  132. :underline="false"
  133. @click="receiveGoos(row, 'detail')"
  134. v-if="
  135. row.approvalStatus == 2 &&
  136. row.sendStatus != 1 &&
  137. row.sendStatus != 5
  138. "
  139. >
  140. 收货详情
  141. </el-link>
  142. </template>
  143. </ele-pro-table>
  144. </el-card>
  145. <Create ref="create" @refresh="reload" />
  146. <ele-modal
  147. :visible.sync="visible"
  148. width="20vw"
  149. append-to-body
  150. :maxable="true"
  151. >
  152. <el-form label-width="100px">
  153. <el-form-item label="入库仓库:" prop="warehouseId">
  154. <el-select v-model="warehouseId">
  155. <el-option
  156. v-for="item in warehouseList"
  157. :key="item.id"
  158. :value="item.id"
  159. :label="item.name"
  160. ></el-option>
  161. </el-select>
  162. </el-form-item>
  163. </el-form>
  164. <template v-slot:footer>
  165. <el-button @click="visible = false">取消</el-button>
  166. <el-button type="primary" @click="warehouseEntry"> 确定 </el-button>
  167. </template>
  168. </ele-modal>
  169. <create-order ref="createOrderRef" @refresh="reload"></create-order>
  170. <goodsDetail ref="goodsDetailRef" @done="refresh"></goodsDetail>
  171. </div>
  172. </template>
  173. <script>
  174. import OrderSearch from '@/views/entrust/components/order-search.vue';
  175. import dictMixins from '@/mixins/dictMixins';
  176. import Create from '@/views/entrust/components/create';
  177. import createOrder from './components/create-order.vue';
  178. import {
  179. getList,
  180. warehouseEntry,
  181. update,
  182. transferProductionPlan
  183. } from '@/api/beEntrusted/index';
  184. import goodsDetail from './components/goodsDetail.vue';
  185. import warehouseDefinition from '@/api/warehouseManagement/warehouseDefinition';
  186. import { getByCode } from '@/api/system/dictionary-data';
  187. import {
  188. getWarehouseList
  189. // queryKilnXCH
  190. } from '@/api/mes';
  191. export default {
  192. components: {
  193. OrderSearch,
  194. Create,
  195. createOrder,
  196. goodsDetail
  197. },
  198. mixins: [dictMixins],
  199. data() {
  200. return {
  201. visible: false,
  202. loading: false,
  203. id: '',
  204. current: null,
  205. warehouseId: '',
  206. warehouseList: [],
  207. tableHeight: 'calc(100vh - 320px)',
  208. selection: [],
  209. factoryList: [],
  210. typeList: [],
  211. tabValue: '1'
  212. };
  213. },
  214. computed: {
  215. // 表格列配置
  216. columns() {
  217. return [
  218. {
  219. columnKey: 'selection',
  220. type: 'selection',
  221. width: 45,
  222. align: 'center',
  223. fixed: 'left'
  224. },
  225. {
  226. columnKey: 'index',
  227. label: '序号',
  228. type: 'index',
  229. width: 55,
  230. align: 'center',
  231. showOverflowTooltip: true,
  232. fixed: 'left'
  233. },
  234. {
  235. prop: 'type',
  236. label: '类型',
  237. width: 55,
  238. align: 'center',
  239. showOverflowTooltip: true,
  240. slot: 'type'
  241. },
  242. {
  243. prop: 'priority',
  244. label: '紧急程度',
  245. width: 90,
  246. align: 'center',
  247. showOverflowTooltip: true,
  248. formatter: (row, column, cellValue) => {
  249. return cellValue == 1 ? '一般' : cellValue == 2 ? '紧急' : '';
  250. }
  251. },
  252. {
  253. prop: 'name',
  254. label: '名称',
  255. width: 130,
  256. showOverflowTooltip: true,
  257. align: 'center'
  258. },
  259. {
  260. prop: 'code',
  261. slot: 'code',
  262. label: '编码',
  263. width: 160,
  264. showOverflowTooltip: true,
  265. align: 'center'
  266. },
  267. {
  268. prop: 'applyFactoriesName',
  269. label: '所属工厂',
  270. align: 'center',
  271. width: 130,
  272. showOverflowTooltip: true
  273. },
  274. {
  275. prop: 'applyDeptName',
  276. label: '请托部门',
  277. align: 'center',
  278. width: 120,
  279. showOverflowTooltip: true
  280. },
  281. {
  282. prop: 'createUserName',
  283. label: '请托人',
  284. align: 'center',
  285. width: 80,
  286. showOverflowTooltip: true
  287. },
  288. {
  289. prop: 'totalCount',
  290. slot: 'totalCount',
  291. label: '请托数量',
  292. align: 'center',
  293. width: 130,
  294. showOverflowTooltip: true
  295. },
  296. {
  297. prop: 'receiveQuantity',
  298. slot: 'receiveQuantity',
  299. label: '接收数量',
  300. align: 'center',
  301. width: 130,
  302. showOverflowTooltip: true
  303. },
  304. {
  305. prop: 'beEntrustedFactoriesName',
  306. label: '受托工厂',
  307. align: 'center',
  308. width: 130,
  309. showOverflowTooltip: true
  310. },
  311. {
  312. prop: 'beEntrustedDeptName',
  313. label: '受托部门',
  314. align: 'center',
  315. width: 120,
  316. showOverflowTooltip: true
  317. },
  318. {
  319. prop: 'productionPlanCode',
  320. label: '计划编号',
  321. align: 'center',
  322. minWidth: 110,
  323. showOverflowTooltip: true
  324. },
  325. {
  326. prop: 'sendStatus',
  327. slot: 'sendStatus',
  328. label: '收货状态',
  329. align: 'center',
  330. minWidth: 110,
  331. showOverflowTooltip: true
  332. },
  333. {
  334. prop: 'produceRoutingName',
  335. label: '工艺路线',
  336. align: 'center',
  337. showOverflowTooltip: true
  338. },
  339. {
  340. prop: 'brandNum',
  341. label: '牌号',
  342. align: 'center',
  343. minWidth: 110,
  344. showOverflowTooltip: true
  345. },
  346. {
  347. prop: 'batchNo',
  348. label: '批次号',
  349. align: 'center',
  350. minWidth: 110,
  351. showOverflowTooltip: true
  352. },
  353. {
  354. prop: 'planStartTime',
  355. label: '计划开始时间',
  356. align: 'center',
  357. showOverflowTooltip: true,
  358. minWidth: 130,
  359. sortable: true
  360. },
  361. {
  362. prop: 'planCompleteTime',
  363. label: '计划结束时间',
  364. align: 'center',
  365. showOverflowTooltip: true,
  366. minWidth: 130,
  367. sortable: true
  368. },
  369. {
  370. prop: 'specification',
  371. label: '规格',
  372. align: 'center',
  373. minWidth: 110,
  374. showOverflowTooltip: true
  375. },
  376. {
  377. prop: 'planDeliveryTime',
  378. label: '完成时间',
  379. align: 'center',
  380. width: 150,
  381. showOverflowTooltip: true
  382. },
  383. {
  384. prop: 'createTime',
  385. label: '创建时间',
  386. align: 'center',
  387. width: 150,
  388. showOverflowTooltip: true
  389. },
  390. {
  391. prop: 'describes',
  392. label: '需求描述',
  393. align: 'center',
  394. showOverflowTooltip: true
  395. },
  396. {
  397. prop: 'status',
  398. label: '状态',
  399. align: 'center',
  400. slot: 'status',
  401. width: 100
  402. },
  403. {
  404. prop: 'approvalStatus',
  405. label: '审批状态',
  406. align: 'center',
  407. slot: 'approvalStatus',
  408. width: 120
  409. },
  410. {
  411. prop: 'changeType',
  412. label: '转换状态',
  413. align: 'center',
  414. slot: 'changeType',
  415. width: 120
  416. },
  417. {
  418. prop: 'beReason',
  419. label: '原因',
  420. align: 'center',
  421. slot: 'beReason',
  422. width: 150
  423. },
  424. {
  425. columnKey: 'action',
  426. label: '操作',
  427. width: 180,
  428. align: 'center',
  429. resizable: false,
  430. fixed: 'right',
  431. slot: 'action',
  432. showOverflowTooltip: true
  433. }
  434. ];
  435. },
  436. seekList() {
  437. return [
  438. {
  439. label: '类型:',
  440. value: 'type',
  441. type: 'select',
  442. labelWidth: 50,
  443. planList: this.typeList
  444. },
  445. {
  446. label: '名称:',
  447. value: 'name',
  448. type: 'input',
  449. labelWidth: 50
  450. },
  451. {
  452. label: '请托工厂:',
  453. value: 'applyFactoriesId',
  454. type: 'select',
  455. planList: this.factoryList
  456. },
  457. // {
  458. // label: '状态:',
  459. // value: 'preStatus',
  460. // type: 'select',
  461. // planList: [
  462. // { value: 0, label: '准备中' },
  463. // { value: 1, label: '准备完成' },
  464. // { value: 2, label: '取消' }
  465. // ]
  466. // },
  467. // {
  468. // label: '受托工厂:',
  469. // value: 'beEntrustedFactoriesId',
  470. // type: 'select',
  471. // planList: this.factoryList
  472. // },
  473. {
  474. label: '请托时间:',
  475. value: 'planDeliveryTime',
  476. type: 'date',
  477. dateType: 'daterange',
  478. placeholder: ''
  479. }
  480. ];
  481. }
  482. },
  483. created() {
  484. this.requestDict('请托类型');
  485. this.getTypeList();
  486. this.getFactoryList();
  487. getWarehouseList().then((res) => {
  488. this.warehouseList = res;
  489. });
  490. },
  491. filters: {},
  492. methods: {
  493. /* 表格数据源 */
  494. datasource({ page, limit, where }) {
  495. // console.log(where.planDeliveryTime, 'www');
  496. let startTime = undefined;
  497. let endTime = undefined;
  498. if (where.planDeliveryTime) {
  499. startTime = where.planDeliveryTime[0];
  500. endTime = where.planDeliveryTime[1];
  501. }
  502. return getList({
  503. pageNum: page,
  504. size: limit,
  505. ...where,
  506. startTime,
  507. endTime
  508. });
  509. },
  510. open(type, row) {
  511. this.$refs.create.open(type, row);
  512. },
  513. handleTabClick(e) {
  514. this.tabValue = e.name;
  515. this.reload();
  516. },
  517. async getTypeList() {
  518. let res = await getByCode('entrust_type');
  519. if (res?.code == 0) {
  520. console.log(res);
  521. let list = res.data.map((item) => {
  522. let key = Object.keys(item)[0];
  523. return { value: Number(key), label: item[key] };
  524. });
  525. this.typeList = list;
  526. }
  527. console.log(this.typeList, 'this.typeList');
  528. },
  529. async getFactoryList() {
  530. const { list } = await warehouseDefinition.getFactoryarea({
  531. pageNum: 1,
  532. size: 999,
  533. type: 1
  534. });
  535. list.forEach((item) => {
  536. item.label = item.name;
  537. item.value = item.id;
  538. });
  539. this.factoryList = list || [];
  540. },
  541. async salesToProductionOpen(type) {
  542. const actionText = type == 1 ? '转生产计划' : '转生产订单';
  543. if (this.selection.length == 0) {
  544. return this.$message.warning('请选择一条数据');
  545. }
  546. if (type == 2 && this.selection.length > 1) {
  547. return this.$message.warning('只能选择一条数据');
  548. }
  549. const unreceived = this.selection.find(
  550. (item) => item.approvalStatus == 2 && item.sendStatus != 2
  551. );
  552. if (unreceived) {
  553. return this.$message.warning(`请先收货再${actionText}`);
  554. }
  555. const converted = this.selection.find(
  556. (item) =>
  557. item.changeType == 1 || item.changeType == 2 || item.changeType == 3
  558. );
  559. if (converted) {
  560. return this.$message.warning('该委托工单已转换,不能重复转换');
  561. }
  562. if (type == 2) {
  563. this.$refs.createOrderRef.open(this.selection);
  564. return;
  565. }
  566. const ids = this.selection.map((item) => item.id);
  567. try {
  568. await this.$confirm(
  569. `确认将已勾选的 ${ids.length} 条数据转为生产计划吗?`,
  570. '提示',
  571. {
  572. confirmButtonText: '确定',
  573. cancelButtonText: '取消',
  574. type: 'warning'
  575. }
  576. );
  577. this.loading = true;
  578. await transferProductionPlan(ids);
  579. this.$message.success('转生产计划成功');
  580. this.reload();
  581. } catch (err) {
  582. if (err !== 'cancel' && err !== 'close') {
  583. this.$message.error(err.message || '转生产计划失败');
  584. }
  585. } finally {
  586. this.loading = false;
  587. }
  588. },
  589. update(id) {
  590. update({ id, status: 1 }).then((res) => {
  591. this.reload();
  592. });
  593. },
  594. openWarehouseEntry(id) {
  595. this.id = id;
  596. this.visible = true;
  597. },
  598. warehouseEntry() {
  599. if (!this.warehouseId) {
  600. this.$message.error('请选择仓库');
  601. return;
  602. }
  603. warehouseEntry({
  604. id: this.id,
  605. warehouseId: this.warehouseId
  606. }).then((res) => {
  607. this.reload();
  608. this.visible = false;
  609. });
  610. },
  611. /* 刷新表格 */
  612. reload(where) {
  613. const queryWhere = { ...(where || {}) };
  614. if (this.tabValue === '2') {
  615. queryWhere.preStatus = 1;
  616. } else {
  617. delete queryWhere.preStatus;
  618. }
  619. this.$nextTick(() => {
  620. this.$refs.table.reload({ page: 1, where: queryWhere });
  621. });
  622. },
  623. refresh() {
  624. this.reload();
  625. },
  626. search(e) {
  627. this.reload(e);
  628. },
  629. receiveGoos(item, type) {
  630. this.$refs.goodsDetailRef.open(item, type);
  631. },
  632. fullscreenChange(fullscreen) {
  633. if (fullscreen) {
  634. this.tableHeight = 'calc(100vh - 120px)';
  635. } else {
  636. this.tableHeight = 'calc(100vh - 320px)';
  637. }
  638. }
  639. }
  640. };
  641. </script>
  642. <style lang="scss" scoped>
  643. .btn_box {
  644. margin-bottom: 6px;
  645. }
  646. </style>