details.vue 29 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074
  1. <template>
  2. <view class="content-box">
  3. <uni-nav-bar
  4. fixed="true"
  5. statusBar="true"
  6. left-icon="back"
  7. :title="title"
  8. background-color="#F7F9FA"
  9. color="#000"
  10. @clickLeft="back"
  11. right-icon="scan"
  12. @clickRight="handlScanCode"
  13. ></uni-nav-bar>
  14. <!-- 投料 -->
  15. <view class="list_box">
  16. <u-list @scrolltolower="scrolltolower">
  17. <view v-for="(item, index) in List" :key="index" class="card_box">
  18. <!-- 工单信息 -->
  19. <workOrderBom
  20. :item="item"
  21. pType="feed"
  22. :isDetails="true"
  23. :taskType="item.currentTaskDiagram.type"
  24. @handleScan="handleScan"
  25. ></workOrderBom>
  26. <paramBom
  27. v-if="item.paramDetailList.length != 0"
  28. :list="item.paramDetailList"
  29. ></paramBom>
  30. <!-- //设备信息 -->
  31. <deviceBom
  32. v-if="item.equipmentList.length != 0"
  33. :workOrderId="item.workOrderId"
  34. :wordItem="item"
  35. :list="item.equipmentList"
  36. :turnover="item.turnover"
  37. @scanIt="scanIt"
  38. :type="type"
  39. ></deviceBom>
  40. <!-- //在制品 -->
  41. <view
  42. v-if="
  43. item.product && item.product.length != 0 && item.singleReport == 0
  44. "
  45. >
  46. <workInProgressList
  47. :itemData="item"
  48. :equipmentList="item.equipmentList"
  49. ></workInProgressList>
  50. </view>
  51. <!-- <productsBom v-if="item.product != null && item.product != '{}'" :itemObj="item"
  52. :productsObj="item.product">
  53. </productsBom> -->
  54. <!-- feedNeedMould -->
  55. <modelBom
  56. v-if="item.modelList.length != 0"
  57. :workOrderId="item.workOrderId"
  58. :list="item.modelList"
  59. @scanIt="scanIt"
  60. :pattern="'feed'"
  61. >
  62. </modelBom>
  63. <instanceBom
  64. v-if="item.instanceList.length != 0"
  65. :workOrderId="item.workOrderId"
  66. :list="item.instanceList"
  67. :equipmentList="item.equipmentList"
  68. :currentTaskDiagram="item.currentTaskDiagram"
  69. :workInfo="item"
  70. >
  71. </instanceBom>
  72. <!-- 物料明细 -->
  73. <semiProductBom
  74. v-if="item.semiProductList.length != 0"
  75. :workOrderId="item.workOrderId"
  76. :list="item.semiProductList"
  77. :equipmentList="item.equipmentList"
  78. :currentTaskDiagram="item.currentTaskDiagram"
  79. :workInfo="item"
  80. ></semiProductBom>
  81. <!-- 11 周转车 -->
  82. <turnoverBom
  83. v-if="item.turnover.length != 0"
  84. :list="item.turnover"
  85. :wordItem="item"
  86. pattern="feed"
  87. @handleScan="handleScan"
  88. @handleDel="handleDel"
  89. :productsObj="item.product"
  90. ></turnoverBom>
  91. <aridRegion
  92. v-if="item.aridRegionList.length != 0"
  93. :list="item.aridRegionList"
  94. @handleScan="handleScan"
  95. ></aridRegion>
  96. <palletBom
  97. v-if="item.palletList.length != 0"
  98. :palletList="item.palletList"
  99. ></palletBom>
  100. <revolvingDiskBom
  101. v-if="item.revolvingDiskList.length != 0"
  102. :revolvingDiskList="item.revolvingDiskList"
  103. ></revolvingDiskBom>
  104. <!-- 包装投料 -->
  105. <packingBom
  106. v-if="item.packingList.length != 0"
  107. :list="item.packingList"
  108. ></packingBom>
  109. <view :class="[operateBtn ? 'flex_btn' : 'flex_btn2']">
  110. <image
  111. v-if="operateBtn"
  112. class="jiantou"
  113. src="../../../static/rightJt.png"
  114. @click="operateBtn = false"
  115. >
  116. </image>
  117. <view class="close_box" @click="operateBtn = true">
  118. <image
  119. v-if="!operateBtn"
  120. class="close"
  121. src="../../../static/close.png"
  122. ></image>
  123. </view>
  124. <view v-if="!operateBtn" @click="openDetails(item.workOrderId)"
  125. >出库单</view
  126. >
  127. <view v-if="!operateBtn" @click="removeCacheFn()">清空缓存</view>
  128. </view>
  129. <view :class="[idsList.length == 1 ? 'operate_box' : 'operate_box2']">
  130. <u-button
  131. size="small"
  132. class="u-reset-button"
  133. type="success"
  134. @click="handAdd(item.workOrderId)"
  135. >手动添加</u-button
  136. >
  137. <u-button
  138. size="small"
  139. class="u-reset-button"
  140. type="success"
  141. @click="scanIt(item.workOrderId)"
  142. >扫一扫</u-button
  143. >
  144. </view>
  145. </view>
  146. </u-list>
  147. </view>
  148. <view class="bottom-wrapper">
  149. <view class="btn_box" @click="save(1)">缓存</view>
  150. <view class="btn_box" @click="save(2)">一键投料</view>
  151. </view>
  152. <view>
  153. <uni-popup ref="alertDialog" type="dialog">
  154. <uni-popup-dialog
  155. type="warning"
  156. cancelText="取消"
  157. confirmText="确定"
  158. title="提示"
  159. :content="titleText"
  160. @confirm="dialogConfirm"
  161. @close="dialogClose"
  162. ></uni-popup-dialog>
  163. </uni-popup>
  164. </view>
  165. </view>
  166. </template>
  167. <script>
  168. import workOrderBom from "./components/workOrderBom.vue"; //gd
  169. import deviceBom from "./components/deviceBom.vue"; //设备信息
  170. import modelBom from "./components/modelBom.vue"; //模具信息
  171. import instanceBom from "./components/instanceBom.vue";
  172. import semiProductBom from "./components/semiProductBom"; //半成品信息
  173. import aridRegion from "./components/aridRegion"; //干燥区
  174. import paramBom from "./components/paramBom.vue"; //
  175. import turnoverBom from "./components/turnoverBom.vue"; //周转车信息
  176. import packingBom from "./components/packingBom.vue"; //包装信息
  177. import productsBom from "./components/productsBom.vue"; //在制品信息
  178. import palletBom from "./components/palletBom"; //舟皿
  179. import revolvingDiskBom from "./components/revolvingDiskBom";
  180. import workInProgressList from "./components/workInProgressList.vue";
  181. import {
  182. workorderList,
  183. getByCode,
  184. scanLedger,
  185. feedSaveCache,
  186. feedGetCache,
  187. removeCache,
  188. } from "@/api/pda/workOrder.js";
  189. import { batchSave, checkRepeatFeed } from "@/api/pda/feeding.js";
  190. export default {
  191. components: {
  192. workOrderBom,
  193. deviceBom,
  194. modelBom,
  195. instanceBom,
  196. semiProductBom,
  197. aridRegion,
  198. paramBom,
  199. turnoverBom,
  200. packingBom,
  201. productsBom,
  202. palletBom,
  203. revolvingDiskBom,
  204. workInProgressList,
  205. },
  206. data() {
  207. return {
  208. title: "",
  209. idsList: [],
  210. List: [],
  211. taskId: null,
  212. type: "",
  213. clientEnvironmentId: null,
  214. operateBtn: true,
  215. cloneListNum: "",
  216. feedNeedEquipment: null, ////投料是否要添加生产设备1是0否
  217. taskType: "",
  218. titleText: "",
  219. };
  220. },
  221. onLoad(options) {
  222. console.log(options, "options");
  223. this.title = options.taskName ? options.taskName + "-投料" : "投料";
  224. let queryArray = decodeURIComponent(options.arr);
  225. this.idsList = JSON.parse(queryArray);
  226. this.taskId = options.taskId;
  227. this.taskName = options.taskName;
  228. this.type = options.type;
  229. // this.feedNeedEquipment = options.feedNeedEquipment;
  230. console.log(this.idsList, "onLoad");
  231. this.getList();
  232. this.clientEnvironmentId =
  233. uni.getStorageSync("userInfo") &&
  234. uni.getStorageSync("userInfo").clientEnvironmentId;
  235. },
  236. onShow() {
  237. uni.$off("setSelectList");
  238. uni.$on("setSelectList", (selectList, id) => {
  239. this.List.forEach((m) => {
  240. if (selectList.length) {
  241. let num = 0;
  242. selectList.map((v) => {
  243. if (v.extInfo.positionList && v.extInfo.positionList.length) {
  244. v.extInfo.positionList.map((d) => {
  245. if (m.code == d.workOrderCode) {
  246. console.log(d);
  247. num += d.quantity;
  248. }
  249. });
  250. }
  251. });
  252. if (m.product && num != 0) {
  253. this.cloneListNum = num;
  254. m.product.feedQuantity = num;
  255. }
  256. }
  257. if (m.workOrderId == id) {
  258. let modelList = []; // 模具
  259. let instanceList = []; // 投料
  260. let aridRegionList = []; // 干燥区
  261. let equipmentList = []; // 生产设备
  262. let palletList = []; // 舟皿
  263. let revolvingDiskList = []; // 周转盘
  264. let semiProductList = []; // 半成品
  265. let turnover = []; //周转车
  266. selectList.forEach((f) => {
  267. if (f.rootCategoryLevelId == 4) {
  268. equipmentList = equipmentList.concat(f);
  269. equipmentList.map((d) => {
  270. if (d.equipmentLabelJson.length) {
  271. d.equipmentLabelJson.map((v) => {
  272. if (v.SJSB) {
  273. d.isSJSB = v.SJSB;
  274. }
  275. });
  276. }
  277. });
  278. }
  279. if (f.rootCategoryLevelId == 5) {
  280. modelList = modelList.concat(f);
  281. } else if (f.rootCategoryLevelId == 1) {
  282. instanceList = instanceList.concat(f);
  283. } else if (f.rootCategoryLevelId == 11) {
  284. aridRegionList = aridRegionList.concat(f);
  285. } else if (f.rootCategoryLevelId == 7) {
  286. turnover = turnover.concat(f);
  287. } else if (f.rootCategoryLevelId == 8) {
  288. palletList = palletList.concat(f);
  289. } else if (f.rootCategoryLevelId == 26) {
  290. revolvingDiskList = revolvingDiskList.concat(f);
  291. } else if ([23, 2, 9, 28].includes(Number(f.rootCategoryLevelId))) {
  292. semiProductList = semiProductList.concat(f);
  293. }
  294. });
  295. this.$set(m, "modelList", modelList);
  296. this.$set(m, "instanceList", instanceList);
  297. this.$set(m, "aridRegionList", aridRegionList);
  298. this.$set(m, "equipmentList", equipmentList);
  299. this.$set(m, "turnover", turnover);
  300. this.$set(m, "palletList", palletList);
  301. this.$set(m, "revolvingDiskList", revolvingDiskList);
  302. this.$set(m, "semiProductList", semiProductList);
  303. }
  304. });
  305. });
  306. },
  307. methods: {
  308. scrolltolower() {},
  309. clonenember(e) {
  310. return JSON.parse(JSON.stringify(e));
  311. },
  312. async save(type) {
  313. console.log(this.List, "1231");
  314. if (this.clientEnvironmentId == 3) {
  315. for (let it of this.List) {
  316. if (
  317. it.currentTaskDiagram.isFirstTask == 1 &&
  318. it.instanceList.length == 0 &&
  319. it.semiProductList.length == 0
  320. ) {
  321. uni.showToast({
  322. title: `请先去领料`,
  323. icon: "none",
  324. });
  325. return false;
  326. }
  327. }
  328. // this.List.forEach((it) => {
  329. // console.log(
  330. // it.currentTaskDiagram.isFirstTask,
  331. // it.instanceList.length,
  332. // "ititit"
  333. // );
  334. // if (
  335. // it.currentTaskDiagram.isFirstTask == 1 &&
  336. // it.instanceList.length == 0
  337. // ) {
  338. // uni.showToast({
  339. // title: `请先领料`,
  340. // icon: "none",
  341. // });
  342. // console.log("1234");
  343. // return false;
  344. // }
  345. // });
  346. }
  347. for (let i = 0; i < this.List.length; i++) {
  348. if (
  349. !this.List[i].executorTime &&
  350. this.List[i].executorTime == undefined
  351. ) {
  352. uni.showToast({
  353. title: `请先选择投料时间`,
  354. icon: "none",
  355. });
  356. return;
  357. }
  358. }
  359. this.List.forEach((f) => {
  360. this.$isJobExls(2, f);
  361. });
  362. this.List.forEach((f) => {
  363. f.instanceList.forEach((e) => {
  364. if (Object.prototype.hasOwnProperty.call(e, "type")) {
  365. e.extInfo["type"] = e.type;
  366. }
  367. e.extInfo["isConsumable"] = e.isConsumable;
  368. });
  369. });
  370. const isCache = await this.checkCache(type);
  371. if (!isCache) {
  372. return false;
  373. }
  374. if (
  375. this.clientEnvironmentId == 3 &&
  376. this.List[0].currentTaskDiagram.type == 1
  377. ) {
  378. if (
  379. this.List[0] &&
  380. this.List[0].executorTime &&
  381. this.List[0].executorTime != undefined
  382. ) {
  383. // 正则表达式1:匹配 yyyy-MM-dd 格式
  384. let dateRegex = /^\d{4}-\d{2}-\d{2}$/;
  385. if (dateRegex.test(this.List[0].executorTime.trimRight())) {
  386. this.List[0].executorTime = this.List[0].executorTime + " 00:00:00";
  387. }
  388. } else {
  389. uni.showToast({
  390. title: `请先选择时间投料时间`,
  391. icon: "none",
  392. });
  393. return false;
  394. }
  395. }
  396. if (this.clientEnvironmentId !== 9 && this.feedNeedEquipment == 1) {
  397. const isDevice = await this.checkdDevice();
  398. if (!isDevice) {
  399. return;
  400. }
  401. }
  402. // item.equipmentList
  403. // 索尔环境下,需要填写炉次号
  404. if (this.clientEnvironmentId === 2) {
  405. if (this.List[0].equipmentList.length) {
  406. if (!this.equipmentListList("heatNumber")) {
  407. return uni.showToast({
  408. title: `请填写炉次号`,
  409. icon: "none",
  410. });
  411. }
  412. }
  413. }
  414. let newList = [];
  415. for (let item of this.List) {
  416. newList.push({
  417. currentTaskDiagram: item.currentTaskDiagram,
  418. workOrderId: item.workOrderId,
  419. });
  420. }
  421. await checkRepeatFeed(newList).then((res) => {
  422. if (res.length != 0) {
  423. this.checkFeed(res);
  424. }
  425. });
  426. },
  427. checkFeed(list) {
  428. for (let item of list) {
  429. if (item.feedFormed != "0") {
  430. this.titleText = `工单号${item.workOrderCode}已有投料,是否继续重复投料?`;
  431. this.$refs.alertDialog.open();
  432. } else {
  433. this.feedReport();
  434. }
  435. }
  436. },
  437. dialogClose() {},
  438. dialogConfirm() {
  439. this.feedReport();
  440. },
  441. feedReport() {
  442. batchSave(this.List).then((res) => {
  443. // 江南环境
  444. if (this.clientEnvironmentId == 9) {
  445. uni.redirectTo({
  446. url: `/pages/pda/workOrder/extrusionMolding/index?id=${this.idsList}`,
  447. });
  448. } else {
  449. uni.redirectTo({
  450. url: `/pages/pda/feeding/index/index?feedStatus=1`,
  451. });
  452. }
  453. });
  454. },
  455. equipmentListList(propertyName) {
  456. return this.List.every((f) => {
  457. if (f.equipmentList && f.equipmentList.length > 0) {
  458. return f.equipmentList.every((obj) => {
  459. // 检查属性存在且不为空(null, undefined, 空字符串等)
  460. return (
  461. obj.extInfo.hasOwnProperty(propertyName) &&
  462. obj.extInfo[propertyName] !== null &&
  463. obj.extInfo[propertyName] !== undefined &&
  464. obj.extInfo[propertyName] !== ""
  465. );
  466. });
  467. }
  468. });
  469. },
  470. checkCache(type) {
  471. uni.hideLoading();
  472. return new Promise((resolve) => {
  473. if (type == 1) {
  474. feedSaveCache(this.List).then((rr) => {
  475. uni.showToast({
  476. title: `已经缓存`,
  477. icon: "none",
  478. });
  479. });
  480. resolve(false);
  481. } else if (type == 2) {
  482. resolve(true);
  483. }
  484. });
  485. },
  486. getList() {
  487. workorderList({
  488. ids: this.idsList,
  489. taskId: this.taskId,
  490. })
  491. .then((res) => {
  492. this.List = res.map((m) => {
  493. m.workOrderId = m.id;
  494. m.instanceList = []; // 物料
  495. // m.equipmentList = [] // 设备
  496. m.modelList = []; // 模具
  497. m.aridRegionList = []; // 干燥区
  498. m.packingList = []; // 包装
  499. m.palletList = []; // 舟皿
  500. m.revolvingDiskList = []; // 周转盘
  501. m.semiProductList = []; //半成品
  502. if (m.pickOutInList.length > 0) {
  503. m.pickOutInList.forEach((f) => {
  504. if (f.rootCategoryLevelId == 1) {
  505. m.instanceList.push(f);
  506. } else if (f.rootCategoryLevelId == 4) {
  507. m.modelList.push(f);
  508. } else if (f.rootCategoryLevelId == 5) {
  509. m.modelList.push(f);
  510. } else if (f.rootCategoryLevelId == 11) {
  511. m.aridRegionList.push(f);
  512. } else if (f.rootCategoryLevelId == 13) {
  513. m.packingList.push(f);
  514. } else if (f.rootCategoryLevelId == 8) {
  515. m.palletList.push(f);
  516. } else if (f.rootCategoryLevelId == 26) {
  517. m.revolvingDiskList.push(f);
  518. } else if (
  519. [23, 2, 9, 28].includes(Number(f.rootCategoryLevelId))
  520. ) {
  521. m.semiProductList.push(f);
  522. }
  523. });
  524. }
  525. // 处理字段
  526. m.quality == "" ? (m.quality = {}) : "";
  527. if (!Object.prototype.hasOwnProperty.call(m, "product")) {
  528. m.product = "{}";
  529. }
  530. delete m.id;
  531. if (this.taskId) {
  532. m.taskId = this.taskId;
  533. m.taskName = this.taskName;
  534. }
  535. return {
  536. ...m,
  537. };
  538. });
  539. this.cloneList = JSON.parse(JSON.stringify(this.List));
  540. this.feedNeedEquipment =
  541. this.List[0].currentTaskDiagram.feedNeedEquipment;
  542. })
  543. .finally(() => {
  544. this.getCacheFn();
  545. });
  546. },
  547. handleScan(id, type) {
  548. uni.scanCode({
  549. success: (res) => {
  550. this.scanData(res.result, type, id);
  551. },
  552. });
  553. },
  554. scanData(result, type, id) {
  555. if (type == "wordOrder") {
  556. let isFals = this.List.some((m) => m.code == result);
  557. if (isFals) {
  558. uni.showToast({
  559. title: "工单已存在",
  560. icon: "none",
  561. });
  562. return false;
  563. }
  564. getByCode(result).then((res) => {
  565. let _arr = this.List;
  566. _arr.forEach((e, index) => {
  567. if (e.workOrderId == id && res) {
  568. _arr[index] = res;
  569. }
  570. });
  571. this.List = _arr;
  572. this.$forceUpdate();
  573. });
  574. }
  575. },
  576. scanIt(id) {
  577. uni.scanCode({
  578. success: (res) => {
  579. this.scanItData(res.result, id);
  580. },
  581. });
  582. },
  583. scanItData(result, id) {
  584. scanLedger(result).then((res) => {
  585. let _arr = [];
  586. if (res.length == 1 && res[0].rootCategoryLevelId == 4) {
  587. // 设备
  588. _arr = this.List;
  589. _arr.forEach((e, index) => {
  590. if (e.workOrderId == id) {
  591. _arr[index].equipmentList = _arr[index].equipmentList.concat(res);
  592. }
  593. });
  594. this.List = _arr;
  595. this.$forceUpdate();
  596. } else if (res.length >= 1 && res[0].rootCategoryLevelId == 5) {
  597. // 模具
  598. _arr = this.List;
  599. _arr.forEach((e, index) => {
  600. if (e.workOrderId == id) {
  601. _arr[index].modelList = res;
  602. }
  603. });
  604. this.List = _arr;
  605. this.$forceUpdate();
  606. } else if (
  607. res.length >= 1 &&
  608. [1].includes(Number(res[0].rootCategoryLevelId))
  609. ) {
  610. // 物料
  611. _arr = this.List;
  612. _arr.forEach((e, index) => {
  613. if (e.workOrderId == id) {
  614. _arr[index].instanceList = _arr[index].instanceList.concat(res);
  615. }
  616. });
  617. this.List = _arr;
  618. this.$forceUpdate();
  619. } else if (
  620. res.length >= 1 &&
  621. [23, 2, 9, 28].includes(Number(res[0].rootCategoryLevelId))
  622. ) {
  623. _arr = this.List;
  624. _arr.forEach((e, index) => {
  625. if (e.workOrderId == id) {
  626. _arr[index].semiProductList =
  627. _arr[index].semiProductList.concat(res);
  628. }
  629. });
  630. this.List = _arr;
  631. this.$forceUpdate();
  632. } else if (res.length >= 1 && res[0].rootCategoryLevelId == 11) {
  633. // 干燥区
  634. _arr = this.List;
  635. _arr.forEach((e, index) => {
  636. if (e.workOrderId == id) {
  637. let isFals = _arr[index].aridRegionList.some(
  638. (m) => m.code == res[0].aridRegionList[0].code
  639. );
  640. if (isFals) {
  641. uni.showToast({
  642. title: "干燥区已存在",
  643. icon: "none",
  644. });
  645. return false;
  646. }
  647. let _obj = res[0].aridRegionList[0];
  648. if (_obj.status == 0) {
  649. _obj["name"] = res[0].name;
  650. _obj["region"] = res[0].extInfo.region;
  651. _arr[index].aridRegionList = _arr[index].aridRegionList.concat(
  652. res[0].aridRegionList
  653. );
  654. } else {
  655. uni.showToast({
  656. title: "干燥区已占用",
  657. icon: "none",
  658. });
  659. }
  660. }
  661. });
  662. this.List = _arr;
  663. this.$forceUpdate();
  664. } else if (res.length >= 1 && res[0].rootCategoryLevelId == 7) {
  665. // 周转车
  666. _arr = this.List;
  667. _arr.forEach((e, index) => {
  668. if (e.workOrderId == id) {
  669. let isFals = _arr[index].turnover.some(
  670. (m) => m.code == res[0].code
  671. );
  672. if (isFals) {
  673. uni.showToast({
  674. title: "周转车已存在",
  675. icon: "none",
  676. });
  677. return false;
  678. }
  679. _arr.forEach((e, index) => {
  680. if (e.workOrderId == id) {
  681. _arr[index].turnover = _arr[index].turnover.concat(res);
  682. }
  683. });
  684. this.List = _arr;
  685. this.$forceUpdate();
  686. }
  687. });
  688. }
  689. });
  690. },
  691. // 全部扫一扫
  692. handlScanCode() {
  693. uni.scanCode({
  694. success: (res) => {
  695. this.scanItAllData(res.result);
  696. },
  697. });
  698. },
  699. scanItAllData(result) {
  700. scanLedger(result).then((res) => {
  701. let _arr = [];
  702. if (res.length == 1 && res[0].rootCategoryLevelId == 4) {
  703. // 设备
  704. _arr = this.List;
  705. _arr.forEach((e, index) => {
  706. res["extInfo"].fixCode = res.fixCode;
  707. e.equipmentList = e.equipmentList.concat(res);
  708. });
  709. this.List = _arr;
  710. this.$forceUpdate();
  711. } else if (res.length >= 1 && res[0].rootCategoryLevelId == 5) {
  712. // 模具
  713. _arr = this.List;
  714. _arr.forEach((e, index) => {
  715. e.modelList = res;
  716. });
  717. this.List = _arr;
  718. this.$forceUpdate();
  719. } else if (
  720. res.length >= 1 &&
  721. [1].includes(Number(res[0].rootCategoryLevelId))
  722. ) {
  723. _arr = this.List;
  724. _arr.forEach((e, index) => {
  725. e.instanceList = e.instanceList.concat(res);
  726. });
  727. this.List = _arr;
  728. this.$forceUpdate();
  729. } else if (
  730. res.length >= 1 &&
  731. [23, 2, 9, 28].includes(Number(res[0].rootCategoryLevelId))
  732. ) {
  733. _arr = this.List;
  734. _arr.forEach((e, index) => {
  735. e.semiProductList = e.semiProductList.concat(res);
  736. });
  737. this.List = _arr;
  738. this.$forceUpdate();
  739. } else if (res.length >= 1 && res[0].rootCategoryLevelId == 7) {
  740. // 周转车
  741. _arr = this.List;
  742. if (_arr.length == 1) {
  743. _arr.forEach((e, index) => {
  744. e.turnover = e.turnover.concat(res);
  745. });
  746. this.List = _arr;
  747. this.$forceUpdate();
  748. } else if (_arr.length > 1) {
  749. uni.showToast({
  750. title: "多个工单通过下面单个扫一扫添加",
  751. icon: "none",
  752. });
  753. }
  754. }
  755. });
  756. },
  757. getCacheFn() {
  758. let parma = {
  759. workOrderIds: this.idsList,
  760. taskId: this.taskId,
  761. type: 2,
  762. };
  763. feedGetCache(parma).then((res) => {
  764. if (res.length == 0) {
  765. return false;
  766. }
  767. let objList = res[0].extInfo.objList;
  768. this.List.forEach((f) => {
  769. objList.forEach((o) => {
  770. if (f.workOrderId == o.workOrderId && f.taskId == o.taskId) {
  771. // f['instanceList'] = o.instanceList || [] // 实例
  772. f["equipmentList"] = o.equipmentList || []; // 设备
  773. f["modelList"] = o.modelList || []; // 模具
  774. f["aridRegionList"] = o.aridRegionList || []; // 干燥区
  775. f["packingList"] = o.packingList || []; // 包装
  776. f["palletList"] = o.palletList || []; //舟皿
  777. f["instanceList"] = o.instanceList || []; // 物料
  778. f["revolvingDiskList"] = o.revolvingDiskList || []; // 周转盘
  779. f["semiProductList"] = o.semiProductList || []; // 半成品
  780. f["turnover"] = o.turnover || []; // 周转车
  781. this.$forceUpdate();
  782. }
  783. });
  784. });
  785. });
  786. },
  787. removeCacheFn() {
  788. uni.showModal({
  789. title: "缓存",
  790. content: "是否清空缓存!",
  791. confirmText: "确认", //这块是确定按钮的文字
  792. success: (rr) => {
  793. if (rr.confirm) {
  794. let parma = {
  795. workOrderIds: this.idsList,
  796. taskId: this.taskId,
  797. type: 2,
  798. };
  799. removeCache(parma).then((res) => {
  800. this.getList();
  801. });
  802. }
  803. },
  804. });
  805. },
  806. handAdd(id) {
  807. const storageKey = Date.now() + "";
  808. uni.setStorageSync(storageKey, this.List || []);
  809. uni.navigateTo({
  810. url: `/pages/pda/workOrder/search/index?id=${id}&storageKey=${storageKey}&isType=feed&taskId=${this.taskId}`,
  811. });
  812. },
  813. openDetails(id) {
  814. const storageKey = Date.now() + "";
  815. uni.setStorageSync(storageKey, this.List || []);
  816. let url = `/pages/pda/feeding/single?id=${id}&taskId=${this.taskId}&storageKey=${storageKey}`;
  817. uni.navigateTo({
  818. url,
  819. });
  820. },
  821. checkdDevice() {
  822. return new Promise((resolve) => {
  823. console.log(this.List);
  824. let isFalse = this.List.every((item) => {
  825. return item.equipmentList && item.equipmentList.length > 0;
  826. });
  827. if (isFalse) {
  828. resolve(true);
  829. } else {
  830. uni.showToast({
  831. title: "请添加设备",
  832. icon: "none", // 可选值:'success', 'loading', 'none'
  833. duration: 3000, // 持续时间,单位ms
  834. });
  835. resolve(false);
  836. // uni.showModal({
  837. // title: '提示',
  838. // content: '没有选择设备,是否继续?',
  839. // confirmText: '确认', //这块是确定按钮的文字
  840. // success: function (res) {
  841. // if (res.confirm) {
  842. // resolve(true)
  843. // } else {
  844. // resolve(false)
  845. // }
  846. // }
  847. // })
  848. }
  849. });
  850. },
  851. },
  852. beforeDestroy() {
  853. uni.hideLoading();
  854. },
  855. };
  856. </script>
  857. <style lang="scss" scoped>
  858. .content-box {
  859. height: 100vh;
  860. overflow: hidden;
  861. display: flex;
  862. flex-direction: column;
  863. }
  864. .list_box {
  865. flex: 1;
  866. overflow: hidden;
  867. padding: 4rpx 0;
  868. .u-list {
  869. height: 100% !important;
  870. }
  871. .card_box {
  872. padding: 16rpx;
  873. }
  874. }
  875. .bottom-wrapper {
  876. width: 100%;
  877. display: flex;
  878. align-items: center;
  879. justify-content: space-around;
  880. .btn_box {
  881. width: 50%;
  882. height: 88rpx;
  883. line-height: 88rpx;
  884. background: $theme-color;
  885. text-align: center;
  886. font-size: 36rpx;
  887. font-style: normal;
  888. font-weight: 400;
  889. color: #fff;
  890. &:first-child {
  891. border-right: 2rpx solid #fff;
  892. }
  893. }
  894. }
  895. .operate_box {
  896. position: fixed;
  897. right: 0;
  898. top: 400rpx;
  899. /deep/ .u-button {
  900. margin-top: 20rpx;
  901. width: 150rpx;
  902. border-radius: 22rpx 0 0 22rpx;
  903. opacity: 0.6;
  904. font-size: 22rpx;
  905. }
  906. }
  907. .operate_box2 {
  908. display: flex;
  909. /deep/ .u-button {
  910. margin-top: 20rpx;
  911. width: 150rpx;
  912. }
  913. }
  914. .flex_btn {
  915. position: fixed;
  916. right: 0;
  917. bottom: 160rpx;
  918. width: 40rpx;
  919. height: 50rpx;
  920. line-height: 66rpx;
  921. border-radius: 22rpx 0 0 22rpx;
  922. background: $theme-color;
  923. text-align: center;
  924. font-size: 22rpx;
  925. font-style: normal;
  926. font-weight: 400;
  927. color: #fff;
  928. opacity: 0.6;
  929. .jiantou {
  930. width: 30rpx;
  931. height: 30rpx;
  932. }
  933. }
  934. .flex_btn2 {
  935. position: fixed;
  936. right: 0;
  937. bottom: 160rpx;
  938. width: 126rpx;
  939. min-height: 140rpx;
  940. line-height: 62rpx;
  941. border-radius: 22rpx 0 0 22rpx;
  942. background: $theme-color;
  943. text-align: center;
  944. font-size: 22rpx;
  945. font-style: normal;
  946. font-weight: 400;
  947. color: #fff;
  948. opacity: 0.7;
  949. .close_box {
  950. height: 50rpx;
  951. line-height: 50rpx;
  952. width: 126rpx;
  953. text-align: left;
  954. .close {
  955. width: 40rpx;
  956. height: 40rpx;
  957. padding: 6rpx 10rpx;
  958. }
  959. }
  960. }
  961. </style>