index.vue 65 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125
  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" v-if="isReportTime">
  9. <div class="name">批量报工时间:</div>
  10. <el-date-picker
  11. v-model="reportTime"
  12. type="datetimerange"
  13. range-separator="至"
  14. start-placeholder="开始时间"
  15. end-placeholder="结束时间"
  16. format="yyyy-MM-dd HH:mm:ss"
  17. value-format="yyyy-MM-dd HH:mm:ss"
  18. align="right"
  19. @change="changeBatchReportTime"
  20. :picker-options="pickerOptionsTwo"
  21. @calendar-change="handleCalendarChange"
  22. >
  23. </el-date-picker>
  24. </div>
  25. <div class="rx-bc" v-if="!isReportTime">
  26. <div class="name">批量报工时间:</div>
  27. <el-date-picker
  28. v-model="executorTime"
  29. type="datetime"
  30. format="yyyy-MM-dd HH:mm:ss"
  31. value-format="yyyy-MM-dd HH:mm:ss"
  32. placeholder="选择日期"
  33. @change="handleCreate"
  34. :picker-options="pickerOptions"
  35. >
  36. </el-date-picker>
  37. </div>
  38. </div>
  39. <el-button
  40. type="primary"
  41. size="mini"
  42. :loading="loadingBtn"
  43. @click="save(2, 'all')"
  44. >一键报工</el-button
  45. >
  46. <el-button type="primary" size="mini" @click="removeCacheFn('all')"
  47. >清空缓存</el-button
  48. >
  49. <el-button
  50. v-if="taskObj.type == 1"
  51. type="primary"
  52. size="mini"
  53. @click="save(1, 'all')"
  54. >缓存</el-button
  55. >
  56. </div>
  57. <div class="job_box">
  58. <div
  59. v-for="(item, index) in List"
  60. :key="index"
  61. class="card_box"
  62. v-if="isLoad"
  63. >
  64. <div class="title_box rx-bc">
  65. <div class="name" v-if="!taskObj.isOrderListData">工单信息 </div>
  66. <div class="name" v-else> </div>
  67. <div class="rx-bc">
  68. <el-button
  69. type="text"
  70. size="mini"
  71. @click="openPicking(item.workOrderId, item)"
  72. >手动添加</el-button
  73. >
  74. <el-button
  75. type="text"
  76. size="mini"
  77. @click="removeCacheFn(item.workOrderId)"
  78. >清空缓存</el-button
  79. >
  80. <el-button
  81. v-if="taskObj.type == 1"
  82. type="text"
  83. size="mini"
  84. @click="save(1, index)"
  85. >缓存</el-button
  86. >
  87. </div>
  88. </div>
  89. <!-- // 工单信息 -->
  90. <workOrderBom
  91. :item="item"
  92. :isReportWork="true"
  93. :isOrder="!taskObj.isOrderListData"
  94. ></workOrderBom>
  95. <!-- 报工时间 -->
  96. <div>
  97. <div class="title_box rx-bc">
  98. <div class="name">报工时间</div>
  99. </div>
  100. <div v-if="isReportTime">
  101. 报工时间
  102. <el-date-picker
  103. v-model="item.workReportInfo.reportTime"
  104. type="datetimerange"
  105. range-separator="至"
  106. start-placeholder="开始时间"
  107. end-placeholder="结束时间"
  108. format="yyyy-MM-dd HH:mm:ss"
  109. value-format="yyyy-MM-dd HH:mm:ss"
  110. align="right"
  111. style="margin-right: 10px"
  112. @change="changeReportTime(index)"
  113. :picker-options="pickerOptionsTwo"
  114. @calendar-change="handleCalendarChange"
  115. >
  116. </el-date-picker>
  117. 工时
  118. <el-input
  119. v-model="item.workReportInfo.workTime"
  120. placeholder="请输入工时"
  121. style="width: 220px"
  122. >
  123. <template slot="append">小时</template>
  124. </el-input>
  125. <div style="margin-top: 10px">
  126. 执行人:
  127. <el-select
  128. v-model="teamId"
  129. placeholder="请选择班组"
  130. filterable
  131. style="width: 120px"
  132. @change="checkTeamList(teamId)"
  133. >
  134. <el-option
  135. v-for="item in teamList"
  136. :label="item.name"
  137. :value="item.id"
  138. :key="item.id"
  139. >
  140. </el-option>
  141. </el-select>
  142. <el-select
  143. v-model="executorIdList"
  144. placeholder="请选择执行人"
  145. filterable
  146. multiple
  147. @change="changeId(index)"
  148. style="width: 160px"
  149. >
  150. <div class="checkboxWrapper">
  151. <el-checkbox v-model="checked" @change="checkChange(index)">
  152. 全选
  153. </el-checkbox>
  154. </div>
  155. <el-option
  156. v-for="item in teamUserList"
  157. :label="item.name"
  158. :value="item.id"
  159. :key="item.id"
  160. >
  161. </el-option>
  162. </el-select>
  163. </div>
  164. </div>
  165. <div v-else>
  166. 报工时间:
  167. <el-date-picker
  168. v-model="item.workReportInfo.executorTime"
  169. type="datetime"
  170. format="yyyy-MM-dd HH:mm:ss"
  171. value-format="yyyy-MM-dd HH:mm:ss"
  172. placeholder="选择日期"
  173. style="margin-right: 25px; width: 190px"
  174. :picker-options="pickerOptions"
  175. >
  176. </el-date-picker>
  177. 执行人:
  178. <el-select
  179. v-model="teamId"
  180. placeholder="请选择班组"
  181. filterable
  182. style="width: 120px"
  183. @change="checkTeamList(teamId)"
  184. >
  185. <el-option
  186. v-for="item in teamList"
  187. :label="item.name"
  188. :value="item.id"
  189. :key="item.id"
  190. >
  191. </el-option>
  192. </el-select>
  193. <el-select
  194. v-model="executorIdList"
  195. placeholder="请选择执行人"
  196. filterable
  197. multiple
  198. @change="changeId(index)"
  199. >
  200. <div class="checkboxWrapper">
  201. <el-checkbox v-model="checked" @change="checkChange">
  202. 全选
  203. </el-checkbox>
  204. </div>
  205. <el-option
  206. v-for="item in teamUserList"
  207. :label="item.name"
  208. :value="item.id"
  209. :key="item.id"
  210. >
  211. </el-option>
  212. </el-select>
  213. </div>
  214. </div>
  215. <paramBom
  216. v-if="item.paramDetailList.length != 0"
  217. :list="item.paramDetailList"
  218. ></paramBom>
  219. <!-- //报工信息 -->
  220. <div v-if="item.singleReport == 0">
  221. <jobBom
  222. :item="item"
  223. ref="jobBomRef"
  224. :notFormed="item.notFormedList"
  225. :warehouseList="warehouseList"
  226. ></jobBom>
  227. </div>
  228. <div v-if="item.singleReport == 1">
  229. <jobDdBom
  230. :item="item"
  231. ref="jobRef"
  232. :notFormed="item.notFormedList"
  233. :warehouseList="warehouseList"
  234. ></jobDdBom>
  235. </div>
  236. <!-- :item="item" :notFormed="item.notFormedList" :warehouseList="warehouseList" @modeNum='modeNum'-->
  237. <deviceBom
  238. v-if="item.equipmentList.length != 0"
  239. :list="item.equipmentList"
  240. ></deviceBom>
  241. <modelBom
  242. v-if="item.modelList.length != 0"
  243. :list="item.modelList"
  244. pattern="job"
  245. ref="modelRef"
  246. :item="item"
  247. ></modelBom>
  248. <palletBom
  249. v-if="item.palletList.length != 0"
  250. :list="item.palletList"
  251. ></palletBom>
  252. <revolvingDiskBom
  253. v-if="item.revolvingDiskList.length > 0"
  254. pattern="job"
  255. :list="objData.revolvingDiskList"
  256. >
  257. </revolvingDiskBom>
  258. <!-- 单件 报告信息 -->
  259. <semiProductJobBom
  260. :singleReport="item.singleReport"
  261. v-if="
  262. item.semiProductList &&
  263. item.semiProductList.length != 0 &&
  264. item.singleReport == 1 &&
  265. clientEnvironmentId != 3
  266. "
  267. :item="item"
  268. :list="item.semiProductList"
  269. :equipmentList="item.equipmentList"
  270. :isChoose="isChoose"
  271. @chooseData="chooseData"
  272. :isEngrave="isEngrave"
  273. :isDisposal="isDisposal"
  274. ></semiProductJobBom>
  275. <semiProductJobBom
  276. :singleReport="item.singleReport"
  277. v-if="
  278. item.semiProductList &&
  279. item.semiProductList.length != 0 &&
  280. item.singleReport == 1 &&
  281. clientEnvironmentId == 3 &&
  282. taskObj.type != 4
  283. "
  284. :item="item"
  285. :list="item.semiProductList"
  286. :equipmentList="item.equipmentList"
  287. :isChoose="isChoose"
  288. @chooseData="chooseData"
  289. :isEngrave="isEngrave"
  290. :isDisposal="isDisposal"
  291. ></semiProductJobBom>
  292. <!-- 通用批量报工 -->
  293. <batchSemiProductJobBom
  294. :singleReport="item.singleReport"
  295. v-if="
  296. item.product &&
  297. item.product.length != 0 &&
  298. item.singleReport == 0 &&
  299. clientEnvironmentId != 3
  300. "
  301. :item="item"
  302. :list="item.product"
  303. :equipmentList="item.equipmentList"
  304. :isChoose="isChoose"
  305. :isEngrave="isEngrave"
  306. :isDisposal="isDisposal"
  307. @chooseData="chooseData"
  308. ></batchSemiProductJobBom>
  309. <!-- <batchSemiProductJobBom
  310. :singleReport="item.singleReport"
  311. v-if="
  312. item.semiProductList &&
  313. item.semiProductList.length != 0 &&
  314. item.singleReport == 0 &&
  315. clientEnvironmentId == 3 &&
  316. taskObj.type == 4
  317. "
  318. :item="item"
  319. :list="item.semiProductList"
  320. :equipmentList="item.equipmentList"
  321. :isChoose="isChoose"
  322. :isEngrave="isEngrave"
  323. :isDisposal="isDisposal"
  324. @chooseData="chooseData"
  325. ></batchSemiProductJobBom> -->
  326. <!-- <checkbox :tableData="item.semiProductList" ></checkbox> -->
  327. <!-- :itemData="item" @tableDataFn="tableDataFn" -->
  328. <!-- 碳谷批量报工 -->
  329. <semiProductJobBomPL
  330. :singleReport="item.singleReport"
  331. v-if="
  332. item.semiProductList &&
  333. item.semiProductList.length != 0 &&
  334. taskObj.type != 6 &&
  335. item.singleReport == 0 &&
  336. clientEnvironmentId == 3
  337. "
  338. :item="item"
  339. :list="item.semiProductList"
  340. :equipmentList="item.equipmentList"
  341. @countNumPl="countNumPl"
  342. :isChoose="isChoose"
  343. :isEngrave="isEngrave"
  344. :isDisposal="isDisposal"
  345. :index="index"
  346. ></semiProductJobBomPL>
  347. <!-- <semiProductJobBom v-if="
  348. item.pickOutInList &&
  349. item.pickOutInList.length != 0 &&
  350. taskObj.type == 6 &&
  351. item.singleReport == 1
  352. " :item="item" :list="item.pickOutInList">
  353. </semiProductJobBom> -->
  354. <!-- 物料清单 -->
  355. <!-- <semiProductBom
  356. v-if="
  357. item.semiProductList.length != 0 &&
  358. item.singleReport == 0 &&
  359. clientEnvironmentId != 3
  360. "
  361. :list="item.semiProductList"
  362. :equipmentList="item.equipmentList"
  363. :workInfo="item"
  364. ></semiProductBom> -->
  365. <!-- 产品信息 -->
  366. <oneJobQualityBomPL
  367. v-if="
  368. item.semiProductList &&
  369. item.semiProductList.length != 0 &&
  370. taskObj.type == 6 &&
  371. item.singleReport == 0 &&
  372. clientEnvironmentId == 3
  373. "
  374. :item="item"
  375. :list="item.semiProductList"
  376. >
  377. </oneJobQualityBomPL>
  378. <byProductBom
  379. v-if="item.productRecycleList.length != 0"
  380. :list="item.productRecycleList"
  381. >
  382. </byProductBom>
  383. <turnoverBom
  384. v-if="item.turnover.length != 0"
  385. :list="item.turnover"
  386. :wordItem="item"
  387. pattern="job"
  388. >
  389. </turnoverBom>
  390. <aridRegion
  391. v-if="item.aridRegionList.length != 0"
  392. :list="item.aridRegionList"
  393. :isType="true"
  394. ></aridRegion>
  395. <!-- 这里是包装分组 -->
  396. <!-- <div
  397. v-if="
  398. item.currentTaskDiagram.type == 4 &&
  399. item.semiProductList.length != 0
  400. "
  401. >
  402. <semiProductJobBom
  403. :singleReport="item.singleReport"
  404. :item="item"
  405. :list="
  406. item.currentTaskDiagram.type == 4
  407. ? item.pickOutInList
  408. : item.semiProductList
  409. "
  410. :equipmentList="item.equipmentList"
  411. ></semiProductJobBom>
  412. </div>
  413. <div
  414. v-if="
  415. item.currentTaskDiagram.type == 4 && item.pickOutInList.length != 0
  416. "
  417. >
  418. <semiProductJobBom
  419. :singleReport="item.singleReport"
  420. :item="item"
  421. :list="
  422. item.currentTaskDiagram.type == 4
  423. ? item.pickOutInList
  424. : item.semiProductList
  425. "
  426. :equipmentList="item.equipmentList"
  427. ></semiProductJobBom>
  428. </div> -->
  429. <packingTgBom
  430. v-if="
  431. item.semiProductList &&
  432. item.semiProductList.length != 0 &&
  433. taskObj.type == 4 &&
  434. clientEnvironmentId == 3 &&
  435. item.singleReport == 1
  436. "
  437. :list="item.semiProductList"
  438. :item="item"
  439. :isChoose="isChoose"
  440. :isEngrave="isEngrave"
  441. :isDisposal="isDisposal"
  442. ></packingTgBom>
  443. <div
  444. v-if="
  445. item &&
  446. item.currentTaskDiagram.type == 4 &&
  447. clientEnvironmentId == 3 &&
  448. item.singleReport == 0
  449. "
  450. >
  451. <batchPackagingGrouping
  452. ref="packagingGroupingRef"
  453. :objData="item"
  454. :workOrderId="item.workOrderId"
  455. :taskId="item.currentTaskDiagram.taskId"
  456. >
  457. </batchPackagingGrouping>
  458. </div>
  459. <div
  460. v-if="
  461. item &&
  462. item.currentTaskDiagram.type == 4 &&
  463. clientEnvironmentId != 3
  464. "
  465. >
  466. <!-- <packagingGrouping
  467. ref="packagingGroupingRef"
  468. :objData="item"
  469. :workOrderId="item.workOrderId"
  470. :taskId="item.currentTaskDiagram.taskId"
  471. >
  472. </packagingGrouping> -->
  473. <batchPackagingGrouping
  474. ref="packagingGroupingRef"
  475. :objData="item"
  476. :workOrderId="item.workOrderId"
  477. :taskId="item.currentTaskDiagram.taskId"
  478. >
  479. </batchPackagingGrouping>
  480. </div>
  481. <!-- <packingBom :taskId='taskObj.id' :workOrderId="item.workOrderId" :objData="item" ref="packRef"
  482. v-if='taskObj.type == 4 && clientEnvironmentId != 3 && item'></packingBom> -->
  483. <!-- <semiProductJobBom
  484. :singleReport="item.singleReport"
  485. v-if="
  486. item.semiProductList &&
  487. item.semiProductList.length != 0 &&
  488. item.singleReport == 1
  489. "
  490. :item="item"
  491. :list="item.semiProductList"
  492. :equipmentList="item.equipmentList"
  493. :isChoose="isChoose"
  494. @chooseData="chooseData"
  495. :isEngrave="isEngrave"
  496. :isDisposal="isDisposal"
  497. ></semiProductJobBom> -->
  498. <!-- <packingTgBom
  499. v-if="
  500. item.semiProductList &&
  501. item.semiProductList.length != 0 &&
  502. taskObj.type == 4 &&
  503. clientEnvironmentId == 3
  504. "
  505. :list="item.semiProductList"
  506. :item="item"
  507. ></packingTgBom> -->
  508. <semiProductJobBom
  509. v-if="
  510. item.pickOutInList &&
  511. item.pickOutInList.length != 0 &&
  512. taskObj.type == 4 &&
  513. clientEnvironmentId == 3
  514. "
  515. :singleReport="item.singleReport"
  516. :list="item.semiProductList"
  517. :equipmentList="item.equipmentList"
  518. :item="item"
  519. @chooseData="chooseData"
  520. :isEngrave="isEngrave"
  521. :isDisposal="isDisposal"
  522. ></semiProductJobBom>
  523. </div>
  524. </div>
  525. <pickingList
  526. isType="feed"
  527. ref="pickingListRef"
  528. @allSelection="allSelection"
  529. ></pickingList>
  530. </div>
  531. </template>
  532. <script>
  533. import { listByIdsReport, checkReportNumber } from '@/api/produce/job';
  534. import { getWarehouseList } from '@/api/produce/index';
  535. import {
  536. jobSave,
  537. saveCache,
  538. getCache,
  539. removeCache
  540. } from '@/api/produce/workOrder';
  541. import pickingList from '../picking/pickingList.vue';
  542. import packagingGrouping from './components/packagingGrouping.vue';
  543. import workOrderBom from '../feeding/components/workOrderBom.vue';
  544. import paramBom from '../feeding/components/paramBom.vue';
  545. import jobBom from './components/jobBom.vue';
  546. import deviceBom from '../feeding/components/deviceBom.vue';
  547. import modelBom from '../feeding/components/modelBom.vue';
  548. import palletBom from './components/palletBom.vue';
  549. import revolvingDiskBom from '../feeding/components/revolvingDiskBom.vue';
  550. import oneJobQualityBom from './components/oneJobQualityBom.vue';
  551. import oneJobQualityBomPL from './components/oneJobQualityBomPL.vue';
  552. import jobDdBom from './components/jobDdBom.vue';
  553. import semiProductJobBom from './components/semiProductJobBom.vue';
  554. // import semiProductJobBom from './components/newSemiProductJobBom.vue';
  555. import semiProductJobBomPL from './components/semiProductJobBomPL.vue';
  556. import semiProductJobBomQT from './components/semiProductJobBomQT.vue';
  557. import batchSemiProductJobBom from './components/batchSemiProductJobBom.vue';
  558. import batchPackagingGrouping from './components/batchPackagingGrouping.vue';
  559. import semiProductBom from '../feeding/components/semiProductBom';
  560. // import byProductBom from './components/byProductBom.vue';
  561. import byProductBom from './components/newByProductBom.vue';
  562. import turnoverBom from './components/turnoverBom.vue';
  563. import aridRegion from '../feeding/components/aridRegion.vue';
  564. import packingBom from './components/packingBom.vue';
  565. import packingTgBom from './components/packingTgBom.vue';
  566. import { timestampToDateTime } from '@/utils/index.js';
  567. import { parameterGetByCode } from '@/api/system/dictionary-data';
  568. import { getTeam } from '@/api/produce/job.js';
  569. export default {
  570. components: {
  571. pickingList,
  572. packagingGrouping,
  573. workOrderBom,
  574. paramBom,
  575. jobBom,
  576. deviceBom,
  577. modelBom,
  578. palletBom,
  579. revolvingDiskBom,
  580. oneJobQualityBom,
  581. oneJobQualityBomPL,
  582. semiProductJobBomQT,
  583. semiProductJobBom,
  584. semiProductJobBomPL,
  585. byProductBom,
  586. turnoverBom,
  587. aridRegion,
  588. packingBom,
  589. jobDdBom,
  590. packingTgBom,
  591. semiProductBom,
  592. batchSemiProductJobBom,
  593. batchPackagingGrouping
  594. },
  595. props: {
  596. workListIds: {
  597. type: Array,
  598. default() {
  599. return [];
  600. }
  601. },
  602. reportNeedFeed: {},
  603. workPlanType: {
  604. type: String,
  605. default: ''
  606. }
  607. },
  608. data() {
  609. return {
  610. List: [],
  611. idsList: [],
  612. isLoad: false,
  613. executorTime: '',
  614. warehouseList: [],
  615. loading: null,
  616. loadingBtn: false,
  617. chooseListData: [],
  618. isChoose: false,
  619. isEngrave: false,
  620. isDisposal: false,
  621. teamList: [],
  622. teamAllList: [],
  623. teamUserList: [],
  624. executorIdList: [],
  625. teamId: '',
  626. checked: false,
  627. isReportTime: false,
  628. reportTime: '',
  629. workHour: '',
  630. pickerOptions: {
  631. disabledDate(time) {
  632. // 禁止选择大于当前时间的日期
  633. return time.getTime() > Date.now();
  634. }
  635. // selectableRange: (() => {
  636. // const now = new Date();
  637. // const start = '00:00:00';
  638. // const end = now.toTimeString().split(' ')[0];
  639. // return `${start} - ${end}`;
  640. // })()
  641. },
  642. pickerOptionsTwo: {
  643. disabledDate: (time) => {
  644. // 禁止选择当前时间之后的所有日期时间
  645. return time.getTime() > Date.now();
  646. },
  647. selectableRange: '00:00:00 - 23:59:59' // 默认全天可选,后面会动态修改
  648. }
  649. };
  650. },
  651. computed: {
  652. taskObj() {
  653. return this.$store.state.user.taskObj;
  654. },
  655. clientEnvironmentId() {
  656. return this.$store.state.user.info.clientEnvironmentId;
  657. }
  658. },
  659. watch: {
  660. workListIds: {
  661. handler(val) {
  662. this.getList(val);
  663. },
  664. deep: true,
  665. immediate: true
  666. },
  667. workPlanType: {
  668. handler(val) {
  669. if (val == 1) {
  670. this.getList(this.idsList);
  671. }
  672. }
  673. }
  674. },
  675. created() {
  676. this.getWarehouseListFn();
  677. this.getChooseEngrave();
  678. },
  679. mounted() {
  680. if (localStorage.getItem('singleUserInfo') == '1') {
  681. const data = JSON.parse(localStorage.getItem('chooseUserInfo'));
  682. this.getTeamList(data.teamId);
  683. } else {
  684. this.getTeamList(this.$store.state.user.info.teamId);
  685. }
  686. },
  687. methods: {
  688. checkPack() {
  689. this.$refs.packagingGroupingRef[0].getData();
  690. },
  691. handleCreate(e) {
  692. if (e) {
  693. const list = JSON.parse(JSON.stringify(this.List));
  694. list.map((item) => {
  695. item.workReportInfo.executorTime = e;
  696. });
  697. this.$set(this, 'List', list);
  698. }
  699. },
  700. changeBatchReportTime(e) {
  701. if (e) {
  702. const list = JSON.parse(JSON.stringify(this.List));
  703. list.map((item) => {
  704. item.workReportInfo.reportTime = e;
  705. const startTime = new Date(item.workReportInfo.reportTime[0]);
  706. const endTime = new Date(item.workReportInfo.reportTime[1]);
  707. const diffMs = endTime - startTime;
  708. const diffHours = diffMs / (1000 * 60 * 60);
  709. if (this.executorIdList.length != 0) {
  710. item.workReportInfo.workTime =
  711. Number(diffHours) * Number(this.executorIdList.length);
  712. }
  713. });
  714. this.$set(this, 'List', list);
  715. }
  716. },
  717. async getTeamList(id) {
  718. if(!id) return;
  719. const ids = id.split(',');
  720. this.teamList = [];
  721. this.teamUserList = [];
  722. const list = ids.map((item) => getTeam(item));
  723. const dataList = await Promise.all(list);
  724. dataList.forEach((item) => {
  725. this.teamList.push({
  726. name: item.name,
  727. id: item.id
  728. });
  729. this.teamAllList.push(item.userVOList);
  730. });
  731. },
  732. async getChooseEngrave() {
  733. await parameterGetByCode({
  734. code: 'work_hour'
  735. }).then((res) => {
  736. this.isReportTime = res.value == '1' ? true : false;
  737. });
  738. await parameterGetByCode({
  739. code: 'choose_engrave'
  740. }).then((res) => {
  741. this.isChoose = res.value == '1' ? true : false;
  742. });
  743. await parameterGetByCode({
  744. code: 'batch_update_engrave'
  745. }).then((res) => {
  746. this.isEngrave = res.value == '1' ? true : false;
  747. });
  748. await parameterGetByCode({
  749. code: 'batch_disposal'
  750. }).then((res) => {
  751. this.isDisposal = res.value == '1' ? true : false;
  752. });
  753. await parameterGetByCode({
  754. code: 'default_executor'
  755. }).then((res) => {
  756. this.isDefaultExecutor = res.value == '1' ? true : false;
  757. if (this.isDefaultExecutor) {
  758. this.setDefaultIdList();
  759. }
  760. });
  761. },
  762. setDefaultIdList() {
  763. if (this.teamList.length != 0) {
  764. this.teamId = this.teamList[0].id;
  765. const index = this.teamList.findIndex(
  766. (item) => item.id == this.teamId
  767. );
  768. this.teamUserList = this.teamAllList[index];
  769. if (this.teamUserList) {
  770. const res = this.teamUserList.find(
  771. (it) => it.id == this.$store.state.user.info.userId
  772. );
  773. this.executorIdList.push(res.id);
  774. }
  775. // const res = this.teamUserList.find(
  776. // (it) => it.id == this.$store.state.user.info.userId
  777. // );
  778. // this.executorIdList.push(res.id);
  779. }
  780. },
  781. changeId(index) {
  782. if (this.isReportTime) {
  783. this.calculateWorkingHours(index);
  784. }
  785. if (this.executorIdList.length == this.teamUserList.length) {
  786. this.checked = true;
  787. } else {
  788. this.checked = false;
  789. }
  790. },
  791. changeReportTime(index) {
  792. if (this.List[index].workReportInfo.reportTime) {
  793. this.calculateWorkingHours(index);
  794. } else {
  795. this.List[index].workReportInfo.workTime = '';
  796. }
  797. },
  798. calculateWorkingHours(index) {
  799. const startTime = new Date(
  800. this.List[index].workReportInfo.reportTime[0]
  801. );
  802. const endTime = new Date(this.List[index].workReportInfo.reportTime[1]);
  803. const diffMs = endTime - startTime;
  804. const diffHours = diffMs / (1000 * 60 * 60);
  805. if (this.executorIdList.length != 0) {
  806. this.List[index].workReportInfo.workTime =
  807. Number(diffHours) * Number(this.executorIdList.length);
  808. }
  809. },
  810. checkChange(index) {
  811. if (this.checked) {
  812. this.executorIdList = [];
  813. this.executorIdList = this.teamUserList.map((item) => item.id);
  814. } else {
  815. this.executorIdList = [];
  816. this.List[index].workReportInfo.workTime = '';
  817. }
  818. if (this.isReportTime) {
  819. this.calculateWorkingHours(index);
  820. }
  821. },
  822. getList(ids) {
  823. this.idsList = ids || [];
  824. if (this.taskObj.id != -2) {
  825. let param = {
  826. ids: ids,
  827. taskId: this.taskObj.id,
  828. type: 0
  829. };
  830. this.isLoad = false;
  831. listByIdsReport(param)
  832. .then((res) => {
  833. this.List = res.map((obj) => {
  834. if (!Object.prototype.hasOwnProperty.call(obj, 'turnover')) {
  835. obj['turnover'] = [];
  836. }
  837. if (
  838. !Object.prototype.hasOwnProperty.call(obj, 'aridRegionList')
  839. ) {
  840. obj['aridRegionList'] = [];
  841. }
  842. if (
  843. !Object.prototype.hasOwnProperty.call(obj, 'instanceList')
  844. ) {
  845. obj['instanceList'] = [];
  846. }
  847. if (!Object.prototype.hasOwnProperty.call(obj, 'palletList')) {
  848. obj['palletList'] = [];
  849. }
  850. if (
  851. !Object.prototype.hasOwnProperty.call(
  852. obj,
  853. 'revolvingDiskList'
  854. )
  855. ) {
  856. obj['revolvingDiskList'] = [];
  857. }
  858. if (obj.palletList.length > 0) {
  859. obj.palletList = obj.palletList.map((m) => {
  860. return {
  861. hideKc: true, // 不显示库存
  862. quantity: m.feedQuantity,
  863. ...m
  864. };
  865. });
  866. }
  867. // console.log(this.taskObj.type, 'this.taskObj.type');
  868. if (
  869. (this.taskObj.type == 6 && obj.singleReport == 1) ||
  870. (this.clientEnvironmentId == 3 &&
  871. obj.singleReport == 0 &&
  872. this.taskObj.type == 6)
  873. ) {
  874. obj.semiProductList = obj.pickOutInList;
  875. obj.semiProductList.forEach((item) => {
  876. if (item.extInfo.taskId == -1) {
  877. item.extInfo.taskId = item.extInfo.taskId + '';
  878. }
  879. });
  880. obj.pickOutInList = [];
  881. console.log('赋值了');
  882. } else if (
  883. this.clientEnvironmentId == 3 &&
  884. obj.singleReport == 0
  885. ) {
  886. if (obj.pickOutInList && obj.pickOutInList.length != 0) {
  887. obj.semiProductList = obj.pickOutInList;
  888. obj.semiProductList.forEach((item) => {
  889. if (item.extInfo.taskId == -1) {
  890. item.extInfo.taskId = item.extInfo.taskId + '';
  891. }
  892. });
  893. obj.pickOutInList = [];
  894. }
  895. } else if (this.taskObj.type == 6 && obj.singleReport == 0) {
  896. obj.product = obj.pickOutInList;
  897. obj.pickOutInList = [];
  898. } else if (
  899. this.taskObj.type == 4 &&
  900. obj.singleReport == 0 &&
  901. this.clientEnvironmentId != 3
  902. ) {
  903. if (obj.pickOutInList && obj.pickOutInList.length != 0) {
  904. obj.product = obj.pickOutInList;
  905. obj.pickOutInList = [];
  906. }
  907. } else if (
  908. this.taskObj.type == 4 &&
  909. obj.singleReport == 1 &&
  910. this.clientEnvironmentId != 2
  911. ) {
  912. if (obj.pickOutInList && obj.pickOutInList.length != 0) {
  913. obj.semiProductList = obj.pickOutInList;
  914. obj.pickOutInList = [];
  915. }
  916. }
  917. if (
  918. obj.singleReport == 1 &&
  919. obj.currentTaskDiagram.type != 2 &&
  920. obj.currentTaskDiagram.type != 3 &&
  921. obj.currentTaskDiagram.type != 6
  922. ) {
  923. obj.semiProductList.map((item) => {
  924. item.extInfo.taskId = '';
  925. item.extInfo.taskName = '';
  926. });
  927. }
  928. if (
  929. obj.singleReport == 0 &&
  930. obj.currentTaskDiagram.type != 2 &&
  931. obj.currentTaskDiagram.type != 3 &&
  932. obj.currentTaskDiagram.type != 6
  933. ) {
  934. obj.product.map((item) => {
  935. item.extInfo.taskId = '';
  936. item.extInfo.taskName = '';
  937. });
  938. }
  939. if (
  940. this.clientEnvironmentId == 3 &&
  941. obj.singleReport == 0 &&
  942. this.taskObj.type != 6
  943. ) {
  944. obj.semiProductList.map((a) => {
  945. let feedQuantity = 0;
  946. let reportWeight = 0;
  947. let unFeedQuantity = 0;
  948. let unReportWeight = 0;
  949. if (
  950. a.extInfo &&
  951. a.extInfo.batchReportInfo &&
  952. a.extInfo.batchReportInfo.length != 0
  953. ) {
  954. a.extInfo.batchReportInfo.forEach((it) => {
  955. console.log(it, '1111111111');
  956. feedQuantity += Number(it.allFeedQuantity);
  957. reportWeight += Number(it.allReportWeight);
  958. });
  959. }
  960. if (
  961. a.extInfo &&
  962. a.extInfo.notBatchReportInfo &&
  963. a.extInfo.notBatchReportInfo.length != 0
  964. ) {
  965. a.extInfo.notBatchReportInfo.forEach((it) => {
  966. unFeedQuantity += Number(it.allFeedQuantity);
  967. unReportWeight += Number(it.allReportWeight);
  968. });
  969. }
  970. a.extInfo.batchReportInfo = [
  971. {
  972. allFeedQuantity: feedQuantity,
  973. allReportWeight: reportWeight,
  974. taskId: '',
  975. taskName: ''
  976. }
  977. ];
  978. a.extInfo.notBatchReportInfo = [
  979. {
  980. allFeedQuantity: unFeedQuantity,
  981. allReportWeight: unReportWeight,
  982. notType: '',
  983. taskId: '',
  984. taskName: '',
  985. notReason: ''
  986. }
  987. ];
  988. return {
  989. a
  990. };
  991. });
  992. obj.semiProductList = JSON.parse(
  993. JSON.stringify(obj.semiProductList)
  994. );
  995. }
  996. obj.semiProductList = obj.semiProductList.map((item) => {
  997. if (this.taskObj.type != 6) {
  998. if (item['extInfo']?.reportWeight) {
  999. item['extInfo'].reportWeight = '';
  1000. }
  1001. }
  1002. item.confirm = 0;
  1003. return item;
  1004. });
  1005. obj.product = obj.product.map((item) => {
  1006. if (this.taskObj.type != 6) {
  1007. if (item['extInfo']?.reportWeight) {
  1008. item['extInfo'].reportWeight = '';
  1009. }
  1010. }
  1011. item.confirm = 0;
  1012. return item;
  1013. });
  1014. obj.workReportInfo = {
  1015. executorTime: null,
  1016. formingNum: null,
  1017. formingWeight: null,
  1018. formedNum: null,
  1019. formedWeight: null,
  1020. taskId: this.taskObj.id,
  1021. notFormedNum: null,
  1022. notFormedWeight: null,
  1023. lossQuantity: null,
  1024. lossWeight: null,
  1025. executorStartTime: null,
  1026. reportTime: '',
  1027. workTime: ''
  1028. };
  1029. obj.notFormedList = [
  1030. {
  1031. notFormedNum: null,
  1032. notFormedWeight: null,
  1033. weightUnit: obj.weightUnit,
  1034. unit: obj.unit,
  1035. warehouseId: null // 处置 仓库id
  1036. }
  1037. ];
  1038. if (obj.semiProductList.length != 0) {
  1039. // 预制体报工
  1040. obj.workReportInfo.formedNum = obj.semiProductList.length;
  1041. let numCot = 0;
  1042. let notFormedNum = 0;
  1043. if (obj.semiProductList.length > 0) {
  1044. obj.semiProductList.map((fitem) => {
  1045. if (
  1046. !fitem.extInfo.isQualified ||
  1047. fitem.extInfo.isQualified == 1
  1048. ) {
  1049. numCot = numCot + fitem.feedQuantity || 1;
  1050. } else {
  1051. notFormedNum = notFormedNum + fitem.feedQuantity;
  1052. }
  1053. });
  1054. obj.workReportInfo.formedNum = numCot;
  1055. obj.workReportInfo.notFormedNum = notFormedNum;
  1056. }
  1057. } else if (obj.product.length != 0) {
  1058. const formedNum = obj.product.reduce((acc, pro) => {
  1059. return pro.feedQuantity &&
  1060. (!pro.extInfo.isQualified || pro.extInfo.isQualified == 1)
  1061. ? acc + Number(pro.feedQuantity)
  1062. : acc;
  1063. }, 0);
  1064. const notFormedNum = obj.product.reduce((acc, pro) => {
  1065. return pro.feedQuantity && pro.extInfo.isQualified == 2
  1066. ? acc + Number(pro.feedQuantity)
  1067. : acc;
  1068. }, 0);
  1069. obj.workReportInfo.formedNum = formedNum;
  1070. obj.workReportInfo.notFormedNum = notFormedNum;
  1071. }
  1072. obj.workReportInfo.formingNum = obj.formingNum;
  1073. obj.workReportInfo.formingWeight = obj.formingWeight;
  1074. obj.workReportInfo.unit = obj.unit;
  1075. obj.workReportInfo.weightUnit = obj.weightUnit;
  1076. obj.workReportInfo.workOrderId = obj.workOrderId;
  1077. obj.workReportInfo.executorTime = obj.executorTime;
  1078. obj.paramDetailList.map((m) => {
  1079. if (m.extInfo.textType == 5) {
  1080. m.remainingTime = m.extInfo.remainingTime;
  1081. }
  1082. return {
  1083. ...m.extInfo
  1084. };
  1085. });
  1086. console.log(obj, 4445555);
  1087. if (this.taskObj.type == 4) {
  1088. let numVal = 0;
  1089. obj.pickOutInList.map((item) => {
  1090. numVal = numVal + item.feedQuantity;
  1091. });
  1092. obj.workReportInfo.formedNum = numVal;
  1093. }
  1094. return {
  1095. ...obj
  1096. };
  1097. });
  1098. if (this.clientEnvironmentId == 3) {
  1099. this.List.forEach((item, index) => {
  1100. if (
  1101. item.semiProductList.length != 0 &&
  1102. item.singleReport == 0
  1103. ) {
  1104. this.countNumPl(item.semiProductList, index);
  1105. }
  1106. });
  1107. }
  1108. })
  1109. .finally(() => {
  1110. this.isLoad = true;
  1111. if (this.taskObj.type == 1) {
  1112. this.getCacheFn();
  1113. }
  1114. });
  1115. }
  1116. },
  1117. openPicking(id, item) {
  1118. this.$refs.pickingListRef.open(
  1119. id,
  1120. item,
  1121. '选择设备列表',
  1122. this.taskObj.id
  1123. );
  1124. },
  1125. allSelection(id, selectList) {
  1126. console.log(id, selectList, 'allSelection');
  1127. this.List.forEach((m) => {
  1128. if (m.workOrderId == id) {
  1129. let turnover = [];
  1130. let equipmentList = []; // 生产设备
  1131. selectList.forEach((f) => {
  1132. if (f.rootCategoryLevelId == 4) {
  1133. equipmentList = equipmentList.concat(f);
  1134. }
  1135. if (f.rootCategoryLevelId == 7) {
  1136. turnover = turnover.concat(f);
  1137. }
  1138. });
  1139. this.$set(m, 'equipmentList', equipmentList);
  1140. this.$set(m, 'turnover', turnover);
  1141. this.$forceUpdate();
  1142. }
  1143. });
  1144. },
  1145. chooseData(dataList) {
  1146. this.chooseListData = this.deepCopy(dataList);
  1147. // if (this.chooseListData.length > 0) {
  1148. // this.chooseListData.forEach((item) => {
  1149. // item.confirm = 1;
  1150. // });
  1151. // } else {
  1152. // this.List.forEach((item) => {
  1153. // item.semiProductList.forEach((fitem) => {
  1154. // fitem.confirm = 0;
  1155. // });
  1156. // });
  1157. // }
  1158. },
  1159. deepCopy(obj, hash = new WeakMap()) {
  1160. if (obj === null) return null;
  1161. if (obj instanceof Date) return new Date(obj);
  1162. if (obj instanceof RegExp) return new RegExp(obj);
  1163. if (typeof obj !== 'object' && typeof obj !== 'function') return obj;
  1164. if (hash.has(obj)) return hash.get(obj); // 处理循环引用
  1165. const result = Array.isArray(obj) ? [] : {};
  1166. hash.set(obj, result); // 存储原始对象和其副本的映射关系
  1167. return Object.keys(obj).reduce((acc, key) => {
  1168. acc[key] = this.deepCopy(obj[key], hash);
  1169. return acc;
  1170. }, result);
  1171. },
  1172. checkTeamList(id) {
  1173. this.executorIdList = [];
  1174. const index = this.teamList.findIndex((item) => item.id == id);
  1175. this.teamUserList = this.teamAllList[index];
  1176. },
  1177. toInteger(num) {
  1178. const len = this.getDecimalLength(num);
  1179. return {
  1180. int: Math.round(num * Math.pow(10, len)),
  1181. factor: Math.pow(10, len)
  1182. };
  1183. },
  1184. add(a, b) {
  1185. const { int: aInt, factor: aFactor } = this.toInteger(a);
  1186. const { int: bInt, factor: bFactor } = this.toInteger(b);
  1187. const maxFactor = Math.max(aFactor, bFactor);
  1188. return (
  1189. (aInt * (maxFactor / aFactor) + bInt * (maxFactor / bFactor)) /
  1190. maxFactor
  1191. );
  1192. },
  1193. getDecimalLength(num) {
  1194. return (num.toString().split('.')[1] || '').length;
  1195. },
  1196. async checkReportNum() {
  1197. for (let item of this.List) {
  1198. if (item.currentTaskDiagram.isFirstTask == '1') {
  1199. await checkReportNumber({
  1200. currentTaskDiagram: item.currentTaskDiagram,
  1201. workOrderId: item.workOrderId
  1202. }).then((res) => {
  1203. const totalNum = Number(item.formingNum);
  1204. const reportNum = this.add(
  1205. item.workReportInfo.notFormedNum,
  1206. item.workReportInfo.formedNum
  1207. );
  1208. const totalReportNum = this.add(reportNum, Number(res));
  1209. console.log(totalReportNum, totalNum, '1111');
  1210. if (totalReportNum > totalNum) {
  1211. this.$confirm('报工数量大于生产数量, 是否继续报工?', '提示', {
  1212. confirmButtonText: '确定',
  1213. cancelButtonText: '取消',
  1214. type: 'warning'
  1215. })
  1216. .then(() => {
  1217. this.$message({
  1218. type: 'success',
  1219. message: '删除成功!'
  1220. });
  1221. return true;
  1222. })
  1223. .catch(() => {
  1224. this.$message({
  1225. type: 'info',
  1226. message: '已取消删除'
  1227. });
  1228. return false;
  1229. });
  1230. }
  1231. });
  1232. }
  1233. }
  1234. },
  1235. handleCalendarChange(val) {
  1236. if (!val || val.length === 0) return;
  1237. const selected = val[val.length - 1]; // 当前选中的日期
  1238. const now = new Date();
  1239. const todayStr = now.toDateString();
  1240. const selectedStr = new Date(selected).toDateString();
  1241. if (todayStr === selectedStr) {
  1242. // 如果选中的是今天,只能选择到当前时分秒
  1243. const end = now.toTimeString().split(' ')[0];
  1244. this.pickerOptions.selectableRange = `00:00:00 - ${end}`;
  1245. } else {
  1246. // 其他日期不限
  1247. this.pickerOptions.selectableRange = '00:00:00 - 23:59:59';
  1248. }
  1249. },
  1250. async save(type) {
  1251. const required = await parameterGetByCode({
  1252. code: 'mes_report_engrave_required'
  1253. }).then((res) => {
  1254. return res;
  1255. });
  1256. if (this.executorIdList.length == 0) {
  1257. return this.$message.warning('执行人不能为空!');
  1258. }
  1259. const executorList = [];
  1260. this.executorIdList.forEach((item) => {
  1261. const data = this.teamUserList.find((it) => it.id == item);
  1262. if (data) {
  1263. executorList.push({
  1264. userId: data.id,
  1265. jobNumber: data.jobNumber,
  1266. name: data.name
  1267. });
  1268. }
  1269. });
  1270. this.List = this.List.map((item) => {
  1271. item.workReportInfo.executorList = executorList;
  1272. return item;
  1273. });
  1274. console.log(this.List, '------------');
  1275. let confirmList = [];
  1276. // const confirmList = this.List[0].semiProductList.filter(
  1277. // (item) => item.confirm == 1
  1278. // );
  1279. this.List.forEach((item) => {
  1280. item.semiProductList.forEach((it) => {
  1281. if (it.confirm == 1) {
  1282. confirmList.push(it);
  1283. }
  1284. });
  1285. });
  1286. if (required.value == '1' && this.List[0].singleReport == 1) {
  1287. // if (this.chooseListData.length > 0) {
  1288. // this.checkChooseData(this.chooseListData, type, 'choose');
  1289. // return;
  1290. // } else {
  1291. // this.checkChooseData(this.List, type, 'all');
  1292. // return;
  1293. // }
  1294. console.log(this.List, 'this.List');
  1295. if (confirmList.length > 0) {
  1296. for (let i = 0; i < confirmList.length; i++) {
  1297. // if (
  1298. // !confirmList[i].extInfo.engrave &&
  1299. // confirmList[i].confirm == 1
  1300. // ) {
  1301. // this.$message.warning('请输入刻码!');
  1302. // return;
  1303. // }
  1304. if (confirmList[i].confirm == 1) {
  1305. if (!confirmList[i].extInfo.engrave) {
  1306. this.$message.warning('请输入刻码!');
  1307. return;
  1308. }
  1309. }
  1310. }
  1311. } else {
  1312. if (this.List.length > 0) {
  1313. console.log(this.List);
  1314. for (let i = 0; i < this.List[0].semiProductList.length; i++) {
  1315. // if (!this.List[0].semiProductList[i].extInfo.engrave) {
  1316. // this.$message.warning('请输入刻码!');
  1317. // return;
  1318. // }
  1319. if (this.List[0].semiProductList[i].confirm == 1) {
  1320. if (!this.List[0].semiProductList[i].extInfo.engrave) {
  1321. this.$message.warning('请输入刻码!');
  1322. return;
  1323. }
  1324. }
  1325. }
  1326. // this.List.forEach((item) => {
  1327. // for (let i = 0; i < item.semiProductList.length; i++) {
  1328. // if (!item.semiProductList[i].extInfo.engrave) {
  1329. // this.$message.warning('请输入刻码!');
  1330. // return;
  1331. // }
  1332. // }
  1333. // });
  1334. // for (let i = 0; i < this.List.length; i++) {
  1335. // for(let j = 0; i < this.List[i].semiProductList.length; j++) {
  1336. // }
  1337. // // for (let j = 0; this.List[i].semiProductList.length; j++) {
  1338. // // console.log(
  1339. // // this.List[i].semiProductList[j],
  1340. // // 'this.List[i].semiProductList[j]'
  1341. // // );
  1342. // // if (!this.List[i].semiProductList[j].extInfo.engrave) {
  1343. // // this.$message.warning('请输入刻码!');
  1344. // // return;
  1345. // // }
  1346. // // }
  1347. // }
  1348. }
  1349. }
  1350. }
  1351. this.loading = this.$loading({
  1352. lock: true,
  1353. text: '加载中',
  1354. background: 'rgba(0, 0, 0, 0.7)'
  1355. });
  1356. if (this.isReportTime) {
  1357. let arr = this.List.filter((L) => L.workReportInfo.reportTime);
  1358. if (!arr.length) {
  1359. this.loading.close();
  1360. return this.$message.warning('请选择执行时间');
  1361. }
  1362. this.List.forEach((item) => {
  1363. item.workReportInfo.executorStartTime =
  1364. item.workReportInfo.reportTime[0];
  1365. item.workReportInfo.executorTime =
  1366. item.workReportInfo.reportTime[1];
  1367. });
  1368. } else {
  1369. let arr = this.List.filter((L) => L.workReportInfo.executorTime);
  1370. if (!arr.length) {
  1371. this.loading.close();
  1372. return this.$message.warning('请选择执行时间');
  1373. }
  1374. }
  1375. // for (let i = 0; i < this.List.length; i++) {
  1376. // if (
  1377. // this.List[i].packInfo &&
  1378. // Object.keys(this.List[i].packInfo).length === 0
  1379. // ) {
  1380. // this.loading.close();
  1381. // return this.$message.warning('请到主数据配置包装规格');
  1382. // }
  1383. // }
  1384. // if(this.taskObj.type !=6){
  1385. // if(this.reportNeedFeed==1&&!(this.List[0].semiProductList.length>0||this.List[0].pickOutInList.length>0)){
  1386. // this.loading.close();
  1387. // return this.$message.warning('请先投料再报工');
  1388. // }
  1389. // }
  1390. let bol2;
  1391. bol2 = this.List.every((e) => {
  1392. return (
  1393. // e.workReportInfo['formedNum'] && e.workReportInfo['formedNum'] != 0
  1394. e.workReportInfo['formedNum'] != ''
  1395. );
  1396. });
  1397. // if (!bol2) {
  1398. // this.$message.warning('请输入合格品数量');
  1399. // this.loading.close();
  1400. // return false;
  1401. // }
  1402. // 预制体
  1403. let wId;
  1404. let bol = true;
  1405. let _i;
  1406. this.List.forEach((L) => {
  1407. if (
  1408. L.semiProductList.length > 0 &&
  1409. this.taskObj.type != 4 &&
  1410. L.singleReport == 1
  1411. ) {
  1412. bol = L.semiProductList.every((e, i) => {
  1413. _i = i + 1;
  1414. wId = L.code;
  1415. if (this.taskObj.type == 6) {
  1416. return (
  1417. Object.prototype.hasOwnProperty.call(e.extInfo, 'taskId') &&
  1418. e.extInfo.taskId
  1419. );
  1420. } else {
  1421. if (e.extInfo.isQualified == 1 || e.extInfo.notType == 5) {
  1422. return (
  1423. Object.prototype.hasOwnProperty.call(e.extInfo, 'taskId') &&
  1424. e.extInfo.taskId &&
  1425. e.extInfo.reportWeight
  1426. );
  1427. } else {
  1428. return (
  1429. Object.prototype.hasOwnProperty.call(
  1430. e.extInfo,
  1431. 'notType'
  1432. ) && e.extInfo.notType
  1433. );
  1434. }
  1435. }
  1436. });
  1437. }
  1438. if (L.workReportInfo.batchNo) {
  1439. L.workReportInfo.batchNo = L.batchNo + L.workReportInfo.batchNo;
  1440. }
  1441. });
  1442. // if (!bol) {
  1443. // this.$message.warning(`请完善工单${wId}第${_i}处置方式`);
  1444. // this.loading.close();
  1445. // return false;
  1446. // }
  1447. if (this.clientEnvironmentId == 3) {
  1448. for (const item of this.List) {
  1449. if (item.singleReport == 0) {
  1450. if (item.currentTaskDiagram.type == 6) {
  1451. for (const it of item.sampleQuality) {
  1452. const data = it.extInfo;
  1453. if (data.batchReportInfo.length == 0) {
  1454. if (!data.reportWeight) {
  1455. this.loading.close();
  1456. return this.$message.warning('报工重量不能为空');
  1457. }
  1458. } else if (data.batchReportInfo.length != 0) {
  1459. for (const i of data.batchReportInfo) {
  1460. if (i.allFeedQuantity) {
  1461. if (!i.allReportWeight) {
  1462. this.loading.close();
  1463. return this.$message.warning('报工重量不能为空');
  1464. }
  1465. }
  1466. }
  1467. }
  1468. }
  1469. } else {
  1470. for (const it of item.semiProductList) {
  1471. const data = it.extInfo;
  1472. for (const i of data.batchReportInfo) {
  1473. if (i.allFeedQuantity) {
  1474. if (!i.allReportWeight) {
  1475. this.loading.close();
  1476. return this.$message.warning('报工重量不能为空');
  1477. }
  1478. }
  1479. }
  1480. for (const i of data.notBatchReportInfo) {
  1481. if (i.allFeedQuantity) {
  1482. if (!i.allReportWeight) {
  1483. this.loading.close();
  1484. return this.$message.warning('不合格品重量不能为空');
  1485. }
  1486. }
  1487. }
  1488. }
  1489. }
  1490. } else {
  1491. if (item.currentTaskDiagram.type != 4) {
  1492. for (const it of item.semiProductList) {
  1493. const data = it.extInfo;
  1494. if (!data.reportWeight) {
  1495. this.loading.close();
  1496. return this.$message.warning('报工重量不能为空');
  1497. }
  1498. }
  1499. }
  1500. }
  1501. }
  1502. }
  1503. if (this.clientEnvironmentId != 2) {
  1504. for (let i = 0; i < this.List.length; i++) {
  1505. for (let j = 0; j < this.List[i].productRecycleList.length; j++) {
  1506. if (!this.List[i].productRecycleList[j].warehouseId) {
  1507. const isRecycle = await this.checkRecycle();
  1508. if (!isRecycle) {
  1509. this.loading.close();
  1510. return false;
  1511. }
  1512. }
  1513. }
  1514. }
  1515. // let succ = this.List.some((L) => {
  1516. // return L.productRecycleList.length > 0;
  1517. // });
  1518. // if (succ) {
  1519. // const isRecycle = await this.checkRecycle();
  1520. // if (!isRecycle) {
  1521. // return false;
  1522. // }
  1523. // }
  1524. }
  1525. if (this.taskObj.type == 4) {
  1526. if (this.clientEnvironmentId == 3) {
  1527. this.List.forEach((it) => {
  1528. if (it.singleReport == 0) {
  1529. this.checkPack();
  1530. }
  1531. });
  1532. } else {
  1533. this.checkPack();
  1534. }
  1535. // if (!isPack) {
  1536. // return false
  1537. // }
  1538. }
  1539. if (this.taskObj.type == 1) {
  1540. const isCache = await this.checkCache(type);
  1541. if (!isCache) {
  1542. return false;
  1543. }
  1544. }
  1545. if (
  1546. this.clientEnvironmentId == 3 &&
  1547. type == 2 &&
  1548. this.taskObj.type == 6
  1549. ) {
  1550. this.List.forEach((L) => {
  1551. if (L.singleReport == 0) {
  1552. L.semiProductList = [];
  1553. }
  1554. });
  1555. }
  1556. let isSemiProduct = false;
  1557. this.List.map((semi) => {
  1558. if (
  1559. semi.semiProductList.length == 0 &&
  1560. semi.singleReport == 1 &&
  1561. semi.currentTaskDiagram.isFirstTask == 1 &&
  1562. this.clientEnvironmentId != 3
  1563. ) {
  1564. isSemiProduct = true;
  1565. this.loading.close();
  1566. setTimeout(() => {
  1567. this.$message.warning({
  1568. message: '请工单编号:' + semi.code + '先创建在制品',
  1569. key: semi.code // 使用当前时间作为key,确保唯一性
  1570. });
  1571. }, 500);
  1572. }
  1573. if (semi.semiProductList.length == 0 && semi.singleReport == 0) {
  1574. semi.semiProductList.map((ditem) => {
  1575. if (ditem.extInfo.batchReportInfo) {
  1576. ditem.extInfo.batchReportInfo.map((baItem) => {
  1577. let idvalue = baItem.deviceId
  1578. ? baItem.deviceId.split('/')
  1579. : '';
  1580. baItem.deviceId = idvalue ? idvalue[0] : '';
  1581. });
  1582. }
  1583. if (ditem.extInfo.notBatchReportInfo) {
  1584. ditem.extInfo.notBatchReportInfo.map((noItem) => {
  1585. let idvalue = noItem.deviceId
  1586. ? noItem.deviceId.split('/')
  1587. : '';
  1588. noItem.deviceId = idvalue ? idvalue[0] : '';
  1589. });
  1590. }
  1591. });
  1592. }
  1593. });
  1594. if (isSemiProduct) {
  1595. this.loading.close();
  1596. return;
  1597. }
  1598. let newList = [];
  1599. for (let item of this.List) {
  1600. newList.push({
  1601. currentTaskDiagram: item.currentTaskDiagram,
  1602. workOrderId: item.workOrderId
  1603. });
  1604. // await checkReportNumber({
  1605. // currentTaskDiagram: item.currentTaskDiagram,
  1606. // workOrderId: item.workOrderId
  1607. // }).then((res) => {
  1608. // const totalNum = Number(item.formingNum);
  1609. // const reportNum = this.add(
  1610. // item.workReportInfo.notFormedNum,
  1611. // item.workReportInfo.formedNum
  1612. // );
  1613. // const totalReportNum = this.add(reportNum, Number(res));
  1614. // if (totalReportNum > totalNum) {
  1615. // this.$confirm('报工数量大于生产数量, 是否继续报工?', '提示', {
  1616. // confirmButtonText: '确定',
  1617. // cancelButtonText: '取消',
  1618. // type: 'warning'
  1619. // })
  1620. // .then(() => {
  1621. // this.jobBookReport();
  1622. // })
  1623. // .catch(() => {
  1624. // this.loading.close();
  1625. // });
  1626. // } else {
  1627. // this.jobBookReport();
  1628. // }
  1629. // });
  1630. }
  1631. await checkReportNumber(newList).then((res) => {
  1632. if (res.length != 0) {
  1633. this.checkJobBook(res);
  1634. }
  1635. });
  1636. // this.loadingBtn = true;
  1637. // jobSave(this.List)
  1638. // .then((res) => {
  1639. // this.loadingBtn = false;
  1640. // this.loading.close();
  1641. // this.$message.success('报工成功');
  1642. // this.checked = false;
  1643. // this.executorIdList = [];
  1644. // this.teamId = '';
  1645. // this.getList(this.idsList);
  1646. // this.$emit('jobSuccess', 'Success');
  1647. // })
  1648. // .catch(() => {
  1649. // this.loadingBtn = false;
  1650. // this.loading.close();
  1651. // });
  1652. // .finally(() => {
  1653. // setTimeout(function () {
  1654. // this.loading.close();
  1655. // }, 3000);
  1656. // });
  1657. },
  1658. checkJobBook(list) {
  1659. let wordCodeList = [];
  1660. let reportCodeList = [];
  1661. for (let item of list) {
  1662. if (item.reportFormed != '0') {
  1663. wordCodeList.push(item.workOrderCode);
  1664. }
  1665. }
  1666. if (!this.isReportTime) {
  1667. for (let item of list) {
  1668. for (let it of this.List) {
  1669. if (item.workOrderCode == it.code) {
  1670. if (item.feedDate) {
  1671. const t1 = new Date(item.feedDate);
  1672. const t2 = new Date(it.workReportInfo.executorTime);
  1673. if (t1 > t2) {
  1674. reportCodeList.push(item.workOrderCode);
  1675. }
  1676. }
  1677. if (item.reportDate) {
  1678. const t1 = new Date(item.reportDate);
  1679. const t2 = new Date(it.workReportInfo.executorTime);
  1680. if (t1 > t2) {
  1681. reportCodeList.push(item.workOrderCode);
  1682. }
  1683. }
  1684. }
  1685. }
  1686. }
  1687. }
  1688. if (reportCodeList.length != 0) {
  1689. this.$confirm(
  1690. `工单号${reportCodeList.join(
  1691. ','
  1692. )}报工时间大于上道工序的执行时间,是否继续报工?`,
  1693. '提示',
  1694. {
  1695. confirmButtonText: '确定',
  1696. cancelButtonText: '取消',
  1697. type: 'warning',
  1698. center: true
  1699. }
  1700. )
  1701. .then(() => {
  1702. return this.checkWorkCode(wordCodeList);
  1703. })
  1704. .catch(() => {
  1705. this.loading.close();
  1706. });
  1707. } else {
  1708. this.checkWorkCode(wordCodeList);
  1709. }
  1710. },
  1711. checkWorkCode(list) {
  1712. if (list.length != 0) {
  1713. this.$confirm(
  1714. `工单号${list.join(',')}已有报工,是否继续重复报工?`,
  1715. '提示',
  1716. {
  1717. confirmButtonText: '确定',
  1718. cancelButtonText: '取消',
  1719. type: 'warning',
  1720. center: true
  1721. }
  1722. )
  1723. .then(() => {
  1724. this.jobBookReport();
  1725. })
  1726. .catch(() => {
  1727. this.loading.close();
  1728. });
  1729. } else {
  1730. this.jobBookReport();
  1731. }
  1732. },
  1733. jobBookReport() {
  1734. this.loadingBtn = true;
  1735. jobSave(this.List)
  1736. .then((res) => {
  1737. this.loadingBtn = false;
  1738. this.loading.close();
  1739. this.$message.success('报工成功');
  1740. this.checked = false;
  1741. this.executorIdList = [];
  1742. this.teamId = '';
  1743. this.getList(this.idsList);
  1744. this.$emit('jobSuccess', 'Success');
  1745. })
  1746. .catch(() => {
  1747. this.loadingBtn = false;
  1748. this.loading.close();
  1749. });
  1750. },
  1751. checkRecycle() {
  1752. // this.loading.close();
  1753. return new Promise((resolve) => {
  1754. this.$confirm('是否跳过副产品回收处置!', '提示', {
  1755. confirmButtonText: '确定',
  1756. cancelButtonText: '取消',
  1757. type: 'warning'
  1758. })
  1759. .then(() => {
  1760. resolve(true);
  1761. })
  1762. .catch(() => {
  1763. resolve(false);
  1764. });
  1765. });
  1766. },
  1767. checkCache(type) {
  1768. return new Promise((resolve) => {
  1769. if (type == 1) {
  1770. saveCache(this.List).then((rr) => {
  1771. this.$message.success('缓存成功');
  1772. this.loading.close();
  1773. });
  1774. resolve(false);
  1775. } else if (type == 2) {
  1776. resolve(true);
  1777. }
  1778. });
  1779. },
  1780. getCacheFn() {
  1781. let parma = {
  1782. workOrderIds: this.idsList,
  1783. taskId: this.taskObj.id,
  1784. type: 1
  1785. };
  1786. getCache(parma).then((res) => {
  1787. this.List.forEach((f, index) => {
  1788. res.forEach((o) => {
  1789. if (f.workOrderId == o.workOrderId) {
  1790. f['product'] = o.extInfo.product;
  1791. f['workReportInfo'] = o.extInfo.workReportInfo;
  1792. f['notFormedList'] = o.extInfo.notFormedList;
  1793. f['turnover'] = o.extInfo.turnover;
  1794. f['productRecycleList'] = o.extInfo.productRecycleList;
  1795. f['semiProductList'] = o.extInfo.semiProductList;
  1796. f['modelList'] = o.extInfo.modelList;
  1797. // this.$set(this.List[index].workReportInfo,'executorTime',timestampToDateTime(o.extInfo.workReportInfo.executorTime))
  1798. this.$forceUpdate();
  1799. }
  1800. });
  1801. });
  1802. });
  1803. },
  1804. removeCacheFn(type) {
  1805. this.$confirm('是否清空缓存', '缓存')
  1806. .then(() => {
  1807. let parma = {
  1808. workOrderIds: type == 'all' ? this.idsList : [type],
  1809. taskId: this.taskObj.id,
  1810. type: 1
  1811. };
  1812. removeCache(parma).then((res) => {
  1813. this.$message.success('已经清空缓存');
  1814. this.getList(this.idsList);
  1815. });
  1816. })
  1817. .catch(() => {});
  1818. },
  1819. getWarehouseListFn() {
  1820. getWarehouseList().then((res) => {
  1821. this.warehouseList = res.data;
  1822. });
  1823. },
  1824. //批量报工合格不合格重量统计
  1825. countNumPl(list, index) {
  1826. console.log('11111122222333', list);
  1827. //合格总数
  1828. let formedNumCount = 0;
  1829. //合格总重量
  1830. let formedWeightCount = 0;
  1831. //不合格总数
  1832. let notFormedNumCount = 0;
  1833. //不合格总重量
  1834. let notFormedWeightCount = 0;
  1835. list.map((item) => {
  1836. //合格总数
  1837. item.extInfo.batchReportInfo.forEach((m) => {
  1838. formedNumCount = formedNumCount + Number(m.allFeedQuantity || 0);
  1839. });
  1840. //合格总重量
  1841. item.extInfo.batchReportInfo.forEach((w) => {
  1842. formedWeightCount =
  1843. formedWeightCount + Number(w.allReportWeight || 0);
  1844. });
  1845. //不合格总数
  1846. item.extInfo.notBatchReportInfo.forEach((nf) => {
  1847. notFormedNumCount =
  1848. notFormedNumCount + Number(nf.allFeedQuantity || 0);
  1849. });
  1850. //不合格总重量
  1851. item.extInfo.notBatchReportInfo.forEach((nw) => {
  1852. notFormedWeightCount =
  1853. notFormedWeightCount + Number(nw.allReportWeight || 0);
  1854. });
  1855. });
  1856. this.$set(this.List[index].workReportInfo, 'formedNum', formedNumCount); //合格总数
  1857. this.$set(
  1858. this.List[index].workReportInfo,
  1859. 'formedWeight',
  1860. formedWeightCount
  1861. ); //合格总重量
  1862. this.$set(
  1863. this.List[index].workReportInfo,
  1864. 'notFormedNum',
  1865. notFormedNumCount
  1866. ); //不合格总数
  1867. this.$set(
  1868. this.List[index].workReportInfo,
  1869. 'notFormedWeight',
  1870. notFormedWeightCount
  1871. ); //不合格总重量
  1872. }
  1873. }
  1874. };
  1875. </script>
  1876. <style scoped lang="scss">
  1877. .top_fixed {
  1878. width: 100%;
  1879. height: 40px;
  1880. background: #fff;
  1881. display: flex;
  1882. align-items: center;
  1883. justify-content: flex-end;
  1884. }
  1885. .title_box {
  1886. padding: 10px 0;
  1887. .name {
  1888. font-size: 14px;
  1889. font-style: normal;
  1890. font-weight: 400;
  1891. color: #157a2c;
  1892. padding-left: 5px;
  1893. position: relative;
  1894. &:before {
  1895. position: absolute;
  1896. content: '';
  1897. left: 0px;
  1898. top: 0px;
  1899. bottom: 0px;
  1900. width: 2px;
  1901. height: 14px;
  1902. background: #157a2c;
  1903. margin: auto;
  1904. }
  1905. }
  1906. }
  1907. .job_box {
  1908. // margin-top: 6px;
  1909. width: 100%;
  1910. height: calc(100vh - 70px - 50px - 80px - 60px);
  1911. overflow-y: scroll;
  1912. overflow-x: hidden;
  1913. }
  1914. .card_box {
  1915. background: #fff;
  1916. padding: 8px;
  1917. border-radius: 2px;
  1918. }
  1919. .checkboxWrapper {
  1920. padding: 8px 20px;
  1921. border-bottom: 1px solid #ccc;
  1922. }
  1923. ::v-deep .el-select__tags {
  1924. flex-wrap: nowrap;
  1925. overflow: auto;
  1926. }
  1927. /* 输入框最大宽度*/
  1928. ::v-deep .el-select__tags-text {
  1929. max-width: 90px;
  1930. }
  1931. /* 底部滚动条的高度*/
  1932. ::v-deep .el-select__tags::-webkit-scrollbar {
  1933. height: 2px !important;
  1934. }
  1935. </style>