produceOrder.vue 6.9 KB

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