index.vue 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638
  1. <template>
  2. <div>
  3. <div class="top_fixed">
  4. <el-button type="primary" size="mini" @click="save(2, 'all')"
  5. >一键报工</el-button
  6. >
  7. <el-button type="primary" size="mini" @click="removeCacheFn('all')"
  8. >清空缓存</el-button
  9. >
  10. <el-button
  11. v-if="taskObj.type == 1"
  12. type="primary"
  13. size="mini"
  14. @click="save(1, 'all')"
  15. >缓存</el-button
  16. >
  17. </div>
  18. <div class="job_box">
  19. <div
  20. v-for="(item, index) in List"
  21. :key="index"
  22. class="card_box"
  23. v-if="isLoad"
  24. >
  25. <div class="title_box rx-bc">
  26. <div class="name">工单信息 </div>
  27. <div class="rx-bc">
  28. <el-button
  29. type="text"
  30. size="mini"
  31. @click="openPicking(item.workOrderId, item)"
  32. >添加物料</el-button
  33. >
  34. <el-button
  35. type="text"
  36. size="mini"
  37. @click="removeCacheFn(item.workOrderId)"
  38. >清空缓存</el-button
  39. >
  40. <el-button
  41. v-if="taskObj.type == 1"
  42. type="text"
  43. size="mini"
  44. @click="save(1, index)"
  45. >缓存</el-button
  46. >
  47. </div>
  48. </div>
  49. <workOrderBom :item="item"></workOrderBom>
  50. <paramBom
  51. v-if="item.paramDetailList.length != 0"
  52. :list="item.paramDetailList"
  53. ></paramBom>
  54. <jobBom
  55. :item="item"
  56. :notFormed="item.notFormedList"
  57. :warehouseList="warehouseList"
  58. ></jobBom>
  59. <deviceBom
  60. v-if="item.equipmentList.length != 0"
  61. :list="item.equipmentList"
  62. ></deviceBom>
  63. <modelBom
  64. v-if="item.modelList.length != 0"
  65. :list="item.modelList"
  66. pattern="job"
  67. ref="modelRef"
  68. ></modelBom>
  69. <palletBom
  70. v-if="item.palletList.length != 0"
  71. :list="item.palletList"
  72. ></palletBom>
  73. <revolvingDiskBom
  74. v-if="item.revolvingDiskList.length > 0"
  75. pattern="job"
  76. :list="objData.revolvingDiskList"
  77. >
  78. </revolvingDiskBom>
  79. <semiProductJobBom
  80. :singleReport="item.singleReport"
  81. v-if="
  82. item.semiProductList &&
  83. item.semiProductList.length != 0 &&
  84. taskObj.type != 4 &&
  85. taskObj.type != 6 &&
  86. item.singleReport == 1
  87. "
  88. :item="item"
  89. :list="item.semiProductList"
  90. :equipmentList="item.equipmentList"
  91. ></semiProductJobBom>
  92. <semiProductJobBomPL
  93. :singleReport="item.singleReport"
  94. v-if="
  95. item.semiProductList &&
  96. item.semiProductList.length != 0 &&
  97. taskObj.type != 4 &&
  98. taskObj.type != 6 &&
  99. item.singleReport == 0
  100. "
  101. :item="item"
  102. :list="item.semiProductList"
  103. :equipmentList="item.equipmentList"
  104. ></semiProductJobBomPL>
  105. <oneJobQualityBom
  106. :singleReport="item.singleReport"
  107. v-if="
  108. item.semiProductList &&
  109. item.semiProductList.length != 0 &&
  110. taskObj.type == 6 &&
  111. item.singleReport == 1
  112. "
  113. :item="item"
  114. :list="item.semiProductList"
  115. >
  116. </oneJobQualityBom>
  117. <byProductBom
  118. v-if="item.productRecycleList.length != 0"
  119. :list="item.productRecycleList"
  120. >
  121. </byProductBom>
  122. <turnoverBom
  123. v-if="item.turnover.length != 0"
  124. :list="item.turnover"
  125. :wordItem="item"
  126. pattern="job"
  127. >
  128. </turnoverBom>
  129. <aridRegion
  130. v-if="item.aridRegionList.length != 0"
  131. :list="item.aridRegionList"
  132. :isType="true"
  133. ></aridRegion>
  134. <!-- <packingBom :taskId='taskObj.id' :workOrderId="item.workOrderId" :objData="item" ref="packRef"
  135. v-if='taskObj.type == 4 && clientEnvironmentId != 3 && item'></packingBom> -->
  136. <packingTgBom
  137. v-if="
  138. item.pickOutInList &&
  139. item.pickOutInList.length != 0 &&
  140. taskObj.type == 4 &&
  141. clientEnvironmentId == 3
  142. "
  143. :list="item.pickOutInList"
  144. :item="item"
  145. ></packingTgBom>
  146. </div>
  147. </div>
  148. <pickingList
  149. isType="job"
  150. ref="pickingListRef"
  151. @allSelection="allSelection"
  152. ></pickingList>
  153. </div>
  154. </template>
  155. <script>
  156. import { listByIdsReport } from '@/api/produce/job';
  157. import { getWarehouseList } from '@/api/produce/index';
  158. import {
  159. jobSave,
  160. saveCache,
  161. getCache,
  162. removeCache
  163. } from '@/api/produce/workOrder';
  164. import pickingList from '../picking/pickingList.vue';
  165. import workOrderBom from '../feeding/components/workOrderBom.vue';
  166. import paramBom from '../feeding/components/paramBom.vue';
  167. import jobBom from './components/jobBom.vue';
  168. import deviceBom from '../feeding/components/deviceBom.vue';
  169. import modelBom from '../feeding/components/modelBom.vue';
  170. import palletBom from './components/palletBom.vue';
  171. import revolvingDiskBom from '../feeding/components/revolvingDiskBom.vue';
  172. import oneJobQualityBom from './components/oneJobQualityBom.vue';
  173. import semiProductJobBom from './components/semiProductJobBom.vue';
  174. import semiProductJobBomPL from './components/semiProductJobBomPL.vue';
  175. import byProductBom from './components/byProductBom.vue';
  176. import turnoverBom from './components/turnoverBom.vue';
  177. import aridRegion from '../feeding/components/aridRegion.vue';
  178. import packingBom from './components/packingBom.vue';
  179. import packingTgBom from './components/packingTgBom';
  180. export default {
  181. components: {
  182. pickingList,
  183. workOrderBom,
  184. paramBom,
  185. jobBom,
  186. deviceBom,
  187. modelBom,
  188. palletBom,
  189. revolvingDiskBom,
  190. oneJobQualityBom,
  191. semiProductJobBom,
  192. semiProductJobBomPL,
  193. byProductBom,
  194. turnoverBom,
  195. aridRegion,
  196. packingBom,
  197. packingTgBom
  198. },
  199. props: {
  200. workListIds: {
  201. type: Array,
  202. default() {
  203. return [];
  204. }
  205. }
  206. },
  207. computed: {
  208. taskObj() {
  209. return this.$store.state.user.taskObj;
  210. }
  211. },
  212. data() {
  213. return {
  214. List: [],
  215. idsList: [],
  216. isLoad: false,
  217. warehouseList: [],
  218. loading: null
  219. };
  220. },
  221. computed: {
  222. taskObj() {
  223. return this.$store.state.user.taskObj;
  224. },
  225. clientEnvironmentId() {
  226. return this.$store.state.user.info.clientEnvironmentId;
  227. }
  228. },
  229. watch: {
  230. workListIds: {
  231. handler(val) {
  232. this.getList(val);
  233. },
  234. deep: true,
  235. immediate: true
  236. }
  237. },
  238. created() {
  239. this.getWarehouseListFn();
  240. },
  241. methods: {
  242. getList(ids) {
  243. this.idsList = ids || [];
  244. let param = {
  245. ids: ids,
  246. taskId: this.taskObj.id,
  247. type: 0
  248. };
  249. this.isLoad = false;
  250. listByIdsReport(param)
  251. .then((res) => {
  252. this.List = res.map((obj) => {
  253. if (!Object.prototype.hasOwnProperty.call(obj, 'turnover')) {
  254. obj['turnover'] = [];
  255. }
  256. if (
  257. !Object.prototype.hasOwnProperty.call(obj, 'aridRegionList')
  258. ) {
  259. obj['aridRegionList'] = [];
  260. }
  261. if (!Object.prototype.hasOwnProperty.call(obj, 'instanceList')) {
  262. obj['instanceList'] = [];
  263. }
  264. if (!Object.prototype.hasOwnProperty.call(obj, 'palletList')) {
  265. obj['palletList'] = [];
  266. }
  267. if (
  268. !Object.prototype.hasOwnProperty.call(obj, 'revolvingDiskList')
  269. ) {
  270. obj['revolvingDiskList'] = [];
  271. }
  272. if (obj.palletList.length > 0) {
  273. obj.palletList = obj.palletList.map((m) => {
  274. return {
  275. hideKc: true, // 不显示库存
  276. quantity: m.feedQuantity,
  277. ...m
  278. };
  279. });
  280. }
  281. if (this.taskObj.type == 6 && this.clientEnvironmentId == 3) {
  282. obj.semiProductList = obj.pickOutInList;
  283. }
  284. if (this.clientEnvironmentId == 3 && obj.singleReport == 0) {
  285. obj.semiProductList.map((a) => {
  286. a.extInfo.batchReportInfo = [
  287. {
  288. allFeedQuantity: '',
  289. allReportWeight: '',
  290. taskId: '',
  291. taskName: ''
  292. }
  293. ];
  294. return {
  295. a
  296. };
  297. });
  298. obj.semiProductList = JSON.parse(
  299. JSON.stringify(obj.semiProductList)
  300. );
  301. }
  302. obj.workReportInfo = {
  303. formingNum: null,
  304. formingWeight: null,
  305. formedNum: null,
  306. formedWeight: null,
  307. taskId: this.taskObj.id
  308. };
  309. obj.notFormedList = [
  310. {
  311. notFormedNum: null,
  312. notFormedWeight: null,
  313. weightUnit: obj.weightUnit,
  314. unit: obj.unit,
  315. warehouseId: null // 处置 仓库id
  316. }
  317. ];
  318. if (obj.semiProductList.length > 0) {
  319. // 预制体报工
  320. obj.workReportInfo.formedNum = obj.semiProductList.length;
  321. }
  322. obj.workReportInfo.formingNum = obj.formingNum;
  323. obj.workReportInfo.formingWeight = obj.formingWeight;
  324. obj.workReportInfo.unit = obj.unit;
  325. obj.workReportInfo.weightUnit = obj.weightUnit;
  326. obj.workReportInfo.workOrderId = obj.workOrderId;
  327. obj.paramDetailList.map((m) => {
  328. if (m.extInfo.textType == 5) {
  329. m.remainingTime = m.extInfo.remainingTime;
  330. }
  331. return {
  332. ...m.extInfo
  333. };
  334. });
  335. console.log(obj, 444);
  336. return {
  337. ...obj
  338. };
  339. });
  340. })
  341. .finally(() => {
  342. this.isLoad = true;
  343. if (this.taskObj.type == 1) {
  344. this.getCacheFn();
  345. }
  346. });
  347. },
  348. openPicking(id, item) {
  349. this.$refs.pickingListRef.open(id, item);
  350. },
  351. allSelection(id, selectList) {
  352. this.List.forEach((m) => {
  353. if (m.workOrderId == id) {
  354. let turnover = [];
  355. let equipmentList = []; // 生产设备
  356. selectList.forEach((f) => {
  357. if (f.rootCategoryLevelId == 4) {
  358. equipmentList = equipmentList.concat(f);
  359. }
  360. if (f.rootCategoryLevelId == 7) {
  361. turnover = turnover.concat(f);
  362. }
  363. });
  364. this.$set(m, 'equipmentList', equipmentList);
  365. this.$set(m, 'turnover', turnover);
  366. this.$forceUpdate();
  367. }
  368. });
  369. },
  370. async save(type) {
  371. this.loading = this.$loading({
  372. lock: true,
  373. text: '加载中',
  374. background: 'rgba(0, 0, 0, 0.7)'
  375. });
  376. let bol2;
  377. bol2 = this.List.every((e) => {
  378. return (
  379. e.workReportInfo['formedNum'] && e.workReportInfo['formedNum'] != 0
  380. );
  381. });
  382. if (!bol2) {
  383. this.$message.warning('请输入合格品数量');
  384. this.loading.close();
  385. return false;
  386. }
  387. // 预制体
  388. let wId;
  389. let bol = true;
  390. let _i;
  391. this.List.forEach((L) => {
  392. if (
  393. L.semiProductList.length > 0 &&
  394. this.taskObj.type != 4 &&
  395. L.singleReport == 1
  396. ) {
  397. bol = L.semiProductList.every((e, i) => {
  398. _i = i + 1;
  399. wId = L.code;
  400. if (this.taskObj.type == 6) {
  401. return (
  402. Object.prototype.hasOwnProperty.call(e.extInfo, 'taskId') &&
  403. e.extInfo.taskId
  404. );
  405. } else {
  406. return (
  407. Object.prototype.hasOwnProperty.call(e.extInfo, 'taskId') &&
  408. e.extInfo.taskId &&
  409. e.extInfo.reportWeight
  410. );
  411. }
  412. });
  413. }
  414. });
  415. if (!bol) {
  416. this.$message.warning(`请完善工单${wId}第${_i}处置方式`);
  417. this.loading.close();
  418. return false;
  419. }
  420. if (this.clientEnvironmentId != 2) {
  421. let succ = this.List.some((L) => {
  422. return L.productRecycleList.length > 0;
  423. });
  424. if (succ) {
  425. const isRecycle = await this.checkRecycle();
  426. if (!isRecycle) {
  427. return false;
  428. }
  429. }
  430. }
  431. // if (this.taskObj.type == 4 && this.clientEnvironmentId != 3) {
  432. // const isPack = await this.checkPack()
  433. // if (!isPack) {
  434. // return false
  435. // }
  436. // }
  437. if (this.taskObj.type == 1) {
  438. const isCache = await this.checkCache(type);
  439. if (!isCache) {
  440. return false;
  441. }
  442. }
  443. jobSave(this.List)
  444. .then((res) => {
  445. this.loading.close();
  446. this.$message.success('报工成功');
  447. this.getList(this.idsList);
  448. })
  449. .catch(() => {
  450. this.loading.close();
  451. })
  452. .finally(() => {
  453. setTimeout(function () {
  454. // this.loading.close();
  455. }, 3000);
  456. });
  457. },
  458. checkRecycle() {
  459. this.loading.close();
  460. return new Promise((resolve) => {
  461. this.$confirm('是否跳过副产品回收处置!', '提示', {
  462. confirmButtonText: '确定',
  463. cancelButtonText: '取消',
  464. type: 'warning'
  465. })
  466. .then(() => {
  467. resolve(true);
  468. })
  469. .catch(() => {
  470. resolve(false);
  471. });
  472. });
  473. },
  474. checkCache(type) {
  475. return new Promise((resolve) => {
  476. if (type == 1) {
  477. saveCache(this.List).then((rr) => {
  478. this.$message.success('缓存成功');
  479. this.loading.close();
  480. });
  481. resolve(false);
  482. } else if (type == 2) {
  483. resolve(true);
  484. }
  485. });
  486. },
  487. getCacheFn() {
  488. let parma = {
  489. workOrderIds: this.idsList,
  490. taskId: this.taskObj.id,
  491. type: 1
  492. };
  493. getCache(parma).then((res) => {
  494. console.log(res);
  495. });
  496. },
  497. removeCacheFn(type) {
  498. this.$confirm('是否清空缓存', '缓存')
  499. .then(() => {
  500. let parma = {
  501. workOrderIds: type == 'all' ? this.idsList : [type],
  502. taskId: this.taskObj.id,
  503. type: 1
  504. };
  505. removeCache(parma).then((res) => {
  506. this.$message.success('已经清空缓存');
  507. this.getList(this.idsList);
  508. });
  509. })
  510. .catch(() => {});
  511. },
  512. getWarehouseListFn() {
  513. getWarehouseList().then((res) => {
  514. this.warehouseList = res.data;
  515. });
  516. }
  517. }
  518. };
  519. </script>
  520. <style scoped lang="scss">
  521. .top_fixed {
  522. width: 100%;
  523. height: 40px;
  524. background: #fff;
  525. display: flex;
  526. align-items: center;
  527. justify-content: flex-end;
  528. }
  529. .title_box {
  530. .name {
  531. font-size: 14px;
  532. font-style: normal;
  533. font-weight: 400;
  534. color: #157a2c;
  535. padding-left: 5px;
  536. position: relative;
  537. &:before {
  538. position: absolute;
  539. content: '';
  540. left: 0px;
  541. top: 0px;
  542. bottom: 0px;
  543. width: 2px;
  544. height: 14px;
  545. background: #157a2c;
  546. margin: auto;
  547. }
  548. }
  549. }
  550. .job_box {
  551. margin-top: 6px;
  552. width: 100%;
  553. height: calc(100vh - 70px - 50px - 80px - 60px);
  554. overflow-y: scroll;
  555. overflow-x: hidden;
  556. }
  557. .card_box {
  558. background: #fff;
  559. padding: 8px;
  560. border-radius: 2px;
  561. }
  562. </style>