index.vue 17 KB

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