produceOrder.vue 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274
  1. <template>
  2. <div>
  3. <ele-pro-table
  4. ref="table"
  5. :height="internalIsFullscreen ? '400px' : '300px'"
  6. :columns="columns"
  7. width="100%"
  8. :datasource="datasource"
  9. :selection.sync="selection"
  10. @selection-change="handleSelectionChange"
  11. cache-key="produceOrderZ"
  12. highlight-current-row
  13. @row-click="rowClick"
  14. :need-page="false"
  15. >
  16. <template v-slot:toolbar>
  17. <div class="c_title">工单列表 </div>
  18. </template>
  19. <template v-slot:code="{ row }">
  20. <el-link type="primary" @click="handRoute(row)" :underline="false">{{
  21. row.code
  22. }}</el-link>
  23. </template>
  24. <template v-slot:formingNum="{ row }">
  25. <span> {{ row.formingNum }} {{ row.unit }} </span>
  26. </template>
  27. <template v-slot:formingWeight="{ row }">
  28. <span> {{ row.formingNum }} {{ row.weightUnit }} </span>
  29. </template>
  30. </ele-pro-table>
  31. <routings
  32. v-if="routingShow"
  33. :routeObj="routeObj"
  34. @closeRoute="closeRoute"
  35. ></routings>
  36. </div>
  37. </template>
  38. <script>
  39. import { workorderPage } from '@/api/produce/workOrder.js';
  40. import routings from './routings.vue';
  41. import { isFullscreen } from 'ele-admin';
  42. export default {
  43. components: { routings },
  44. data() {
  45. return {
  46. loading: false,
  47. selection: [],
  48. routeObj: {},
  49. routingShow: false,
  50. internalIsFullscreen: isFullscreen() // 初始值
  51. };
  52. },
  53. computed: {
  54. // 表格列配置
  55. columns() {
  56. return [
  57. {
  58. width: 45,
  59. type: 'selection',
  60. columnKey: 'selection',
  61. align: 'center',
  62. fixed: true
  63. },
  64. {
  65. columnKey: 'index',
  66. label: '序号',
  67. type: 'index',
  68. width: 55,
  69. align: 'center',
  70. showOverflowTooltip: true
  71. },
  72. {
  73. prop: 'batchNo',
  74. label: '批号',
  75. align: 'center'
  76. },
  77. {
  78. prop: 'code',
  79. slot: 'code',
  80. label: '生产工单号',
  81. align: 'center',
  82. minWidth: '110'
  83. },
  84. {
  85. prop: '',
  86. label: '计划编号',
  87. align: 'center'
  88. },
  89. {
  90. prop: '',
  91. label: '计划类型',
  92. align: 'center'
  93. },
  94. {
  95. prop: 'productCode',
  96. label: '产品编码',
  97. align: 'center'
  98. },
  99. {
  100. prop: 'productName',
  101. label: '产品名称',
  102. align: 'center'
  103. },
  104. {
  105. prop: 'brandNo',
  106. label: '牌号',
  107. align: 'center'
  108. },
  109. {
  110. prop: 'model',
  111. label: '型号',
  112. align: 'center'
  113. },
  114. {
  115. prop: 'priority',
  116. label: '优先级',
  117. align: 'center',
  118. minWidth: 120
  119. },
  120. {
  121. prop: 'formingNum',
  122. label: '要求生产数量',
  123. align: 'center',
  124. slot: 'formingNum',
  125. showOverflowTooltip: true,
  126. minWidth: 110
  127. },
  128. {
  129. prop: 'formingWeight',
  130. label: '要求生产重量',
  131. slot: 'formingWeight',
  132. align: 'center',
  133. showOverflowTooltip: true,
  134. minWidth: 110
  135. },
  136. {
  137. prop: 'formedNum',
  138. label: '已生产数量',
  139. align: 'center',
  140. showOverflowTooltip: true,
  141. minWidth: 110
  142. },
  143. {
  144. prop: 'formedWeight',
  145. label: '已生产重量',
  146. align: 'center',
  147. showOverflowTooltip: true,
  148. minWidth: 110
  149. },
  150. {
  151. prop: 'planStartTime',
  152. label: '计划开始时间',
  153. align: 'center',
  154. showOverflowTooltip: true,
  155. minWidth: 110
  156. },
  157. {
  158. prop: 'planCompleteTime',
  159. label: '计划结束时间',
  160. align: 'center',
  161. showOverflowTooltip: true,
  162. minWidth: 110
  163. },
  164. {
  165. prop: 'startTime',
  166. label: '实际开始时间',
  167. align: 'center',
  168. showOverflowTooltip: true,
  169. minWidth: 110
  170. },
  171. {
  172. prop: 'createTime',
  173. label: '创建时间',
  174. align: 'center',
  175. showOverflowTooltip: true,
  176. minWidth: 110
  177. }
  178. ];
  179. },
  180. taskObj() {
  181. return this.$store.state.user.taskObj;
  182. }
  183. },
  184. watch: {
  185. taskObj: {
  186. handler(val) {
  187. this.reload();
  188. },
  189. immediate: true,
  190. deep: true
  191. }
  192. },
  193. created() {},
  194. mounted() {
  195. // 添加窗口resize事件监听器
  196. window.addEventListener('resize', this.handleResize);
  197. },
  198. beforeDestroy() {
  199. // 组件销毁前移除事件监听器,防止内存泄漏
  200. window.removeEventListener('resize', this.handleResize);
  201. },
  202. methods: {
  203. /* 表格数据源 */
  204. datasource({ page, where }) {
  205. return workorderPage({
  206. pageNum: page,
  207. size: 200,
  208. taskId: this.taskObj && this.taskObj.id,
  209. ...where
  210. });
  211. },
  212. /* 刷新表格 */
  213. reload(where) {
  214. this.$nextTick(() => {
  215. this.$refs.table.reload({ page: 1, where });
  216. });
  217. },
  218. handleSelectionChange(val) {
  219. let ids = [];
  220. ids = val.map((item) => {
  221. return item.id;
  222. });
  223. console.log(ids);
  224. this.$emit('workSelect', ids);
  225. },
  226. rowClick(e) {
  227. this.$emit('rowClick', e, this.taskObj.id);
  228. },
  229. handRoute(row) {
  230. this.routeObj = row;
  231. this.routingShow = true;
  232. },
  233. closeRoute() {
  234. this.routingShow = false;
  235. },
  236. handleResize() {
  237. this.internalIsFullscreen = isFullscreen();
  238. }
  239. }
  240. };
  241. </script>
  242. <style lang="scss" scoped>
  243. .table {
  244. min-height: calc((100vh - 70px - 50px - 80px - 20px) / 2);
  245. max-height: 68vh;
  246. }
  247. </style>