produceOrder.vue 9.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404
  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. @cell-click="cellClick"
  12. highlight-current-row
  13. @select="cellClick"
  14. :need-page="false"
  15. @sort-change="onSortChange"
  16. @columns-change="handleColumnChange"
  17. :cache-key="cacheKeyUrl"
  18. >
  19. <!-- <template v-slot:toolbar>
  20. <div class="rx-bc">
  21. <div class="c_title">工单列表 </div>
  22. <div>
  23. <el-input
  24. style="width: 180px"
  25. clearable
  26. v-model="code"
  27. placeholder="请输入工单号"
  28. />
  29. <el-button size="mini" type="primary" style="margin: 0 5px" @click="handleSearch">查询</el-button>
  30. </div>
  31. </div>
  32. </template> -->
  33. <template v-slot:code="{ row }">
  34. <el-link type="primary" @click="handRoute(row)" :underline="false">{{
  35. row.code
  36. }}</el-link>
  37. </template>
  38. <template v-slot:singleReport="{ row }">
  39. <el-tag size="mini">
  40. {{ row.singleReport == 1 ? '单个报工' : '批量报工' }}</el-tag
  41. >
  42. </template>
  43. <template v-slot:taskName="{ row }">
  44. <span> {{ row.taskName }}</span>
  45. </template>
  46. <template v-slot:status="{ row }">
  47. <span> {{ sumStatus(row) }}</span>
  48. </template>
  49. <template v-slot:formingNum="{ row }">
  50. <span> {{ row.formingNum }} {{ row.unit }} </span>
  51. </template>
  52. <template v-slot:formingWeight="{ row }">
  53. <span> {{ row.formingWeight }} {{ row.weightUnit }} </span>
  54. </template>
  55. </ele-pro-table>
  56. <!-- //工单列表 -->
  57. <routings
  58. v-if="routingShow"
  59. :routeObj="routeObj"
  60. @closeRoute="closeRoute"
  61. ></routings>
  62. </div>
  63. </template>
  64. <script>
  65. import { workorderPage2 } from '@/api/produce/workOrder.js';
  66. import routings from './routings.vue';
  67. import { isFullscreen } from 'ele-admin';
  68. import tableColumnsMixin from '@/mixins/tableColumnsMixin';
  69. export default {
  70. components: { routings },
  71. mixins: [tableColumnsMixin],
  72. data() {
  73. return {
  74. loading: false,
  75. selection: [],
  76. routeObj: {},
  77. routingShow: false,
  78. code: '',
  79. internalIsFullscreen: isFullscreen(), // 初始值
  80. cacheKeyUrl: 'mes-145878-mes-produce',
  81. columnsVersion: 0
  82. };
  83. },
  84. computed: {
  85. // 表格列配置
  86. columns() {
  87. let columnsVersion=this.columnsVersion;
  88. return [
  89. {
  90. width: 45,
  91. type: 'selection',
  92. columnKey: 'selection',
  93. align: 'center',
  94. fixed: true
  95. },
  96. {
  97. columnKey: 'index',
  98. label: '序号',
  99. type: 'index',
  100. width: 55,
  101. align: 'center',
  102. showOverflowTooltip: true
  103. },
  104. {
  105. prop: 'batchNo',
  106. label: '批次号',
  107. align: 'center'
  108. },
  109. {
  110. prop: 'code',
  111. slot: 'code',
  112. label: '生产工单号',
  113. align: 'center',
  114. minWidth: '160'
  115. },
  116. {
  117. prop: 'productCode',
  118. label: '编码',
  119. align: 'center',
  120. minWidth: '160',
  121. showOverflowTooltip: true
  122. },
  123. {
  124. prop: 'productName',
  125. label: '名称',
  126. align: 'center',
  127. showOverflowTooltip: true
  128. },
  129. {
  130. prop: 'singleReport',
  131. slot: 'singleReport',
  132. label: '报工类型',
  133. align: 'center',
  134. filters: [
  135. { text: '单个报工', value: 1 },
  136. { text: '批量报工', value: 0 }
  137. ],
  138. filterMethod: this.filterMethod,
  139. width: 100
  140. },
  141. {
  142. prop: 'model',
  143. label: '型号',
  144. align: 'center',
  145. showOverflowTooltip: true
  146. },
  147. {
  148. prop: 'productionCodes',
  149. label: '生产编号',
  150. align: 'center',
  151. minWidth: 150,
  152. showOverflowTooltip: true
  153. },
  154. {
  155. prop: 'brandNo',
  156. label: '牌号',
  157. align: 'center',
  158. showOverflowTooltip: true
  159. },
  160. {
  161. prop: 'priority',
  162. label: '优先级',
  163. align: 'center',
  164. minWidth: 120
  165. },
  166. {
  167. prop: 'formingNum',
  168. label: '要求生产数量',
  169. align: 'center',
  170. slot: 'formingNum',
  171. showOverflowTooltip: true,
  172. minWidth: 110
  173. },
  174. {
  175. prop: 'formingWeight',
  176. label: '要求生产重量',
  177. slot: 'formingWeight',
  178. align: 'center',
  179. showOverflowTooltip: true,
  180. minWidth: 110
  181. },
  182. {
  183. prop: 'formedNum',
  184. label: '已生产数量',
  185. align: 'center',
  186. showOverflowTooltip: true,
  187. minWidth: 110
  188. },
  189. {
  190. prop: 'formedWeight',
  191. label: '已生产重量',
  192. align: 'center',
  193. showOverflowTooltip: true,
  194. minWidth: 110
  195. },
  196. {
  197. slot: 'taskName',
  198. prop: 'taskName',
  199. label: '工序进度',
  200. align: 'center',
  201. showOverflowTooltip: true,
  202. sortable: 'custom',
  203. minWidth: 110
  204. },
  205. {
  206. slot: 'status',
  207. prop: 'status',
  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. {
  235. prop: 'createTime',
  236. label: '创建时间',
  237. align: 'center',
  238. showOverflowTooltip: true,
  239. minWidth: 110
  240. }
  241. ];
  242. },
  243. taskObj() {
  244. return this.$store.state.user.taskObj;
  245. },
  246. current() {
  247. console.log(this.$store.state.user, 'this.$store.state.user');
  248. return this.$store.state.user.currentObj.id;
  249. }
  250. },
  251. watch: {
  252. taskObj: {
  253. handler(val) {
  254. this.reload();
  255. },
  256. // immediate: true,
  257. deep: true
  258. },
  259. current: {
  260. handler(val) {
  261. this.reload();
  262. },
  263. // immediate: true,
  264. deep: true
  265. }
  266. },
  267. created() {},
  268. mounted() {
  269. // 添加窗口resize事件监听器
  270. window.addEventListener('resize', this.handleResize);
  271. },
  272. beforeDestroy() {
  273. // 组件销毁前移除事件监听器,防止内存泄漏
  274. window.removeEventListener('resize', this.handleResize);
  275. },
  276. methods: {
  277. filterMethod(value, row, column) {
  278. if (value == row.singleReport) {
  279. return row;
  280. }
  281. },
  282. sumStatus(row) {
  283. if (row.reportStatus === 1) {
  284. return '已报工';
  285. }
  286. if (row.feedStatus === 1) {
  287. return '已投料';
  288. }
  289. // {{ row.reportStatus }} {{ row.feedStatus }}
  290. },
  291. /* 表格数据源 */
  292. datasource({ page, where }) {
  293. if (!this.taskObj?.id) {
  294. return [];
  295. }
  296. return workorderPage2({
  297. pageNum: page,
  298. size: 1000,
  299. workOrderId: this.$route.query.workOrderId
  300. ? this.$route.query.workOrderId
  301. : null,
  302. taskId: this.taskObj && this.taskObj.id,
  303. deviceId: this.current && this.current.deviceId,
  304. keyWord: this.keyWord,
  305. taskName: this.taskName,
  306. ...where
  307. });
  308. },
  309. onSortChange(e) {
  310. console.log(e);
  311. let sort = {
  312. orderBy: e.order,
  313. sortName: e.prop
  314. };
  315. this.where = sort;
  316. this.reload();
  317. },
  318. handleSearch(obj) {
  319. this.keyWord = obj.keyWord;
  320. this.taskName = obj.taskName;
  321. this.reload();
  322. },
  323. /* 刷新表格 */
  324. reload(where) {
  325. this.$nextTick(() => {
  326. this.$refs.table.reload({ page: 1, where });
  327. });
  328. },
  329. handleSelectionChange(val) {
  330. let initReportValue = val[0] && val[0].singleReport;
  331. let allSame = true;
  332. val.forEach((item) => {
  333. if (item.singleReport !== initReportValue) {
  334. allSame = false;
  335. }
  336. });
  337. if (!allSame) {
  338. return this.$message.warning('请选择报工类型相同的工单');
  339. }
  340. let ids = [];
  341. ids = val.map((item) => {
  342. return item.id;
  343. });
  344. this.$emit('workSelect', { ids: ids, list: val });
  345. },
  346. rowClick(e) {
  347. this.$emit('rowClick', e, this.taskObj.id);
  348. },
  349. cellClick() {
  350. this.$nextTick(() => {
  351. this.$emit('getTaskName', this.selection);
  352. });
  353. },
  354. handRoute(row) {
  355. this.routeObj = row;
  356. this.routingShow = true;
  357. },
  358. closeRoute() {
  359. this.routingShow = false;
  360. },
  361. handleResize() {
  362. this.internalIsFullscreen = isFullscreen();
  363. }
  364. }
  365. };
  366. </script>
  367. <style lang="scss" scoped></style>