index.vue 10 KB

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