index.vue 19 KB

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