index.vue 33 KB

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