index.vue 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723
  1. <template>
  2. <div class="ele-body">
  3. <el-card shadow="never" v-loading="loading">
  4. <order-search
  5. ref="searchRefs"
  6. @search="reload"
  7. :selection="selection"
  8. :activeName="activeName"
  9. @check="check"
  10. >
  11. </order-search>
  12. <!-- <plan-statistics></plan-statistics> -->
  13. <el-tabs v-model="activeName" type="card" @tab-click="changeTab">
  14. <el-tab-pane label="待排产" name="first"></el-tab-pane>
  15. <el-tab-pane label="未排完" name="three"></el-tab-pane>
  16. <el-tab-pane label="已排产" name="second"></el-tab-pane>
  17. </el-tabs>
  18. <!-- 数据表格 -->
  19. <ele-pro-table
  20. ref="table"
  21. :columns="columns"
  22. :initLoad="false"
  23. :datasource="datasource"
  24. :selection.sync="selection"
  25. cache-key="systemRoleTable1"
  26. height="calc(100vh - 390px)"
  27. row-key="id"
  28. @sort-change="onSortChange"
  29. @columns-change="handleColumnChange"
  30. :cacheKey="cacheKeyUrl"
  31. >
  32. <!-- :cache-key="cacheKeyUrl" -->
  33. <template v-slot:code="{ row }">
  34. <el-link :underline="false" type="primary" @click="openDetails(row)">
  35. {{ row.code }}
  36. </el-link>
  37. </template>
  38. <template v-slot:priority="{ row }">
  39. <div style="display: flex">
  40. <el-input
  41. v-model="row.priority"
  42. type="number"
  43. size="mini"
  44. :min="0"
  45. :max="10"
  46. @change="priorityChange(row)"
  47. style="width: 80px"
  48. ></el-input>
  49. <el-popover
  50. placement="right"
  51. width="200"
  52. trigger="hover"
  53. content="数值越大优先级越高(0-3普通, 4-6优先, 7-10紧急)"
  54. >
  55. <div class="sort-wrap" slot="reference">
  56. <i class="el-icon-caret-top" @click="sortTop(row)"></i>
  57. <i class="el-icon-caret-bottom" @click="sortBottom(row)"></i>
  58. </div>
  59. </el-popover>
  60. </div>
  61. </template>
  62. <template v-slot:productSumWeight="{ row }">
  63. {{ row.productSumWeight }} {{ row.weightUnit }}
  64. </template>
  65. <template v-slot:contractNum="{ row }">
  66. {{ row.contractNum }} {{ row.measuringUnit }}
  67. </template>
  68. <!-- 操作列 -->
  69. <template v-slot:action="{ row }">
  70. <template>
  71. <el-link
  72. v-if="row.orderSource != 1 && activeName == 'first'"
  73. type="primary"
  74. :underline="false"
  75. icon="el-icon-edit"
  76. @click="toUpdate(row)"
  77. >
  78. 修改
  79. </el-link>
  80. <el-popconfirm
  81. v-if="row.orderSource != 1 && activeName == 'first'"
  82. class="ele-action"
  83. title="确定要删除此销售订单吗?"
  84. @confirm="remove(row)"
  85. >
  86. <template v-slot:reference>
  87. <el-link type="danger" :underline="false" icon="el-icon-delete">
  88. 删除
  89. </el-link>
  90. </template>
  91. </el-popconfirm>
  92. </template>
  93. </template>
  94. </ele-pro-table>
  95. </el-card>
  96. <!-- 详情弹窗 -->
  97. <order-detail @refresh="reload" ref="detailDialog"> </order-detail>
  98. <!-- 创建订单 -->
  99. <create-order ref="createDialog" @refresh="reload"> </create-order>
  100. <orderHomogeneityInspectDialog
  101. ref="orderHomogeneityInspectDialog"
  102. @reload="reload"
  103. ></orderHomogeneityInspectDialog>
  104. <orderHomogeneityInspectInstallDialog
  105. ref="orderHomogeneityInspectInstallDialog"
  106. ></orderHomogeneityInspectInstallDialog>
  107. </div>
  108. </template>
  109. <script>
  110. import OrderSearch from './components/order-search.vue';
  111. import OrderDetail from './components/order-detail.vue';
  112. import orderHomogeneityInspectDialog from './components/orderHomogeneityInspectDialog';
  113. import orderHomogeneityInspectInstallDialog from './components/orderHomogeneityInspectInstallDialog';
  114. import PlanStatistics from '@/components/statistics/PlanStatistics.vue';
  115. import CreateOrder from './components/create-order.vue';
  116. import {
  117. getPageList,
  118. deleteOrder,
  119. updatePriority,
  120. fieldModel,
  121. getByCodeList
  122. } from '@/api/saleOrder';
  123. import dictMixins from '@/mixins/dictMixins';
  124. import { debounce } from 'lodash';
  125. import { Alert } from 'element-ui';
  126. import tabMixins from '@/mixins/tableColumnsMixin';
  127. export default {
  128. name: 'saleOrder',
  129. mixins: [dictMixins, tabMixins],
  130. components: {
  131. OrderSearch,
  132. OrderDetail,
  133. CreateOrder,
  134. orderHomogeneityInspectDialog,
  135. PlanStatistics,
  136. orderHomogeneityInspectInstallDialog
  137. },
  138. data() {
  139. return {
  140. // 加载状态
  141. loading: false,
  142. activeName: 'first',
  143. selection: [],
  144. columns: [],
  145. cacheKeyUrl: 'c32a9c7d-aps-saleOrder-index',
  146. columnsVersion: 1,
  147. // 订单类型
  148. orderTypeList: [
  149. {
  150. id: 0,
  151. label: '库存性订单'
  152. },
  153. {
  154. id: 1,
  155. label: '生产性订单'
  156. },
  157. {
  158. id: 2,
  159. label: '无客户生产性订单'
  160. },
  161. {
  162. id: 4,
  163. label: '不定向订单'
  164. }
  165. ]
  166. };
  167. },
  168. computed: {
  169. // 表格列配置
  170. // clientEnvironmentId() {
  171. // return
  172. // },
  173. },
  174. created() {
  175. this.setColumns();
  176. this.getFieldModel();
  177. this.requestDict('按单按库');
  178. this.requestDict('交付要求');
  179. this.requestDict('订单类型');
  180. this.requestDict('订单来源');
  181. this.requestDict('生产状态');
  182. },
  183. methods: {
  184. setColumns() {
  185. let clientEnvironmentId =
  186. this.$store.state.user.info.clientEnvironmentId;
  187. this.columns = [
  188. {
  189. width: 45,
  190. type: 'selection',
  191. columnKey: 'selection',
  192. align: 'center',
  193. selectable: (row, index) => {
  194. return this.activeName != 'second';
  195. }
  196. },
  197. {
  198. columnKey: 'index',
  199. label: '序号',
  200. type: 'index',
  201. width: 55,
  202. align: 'center',
  203. showOverflowTooltip: true,
  204. fixed: 'left'
  205. },
  206. {
  207. prop: 'code',
  208. label: '销售订单号',
  209. align: 'center',
  210. showOverflowTooltip: true,
  211. minWidth: 150,
  212. slot: 'code',
  213. sortable: true
  214. },
  215. {
  216. prop: 'lineNumber',
  217. label: '行号',
  218. align: 'center',
  219. showOverflowTooltip: true
  220. },
  221. {
  222. prop: 'productCode',
  223. label: '编码',
  224. align: 'center',
  225. showOverflowTooltip: true,
  226. minWidth: 140,
  227. sortable: true
  228. },
  229. {
  230. prop: 'batchNo',
  231. label: '批次号',
  232. align: 'center',
  233. showOverflowTooltip: true
  234. },
  235. {
  236. prop: 'bomType',
  237. label: 'BOM类型',
  238. align: 'center',
  239. width: 130,
  240. showOverflowTooltip: true,
  241. formatter: (row) => {
  242. if (row.bomType) {
  243. return row.bomType == 1
  244. ? 'PBOM'
  245. : row.bomType == 2
  246. ? 'MBOM'
  247. : row.bomType == 3
  248. ? 'ABOM'
  249. : 'EBOM';
  250. }
  251. return '';
  252. }
  253. },
  254. {
  255. prop: 'versions',
  256. label: 'BOM版本',
  257. align: 'center',
  258. width: 130,
  259. showOverflowTooltip: true,
  260. formatter: (row) => {
  261. if (row.versions) {
  262. return `V${row.versions}.0`;
  263. }
  264. return '';
  265. }
  266. },
  267. {
  268. prop: 'productName',
  269. label: '名称',
  270. align: 'center',
  271. minWidth: 120,
  272. showOverflowTooltip: true
  273. },
  274. {
  275. prop: 'produceRoutingName',
  276. label: '工艺路线',
  277. align: 'center',
  278. minWidth: 120,
  279. showOverflowTooltip: true
  280. },
  281. {
  282. prop: 'modelKey',
  283. label: '机型',
  284. align: 'center',
  285. minWidth: 120,
  286. showOverflowTooltip: true,
  287. formatter: (row) => {
  288. if (row.modelKey) {
  289. return row.modelKey.toString();
  290. }
  291. return '';
  292. }
  293. },
  294. {
  295. prop: 'colorKey',
  296. label: '颜色',
  297. align: 'center',
  298. minWidth: 120,
  299. showOverflowTooltip: true,
  300. formatter: (row) => {
  301. if (row.colorKey) {
  302. return row.colorKey.toString();
  303. }
  304. return '';
  305. }
  306. },
  307. {
  308. prop: 'specification',
  309. label: '规格',
  310. align: 'center',
  311. minWidth: 150,
  312. showOverflowTooltip: true
  313. },
  314. {
  315. prop: 'stockNum',
  316. label: '库存',
  317. align: 'center',
  318. minWidth: 100,
  319. showOverflowTooltip: true
  320. },
  321. {
  322. prop: 'productionCodes',
  323. label: '生产编号',
  324. align: 'center',
  325. minWidth: 150,
  326. showOverflowTooltip: true
  327. },
  328. {
  329. prop: 'brandNo',
  330. label: '牌号',
  331. align: 'center',
  332. showOverflowTooltip: true
  333. },
  334. {
  335. prop: 'model',
  336. label: '型号',
  337. align: 'center',
  338. minWidth: 120,
  339. showOverflowTooltip: true
  340. },
  341. {
  342. prop: 'priority',
  343. label: '优先级',
  344. align: 'center',
  345. minWidth: 120,
  346. slot: 'priority',
  347. sortable: 'custom'
  348. },
  349. {
  350. prop: 'productSumWeight',
  351. label: '订单重量',
  352. align: 'center',
  353. slot: 'productSumWeight'
  354. },
  355. {
  356. prop: 'contractNum',
  357. slot: 'contractNum',
  358. label: clientEnvironmentId == '4' ? '交付数量' : '订单数量',
  359. align: 'center'
  360. },
  361. {
  362. prop: 'lackNum',
  363. label: '欠交数量',
  364. align: 'center'
  365. },
  366. {
  367. prop: 'measuringUnit',
  368. label: '计量单位',
  369. align: 'center'
  370. },
  371. {
  372. prop: 'moCount',
  373. label: '模数',
  374. align: 'center',
  375. show: clientEnvironmentId == '4'
  376. },
  377. {
  378. prop: 'planedNum',
  379. label: '未排完数量',
  380. align: 'center',
  381. formatter: (_row, _column, cellValue) => {
  382. return _row.contractNum - _row.planedNum;
  383. }
  384. },
  385. {
  386. prop: 'blockCount',
  387. label: '块数',
  388. align: 'center',
  389. show: clientEnvironmentId == '4'
  390. },
  391. {
  392. prop: 'orderLibraryType',
  393. label: '按单按库',
  394. align: 'center',
  395. showOverflowTooltip: true,
  396. formatter: (_row, _column, cellValue) => {
  397. return this.getDictValue('按单按库', _row.orderLibraryType);
  398. }
  399. },
  400. {
  401. prop: 'deliveryRequirements',
  402. label: '交付要求',
  403. align: 'center',
  404. showOverflowTooltip: true,
  405. formatter: (_row, _column, cellValue) => {
  406. return this.getDictValue('交付要求', _row.deliveryRequirements);
  407. }
  408. },
  409. {
  410. prop: 'saleType',
  411. label: '销售类型',
  412. align: 'center',
  413. showOverflowTooltip: true,
  414. formatter: (_row, _column, cellValue) => {
  415. return this.getDictValue('订单类型', _row.saleType);
  416. }
  417. },
  418. {
  419. prop: 'orderType',
  420. label: '订单类型',
  421. align: 'center',
  422. showOverflowTooltip: true,
  423. formatter: (_row, _column, cellValue) => {
  424. let obj = this.orderTypeList.find(
  425. (el) => el.id == _row.orderType
  426. );
  427. return obj ? obj.label : '';
  428. }
  429. },
  430. {
  431. prop: 'orderSource',
  432. label: '订单来源',
  433. align: 'center',
  434. showOverflowTooltip: true,
  435. formatter: (_row, _column, cellValue) => {
  436. return this.getDictValue('订单来源', _row.orderSource);
  437. }
  438. },
  439. {
  440. prop: 'status',
  441. label: '生产状态',
  442. align: 'center',
  443. showOverflowTooltip: true,
  444. formatter: (_row, _column, cellValue) => {
  445. return this.getDictValue('生产状态', _row.status);
  446. }
  447. },
  448. {
  449. prop: 'releaseTime',
  450. label: '下达时间',
  451. align: 'center',
  452. showOverflowTooltip: true
  453. },
  454. {
  455. prop: 'deliveryTime',
  456. label: '客户期望交期',
  457. align: 'center',
  458. showOverflowTooltip: true
  459. },
  460. {
  461. prop: 'customerName',
  462. label: '客户名称',
  463. align: 'center',
  464. showOverflowTooltip: true
  465. },
  466. {
  467. prop: 'serialNo',
  468. label: '客户代号',
  469. align: 'center',
  470. showOverflowTooltip: true
  471. },
  472. {
  473. prop: 'simpleName',
  474. label: '客户简称',
  475. align: 'center',
  476. showOverflowTooltip: true
  477. },
  478. {
  479. prop: 'salesman',
  480. label: '业务员',
  481. showOverflowTooltip: true
  482. },
  483. {
  484. prop: 'hostCode',
  485. label: '主机编码',
  486. showOverflowTooltip: true
  487. },
  488. {
  489. prop: 'hostDescription',
  490. label: '主机描述',
  491. showOverflowTooltip: true
  492. }
  493. ];
  494. },
  495. async check(val) {
  496. if (this.selection.length == 0) {
  497. return this.$message.warning('请至少选择一条计划!');
  498. }
  499. for (let i = 0; i < this.selection.length; i++) {
  500. let el = this.selection[i];
  501. // if (!el.bomCategoryId) {
  502. // return this.$message.warning('请选择有BOM版本的数据');
  503. // }
  504. }
  505. let codeList = [];
  506. this.selection.map((ele) => {
  507. if (ele.code) {
  508. codeList.push(ele.code);
  509. }
  510. });
  511. let res = await getByCodeList(codeList);
  512. console.log(res, '0000000000000000');
  513. // let flag = true;
  514. // let type = 0;
  515. let data = [];
  516. let data2 = [];
  517. let first = null;
  518. let firstFlag = true;
  519. if (res) {
  520. for (let ele of res) {
  521. let list = ele.productInfoList;
  522. if (firstFlag) {
  523. first = ele;
  524. firstFlag = false;
  525. }
  526. if (list) {
  527. let pre = null;
  528. for (let item of list) {
  529. // if (!item.productType) {
  530. // flag = false;
  531. // this.$message.warning(
  532. // '产品(' + item.productCode + ')未选择生产类型'
  533. // );
  534. // return;
  535. // }
  536. // type = item.productType;
  537. // if (!item.bomCategoryId) {
  538. // flag = false;
  539. // this.$message.warning(
  540. // '产品(' + item.productCode + ')未选择BOM版本'
  541. // );
  542. // return;
  543. // }
  544. // if (pre) {
  545. // if (pre.productType != item.productType) {
  546. // flag = false;
  547. // this.$message.warning('请选择生产类型相同的订单');
  548. // return;
  549. // }
  550. // }
  551. pre = item;
  552. // JSON.parse(JSON.stringify({}))
  553. data.push(item.id);
  554. item.code = ele.code;
  555. data2.push(item);
  556. }
  557. }
  558. }
  559. }
  560. this.$refs.orderHomogeneityInspectDialog.open(
  561. data2,
  562. first,
  563. 'list',
  564. val
  565. );
  566. // if (flag) {
  567. // // 齐料
  568. // if (type == 2) {
  569. // this.$refs.orderHomogeneityInspectDialog.open(data2, first);
  570. // } else if (type == 3) {
  571. // this.$refs.orderHomogeneityInspectInstallDialog.open(data);
  572. // } else {
  573. // this.$message.warning('请确认生产类型!');
  574. // }
  575. // }
  576. },
  577. getFieldModel() {
  578. fieldModel({ fieldModel: 't_main_category' }).then((res) => {
  579. const privateColumn = [];
  580. if (this.activeName == 'first') {
  581. privateColumn.push({
  582. columnKey: 'action',
  583. label: '操作',
  584. width: 130,
  585. align: 'center',
  586. resizable: false,
  587. slot: 'action',
  588. fixed: 'right'
  589. });
  590. } else {
  591. privateColumn = [];
  592. }
  593. let newRes = res.map((m) => {
  594. return {
  595. prop: 'extField.' + m.prop,
  596. label: m.label,
  597. align: 'center',
  598. showOverflowTooltip: true
  599. };
  600. });
  601. // console.log(this._newColumns, 'newRes');
  602. this.columns = [...this.columns, ...newRes, ...privateColumn];
  603. // console.log(this.newColumns, 'productCode')
  604. this.getTabColumns();
  605. // this.$forceUpdate();
  606. });
  607. },
  608. /* 表格数据源 */
  609. async datasource({ page, limit, where, order }) {
  610. if (this.activeName == 'first') {
  611. where.status = [1];
  612. } else if (this.activeName == 'three') {
  613. where.status = [0];
  614. } else {
  615. if (where.proStu) {
  616. where.status = [where.proStu];
  617. } else {
  618. where.status = [2, 3, 4, 5, 6, 7];
  619. }
  620. }
  621. const params = {
  622. size: limit,
  623. pageNum: page,
  624. ...where,
  625. ...this.sort
  626. };
  627. const data = await getPageList(params);
  628. console.log(data, 'data');
  629. return data;
  630. },
  631. /* 刷新表格 */
  632. reload(where) {
  633. this.$nextTick(() =>
  634. this.$refs.table.reload({ page: 1, limit: 10, where })
  635. );
  636. },
  637. changeTab(e) {
  638. console.log(e);
  639. this.$forceUpdate();
  640. },
  641. openDetails(row) {
  642. this.$refs.detailDialog.open(row);
  643. },
  644. toUpdate(row) {
  645. this.$refs.createDialog.open(row);
  646. },
  647. remove(row) {
  648. deleteOrder([row.id]).then((res) => {
  649. this.$message.success(res);
  650. this.reload();
  651. });
  652. },
  653. onSortChange(e) {
  654. let sort = {
  655. orderBy: e.order,
  656. sortName: e.prop
  657. };
  658. this.sort = sort;
  659. this.reload();
  660. },
  661. sortTop(row) {
  662. row.priority = Number(row.priority) + 1;
  663. this.priorityChange(row);
  664. },
  665. sortBottom(row) {
  666. if (row.priority <= 1) {
  667. return;
  668. }
  669. row.priority = Number(row.priority) - 1;
  670. this.priorityChange(row);
  671. },
  672. priorityChange(row) {
  673. if (row.priority > 10) {
  674. row.priority = 10; // 如果大于 10,则设置为 10
  675. } else if (row.priority < 0) {
  676. row.priority = 0; // 如果小于 0,则设置为 0
  677. }
  678. this.priorityFn(row);
  679. },
  680. priorityFn: debounce(function (row) {
  681. let params = {
  682. id: row.id,
  683. priority: row.priority
  684. };
  685. updatePriority(params).then((res) => {});
  686. }, 800)
  687. }
  688. };
  689. </script>
  690. <style lang="scss" scoped></style>