index.vue 16 KB

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