index.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446
  1. r++<template>
  2. <div class="ele-body">
  3. <el-card shadow="never" v-loading="loading">
  4. <order-search @search="reload" ref="searchRef"> </order-search>
  5. <!-- 数据表格 -->
  6. <ele-pro-table
  7. ref="table"
  8. :columns="newColumns"
  9. :datasource="datasource"
  10. :cache-key="cacheKeyUrl"
  11. :height="tableHeight"
  12. @sort-change="onSortChange"
  13. @columns-change="handleColumnChange"
  14. @fullscreen-change="fullscreenChange"
  15. :pageSize="20"
  16. >
  17. <template v-slot:code="{ row }">
  18. <!-- <el-link type="primary" :underline="false" @click="goDetail(row)"> -->
  19. {{ row.code }}
  20. <!-- </el-link> -->
  21. </template>
  22. <template v-slot:sourceType="{ row }">
  23. <span v-if="row.sourceType == 1">生产计划</span>
  24. <span v-if="row.sourceType == 2">临时生产计划</span>
  25. <span v-if="row.sourceType == 3">受托转订单</span>
  26. </template>
  27. <template v-slot:workOrderType="{ row }">
  28. <span v-if="row.workOrderType == 1">普通订单</span>
  29. <span v-if="row.workOrderType == 2">临时订单</span>
  30. <span v-if="row.workOrderType == 3">受托订单</span>
  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:status="{ row }">
  57. <span :class="{ 'ele-text-danger': row.status == 3 }">
  58. {{ statusFormatter(row.status) }}
  59. </span>
  60. </template>
  61. <template v-slot:crewNames="{ row }">
  62. <span v-if="row.crewNames">
  63. {{ row.crewNames }}
  64. </span>
  65. <span v-if="row.workstationNames">
  66. {{ row.workstationNames }}
  67. </span>
  68. </template>
  69. </ele-pro-table>
  70. </el-card>
  71. <el-dialog :visible.sync="visible" title="选择班组" width="400px">
  72. <el-select v-model="releasParams.teamId">
  73. <el-option
  74. v-for="item in teamList"
  75. :value="item.id"
  76. :key="item.id"
  77. :label="item.name"
  78. ></el-option>
  79. </el-select>
  80. <div class="footer" slot="footer">
  81. <el-button @click="visible = false">取消</el-button>
  82. <el-button type="primary">确定</el-button>
  83. </div>
  84. </el-dialog>
  85. </div>
  86. </template>
  87. <script>
  88. import {
  89. getList,
  90. releaseWorkOrder,
  91. updatePriority,
  92. fieldModel
  93. } from '@/api/produceWord/index.js';
  94. import OrderSearch from './components/order-search.vue';
  95. import { debounce } from 'lodash';
  96. import tableColumnsMixin from '@/mixins/tableColumnsMixin';
  97. export default {
  98. mixins: [tableColumnsMixin],
  99. components: {
  100. OrderSearch
  101. },
  102. data() {
  103. return {
  104. visible: false,
  105. loading: false,
  106. releasParams: {
  107. teamId: '',
  108. id: ''
  109. },
  110. teamList: [],
  111. newColumns: [],
  112. statusOpt: [
  113. { label: '待生产', value: 4 },
  114. { label: '生产中', value: 5 },
  115. { label: '已完成', value: 6 },
  116. { label: '已延期', value: 7 },
  117. { label: '待下达', value: 8 }
  118. ],
  119. cacheKeyUrl: '0c2fb832-mes-produceWord',
  120. columnsVersion: 0,
  121. tableHeight: 'calc(100vh - 380px)'
  122. };
  123. },
  124. computed: {
  125. // 表格列配置
  126. columns() {
  127. const num = this.columnsVersion;
  128. return [
  129. {
  130. columnKey: 'index',
  131. label: '序号',
  132. type: 'index',
  133. width: 55,
  134. align: 'center',
  135. showOverflowTooltip: true,
  136. fixed: 'left'
  137. },
  138. {
  139. prop: 'batchNo',
  140. label: '批次号',
  141. align: 'center',
  142. minWidth: 100,
  143. showOverflowTooltip: true
  144. },
  145. {
  146. prop: 'code',
  147. slot: 'code',
  148. label: '生产订单号',
  149. align: 'center',
  150. minWidth: 110,
  151. showOverflowTooltip: true
  152. },
  153. {
  154. prop: 'productionPlanCode',
  155. label: '计划编码',
  156. align: 'center',
  157. showOverflowTooltip: true
  158. },
  159. {
  160. prop: 'produceRoutingName',
  161. label: '工艺路线',
  162. align: 'center',
  163. showOverflowTooltip: true
  164. },
  165. {
  166. prop: 'productCode',
  167. label: '编码',
  168. align: 'center',
  169. showOverflowTooltip: true
  170. },
  171. {
  172. prop: 'productionCodes',
  173. label: '生产编号',
  174. align: 'center',
  175. showOverflowTooltip: true
  176. },
  177. {
  178. prop: 'productName',
  179. label: '名称',
  180. align: 'center',
  181. showOverflowTooltip: true
  182. },
  183. {
  184. prop: 'brandNo',
  185. label: '牌号',
  186. align: 'center',
  187. showOverflowTooltip: true
  188. },
  189. {
  190. prop: 'sourceType',
  191. label: '来源类型',
  192. slot: 'sourceType',
  193. align: 'center',
  194. minWidth: 110,
  195. showOverflowTooltip: true
  196. },
  197. {
  198. prop: 'sourceCode',
  199. label: '来源编码',
  200. align: 'center',
  201. minWidth: 110,
  202. showOverflowTooltip: true
  203. },
  204. {
  205. prop: 'workOrderType',
  206. label: '订单类型',
  207. slot: 'workOrderType',
  208. align: 'center',
  209. minWidth: 110,
  210. showOverflowTooltip: true
  211. },
  212. {
  213. prop: 'model',
  214. label: '型号',
  215. align: 'center',
  216. showOverflowTooltip: true
  217. },
  218. {
  219. prop: 'colorKey',
  220. label: '颜色',
  221. align: 'center',
  222. showOverflowTooltip: true,
  223. minWidth: 110
  224. },
  225. {
  226. prop: 'modelKey',
  227. label: '机型',
  228. align: 'center',
  229. showOverflowTooltip: true,
  230. minWidth: 110
  231. },
  232. {
  233. prop: 'specification',
  234. label: '规格',
  235. align: 'center',
  236. showOverflowTooltip: true
  237. },
  238. {
  239. prop: 'priority',
  240. label: '优先级',
  241. align: 'center',
  242. minWidth: 120,
  243. slot: 'priority',
  244. sortable: 'custom',
  245. showOverflowTooltip: true
  246. },
  247. {
  248. prop: 'formingNum',
  249. label: '要求生产数量',
  250. align: 'center',
  251. showOverflowTooltip: true,
  252. minWidth: 110
  253. },
  254. {
  255. prop: 'formingWeight',
  256. label: '要求生产重量',
  257. align: 'center',
  258. showOverflowTooltip: true,
  259. minWidth: 110
  260. },
  261. {
  262. prop: 'planStartTime',
  263. label: '计划开始时间',
  264. align: 'center',
  265. showOverflowTooltip: true,
  266. minWidth: 110
  267. },
  268. {
  269. prop: 'planCompleteTime',
  270. label: '计划结束时间',
  271. align: 'center',
  272. showOverflowTooltip: true,
  273. minWidth: 110
  274. },
  275. {
  276. prop: 'completeTime',
  277. label: '实际完成时间',
  278. align: 'center',
  279. showOverflowTooltip: true,
  280. minWidth: 110
  281. },
  282. {
  283. prop: 'createTime',
  284. label: '创建时间',
  285. align: 'center',
  286. showOverflowTooltip: true,
  287. minWidth: 110,
  288. sortable: 'custom'
  289. },
  290. {
  291. prop: 'status',
  292. slot: 'status',
  293. label: '状态',
  294. align: 'center',
  295. formatter: (row) => {
  296. const obj = this.statusOpt.find((i) => i.value == row.status);
  297. return obj && obj.label;
  298. }
  299. },
  300. {
  301. prop: 'teamName',
  302. label: '班组',
  303. align: 'center',
  304. showOverflowTooltip: true,
  305. minWidth: 140
  306. },
  307. {
  308. prop: 'crewNames',
  309. label: '人员/工位',
  310. align: 'center',
  311. slot: 'crewNames',
  312. showOverflowTooltip: true,
  313. minWidth: 160
  314. }
  315. // {
  316. // columnKey: 'action',
  317. // label: '操作',
  318. // width: 90,
  319. // align: 'center',
  320. // resizable: false,
  321. // fixed: 'right',
  322. // slot: 'action',
  323. // showOverflowTooltip: true
  324. // }
  325. ];
  326. }
  327. },
  328. created() {
  329. this.getFieldModel();
  330. },
  331. methods: {
  332. statusFormatter(status) {
  333. const obj = this.statusOpt.find((i) => i.value == status);
  334. return obj && obj.label;
  335. },
  336. /* 表格数据源 */
  337. datasource({ page, limit, where }) {
  338. if (where.status) {
  339. where.statusList = [];
  340. where.statusList.push(where.status);
  341. } else {
  342. where.statusList = [4, 5, 6, 7];
  343. }
  344. return getList({
  345. pageNum: page,
  346. size: limit,
  347. ...where,
  348. ...this.sort
  349. });
  350. },
  351. /* 刷新表格 */
  352. reload(where) {
  353. this.$nextTick(() => {
  354. this.$refs.table.reload({ page: 1, where });
  355. });
  356. },
  357. onSortChange(e) {
  358. let sort = {
  359. orderBy: e.order,
  360. sortName: e.prop
  361. };
  362. this.sort = sort;
  363. this.reload();
  364. },
  365. fullscreenChange(fullscreen) {
  366. if (fullscreen) {
  367. this.tableHeight = 'calc(100vh - 120px)';
  368. } else {
  369. this.tableHeight = 'calc(100vh - 380px)';
  370. }
  371. },
  372. getFieldModel() {
  373. fieldModel({ fieldModel: 't_main_category' }).then((res) => {
  374. let newRes = res.map((m) => {
  375. return {
  376. prop: 'extField.' + m.prop,
  377. label: m.label,
  378. align: 'center',
  379. showOverflowTooltip: true
  380. };
  381. });
  382. this.newColumns = [...this.columns, ...newRes];
  383. this.getTabColumns();
  384. this.$forceUpdate();
  385. });
  386. },
  387. sortTop(row) {
  388. row.priority = Number(row.priority) + 1;
  389. this.priorityChange(row);
  390. },
  391. sortBottom(row) {
  392. if (row.priority <= 1) {
  393. return;
  394. }
  395. row.priority = Number(row.priority) - 1;
  396. this.priorityChange(row);
  397. },
  398. priorityChange(row) {
  399. if (row.priority > 10) {
  400. row.priority = 10; // 如果大于 10,则设置为 10
  401. } else if (row.priority < 0) {
  402. row.priority = 0; // 如果小于 0,则设置为 0
  403. }
  404. this.priorityFn(row);
  405. },
  406. priorityFn: debounce(function (row) {
  407. let params = {
  408. id: row.id,
  409. priority: row.priority
  410. };
  411. updatePriority(params).then((res) => {});
  412. }, 800)
  413. }
  414. };
  415. </script>
  416. <style lang="scss" scoped></style>