index.vue 32 KB

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