index.vue 20 KB

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