index.vue 65 KB

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