index.vue 32 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160
  1. <template>
  2. <div>
  3. <div v-if="isShow">
  4. <div class="top_fixed">
  5. <div
  6. style="display: flex; align-items: center; margin-right: 10px"
  7. v-if="List.length > 1"
  8. >
  9. <div class="rx-bc">
  10. <div class="name">批量投料时间:</div>
  11. </div>
  12. <el-date-picker
  13. v-model="executorTime"
  14. type="datetime"
  15. format="yyyy-MM-dd HH:mm:ss"
  16. value-format="yyyy-MM-dd HH:mm:ss"
  17. placeholder="选择日期"
  18. @change="handleCreate"
  19. :picker-options="pickerOptions"
  20. >
  21. </el-date-picker>
  22. </div>
  23. <el-button
  24. type="primary"
  25. size="mini"
  26. :loading="loadingBtn"
  27. @click="save(2, 'all')"
  28. >一键投料(报工)</el-button
  29. >
  30. <el-button type="primary" size="mini" @click="removeCacheFn('all')"
  31. >清空缓存</el-button
  32. >
  33. <el-button type="primary" size="mini" @click="save(1, 'all')"
  34. >缓存</el-button
  35. >
  36. </div>
  37. <div class="feed_box" v-if="isLoad">
  38. <div v-for="(item, index) in List" :key="index" class="card_box">
  39. <div class="title_box rx-bc">
  40. <div class="name" v-if="!taskObj.isOrderListData">工单信息 </div>
  41. <div class="name" v-else> </div>
  42. <div class="rx-bc">
  43. <el-button
  44. type="text"
  45. size="mini"
  46. @click="outboundOrder(item.workOrderId, item)"
  47. >出库单</el-button
  48. >
  49. <el-button
  50. type="text"
  51. size="mini"
  52. @click="openPicking(item.workOrderId, item)"
  53. >手动添加</el-button
  54. >
  55. <el-button
  56. type="text"
  57. size="mini"
  58. @click="removeCacheFn(item.workOrderId)"
  59. >清空缓存</el-button
  60. >
  61. <el-button type="text" size="mini" @click="save(1, index)"
  62. >缓存</el-button
  63. >
  64. </div>
  65. </div>
  66. <workOrderBom
  67. :item="item"
  68. :isReportWork="false"
  69. v-if="!taskObj.isOrderListData"
  70. ></workOrderBom>
  71. <div>
  72. <div class="title_box rx-bc">
  73. <div class="name">投料时间 </div>
  74. </div>
  75. 投料时间:
  76. <el-date-picker
  77. v-model="item.executorTime"
  78. type="datetime"
  79. format="yyyy-MM-dd HH:mm:ss"
  80. value-format="yyyy-MM-dd HH:mm:ss"
  81. placeholder="选择日期"
  82. style="margin-right: 25px; width: 190px"
  83. :picker-options="pickerOptions"
  84. >
  85. </el-date-picker>
  86. 执行人:
  87. <el-select
  88. v-model="teamId"
  89. placeholder="请选择班组"
  90. filterable
  91. style="width: 120px"
  92. @change="checkTeamList(teamId)"
  93. >
  94. <el-option
  95. v-for="item in teamList"
  96. :label="item.name"
  97. :value="item.id"
  98. :key="item.id"
  99. >
  100. </el-option>
  101. </el-select>
  102. <el-select
  103. v-model="executorIdList"
  104. placeholder="请选择执行人"
  105. filterable
  106. multiple
  107. @change="changeId"
  108. >
  109. <div class="checkboxWrapper">
  110. <el-checkbox v-model="checked" @change="checkChange">
  111. 全选
  112. </el-checkbox>
  113. </div>
  114. <el-option
  115. v-for="item in teamUserList"
  116. :label="item.name"
  117. :value="item.id"
  118. :key="item.id"
  119. >
  120. </el-option>
  121. </el-select>
  122. <!-- -->
  123. </div>
  124. <paramBom
  125. v-if="item.paramDetailList.length != 0"
  126. :list="item.paramDetailList"
  127. ></paramBom>
  128. <!-- 设备信息 -->
  129. <deviceBom
  130. v-if="item.equipmentList.length != 0"
  131. :list="item.equipmentList"
  132. ></deviceBom>
  133. <!-- <productsBom
  134. v-if="
  135. item.product != null &&
  136. item.product != '{}' &&
  137. item.singleReport != 0
  138. "
  139. :itemObj="item"
  140. :productsObj="item.product"
  141. >
  142. </productsBom> -->
  143. <productsBom
  144. v-if="item.product.length != 0 && item.singleReport == 1"
  145. :itemObj="item"
  146. :productsObj="item.product"
  147. >
  148. </productsBom>
  149. <!-- <batchProductsBom
  150. v-if="
  151. item.product != null &&
  152. item.product != '{}' &&
  153. item.singleReport == 0
  154. "
  155. :itemObj="item"
  156. :productsObj="item.product"
  157. >
  158. </batchProductsBom> -->
  159. <batchProductsBom
  160. v-if="item.product.length != 0 && item.singleReport == 0"
  161. :itemObj="item"
  162. :productsObj="item.product"
  163. :isEdit="isEdit"
  164. >
  165. </batchProductsBom>
  166. <modelBom v-if="item.modelList.length != 0" :list="item.modelList">
  167. </modelBom>
  168. <!-- 物料清单 -->
  169. <instanceBom
  170. v-if="item.instanceList.length != 0"
  171. :list="item.instanceList"
  172. :equipmentList="item.equipmentList"
  173. :currentTaskDiagram="item.currentTaskDiagram"
  174. :workInfo="item"
  175. title="物料清单"
  176. >
  177. </instanceBom>
  178. <!-- 备料清单 -->
  179. <instanceBom
  180. v-if="item.sparePartsList.length != 0"
  181. :list="item.sparePartsList"
  182. :equipmentList="item.equipmentList"
  183. :currentTaskDiagram="item.currentTaskDiagram"
  184. :workInfo="item"
  185. title="备料清单"
  186. >
  187. </instanceBom>
  188. <semiProductJobBom
  189. v-if="item.semiProductList.length != 0"
  190. :list="item.semiProductList"
  191. :equipmentList="item.equipmentList"
  192. :currentTaskDiagram="item.currentTaskDiagram"
  193. :item="item"
  194. :isChoose="isChoose"
  195. :isEngrave="isEngrave"
  196. :isDisposal="isDisposal"
  197. title="物料清单"
  198. >
  199. </semiProductJobBom>
  200. <!-- 周转车 -->
  201. <turnoverBom
  202. v-if="item.turnover.length != 0"
  203. :wordItem="item"
  204. :list="item.turnover"
  205. pattern="feed"
  206. >
  207. </turnoverBom>
  208. <aridRegion
  209. v-if="item.aridRegionList.length != 0"
  210. :list="item.aridRegionList"
  211. ></aridRegion>
  212. <palletBom
  213. v-if="item.palletList.length != 0"
  214. :list="item.palletList"
  215. ></palletBom>
  216. <!-- // 包装物料清单 -->
  217. <packingBom
  218. v-if="item.packingList.length != 0"
  219. :list="item.packingList"
  220. ></packingBom>
  221. <revolvingDiskBom
  222. v-if="item.revolvingDiskList.length != 0"
  223. :list="item.revolvingDiskList"
  224. ></revolvingDiskBom>
  225. </div>
  226. </div>
  227. <pickingList
  228. isType="feed"
  229. ref="pickingListRef"
  230. @allSelection="allSelection"
  231. ></pickingList>
  232. </div>
  233. <div v-else>
  234. <el-empty description="批量报工,不需要投料,直接去报工取样"></el-empty>
  235. </div>
  236. <outboundOrderDialog
  237. ref="outboundOrderDialogRef"
  238. @chooseData="chooseData"
  239. />
  240. </div>
  241. </template>
  242. <script>
  243. import { workorderList } from '@/api/produce/workOrder';
  244. import {
  245. batchSave,
  246. feedSaveCache,
  247. feedGetCache,
  248. removeCache
  249. } from '@/api/produce/feeding';
  250. import { checkRepeatFeed } from '@/api/produce/index';
  251. import pickingList from '../picking/pickingList.vue';
  252. import packingBom from './components/packingBom.vue';
  253. import workOrderBom from './components/workOrderBom.vue';
  254. import paramBom from './components/paramBom.vue';
  255. import deviceBom from './components/deviceBom.vue';
  256. import productsBom from './components/productsBom.vue';
  257. import batchProductsBom from './components/batchProductsBom.vue';
  258. import modelBom from './components/modelBom.vue';
  259. import instanceBom from './components/instanceBom.vue';
  260. // import semiProductBom from './components/semiProductBom.vue';
  261. import semiProductJobBom from '@/views/produce/components/jobBooking/components/semiProductJobBom.vue';
  262. import turnoverBom from './components/turnoverBom.vue';
  263. import aridRegion from './components/aridRegion.vue';
  264. import palletBom from './components/palletBom.vue';
  265. import revolvingDiskBom from './components/revolvingDiskBom.vue';
  266. import outboundOrderDialog from './components/outboundOrderDialog.vue';
  267. import { deepClone } from '@/utils';
  268. import { timestampToDateTime } from '@/utils/index.js';
  269. import { parameterGetByCode } from '@/api/system/dictionary-data';
  270. import { getTeam } from '@/api/produce/job.js';
  271. export default {
  272. name: 'feeding',
  273. components: {
  274. pickingList,
  275. packingBom,
  276. workOrderBom,
  277. paramBom,
  278. deviceBom,
  279. productsBom,
  280. modelBom,
  281. instanceBom,
  282. semiProductJobBom,
  283. turnoverBom,
  284. aridRegion,
  285. palletBom,
  286. revolvingDiskBom,
  287. batchProductsBom,
  288. outboundOrderDialog
  289. },
  290. props: {
  291. workListIds: {
  292. type: Array,
  293. default() {
  294. return [];
  295. }
  296. },
  297. feedNeedEquipment: {}
  298. },
  299. computed: {
  300. taskObj() {
  301. return this.$store.state.user.taskObj;
  302. },
  303. clientEnvironmentId() {
  304. return this.$store.state.user.info.clientEnvironmentId;
  305. }
  306. },
  307. watch: {
  308. workListIds: {
  309. handler(val) {
  310. this.getList(val);
  311. console.log('1111122222', val);
  312. },
  313. deep: true,
  314. immediate: true
  315. }
  316. },
  317. data() {
  318. return {
  319. List: [],
  320. idsList: [],
  321. executorTime: '',
  322. isLoad: false,
  323. isShow: true,
  324. loading: null,
  325. loadingBtn: false,
  326. isEdit: false,
  327. isChoose: false,
  328. isEngrave: false,
  329. isDisposal: false,
  330. teamList: [],
  331. teamAllList: [],
  332. teamUserList: [],
  333. executorIdList: [],
  334. teamId: '',
  335. isDefaultExecutor: false,
  336. checked: false,
  337. pickerOptions: {
  338. disabledDate(time) {
  339. // 禁止选择大于当前时间的日期
  340. return time.getTime() > Date.now();
  341. }
  342. // selectableRange: (() => {
  343. // const now = new Date();
  344. // const start = '00:00:00';
  345. // const end = now.toTimeString().split(' ')[0];
  346. // return `${start} - ${end}`;
  347. // })()
  348. }
  349. // feedExistNum: '',
  350. // feedNeedAridRegion: '',
  351. // feedNeedAuxiliaryEquipment: '',
  352. // feedNeedBoat: '',
  353. // feedNeedConsumableMaterial: '',
  354. // feedNeedEquipment: '',
  355. // feedNeedJunkProduct: '',
  356. // feedNeedMateriel: '',
  357. // feedNeedMeasuringEquipment: '',
  358. // feedNeedMould: '',
  359. // feedNeedProduct: '',
  360. // feedNeedQuality: '',
  361. // feedNeedReworkProduct: '',
  362. // feedNeedSemiProduct: '',
  363. // feedNeedTurnover: '',
  364. // feedStatus: ''
  365. };
  366. },
  367. mounted() {
  368. this.getChooseEngrave();
  369. if (localStorage.getItem('singleUserInfo') == '1') {
  370. const data = JSON.parse(localStorage.getItem('chooseUserInfo'));
  371. this.getTeamList(data.teamId);
  372. } else {
  373. this.getTeamList(this.$store.state.user.info.teamId);
  374. }
  375. // this.getTeamList(this.$store.state.user.info.teamId);
  376. },
  377. methods: {
  378. handleCreate(e) {
  379. if (e) {
  380. const list = JSON.parse(JSON.stringify(this.List));
  381. console.log(list);
  382. list.map((item) => {
  383. item.executorTime = e;
  384. });
  385. this.$set(this, 'List', list);
  386. }
  387. },
  388. getList(ids) {
  389. this.idsList = ids || [];
  390. let param = {
  391. ids: ids,
  392. taskId: this.taskObj.id
  393. };
  394. this.isLoad = false;
  395. workorderList(param)
  396. .then((res) => {
  397. let arr = [];
  398. arr = res.map((m) => {
  399. m.workOrderId = m.id;
  400. m.paramDetailList = m.paramDetailList;
  401. m.instanceList = []; // 物料
  402. // m.equipmentList = []; // 设备
  403. m.modelList = []; // 模具
  404. m.aridRegionList = []; // 干燥区
  405. m.packingList = []; // 包装
  406. m.palletList = []; // 舟皿
  407. m.revolvingDiskList = []; // 周转盘
  408. m.semiProductList = []; //半成品
  409. m.sparePartsList = []; //备品清单
  410. if (m.pickOutInList.length > 0) {
  411. m.pickOutInList.forEach((f) => {
  412. if (f.rootCategoryLevelId == 1) {
  413. m.instanceList.push(f);
  414. } else if (f.rootCategoryLevelId == 4) {
  415. m.modelList.push(f);
  416. } else if (f.rootCategoryLevelId == 5) {
  417. m.modelList.push(f);
  418. } else if (f.rootCategoryLevelId == 6) {
  419. m.sparePartsList.push(f);
  420. } else if (f.rootCategoryLevelId == 11) {
  421. m.aridRegionList.push(f);
  422. } else if (f.rootCategoryLevelId == 13) {
  423. m.packingList.push(f);
  424. } else if (f.rootCategoryLevelId == 8) {
  425. m.palletList.push(f);
  426. } else if (f.rootCategoryLevelId == 26) {
  427. m.revolvingDiskList.push(f);
  428. } else if (
  429. [23, 2, 9, 28].includes(Number(f.rootCategoryLevelId))
  430. ) {
  431. m.semiProductList.push(f);
  432. }
  433. });
  434. }
  435. if (m.semiProductList.length != 0) {
  436. m.semiProductList.forEach((item) => {
  437. if (!item.confirm) {
  438. item.confirm = '';
  439. }
  440. });
  441. }
  442. // 处理字段
  443. if (m.quality == '') {
  444. m.product = '{}';
  445. }
  446. if (!Object.prototype.hasOwnProperty.call(m, 'product')) {
  447. m.product = '{}';
  448. }
  449. if (m.singleReport == 1) {
  450. m.semiProductList.map((item) => {
  451. item.extInfo.taskId = '';
  452. item.extInfo.taskName = '';
  453. });
  454. }
  455. if (m.singleReport == 0) {
  456. m.product.map((item) => {
  457. item.extInfo.taskId = '';
  458. item.extInfo.taskName = '';
  459. });
  460. }
  461. if (
  462. this.clientEnvironmentId == 3 &&
  463. this.taskObj.type == 6 &&
  464. m.singleReport == 0
  465. ) {
  466. this.isShow = false;
  467. } else {
  468. this.isShow = true;
  469. }
  470. delete m.id;
  471. if (this.taskObj.id) {
  472. m.taskId = this.taskObj.id;
  473. m.taskName = this.taskObj.name;
  474. }
  475. return {
  476. ...m
  477. };
  478. });
  479. console.log(arr, 'arr');
  480. arr.forEach((it) => {
  481. if (it.semiProductList.length != 0) {
  482. it.semiProductList.forEach((item) => {
  483. if (item.extInfo && item.extInfo.taskId == -1) {
  484. item.extInfo.taskId = item.extInfo.taskId + '';
  485. }
  486. });
  487. }
  488. // if (it.pickOutInList.length != 0) {
  489. // it.pickOutInList.forEach((item) => {
  490. // if (item.extInfo && item.extInfo.taskId == -1) {
  491. // item.extInfo.taskId = item.extInfo.taskId + '';
  492. // }
  493. // });
  494. // }
  495. });
  496. this.List = deepClone(arr);
  497. })
  498. .finally(() => {
  499. this.isLoad = true;
  500. this.getCacheFn();
  501. });
  502. this.$forceUpdate();
  503. },
  504. async getChooseEngrave() {
  505. await parameterGetByCode({
  506. code: 'choose_engrave'
  507. }).then((res) => {
  508. this.isChoose = res.value == '1' ? true : false;
  509. });
  510. await parameterGetByCode({
  511. code: 'batch_update_engrave'
  512. }).then((res) => {
  513. this.isEngrave = res.value == '1' ? true : false;
  514. });
  515. await parameterGetByCode({
  516. code: 'batch_disposal'
  517. }).then((res) => {
  518. this.isDisposal = res.value == '1' ? true : false;
  519. });
  520. await parameterGetByCode({
  521. code: 'default_executor'
  522. }).then((res) => {
  523. this.isDefaultExecutor = res.value == '1' ? true : false;
  524. if (this.isDefaultExecutor) {
  525. this.setDefaultIdList();
  526. }
  527. });
  528. },
  529. setDefaultIdList() {
  530. if (this.teamList.length != 0) {
  531. this.teamId = this.teamList[0].id;
  532. const index = this.teamList.findIndex(
  533. (item) => item.id == this.teamId
  534. );
  535. console.log(this.teamAllList);
  536. this.teamUserList = this.teamAllList[index];
  537. if (this.teamUserList) {
  538. const res = this.teamUserList.find(
  539. (it) => it.id == this.$store.state.user.info.userId
  540. );
  541. this.executorIdList.push(res.id);
  542. }
  543. }
  544. },
  545. changeId() {
  546. if (this.executorIdList.length == this.teamUserList.length) {
  547. this.checked = true;
  548. } else {
  549. this.checked = false;
  550. }
  551. },
  552. checkTeamList(id) {
  553. this.executorIdList = [];
  554. const index = this.teamList.findIndex((item) => item.id == id);
  555. this.teamUserList = this.teamAllList[index];
  556. },
  557. async getTeamList(id) {
  558. if (!id) return;
  559. const ids = id.split(',');
  560. this.teamList = [];
  561. this.teamUserList = [];
  562. const list = ids.map((item) => getTeam(item));
  563. const dataList = await Promise.all(list);
  564. dataList.forEach((item) => {
  565. this.teamList.push({
  566. name: item.name,
  567. id: item.id
  568. });
  569. this.teamAllList.push(item.userVOList);
  570. });
  571. },
  572. outboundOrder(id, item) {
  573. this.$refs.outboundOrderDialogRef.open(id, item);
  574. },
  575. openPicking(id, item) {
  576. this.$refs.pickingListRef.open(
  577. id,
  578. item,
  579. '选择设备列表',
  580. this.taskObj.id
  581. );
  582. },
  583. chooseData(listData) {
  584. this.$set(this.List[0], 'semiProductList', listData);
  585. this.$forceUpdate();
  586. console.log(this.List[0], 'this.List');
  587. },
  588. allSelection(id, selectList) {
  589. this.List.forEach((m) => {
  590. if (m.workOrderId == id) {
  591. let modelList = []; // 模具
  592. let instanceList = []; // 投料
  593. let aridRegionList = []; // 干燥区
  594. let equipmentList = []; // 生产设备
  595. let palletList = []; // 舟皿
  596. let revolvingDiskList = []; // 周转盘
  597. let semiProductList = []; // 半成品
  598. let turnover = []; //周转车
  599. let sparePartsList = []; //备品清单
  600. selectList.forEach((f) => {
  601. if (f.rootCategoryLevelId == 4) {
  602. equipmentList = equipmentList.concat(f);
  603. }
  604. if (f.rootCategoryLevelId == 5) {
  605. modelList = modelList.concat(f);
  606. } else if (f.rootCategoryLevelId == 1) {
  607. instanceList = instanceList.concat(f);
  608. } else if (f.rootCategoryLevelId == 11) {
  609. aridRegionList = aridRegionList.concat(f);
  610. } else if (f.rootCategoryLevelId == 6) {
  611. sparePartsList = sparePartsList.concat(f);
  612. } else if (f.rootCategoryLevelId == 7) {
  613. turnover = turnover.concat(f);
  614. } else if (f.rootCategoryLevelId == 8) {
  615. palletList = palletList.concat(f);
  616. } else if (f.rootCategoryLevelId == 26) {
  617. revolvingDiskList = revolvingDiskList.concat(f);
  618. } else if (
  619. [23, 2, 9, 28].includes(Number(f.rootCategoryLevelId))
  620. ) {
  621. semiProductList = semiProductList.concat(f);
  622. }
  623. });
  624. this.$set(m, 'modelList', modelList);
  625. this.$set(m, 'sparePartsList', sparePartsList);
  626. this.$set(m, 'instanceList', instanceList);
  627. this.$set(m, 'aridRegionList', aridRegionList);
  628. this.$set(m, 'equipmentList', equipmentList);
  629. this.$set(m, 'turnover', turnover);
  630. this.$set(m, 'palletList', palletList);
  631. this.$set(m, 'revolvingDiskList', revolvingDiskList);
  632. this.$set(m, 'semiProductList', semiProductList);
  633. this.$forceUpdate();
  634. }
  635. });
  636. },
  637. checkChange() {
  638. if (this.checked) {
  639. this.executorIdList = [];
  640. this.executorIdList = this.teamUserList.map((item) => item.id);
  641. } else {
  642. this.executorIdList = [];
  643. }
  644. },
  645. getCacheFn() {
  646. let parma = {
  647. workOrderIds: this.idsList,
  648. taskId: this.taskObj.id,
  649. type: 2
  650. };
  651. feedGetCache(parma).then((res) => {
  652. if (res.length == 0) {
  653. return false;
  654. }
  655. let objList = res[0].extInfo.objList;
  656. this.List.forEach((f, index) => {
  657. objList.forEach((o) => {
  658. if (
  659. f.workOrderId == o.workOrderId &&
  660. f.currentTaskDiagram.taskId == o.taskId
  661. ) {
  662. f['instanceList'] = o.instanceList || [];
  663. f['equipmentList'] = o.equipmentList || [];
  664. f['modelList'] = o.modelList || [];
  665. f['sparePartsList'] = o.sparePartsList || [];
  666. f['aridRegionList'] = o.aridRegionList || [];
  667. f['packingList'] = o.packingList || [];
  668. f['palletList'] = o.palletList || [];
  669. f['revolvingDiskList'] = o.revolvingDiskList || [];
  670. f['semiProductList'] = o.semiProductList || [];
  671. this.$set(this.List[index], 'executorTime', o.executorTime);
  672. this.$forceUpdate();
  673. }
  674. });
  675. });
  676. });
  677. },
  678. async save(type, index) {
  679. let arr = this.List.filter((L) => L.executorTime);
  680. if (!arr.length) {
  681. return this.$message.warning('请选择投料时间');
  682. }
  683. if (this.executorIdList.length == 0) {
  684. return this.$message.warning('执行人不能为空!');
  685. }
  686. const executorList = [];
  687. this.executorIdList.forEach((item) => {
  688. const data = this.teamUserList.find((it) => it.id == item);
  689. if (data) {
  690. executorList.push({
  691. userId: data.id,
  692. jobNumber: data.jobNumber,
  693. name: data.name
  694. });
  695. }
  696. });
  697. this.List = this.List.map((item) => {
  698. item.executorList = executorList;
  699. return item;
  700. });
  701. // this.List = this.List.map((item) => {
  702. // item.executorList = executorList;
  703. // return item;
  704. // });
  705. let deviceIs = false;
  706. this.List.forEach((f) => {
  707. f.instanceList.forEach((e) => {
  708. if (Object.prototype.hasOwnProperty.call(e, 'type')) {
  709. e.extInfo['type'] = e.type;
  710. }
  711. e.extInfo['isConsumable'] = e.isConsumable;
  712. });
  713. if (this.feedNeedEquipment == 1 && f.equipmentList.length == 0) {
  714. deviceIs = true;
  715. setTimeout(() => {
  716. this.$message.warning({
  717. message: '请工单编号:' + f.code + '添加设备',
  718. key: f.code
  719. });
  720. }, 500);
  721. }
  722. });
  723. //判断投料是否要添加设备
  724. if (deviceIs) {
  725. return;
  726. }
  727. for (let item of this.List) {
  728. if (
  729. item.currentTaskDiagram.feedNeedTurnover == 1 &&
  730. item.turnover.length == 0
  731. ) {
  732. setTimeout(() => {
  733. this.$message.warning({
  734. message: '请工单编号:' + item.code + '添加周转车',
  735. key: item.code
  736. });
  737. }, 500);
  738. return;
  739. }
  740. }
  741. for (let item of this.List) {
  742. if (
  743. item.currentTaskDiagram.feedNeedBoat == 1 &&
  744. item.palletList.length == 0
  745. ) {
  746. setTimeout(() => {
  747. this.$message.warning({
  748. message: '请工单编号:' + item.code + '添加舟皿',
  749. key: item.code
  750. });
  751. }, 500);
  752. return;
  753. }
  754. }
  755. const isCache = await this.checkCache(type);
  756. if (!isCache) {
  757. return false;
  758. }
  759. this.loading = this.$loading({
  760. lock: true,
  761. text: '加载中',
  762. background: 'rgba(0, 0, 0, 0.7)'
  763. });
  764. let newList = [];
  765. for (let item of this.List) {
  766. newList.push({
  767. currentTaskDiagram: item.currentTaskDiagram,
  768. workOrderId: item.workOrderId
  769. });
  770. }
  771. await checkRepeatFeed(newList).then((res) => {
  772. if (res.data.length != 0) {
  773. this.checkFeed(res.data);
  774. }
  775. });
  776. },
  777. checkFeed(list) {
  778. let wordCodeList = [];
  779. for (let item of list) {
  780. if (item.feedFormed != '0') {
  781. wordCodeList.push(item.workOrderCode);
  782. }
  783. }
  784. if (wordCodeList.length != 0) {
  785. this.$confirm(
  786. `工单号${wordCodeList.join(',')}已有投料,是否继续重复投料?`,
  787. '提示',
  788. {
  789. confirmButtonText: '确定',
  790. cancelButtonText: '取消',
  791. type: 'warning',
  792. center: true
  793. }
  794. )
  795. .then(() => {
  796. this.feedReport();
  797. })
  798. .catch(() => {
  799. this.loading.close();
  800. });
  801. } else {
  802. this.feedReport();
  803. }
  804. },
  805. feedReport() {
  806. batchSave(this.List)
  807. .then((res) => {
  808. this.loading.close();
  809. this.$message.success('投料成功');
  810. this.getList(this.idsList);
  811. this.executorIdList = [];
  812. this.checked = false;
  813. this.teamId = '';
  814. // 延迟刷新
  815. setTimeout(() => {
  816. this.$emit('reload');
  817. }, 500);
  818. this.$emit('feedSuccess', 'success');
  819. })
  820. .catch((e) => {
  821. this.loading.close();
  822. });
  823. },
  824. toInteger(num) {
  825. const len = this.getDecimalLength(num);
  826. return {
  827. int: Math.round(num * Math.pow(10, len)),
  828. factor: Math.pow(10, len)
  829. };
  830. },
  831. add(a, b) {
  832. const { int: aInt, factor: aFactor } = this.toInteger(a);
  833. const { int: bInt, factor: bFactor } = this.toInteger(b);
  834. const maxFactor = Math.max(aFactor, bFactor);
  835. return (
  836. (aInt * (maxFactor / aFactor) + bInt * (maxFactor / bFactor)) /
  837. maxFactor
  838. );
  839. },
  840. getDecimalLength(num) {
  841. return (num.toString().split('.')[1] || '').length;
  842. },
  843. checkCache(type, index) {
  844. return new Promise((resolve) => {
  845. if (type == 1) {
  846. feedSaveCache(this.List).then((rr) => {
  847. this.$message.success('已经缓存');
  848. });
  849. resolve(false);
  850. } else if (type == 2) {
  851. resolve(true);
  852. }
  853. });
  854. },
  855. removeCacheFn(type) {
  856. this.$confirm('是否清空缓存', '缓存')
  857. .then(() => {
  858. let parma = {
  859. workOrderIds: type == 'all' ? this.idsList : [type],
  860. taskId: this.taskObj.id,
  861. type: 2
  862. };
  863. removeCache(parma).then((res) => {
  864. this.getList(this.idsList);
  865. });
  866. })
  867. .catch(() => {});
  868. }
  869. }
  870. };
  871. </script>
  872. <style scoped lang="scss">
  873. .top_fixed {
  874. width: 100%;
  875. height: 40px;
  876. background: #fff;
  877. display: flex;
  878. align-items: center;
  879. justify-content: flex-end;
  880. }
  881. .feed_box {
  882. // margin-top: 6px;
  883. width: 100%;
  884. height: calc(100vh - 70px - 50px - 80px - 60px);
  885. overflow-y: scroll;
  886. overflow-x: hidden;
  887. }
  888. .card_box {
  889. background: #fff;
  890. padding: 8px;
  891. border-radius: 2px;
  892. }
  893. .checkboxWrapper {
  894. padding: 8px 20px;
  895. border-bottom: 1px solid #ccc;
  896. }
  897. ::v-deep .el-select__tags {
  898. flex-wrap: nowrap;
  899. overflow: auto;
  900. }
  901. ::v-deep .el-select__tags-text {
  902. max-width: 90px;
  903. }
  904. ::v-deep .el-select__tags::-webkit-scrollbar {
  905. height: 2px !important;
  906. }
  907. </style>
  908. <style lang="scss">
  909. .mt6 {
  910. margin-top: 6px;
  911. }
  912. .title_box {
  913. padding: 5px 0;
  914. .name {
  915. font-size: 14px;
  916. font-style: normal;
  917. font-weight: 400;
  918. color: #157a2c;
  919. padding-left: 5px;
  920. position: relative;
  921. &:before {
  922. position: absolute;
  923. content: '';
  924. left: 0px;
  925. top: 0px;
  926. bottom: 0px;
  927. width: 2px;
  928. height: 14px;
  929. background: #157a2c;
  930. margin: auto;
  931. }
  932. }
  933. }
  934. .material {
  935. margin-top: 6px;
  936. .content_table {
  937. width: 100%;
  938. border: 1px solid #e3e5e5;
  939. position: relative;
  940. .item {
  941. display: flex;
  942. border-bottom: 1px solid #e3e5e5;
  943. .lable {
  944. width: 72px;
  945. text-align: center;
  946. background-color: #f7f9fa;
  947. font-size: 12px;
  948. border-right: 1px solid #e3e5e5;
  949. flex-shrink: 0;
  950. }
  951. .lable80 {
  952. width: 80px !important;
  953. font-size: 12px;
  954. }
  955. .lable90 {
  956. width: 90px !important;
  957. }
  958. .lable100 {
  959. width: 100px !important;
  960. }
  961. .ww60 {
  962. width: 60px;
  963. }
  964. .content {
  965. width: 250px;
  966. min-height: 32px;
  967. font-size: 14px;
  968. line-height: 14px;
  969. font-style: normal;
  970. font-weight: 400;
  971. padding: 9px 4px;
  972. box-sizing: border-box;
  973. word-wrap: break-word;
  974. flex-grow: 1 !important;
  975. .unit {
  976. padding: 0 2px;
  977. font-size: 12px;
  978. color: #404446;
  979. }
  980. }
  981. .content_num {
  982. display: flex;
  983. align-items: center;
  984. padding: 2px;
  985. --input-background-color: #f0f8f2;
  986. }
  987. .pd2 {
  988. padding: 2px 4px;
  989. }
  990. &:last-child {
  991. border-bottom: none;
  992. }
  993. }
  994. .ww55 {
  995. width: 55%;
  996. }
  997. .ww50 {
  998. width: 50%;
  999. }
  1000. .ww45 {
  1001. width: 45%;
  1002. }
  1003. .ww40 {
  1004. width: 40%;
  1005. }
  1006. .ww30 {
  1007. width: 30%;
  1008. }
  1009. .ww33 {
  1010. width: 33.33%;
  1011. }
  1012. .ww20 {
  1013. width: 20%;
  1014. }
  1015. .del_box {
  1016. position: absolute;
  1017. right: 2px;
  1018. top: 2px;
  1019. }
  1020. .sort_index {
  1021. position: absolute;
  1022. left: 2px;
  1023. top: 2px;
  1024. width: 14px;
  1025. height: 14px;
  1026. line-height: 14px;
  1027. text-align: center;
  1028. color: #fff;
  1029. font-size: 12px;
  1030. border-radius: 50%;
  1031. background: rgb(21, 122, 44);
  1032. }
  1033. }
  1034. }
  1035. </style>