index.vue 10 KB

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