index.vue 9.1 KB

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