index.vue 61 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027
  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. teamName: '',
  627. checked: false,
  628. isReportTime: false,
  629. reportTime: '',
  630. workHour: '',
  631. pickerOptions: {
  632. disabledDate(time) {
  633. // 禁止选择大于当前时间的日期
  634. return time.getTime() > Date.now();
  635. }
  636. // selectableRange: (() => {
  637. // const now = new Date();
  638. // const start = '00:00:00';
  639. // const end = now.toTimeString().split(' ')[0];
  640. // return `${start} - ${end}`;
  641. // })()
  642. },
  643. pickerOptionsTwo: {
  644. disabledDate: (time) => {
  645. // 禁止选择当前时间之后的所有日期时间
  646. return time.getTime() > Date.now();
  647. },
  648. selectableRange: '00:00:00 - 23:59:59' // 默认全天可选,后面会动态修改
  649. }
  650. };
  651. },
  652. computed: {
  653. taskObj() {
  654. return this.$store.state.user.taskObj;
  655. },
  656. clientEnvironmentId() {
  657. return this.$store.state.user.info.clientEnvironmentId;
  658. }
  659. },
  660. watch: {
  661. workListIds: {
  662. handler(val) {
  663. this.getList(val);
  664. },
  665. deep: true,
  666. immediate: true
  667. },
  668. workPlanType: {
  669. handler(val) {
  670. if (val == 1) {
  671. this.getList(this.idsList);
  672. }
  673. }
  674. }
  675. },
  676. created() {
  677. this.getWarehouseListFn();
  678. this.getChooseEngrave();
  679. },
  680. mounted() {
  681. if (localStorage.getItem('singleUserInfo') == '1') {
  682. const data = JSON.parse(localStorage.getItem('chooseUserInfo'));
  683. this.getTeamList(data.teamId);
  684. } else {
  685. this.getTeamList(this.$store.state.user.info.teamId);
  686. }
  687. },
  688. methods: {
  689. checkPack() {
  690. this.$refs.packagingGroupingRef[0].getData();
  691. },
  692. handleCreate(e) {
  693. if (e) {
  694. const list = JSON.parse(JSON.stringify(this.List));
  695. list.map((item) => {
  696. item.workReportInfo.executorTime = e;
  697. });
  698. this.$set(this, 'List', list);
  699. }
  700. },
  701. changeBatchReportTime(e) {
  702. if (e) {
  703. const list = JSON.parse(JSON.stringify(this.List));
  704. list.map((item) => {
  705. item.workReportInfo.reportTime = e;
  706. const startTime = new Date(item.workReportInfo.reportTime[0]);
  707. const endTime = new Date(item.workReportInfo.reportTime[1]);
  708. const diffMs = endTime - startTime;
  709. const diffHours = diffMs / (1000 * 60 * 60);
  710. if (this.executorIdList.length != 0) {
  711. item.workReportInfo.workTime =
  712. Number(diffHours) * Number(this.executorIdList.length);
  713. }
  714. });
  715. this.$set(this, 'List', list);
  716. }
  717. },
  718. async getTeamList(id) {
  719. if (!id) return;
  720. const ids = id.split(',');
  721. this.teamList = [];
  722. this.teamUserList = [];
  723. const list = ids.map((item) => getTeam(item));
  724. const dataList = await Promise.all(list);
  725. dataList.forEach((item) => {
  726. this.teamList.push({
  727. name: item.name,
  728. id: item.id
  729. });
  730. this.teamAllList.push(item.userVOList);
  731. });
  732. },
  733. getNowTime() {
  734. const now = new Date();
  735. const year = now.getFullYear();
  736. const month = String(now.getMonth() + 1).padStart(2, '0');
  737. const day = String(now.getDate()).padStart(2, '0');
  738. const hour = String(now.getHours()).padStart(2, '0');
  739. const minute = String(now.getMinutes()).padStart(2, '0');
  740. const second = String(now.getSeconds()).padStart(2, '0');
  741. return `${year}-${month}-${day} ${hour}:${minute}:${second}`;
  742. },
  743. async getChooseEngrave() {
  744. await parameterGetByCode({
  745. code: 'work_hour'
  746. }).then((res) => {
  747. this.isReportTime = res.value == '1' ? true : false;
  748. });
  749. const res = await parameterGetByCode({
  750. code: 'mes_order_feed_by_default_date'
  751. });
  752. if (res.value == '1') {
  753. const dateTime = this.getNowTime();
  754. this.$nextTick(() => {
  755. this.List.forEach((item) => {
  756. if (!item.workReportInfo) {
  757. this.$set(item, 'workReportInfo', {});
  758. }
  759. this.$set(item.workReportInfo, 'executorTime', dateTime);
  760. });
  761. });
  762. }
  763. // await parameterGetByCode({
  764. // code: 'mes_order_feed_by_default_date'
  765. // }).then((res) => {
  766. // if (res.value == '1') {
  767. // const dateTime = this.getNowTime();
  768. // this.List.forEach((item) => {
  769. // item.workReportInfo.executorTime = dateTime;
  770. // });
  771. // }
  772. // });
  773. await parameterGetByCode({
  774. code: 'choose_engrave'
  775. }).then((res) => {
  776. this.isChoose = res.value == '1' ? true : false;
  777. });
  778. await parameterGetByCode({
  779. code: 'batch_update_engrave'
  780. }).then((res) => {
  781. this.isEngrave = res.value == '1' ? true : false;
  782. });
  783. await parameterGetByCode({
  784. code: 'batch_disposal'
  785. }).then((res) => {
  786. this.isDisposal = res.value == '1' ? true : false;
  787. });
  788. await parameterGetByCode({
  789. code: 'default_executor'
  790. }).then((res) => {
  791. this.isDefaultExecutor = res.value == '1' ? true : false;
  792. if (this.isDefaultExecutor) {
  793. this.setDefaultIdList();
  794. }
  795. });
  796. },
  797. setDefaultIdList() {
  798. if (this.teamList.length != 0) {
  799. this.teamId = this.teamList[0].id;
  800. this.teamName = this.teamList[0].name;
  801. const index = this.teamList.findIndex(
  802. (item) => item.id == this.teamId
  803. );
  804. this.teamUserList = this.teamAllList[index];
  805. if (this.teamUserList) {
  806. const res = this.teamUserList.find(
  807. (it) => it.id == this.$store.state.user.info.userId
  808. );
  809. this.executorIdList.push(res.id);
  810. }
  811. // const res = this.teamUserList.find(
  812. // (it) => it.id == this.$store.state.user.info.userId
  813. // );
  814. // this.executorIdList.push(res.id);
  815. }
  816. },
  817. changeId(index) {
  818. if (this.isReportTime) {
  819. this.calculateWorkingHours(index);
  820. }
  821. if (this.executorIdList.length == this.teamUserList.length) {
  822. this.checked = true;
  823. } else {
  824. this.checked = false;
  825. }
  826. },
  827. changeReportTime(index) {
  828. if (this.List[index].workReportInfo.reportTime) {
  829. this.calculateWorkingHours(index);
  830. } else {
  831. this.List[index].workReportInfo.workTime = '';
  832. }
  833. },
  834. calculateWorkingHours(index) {
  835. const startTime = new Date(
  836. this.List[index].workReportInfo.reportTime[0]
  837. );
  838. const endTime = new Date(this.List[index].workReportInfo.reportTime[1]);
  839. const diffMs = endTime - startTime;
  840. const diffHours = diffMs / (1000 * 60 * 60);
  841. if (this.executorIdList.length != 0) {
  842. this.List[index].workReportInfo.workTime =
  843. Number(diffHours) * Number(this.executorIdList.length);
  844. }
  845. },
  846. checkChange(index) {
  847. if (this.checked) {
  848. this.executorIdList = [];
  849. this.executorIdList = this.teamUserList.map((item) => item.id);
  850. } else {
  851. this.executorIdList = [];
  852. this.List[index].workReportInfo.workTime = '';
  853. }
  854. if (this.isReportTime) {
  855. this.calculateWorkingHours(index);
  856. }
  857. },
  858. getList(ids) {
  859. this.idsList = ids || [];
  860. if (this.taskObj.id != -2) {
  861. let param = {
  862. ids: ids,
  863. taskId: this.taskObj.id,
  864. type: 0
  865. };
  866. this.isLoad = false;
  867. listByIdsReport(param)
  868. .then((res) => {
  869. this.List = res.map((obj) => {
  870. if (!Object.prototype.hasOwnProperty.call(obj, 'turnover')) {
  871. obj['turnover'] = [];
  872. }
  873. if (
  874. !Object.prototype.hasOwnProperty.call(obj, 'aridRegionList')
  875. ) {
  876. obj['aridRegionList'] = [];
  877. }
  878. if (
  879. !Object.prototype.hasOwnProperty.call(obj, 'instanceList')
  880. ) {
  881. obj['instanceList'] = [];
  882. }
  883. if (!Object.prototype.hasOwnProperty.call(obj, 'palletList')) {
  884. obj['palletList'] = [];
  885. }
  886. if (
  887. !Object.prototype.hasOwnProperty.call(
  888. obj,
  889. 'revolvingDiskList'
  890. )
  891. ) {
  892. obj['revolvingDiskList'] = [];
  893. }
  894. if (obj.palletList.length > 0) {
  895. obj.palletList = obj.palletList.map((m) => {
  896. return {
  897. hideKc: true, // 不显示库存
  898. quantity: m.feedQuantity,
  899. ...m
  900. };
  901. });
  902. }
  903. // console.log(this.taskObj.type, 'this.taskObj.type');
  904. if (
  905. (this.taskObj.type == 6 && obj.singleReport == 1) ||
  906. (this.clientEnvironmentId == 3 &&
  907. obj.singleReport == 0 &&
  908. this.taskObj.type == 6)
  909. ) {
  910. obj.semiProductList = obj.pickOutInList;
  911. obj.semiProductList.forEach((item) => {
  912. if (item.extInfo.taskId == -1) {
  913. item.extInfo.taskId = item.extInfo.taskId + '';
  914. }
  915. });
  916. obj.pickOutInList = [];
  917. console.log('赋值了');
  918. } else if (
  919. this.clientEnvironmentId == 3 &&
  920. obj.singleReport == 0
  921. ) {
  922. if (obj.pickOutInList && obj.pickOutInList.length != 0) {
  923. obj.semiProductList = obj.pickOutInList;
  924. obj.semiProductList.forEach((item) => {
  925. if (item.extInfo.taskId == -1) {
  926. item.extInfo.taskId = item.extInfo.taskId + '';
  927. }
  928. });
  929. obj.pickOutInList = [];
  930. }
  931. } else if (this.taskObj.type == 6 && obj.singleReport == 0) {
  932. obj.product = obj.pickOutInList;
  933. obj.pickOutInList = [];
  934. } else if (
  935. this.taskObj.type == 4 &&
  936. obj.singleReport == 0 &&
  937. this.clientEnvironmentId != 3
  938. ) {
  939. if (obj.pickOutInList && obj.pickOutInList.length != 0) {
  940. obj.product = obj.pickOutInList;
  941. obj.pickOutInList = [];
  942. }
  943. } else if (
  944. this.taskObj.type == 4 &&
  945. obj.singleReport == 1 &&
  946. this.clientEnvironmentId != 2
  947. ) {
  948. if (obj.pickOutInList && obj.pickOutInList.length != 0) {
  949. obj.semiProductList = obj.pickOutInList;
  950. obj.pickOutInList = [];
  951. }
  952. }
  953. if (
  954. obj.singleReport == 1 &&
  955. obj.currentTaskDiagram.type != 2 &&
  956. obj.currentTaskDiagram.type != 3 &&
  957. obj.currentTaskDiagram.type != 6
  958. ) {
  959. obj.semiProductList.map((item) => {
  960. item.extInfo.taskId = '';
  961. item.extInfo.taskName = '';
  962. });
  963. }
  964. if (
  965. obj.singleReport == 0 &&
  966. obj.currentTaskDiagram.type != 2 &&
  967. obj.currentTaskDiagram.type != 3 &&
  968. obj.currentTaskDiagram.type != 6
  969. ) {
  970. obj.product.map((item) => {
  971. item.extInfo.taskId = '';
  972. item.extInfo.taskName = '';
  973. });
  974. }
  975. if (
  976. this.clientEnvironmentId == 3 &&
  977. obj.singleReport == 0 &&
  978. this.taskObj.type != 6
  979. ) {
  980. obj.semiProductList.map((a) => {
  981. let feedQuantity = 0;
  982. let reportWeight = 0;
  983. let unFeedQuantity = 0;
  984. let unReportWeight = 0;
  985. if (
  986. a.extInfo &&
  987. a.extInfo.batchReportInfo &&
  988. a.extInfo.batchReportInfo.length != 0
  989. ) {
  990. a.extInfo.batchReportInfo.forEach((it) => {
  991. console.log(it, '1111111111');
  992. feedQuantity += Number(it.allFeedQuantity);
  993. reportWeight += Number(it.allReportWeight);
  994. });
  995. }
  996. if (
  997. a.extInfo &&
  998. a.extInfo.notBatchReportInfo &&
  999. a.extInfo.notBatchReportInfo.length != 0
  1000. ) {
  1001. a.extInfo.notBatchReportInfo.forEach((it) => {
  1002. unFeedQuantity += Number(it.allFeedQuantity);
  1003. unReportWeight += Number(it.allReportWeight);
  1004. });
  1005. }
  1006. a.extInfo.batchReportInfo = [
  1007. {
  1008. allFeedQuantity: feedQuantity,
  1009. allReportWeight: reportWeight,
  1010. taskId: '',
  1011. taskName: ''
  1012. }
  1013. ];
  1014. a.extInfo.notBatchReportInfo = [
  1015. {
  1016. allFeedQuantity: unFeedQuantity,
  1017. allReportWeight: unReportWeight,
  1018. notType: '',
  1019. taskId: '',
  1020. taskName: '',
  1021. notReason: ''
  1022. }
  1023. ];
  1024. return {
  1025. a
  1026. };
  1027. });
  1028. obj.semiProductList = JSON.parse(
  1029. JSON.stringify(obj.semiProductList)
  1030. );
  1031. }
  1032. obj.semiProductList = obj.semiProductList.map((item) => {
  1033. if (this.taskObj.type != 6) {
  1034. if (item['extInfo']?.reportWeight) {
  1035. item['extInfo'].reportWeight = '';
  1036. }
  1037. }
  1038. item.confirm = 0;
  1039. return item;
  1040. });
  1041. obj.product = obj.product.map((item) => {
  1042. if (this.taskObj.type != 6) {
  1043. if (item['extInfo']?.reportWeight) {
  1044. item['extInfo'].reportWeight = '';
  1045. }
  1046. }
  1047. item.confirm = 0;
  1048. return item;
  1049. });
  1050. obj.workReportInfo = {
  1051. executorTime: null,
  1052. formingNum: null,
  1053. formingWeight: null,
  1054. formedNum: null,
  1055. formedWeight: null,
  1056. taskId: this.taskObj.id,
  1057. notFormedNum: null,
  1058. notFormedWeight: null,
  1059. lossQuantity: null,
  1060. lossWeight: null,
  1061. executorStartTime: null,
  1062. reportTime: '',
  1063. workTime: ''
  1064. };
  1065. obj.notFormedList = [
  1066. {
  1067. notFormedNum: null,
  1068. notFormedWeight: null,
  1069. weightUnit: obj.weightUnit,
  1070. unit: obj.unit,
  1071. warehouseId: null // 处置 仓库id
  1072. }
  1073. ];
  1074. if (obj.semiProductList.length != 0) {
  1075. // 预制体报工
  1076. obj.workReportInfo.formedNum = obj.semiProductList.length;
  1077. let numCot = 0;
  1078. let notFormedNum = 0;
  1079. if (obj.semiProductList.length > 0) {
  1080. obj.semiProductList.map((fitem) => {
  1081. if (
  1082. !fitem.extInfo.isQualified ||
  1083. fitem.extInfo.isQualified == 1
  1084. ) {
  1085. numCot = numCot + fitem.feedQuantity || 1;
  1086. } else {
  1087. notFormedNum = notFormedNum + fitem.feedQuantity;
  1088. }
  1089. });
  1090. obj.workReportInfo.formedNum = numCot;
  1091. obj.workReportInfo.notFormedNum = notFormedNum;
  1092. }
  1093. } else if (obj.product.length != 0) {
  1094. const formedNum = obj.product.reduce((acc, pro) => {
  1095. return pro.feedQuantity &&
  1096. (!pro.extInfo.isQualified || pro.extInfo.isQualified == 1)
  1097. ? acc + Number(pro.feedQuantity)
  1098. : acc;
  1099. }, 0);
  1100. const notFormedNum = obj.product.reduce((acc, pro) => {
  1101. return pro.feedQuantity && pro.extInfo.isQualified == 2
  1102. ? acc + Number(pro.feedQuantity)
  1103. : acc;
  1104. }, 0);
  1105. obj.workReportInfo.formedNum = formedNum;
  1106. obj.workReportInfo.notFormedNum = notFormedNum;
  1107. }
  1108. obj.workReportInfo.formingNum = obj.formingNum;
  1109. obj.workReportInfo.formingWeight = obj.formingWeight;
  1110. obj.workReportInfo.unit = obj.unit;
  1111. obj.workReportInfo.weightUnit = obj.weightUnit;
  1112. obj.workReportInfo.workOrderId = obj.workOrderId;
  1113. obj.workReportInfo.executorTime = obj.executorTime;
  1114. obj.paramDetailList.map((m) => {
  1115. if (m.extInfo.textType == 5) {
  1116. m.remainingTime = m.extInfo.remainingTime;
  1117. }
  1118. return {
  1119. ...m.extInfo
  1120. };
  1121. });
  1122. console.log(obj, 4445555);
  1123. if (this.taskObj.type == 4) {
  1124. let numVal = 0;
  1125. obj.pickOutInList.map((item) => {
  1126. numVal = numVal + item.feedQuantity;
  1127. });
  1128. obj.workReportInfo.formedNum = numVal;
  1129. }
  1130. return {
  1131. ...obj
  1132. };
  1133. });
  1134. if (this.clientEnvironmentId == 3) {
  1135. this.List.forEach((item, index) => {
  1136. if (
  1137. item.semiProductList.length != 0 &&
  1138. item.singleReport == 0
  1139. ) {
  1140. this.countNumPl(item.semiProductList, index);
  1141. }
  1142. });
  1143. }
  1144. })
  1145. .finally(() => {
  1146. this.isLoad = true;
  1147. if (this.taskObj.type == 1) {
  1148. this.getCacheFn();
  1149. }
  1150. });
  1151. }
  1152. },
  1153. openPicking(id, item) {
  1154. this.$refs.pickingListRef.open(
  1155. id,
  1156. item,
  1157. '选择设备列表',
  1158. this.taskObj.id
  1159. );
  1160. },
  1161. allSelection(id, selectList) {
  1162. console.log(id, selectList, 'allSelection');
  1163. this.List.forEach((m) => {
  1164. if (m.workOrderId == id) {
  1165. let turnover = [];
  1166. let equipmentList = []; // 生产设备
  1167. selectList.forEach((f) => {
  1168. if (f.rootCategoryLevelId == 4) {
  1169. equipmentList = equipmentList.concat(f);
  1170. }
  1171. if (f.rootCategoryLevelId == 7) {
  1172. turnover = turnover.concat(f);
  1173. }
  1174. });
  1175. this.$set(m, 'equipmentList', equipmentList);
  1176. this.$set(m, 'turnover', turnover);
  1177. this.$forceUpdate();
  1178. }
  1179. });
  1180. },
  1181. chooseData(dataList) {
  1182. this.chooseListData = this.deepCopy(dataList);
  1183. // if (this.chooseListData.length > 0) {
  1184. // this.chooseListData.forEach((item) => {
  1185. // item.confirm = 1;
  1186. // });
  1187. // } else {
  1188. // this.List.forEach((item) => {
  1189. // item.semiProductList.forEach((fitem) => {
  1190. // fitem.confirm = 0;
  1191. // });
  1192. // });
  1193. // }
  1194. },
  1195. deepCopy(obj, hash = new WeakMap()) {
  1196. if (obj === null) return null;
  1197. if (obj instanceof Date) return new Date(obj);
  1198. if (obj instanceof RegExp) return new RegExp(obj);
  1199. if (typeof obj !== 'object' && typeof obj !== 'function') return obj;
  1200. if (hash.has(obj)) return hash.get(obj); // 处理循环引用
  1201. const result = Array.isArray(obj) ? [] : {};
  1202. hash.set(obj, result); // 存储原始对象和其副本的映射关系
  1203. return Object.keys(obj).reduce((acc, key) => {
  1204. acc[key] = this.deepCopy(obj[key], hash);
  1205. return acc;
  1206. }, result);
  1207. },
  1208. checkTeamList(id) {
  1209. this.executorIdList = [];
  1210. const index = this.teamList.findIndex((item) => item.id == id);
  1211. this.teamName = this.teamList[index].name;
  1212. this.teamUserList = this.teamAllList[index];
  1213. },
  1214. toInteger(num) {
  1215. const len = this.getDecimalLength(num);
  1216. return {
  1217. int: Math.round(num * Math.pow(10, len)),
  1218. factor: Math.pow(10, len)
  1219. };
  1220. },
  1221. add(a, b) {
  1222. const { int: aInt, factor: aFactor } = this.toInteger(a);
  1223. const { int: bInt, factor: bFactor } = this.toInteger(b);
  1224. const maxFactor = Math.max(aFactor, bFactor);
  1225. return (
  1226. (aInt * (maxFactor / aFactor) + bInt * (maxFactor / bFactor)) /
  1227. maxFactor
  1228. );
  1229. },
  1230. getDecimalLength(num) {
  1231. return (num.toString().split('.')[1] || '').length;
  1232. },
  1233. async checkReportNum() {
  1234. for (let item of this.List) {
  1235. if (item.currentTaskDiagram.isFirstTask == '1') {
  1236. await checkReportNumber({
  1237. currentTaskDiagram: item.currentTaskDiagram,
  1238. workOrderId: item.workOrderId
  1239. }).then((res) => {
  1240. const totalNum = Number(item.formingNum);
  1241. const reportNum = this.add(
  1242. item.workReportInfo.notFormedNum,
  1243. item.workReportInfo.formedNum
  1244. );
  1245. const totalReportNum = this.add(reportNum, Number(res));
  1246. if (totalReportNum > totalNum) {
  1247. this.$confirm('报工数量大于生产数量, 是否继续报工?', '提示', {
  1248. confirmButtonText: '确定',
  1249. cancelButtonText: '取消',
  1250. type: 'warning'
  1251. })
  1252. .then(() => {
  1253. this.$message({
  1254. type: 'success',
  1255. message: '删除成功!'
  1256. });
  1257. return true;
  1258. })
  1259. .catch(() => {
  1260. this.$message({
  1261. type: 'info',
  1262. message: '已取消删除'
  1263. });
  1264. return false;
  1265. });
  1266. }
  1267. });
  1268. }
  1269. }
  1270. },
  1271. handleCalendarChange(val) {
  1272. if (!val || val.length === 0) return;
  1273. const selected = val[val.length - 1]; // 当前选中的日期
  1274. const now = new Date();
  1275. const todayStr = now.toDateString();
  1276. const selectedStr = new Date(selected).toDateString();
  1277. if (todayStr === selectedStr) {
  1278. // 如果选中的是今天,只能选择到当前时分秒
  1279. const end = now.toTimeString().split(' ')[0];
  1280. this.pickerOptions.selectableRange = `00:00:00 - ${end}`;
  1281. } else {
  1282. // 其他日期不限
  1283. this.pickerOptions.selectableRange = '00:00:00 - 23:59:59';
  1284. }
  1285. },
  1286. async save(type) {
  1287. const required = await parameterGetByCode({
  1288. code: 'mes_report_engrave_required'
  1289. }).then((res) => {
  1290. return res;
  1291. });
  1292. if (this.executorIdList.length == 0) {
  1293. return this.$message.warning('执行人不能为空!');
  1294. }
  1295. const executorList = [];
  1296. this.executorIdList.forEach((item) => {
  1297. const data = this.teamUserList.find((it) => it.id == item);
  1298. if (data) {
  1299. executorList.push({
  1300. userId: data.id,
  1301. jobNumber: data.jobNumber,
  1302. name: data.name
  1303. });
  1304. }
  1305. });
  1306. this.List = this.List.map((item) => {
  1307. item.workReportInfo.executorList = executorList;
  1308. item.workReportInfo.teamId = this.teamId;
  1309. item.workReportInfo.teamName = this.teamName;
  1310. return item;
  1311. });
  1312. let confirmList = [];
  1313. this.List.forEach((item) => {
  1314. item.semiProductList.forEach((it) => {
  1315. if (it.confirm == 1) {
  1316. confirmList.push(it);
  1317. }
  1318. });
  1319. });
  1320. if (required.value == '1' && this.List[0].singleReport == 1) {
  1321. if (confirmList.length > 0) {
  1322. for (let i = 0; i < confirmList.length; i++) {
  1323. if (confirmList[i].confirm == 1) {
  1324. if (!confirmList[i].extInfo.engrave) {
  1325. this.$message.warning('请输入刻码!');
  1326. return;
  1327. }
  1328. }
  1329. }
  1330. } else {
  1331. if (this.List.length > 0) {
  1332. console.log(this.List);
  1333. for (let i = 0; i < this.List[0].semiProductList.length; i++) {
  1334. if (this.List[0].semiProductList[i].confirm == 1) {
  1335. if (!this.List[0].semiProductList[i].extInfo.engrave) {
  1336. this.$message.warning('请输入刻码!');
  1337. return;
  1338. }
  1339. }
  1340. }
  1341. }
  1342. }
  1343. }
  1344. this.loading = this.$loading({
  1345. lock: true,
  1346. text: '加载中',
  1347. background: 'rgba(0, 0, 0, 0.7)'
  1348. });
  1349. if (this.isReportTime) {
  1350. let arr = this.List.filter((L) => L.workReportInfo.reportTime);
  1351. if (!arr.length) {
  1352. this.loading.close();
  1353. return this.$message.warning('请选择执行时间');
  1354. }
  1355. this.List.forEach((item) => {
  1356. item.workReportInfo.executorStartTime =
  1357. item.workReportInfo.reportTime[0];
  1358. item.workReportInfo.executorTime =
  1359. item.workReportInfo.reportTime[1];
  1360. });
  1361. } else {
  1362. let arr = this.List.filter((L) => L.workReportInfo.executorTime);
  1363. if (!arr.length) {
  1364. this.loading.close();
  1365. return this.$message.warning('请选择执行时间');
  1366. }
  1367. }
  1368. let bol2;
  1369. bol2 = this.List.every((e) => {
  1370. return (
  1371. // e.workReportInfo['formedNum'] && e.workReportInfo['formedNum'] != 0
  1372. e.workReportInfo['formedNum'] != ''
  1373. );
  1374. });
  1375. let wId;
  1376. let bol = true;
  1377. let _i;
  1378. this.List.forEach((L) => {
  1379. if (
  1380. L.semiProductList.length > 0 &&
  1381. this.taskObj.type != 4 &&
  1382. L.singleReport == 1
  1383. ) {
  1384. bol = L.semiProductList.every((e, i) => {
  1385. _i = i + 1;
  1386. wId = L.code;
  1387. if (this.taskObj.type == 6) {
  1388. return (
  1389. Object.prototype.hasOwnProperty.call(e.extInfo, 'taskId') &&
  1390. e.extInfo.taskId
  1391. );
  1392. } else {
  1393. if (e.extInfo.isQualified == 1 || e.extInfo.notType == 5) {
  1394. return (
  1395. Object.prototype.hasOwnProperty.call(e.extInfo, 'taskId') &&
  1396. e.extInfo.taskId &&
  1397. e.extInfo.reportWeight
  1398. );
  1399. } else {
  1400. return (
  1401. Object.prototype.hasOwnProperty.call(
  1402. e.extInfo,
  1403. 'notType'
  1404. ) && e.extInfo.notType
  1405. );
  1406. }
  1407. }
  1408. });
  1409. }
  1410. if (L.workReportInfo.batchNo) {
  1411. L.workReportInfo.batchNo = L.batchNo + L.workReportInfo.batchNo;
  1412. }
  1413. });
  1414. if (this.clientEnvironmentId == 3) {
  1415. for (const item of this.List) {
  1416. if (item.singleReport == 0) {
  1417. if (item.currentTaskDiagram.type == 6) {
  1418. for (const it of item.sampleQuality) {
  1419. const data = it.extInfo;
  1420. if (data.batchReportInfo.length == 0) {
  1421. if (!data.reportWeight) {
  1422. this.loading.close();
  1423. return this.$message.warning('报工重量不能为空');
  1424. }
  1425. } else if (data.batchReportInfo.length != 0) {
  1426. for (const i of data.batchReportInfo) {
  1427. if (i.allFeedQuantity) {
  1428. if (!i.allReportWeight) {
  1429. this.loading.close();
  1430. return this.$message.warning('报工重量不能为空');
  1431. }
  1432. }
  1433. }
  1434. }
  1435. }
  1436. } else {
  1437. for (const it of item.semiProductList) {
  1438. const data = it.extInfo;
  1439. for (const i of data.batchReportInfo) {
  1440. if (i.allFeedQuantity) {
  1441. if (!i.allReportWeight) {
  1442. this.loading.close();
  1443. return this.$message.warning('报工重量不能为空');
  1444. }
  1445. }
  1446. }
  1447. for (const i of data.notBatchReportInfo) {
  1448. if (i.allFeedQuantity) {
  1449. if (!i.allReportWeight) {
  1450. this.loading.close();
  1451. return this.$message.warning('不合格品重量不能为空');
  1452. }
  1453. }
  1454. }
  1455. }
  1456. }
  1457. } else {
  1458. if (item.currentTaskDiagram.type != 4) {
  1459. for (const it of item.semiProductList) {
  1460. const data = it.extInfo;
  1461. if (!data.reportWeight) {
  1462. this.loading.close();
  1463. return this.$message.warning('报工重量不能为空');
  1464. }
  1465. }
  1466. }
  1467. }
  1468. }
  1469. }
  1470. if (this.clientEnvironmentId != 2) {
  1471. for (let i = 0; i < this.List.length; i++) {
  1472. for (let j = 0; j < this.List[i].productRecycleList.length; j++) {
  1473. if (!this.List[i].productRecycleList[j].warehouseId) {
  1474. const isRecycle = await this.checkRecycle();
  1475. if (!isRecycle) {
  1476. this.loading.close();
  1477. return false;
  1478. }
  1479. }
  1480. }
  1481. }
  1482. }
  1483. if (this.taskObj.type == 4) {
  1484. if (this.clientEnvironmentId == 3) {
  1485. this.List.forEach((it) => {
  1486. if (it.singleReport == 0) {
  1487. this.checkPack();
  1488. }
  1489. });
  1490. } else {
  1491. this.checkPack();
  1492. }
  1493. }
  1494. if (this.taskObj.type == 1) {
  1495. const isCache = await this.checkCache(type);
  1496. if (!isCache) {
  1497. return false;
  1498. }
  1499. }
  1500. if (
  1501. this.clientEnvironmentId == 3 &&
  1502. type == 2 &&
  1503. this.taskObj.type == 6
  1504. ) {
  1505. this.List.forEach((L) => {
  1506. if (L.singleReport == 0) {
  1507. L.semiProductList = [];
  1508. }
  1509. });
  1510. }
  1511. let isSemiProduct = false;
  1512. this.List.map((semi) => {
  1513. if (
  1514. semi.semiProductList.length == 0 &&
  1515. semi.singleReport == 1 &&
  1516. semi.currentTaskDiagram.isFirstTask == 1 &&
  1517. this.clientEnvironmentId != 3
  1518. ) {
  1519. isSemiProduct = true;
  1520. this.loading.close();
  1521. setTimeout(() => {
  1522. this.$message.warning({
  1523. message: '请工单编号:' + semi.code + '先创建在制品',
  1524. key: semi.code // 使用当前时间作为key,确保唯一性
  1525. });
  1526. }, 500);
  1527. }
  1528. if (semi.semiProductList.length == 0 && semi.singleReport == 0) {
  1529. semi.semiProductList.map((ditem) => {
  1530. if (ditem.extInfo.batchReportInfo) {
  1531. ditem.extInfo.batchReportInfo.map((baItem) => {
  1532. let idvalue = baItem.deviceId
  1533. ? baItem.deviceId.split('/')
  1534. : '';
  1535. baItem.deviceId = idvalue ? idvalue[0] : '';
  1536. });
  1537. }
  1538. if (ditem.extInfo.notBatchReportInfo) {
  1539. ditem.extInfo.notBatchReportInfo.map((noItem) => {
  1540. let idvalue = noItem.deviceId
  1541. ? noItem.deviceId.split('/')
  1542. : '';
  1543. noItem.deviceId = idvalue ? idvalue[0] : '';
  1544. });
  1545. }
  1546. });
  1547. }
  1548. });
  1549. if (isSemiProduct) {
  1550. this.loading.close();
  1551. return;
  1552. }
  1553. let newList = [];
  1554. for (let item of this.List) {
  1555. newList.push({
  1556. currentTaskDiagram: item.currentTaskDiagram,
  1557. workOrderId: item.workOrderId
  1558. });
  1559. }
  1560. await checkReportNumber(newList).then((res) => {
  1561. if (res.length != 0) {
  1562. this.checkJobBook(res);
  1563. }
  1564. });
  1565. },
  1566. checkJobBook(list) {
  1567. let wordCodeList = [];
  1568. let reportCodeList = [];
  1569. for (let item of list) {
  1570. if (item.reportFormed != '0') {
  1571. wordCodeList.push(item.workOrderCode);
  1572. }
  1573. }
  1574. if (!this.isReportTime) {
  1575. for (let item of list) {
  1576. for (let it of this.List) {
  1577. if (item.workOrderCode == it.code) {
  1578. if (item.feedDate) {
  1579. const t1 = new Date(item.feedDate);
  1580. const t2 = new Date(it.workReportInfo.executorTime);
  1581. if (t1 > t2) {
  1582. reportCodeList.push(item.workOrderCode);
  1583. }
  1584. }
  1585. if (item.reportDate) {
  1586. const t1 = new Date(item.reportDate);
  1587. const t2 = new Date(it.workReportInfo.executorTime);
  1588. if (t1 > t2) {
  1589. reportCodeList.push(item.workOrderCode);
  1590. }
  1591. }
  1592. }
  1593. }
  1594. }
  1595. }
  1596. if (reportCodeList.length != 0) {
  1597. this.$confirm(
  1598. `工单号${reportCodeList.join(
  1599. ','
  1600. )}报工时间大于上道工序的执行时间,是否继续报工?`,
  1601. '提示',
  1602. {
  1603. confirmButtonText: '确定',
  1604. cancelButtonText: '取消',
  1605. type: 'warning',
  1606. center: true
  1607. }
  1608. )
  1609. .then(() => {
  1610. return this.checkWorkCode(wordCodeList);
  1611. })
  1612. .catch(() => {
  1613. this.loading.close();
  1614. });
  1615. } else {
  1616. this.checkWorkCode(wordCodeList);
  1617. }
  1618. },
  1619. checkWorkCode(list) {
  1620. if (list.length != 0) {
  1621. this.$confirm(
  1622. `工单号:<br>${list.join('<br>')}<br>已有报工,是否继续重复报工?`,
  1623. '提示',
  1624. {
  1625. confirmButtonText: '确定',
  1626. cancelButtonText: '取消',
  1627. type: 'warning',
  1628. center: true,
  1629. dangerouslyUseHTMLString: true
  1630. }
  1631. )
  1632. .then(() => {
  1633. this.jobBookReport();
  1634. })
  1635. .catch(() => {
  1636. this.loading.close();
  1637. });
  1638. } else {
  1639. this.jobBookReport();
  1640. }
  1641. },
  1642. jobBookReport() {
  1643. this.loadingBtn = true;
  1644. jobSave(this.List)
  1645. .then((res) => {
  1646. this.loadingBtn = false;
  1647. this.loading.close();
  1648. this.$message.success('报工成功');
  1649. this.checked = false;
  1650. this.executorIdList = [];
  1651. this.teamId = '';
  1652. this.teamName = '';
  1653. this.getList(this.idsList);
  1654. this.$emit('jobSuccess', 'Success');
  1655. })
  1656. .catch(() => {
  1657. this.loadingBtn = false;
  1658. this.loading.close();
  1659. });
  1660. },
  1661. checkRecycle() {
  1662. return new Promise((resolve) => {
  1663. this.$confirm('是否跳过副产品回收处置!', '提示', {
  1664. confirmButtonText: '确定',
  1665. cancelButtonText: '取消',
  1666. type: 'warning'
  1667. })
  1668. .then(() => {
  1669. resolve(true);
  1670. })
  1671. .catch(() => {
  1672. resolve(false);
  1673. });
  1674. });
  1675. },
  1676. checkCache(type) {
  1677. return new Promise((resolve) => {
  1678. if (type == 1) {
  1679. saveCache(this.List).then((rr) => {
  1680. this.$message.success('缓存成功');
  1681. this.loading.close();
  1682. });
  1683. resolve(false);
  1684. } else if (type == 2) {
  1685. resolve(true);
  1686. }
  1687. });
  1688. },
  1689. getCacheFn() {
  1690. let parma = {
  1691. workOrderIds: this.idsList,
  1692. taskId: this.taskObj.id,
  1693. type: 1
  1694. };
  1695. getCache(parma).then((res) => {
  1696. this.List.forEach((f, index) => {
  1697. res.forEach((o) => {
  1698. if (f.workOrderId == o.workOrderId) {
  1699. f['product'] = o.extInfo.product;
  1700. f['workReportInfo'] = o.extInfo.workReportInfo;
  1701. f['notFormedList'] = o.extInfo.notFormedList;
  1702. f['turnover'] = o.extInfo.turnover;
  1703. f['productRecycleList'] = o.extInfo.productRecycleList;
  1704. f['semiProductList'] = o.extInfo.semiProductList;
  1705. f['modelList'] = o.extInfo.modelList;
  1706. this.$forceUpdate();
  1707. }
  1708. });
  1709. });
  1710. });
  1711. },
  1712. removeCacheFn(type) {
  1713. this.$confirm('是否清空缓存', '缓存')
  1714. .then(() => {
  1715. let parma = {
  1716. workOrderIds: type == 'all' ? this.idsList : [type],
  1717. taskId: this.taskObj.id,
  1718. type: 1
  1719. };
  1720. removeCache(parma).then((res) => {
  1721. this.$message.success('已经清空缓存');
  1722. this.getList(this.idsList);
  1723. });
  1724. })
  1725. .catch(() => {});
  1726. },
  1727. getWarehouseListFn() {
  1728. getWarehouseList().then((res) => {
  1729. this.warehouseList = res.data;
  1730. });
  1731. },
  1732. //批量报工合格不合格重量统计
  1733. countNumPl(list, index) {
  1734. console.log('11111122222333', list);
  1735. //合格总数
  1736. let formedNumCount = 0;
  1737. //合格总重量
  1738. let formedWeightCount = 0;
  1739. //不合格总数
  1740. let notFormedNumCount = 0;
  1741. //不合格总重量
  1742. let notFormedWeightCount = 0;
  1743. list.map((item) => {
  1744. //合格总数
  1745. item.extInfo.batchReportInfo.forEach((m) => {
  1746. formedNumCount = formedNumCount + Number(m.allFeedQuantity || 0);
  1747. });
  1748. //合格总重量
  1749. item.extInfo.batchReportInfo.forEach((w) => {
  1750. formedWeightCount =
  1751. formedWeightCount + Number(w.allReportWeight || 0);
  1752. });
  1753. //不合格总数
  1754. item.extInfo.notBatchReportInfo.forEach((nf) => {
  1755. notFormedNumCount =
  1756. notFormedNumCount + Number(nf.allFeedQuantity || 0);
  1757. });
  1758. //不合格总重量
  1759. item.extInfo.notBatchReportInfo.forEach((nw) => {
  1760. notFormedWeightCount =
  1761. notFormedWeightCount + Number(nw.allReportWeight || 0);
  1762. });
  1763. });
  1764. this.$set(this.List[index].workReportInfo, 'formedNum', formedNumCount); //合格总数
  1765. this.$set(
  1766. this.List[index].workReportInfo,
  1767. 'formedWeight',
  1768. formedWeightCount
  1769. ); //合格总重量
  1770. this.$set(
  1771. this.List[index].workReportInfo,
  1772. 'notFormedNum',
  1773. notFormedNumCount
  1774. ); //不合格总数
  1775. this.$set(
  1776. this.List[index].workReportInfo,
  1777. 'notFormedWeight',
  1778. notFormedWeightCount
  1779. ); //不合格总重量
  1780. }
  1781. }
  1782. };
  1783. </script>
  1784. <style scoped lang="scss">
  1785. .top_fixed {
  1786. width: 100%;
  1787. height: 40px;
  1788. background: #fff;
  1789. display: flex;
  1790. align-items: center;
  1791. justify-content: flex-end;
  1792. }
  1793. .title_box {
  1794. padding: 10px 0;
  1795. .name {
  1796. font-size: 14px;
  1797. font-style: normal;
  1798. font-weight: 400;
  1799. color: #157a2c;
  1800. padding-left: 5px;
  1801. position: relative;
  1802. &:before {
  1803. position: absolute;
  1804. content: '';
  1805. left: 0px;
  1806. top: 0px;
  1807. bottom: 0px;
  1808. width: 2px;
  1809. height: 14px;
  1810. background: #157a2c;
  1811. margin: auto;
  1812. }
  1813. }
  1814. }
  1815. .job_box {
  1816. // margin-top: 6px;
  1817. width: 100%;
  1818. height: calc(100vh - 70px - 50px - 80px - 60px);
  1819. overflow-y: scroll;
  1820. overflow-x: hidden;
  1821. }
  1822. .card_box {
  1823. background: #fff;
  1824. padding: 8px;
  1825. border-radius: 2px;
  1826. }
  1827. .checkboxWrapper {
  1828. padding: 8px 20px;
  1829. border-bottom: 1px solid #ccc;
  1830. }
  1831. ::v-deep .el-select__tags {
  1832. flex-wrap: nowrap;
  1833. overflow: auto;
  1834. }
  1835. /* 输入框最大宽度*/
  1836. ::v-deep .el-select__tags-text {
  1837. max-width: 90px;
  1838. }
  1839. /* 底部滚动条的高度*/
  1840. ::v-deep .el-select__tags::-webkit-scrollbar {
  1841. height: 2px !important;
  1842. }
  1843. </style>