index.vue 33 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190
  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. teamName: '',
  336. isDefaultExecutor: false,
  337. checked: false,
  338. pickerOptions: {
  339. disabledDate(time) {
  340. // 禁止选择大于当前时间的日期
  341. return time.getTime() > Date.now();
  342. }
  343. // selectableRange: (() => {
  344. // const now = new Date();
  345. // const start = '00:00:00';
  346. // const end = now.toTimeString().split(' ')[0];
  347. // return `${start} - ${end}`;
  348. // })()
  349. }
  350. // feedExistNum: '',
  351. // feedNeedAridRegion: '',
  352. // feedNeedAuxiliaryEquipment: '',
  353. // feedNeedBoat: '',
  354. // feedNeedConsumableMaterial: '',
  355. // feedNeedEquipment: '',
  356. // feedNeedJunkProduct: '',
  357. // feedNeedMateriel: '',
  358. // feedNeedMeasuringEquipment: '',
  359. // feedNeedMould: '',
  360. // feedNeedProduct: '',
  361. // feedNeedQuality: '',
  362. // feedNeedReworkProduct: '',
  363. // feedNeedSemiProduct: '',
  364. // feedNeedTurnover: '',
  365. // feedStatus: ''
  366. };
  367. },
  368. mounted() {
  369. this.getChooseEngrave();
  370. if (localStorage.getItem('singleUserInfo') == '1') {
  371. const data = JSON.parse(localStorage.getItem('chooseUserInfo'));
  372. this.getTeamList(data.teamId);
  373. } else {
  374. this.getTeamList(this.$store.state.user.info.teamId);
  375. }
  376. // this.getTeamList(this.$store.state.user.info.teamId);
  377. },
  378. methods: {
  379. handleCreate(e) {
  380. if (e) {
  381. const list = JSON.parse(JSON.stringify(this.List));
  382. console.log(list);
  383. list.map((item) => {
  384. item.executorTime = e;
  385. });
  386. this.$set(this, 'List', list);
  387. }
  388. },
  389. getList(ids) {
  390. this.idsList = ids || [];
  391. let param = {
  392. ids: ids,
  393. taskId: this.taskObj.id
  394. };
  395. this.isLoad = false;
  396. workorderList(param)
  397. .then((res) => {
  398. let arr = [];
  399. arr = res.map((m) => {
  400. m.workOrderId = m.id;
  401. m.paramDetailList = m.paramDetailList;
  402. m.instanceList = []; // 物料
  403. // m.equipmentList = []; // 设备
  404. m.modelList = []; // 模具
  405. m.aridRegionList = []; // 干燥区
  406. m.packingList = []; // 包装
  407. m.palletList = []; // 舟皿
  408. m.revolvingDiskList = []; // 周转盘
  409. m.semiProductList = []; //半成品
  410. m.sparePartsList = []; //备品清单
  411. if (m.pickOutInList.length > 0) {
  412. m.pickOutInList.forEach((f) => {
  413. if (f.rootCategoryLevelId == 1) {
  414. m.instanceList.push(f);
  415. } else if (f.rootCategoryLevelId == 4) {
  416. m.modelList.push(f);
  417. } else if (f.rootCategoryLevelId == 5) {
  418. m.modelList.push(f);
  419. } else if (f.rootCategoryLevelId == 6) {
  420. m.sparePartsList.push(f);
  421. } else if (f.rootCategoryLevelId == 11) {
  422. m.aridRegionList.push(f);
  423. } else if (f.rootCategoryLevelId == 13) {
  424. m.packingList.push(f);
  425. } else if (f.rootCategoryLevelId == 8) {
  426. m.palletList.push(f);
  427. } else if (f.rootCategoryLevelId == 26) {
  428. m.revolvingDiskList.push(f);
  429. } else if (
  430. [23, 2, 9, 28].includes(Number(f.rootCategoryLevelId))
  431. ) {
  432. m.semiProductList.push(f);
  433. }
  434. });
  435. }
  436. if (m.semiProductList.length != 0) {
  437. m.semiProductList.forEach((item) => {
  438. if (!item.confirm) {
  439. item.confirm = '';
  440. }
  441. });
  442. }
  443. // 处理字段
  444. if (m.quality == '') {
  445. m.product = '{}';
  446. }
  447. if (!Object.prototype.hasOwnProperty.call(m, 'product')) {
  448. m.product = '{}';
  449. }
  450. if (m.singleReport == 1) {
  451. m.semiProductList.map((item) => {
  452. item.extInfo.taskId = '';
  453. item.extInfo.taskName = '';
  454. });
  455. }
  456. if (m.singleReport == 0) {
  457. m.product.map((item) => {
  458. item.extInfo.taskId = '';
  459. item.extInfo.taskName = '';
  460. });
  461. }
  462. if (
  463. this.clientEnvironmentId == 3 &&
  464. this.taskObj.type == 6 &&
  465. m.singleReport == 0
  466. ) {
  467. this.isShow = false;
  468. } else {
  469. this.isShow = true;
  470. }
  471. delete m.id;
  472. if (this.taskObj.id) {
  473. m.taskId = this.taskObj.id;
  474. m.taskName = this.taskObj.name;
  475. }
  476. return {
  477. ...m
  478. };
  479. });
  480. console.log(arr, 'arr');
  481. arr.forEach((it) => {
  482. if (it.semiProductList.length != 0) {
  483. it.semiProductList.forEach((item) => {
  484. if (item.extInfo && item.extInfo.taskId == -1) {
  485. item.extInfo.taskId = item.extInfo.taskId + '';
  486. }
  487. });
  488. }
  489. // if (it.pickOutInList.length != 0) {
  490. // it.pickOutInList.forEach((item) => {
  491. // if (item.extInfo && item.extInfo.taskId == -1) {
  492. // item.extInfo.taskId = item.extInfo.taskId + '';
  493. // }
  494. // });
  495. // }
  496. });
  497. this.List = deepClone(arr);
  498. })
  499. .finally(() => {
  500. this.isLoad = true;
  501. this.getCacheFn();
  502. });
  503. this.$forceUpdate();
  504. },
  505. getNowTime() {
  506. const now = new Date();
  507. const year = now.getFullYear();
  508. const month = String(now.getMonth() + 1).padStart(2, '0');
  509. const day = String(now.getDate()).padStart(2, '0');
  510. const hour = String(now.getHours()).padStart(2, '0');
  511. const minute = String(now.getMinutes()).padStart(2, '0');
  512. const second = String(now.getSeconds()).padStart(2, '0');
  513. return `${year}-${month}-${day} ${hour}:${minute}:${second}`;
  514. },
  515. async getChooseEngrave() {
  516. await parameterGetByCode({
  517. code: 'choose_engrave'
  518. }).then((res) => {
  519. this.isChoose = res.value == '1' ? true : false;
  520. });
  521. await parameterGetByCode({
  522. code: 'mes_order_feed_by_default_date'
  523. }).then((res) => {
  524. if (res.value == '1') {
  525. const dateTime = this.getNowTime();
  526. this.List.forEach((item) => {
  527. item.executorTime = dateTime;
  528. });
  529. }
  530. });
  531. await parameterGetByCode({
  532. code: 'batch_update_engrave'
  533. }).then((res) => {
  534. this.isEngrave = res.value == '1' ? true : false;
  535. });
  536. await parameterGetByCode({
  537. code: 'batch_disposal'
  538. }).then((res) => {
  539. this.isDisposal = res.value == '1' ? true : false;
  540. });
  541. await parameterGetByCode({
  542. code: 'default_executor'
  543. }).then((res) => {
  544. this.isDefaultExecutor = res.value == '1' ? true : false;
  545. if (this.isDefaultExecutor) {
  546. this.setDefaultIdList();
  547. }
  548. });
  549. },
  550. setDefaultIdList() {
  551. if (this.teamList.length != 0) {
  552. this.teamId = this.teamList[0].id;
  553. this.teamName = this.teamList[0].name;
  554. const index = this.teamList.findIndex(
  555. (item) => item.id == this.teamId
  556. );
  557. console.log(this.teamAllList);
  558. this.teamUserList = this.teamAllList[index];
  559. if (this.teamUserList) {
  560. const res = this.teamUserList.find(
  561. (it) => it.id == this.$store.state.user.info.userId
  562. );
  563. this.executorIdList.push(res.id);
  564. }
  565. }
  566. },
  567. changeId() {
  568. if (this.executorIdList.length == this.teamUserList.length) {
  569. this.checked = true;
  570. } else {
  571. this.checked = false;
  572. }
  573. },
  574. checkTeamList(id) {
  575. this.executorIdList = [];
  576. const index = this.teamList.findIndex((item) => item.id == id);
  577. this.teamName = this.teamList[index].name;
  578. this.teamUserList = this.teamAllList[index];
  579. },
  580. async getTeamList(id) {
  581. if (!id) return;
  582. const ids = id.split(',');
  583. this.teamList = [];
  584. this.teamUserList = [];
  585. const list = ids.map((item) => getTeam(item));
  586. const dataList = await Promise.all(list);
  587. dataList.forEach((item) => {
  588. this.teamList.push({
  589. name: item.name,
  590. id: item.id
  591. });
  592. this.teamAllList.push(item.userVOList);
  593. });
  594. },
  595. outboundOrder(id, item) {
  596. this.$refs.outboundOrderDialogRef.open(id, item);
  597. },
  598. openPicking(id, item) {
  599. this.$refs.pickingListRef.open(
  600. id,
  601. item,
  602. '选择设备列表',
  603. this.taskObj.id
  604. );
  605. },
  606. chooseData(listData) {
  607. this.$set(this.List[0], 'semiProductList', listData);
  608. this.$forceUpdate();
  609. console.log(this.List[0], 'this.List');
  610. },
  611. allSelection(id, selectList) {
  612. this.List.forEach((m) => {
  613. if (m.workOrderId == id) {
  614. let modelList = []; // 模具
  615. let instanceList = []; // 投料
  616. let aridRegionList = []; // 干燥区
  617. let equipmentList = []; // 生产设备
  618. let palletList = []; // 舟皿
  619. let revolvingDiskList = []; // 周转盘
  620. let semiProductList = []; // 半成品
  621. let turnover = []; //周转车
  622. let sparePartsList = []; //备品清单
  623. selectList.forEach((f) => {
  624. if (f.rootCategoryLevelId == 4) {
  625. equipmentList = equipmentList.concat(f);
  626. }
  627. if (f.rootCategoryLevelId == 5) {
  628. modelList = modelList.concat(f);
  629. } else if (f.rootCategoryLevelId == 1) {
  630. instanceList = instanceList.concat(f);
  631. } else if (f.rootCategoryLevelId == 11) {
  632. aridRegionList = aridRegionList.concat(f);
  633. } else if (f.rootCategoryLevelId == 6) {
  634. sparePartsList = sparePartsList.concat(f);
  635. } else if (f.rootCategoryLevelId == 7) {
  636. turnover = turnover.concat(f);
  637. } else if (f.rootCategoryLevelId == 8) {
  638. palletList = palletList.concat(f);
  639. } else if (f.rootCategoryLevelId == 26) {
  640. revolvingDiskList = revolvingDiskList.concat(f);
  641. } else if (
  642. [23, 2, 9, 28].includes(Number(f.rootCategoryLevelId))
  643. ) {
  644. semiProductList = semiProductList.concat(f);
  645. }
  646. });
  647. this.$set(m, 'modelList', modelList);
  648. this.$set(m, 'sparePartsList', sparePartsList);
  649. this.$set(m, 'instanceList', instanceList);
  650. this.$set(m, 'aridRegionList', aridRegionList);
  651. this.$set(m, 'equipmentList', equipmentList);
  652. this.$set(m, 'turnover', turnover);
  653. this.$set(m, 'palletList', palletList);
  654. this.$set(m, 'revolvingDiskList', revolvingDiskList);
  655. this.$set(m, 'semiProductList', semiProductList);
  656. this.$forceUpdate();
  657. }
  658. });
  659. },
  660. checkChange() {
  661. if (this.checked) {
  662. this.executorIdList = [];
  663. this.executorIdList = this.teamUserList.map((item) => item.id);
  664. } else {
  665. this.executorIdList = [];
  666. }
  667. },
  668. getCacheFn() {
  669. let parma = {
  670. workOrderIds: this.idsList,
  671. taskId: this.taskObj.id,
  672. type: 2
  673. };
  674. feedGetCache(parma).then((res) => {
  675. if (res.length == 0) {
  676. return false;
  677. }
  678. let objList = res[0].extInfo.objList;
  679. this.List.forEach((f, index) => {
  680. objList.forEach((o) => {
  681. if (
  682. f.workOrderId == o.workOrderId &&
  683. f.currentTaskDiagram.taskId == o.taskId
  684. ) {
  685. f['instanceList'] = o.instanceList || [];
  686. f['equipmentList'] = o.equipmentList || [];
  687. f['modelList'] = o.modelList || [];
  688. f['sparePartsList'] = o.sparePartsList || [];
  689. f['aridRegionList'] = o.aridRegionList || [];
  690. f['packingList'] = o.packingList || [];
  691. f['palletList'] = o.palletList || [];
  692. f['revolvingDiskList'] = o.revolvingDiskList || [];
  693. f['semiProductList'] = o.semiProductList || [];
  694. this.$set(this.List[index], 'executorTime', o.executorTime);
  695. this.$forceUpdate();
  696. }
  697. });
  698. });
  699. });
  700. },
  701. async save(type, index) {
  702. let arr = this.List.filter((L) => L.executorTime);
  703. if (!arr.length) {
  704. return this.$message.warning('请选择投料时间');
  705. }
  706. if (this.executorIdList.length == 0) {
  707. return this.$message.warning('执行人不能为空!');
  708. }
  709. const executorList = [];
  710. this.executorIdList.forEach((item) => {
  711. const data = this.teamUserList.find((it) => it.id == item);
  712. if (data) {
  713. executorList.push({
  714. userId: data.id,
  715. jobNumber: data.jobNumber,
  716. name: data.name
  717. });
  718. }
  719. });
  720. this.List = this.List.map((item) => {
  721. item.executorList = executorList;
  722. item.teamId = this.teamId;
  723. item.teamName = this.teamName;
  724. return item;
  725. });
  726. // this.List = this.List.map((item) => {
  727. // item.executorList = executorList;
  728. // return item;
  729. // });
  730. let deviceIs = false;
  731. this.List.forEach((f) => {
  732. f.instanceList.forEach((e) => {
  733. if (Object.prototype.hasOwnProperty.call(e, 'type')) {
  734. e.extInfo['type'] = e.type;
  735. }
  736. e.extInfo['isConsumable'] = e.isConsumable;
  737. });
  738. if (this.feedNeedEquipment == 1 && f.equipmentList.length == 0) {
  739. deviceIs = true;
  740. setTimeout(() => {
  741. this.$message.warning({
  742. message: '请工单编号:' + f.code + '添加设备',
  743. key: f.code
  744. });
  745. }, 500);
  746. }
  747. });
  748. //判断投料是否要添加设备
  749. if (deviceIs) {
  750. return;
  751. }
  752. for (let item of this.List) {
  753. if (
  754. item.currentTaskDiagram.feedNeedTurnover == 1 &&
  755. item.turnover.length == 0
  756. ) {
  757. setTimeout(() => {
  758. this.$message.warning({
  759. message: '请工单编号:' + item.code + '添加周转车',
  760. key: item.code
  761. });
  762. }, 500);
  763. return;
  764. }
  765. }
  766. for (let item of this.List) {
  767. if (
  768. item.currentTaskDiagram.feedNeedBoat == 1 &&
  769. item.palletList.length == 0
  770. ) {
  771. setTimeout(() => {
  772. this.$message.warning({
  773. message: '请工单编号:' + item.code + '添加舟皿',
  774. key: item.code
  775. });
  776. }, 500);
  777. return;
  778. }
  779. }
  780. const isCache = await this.checkCache(type);
  781. if (!isCache) {
  782. return false;
  783. }
  784. this.loading = this.$loading({
  785. lock: true,
  786. text: '加载中',
  787. background: 'rgba(0, 0, 0, 0.7)'
  788. });
  789. let newList = [];
  790. for (let item of this.List) {
  791. newList.push({
  792. currentTaskDiagram: item.currentTaskDiagram,
  793. workOrderId: item.workOrderId
  794. });
  795. }
  796. await checkRepeatFeed(newList).then((res) => {
  797. if (res.data.length != 0) {
  798. this.checkFeed(res.data);
  799. }
  800. });
  801. },
  802. checkFeed(list) {
  803. let wordCodeList = [];
  804. for (let item of list) {
  805. if (item.feedFormed != '0') {
  806. wordCodeList.push(item.workOrderCode);
  807. }
  808. }
  809. if (wordCodeList.length != 0) {
  810. this.$confirm(
  811. `工单号${wordCodeList.join(',')}已有投料,是否继续重复投料?`,
  812. '提示',
  813. {
  814. confirmButtonText: '确定',
  815. cancelButtonText: '取消',
  816. type: 'warning',
  817. center: true
  818. }
  819. )
  820. .then(() => {
  821. this.feedReport();
  822. })
  823. .catch(() => {
  824. this.loading.close();
  825. });
  826. } else {
  827. this.feedReport();
  828. }
  829. },
  830. feedReport() {
  831. batchSave(this.List)
  832. .then((res) => {
  833. this.loading.close();
  834. this.$message.success('投料成功');
  835. this.getList(this.idsList);
  836. this.executorIdList = [];
  837. this.checked = false;
  838. this.teamId = '';
  839. // 延迟刷新
  840. setTimeout(() => {
  841. this.$emit('reload');
  842. }, 500);
  843. this.$emit('feedSuccess', 'success');
  844. })
  845. .catch((e) => {
  846. this.loading.close();
  847. });
  848. },
  849. toInteger(num) {
  850. const len = this.getDecimalLength(num);
  851. return {
  852. int: Math.round(num * Math.pow(10, len)),
  853. factor: Math.pow(10, len)
  854. };
  855. },
  856. add(a, b) {
  857. const { int: aInt, factor: aFactor } = this.toInteger(a);
  858. const { int: bInt, factor: bFactor } = this.toInteger(b);
  859. const maxFactor = Math.max(aFactor, bFactor);
  860. return (
  861. (aInt * (maxFactor / aFactor) + bInt * (maxFactor / bFactor)) /
  862. maxFactor
  863. );
  864. },
  865. getDecimalLength(num) {
  866. return (num.toString().split('.')[1] || '').length;
  867. },
  868. checkCache(type, index) {
  869. return new Promise((resolve) => {
  870. if (type == 1) {
  871. feedSaveCache(this.List).then((rr) => {
  872. this.$message.success('已经缓存');
  873. });
  874. resolve(false);
  875. } else if (type == 2) {
  876. resolve(true);
  877. }
  878. });
  879. },
  880. removeCacheFn(type) {
  881. this.$confirm('是否清空缓存', '缓存')
  882. .then(() => {
  883. let parma = {
  884. workOrderIds: type == 'all' ? this.idsList : [type],
  885. taskId: this.taskObj.id,
  886. type: 2
  887. };
  888. removeCache(parma).then((res) => {
  889. this.getList(this.idsList);
  890. });
  891. })
  892. .catch(() => {});
  893. }
  894. }
  895. };
  896. </script>
  897. <style scoped lang="scss">
  898. .top_fixed {
  899. width: 100%;
  900. height: 40px;
  901. background: #fff;
  902. display: flex;
  903. align-items: center;
  904. justify-content: flex-end;
  905. }
  906. .feed_box {
  907. // margin-top: 6px;
  908. width: 100%;
  909. height: calc(100vh - 70px - 50px - 80px - 60px);
  910. overflow-y: scroll;
  911. overflow-x: hidden;
  912. }
  913. .card_box {
  914. background: #fff;
  915. padding: 8px;
  916. border-radius: 2px;
  917. }
  918. .checkboxWrapper {
  919. padding: 8px 20px;
  920. border-bottom: 1px solid #ccc;
  921. }
  922. ::v-deep .el-select__tags {
  923. flex-wrap: nowrap;
  924. overflow: auto;
  925. }
  926. ::v-deep .el-select__tags-text {
  927. max-width: 90px;
  928. }
  929. ::v-deep .el-select__tags::-webkit-scrollbar {
  930. height: 2px !important;
  931. }
  932. </style>
  933. <style lang="scss">
  934. .mt6 {
  935. margin-top: 6px;
  936. }
  937. .title_box {
  938. padding: 5px 0;
  939. .name {
  940. font-size: 14px;
  941. font-style: normal;
  942. font-weight: 400;
  943. color: #157a2c;
  944. padding-left: 5px;
  945. position: relative;
  946. &:before {
  947. position: absolute;
  948. content: '';
  949. left: 0px;
  950. top: 0px;
  951. bottom: 0px;
  952. width: 2px;
  953. height: 14px;
  954. background: #157a2c;
  955. margin: auto;
  956. }
  957. }
  958. }
  959. .material {
  960. margin-top: 6px;
  961. .content_table {
  962. width: 100%;
  963. border: 1px solid #e3e5e5;
  964. position: relative;
  965. .item {
  966. display: flex;
  967. border-bottom: 1px solid #e3e5e5;
  968. .lable {
  969. width: 72px;
  970. text-align: center;
  971. background-color: #f7f9fa;
  972. font-size: 12px;
  973. border-right: 1px solid #e3e5e5;
  974. flex-shrink: 0;
  975. }
  976. .lable80 {
  977. width: 80px !important;
  978. font-size: 12px;
  979. }
  980. .lable90 {
  981. width: 90px !important;
  982. }
  983. .lable100 {
  984. width: 100px !important;
  985. }
  986. .ww60 {
  987. width: 60px;
  988. }
  989. .content {
  990. width: 250px;
  991. min-height: 32px;
  992. font-size: 14px;
  993. line-height: 14px;
  994. font-style: normal;
  995. font-weight: 400;
  996. padding: 9px 4px;
  997. box-sizing: border-box;
  998. word-wrap: break-word;
  999. flex-grow: 1 !important;
  1000. .unit {
  1001. padding: 0 2px;
  1002. font-size: 12px;
  1003. color: #404446;
  1004. }
  1005. }
  1006. .content_num {
  1007. display: flex;
  1008. align-items: center;
  1009. padding: 2px;
  1010. --input-background-color: #f0f8f2;
  1011. }
  1012. .pd2 {
  1013. padding: 2px 4px;
  1014. }
  1015. &:last-child {
  1016. border-bottom: none;
  1017. }
  1018. }
  1019. .ww55 {
  1020. width: 55%;
  1021. }
  1022. .ww50 {
  1023. width: 50%;
  1024. }
  1025. .ww45 {
  1026. width: 45%;
  1027. }
  1028. .ww40 {
  1029. width: 40%;
  1030. }
  1031. .ww30 {
  1032. width: 30%;
  1033. }
  1034. .ww33 {
  1035. width: 33.33%;
  1036. }
  1037. .ww20 {
  1038. width: 20%;
  1039. }
  1040. .del_box {
  1041. position: absolute;
  1042. right: 2px;
  1043. top: 2px;
  1044. }
  1045. .sort_index {
  1046. position: absolute;
  1047. left: 2px;
  1048. top: 2px;
  1049. width: 14px;
  1050. height: 14px;
  1051. line-height: 14px;
  1052. text-align: center;
  1053. color: #fff;
  1054. font-size: 12px;
  1055. border-radius: 50%;
  1056. background: rgb(21, 122, 44);
  1057. }
  1058. }
  1059. }
  1060. </style>