batchJobBom.vue 30 KB

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