new_produceOrder.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461
  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:productUnitWeight="{ row }">
  44. <span> {{ row.productUnitWeight }}{{ row.weightUnit }}</span>
  45. </template>
  46. <template v-slot:taskName="{ row }">
  47. <span> {{ row.taskName }}</span>
  48. </template>
  49. <template v-slot:outsourceStatus="{ row }">
  50. <div v-if="row.outsourceStatus">
  51. <span v-if="row.outsourceStatus == 1">未委外</span>
  52. <span v-if="row.outsourceStatus == 2">委外中</span>
  53. <span v-if="row.outsourceStatus == 3">完成委外-未质检</span>
  54. </div>
  55. </template>
  56. <template v-slot:status="{ row }">
  57. <span> {{ sumStatus(row) }}</span>
  58. </template>
  59. <template v-slot:formingNum="{ row }">
  60. <span> {{ row.formingNum }} {{ row.unit }} </span>
  61. </template>
  62. <template v-slot:formingWeight="{ row }">
  63. <span> {{ row.formingWeight }} {{ row.weightUnit }} </span>
  64. </template>
  65. </ele-pro-table>
  66. <!-- //工单列表 -->
  67. <routings
  68. v-if="routingShow"
  69. :routeObj="routeObj"
  70. @closeRoute="closeRoute"
  71. ></routings>
  72. </div>
  73. </template>
  74. <script>
  75. import { workorderPage2 } from '@/api/produce/workOrder.js';
  76. import routings from './routings.vue';
  77. import { isFullscreen } from 'ele-admin';
  78. import tableColumnsMixin from '@/mixins/tableColumnsMixin';
  79. import {
  80. getList,
  81. removeItem,
  82. updateCertificateNumber
  83. } from '@/api/inspectionWork';
  84. export default {
  85. components: { routings },
  86. mixins: [tableColumnsMixin],
  87. data() {
  88. return {
  89. loading: false,
  90. selection: [],
  91. routeObj: {},
  92. routingShow: false,
  93. code: '',
  94. internalIsFullscreen: isFullscreen(), // 初始值
  95. cacheKeyUrl: 'mes-145878-mes-produce',
  96. columnsVersion: 0
  97. };
  98. },
  99. computed: {
  100. // 表格列配置
  101. columns() {
  102. this.columnsVersion++;
  103. return [
  104. {
  105. width: 45,
  106. type: 'selection',
  107. columnKey: 'selection',
  108. align: 'center',
  109. fixed: true
  110. },
  111. {
  112. columnKey: 'index',
  113. label: '序号',
  114. type: 'index',
  115. width: 55,
  116. align: 'center',
  117. showOverflowTooltip: true
  118. },
  119. {
  120. prop: 'batchNo',
  121. label: '批次号',
  122. align: 'center'
  123. },
  124. {
  125. prop: 'code',
  126. slot: 'code',
  127. label: '生产工单号',
  128. align: 'center',
  129. minWidth: '160'
  130. },
  131. {
  132. prop: 'produceRoutingName',
  133. label: '工艺路线',
  134. align: 'center',
  135. minWidth: '160'
  136. },
  137. {
  138. prop: 'productCode',
  139. label: '编码',
  140. align: 'center',
  141. minWidth: '160',
  142. showOverflowTooltip: true
  143. },
  144. {
  145. prop: 'productName',
  146. label: '名称',
  147. align: 'center',
  148. showOverflowTooltip: true
  149. },
  150. {
  151. prop: 'singleReport',
  152. slot: 'singleReport',
  153. label: '报工类型',
  154. align: 'center',
  155. filters: [
  156. { text: '单个报工', value: 1 },
  157. { text: '批量报工', value: 0 }
  158. ],
  159. filterMethod: this.filterMethod,
  160. width: 100
  161. },
  162. {
  163. prop: 'model',
  164. label: '型号',
  165. align: 'center',
  166. showOverflowTooltip: true
  167. },
  168. {
  169. prop: 'outsourceStatus',
  170. label: '委外状态',
  171. align: 'center',
  172. slot: 'outsourceStatus',
  173. showOverflowTooltip: true
  174. },
  175. {
  176. prop: 'productionCodes',
  177. label: '生产编号',
  178. align: 'center',
  179. minWidth: 150,
  180. showOverflowTooltip: true
  181. },
  182. {
  183. prop: 'brandNo',
  184. label: '牌号',
  185. align: 'center',
  186. showOverflowTooltip: true
  187. },
  188. {
  189. prop: 'productUnitWeight',
  190. slot: 'productUnitWeight',
  191. label: '单重',
  192. align: 'center',
  193. showOverflowTooltip: true
  194. },
  195. {
  196. prop: 'priority',
  197. label: '优先级',
  198. align: 'center',
  199. minWidth: 120
  200. },
  201. {
  202. prop: 'formingNum',
  203. label: '要求生产数量',
  204. align: 'center',
  205. slot: 'formingNum',
  206. showOverflowTooltip: true,
  207. minWidth: 110
  208. },
  209. {
  210. prop: 'formingWeight',
  211. label: '要求生产重量',
  212. slot: 'formingWeight',
  213. align: 'center',
  214. showOverflowTooltip: true,
  215. minWidth: 110
  216. },
  217. {
  218. prop: 'formedNum',
  219. label: '已生产数量',
  220. align: 'center',
  221. showOverflowTooltip: true,
  222. minWidth: 110
  223. },
  224. {
  225. prop: 'formedWeight',
  226. label: '已生产重量',
  227. align: 'center',
  228. showOverflowTooltip: true,
  229. minWidth: 110
  230. },
  231. {
  232. slot: 'taskName',
  233. prop: 'taskName',
  234. label: '工序进度',
  235. align: 'center',
  236. showOverflowTooltip: true,
  237. sortable: 'custom',
  238. minWidth: 110
  239. },
  240. {
  241. slot: 'status',
  242. prop: 'status',
  243. label: '最新工单状态',
  244. align: 'center',
  245. showOverflowTooltip: true,
  246. minWidth: 110
  247. },
  248. {
  249. prop: 'planStartTime',
  250. label: '计划开始时间',
  251. align: 'center',
  252. showOverflowTooltip: true,
  253. minWidth: 130,
  254. sortable: true
  255. },
  256. {
  257. prop: 'planCompleteTime',
  258. label: '计划结束时间',
  259. align: 'center',
  260. showOverflowTooltip: true,
  261. minWidth: 130,
  262. sortable: true
  263. },
  264. {
  265. prop: 'startTime',
  266. label: '实际开始时间',
  267. align: 'center',
  268. showOverflowTooltip: true,
  269. minWidth: 130,
  270. sortable: true
  271. },
  272. {
  273. prop: 'completeTime',
  274. label: '实际完成时间',
  275. align: 'center',
  276. showOverflowTooltip: true,
  277. minWidth: 130,
  278. sortable: true
  279. },
  280. {
  281. prop: 'createTime',
  282. label: '创建时间',
  283. align: 'center',
  284. showOverflowTooltip: true,
  285. minWidth: 130,
  286. sortable: true
  287. }
  288. ];
  289. },
  290. taskObj() {
  291. return this.$store.state.user.taskObj;
  292. },
  293. current() {
  294. console.log(this.$store.state.user, 'this.$store.state.user');
  295. return this.$store.state.user.currentObj.id;
  296. }
  297. },
  298. watch: {
  299. taskObj: {
  300. handler(val) {
  301. this.reload();
  302. },
  303. // immediate: true,
  304. deep: true
  305. },
  306. current: {
  307. handler(val) {
  308. this.reload();
  309. },
  310. // immediate: true,
  311. deep: true
  312. }
  313. },
  314. created() {},
  315. mounted() {
  316. // 添加窗口resize事件监听器
  317. window.addEventListener('resize', this.handleResize);
  318. },
  319. beforeDestroy() {
  320. // 组件销毁前移除事件监听器,防止内存泄漏
  321. window.removeEventListener('resize', this.handleResize);
  322. },
  323. methods: {
  324. filterMethod(value, row, column) {
  325. if (value == row.singleReport) {
  326. return row;
  327. }
  328. },
  329. sumStatus(row) {
  330. if (row.reportStatus === 1) {
  331. return '已报工';
  332. }
  333. if (row.feedStatus === 1) {
  334. return '已投料';
  335. }
  336. // {{ row.reportStatus }} {{ row.feedStatus }}
  337. },
  338. /* 表格数据源 */
  339. datasource({ page, where }) {
  340. if (!this.taskObj?.id) {
  341. return [];
  342. }
  343. console.log(this.taskObj?.id);
  344. // if (this.taskObj?.id == '1916800744740663298') {
  345. // return getList({
  346. // pageNum: page,
  347. // size: 1000
  348. // });
  349. // } else {
  350. return workorderPage2({
  351. pageNum: page,
  352. size: 1000,
  353. workOrderId: this.$route.query.workOrderId
  354. ? this.$route.query.workOrderId
  355. : null,
  356. taskId: this.taskObj && this.taskObj.id,
  357. deviceId: this.current && this.current.deviceId,
  358. keyWord: this.keyWord,
  359. taskName: this.taskName,
  360. ...where
  361. });
  362. // }
  363. },
  364. onSortChange(e) {
  365. console.log(e);
  366. let sort = {
  367. orderBy: e.order,
  368. sortName: e.prop
  369. };
  370. this.where = sort;
  371. this.reload();
  372. },
  373. handleSearch(obj) {
  374. this.keyWord = obj.keyWord;
  375. this.taskName = obj.taskName;
  376. this.reload();
  377. },
  378. /* 刷新表格 */
  379. reload(where) {
  380. this.$nextTick(() => {
  381. this.$refs.table.reload({ page: 1, where });
  382. });
  383. },
  384. handleSelectionChange(val) {
  385. let initReportValue = val[0] && val[0].singleReport;
  386. let allSame = true;
  387. val.forEach((item) => {
  388. if (item.singleReport !== initReportValue) {
  389. allSame = false;
  390. }
  391. });
  392. if (!allSame) {
  393. return this.$message.warning('请选择报工类型相同的工单');
  394. }
  395. let ids = [];
  396. ids = val.map((item) => {
  397. return item.id;
  398. });
  399. this.$emit('workSelect', { ids: ids, list: val });
  400. },
  401. rowClick(e) {
  402. this.$emit('rowClick', e, this.taskObj.id);
  403. },
  404. cellClick() {
  405. this.$nextTick(() => {
  406. this.$emit('getTaskName', this.selection);
  407. });
  408. },
  409. handRoute(row) {
  410. this.routeObj = row;
  411. this.routingShow = true;
  412. },
  413. closeRoute() {
  414. this.routingShow = false;
  415. },
  416. handleResize() {
  417. this.internalIsFullscreen = isFullscreen();
  418. }
  419. }
  420. };
  421. </script>
  422. <style lang="scss" scoped></style>