produceOrder.vue 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336
  1. <template>
  2. <div class="ele-body">
  3. <el-card shadow="never" v-loading="loading">
  4. <produceOrder-search
  5. @search="reload"
  6. ref="searchRef"
  7. :statusOpt="statusOpt"
  8. :planType="planType"
  9. :activeName="activeName"
  10. >
  11. </produceOrder-search>
  12. <el-tabs v-model="activeName" type="card">
  13. <el-tab-pane label="未完成工单" name="first"></el-tab-pane>
  14. <el-tab-pane label="已完成工单" name="second"></el-tab-pane>
  15. </el-tabs>
  16. <!-- 数据表格 -->
  17. <ele-pro-table
  18. ref="table"
  19. :key="activeName"
  20. :initLoad="false"
  21. :columns="newColumns"
  22. :datasource="datasource"
  23. row-key="code"
  24. :cache-key="`${activeName}produceOrderTable`"
  25. autoAmendPage
  26. >
  27. <template v-slot:code="{ row }">
  28. <span>{{ row.code }}</span>
  29. </template>
  30. <template v-slot:formingNum="{ row }">
  31. <span> {{ row.formingNum }} {{ row.unit }} </span>
  32. </template>
  33. <template v-slot:formingWeight="{ row }">
  34. <span> {{ row.formingNum }} {{ row.weightUnit }} </span>
  35. </template>
  36. <template v-slot:status="{ row }">
  37. <span :class="{ 'ele-text-danger': row.status == 3 }">
  38. {{ statusFormatter(row.status) }}
  39. </span>
  40. </template>
  41. </ele-pro-table>
  42. </el-card>
  43. </div>
  44. </template>
  45. <script>
  46. import { getPage } from '@/api/mes/index.js';
  47. import { fieldModelAPI } from '@/api/main';
  48. import produceOrderSearch from './produceOrder-search.vue';
  49. export default {
  50. components: {
  51. produceOrderSearch
  52. },
  53. props: {
  54. saleOrderData: {
  55. type: Object,
  56. default: () => {
  57. return {};
  58. }
  59. }
  60. },
  61. data() {
  62. return {
  63. activeName: 'first',
  64. // 加载状态
  65. loading: false,
  66. statusOpt: {
  67. first: [
  68. { label: '所有状态', value: '5,4' },
  69. { label: '待生产', value: '4' },
  70. { label: '生产中', value: '5' }
  71. // { label: '已延期', value: '7' }
  72. ],
  73. second: [{ label: '已完成', value: '6' }]
  74. },
  75. planType: [
  76. { label: '所有计划类型', value: null },
  77. { label: '内销计划', value: '1' },
  78. { label: '外销计划', value: '2' },
  79. { label: '预制计划', value: '3' }
  80. ],
  81. newColumns: []
  82. };
  83. },
  84. computed: {
  85. // 表格列配置
  86. columns() {
  87. const opt = {
  88. first: [
  89. // {
  90. // prop: 'deliveryTime',
  91. // label: '预测交货日期',
  92. // align: 'center',
  93. // showOverflowTooltip: true,
  94. // minWidth: 110
  95. // }
  96. ],
  97. second: [
  98. {
  99. prop: 'completeTime',
  100. label: '完成时间',
  101. align: 'center'
  102. },
  103. {
  104. prop: 'cycle',
  105. label: '生产周期',
  106. align: 'center'
  107. }
  108. ]
  109. };
  110. return [
  111. {
  112. prop: 'batchNo',
  113. label: '批次号',
  114. align: 'center',
  115. minWidth: 100
  116. },
  117. {
  118. slot: 'code',
  119. label: '生产工单号',
  120. align: 'center',
  121. minWidth: 110
  122. },
  123. // {
  124. // prop: 'originalCode',
  125. // label: '原始工单号',
  126. // align: 'center',
  127. // minWidth: 110
  128. // },
  129. {
  130. slot: 'QRcode',
  131. label: '二维码',
  132. align: 'center',
  133. minWidth: 110
  134. },
  135. {
  136. prop: 'productionPlanCode',
  137. label: '计划编号',
  138. align: 'center',
  139. minWidth: 110
  140. },
  141. {
  142. prop: 'planType',
  143. label: '计划类型',
  144. align: 'center',
  145. formatter: (row) => {
  146. const obj = this.planType.find((i) => i.value == row.planType);
  147. return obj && obj.label;
  148. }
  149. },
  150. {
  151. prop: 'produceRoutingName',
  152. label: '工艺路线',
  153. align: 'center'
  154. },
  155. {
  156. prop: 'productCode',
  157. label: '物料编码',
  158. align: 'center'
  159. },
  160. {
  161. prop: 'productName',
  162. label: '产品名称',
  163. align: 'center'
  164. },
  165. {
  166. prop: 'brandNo',
  167. label: '牌号',
  168. align: 'center'
  169. },
  170. {
  171. prop: 'model',
  172. label: '型号',
  173. align: 'center'
  174. },
  175. {
  176. prop: 'priority',
  177. label: '优先级',
  178. align: 'center',
  179. minWidth: 120,
  180. slot: 'priority',
  181. sortable: 'custom'
  182. },
  183. {
  184. prop: 'formingNum',
  185. label: '要求生产数量',
  186. align: 'center',
  187. slot: 'formingNum',
  188. showOverflowTooltip: true,
  189. minWidth: 110
  190. },
  191. {
  192. prop: 'formingWeight',
  193. label: '要求生产重量',
  194. slot: 'formingWeight',
  195. align: 'center',
  196. showOverflowTooltip: true,
  197. minWidth: 110
  198. },
  199. {
  200. prop: 'formedNum',
  201. label: '已生产数量',
  202. align: 'center',
  203. showOverflowTooltip: true,
  204. minWidth: 110
  205. },
  206. {
  207. prop: 'formedWeight',
  208. label: '已生产重量',
  209. align: 'center',
  210. showOverflowTooltip: true,
  211. minWidth: 110
  212. },
  213. {
  214. prop: 'planStartTime',
  215. label: '计划开始时间',
  216. align: 'center',
  217. showOverflowTooltip: true,
  218. minWidth: 110
  219. },
  220. {
  221. prop: 'planCompleteTime',
  222. label: '计划结束时间',
  223. align: 'center',
  224. showOverflowTooltip: true,
  225. minWidth: 110
  226. },
  227. {
  228. prop: 'startTime',
  229. label: '实际开始时间',
  230. align: 'center',
  231. showOverflowTooltip: true,
  232. minWidth: 110
  233. },
  234. ...opt[this.activeName],
  235. {
  236. prop: 'createTime',
  237. label: '创建时间',
  238. align: 'center',
  239. showOverflowTooltip: true,
  240. minWidth: 110
  241. },
  242. {
  243. slot: 'status',
  244. label: '状态',
  245. align: 'center',
  246. formatter: (row) => {
  247. const obj = this.statusOpt[this.activeName].find(
  248. (i) => i.value == row.status
  249. );
  250. return obj && obj.label;
  251. }
  252. },
  253. {
  254. prop: 'teamName',
  255. label: '班组',
  256. align: 'center',
  257. showOverflowTooltip: true
  258. }
  259. ];
  260. },
  261. clientEnvironmentId() {
  262. return this.$store.state.user.info.clientEnvironmentId;
  263. }
  264. },
  265. created() {
  266. this.getFieldModel();
  267. },
  268. methods: {
  269. statusFormatter(status) {
  270. const obj = this.statusOpt[this.activeName].find(
  271. (i) => i.value == status
  272. );
  273. return obj && obj.label;
  274. },
  275. /* 表格数据源 */
  276. async datasource({ page, limit, where, order }) {
  277. if (this.saleOrderData.id) {
  278. where['saleOrderCode'] = this.saleOrderData.orderNo;
  279. }
  280. let res = await getPage({
  281. ...where,
  282. ...order,
  283. pageNum: page,
  284. size: limit,
  285. ...this.sort
  286. });
  287. // res['list'] = this.flattenArray(res.list)
  288. return res;
  289. },
  290. getFieldModel() {
  291. fieldModelAPI({ fieldModel: 't_main_category' }).then((res) => {
  292. let newRes = res.map((m) => {
  293. return {
  294. prop: 'extField.' + m.prop,
  295. label: m.label,
  296. align: 'center',
  297. showOverflowTooltip: true
  298. };
  299. });
  300. this.newColumns = [...this.columns, ...newRes];
  301. this.$forceUpdate();
  302. });
  303. },
  304. /* 刷新表格 */
  305. reload(where = {}) {
  306. this.$nextTick(() => {
  307. where.statusList = (
  308. where.status || this.statusOpt[this.activeName][0].value
  309. ).split(',');
  310. this.$refs.table.reload({ page: 1, where });
  311. });
  312. }
  313. }
  314. };
  315. </script>