index.vue 38 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328
  1. <template>
  2. <div>
  3. <div class="top_fixed">
  4. <div
  5. style="display: flex; align-items: center; margin-right: 10px"
  6. v-if="List.length > 1"
  7. >
  8. <div class="rx-bc">
  9. <div class="name">批量报工时间:</div>
  10. </div>
  11. <el-date-picker
  12. v-model="executorTime"
  13. type="datetime"
  14. value-format="yyyy-MM-dd HH:mm:ss"
  15. placeholder="选择日期"
  16. @change="handleCreate"
  17. >
  18. </el-date-picker>
  19. </div>
  20. <el-button
  21. type="primary"
  22. size="mini"
  23. :loading="loadingBtn"
  24. @click="save(2, 'all')"
  25. >一键报工</el-button
  26. >
  27. <el-button type="primary" size="mini" @click="removeCacheFn('all')"
  28. >清空缓存</el-button
  29. >
  30. <el-button
  31. v-if="taskObj.type == 1"
  32. type="primary"
  33. size="mini"
  34. @click="save(1, 'all')"
  35. >缓存</el-button
  36. >
  37. </div>
  38. <div class="job_box">
  39. <div
  40. v-for="(item, index) in List"
  41. :key="index"
  42. class="card_box"
  43. v-if="isLoad"
  44. >
  45. <div class="title_box rx-bc">
  46. <div class="name">工单信息 </div>
  47. <div class="rx-bc">
  48. <el-button
  49. type="text"
  50. size="mini"
  51. @click="openPicking(item.workOrderId, item)"
  52. >手动添加</el-button
  53. >
  54. <el-button
  55. type="text"
  56. size="mini"
  57. @click="removeCacheFn(item.workOrderId)"
  58. >清空缓存</el-button
  59. >
  60. <el-button
  61. v-if="taskObj.type == 1"
  62. type="text"
  63. size="mini"
  64. @click="save(1, index)"
  65. >缓存</el-button
  66. >
  67. </div>
  68. </div>
  69. <!-- // 工单信息 -->
  70. <workOrderBom :item="item"></workOrderBom>
  71. <!-- 报工时间 -->
  72. <div>
  73. <div class="title_box rx-bc">
  74. <div class="name">报工时间</div>
  75. </div>
  76. <el-date-picker
  77. v-model="item.workReportInfo.executorTime"
  78. type="datetime"
  79. value-format="yyyy-MM-dd HH:mm:ss"
  80. placeholder="选择日期"
  81. >
  82. </el-date-picker>
  83. </div>
  84. <paramBom
  85. v-if="item.paramDetailList.length != 0"
  86. :list="item.paramDetailList"
  87. ></paramBom>
  88. <!-- //报工信息 -->
  89. <div v-if="item.singleReport != 1">
  90. <jobBom
  91. :item="item"
  92. ref="jobBomRef"
  93. :notFormed="item.notFormedList"
  94. :warehouseList="warehouseList"
  95. ></jobBom>
  96. </div>
  97. <div v-else>
  98. <jobDdBom
  99. :item="item"
  100. ref="jobRef"
  101. :notFormed="item.notFormedList"
  102. :warehouseList="warehouseList"
  103. ></jobDdBom>
  104. </div>
  105. <!-- :item="item" :notFormed="item.notFormedList" :warehouseList="warehouseList" @modeNum='modeNum'-->
  106. <deviceBom
  107. v-if="item.equipmentList.length != 0"
  108. :list="item.equipmentList"
  109. ></deviceBom>
  110. <modelBom
  111. v-if="item.modelList.length != 0"
  112. :list="item.modelList"
  113. pattern="job"
  114. ref="modelRef"
  115. ></modelBom>
  116. <palletBom
  117. v-if="item.palletList.length != 0"
  118. :list="item.palletList"
  119. ></palletBom>
  120. <revolvingDiskBom
  121. v-if="item.revolvingDiskList.length > 0"
  122. pattern="job"
  123. :list="objData.revolvingDiskList"
  124. >
  125. </revolvingDiskBom>
  126. <!-- 单件 报告信息 -->
  127. <semiProductJobBom
  128. :singleReport="item.singleReport"
  129. v-if="
  130. item.semiProductList &&
  131. item.semiProductList.length != 0 &&
  132. taskObj.type != 4
  133. "
  134. :item="item"
  135. :list="item.semiProductList"
  136. :equipmentList="item.equipmentList"
  137. @chooseData="chooseData"
  138. ></semiProductJobBom>
  139. <!-- <checkbox :tableData="item.semiProductList" ></checkbox> -->
  140. <!-- :itemData="item" @tableDataFn="tableDataFn" -->
  141. <!-- 批量 -->
  142. <!-- <semiProductJobBomPL
  143. :singleReport="item.singleReport"
  144. v-if="
  145. item.semiProductList &&
  146. item.semiProductList.length != 0 &&
  147. taskObj.type != 4 &&
  148. taskObj.type != 6 &&
  149. item.singleReport == 0
  150. "
  151. :item="item"
  152. :list="item.semiProductList"
  153. :equipmentList="item.equipmentList"
  154. @countNumPl="countNumPl"
  155. :index="index"
  156. ></semiProductJobBomPL> -->
  157. <!-- <semiProductJobBom v-if="
  158. item.pickOutInList &&
  159. item.pickOutInList.length != 0 &&
  160. taskObj.type == 6 &&
  161. item.singleReport == 1
  162. " :item="item" :list="item.pickOutInList">
  163. </semiProductJobBom> -->
  164. <!-- 物料清单 -->
  165. <semiProductBom
  166. v-if="
  167. item.semiProductList.length != 0 &&
  168. item.singleReport == 0 &&
  169. clientEnvironmentId != 3
  170. "
  171. :list="item.semiProductList"
  172. :equipmentList="item.equipmentList"
  173. :workInfo="item"
  174. ></semiProductBom>
  175. <!-- 产品信息 -->
  176. <oneJobQualityBomPL
  177. v-if="
  178. item.semiProductList &&
  179. item.semiProductList.length != 0 &&
  180. taskObj.type == 6 &&
  181. item.singleReport == 0 &&
  182. clientEnvironmentId == 3
  183. "
  184. :item="item"
  185. :list="item.semiProductList"
  186. >
  187. </oneJobQualityBomPL>
  188. <byProductBom
  189. v-if="item.productRecycleList.length != 0"
  190. :list="item.productRecycleList"
  191. >
  192. </byProductBom>
  193. <turnoverBom
  194. v-if="item.turnover.length != 0"
  195. :list="item.turnover"
  196. :wordItem="item"
  197. pattern="job"
  198. >
  199. </turnoverBom>
  200. <aridRegion
  201. v-if="item.aridRegionList.length != 0"
  202. :list="item.aridRegionList"
  203. :isType="true"
  204. ></aridRegion>
  205. <!-- 这里是包装分组 -->
  206. <div
  207. v-if="
  208. clientEnvironmentId != 2 &&
  209. item &&
  210. item.currentTaskDiagram.type == 4 &&
  211. clientEnvironmentId != 3 &&
  212. item.singleReport !== 1
  213. "
  214. >
  215. <packagingGrouping
  216. ref="packagingGroupingRef"
  217. :objData="item"
  218. :workOrderId="item.workOrderId"
  219. :taskId="item.currentTaskDiagram.taskId"
  220. >
  221. </packagingGrouping>
  222. </div>
  223. <div
  224. v-if="
  225. item.currentTaskDiagram.type == 4 &&
  226. item.semiProductList.length != 0
  227. "
  228. >
  229. <semiProductJobBom
  230. :singleReport="item.singleReport"
  231. :item="item"
  232. :list="
  233. item.currentTaskDiagram.type == 4
  234. ? item.pickOutInList
  235. : item.semiProductList
  236. "
  237. :equipmentList="item.equipmentList"
  238. ></semiProductJobBom>
  239. </div>
  240. <div
  241. v-if="
  242. item.currentTaskDiagram.type == 4 && item.pickOutInList.length != 0
  243. "
  244. >
  245. <semiProductJobBom
  246. :singleReport="item.singleReport"
  247. :item="item"
  248. :list="
  249. item.currentTaskDiagram.type == 4
  250. ? item.pickOutInList
  251. : item.semiProductList
  252. "
  253. :equipmentList="item.equipmentList"
  254. ></semiProductJobBom>
  255. </div>
  256. <!-- <packingBom :taskId='taskObj.id' :workOrderId="item.workOrderId" :objData="item" ref="packRef"
  257. v-if='taskObj.type == 4 && clientEnvironmentId != 3 && item'></packingBom> -->
  258. <!-- <packingTgBom v-if="
  259. item.pickOutInList &&
  260. item.pickOutInList.length != 0 &&
  261. taskObj.type == 4 &&
  262. clientEnvironmentId == 3
  263. " :list="item.pickOutInList" :item="item"></packingTgBom> -->
  264. </div>
  265. </div>
  266. <pickingList
  267. isType="job"
  268. ref="pickingListRef"
  269. @allSelection="allSelection"
  270. ></pickingList>
  271. </div>
  272. </template>
  273. <script>
  274. import { listByIdsReport } from '@/api/produce/job';
  275. import { getWarehouseList } from '@/api/produce/index';
  276. import {
  277. jobSave,
  278. saveCache,
  279. getCache,
  280. removeCache
  281. } from '@/api/produce/workOrder';
  282. import pickingList from '../picking/pickingList.vue';
  283. import packagingGrouping from './components/packagingGrouping.vue';
  284. import workOrderBom from '../feeding/components/workOrderBom.vue';
  285. import paramBom from '../feeding/components/paramBom.vue';
  286. import jobBom from './components/jobBom.vue';
  287. import deviceBom from '../feeding/components/deviceBom.vue';
  288. import modelBom from '../feeding/components/modelBom.vue';
  289. import palletBom from './components/palletBom.vue';
  290. import revolvingDiskBom from '../feeding/components/revolvingDiskBom.vue';
  291. import oneJobQualityBom from './components/oneJobQualityBom.vue';
  292. import oneJobQualityBomPL from './components/oneJobQualityBomPL.vue';
  293. import jobDdBom from './components/jobDdBom.vue';
  294. import semiProductJobBom from './components/semiProductJobBom.vue';
  295. import semiProductJobBomPL from './components/semiProductJobBomPL.vue';
  296. import semiProductJobBomQT from './components/semiProductJobBomQT.vue';
  297. import semiProductBom from '../feeding/components/semiProductBom';
  298. // import byProductBom from './components/byProductBom.vue';
  299. import byProductBom from './components/newByProductBom.vue';
  300. import turnoverBom from './components/turnoverBom.vue';
  301. import aridRegion from '../feeding/components/aridRegion.vue';
  302. import packingBom from './components/packingBom.vue';
  303. import packingTgBom from './components/packingTgBom';
  304. import { timestampToDateTime } from '@/utils/index.js';
  305. import { parameterGetByCode } from '@/api/system/dictionary-data';
  306. export default {
  307. components: {
  308. pickingList,
  309. packagingGrouping,
  310. workOrderBom,
  311. paramBom,
  312. jobBom,
  313. deviceBom,
  314. modelBom,
  315. palletBom,
  316. revolvingDiskBom,
  317. oneJobQualityBom,
  318. oneJobQualityBomPL,
  319. semiProductJobBomQT,
  320. semiProductJobBom,
  321. semiProductJobBomPL,
  322. byProductBom,
  323. turnoverBom,
  324. aridRegion,
  325. packingBom,
  326. jobDdBom,
  327. packingTgBom,
  328. semiProductBom
  329. },
  330. props: {
  331. workListIds: {
  332. type: Array,
  333. default() {
  334. return [];
  335. }
  336. },
  337. reportNeedFeed: {}
  338. },
  339. data() {
  340. return {
  341. List: [],
  342. idsList: [],
  343. isLoad: false,
  344. executorTime: '',
  345. warehouseList: [],
  346. loading: null,
  347. loadingBtn: false,
  348. chooseListData: []
  349. };
  350. },
  351. computed: {
  352. taskObj() {
  353. return this.$store.state.user.taskObj;
  354. },
  355. clientEnvironmentId() {
  356. return this.$store.state.user.info.clientEnvironmentId;
  357. }
  358. },
  359. watch: {
  360. workListIds: {
  361. handler(val) {
  362. this.getList(val);
  363. },
  364. deep: true,
  365. immediate: true
  366. }
  367. },
  368. created() {
  369. this.getWarehouseListFn();
  370. },
  371. methods: {
  372. checkPack() {
  373. this.$refs.packagingGroupingRef[0].getData();
  374. },
  375. handleCreate(e) {
  376. if (e) {
  377. const list = JSON.parse(JSON.stringify(this.List));
  378. console.log(list);
  379. list.map((item) => {
  380. item.workReportInfo.executorTime = e;
  381. });
  382. this.$set(this, 'List', list);
  383. }
  384. },
  385. getList(ids) {
  386. this.idsList = ids || [];
  387. let param = {
  388. ids: ids,
  389. taskId: this.taskObj.id,
  390. type: 0
  391. };
  392. this.isLoad = false;
  393. listByIdsReport(param)
  394. .then((res) => {
  395. this.List = res.map((obj) => {
  396. if (!Object.prototype.hasOwnProperty.call(obj, 'turnover')) {
  397. obj['turnover'] = [];
  398. }
  399. if (
  400. !Object.prototype.hasOwnProperty.call(obj, 'aridRegionList')
  401. ) {
  402. obj['aridRegionList'] = [];
  403. }
  404. if (!Object.prototype.hasOwnProperty.call(obj, 'instanceList')) {
  405. obj['instanceList'] = [];
  406. }
  407. if (!Object.prototype.hasOwnProperty.call(obj, 'palletList')) {
  408. obj['palletList'] = [];
  409. }
  410. if (
  411. !Object.prototype.hasOwnProperty.call(obj, 'revolvingDiskList')
  412. ) {
  413. obj['revolvingDiskList'] = [];
  414. }
  415. if (obj.palletList.length > 0) {
  416. obj.palletList = obj.palletList.map((m) => {
  417. return {
  418. hideKc: true, // 不显示库存
  419. quantity: m.feedQuantity,
  420. ...m
  421. };
  422. });
  423. }
  424. if (
  425. (this.taskObj.type == 6 && obj.singleReport == 1) ||
  426. (this.clientEnvironmentId == 3 &&
  427. obj.singleReport == 0 &&
  428. this.taskObj.type == 6)
  429. ) {
  430. obj.semiProductList = obj.pickOutInList;
  431. obj.pickOutInList = [];
  432. console.log('赋值了');
  433. }
  434. if (
  435. this.clientEnvironmentId == 3 &&
  436. obj.singleReport == 0 &&
  437. this.taskObj.type != 6
  438. ) {
  439. obj.semiProductList.map((a) => {
  440. a.extInfo.batchReportInfo = [
  441. {
  442. allFeedQuantity: '',
  443. allReportWeight: '',
  444. taskId: '',
  445. taskName: ''
  446. }
  447. ];
  448. a.extInfo.notBatchReportInfo = [
  449. {
  450. allFeedQuantity: '',
  451. notType: '',
  452. taskId: '',
  453. taskName: '',
  454. notReason: ''
  455. }
  456. ];
  457. return {
  458. a
  459. };
  460. });
  461. obj.semiProductList = JSON.parse(
  462. JSON.stringify(obj.semiProductList)
  463. );
  464. }
  465. obj.semiProductList = obj.semiProductList.map((item) => {
  466. if (this.taskObj.type != 6) {
  467. if (item['extInfo']?.reportWeight) {
  468. item['extInfo'].reportWeight = '';
  469. }
  470. }
  471. item.confirm = 0;
  472. console.log(item, 'item');
  473. return item;
  474. });
  475. obj.workReportInfo = {
  476. executorTime: null,
  477. formingNum: null,
  478. formingWeight: null,
  479. formedNum: null,
  480. formedWeight: null,
  481. taskId: this.taskObj.id,
  482. notFormedNum: null,
  483. notFormedWeigh: null
  484. };
  485. obj.notFormedList = [
  486. {
  487. notFormedNum: null,
  488. notFormedWeight: null,
  489. weightUnit: obj.weightUnit,
  490. unit: obj.unit,
  491. warehouseId: null // 处置 仓库id
  492. }
  493. ];
  494. if (obj.semiProductList.length > 0) {
  495. // 预制体报工
  496. obj.workReportInfo.formedNum = obj.semiProductList.length;
  497. let numCot = 0;
  498. if (obj.semiProductList.length > 0) {
  499. obj.semiProductList.map((fitem) => {
  500. numCot = numCot + fitem.feedQuantity || 1;
  501. });
  502. obj.workReportInfo.formedNum = numCot;
  503. }
  504. }
  505. obj.workReportInfo.formingNum = obj.formingNum;
  506. obj.workReportInfo.formingWeight = obj.formingWeight;
  507. obj.workReportInfo.unit = obj.unit;
  508. obj.workReportInfo.weightUnit = obj.weightUnit;
  509. obj.workReportInfo.workOrderId = obj.workOrderId;
  510. obj.workReportInfo.executorTime = obj.executorTime;
  511. obj.paramDetailList.map((m) => {
  512. if (m.extInfo.textType == 5) {
  513. m.remainingTime = m.extInfo.remainingTime;
  514. }
  515. return {
  516. ...m.extInfo
  517. };
  518. });
  519. console.log(obj, 4445555);
  520. if (this.taskObj.type == 4 && obj.singleReport == 0) {
  521. let numVal = 0;
  522. obj.pickOutInList.map((item) => {
  523. numVal = numVal + item.feedQuantity;
  524. });
  525. obj.workReportInfo.formedNum = numVal;
  526. }
  527. return {
  528. ...obj
  529. };
  530. });
  531. })
  532. .finally(() => {
  533. this.isLoad = true;
  534. if (this.taskObj.type == 1) {
  535. this.getCacheFn();
  536. }
  537. });
  538. },
  539. openPicking(id, item) {
  540. this.$refs.pickingListRef.open(id, item);
  541. },
  542. allSelection(id, selectList) {
  543. console.log(id, selectList, 'allSelection');
  544. this.List.forEach((m) => {
  545. if (m.workOrderId == id) {
  546. let turnover = [];
  547. let equipmentList = []; // 生产设备
  548. selectList.forEach((f) => {
  549. if (f.rootCategoryLevelId == 4) {
  550. equipmentList = equipmentList.concat(f);
  551. }
  552. if (f.rootCategoryLevelId == 7) {
  553. turnover = turnover.concat(f);
  554. }
  555. });
  556. this.$set(m, 'equipmentList', equipmentList);
  557. this.$set(m, 'turnover', turnover);
  558. this.$forceUpdate();
  559. }
  560. });
  561. },
  562. chooseData(dataList) {
  563. this.chooseListData = this.deepCopy(dataList);
  564. // if (this.chooseListData.length > 0) {
  565. // this.chooseListData.forEach((item) => {
  566. // item.confirm = 1;
  567. // });
  568. // } else {
  569. // this.List.forEach((item) => {
  570. // item.semiProductList.forEach((fitem) => {
  571. // fitem.confirm = 0;
  572. // });
  573. // });
  574. // }
  575. },
  576. deepCopy(obj, hash = new WeakMap()) {
  577. if (obj === null) return null;
  578. if (obj instanceof Date) return new Date(obj);
  579. if (obj instanceof RegExp) return new RegExp(obj);
  580. if (typeof obj !== 'object' && typeof obj !== 'function') return obj;
  581. if (hash.has(obj)) return hash.get(obj); // 处理循环引用
  582. const result = Array.isArray(obj) ? [] : {};
  583. hash.set(obj, result); // 存储原始对象和其副本的映射关系
  584. return Object.keys(obj).reduce((acc, key) => {
  585. acc[key] = this.deepCopy(obj[key], hash);
  586. return acc;
  587. }, result);
  588. },
  589. async save(type) {
  590. const required = await parameterGetByCode({
  591. code: 'mes_report_engrave_required'
  592. }).then((res) => {
  593. return res;
  594. });
  595. let confirmList = [];
  596. // const confirmList = this.List[0].semiProductList.filter(
  597. // (item) => item.confirm == 1
  598. // );
  599. this.List.forEach((item) => {
  600. item.semiProductList.forEach((it) => {
  601. if (it.confirm == 1) {
  602. confirmList.push(it);
  603. }
  604. });
  605. });
  606. if (required.value == '1') {
  607. // if (this.chooseListData.length > 0) {
  608. // this.checkChooseData(this.chooseListData, type, 'choose');
  609. // return;
  610. // } else {
  611. // this.checkChooseData(this.List, type, 'all');
  612. // return;
  613. // }
  614. if (confirmList.length > 0) {
  615. for (let i = 0; i < confirmList.length; i++) {
  616. if (!confirmList[i].extInfo.engrave) {
  617. this.$message.warning('请输入刻码!');
  618. return;
  619. }
  620. }
  621. } else {
  622. if (this.List.length > 0) {
  623. for (let i = 0; i < this.List.length; i++) {
  624. for (let j = 0; this.List[i].semiProductList.length; j++) {
  625. if (!this.List[i].semiProductList[j].extInfo.engrave) {
  626. this.$message.warning('请输入刻码!');
  627. return;
  628. }
  629. }
  630. }
  631. }
  632. }
  633. }
  634. console.log('11111', this.List);
  635. this.loading = this.$loading({
  636. lock: true,
  637. text: '加载中',
  638. background: 'rgba(0, 0, 0, 0.7)'
  639. });
  640. let arr = this.List.filter((L) => L.workReportInfo.executorTime);
  641. if (!arr.length) {
  642. this.loading.close();
  643. return this.$message.warning('请选择执行时间');
  644. }
  645. // if(this.taskObj.type !=6){
  646. // if(this.reportNeedFeed==1&&!(this.List[0].semiProductList.length>0||this.List[0].pickOutInList.length>0)){
  647. // this.loading.close();
  648. // return this.$message.warning('请先投料再报工');
  649. // }
  650. // }
  651. let bol2;
  652. bol2 = this.List.every((e) => {
  653. return (
  654. // e.workReportInfo['formedNum'] && e.workReportInfo['formedNum'] != 0
  655. e.workReportInfo['formedNum'] != ''
  656. );
  657. });
  658. // if (!bol2) {
  659. // this.$message.warning('请输入合格品数量');
  660. // this.loading.close();
  661. // return false;
  662. // }
  663. // 预制体
  664. let wId;
  665. let bol = true;
  666. let _i;
  667. this.List.forEach((L) => {
  668. if (
  669. L.semiProductList.length > 0 &&
  670. this.taskObj.type != 4 &&
  671. L.singleReport == 1
  672. ) {
  673. bol = L.semiProductList.every((e, i) => {
  674. _i = i + 1;
  675. wId = L.code;
  676. if (this.taskObj.type == 6) {
  677. return (
  678. Object.prototype.hasOwnProperty.call(e.extInfo, 'taskId') &&
  679. e.extInfo.taskId
  680. );
  681. } else {
  682. if (e.extInfo.isQualified == 1 || e.extInfo.notType == 5) {
  683. return (
  684. Object.prototype.hasOwnProperty.call(e.extInfo, 'taskId') &&
  685. e.extInfo.taskId &&
  686. e.extInfo.reportWeight
  687. );
  688. } else {
  689. return (
  690. Object.prototype.hasOwnProperty.call(
  691. e.extInfo,
  692. 'notType'
  693. ) && e.extInfo.notType
  694. );
  695. }
  696. }
  697. });
  698. }
  699. if (L.workReportInfo.batchNo) {
  700. L.workReportInfo.batchNo = L.batchNo + L.workReportInfo.batchNo;
  701. }
  702. });
  703. // if (!bol) {
  704. // this.$message.warning(`请完善工单${wId}第${_i}处置方式`);
  705. // this.loading.close();
  706. // return false;
  707. // }
  708. if (this.clientEnvironmentId != 2) {
  709. let succ = this.List.some((L) => {
  710. return L.productRecycleList.length > 0;
  711. });
  712. if (succ) {
  713. const isRecycle = await this.checkRecycle();
  714. if (!isRecycle) {
  715. return false;
  716. }
  717. }
  718. }
  719. console.log(this.item, '9999999999');
  720. if (
  721. this.taskObj.type == 4 &&
  722. this.clientEnvironmentId != 3 &&
  723. this.clientEnvironmentId != 2 &&
  724. this.List[0].singleReport !== 1
  725. ) {
  726. this.checkPack();
  727. // if (!isPack) {
  728. // return false
  729. // }
  730. }
  731. console.log('4444444444', this.List);
  732. if (this.taskObj.type == 1) {
  733. const isCache = await this.checkCache(type);
  734. if (!isCache) {
  735. return false;
  736. }
  737. }
  738. if (
  739. this.clientEnvironmentId == 3 &&
  740. type == 2 &&
  741. this.taskObj.type == 6
  742. ) {
  743. this.List.forEach((L) => {
  744. if (L.singleReport == 0) {
  745. L.semiProductList = [];
  746. }
  747. });
  748. console.log('ashsaoghaoghoasg');
  749. }
  750. let isSemiProduct = false;
  751. this.List.map((semi) => {
  752. if (
  753. semi.semiProductList.length == 0 &&
  754. semi.singleReport == 1 &&
  755. semi.currentTaskDiagram.isFirstTask == 1 &&
  756. this.clientEnvironmentId != 3
  757. ) {
  758. isSemiProduct = true;
  759. this.loading.close();
  760. setTimeout(() => {
  761. this.$message.warning({
  762. message: '请工单编号:' + semi.code + '先创建在制品',
  763. key: semi.code // 使用当前时间作为key,确保唯一性
  764. });
  765. }, 500);
  766. }
  767. if (semi.semiProductList.length == 0 && semi.singleReport == 0) {
  768. semi.semiProductList.map((ditem) => {
  769. if (ditem.extInfo.batchReportInfo) {
  770. ditem.extInfo.batchReportInfo.map((baItem) => {
  771. let idvalue = baItem.deviceId
  772. ? baItem.deviceId.split('/')
  773. : '';
  774. baItem.deviceId = idvalue ? idvalue[0] : '';
  775. });
  776. }
  777. if (ditem.extInfo.notBatchReportInfo) {
  778. ditem.extInfo.notBatchReportInfo.map((noItem) => {
  779. let idvalue = noItem.deviceId
  780. ? noItem.deviceId.split('/')
  781. : '';
  782. noItem.deviceId = idvalue ? idvalue[0] : '';
  783. });
  784. }
  785. });
  786. }
  787. });
  788. if (isSemiProduct) {
  789. this.loading.close();
  790. return;
  791. }
  792. console.log(this.List, 'this.List');
  793. this.loadingBtn = true;
  794. jobSave(this.List)
  795. .then((res) => {
  796. this.loadingBtn = false;
  797. this.loading.close();
  798. this.$message.success('报工成功');
  799. this.getList(this.idsList);
  800. })
  801. .catch(() => {
  802. this.loadingBtn = false;
  803. this.loading.close();
  804. });
  805. // .finally(() => {
  806. // setTimeout(function () {
  807. // this.loading.close();
  808. // }, 3000);
  809. // });
  810. },
  811. async checkChooseData(dataList, type, chooseType) {
  812. if (chooseType == 'choose') {
  813. for (let i = 0; i < dataList.length; i++) {
  814. if (!dataList[i].extInfo.engrave) {
  815. this.$message.warning('请输入刻码!');
  816. return;
  817. }
  818. }
  819. } else {
  820. for (let i = 0; i < dataList.length; i++) {
  821. if (dataList[i].semiProductList.length > 0) {
  822. for (let j = 0; j < dataList[i].semiProductList.length; j++) {
  823. if (!dataList[i].semiProductList[j].extInfo.engrave) {
  824. this.$message.warning('请输入刻码!');
  825. return;
  826. }
  827. }
  828. }
  829. }
  830. if (chooseType == 'choose') {
  831. dataList.forEach((item) => {
  832. this.List.forEach((it) => {
  833. it.semiProductList.forEach((fitem) => {
  834. if (fitem.extInfo.id == item.extInfo.id) {
  835. fitem.extInfo.engrave = item.extInfo.engrave;
  836. fitem.extInfo.confirm = item.extInfo.confirm;
  837. }
  838. });
  839. });
  840. });
  841. }
  842. // for (let i = 0; i < this.List[0].semiProductList.length; i++) {
  843. // if (!this.List[0].semiProductList[i].extInfo.engrave) {
  844. // this.$message.warning('请输入刻码!');
  845. // return;
  846. // }
  847. // }
  848. }
  849. // for (let i = 0; i < dataList.length; i++) {
  850. // if (!dataList[i].extInfo.engrave) {
  851. // this.$message.warning('请输入刻码!');
  852. // return;
  853. // }
  854. // }
  855. // this.List[0].semiProductList = dataList;
  856. console.log('465646546', this.List);
  857. this.loading = this.$loading({
  858. lock: true,
  859. text: '加载中',
  860. background: 'rgba(0, 0, 0, 0.7)'
  861. });
  862. let arr = this.List.filter((L) => L.workReportInfo.executorTime);
  863. if (!arr.length) {
  864. this.loading.close();
  865. return this.$message.warning('请选择执行时间');
  866. }
  867. // if(this.taskObj.type !=6){
  868. // if(this.reportNeedFeed==1&&!(this.List[0].semiProductList.length>0||this.List[0].pickOutInList.length>0)){
  869. // this.loading.close();
  870. // return this.$message.warning('请先投料再报工');
  871. // }
  872. // }
  873. let bol2;
  874. bol2 = this.List.every((e) => {
  875. return (
  876. // e.workReportInfo['formedNum'] && e.workReportInfo['formedNum'] != 0
  877. e.workReportInfo['formedNum'] != ''
  878. );
  879. });
  880. // if (!bol2) {
  881. // this.$message.warning('请输入合格品数量');
  882. // this.loading.close();
  883. // return false;
  884. // }
  885. // 预制体
  886. let wId;
  887. let bol = true;
  888. let _i;
  889. this.List.forEach((L) => {
  890. if (
  891. L.semiProductList.length > 0 &&
  892. this.taskObj.type != 4 &&
  893. L.singleReport == 1
  894. ) {
  895. bol = L.semiProductList.every((e, i) => {
  896. _i = i + 1;
  897. wId = L.code;
  898. if (this.taskObj.type == 6) {
  899. return (
  900. Object.prototype.hasOwnProperty.call(e.extInfo, 'taskId') &&
  901. e.extInfo.taskId
  902. );
  903. } else {
  904. if (e.extInfo.isQualified == 1 || e.extInfo.notType == 5) {
  905. return (
  906. Object.prototype.hasOwnProperty.call(e.extInfo, 'taskId') &&
  907. e.extInfo.taskId &&
  908. e.extInfo.reportWeight
  909. );
  910. } else {
  911. return (
  912. Object.prototype.hasOwnProperty.call(
  913. e.extInfo,
  914. 'notType'
  915. ) && e.extInfo.notType
  916. );
  917. }
  918. }
  919. });
  920. }
  921. });
  922. // if (!bol) {
  923. // this.$message.warning(`请完善工单${wId}第${_i}处置方式`);
  924. // this.loading.close();
  925. // return false;
  926. // }
  927. if (this.clientEnvironmentId != 2) {
  928. let succ = this.List.some((L) => {
  929. return L.productRecycleList.length > 0;
  930. });
  931. if (succ) {
  932. const isRecycle = await this.checkRecycle();
  933. if (!isRecycle) {
  934. return false;
  935. }
  936. }
  937. }
  938. console.log(this.item, '9999999999');
  939. if (
  940. this.taskObj.type == 4 &&
  941. this.clientEnvironmentId != 3 &&
  942. this.clientEnvironmentId != 2 &&
  943. this.List[0].singleReport !== 1
  944. ) {
  945. this.checkPack();
  946. // if (!isPack) {
  947. // return false
  948. // }
  949. }
  950. console.log('4444444444', this.List);
  951. if (this.taskObj.type == 1) {
  952. const isCache = await this.checkCache(type);
  953. if (!isCache) {
  954. return false;
  955. }
  956. }
  957. if (
  958. this.clientEnvironmentId == 3 &&
  959. type == 2 &&
  960. this.taskObj.type == 6
  961. ) {
  962. this.List.forEach((L) => {
  963. if (L.singleReport == 0) {
  964. L.semiProductList = [];
  965. }
  966. });
  967. console.log('ashsaoghaoghoasg');
  968. }
  969. let isSemiProduct = false;
  970. this.List.map((semi) => {
  971. if (
  972. semi.semiProductList.length == 0 &&
  973. semi.singleReport == 1 &&
  974. semi.currentTaskDiagram.isFirstTask == 1 &&
  975. this.clientEnvironmentId != 3
  976. ) {
  977. isSemiProduct = true;
  978. this.loading.close();
  979. setTimeout(() => {
  980. this.$message.warning({
  981. message: '请工单编号:' + semi.code + '先创建在制品',
  982. key: semi.code // 使用当前时间作为key,确保唯一性
  983. });
  984. }, 500);
  985. }
  986. if (semi.semiProductList.length == 0 && semi.singleReport == 0) {
  987. semi.semiProductList.map((ditem) => {
  988. if (ditem.extInfo.batchReportInfo) {
  989. ditem.extInfo.batchReportInfo.map((baItem) => {
  990. let idvalue = baItem.deviceId
  991. ? baItem.deviceId.split('/')
  992. : '';
  993. baItem.deviceId = idvalue ? idvalue[0] : '';
  994. });
  995. }
  996. if (ditem.extInfo.notBatchReportInfo) {
  997. ditem.extInfo.notBatchReportInfo.map((noItem) => {
  998. let idvalue = noItem.deviceId
  999. ? noItem.deviceId.split('/')
  1000. : '';
  1001. noItem.deviceId = idvalue ? idvalue[0] : '';
  1002. });
  1003. }
  1004. });
  1005. }
  1006. });
  1007. if (isSemiProduct) {
  1008. this.loading.close();
  1009. return;
  1010. }
  1011. console.log(this.List, 'this.List');
  1012. // this.loadingBtn = true;
  1013. // jobSave(this.List)
  1014. // .then((res) => {
  1015. // this.loadingBtn = false;
  1016. // this.loading.close();
  1017. // this.$message.success('报工成功');
  1018. // this.getList(this.idsList);
  1019. // })
  1020. // .catch(() => {
  1021. // this.loadingBtn = false;
  1022. // this.loading.close();
  1023. // })
  1024. // .finally(() => {
  1025. // setTimeout(function () {
  1026. // // this.loading.close();
  1027. // }, 3000);
  1028. // });
  1029. },
  1030. checkRecycle() {
  1031. this.loading.close();
  1032. return new Promise((resolve) => {
  1033. this.$confirm('是否跳过副产品回收处置!', '提示', {
  1034. confirmButtonText: '确定',
  1035. cancelButtonText: '取消',
  1036. type: 'warning'
  1037. })
  1038. .then(() => {
  1039. resolve(true);
  1040. })
  1041. .catch(() => {
  1042. resolve(false);
  1043. });
  1044. });
  1045. },
  1046. checkCache(type) {
  1047. return new Promise((resolve) => {
  1048. if (type == 1) {
  1049. saveCache(this.List).then((rr) => {
  1050. this.$message.success('缓存成功');
  1051. this.loading.close();
  1052. });
  1053. resolve(false);
  1054. } else if (type == 2) {
  1055. resolve(true);
  1056. }
  1057. });
  1058. },
  1059. getCacheFn() {
  1060. let parma = {
  1061. workOrderIds: this.idsList,
  1062. taskId: this.taskObj.id,
  1063. type: 1
  1064. };
  1065. getCache(parma).then((res) => {
  1066. this.List.forEach((f, index) => {
  1067. res.forEach((o) => {
  1068. if (f.workOrderId == o.workOrderId) {
  1069. f['product'] = o.extInfo.product;
  1070. f['workReportInfo'] = o.extInfo.workReportInfo;
  1071. f['notFormedList'] = o.extInfo.notFormedList;
  1072. f['turnover'] = o.extInfo.turnover;
  1073. f['productRecycleList'] = o.extInfo.productRecycleList;
  1074. f['semiProductList'] = o.extInfo.semiProductList;
  1075. f['modelList'] = o.extInfo.modelList;
  1076. // this.$set(this.List[index].workReportInfo,'executorTime',timestampToDateTime(o.extInfo.workReportInfo.executorTime))
  1077. this.$forceUpdate();
  1078. }
  1079. });
  1080. });
  1081. });
  1082. },
  1083. removeCacheFn(type) {
  1084. this.$confirm('是否清空缓存', '缓存')
  1085. .then(() => {
  1086. let parma = {
  1087. workOrderIds: type == 'all' ? this.idsList : [type],
  1088. taskId: this.taskObj.id,
  1089. type: 1
  1090. };
  1091. removeCache(parma).then((res) => {
  1092. this.$message.success('已经清空缓存');
  1093. this.getList(this.idsList);
  1094. });
  1095. })
  1096. .catch(() => {});
  1097. },
  1098. getWarehouseListFn() {
  1099. getWarehouseList().then((res) => {
  1100. this.warehouseList = res.data;
  1101. });
  1102. },
  1103. //批量报工合格不合格重量统计
  1104. countNumPl(list, index) {
  1105. console.log('11111122222333', list);
  1106. //合格总数
  1107. let formedNumCount = 0;
  1108. //合格总重量
  1109. let formedWeightCount = 0;
  1110. //不合格总数
  1111. let notFormedNumCount = 0;
  1112. //不合格总重量
  1113. let notFormedWeightCount = 0;
  1114. list.map((item) => {
  1115. //合格总数
  1116. item.extInfo.batchReportInfo.forEach((m) => {
  1117. formedNumCount = formedNumCount + Number(m.allFeedQuantity || 0);
  1118. });
  1119. //合格总重量
  1120. item.extInfo.batchReportInfo.forEach((w) => {
  1121. formedWeightCount =
  1122. formedWeightCount + Number(w.allReportWeight || 0);
  1123. });
  1124. //不合格总数
  1125. item.extInfo.notBatchReportInfo.forEach((nf) => {
  1126. notFormedNumCount =
  1127. notFormedNumCount + Number(nf.allFeedQuantity || 0);
  1128. });
  1129. //不合格总重量
  1130. item.extInfo.notBatchReportInfo.forEach((nw) => {
  1131. notFormedWeightCount =
  1132. notFormedWeightCount + Number(nw.allReportWeight || 0);
  1133. });
  1134. });
  1135. this.$set(this.List[index].workReportInfo, 'formedNum', formedNumCount); //合格总数
  1136. this.$set(
  1137. this.List[index].workReportInfo,
  1138. 'formedWeight',
  1139. formedWeightCount
  1140. ); //合格总重量
  1141. this.$set(
  1142. this.List[index].workReportInfo,
  1143. 'notFormedNum',
  1144. notFormedNumCount
  1145. ); //不合格总数
  1146. this.$set(
  1147. this.List[index].workReportInfo,
  1148. 'notFormedWeight',
  1149. notFormedWeightCount
  1150. ); //不合格总重量
  1151. }
  1152. }
  1153. };
  1154. </script>
  1155. <style scoped lang="scss">
  1156. .top_fixed {
  1157. width: 100%;
  1158. height: 40px;
  1159. background: #fff;
  1160. display: flex;
  1161. align-items: center;
  1162. justify-content: flex-end;
  1163. }
  1164. .title_box {
  1165. padding: 10px 0;
  1166. .name {
  1167. font-size: 14px;
  1168. font-style: normal;
  1169. font-weight: 400;
  1170. color: #157a2c;
  1171. padding-left: 5px;
  1172. position: relative;
  1173. &:before {
  1174. position: absolute;
  1175. content: '';
  1176. left: 0px;
  1177. top: 0px;
  1178. bottom: 0px;
  1179. width: 2px;
  1180. height: 14px;
  1181. background: #157a2c;
  1182. margin: auto;
  1183. }
  1184. }
  1185. }
  1186. .job_box {
  1187. margin-top: 6px;
  1188. width: 100%;
  1189. height: calc(100vh - 70px - 50px - 80px - 60px);
  1190. overflow-y: scroll;
  1191. overflow-x: hidden;
  1192. }
  1193. .card_box {
  1194. background: #fff;
  1195. padding: 8px;
  1196. border-radius: 2px;
  1197. }
  1198. </style>