batchJobBom.vue 31 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119
  1. <template>
  2. <view>
  3. <!-- 单个报工 -->
  4. <view class="title_box rx-bc">
  5. <view class="name">报工信息</view>
  6. </view>
  7. <view class="material">
  8. <view class="content_table">
  9. <!-- <view class="item rx-sc">
  10. <view class="rx ">
  11. <view class="lable lable150 rx-cc ">报工数量</view>
  12. <view class="content">
  13. {{ tableData.length || 0 }}
  14. </view>
  15. </view>
  16. </view> -->
  17. <!-- <view class="item rx-sc">
  18. <view class="rx ww55">
  19. <view class="lable lable150 rx-cc">要求生产数量</view>
  20. <view class="content rx-sc">
  21. <view>{{ item.formingNum }}</view>
  22. <view class="unit">{{ item.unit }}</view>
  23. </view>
  24. </view>
  25. <view class="rx ww45">
  26. <view class="lable rx-cc ww80">重量</view>
  27. <view class="content content_num">
  28. <view>{{ item.formingWeight }}</view>
  29. <view class="unit">{{ item.weightUnit }}</view>
  30. </view>
  31. </view>
  32. </view> -->
  33. <view class="item rx-sc">
  34. <view class="rx ww55">
  35. <view class="lable lable150 rx-cc">合格品数量</view>
  36. <view class="content content_num">
  37. <input
  38. class="uni-input"
  39. v-model="item.workReportInfo.formedNum"
  40. :disabled="isDetails"
  41. @input="blurNum(item.workReportInfo)"
  42. type="digit"
  43. />
  44. <view class="unit">{{ item.unit }}</view>
  45. </view>
  46. </view>
  47. <view class="rx ww45">
  48. <view class="lable rx-cc ww80">重量</view>
  49. <view class="content content_num">
  50. <input
  51. class="uni-input"
  52. v-model="item.workReportInfo.formedWeight"
  53. type="digit"
  54. :disabled="isDetails"
  55. />
  56. <view class="unit">{{ item.weightUnit }}</view>
  57. </view>
  58. </view>
  59. </view>
  60. <!-- <view
  61. class="item rx-sc"
  62. v-for="(not, notIndex) in notFormedList"
  63. :key="notIndex"
  64. >
  65. <view class="rx ww55">
  66. <view class="lable lable150 rx-cc">不合格数量</view>
  67. <view class="content content_num">
  68. <input
  69. class="uni-input"
  70. v-model="item.workReportInfo.notFormedNum"
  71. type="digit"
  72. :disabled="isDetails"
  73. v-if="isDetails"
  74. @input="changeNum"
  75. />
  76. <input
  77. class="uni-input"
  78. v-model="not.notFormedNum"
  79. type="number"
  80. v-else
  81. @input="changeNum(not)"
  82. />
  83. <view class="unit">{{ item.unit }}</view>
  84. </view>
  85. </view>
  86. <view class="rx ww45">
  87. <view class="lable rx-cc ww80">重量</view>
  88. <view class="content content_num">
  89. <input
  90. class="uni-input"
  91. v-model="item.workReportInfo.notFormedWeight"
  92. type="digit"
  93. :disabled="isDetails"
  94. v-if="isDetails"
  95. />
  96. <input
  97. class="uni-input"
  98. v-model="not.notFormedWeight"
  99. type="digit"
  100. :disabled="isDetails"
  101. v-else
  102. />
  103. <view class="unit">{{ item.weightUnit }}</view>
  104. </view>
  105. </view>
  106. </view> -->
  107. <view class="item rx-sc">
  108. <view class="rx ww55">
  109. <view class="lable lable150 rx-cc">不合格数量</view>
  110. <view class="content content_num">
  111. <!-- //详情 -->
  112. <input
  113. class="uni-input"
  114. v-model="item.workReportInfo.notFormedNum"
  115. type="digit"
  116. :disabled="isDetails"
  117. @input="changeNum(item.workReportInfo.notFormedNum)"
  118. />
  119. <view class="unit">{{ item.unit }}</view>
  120. </view>
  121. </view>
  122. <view class="rx ww45">
  123. <view class="lable rx-cc ww80">重量</view>
  124. <view class="content content_num">
  125. <input
  126. class="uni-input"
  127. v-model="item.workReportInfo.notFormedWeight"
  128. type="digit"
  129. :disabled="isDetails"
  130. />
  131. <view class="unit">{{ item.weightUnit }}</view>
  132. </view>
  133. </view>
  134. </view>
  135. <view class="item rx-sc">
  136. <view class="rx ww55">
  137. <view class="lable lable150 rx-cc">损耗数量</view>
  138. <view class="content content_num">
  139. <!-- //详情 -->
  140. <input
  141. class="uni-input"
  142. v-model="item.workReportInfo.lossQuantity"
  143. type="digit"
  144. :disabled="isDetails"
  145. @input="changeNum(item.workReportInfo.lossQuantity)"
  146. />
  147. <view class="unit">{{ item.unit }}</view>
  148. </view>
  149. </view>
  150. <view class="rx ww45">
  151. <view class="lable rx-cc ww80">重量</view>
  152. <view class="content content_num">
  153. <input
  154. class="uni-input"
  155. v-model="item.workReportInfo.lossWeight"
  156. type="digit"
  157. :disabled="isDetails"
  158. />
  159. <view class="unit">{{ item.weightUnit }}</view>
  160. </view>
  161. </view>
  162. </view>
  163. <view class="item rx-sc">
  164. <view class="rx ww55">
  165. <view class="lable lable150 rx-cc">报工备注</view>
  166. <view class="content content_num" style="width: 100%">
  167. <input
  168. class="uni-input"
  169. v-model="item.workReportInfo.remark"
  170. :disabled="isDetails"
  171. type="text"
  172. />
  173. </view>
  174. </view>
  175. <!-- v-if="clientEnvironmentId==2" -->
  176. <view class="rx ww45" v-if="clientEnvironmentId == 2">
  177. <view class="lable ww80 rx-cc">批次号</view>
  178. <view class="content content_num" style="width: 100%">
  179. {{ item.batchNo }}
  180. <input
  181. class="uni-input"
  182. v-model="batchNo"
  183. @input="batchNoNew"
  184. :disabled="isDetails"
  185. type="text"
  186. />
  187. </view>
  188. </view>
  189. <!-- 不是首工序展示这个按钮 -->
  190. <view
  191. class="unit-btn"
  192. @click="singleBatch"
  193. v-if="
  194. item.currentTaskDiagram &&
  195. item.currentTaskDiagram.isFirstTask == 1 &&
  196. clientEnvironmentId != 3 &&
  197. item.product &&
  198. item.product.length == 0
  199. "
  200. >创建在制品</view
  201. >
  202. <view
  203. class="unit-btn"
  204. @click="singleBatchTg"
  205. v-if="
  206. item.currentTaskDiagram &&
  207. item.currentTaskDiagram.isFirstTask == 1 &&
  208. clientEnvironmentId == 3 &&
  209. item.semiProductList &&
  210. item.semiProductList.length == 0
  211. "
  212. >创建在制品</view
  213. >
  214. </view>
  215. </view>
  216. <view class="content_table">
  217. <!-- <batchProductJobBom
  218. v-if="
  219. item.product &&
  220. item.product.length &&
  221. item.currentTaskDiagram.type != 4 &&
  222. item.currentTaskDiagram.type != 6 &&
  223. item.singleReport == 0
  224. "
  225. :item="item"
  226. :list="item.product"
  227. :equipmentList="item.equipmentList"
  228. @countNumPl="countNumPl"
  229. >
  230. </batchProductJobBom> -->
  231. <batchProductJobBom
  232. v-if="clientEnvironmentId != 3 && item.product && item.product.length"
  233. :item="item"
  234. :list="item.product"
  235. :equipmentList="item.equipmentList"
  236. @countNumPl="countNumPl"
  237. >
  238. </batchProductJobBom>
  239. <!-- <semiProductJobBomPL
  240. v-if="
  241. clientEnvironmentId == 3 &&
  242. item.semiProductList &&
  243. item.semiProductList.length
  244. "
  245. :item="item"
  246. :list="item.semiProductList"
  247. :equipmentList="item.equipmentList"
  248. @countNumPl="countNumPl"
  249. >
  250. </semiProductJobBomPL> -->
  251. <!-- <batchProductJobBom
  252. v-if="
  253. item.product &&
  254. item.product.length &&
  255. item.currentTaskDiagram &&
  256. (item.currentTaskDiagram.type == 2 ||
  257. item.currentTaskDiagram.type == 3 ||
  258. item.currentTaskDiagram.type == 6) &&
  259. item.singleReport == 0
  260. "
  261. :item="item"
  262. :list="item.product"
  263. :equipmentList="item.equipmentList"
  264. @countNumPl="countNumPl"
  265. >
  266. </batchProductJobBom> -->
  267. </view>
  268. </view>
  269. </view>
  270. </template>
  271. <script>
  272. import {
  273. createInProductBatch,
  274. createInProductBatchTG,
  275. } from "@/api/pda/jobBooking.js";
  276. // import checkboxTable from '../componentsTable/checkbox/checkbox.vue'
  277. import batchProductJobBom from "./batchProductJobBom.vue";
  278. import semiProductJobBomPL from "./semiProductJobBomPL.vue";
  279. export default {
  280. props: {
  281. item: {
  282. type: Object,
  283. default: () => {},
  284. },
  285. notFormed: {
  286. type: Array,
  287. default: () => [],
  288. },
  289. isDetails: {
  290. type: Boolean,
  291. default: false,
  292. },
  293. currentTask: {
  294. type: Object,
  295. default: () => {},
  296. },
  297. },
  298. watch: {
  299. notFormed: {
  300. immediate: true,
  301. deep: true,
  302. handler(newVal) {
  303. this.notFormedList = newVal;
  304. },
  305. },
  306. item: {
  307. immediate: true,
  308. deep: true,
  309. handler(newVal) {
  310. console.log(newVal, "newVal");
  311. if (newVal.product && newVal.product.length !== 0) {
  312. const product = newVal.product;
  313. const finalList = product.some((it) => it.confirm == 1)
  314. ? product.filter((it) => it.confirm == 1)
  315. : product;
  316. const isLoss = (item) => item.extInfo.isLoss == 1;
  317. const isFormed = (item) => {
  318. const { isQualified, notType } = item.extInfo;
  319. return (
  320. !isQualified ||
  321. isQualified == 1 ||
  322. isQualified == 3 ||
  323. notType == 5 ||
  324. notType == 8
  325. );
  326. };
  327. const getQty = (item) => Number(item.feedQuantity);
  328. const result = finalList.reduce(
  329. (acc, item) => {
  330. const qty = getQty(item);
  331. if (isLoss(item)) {
  332. acc.lossNum = this.add(acc.lossNum, qty);
  333. } else if (isFormed(item)) {
  334. acc.formedNum = this.add(acc.formedNum, qty);
  335. } else {
  336. acc.notFormedNum = this.add(acc.notFormedNum, qty);
  337. }
  338. return acc;
  339. },
  340. { formedNum: 0, notFormedNum: 0, lossNum: 0 }
  341. );
  342. this.$set(this.item.workReportInfo, "formedNum", result.formedNum);
  343. this.$set(
  344. this.item.workReportInfo,
  345. "notFormedNum",
  346. result.notFormedNum
  347. );
  348. this.$set(this.item.workReportInfo, "lossQuantity", result.lossNum);
  349. this.$forceUpdate();
  350. }
  351. // if (newVal.product && newVal.product.length != 0) {
  352. // let formedNum = 0;
  353. // let notFormedNum = 0;
  354. // let lossNum = 0;
  355. // newVal.product.forEach((item) => {
  356. // if (
  357. // (!item.extInfo.isQualified ||
  358. // item.extInfo.isQualified == 1 ||
  359. // item.extInfo.isQualified == 3) &&
  360. // !item.extInfo.isLoss
  361. // ) {
  362. // formedNum = formedNum + Number(item.feedQuantity);
  363. // // formedNum = this.add(formedNum, Number(item.feedQuantity));
  364. // } else if (!item.extInfo.isLoss) {
  365. // if (item.extInfo.notType == 5 || item.extInfo.notType == 8) {
  366. // formedNum = formedNum + Number(item.feedQuantity);
  367. // // formedNum = this.add(formedNum, Number(item.feedQuantity));
  368. // } else {
  369. // notFormedNum = notFormedNum + Number(item.feedQuantity);
  370. // // if (!item.extInfo.isLoss) {
  371. // // notFormedNum = this.add(
  372. // // notFormedNum,
  373. // // Number(item.feedQuantity)
  374. // // );
  375. // // }
  376. // }
  377. // } else if (item.extInfo.isLoss == 1) {
  378. // // lossNum = this.add(lossNum, Number(item.feedQuantity));
  379. // lossNum = lossNum + Number(item.feedQuantity);
  380. // }
  381. // });
  382. // console.log(formedNum, "formedNumformedNumformedNum");
  383. // this.$set(this.item.workReportInfo, "formedNum", formedNum);
  384. // this.$set(this.item.workReportInfo, "notFormedNum", notFormedNum);
  385. // this.$set(this.item.workReportInfo, "lossQuantity", lossNum);
  386. // // console.log(this.item.workReportInfo);
  387. // this.item.workReportInfo = this.deepCopy(this.item.workReportInfo);
  388. // this.$forceUpdate();
  389. // }
  390. // if (
  391. // this.clientEnvironmentId == 3 &&
  392. // newVal.semiProductList &&
  393. // newVal.semiProductList.length != 0
  394. // ) {
  395. // let formedNum = 0;
  396. // let notFormedNum = 0;
  397. // newVal.semiProductList.forEach((item) => {
  398. // if (
  399. // !item.extInfo.isQualified ||
  400. // item.extInfo.isQualified == 1 ||
  401. // item.extInfo.isQualified == 3
  402. // ) {
  403. // formedNum = formedNum + Number(item.feedQuantity);
  404. // } else {
  405. // notFormedNum = notFormedNum + Number(item.feedQuantity);
  406. // }
  407. // });
  408. // console.log("合格数量:" + formedNum, "不合格数量:" + notFormedNum);
  409. // this.$set(this.item.workReportInfo, "formedNum", formedNum);
  410. // this.$set(this.item.workReportInfo, "notFormedNum", notFormedNum);
  411. // this.item.workReportInfo = this.deepCopy(this.item.workReportInfo);
  412. // this.$forceUpdate();
  413. // }
  414. // if (!this.currentTaskDiagram.isFirstTask) {
  415. // this.getSemiProductList(newVal);
  416. // }
  417. },
  418. },
  419. },
  420. components: { semiProductJobBomPL, batchProductJobBom },
  421. data() {
  422. return {
  423. forValue: {},
  424. tableData: [],
  425. batchNo: "",
  426. notFormedList: [],
  427. clientEnvironmentId:
  428. uni.getStorageSync("userInfo") &&
  429. uni.getStorageSync("userInfo").clientEnvironmentId, // *1 主环境-601环境 2 soll-索尔环境 3 tg-碳谷环境
  430. };
  431. },
  432. created() {
  433. console.log(this.item, "item13131223223");
  434. // this.item.product = this.item.pickOutInList;
  435. let newList = [];
  436. if (
  437. this.item.pickOutInList.length != 0 &&
  438. this.item.product.length == 0 &&
  439. this.item.currentTaskDiagram.type == 6
  440. ) {
  441. this.item.pickOutInList.forEach((item) => {
  442. const data = this.deepCopy(item);
  443. newList.push(data);
  444. });
  445. this.$set(this.item, "product", newList);
  446. }
  447. // this.item.product.push(...newList);
  448. // console.log(this.item.product, "this.item.product");
  449. // this.item.pickOutInList = [];
  450. // this.$set(this.item, "product", ...newList);
  451. // this.$set(this.item, "pickOutInList", []);
  452. // }
  453. if (this.isDetails) {
  454. this.notFormedList = this.notFormedList.map((m) => {
  455. return {
  456. notFormedNum: Number(m.quantity),
  457. notFormedWeight: m.weight,
  458. ...m,
  459. };
  460. });
  461. }
  462. this.getByCode();
  463. },
  464. methods: {
  465. tableDataFn(tableData) {
  466. console.log(tableData);
  467. let adultCount = 0;
  468. let noAdultCount = 0;
  469. this.arrDataStatistics(tableData);
  470. tableData.forEach((v) => {
  471. if (v.selected) {
  472. console.log(11111);
  473. if (v.extInfo.isQualified == 1) {
  474. adultCount += 1;
  475. } else {
  476. noAdultCount += 1;
  477. }
  478. }
  479. });
  480. this.$set(this.item.workReportInfo, "formedNum", adultCount);
  481. this.$set(this.item.workReportInfo, "notFormedNum", noAdultCount);
  482. // this.tableData = this.notFormedList;
  483. if (!(this.clientEnvironmentId == 3 || this.item.singleReport !== 1)) {
  484. this.item.semiProductList = tableData;
  485. }
  486. },
  487. deepCopy(obj, hash = new WeakMap()) {
  488. if (obj === null) return null;
  489. if (obj instanceof Date) return new Date(obj);
  490. if (obj instanceof RegExp) return new RegExp(obj);
  491. if (typeof obj !== "object" && typeof obj !== "function") return obj;
  492. if (hash.has(obj)) return hash.get(obj);
  493. const result = Array.isArray(obj) ? [] : {};
  494. hash.set(obj, result);
  495. return Object.keys(obj).reduce((acc, key) => {
  496. acc[key] = this.deepCopy(obj[key], hash);
  497. return acc;
  498. }, result);
  499. },
  500. arrDataStatistics(arr) {
  501. console.log(arr);
  502. const adultCount = arr.filter(
  503. (user) => user.extInfo.isQualified == 1
  504. ).length;
  505. const noAdultCount = arr.filter(
  506. (user) => user.extInfo.isQualified !== 1
  507. ).length;
  508. console.log(adultCount, noAdultCount);
  509. this.$set(this.item.workReportInfo, "formedNum", adultCount);
  510. this.$set(this.item.workReportInfo, "notFormedNum", noAdultCount);
  511. },
  512. getByCode() {},
  513. getSemiProductList(newVal) {
  514. console.log(newVal);
  515. if (newVal.semiProductList.length) {
  516. newVal.semiProductList.map((v) => {
  517. v.selected = true;
  518. });
  519. this.arrDataStatistics(newVal.semiProductList);
  520. this.tableData = newVal.semiProductList;
  521. }
  522. if (newVal.pickOutInList.length) {
  523. newVal.pickOutInList.map((v) => {
  524. v.selected = true;
  525. });
  526. this.arrDataStatistics(newVal.pickOutInList);
  527. this.tableData = newVal.pickOutInList;
  528. }
  529. },
  530. singleBatch() {
  531. console.log(this.item.workReportInfo, "11111111");
  532. if (!this.item.workReportInfo.formedNum)
  533. return uni.showToast({
  534. icon: "none",
  535. title: "请输入合格品数",
  536. });
  537. // if (
  538. // !this.item.workReportInfo.notFormedNum ||
  539. // this.item.workReportInfo.notFormedNum != 0
  540. // )
  541. // return uni.showToast({
  542. // icon: "none",
  543. // title: "请输入不合格品数",
  544. // });
  545. const req = {
  546. formedNum: this.item.workReportInfo.formedNum,
  547. notFormedNum: this.item.workReportInfo.notFormedNum || 0,
  548. taskId: this.item.workReportInfo.taskId,
  549. workOrderId: this.item.workReportInfo.workOrderId,
  550. };
  551. createInProductBatch(req).then((res) => {
  552. if (res && res.length) {
  553. this.forValue = res[0];
  554. res.map((v) => {
  555. v.selected = true;
  556. });
  557. this.tableData = res;
  558. this.item.product = res;
  559. console.log(this.item);
  560. }
  561. });
  562. },
  563. toInteger(num) {
  564. const len = this.getDecimalLength(num);
  565. return {
  566. int: Math.round(num * Math.pow(10, len)),
  567. factor: Math.pow(10, len),
  568. };
  569. },
  570. add(a, b) {
  571. const { int: aInt, factor: aFactor } = this.toInteger(a);
  572. const { int: bInt, factor: bFactor } = this.toInteger(b);
  573. const maxFactor = Math.max(aFactor, bFactor);
  574. return (
  575. (aInt * (maxFactor / aFactor) + bInt * (maxFactor / bFactor)) /
  576. maxFactor
  577. );
  578. },
  579. sub(a, b) {
  580. const { int: aInt, factor: aFactor } = this.toInteger(a);
  581. const { int: bInt, factor: bFactor } = this.toInteger(b);
  582. const maxFactor = Math.max(aFactor, bFactor);
  583. return (
  584. (aInt * (maxFactor / aFactor) - bInt * (maxFactor / bFactor)) /
  585. maxFactor
  586. );
  587. },
  588. getDecimalLength(num) {
  589. return (num.toString().split(".")[1] || "").length;
  590. },
  591. toInteger(num) {
  592. const len = this.getDecimalLength(num);
  593. return {
  594. int: Math.round(num * Math.pow(10, len)),
  595. factor: Math.pow(10, len),
  596. };
  597. },
  598. add(a, b) {
  599. const { int: aInt, factor: aFactor } = this.toInteger(a);
  600. const { int: bInt, factor: bFactor } = this.toInteger(b);
  601. const maxFactor = Math.max(aFactor, bFactor);
  602. return (
  603. (aInt * (maxFactor / aFactor) + bInt * (maxFactor / bFactor)) /
  604. maxFactor
  605. );
  606. },
  607. sub(a, b) {
  608. const { int: aInt, factor: aFactor } = this.toInteger(a);
  609. const { int: bInt, factor: bFactor } = this.toInteger(b);
  610. const maxFactor = Math.max(aFactor, bFactor);
  611. return (
  612. (aInt * (maxFactor / aFactor) - bInt * (maxFactor / bFactor)) /
  613. maxFactor
  614. );
  615. },
  616. getDecimalLength(num) {
  617. return (num.toString().split(".")[1] || "").length;
  618. },
  619. singleBatchTg() {
  620. if (!this.item.workReportInfo.formedNum)
  621. return uni.showToast({
  622. icon: "none",
  623. title: "请输入合格品数",
  624. });
  625. // if (
  626. // !this.item.workReportInfo.notFormedNum ||
  627. // this.item.workReportInfo.notFormedNum != 0
  628. // )
  629. // return uni.showToast({
  630. // icon: "none",
  631. // title: "请输入不合格品数",
  632. // });
  633. const req = {
  634. formedNum: this.item.workReportInfo.formedNum,
  635. notFormedNum: this.item.workReportInfo.notFormedNum || 0,
  636. taskId: this.item.workReportInfo.taskId,
  637. workOrderId: this.item.workReportInfo.workOrderId,
  638. };
  639. createInProductBatchTG(req).then((res) => {
  640. if (res && res.length) {
  641. this.forValue = res[0];
  642. res.map((v) => {
  643. v.selected = true;
  644. v.extInfo.batchReportInfo = [
  645. {
  646. allFeedQuantity: "",
  647. allReportWeight: "",
  648. taskId: "",
  649. taskName: "",
  650. },
  651. ];
  652. v.extInfo.notBatchReportInfo = [
  653. {
  654. allFeedQuantity: "",
  655. notType: "",
  656. taskId: "",
  657. taskName: "",
  658. notReason: "",
  659. },
  660. ];
  661. });
  662. this.list = res;
  663. this.item.semiProductList = res;
  664. }
  665. });
  666. // console.log(this.item, "this.itemthis.itemthis.itemthis.item12121");
  667. },
  668. /**
  669. * 更新批次号
  670. *
  671. * @param e 事件对象
  672. */
  673. batchNoNew(e) {
  674. this.item.workReportInfo.batchNo = this.item.batchNo + e.target.value;
  675. },
  676. setFormedNum(num) {
  677. this.item.workReportInfo.formedNum = num;
  678. let weight =
  679. Number(this.item.workReportInfo.formedNum) *
  680. Number(this.item.singleWeight) *
  681. Number(this.item.weightMultiple);
  682. if (["G", "g", "克"].includes(this.item.singleWeightUnit)) {
  683. weight = parseFloat((weight / 1000).toFixed(2));
  684. } else {
  685. weight = parseFloat(weight.toFixed(2));
  686. }
  687. this.$set(this.item.workReportInfo, "formedWeight", weight);
  688. this.$forceUpdate();
  689. },
  690. penalize() {
  691. this.$emit("penalize", null);
  692. },
  693. handleView(name) {
  694. uni.showToast({
  695. icon: "none",
  696. title: name || "未设置",
  697. });
  698. },
  699. blurNum(value) {
  700. let total = 0;
  701. //匹配非数字
  702. let val = value.formedNum;
  703. let reg = new RegExp("([^0-9]*)", "g");
  704. let ma = val.match(reg);
  705. //如果有非数字,替换成""
  706. if (ma.length > 0) {
  707. for (let k in ma) {
  708. if (ma[k] != "") {
  709. val = val.replace(ma[k], 0);
  710. }
  711. }
  712. }
  713. //可以为0,但不能以0开头
  714. if (val.startsWith("0") && val.length > 1) {
  715. val = val.substring(1, val.length);
  716. }
  717. value.formedNum = val;
  718. if (this.item.currentTaskDiagram.isFirstTask) {
  719. // formingNum 生产数量 feedQuantity this.item.product[0] //投料数量
  720. if (value.formedNum > this.item.formingNum) {
  721. this.$set(
  722. this.item.workReportInfo,
  723. "workReportInfo",
  724. this.item.formingNum
  725. );
  726. this.$set(this.item.workReportInfo, "notFormedNum", 0);
  727. this.notForme();
  728. return uni.showToast({
  729. icon: "none",
  730. title: "合格品数量不能大于要求生产数量",
  731. });
  732. }
  733. } else {
  734. if (this.item.product.length) {
  735. const feedNumber = this.item.product.reduce((acc, pre) => {
  736. return pre.feedQuantity ? acc + Number(pre.feedQuantity) : acc;
  737. }, 0);
  738. console.log(this.item, "this.item.product");
  739. if (value.formedNum > feedNumber) {
  740. this.$set(this.item.workReportInfo, "formedNum", feedNumber);
  741. this.$set(this.item.workReportInfo, "notFormedNum", 0);
  742. return uni.showToast({
  743. icon: "none",
  744. title: "合格品数量不能大于投料数量",
  745. });
  746. }
  747. // if (value.formedNum > this.item.product[0].feedQuantity) {
  748. // console.log(this.item.product[0].feedQuantity);
  749. // this.$set(
  750. // this.item.workReportInfo,
  751. // "workReportInfo",
  752. // this.item.product[0].feedQuantity
  753. // );
  754. // this.$set(this.notFormedList[0], "notFormedNum", 0);
  755. // this.notForme();
  756. // return uni.showToast({
  757. // icon: "none",
  758. // title: "合格品数量不能大于投料数量",
  759. // });
  760. // }
  761. }
  762. }
  763. console.log(
  764. Number(this.item.workReportInfo.formedNum),
  765. "Number(this.item.workReportInfo.feedQuantity)"
  766. );
  767. console.log(Number(value.formedNum), "Number(value.formedNum)");
  768. if (
  769. this.item.product[0] &&
  770. this.item.product[0].feedQuantity > 0 &&
  771. Number(this.item.workReportInfo.formedNum)
  772. ) {
  773. console.log("555555");
  774. this.$set(
  775. this.notFormedList[0],
  776. "notFormedNum",
  777. Number(value.formedNum) - Number(this.item.workReportInfo.formedNum)
  778. );
  779. this.notForme();
  780. }
  781. let weight =
  782. Number(this.item.workReportInfo.formedNum) *
  783. Number(this.item.singleWeight) *
  784. Number(this.item.weightMultiple);
  785. if (["G", "g", "克"].includes(this.item.singleWeightUnit)) {
  786. weight = parseFloat((weight / 1000).toFixed(2));
  787. } else {
  788. weight = parseFloat(weight.toFixed(2));
  789. }
  790. this.$set(this.item.workReportInfo, "formedWeight", weight);
  791. total =
  792. Number(this.item.workReportInfo.formedNum) +
  793. Number(this.item.workReportInfo.notFormedNum);
  794. console.log(total);
  795. this.$emit("modeNum", total);
  796. this.$forceUpdate();
  797. },
  798. notForme() {
  799. let weight =
  800. Number(this.item.workReportInfo.notFormedNum) *
  801. Number(this.item.singleWeight) *
  802. Number(this.item.weightMultiple);
  803. if (
  804. this.item.singleWeightUnit == "G" ||
  805. this.item.singleWeightUnit == "g" ||
  806. this.item.singleWeightUnit == "克"
  807. ) {
  808. weight = parseFloat((weight / 1000).toFixed(2));
  809. } else {
  810. weight = parseFloat(weight.toFixed(2));
  811. }
  812. this.$set(this.item.workReportInfo, "notFormedWeight", weight);
  813. // if (
  814. // this.item.product[0] &&
  815. // this.item.product[0].feedQuantity > 0 &&
  816. // Number(this.notFormedList[0].notFormedNum)
  817. // ) {
  818. // this.$set(
  819. // this.item.workReportInfo,
  820. // "formedNum",
  821. // this.item.product[0].feedQuantity -
  822. // Number(this.notFormedList[0].notFormedNum)
  823. // );
  824. // let weight =
  825. // Number(this.item.workReportInfo.formedNum) *
  826. // Number(this.item.singleWeight) *
  827. // Number(this.item.weightMultiple);
  828. // if (
  829. // this.item.singleWeightUnit == "G" ||
  830. // this.item.singleWeightUnit == "g" ||
  831. // this.item.singleWeightUnit == "克"
  832. // ) {
  833. // weight = parseFloat((weight / 1000).toFixed(2));
  834. // } else {
  835. // weight = parseFloat(weight.toFixed(2));
  836. // }
  837. // this.$set(this.item.workReportInfo, "formedWeight", weight);
  838. // }
  839. this.$forceUpdate();
  840. },
  841. changeNum(value) {
  842. // 不合格数量
  843. let val = value;
  844. //匹配非数字
  845. let reg = new RegExp("([^0-9]*)", "g");
  846. let ma = val.match(reg);
  847. //如果有非数字,替换成""
  848. if (ma.length > 0) {
  849. for (let k in ma) {
  850. if (ma[k] != "") {
  851. val = val.replace(ma[k], "0");
  852. }
  853. }
  854. }
  855. //可以为0,但不能以0开头
  856. if (val.startsWith("0") && val.length > 1) {
  857. val = val.substring(1, val.length);
  858. }
  859. // this.$set(this.item.workReportInfo, 'formedNum', val)
  860. value = val;
  861. console.log(Number(this.item.workReportInfo.formedNum), 1);
  862. console.log(Number(this.item.workReportInfo.notFormedNum), 2);
  863. let total =
  864. Number(this.item.workReportInfo.formedNum) +
  865. Number(this.item.workReportInfo.notFormedNum);
  866. console.log(total);
  867. this.$emit("modeNum", total);
  868. this.notForme();
  869. // this.blurNum()
  870. },
  871. },
  872. };
  873. </script>
  874. <style lang="scss" scoped>
  875. .unit-btn {
  876. background-color: #157a2c;
  877. height: 48rpx;
  878. padding: 0 20rpx;
  879. line-height: 48rpx;
  880. color: #fff;
  881. font-size: 12px;
  882. }
  883. .content_num {
  884. display: flex;
  885. align-items: center;
  886. padding: 0 4rpx;
  887. font-size: 26rpx !important;
  888. /deep/ .uni-input-input {
  889. border: 2rpx solid #f0f8f2;
  890. background: #f0f8f2;
  891. color: $theme-color;
  892. }
  893. }
  894. .item {
  895. display: flex;
  896. justify-content: space-between;
  897. }
  898. .title_box {
  899. margin-top: 20rpx;
  900. .name {
  901. font-size: 28rpx;
  902. font-style: normal;
  903. font-weight: 400;
  904. color: $theme-color;
  905. padding-left: 20rpx;
  906. position: relative;
  907. &:before {
  908. position: absolute;
  909. content: "";
  910. left: 0rpx;
  911. top: 0rpx;
  912. bottom: 0rpx;
  913. width: 4rpx;
  914. height: 28rpx;
  915. background: $theme-color;
  916. margin: auto;
  917. }
  918. }
  919. }
  920. .material {
  921. margin-top: 10rpx;
  922. .content_table {
  923. width: 100%;
  924. border: 2rpx solid $border-color;
  925. .item {
  926. display: flex;
  927. border-bottom: 2rpx solid $border-color;
  928. .lable {
  929. width: 132rpx;
  930. text-align: center;
  931. background-color: #f7f9fa;
  932. font-size: 26rpx;
  933. border-right: 2rpx solid $border-color;
  934. flex-shrink: 0;
  935. }
  936. .lable220 {
  937. width: 220rpx !important;
  938. font-size: 24rpx;
  939. }
  940. .lable150 {
  941. width: 156rpx !important;
  942. font-size: 24rpx;
  943. }
  944. .ww80 {
  945. width: 80rpx;
  946. }
  947. .content {
  948. width: 518rpx;
  949. min-height: 64rpx;
  950. font-size: 28rpx;
  951. line-height: 28rpx;
  952. font-style: normal;
  953. font-weight: 400;
  954. padding: 18rpx 8rpx;
  955. box-sizing: border-box;
  956. word-wrap: break-word;
  957. flex-grow: 1 !important;
  958. .unit {
  959. padding: 0 4rpx;
  960. font-size: 24rpx;
  961. color: #404446;
  962. }
  963. .penalize {
  964. width: 160rpx;
  965. line-height: 60rpx;
  966. background: $theme-color;
  967. font-size: 24rpx;
  968. text-align: center;
  969. color: #fff;
  970. }
  971. }
  972. .pd4 {
  973. padding: 4rpx 8rpx;
  974. }
  975. &:last-child {
  976. border-bottom: none;
  977. }
  978. }
  979. .ww55 {
  980. width: 55%;
  981. }
  982. .ww45 {
  983. width: 45%;
  984. }
  985. }
  986. }
  987. </style>