batchJobBom.vue 32 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141
  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. import { parameterGetByCode } from "@/api/mainData/index.js";
  280. export default {
  281. props: {
  282. item: {
  283. type: Object,
  284. default: () => {},
  285. },
  286. notFormed: {
  287. type: Array,
  288. default: () => [],
  289. },
  290. isDetails: {
  291. type: Boolean,
  292. default: false,
  293. },
  294. currentTask: {
  295. type: Object,
  296. default: () => {},
  297. },
  298. },
  299. watch: {
  300. notFormed: {
  301. immediate: true,
  302. deep: true,
  303. handler(newVal) {
  304. this.notFormedList = newVal;
  305. },
  306. },
  307. item: {
  308. immediate: true,
  309. deep: true,
  310. handler(newVal) {
  311. console.log(newVal, "newVal");
  312. if (newVal.product && newVal.product.length !== 0) {
  313. const product = newVal.product;
  314. const finalList = product.some((it) => it.confirm == 1)
  315. ? product.filter((it) => it.confirm == 1)
  316. : product;
  317. const isLoss = (item) => item.extInfo.isLoss == 1;
  318. const isFormed = (item) => {
  319. const { isQualified, notType } = item.extInfo;
  320. return (
  321. !isQualified ||
  322. isQualified == 1 ||
  323. isQualified == 3 ||
  324. notType == 5 ||
  325. notType == 8
  326. );
  327. };
  328. const getQty = (item) => Number(item.feedQuantity);
  329. const result = finalList.reduce(
  330. (acc, item) => {
  331. const qty = getQty(item);
  332. if (isLoss(item)) {
  333. acc.lossNum = this.add(acc.lossNum, qty);
  334. } else if (isFormed(item)) {
  335. acc.formedNum = this.add(acc.formedNum, qty);
  336. } else {
  337. acc.notFormedNum = this.add(acc.notFormedNum, qty);
  338. }
  339. return acc;
  340. },
  341. { formedNum: 0, notFormedNum: 0, lossNum: 0 }
  342. );
  343. this.$set(this.item.workReportInfo, "formedNum", result.formedNum);
  344. this.$set(
  345. this.item.workReportInfo,
  346. "notFormedNum",
  347. result.notFormedNum
  348. );
  349. this.$set(this.item.workReportInfo, "lossQuantity", result.lossNum);
  350. this.$forceUpdate();
  351. }
  352. // if (newVal.product && newVal.product.length != 0) {
  353. // let formedNum = 0;
  354. // let notFormedNum = 0;
  355. // let lossNum = 0;
  356. // newVal.product.forEach((item) => {
  357. // if (
  358. // (!item.extInfo.isQualified ||
  359. // item.extInfo.isQualified == 1 ||
  360. // item.extInfo.isQualified == 3) &&
  361. // !item.extInfo.isLoss
  362. // ) {
  363. // formedNum = formedNum + Number(item.feedQuantity);
  364. // // formedNum = this.add(formedNum, Number(item.feedQuantity));
  365. // } else if (!item.extInfo.isLoss) {
  366. // if (item.extInfo.notType == 5 || item.extInfo.notType == 8) {
  367. // formedNum = formedNum + Number(item.feedQuantity);
  368. // // formedNum = this.add(formedNum, Number(item.feedQuantity));
  369. // } else {
  370. // notFormedNum = notFormedNum + Number(item.feedQuantity);
  371. // // if (!item.extInfo.isLoss) {
  372. // // notFormedNum = this.add(
  373. // // notFormedNum,
  374. // // Number(item.feedQuantity)
  375. // // );
  376. // // }
  377. // }
  378. // } else if (item.extInfo.isLoss == 1) {
  379. // // lossNum = this.add(lossNum, Number(item.feedQuantity));
  380. // lossNum = lossNum + Number(item.feedQuantity);
  381. // }
  382. // });
  383. // console.log(formedNum, "formedNumformedNumformedNum");
  384. // this.$set(this.item.workReportInfo, "formedNum", formedNum);
  385. // this.$set(this.item.workReportInfo, "notFormedNum", notFormedNum);
  386. // this.$set(this.item.workReportInfo, "lossQuantity", lossNum);
  387. // // console.log(this.item.workReportInfo);
  388. // this.item.workReportInfo = this.deepCopy(this.item.workReportInfo);
  389. // this.$forceUpdate();
  390. // }
  391. // if (
  392. // this.clientEnvironmentId == 3 &&
  393. // newVal.semiProductList &&
  394. // newVal.semiProductList.length != 0
  395. // ) {
  396. // let formedNum = 0;
  397. // let notFormedNum = 0;
  398. // newVal.semiProductList.forEach((item) => {
  399. // if (
  400. // !item.extInfo.isQualified ||
  401. // item.extInfo.isQualified == 1 ||
  402. // item.extInfo.isQualified == 3
  403. // ) {
  404. // formedNum = formedNum + Number(item.feedQuantity);
  405. // } else {
  406. // notFormedNum = notFormedNum + Number(item.feedQuantity);
  407. // }
  408. // });
  409. // console.log("合格数量:" + formedNum, "不合格数量:" + notFormedNum);
  410. // this.$set(this.item.workReportInfo, "formedNum", formedNum);
  411. // this.$set(this.item.workReportInfo, "notFormedNum", notFormedNum);
  412. // this.item.workReportInfo = this.deepCopy(this.item.workReportInfo);
  413. // this.$forceUpdate();
  414. // }
  415. // if (!this.currentTaskDiagram.isFirstTask) {
  416. // this.getSemiProductList(newVal);
  417. // }
  418. },
  419. },
  420. },
  421. components: { semiProductJobBomPL, batchProductJobBom },
  422. data() {
  423. return {
  424. forValue: {},
  425. tableData: [],
  426. batchNo: "",
  427. notFormedList: [],
  428. clientEnvironmentId:
  429. uni.getStorageSync("userInfo") &&
  430. uni.getStorageSync("userInfo").clientEnvironmentId, // *1 主环境-601环境 2 soll-索尔环境 3 tg-碳谷环境
  431. };
  432. },
  433. created() {
  434. console.log(this.item, "item13131223223");
  435. // this.item.product = this.item.pickOutInList;
  436. let newList = [];
  437. if (
  438. this.item.pickOutInList.length != 0 &&
  439. this.item.product.length == 0 &&
  440. this.item.currentTaskDiagram.type == 6
  441. ) {
  442. this.item.pickOutInList.forEach((item) => {
  443. const data = this.deepCopy(item);
  444. newList.push(data);
  445. });
  446. this.$set(this.item, "product", newList);
  447. }
  448. // this.item.product.push(...newList);
  449. // console.log(this.item.product, "this.item.product");
  450. // this.item.pickOutInList = [];
  451. // this.$set(this.item, "product", ...newList);
  452. // this.$set(this.item, "pickOutInList", []);
  453. // }
  454. if (this.isDetails) {
  455. this.notFormedList = this.notFormedList.map((m) => {
  456. return {
  457. notFormedNum: Number(m.quantity),
  458. notFormedWeight: m.weight,
  459. ...m,
  460. };
  461. });
  462. }
  463. this.getByCode();
  464. },
  465. methods: {
  466. tableDataFn(tableData) {
  467. console.log(tableData);
  468. let adultCount = 0;
  469. let noAdultCount = 0;
  470. this.arrDataStatistics(tableData);
  471. tableData.forEach((v) => {
  472. if (v.selected) {
  473. console.log(11111);
  474. if (v.extInfo.isQualified == 1) {
  475. adultCount += 1;
  476. } else {
  477. noAdultCount += 1;
  478. }
  479. }
  480. });
  481. this.$set(this.item.workReportInfo, "formedNum", adultCount);
  482. this.$set(this.item.workReportInfo, "notFormedNum", noAdultCount);
  483. // this.tableData = this.notFormedList;
  484. if (!(this.clientEnvironmentId == 3 || this.item.singleReport !== 1)) {
  485. this.item.semiProductList = tableData;
  486. }
  487. },
  488. deepCopy(obj, hash = new WeakMap()) {
  489. if (obj === null) return null;
  490. if (obj instanceof Date) return new Date(obj);
  491. if (obj instanceof RegExp) return new RegExp(obj);
  492. if (typeof obj !== "object" && typeof obj !== "function") return obj;
  493. if (hash.has(obj)) return hash.get(obj);
  494. const result = Array.isArray(obj) ? [] : {};
  495. hash.set(obj, result);
  496. return Object.keys(obj).reduce((acc, key) => {
  497. acc[key] = this.deepCopy(obj[key], hash);
  498. return acc;
  499. }, result);
  500. },
  501. arrDataStatistics(arr) {
  502. console.log(arr);
  503. const adultCount = arr.filter(
  504. (user) => user.extInfo.isQualified == 1
  505. ).length;
  506. const noAdultCount = arr.filter(
  507. (user) => user.extInfo.isQualified !== 1
  508. ).length;
  509. console.log(adultCount, noAdultCount);
  510. this.$set(this.item.workReportInfo, "formedNum", adultCount);
  511. this.$set(this.item.workReportInfo, "notFormedNum", noAdultCount);
  512. },
  513. getByCode() {
  514. parameterGetByCode({ code: "enable_quality_plus" }).then((res) => {
  515. if (
  516. res.value == "1" &&
  517. (this.item.currentTaskDiagram.type == 6 ||
  518. this.item.currentTaskDiagram.type == 2 ||
  519. this.item.currentTaskDiagram.type == 2)
  520. ) {
  521. uni.showModal({
  522. title: "提示",
  523. content: "质检需要去PC端进行",
  524. success: function (res) {
  525. if (res.confirm) {
  526. console.log("用户点击确定");
  527. } else if (res.cancel) {
  528. console.log("用户点击取消");
  529. }
  530. },
  531. });
  532. }
  533. });
  534. },
  535. getSemiProductList(newVal) {
  536. console.log(newVal);
  537. if (newVal.semiProductList.length) {
  538. newVal.semiProductList.map((v) => {
  539. v.selected = true;
  540. });
  541. this.arrDataStatistics(newVal.semiProductList);
  542. this.tableData = newVal.semiProductList;
  543. }
  544. if (newVal.pickOutInList.length) {
  545. newVal.pickOutInList.map((v) => {
  546. v.selected = true;
  547. });
  548. this.arrDataStatistics(newVal.pickOutInList);
  549. this.tableData = newVal.pickOutInList;
  550. }
  551. },
  552. singleBatch() {
  553. console.log(this.item.workReportInfo, "11111111");
  554. if (!this.item.workReportInfo.formedNum)
  555. return uni.showToast({
  556. icon: "none",
  557. title: "请输入合格品数",
  558. });
  559. // if (
  560. // !this.item.workReportInfo.notFormedNum ||
  561. // this.item.workReportInfo.notFormedNum != 0
  562. // )
  563. // return uni.showToast({
  564. // icon: "none",
  565. // title: "请输入不合格品数",
  566. // });
  567. const req = {
  568. formedNum: this.item.workReportInfo.formedNum,
  569. notFormedNum: this.item.workReportInfo.notFormedNum || 0,
  570. taskId: this.item.workReportInfo.taskId,
  571. workOrderId: this.item.workReportInfo.workOrderId,
  572. };
  573. createInProductBatch(req).then((res) => {
  574. if (res && res.length) {
  575. this.forValue = res[0];
  576. res.map((v) => {
  577. v.selected = true;
  578. });
  579. this.tableData = res;
  580. this.item.product = res;
  581. console.log(this.item);
  582. }
  583. });
  584. },
  585. toInteger(num) {
  586. const len = this.getDecimalLength(num);
  587. return {
  588. int: Math.round(num * Math.pow(10, len)),
  589. factor: Math.pow(10, len),
  590. };
  591. },
  592. add(a, b) {
  593. const { int: aInt, factor: aFactor } = this.toInteger(a);
  594. const { int: bInt, factor: bFactor } = this.toInteger(b);
  595. const maxFactor = Math.max(aFactor, bFactor);
  596. return (
  597. (aInt * (maxFactor / aFactor) + bInt * (maxFactor / bFactor)) /
  598. maxFactor
  599. );
  600. },
  601. sub(a, b) {
  602. const { int: aInt, factor: aFactor } = this.toInteger(a);
  603. const { int: bInt, factor: bFactor } = this.toInteger(b);
  604. const maxFactor = Math.max(aFactor, bFactor);
  605. return (
  606. (aInt * (maxFactor / aFactor) - bInt * (maxFactor / bFactor)) /
  607. maxFactor
  608. );
  609. },
  610. getDecimalLength(num) {
  611. return (num.toString().split(".")[1] || "").length;
  612. },
  613. toInteger(num) {
  614. const len = this.getDecimalLength(num);
  615. return {
  616. int: Math.round(num * Math.pow(10, len)),
  617. factor: Math.pow(10, len),
  618. };
  619. },
  620. add(a, b) {
  621. const { int: aInt, factor: aFactor } = this.toInteger(a);
  622. const { int: bInt, factor: bFactor } = this.toInteger(b);
  623. const maxFactor = Math.max(aFactor, bFactor);
  624. return (
  625. (aInt * (maxFactor / aFactor) + bInt * (maxFactor / bFactor)) /
  626. maxFactor
  627. );
  628. },
  629. sub(a, b) {
  630. const { int: aInt, factor: aFactor } = this.toInteger(a);
  631. const { int: bInt, factor: bFactor } = this.toInteger(b);
  632. const maxFactor = Math.max(aFactor, bFactor);
  633. return (
  634. (aInt * (maxFactor / aFactor) - bInt * (maxFactor / bFactor)) /
  635. maxFactor
  636. );
  637. },
  638. getDecimalLength(num) {
  639. return (num.toString().split(".")[1] || "").length;
  640. },
  641. singleBatchTg() {
  642. if (!this.item.workReportInfo.formedNum)
  643. return uni.showToast({
  644. icon: "none",
  645. title: "请输入合格品数",
  646. });
  647. // if (
  648. // !this.item.workReportInfo.notFormedNum ||
  649. // this.item.workReportInfo.notFormedNum != 0
  650. // )
  651. // return uni.showToast({
  652. // icon: "none",
  653. // title: "请输入不合格品数",
  654. // });
  655. const req = {
  656. formedNum: this.item.workReportInfo.formedNum,
  657. notFormedNum: this.item.workReportInfo.notFormedNum || 0,
  658. taskId: this.item.workReportInfo.taskId,
  659. workOrderId: this.item.workReportInfo.workOrderId,
  660. };
  661. createInProductBatchTG(req).then((res) => {
  662. if (res && res.length) {
  663. this.forValue = res[0];
  664. res.map((v) => {
  665. v.selected = true;
  666. v.extInfo.batchReportInfo = [
  667. {
  668. allFeedQuantity: "",
  669. allReportWeight: "",
  670. taskId: "",
  671. taskName: "",
  672. },
  673. ];
  674. v.extInfo.notBatchReportInfo = [
  675. {
  676. allFeedQuantity: "",
  677. notType: "",
  678. taskId: "",
  679. taskName: "",
  680. notReason: "",
  681. },
  682. ];
  683. });
  684. this.list = res;
  685. this.item.semiProductList = res;
  686. }
  687. });
  688. // console.log(this.item, "this.itemthis.itemthis.itemthis.item12121");
  689. },
  690. /**
  691. * 更新批次号
  692. *
  693. * @param e 事件对象
  694. */
  695. batchNoNew(e) {
  696. this.item.workReportInfo.batchNo = this.item.batchNo + e.target.value;
  697. },
  698. setFormedNum(num) {
  699. this.item.workReportInfo.formedNum = num;
  700. let weight =
  701. Number(this.item.workReportInfo.formedNum) *
  702. Number(this.item.singleWeight) *
  703. Number(this.item.weightMultiple);
  704. if (["G", "g", "克"].includes(this.item.singleWeightUnit)) {
  705. weight = parseFloat((weight / 1000).toFixed(2));
  706. } else {
  707. weight = parseFloat(weight.toFixed(2));
  708. }
  709. this.$set(this.item.workReportInfo, "formedWeight", weight);
  710. this.$forceUpdate();
  711. },
  712. penalize() {
  713. this.$emit("penalize", null);
  714. },
  715. handleView(name) {
  716. uni.showToast({
  717. icon: "none",
  718. title: name || "未设置",
  719. });
  720. },
  721. blurNum(value) {
  722. let total = 0;
  723. //匹配非数字
  724. let val = value.formedNum;
  725. let reg = new RegExp("([^0-9]*)", "g");
  726. let ma = val.match(reg);
  727. //如果有非数字,替换成""
  728. if (ma.length > 0) {
  729. for (let k in ma) {
  730. if (ma[k] != "") {
  731. val = val.replace(ma[k], 0);
  732. }
  733. }
  734. }
  735. //可以为0,但不能以0开头
  736. if (val.startsWith("0") && val.length > 1) {
  737. val = val.substring(1, val.length);
  738. }
  739. value.formedNum = val;
  740. if (this.item.currentTaskDiagram.isFirstTask) {
  741. // formingNum 生产数量 feedQuantity this.item.product[0] //投料数量
  742. if (value.formedNum > this.item.formingNum) {
  743. this.$set(
  744. this.item.workReportInfo,
  745. "workReportInfo",
  746. this.item.formingNum
  747. );
  748. this.$set(this.item.workReportInfo, "notFormedNum", 0);
  749. this.notForme();
  750. return uni.showToast({
  751. icon: "none",
  752. title: "合格品数量不能大于要求生产数量",
  753. });
  754. }
  755. } else {
  756. if (this.item.product.length) {
  757. const feedNumber = this.item.product.reduce((acc, pre) => {
  758. return pre.feedQuantity ? acc + Number(pre.feedQuantity) : acc;
  759. }, 0);
  760. console.log(this.item, "this.item.product");
  761. if (value.formedNum > feedNumber) {
  762. this.$set(this.item.workReportInfo, "formedNum", feedNumber);
  763. this.$set(this.item.workReportInfo, "notFormedNum", 0);
  764. return uni.showToast({
  765. icon: "none",
  766. title: "合格品数量不能大于投料数量",
  767. });
  768. }
  769. // if (value.formedNum > this.item.product[0].feedQuantity) {
  770. // console.log(this.item.product[0].feedQuantity);
  771. // this.$set(
  772. // this.item.workReportInfo,
  773. // "workReportInfo",
  774. // this.item.product[0].feedQuantity
  775. // );
  776. // this.$set(this.notFormedList[0], "notFormedNum", 0);
  777. // this.notForme();
  778. // return uni.showToast({
  779. // icon: "none",
  780. // title: "合格品数量不能大于投料数量",
  781. // });
  782. // }
  783. }
  784. }
  785. console.log(
  786. Number(this.item.workReportInfo.formedNum),
  787. "Number(this.item.workReportInfo.feedQuantity)"
  788. );
  789. console.log(Number(value.formedNum), "Number(value.formedNum)");
  790. if (
  791. this.item.product[0] &&
  792. this.item.product[0].feedQuantity > 0 &&
  793. Number(this.item.workReportInfo.formedNum)
  794. ) {
  795. console.log("555555");
  796. this.$set(
  797. this.notFormedList[0],
  798. "notFormedNum",
  799. Number(value.formedNum) - Number(this.item.workReportInfo.formedNum)
  800. );
  801. this.notForme();
  802. }
  803. let weight =
  804. Number(this.item.workReportInfo.formedNum) *
  805. Number(this.item.singleWeight) *
  806. Number(this.item.weightMultiple);
  807. if (["G", "g", "克"].includes(this.item.singleWeightUnit)) {
  808. weight = parseFloat((weight / 1000).toFixed(2));
  809. } else {
  810. weight = parseFloat(weight.toFixed(2));
  811. }
  812. this.$set(this.item.workReportInfo, "formedWeight", weight);
  813. total =
  814. Number(this.item.workReportInfo.formedNum) +
  815. Number(this.item.workReportInfo.notFormedNum);
  816. console.log(total);
  817. this.$emit("modeNum", total);
  818. this.$forceUpdate();
  819. },
  820. notForme() {
  821. let weight =
  822. Number(this.item.workReportInfo.notFormedNum) *
  823. Number(this.item.singleWeight) *
  824. Number(this.item.weightMultiple);
  825. if (
  826. this.item.singleWeightUnit == "G" ||
  827. this.item.singleWeightUnit == "g" ||
  828. this.item.singleWeightUnit == "克"
  829. ) {
  830. weight = parseFloat((weight / 1000).toFixed(2));
  831. } else {
  832. weight = parseFloat(weight.toFixed(2));
  833. }
  834. this.$set(this.item.workReportInfo, "notFormedWeight", weight);
  835. // if (
  836. // this.item.product[0] &&
  837. // this.item.product[0].feedQuantity > 0 &&
  838. // Number(this.notFormedList[0].notFormedNum)
  839. // ) {
  840. // this.$set(
  841. // this.item.workReportInfo,
  842. // "formedNum",
  843. // this.item.product[0].feedQuantity -
  844. // Number(this.notFormedList[0].notFormedNum)
  845. // );
  846. // let weight =
  847. // Number(this.item.workReportInfo.formedNum) *
  848. // Number(this.item.singleWeight) *
  849. // Number(this.item.weightMultiple);
  850. // if (
  851. // this.item.singleWeightUnit == "G" ||
  852. // this.item.singleWeightUnit == "g" ||
  853. // this.item.singleWeightUnit == "克"
  854. // ) {
  855. // weight = parseFloat((weight / 1000).toFixed(2));
  856. // } else {
  857. // weight = parseFloat(weight.toFixed(2));
  858. // }
  859. // this.$set(this.item.workReportInfo, "formedWeight", weight);
  860. // }
  861. this.$forceUpdate();
  862. },
  863. changeNum(value) {
  864. // 不合格数量
  865. let val = value;
  866. //匹配非数字
  867. let reg = new RegExp("([^0-9]*)", "g");
  868. let ma = val.match(reg);
  869. //如果有非数字,替换成""
  870. if (ma.length > 0) {
  871. for (let k in ma) {
  872. if (ma[k] != "") {
  873. val = val.replace(ma[k], "0");
  874. }
  875. }
  876. }
  877. //可以为0,但不能以0开头
  878. if (val.startsWith("0") && val.length > 1) {
  879. val = val.substring(1, val.length);
  880. }
  881. // this.$set(this.item.workReportInfo, 'formedNum', val)
  882. value = val;
  883. console.log(Number(this.item.workReportInfo.formedNum), 1);
  884. console.log(Number(this.item.workReportInfo.notFormedNum), 2);
  885. let total =
  886. Number(this.item.workReportInfo.formedNum) +
  887. Number(this.item.workReportInfo.notFormedNum);
  888. console.log(total);
  889. this.$emit("modeNum", total);
  890. this.notForme();
  891. // this.blurNum()
  892. },
  893. },
  894. };
  895. </script>
  896. <style lang="scss" scoped>
  897. .unit-btn {
  898. background-color: #157a2c;
  899. height: 48rpx;
  900. padding: 0 20rpx;
  901. line-height: 48rpx;
  902. color: #fff;
  903. font-size: 12px;
  904. }
  905. .content_num {
  906. display: flex;
  907. align-items: center;
  908. padding: 0 4rpx;
  909. font-size: 26rpx !important;
  910. /deep/ .uni-input-input {
  911. border: 2rpx solid #f0f8f2;
  912. background: #f0f8f2;
  913. color: $theme-color;
  914. }
  915. }
  916. .item {
  917. display: flex;
  918. justify-content: space-between;
  919. }
  920. .title_box {
  921. margin-top: 20rpx;
  922. .name {
  923. font-size: 28rpx;
  924. font-style: normal;
  925. font-weight: 400;
  926. color: $theme-color;
  927. padding-left: 20rpx;
  928. position: relative;
  929. &:before {
  930. position: absolute;
  931. content: "";
  932. left: 0rpx;
  933. top: 0rpx;
  934. bottom: 0rpx;
  935. width: 4rpx;
  936. height: 28rpx;
  937. background: $theme-color;
  938. margin: auto;
  939. }
  940. }
  941. }
  942. .material {
  943. margin-top: 10rpx;
  944. .content_table {
  945. width: 100%;
  946. border: 2rpx solid $border-color;
  947. .item {
  948. display: flex;
  949. border-bottom: 2rpx solid $border-color;
  950. .lable {
  951. width: 132rpx;
  952. text-align: center;
  953. background-color: #f7f9fa;
  954. font-size: 26rpx;
  955. border-right: 2rpx solid $border-color;
  956. flex-shrink: 0;
  957. }
  958. .lable220 {
  959. width: 220rpx !important;
  960. font-size: 24rpx;
  961. }
  962. .lable150 {
  963. width: 156rpx !important;
  964. font-size: 24rpx;
  965. }
  966. .ww80 {
  967. width: 80rpx;
  968. }
  969. .content {
  970. width: 518rpx;
  971. min-height: 64rpx;
  972. font-size: 28rpx;
  973. line-height: 28rpx;
  974. font-style: normal;
  975. font-weight: 400;
  976. padding: 18rpx 8rpx;
  977. box-sizing: border-box;
  978. word-wrap: break-word;
  979. flex-grow: 1 !important;
  980. .unit {
  981. padding: 0 4rpx;
  982. font-size: 24rpx;
  983. color: #404446;
  984. }
  985. .penalize {
  986. width: 160rpx;
  987. line-height: 60rpx;
  988. background: $theme-color;
  989. font-size: 24rpx;
  990. text-align: center;
  991. color: #fff;
  992. }
  993. }
  994. .pd4 {
  995. padding: 4rpx 8rpx;
  996. }
  997. &:last-child {
  998. border-bottom: none;
  999. }
  1000. }
  1001. .ww55 {
  1002. width: 55%;
  1003. }
  1004. .ww45 {
  1005. width: 45%;
  1006. }
  1007. }
  1008. }
  1009. </style>