produceOrder.vue 7.3 KB

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