index.vue 62 KB

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