index.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459
  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. >
  10. </order-search>
  11. <el-tabs v-model="activeName" type="card" >
  12. <el-tab-pane label="待排产" name="first"></el-tab-pane>
  13. <el-tab-pane label="已排产" name="second"></el-tab-pane>
  14. </el-tabs>
  15. <!-- 数据表格 -->
  16. <ele-pro-table
  17. ref="table"
  18. :columns="newColumns"
  19. :initLoad="false"
  20. :datasource="datasource"
  21. :selection.sync="selection"
  22. cache-key="systemRoleTable1"
  23. height="calc(100vh - 335px)"
  24. row-key="id"
  25. @sort-change="onSortChange"
  26. >
  27. <template v-slot:code="{ row }">
  28. <el-link :underline="false" @click="openDetails(row)">
  29. {{ row.code }}
  30. </el-link>
  31. </template>
  32. <template v-slot:priority="{ row }">
  33. <div style="display: flex">
  34. <el-input
  35. v-model="row.priority"
  36. type="number"
  37. size="mini"
  38. :min="0"
  39. :max="10"
  40. @change="priorityChange(row)"
  41. style="width: 80px"
  42. ></el-input>
  43. <el-popover
  44. placement="right"
  45. width="200"
  46. trigger="hover"
  47. content="数值越大优先级越高(0-3普通, 4-6优先, 7-10紧急)"
  48. >
  49. <div class="sort-wrap" slot="reference">
  50. <i class="el-icon-caret-top" @click="sortTop(row)"></i>
  51. <i class="el-icon-caret-bottom" @click="sortBottom(row)"></i>
  52. </div>
  53. </el-popover>
  54. </div>
  55. </template>
  56. <template v-slot:productSumWeight="{ row }">
  57. {{ row.productSumWeight }}
  58. </template>
  59. <!-- 操作列 -->
  60. <template v-slot:action="{ row }">
  61. <template>
  62. <el-link
  63. v-if="row.orderSource != 1"
  64. type="primary"
  65. :underline="false"
  66. icon="el-icon-edit"
  67. @click="toUpdate(row)"
  68. >
  69. 修改
  70. </el-link>
  71. <el-popconfirm
  72. v-if="row.orderSource != 1 "
  73. class="ele-action"
  74. title="确定要删除此销售订单吗?"
  75. @confirm="remove(row)"
  76. >
  77. <template v-slot:reference>
  78. <el-link type="danger" :underline="false" icon="el-icon-delete">
  79. 删除
  80. </el-link>
  81. </template>
  82. </el-popconfirm>
  83. </template>
  84. </template>
  85. </ele-pro-table>
  86. </el-card>
  87. <!-- 详情弹窗 -->
  88. <order-detail @refresh="reload" ref="detailDialog"> </order-detail>
  89. <!-- 创建订单 -->
  90. <create-order ref="createDialog" @refresh="reload"> </create-order>
  91. </div>
  92. </template>
  93. <script>
  94. import OrderSearch from './components/order-search.vue';
  95. import OrderDetail from './components/order-detail.vue';
  96. import CreateOrder from './components/create-order.vue';
  97. import {
  98. getPageList,
  99. deleteOrder,
  100. updatePriority,
  101. fieldModel
  102. } from '@/api/saleOrder';
  103. import dictMixins from '@/mixins/dictMixins';
  104. import { debounce } from 'lodash';
  105. import { Alert } from 'element-ui';
  106. export default {
  107. name: 'saleOrder',
  108. mixins: [dictMixins],
  109. components: {
  110. OrderSearch,
  111. OrderDetail,
  112. CreateOrder
  113. },
  114. data() {
  115. return {
  116. // 加载状态
  117. loading: false,
  118. activeName: 'first',
  119. selection: [],
  120. newColumns: []
  121. };
  122. },
  123. computed: {
  124. // 表格列配置
  125. clientEnvironmentId() {
  126. return this.$store.state.user.info.clientEnvironmentId;
  127. },
  128. columns() {
  129. return [
  130. {
  131. width: 45,
  132. type: 'selection',
  133. columnKey: 'selection',
  134. align: 'center'
  135. },
  136. {
  137. columnKey: 'index',
  138. label: '序号',
  139. type: 'index',
  140. width: 55,
  141. align: 'center',
  142. showOverflowTooltip: true,
  143. fixed: 'left'
  144. },
  145. {
  146. prop: 'code',
  147. label: '销售订单号',
  148. align: 'center',
  149. showOverflowTooltip: true,
  150. minWidth: 150,
  151. slot: 'code',
  152. sortable: true
  153. },
  154. {
  155. prop: 'lineNumber',
  156. label: '行号',
  157. align: 'center',
  158. showOverflowTooltip: true
  159. },
  160. {
  161. prop: 'productCode',
  162. label: '产品编码',
  163. align: 'center',
  164. showOverflowTooltip: true,
  165. minWidth: 140,
  166. sortable: true
  167. },
  168. {
  169. prop: 'productName',
  170. label: '产品名称',
  171. align: 'center',
  172. minWidth: 120
  173. },
  174. {
  175. prop: 'produceRoutingName',
  176. label: '工艺路线',
  177. align: 'center',
  178. minWidth: 120
  179. },
  180. {
  181. prop: 'brandNo',
  182. label: '牌号',
  183. align: 'center'
  184. },
  185. {
  186. prop: 'specification',
  187. label: '规格',
  188. align: 'center',
  189. minWidth: 150,
  190. showOverflowTooltip: true
  191. },
  192. {
  193. prop: 'model',
  194. label: '型号',
  195. align: 'center',
  196. minWidth: 120,
  197. },
  198. {
  199. prop: 'priority',
  200. label: '优先级',
  201. align: 'center',
  202. minWidth: 120,
  203. slot: 'priority',
  204. sortable: 'custom'
  205. },
  206. {
  207. prop: 'productSumWeight',
  208. label: '合同重量',
  209. align: 'center',
  210. slot: 'productSumWeight'
  211. },
  212. {
  213. prop: 'contractNum',
  214. label: this.clientEnvironmentId == '4' ? '交付数量' : '合同数量',
  215. align: 'center'
  216. },
  217. {
  218. prop: 'lackNum',
  219. label: '欠交数量',
  220. align: 'center'
  221. },
  222. // {
  223. // prop: 'moCount',
  224. // label: '模数',
  225. // align: 'center',
  226. // show: this.clientEnvironmentId == '4'
  227. // },
  228. // {
  229. // prop: 'blockCount',
  230. // label: '块数',
  231. // align: 'center',
  232. // show: this.clientEnvironmentId == '4'
  233. // },
  234. {
  235. prop: 'orderLibraryType',
  236. label: '按单按库',
  237. align: 'center',
  238. showOverflowTooltip: true,
  239. formatter: (_row, _column, cellValue) => {
  240. return this.getDictValue('按单按库', _row.orderLibraryType);
  241. }
  242. },
  243. {
  244. prop: 'deliveryRequirements',
  245. label: '交付要求',
  246. align: 'center',
  247. showOverflowTooltip: true,
  248. formatter: (_row, _column, cellValue) => {
  249. return this.getDictValue('交付要求', _row.deliveryRequirements);
  250. }
  251. },
  252. {
  253. prop: 'orderType',
  254. label: '订单类型',
  255. align: 'center',
  256. showOverflowTooltip: true,
  257. formatter: (_row, _column, cellValue) => {
  258. return this.getDictValue('订单类型', _row.orderType);
  259. }
  260. },
  261. {
  262. prop: 'orderSource',
  263. label: '订单来源',
  264. align: 'center',
  265. showOverflowTooltip: true,
  266. formatter: (_row, _column, cellValue) => {
  267. return this.getDictValue('订单来源', _row.orderSource);
  268. }
  269. },
  270. {
  271. prop: 'status',
  272. label: '生产状态',
  273. align: 'center',
  274. showOverflowTooltip: true,
  275. formatter: (_row, _column, cellValue) => {
  276. return this.getDictValue('生产状态', _row.status);
  277. }
  278. },
  279. {
  280. prop: 'releaseTime',
  281. label: '下达时间',
  282. align: 'center',
  283. showOverflowTooltip: true
  284. },
  285. {
  286. prop: 'deliveryTime',
  287. label: '交付日期',
  288. align: 'center',
  289. showOverflowTooltip: true
  290. },
  291. {
  292. prop: 'customerName',
  293. label: '客户名称',
  294. align: 'center',
  295. showOverflowTooltip: true
  296. },
  297. {
  298. prop: 'serialNo',
  299. label: '客户代号',
  300. align: 'center',
  301. showOverflowTooltip: true
  302. },
  303. {
  304. prop: 'simpleName',
  305. label: '客户简称',
  306. align: 'center',
  307. showOverflowTooltip: true
  308. },
  309. {
  310. prop: 'salesman',
  311. label: '业务员',
  312. showOverflowTooltip: true
  313. }
  314. ];
  315. }
  316. },
  317. created() {
  318. this.getFieldModel();
  319. this.requestDict('按单按库');
  320. this.requestDict('交付要求');
  321. this.requestDict('订单类型');
  322. this.requestDict('订单来源');
  323. this.requestDict('生产状态');
  324. },
  325. methods: {
  326. getFieldModel() {
  327. fieldModel({ fieldModel: 't_main_category' }).then((res) => {
  328. const privateColumn = [];
  329. if (this.activeName == 'first') {
  330. privateColumn.push({
  331. columnKey: 'action',
  332. label: '操作',
  333. width: 130,
  334. align: 'center',
  335. resizable: false,
  336. slot: 'action',
  337. fixed: 'right'
  338. });
  339. } else {
  340. privateColumn = [];
  341. }
  342. let newRes = res.map((m) => {
  343. return {
  344. prop: 'extField.' + m.prop,
  345. label: m.label,
  346. align: 'center',
  347. showOverflowTooltip: true
  348. };
  349. });
  350. this.newColumns = [...this.columns, ...newRes, ...privateColumn];
  351. this.$forceUpdate();
  352. });
  353. },
  354. /* 表格数据源 */
  355. async datasource({ page, limit, where, order }) {
  356. if (this.activeName == 'first') {
  357. where.status = [1];
  358. } else {
  359. if (where.proStu) {
  360. where.status = [where.proStu];
  361. } else {
  362. where.status = [2, 3, 4, 5, 6, 7];
  363. }
  364. }
  365. const params = {
  366. size: limit,
  367. pageNum: page,
  368. ...where,
  369. ...this.sort
  370. };
  371. const data = await getPageList(params);
  372. return data;
  373. },
  374. /* 刷新表格 */
  375. reload(where) {
  376. this.$nextTick(() =>
  377. this.$refs.table.reload({ page: 1, limit: 10, where })
  378. );
  379. },
  380. openDetails(row) {
  381. this.$refs.detailDialog.open(row);
  382. },
  383. toUpdate(row) {
  384. this.$refs.createDialog.open(row);
  385. },
  386. remove(row) {
  387. deleteOrder([row.id]).then((res) => {
  388. this.$message.success(res);
  389. this.reload();
  390. });
  391. },
  392. onSortChange(e) {
  393. let sort = {
  394. orderBy: e.order,
  395. sortName: e.prop
  396. };
  397. this.sort = sort;
  398. this.reload();
  399. },
  400. sortTop(row) {
  401. row.priority = Number(row.priority) + 1;
  402. this.priorityChange(row);
  403. },
  404. sortBottom(row) {
  405. if (row.priority <= 1) {
  406. return;
  407. }
  408. row.priority = Number(row.priority) - 1;
  409. this.priorityChange(row);
  410. },
  411. priorityChange(row) {
  412. if (row.priority > 10) {
  413. row.priority = 10; // 如果大于 10,则设置为 10
  414. } else if (row.priority < 0) {
  415. row.priority = 0; // 如果小于 0,则设置为 0
  416. }
  417. this.priorityFn(row);
  418. },
  419. priorityFn: debounce(function (row) {
  420. let params = {
  421. id: row.id,
  422. priority: row.priority
  423. };
  424. updatePriority(params).then((res) => {});
  425. }, 800)
  426. }
  427. };
  428. </script>
  429. <style lang="scss" scoped></style>