index.vue 18 KB

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