index.vue 32 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174
  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. const ids = id.split(',');
  559. this.teamList = [];
  560. this.teamUserList = [];
  561. const list = ids.map((item) => getTeam(item));
  562. const dataList = await Promise.all(list);
  563. dataList.forEach((item) => {
  564. this.teamList.push({
  565. name: item.name,
  566. id: item.id
  567. });
  568. this.teamAllList.push(item.userVOList);
  569. });
  570. },
  571. outboundOrder(id, item) {
  572. this.$refs.outboundOrderDialogRef.open(id, item);
  573. },
  574. openPicking(id, item) {
  575. this.$refs.pickingListRef.open(id, item, '选择设备列表');
  576. },
  577. chooseData(listData) {
  578. this.$set(this.List[0], 'semiProductList', listData);
  579. this.$forceUpdate();
  580. console.log(this.List[0], 'this.List');
  581. },
  582. allSelection(id, selectList) {
  583. this.List.forEach((m) => {
  584. if (m.workOrderId == id) {
  585. let modelList = []; // 模具
  586. let instanceList = []; // 投料
  587. let aridRegionList = []; // 干燥区
  588. let equipmentList = []; // 生产设备
  589. let palletList = []; // 舟皿
  590. let revolvingDiskList = []; // 周转盘
  591. let semiProductList = []; // 半成品
  592. let turnover = []; //周转车
  593. let sparePartsList = []; //备品清单
  594. selectList.forEach((f) => {
  595. if (f.rootCategoryLevelId == 4) {
  596. equipmentList = equipmentList.concat(f);
  597. }
  598. if (f.rootCategoryLevelId == 5) {
  599. modelList = modelList.concat(f);
  600. } else if (f.rootCategoryLevelId == 1) {
  601. instanceList = instanceList.concat(f);
  602. } else if (f.rootCategoryLevelId == 11) {
  603. aridRegionList = aridRegionList.concat(f);
  604. } else if (f.rootCategoryLevelId == 6) {
  605. sparePartsList = sparePartsList.concat(f);
  606. } else if (f.rootCategoryLevelId == 7) {
  607. turnover = turnover.concat(f);
  608. } else if (f.rootCategoryLevelId == 8) {
  609. palletList = palletList.concat(f);
  610. } else if (f.rootCategoryLevelId == 26) {
  611. revolvingDiskList = revolvingDiskList.concat(f);
  612. } else if (
  613. [23, 2, 9, 28].includes(Number(f.rootCategoryLevelId))
  614. ) {
  615. semiProductList = semiProductList.concat(f);
  616. }
  617. });
  618. this.$set(m, 'modelList', modelList);
  619. this.$set(m, 'sparePartsList', sparePartsList);
  620. this.$set(m, 'instanceList', instanceList);
  621. this.$set(m, 'aridRegionList', aridRegionList);
  622. this.$set(m, 'equipmentList', equipmentList);
  623. this.$set(m, 'turnover', turnover);
  624. this.$set(m, 'palletList', palletList);
  625. this.$set(m, 'revolvingDiskList', revolvingDiskList);
  626. this.$set(m, 'semiProductList', semiProductList);
  627. this.$forceUpdate();
  628. }
  629. });
  630. },
  631. checkChange() {
  632. if (this.checked) {
  633. this.executorIdList = [];
  634. this.executorIdList = this.teamUserList.map((item) => item.id);
  635. } else {
  636. this.executorIdList = [];
  637. }
  638. },
  639. getCacheFn() {
  640. let parma = {
  641. workOrderIds: this.idsList,
  642. taskId: this.taskObj.id,
  643. type: 2
  644. };
  645. feedGetCache(parma).then((res) => {
  646. if (res.length == 0) {
  647. return false;
  648. }
  649. let objList = res[0].extInfo.objList;
  650. this.List.forEach((f, index) => {
  651. objList.forEach((o) => {
  652. if (
  653. f.workOrderId == o.workOrderId &&
  654. f.currentTaskDiagram.taskId == o.taskId
  655. ) {
  656. f['instanceList'] = o.instanceList || [];
  657. f['equipmentList'] = o.equipmentList || [];
  658. f['modelList'] = o.modelList || [];
  659. f['sparePartsList'] = o.sparePartsList || [];
  660. f['aridRegionList'] = o.aridRegionList || [];
  661. f['packingList'] = o.packingList || [];
  662. f['palletList'] = o.palletList || [];
  663. f['revolvingDiskList'] = o.revolvingDiskList || [];
  664. f['semiProductList'] = o.semiProductList || [];
  665. this.$set(this.List[index], 'executorTime', o.executorTime);
  666. this.$forceUpdate();
  667. }
  668. });
  669. });
  670. });
  671. },
  672. async save(type, index) {
  673. let arr = this.List.filter((L) => L.executorTime);
  674. if (!arr.length) {
  675. return this.$message.warning('请选择投料时间');
  676. }
  677. if (this.executorIdList.length == 0) {
  678. return this.$message.warning('执行人不能为空!');
  679. }
  680. const executorList = [];
  681. this.executorIdList.forEach((item) => {
  682. const data = this.teamUserList.find((it) => it.id == item);
  683. if (data) {
  684. executorList.push({
  685. userId: data.id,
  686. jobNumber: data.jobNumber,
  687. name: data.name
  688. });
  689. }
  690. });
  691. this.List = this.List.map((item) => {
  692. item.executorList = executorList;
  693. return item;
  694. });
  695. // this.List = this.List.map((item) => {
  696. // item.executorList = executorList;
  697. // return item;
  698. // });
  699. let deviceIs = false;
  700. this.List.forEach((f) => {
  701. f.instanceList.forEach((e) => {
  702. if (Object.prototype.hasOwnProperty.call(e, 'type')) {
  703. e.extInfo['type'] = e.type;
  704. }
  705. e.extInfo['isConsumable'] = e.isConsumable;
  706. });
  707. if (this.feedNeedEquipment == 1 && f.equipmentList.length == 0) {
  708. deviceIs = true;
  709. setTimeout(() => {
  710. this.$message.warning({
  711. message: '请工单编号:' + f.code + '添加设备',
  712. key: f.code
  713. });
  714. }, 500);
  715. }
  716. });
  717. //判断投料是否要添加设备
  718. if (deviceIs) {
  719. return;
  720. }
  721. for (let item of this.List) {
  722. if (
  723. item.currentTaskDiagram.feedNeedTurnover == 1 &&
  724. item.turnover.length == 0
  725. ) {
  726. setTimeout(() => {
  727. this.$message.warning({
  728. message: '请工单编号:' + item.code + '添加周转车',
  729. key: item.code
  730. });
  731. }, 500);
  732. return;
  733. }
  734. }
  735. for (let item of this.List) {
  736. if (
  737. item.currentTaskDiagram.feedNeedBoat == 1 &&
  738. item.palletList.length == 0
  739. ) {
  740. setTimeout(() => {
  741. this.$message.warning({
  742. message: '请工单编号:' + item.code + '添加舟皿',
  743. key: item.code
  744. });
  745. }, 500);
  746. return;
  747. }
  748. }
  749. const isCache = await this.checkCache(type);
  750. if (!isCache) {
  751. return false;
  752. }
  753. this.loading = this.$loading({
  754. lock: true,
  755. text: '加载中',
  756. background: 'rgba(0, 0, 0, 0.7)'
  757. });
  758. let newList = [];
  759. for (let item of this.List) {
  760. newList.push({
  761. currentTaskDiagram: item.currentTaskDiagram,
  762. workOrderId: item.workOrderId
  763. });
  764. }
  765. await checkRepeatFeed(newList).then((res) => {
  766. if (res.data.length != 0) {
  767. this.checkFeed(res.data);
  768. }
  769. });
  770. // for (let item of this.List) {
  771. // await checkRepeatFeed({
  772. // currentTaskDiagram: item.currentTaskDiagram,
  773. // workOrderId: item.workOrderId
  774. // }).then((res) => {
  775. // if (res.data == 0) {
  776. // // this.feedReport();
  777. // } else {
  778. // this.$confirm('已经有投料是否继续重复投料?', '提示', {
  779. // confirmButtonText: '确定',
  780. // cancelButtonText: '取消',
  781. // type: 'warning'
  782. // })
  783. // .then(() => {
  784. // // this.feedReport();
  785. // })
  786. // .catch(() => {
  787. // this.loading.close();
  788. // });
  789. // }
  790. // });
  791. // }
  792. },
  793. checkFeed(list) {
  794. let wordCodeList = [];
  795. for (let item of list) {
  796. if (item.feedFormed != '0') {
  797. wordCodeList.push(item.workOrderCode);
  798. }
  799. }
  800. if (wordCodeList.length != 0) {
  801. this.$confirm(
  802. `工单号${wordCodeList.join(',')}已有投料,是否继续重复投料?`,
  803. '提示',
  804. {
  805. confirmButtonText: '确定',
  806. cancelButtonText: '取消',
  807. type: 'warning',
  808. center: true
  809. }
  810. )
  811. .then(() => {
  812. this.feedReport();
  813. })
  814. .catch(() => {
  815. this.loading.close();
  816. });
  817. } else {
  818. this.feedReport();
  819. }
  820. },
  821. feedReport() {
  822. batchSave(this.List)
  823. .then((res) => {
  824. this.loading.close();
  825. this.$message.success('投料成功');
  826. this.getList(this.idsList);
  827. this.executorIdList = [];
  828. this.checked = false;
  829. this.teamId = '';
  830. this.$emit('feedSuccess', 'success');
  831. })
  832. .catch((e) => {
  833. this.loading.close();
  834. });
  835. },
  836. toInteger(num) {
  837. const len = this.getDecimalLength(num);
  838. return {
  839. int: Math.round(num * Math.pow(10, len)),
  840. factor: Math.pow(10, len)
  841. };
  842. },
  843. add(a, b) {
  844. const { int: aInt, factor: aFactor } = this.toInteger(a);
  845. const { int: bInt, factor: bFactor } = this.toInteger(b);
  846. const maxFactor = Math.max(aFactor, bFactor);
  847. return (
  848. (aInt * (maxFactor / aFactor) + bInt * (maxFactor / bFactor)) /
  849. maxFactor
  850. );
  851. },
  852. getDecimalLength(num) {
  853. return (num.toString().split('.')[1] || '').length;
  854. },
  855. checkCache(type, index) {
  856. return new Promise((resolve) => {
  857. if (type == 1) {
  858. feedSaveCache(this.List).then((rr) => {
  859. this.$message.success('已经缓存');
  860. });
  861. resolve(false);
  862. } else if (type == 2) {
  863. resolve(true);
  864. }
  865. });
  866. },
  867. removeCacheFn(type) {
  868. this.$confirm('是否清空缓存', '缓存')
  869. .then(() => {
  870. let parma = {
  871. workOrderIds: type == 'all' ? this.idsList : [type],
  872. taskId: this.taskObj.id,
  873. type: 2
  874. };
  875. removeCache(parma).then((res) => {
  876. this.getList(this.idsList);
  877. });
  878. })
  879. .catch(() => {});
  880. }
  881. }
  882. };
  883. </script>
  884. <style scoped lang="scss">
  885. .top_fixed {
  886. width: 100%;
  887. height: 40px;
  888. background: #fff;
  889. display: flex;
  890. align-items: center;
  891. justify-content: flex-end;
  892. }
  893. .feed_box {
  894. // margin-top: 6px;
  895. width: 100%;
  896. height: calc(100vh - 70px - 50px - 80px - 60px);
  897. overflow-y: scroll;
  898. overflow-x: hidden;
  899. }
  900. .card_box {
  901. background: #fff;
  902. padding: 8px;
  903. border-radius: 2px;
  904. }
  905. .checkboxWrapper {
  906. padding: 8px 20px;
  907. border-bottom: 1px solid #ccc;
  908. }
  909. ::v-deep .el-select__tags {
  910. flex-wrap: nowrap;
  911. overflow: auto;
  912. }
  913. /* 输入框最大宽度*/
  914. ::v-deep .el-select__tags-text {
  915. max-width: 90px;
  916. }
  917. /* 底部滚动条的高度*/
  918. ::v-deep .el-select__tags::-webkit-scrollbar {
  919. height: 2px !important;
  920. }
  921. </style>
  922. <style lang="scss">
  923. .mt6 {
  924. margin-top: 6px;
  925. }
  926. .title_box {
  927. padding: 5px 0;
  928. .name {
  929. font-size: 14px;
  930. font-style: normal;
  931. font-weight: 400;
  932. color: #157a2c;
  933. padding-left: 5px;
  934. position: relative;
  935. &:before {
  936. position: absolute;
  937. content: '';
  938. left: 0px;
  939. top: 0px;
  940. bottom: 0px;
  941. width: 2px;
  942. height: 14px;
  943. background: #157a2c;
  944. margin: auto;
  945. }
  946. }
  947. }
  948. .material {
  949. margin-top: 6px;
  950. .content_table {
  951. width: 100%;
  952. border: 1px solid #e3e5e5;
  953. position: relative;
  954. .item {
  955. display: flex;
  956. border-bottom: 1px solid #e3e5e5;
  957. .lable {
  958. width: 72px;
  959. text-align: center;
  960. background-color: #f7f9fa;
  961. font-size: 12px;
  962. border-right: 1px solid #e3e5e5;
  963. flex-shrink: 0;
  964. }
  965. .lable80 {
  966. width: 80px !important;
  967. font-size: 12px;
  968. }
  969. .lable90 {
  970. width: 90px !important;
  971. }
  972. .lable100 {
  973. width: 100px !important;
  974. }
  975. .ww60 {
  976. width: 60px;
  977. }
  978. .content {
  979. width: 250px;
  980. min-height: 32px;
  981. font-size: 14px;
  982. line-height: 14px;
  983. font-style: normal;
  984. font-weight: 400;
  985. padding: 9px 4px;
  986. box-sizing: border-box;
  987. word-wrap: break-word;
  988. flex-grow: 1 !important;
  989. .unit {
  990. padding: 0 2px;
  991. font-size: 12px;
  992. color: #404446;
  993. }
  994. }
  995. .content_num {
  996. display: flex;
  997. align-items: center;
  998. padding: 2px;
  999. --input-background-color: #f0f8f2;
  1000. }
  1001. .pd2 {
  1002. padding: 2px 4px;
  1003. }
  1004. &:last-child {
  1005. border-bottom: none;
  1006. }
  1007. }
  1008. .ww55 {
  1009. width: 55%;
  1010. }
  1011. .ww50 {
  1012. width: 50%;
  1013. }
  1014. .ww45 {
  1015. width: 45%;
  1016. }
  1017. .ww40 {
  1018. width: 40%;
  1019. }
  1020. .ww30 {
  1021. width: 30%;
  1022. }
  1023. .ww33 {
  1024. width: 33.33%;
  1025. }
  1026. .ww20 {
  1027. width: 20%;
  1028. }
  1029. .del_box {
  1030. position: absolute;
  1031. right: 2px;
  1032. top: 2px;
  1033. }
  1034. .sort_index {
  1035. position: absolute;
  1036. left: 2px;
  1037. top: 2px;
  1038. width: 14px;
  1039. height: 14px;
  1040. line-height: 14px;
  1041. text-align: center;
  1042. color: #fff;
  1043. font-size: 12px;
  1044. border-radius: 50%;
  1045. background: rgb(21, 122, 44);
  1046. }
  1047. }
  1048. }
  1049. </style>