index.vue 19 KB

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