jobBom.vue 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688
  1. <template>
  2. <view>
  3. <view class="title_box rx-bc">
  4. <view class="name">报工信息</view>
  5. </view>
  6. <view class="material">
  7. <view class="content_table">
  8. <!-- <view class="item rx-sc"
  9. v-if="Object.prototype.hasOwnProperty.call(item, 'product') && clientEnvironmentId != 3">
  10. <view class="rx ">
  11. <view class="lable lable220 rx-cc ">投料数量</view>
  12. <view class="content">
  13. {{ item.product[0] && item.product[0].feedQuantity }}
  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. @input="blurWeight()"
  56. />
  57. <view class="unit">{{ item.weightUnit }}</view>
  58. </view>
  59. </view>
  60. </view>
  61. <view
  62. class="item rx-sc"
  63. v-for="(not, notIndex) in notFormedList"
  64. :key="notIndex"
  65. >
  66. <view class="rx ww55">
  67. <view class="lable lable150 rx-cc">不合格数量</view>
  68. <view class="content content_num">
  69. <!-- //详情 -->
  70. <input
  71. class="uni-input"
  72. v-model="item.workReportInfo.notFormedNum"
  73. type="digit"
  74. :disabled="isDetails"
  75. v-if="isDetails"
  76. @input="changeNum"
  77. />
  78. <input
  79. class="uni-input"
  80. v-model="notFormedNum"
  81. type="number"
  82. v-else
  83. @input="blurNum2(item.workReportInfo)"
  84. />
  85. <view class="unit">{{ item.unit }}</view>
  86. </view>
  87. </view>
  88. <view class="rx ww45">
  89. <view class="lable rx-cc ww80">重量</view>
  90. <view class="content content_num">
  91. <input
  92. class="uni-input"
  93. v-model="item.workReportInfo.notFormedWeight"
  94. type="digit"
  95. :disabled="isDetails"
  96. v-if="isDetails"
  97. />
  98. <input
  99. class="uni-input"
  100. v-model="notFormedWeight"
  101. type="digit"
  102. :disabled="isDetails"
  103. v-else
  104. @input="blurWeight2()"
  105. />
  106. <view class="unit">{{ item.weightUnit }}</view>
  107. <!-- <view class="penalize" v-if='!isDetails'
  108. :style="{ background: not.warehouseId ? '#FFA07A' : '' }" @click="penalize">处置</view> -->
  109. <!-- <view class="penalize" v-if='isDetails'
  110. :style="{ background: not.warehouseId ? '#FFA07A' : '' }"
  111. @click="handleView(isDetails ? not.warehouseName : item.warehouseName)">查看</view> -->
  112. </view>
  113. </view>
  114. </view>
  115. <view class="item rx-sc">
  116. <view class="rx ww55">
  117. <view class="lable lable150 rx-cc">损耗数量</view>
  118. <view class="content content_num">
  119. <!-- //详情 -->
  120. <input
  121. class="uni-input"
  122. v-model="item.workReportInfo.lossQuantity"
  123. type="digit"
  124. :disabled="isDetails"
  125. @input="changeNum(item.workReportInfo.lossQuantity)"
  126. />
  127. <view class="unit">{{ item.unit }}</view>
  128. </view>
  129. </view>
  130. <view class="rx ww45">
  131. <view class="lable rx-cc ww80">重量</view>
  132. <view class="content content_num">
  133. <input
  134. class="uni-input"
  135. v-model="item.workReportInfo.lossWeight"
  136. type="digit"
  137. :disabled="isDetails"
  138. />
  139. <view class="unit">{{ item.weightUnit }}</view>
  140. </view>
  141. </view>
  142. </view>
  143. <view class="item rx-sc">
  144. <view class="rx ww55">
  145. <view class="lable lable150 rx-cc">报工备注</view>
  146. <view class="content content_num" style="width: 100%">
  147. <input
  148. class="uni-input"
  149. v-model="item.workReportInfo.remark"
  150. :disabled="isDetails"
  151. type="text"
  152. />
  153. </view>
  154. </view>
  155. <!-- v-if="clientEnvironmentId==2" -->
  156. <view class="rx ww45" v-if="clientEnvironmentId == 2">
  157. <view class="lable ww80 rx-cc">批次号</view>
  158. <view class="content content_num" style="width: 100%">
  159. {{ item.batchNo }}
  160. <input
  161. class="uni-input"
  162. v-model="batchNo"
  163. @input="batchNoNew"
  164. :disabled="isDetails"
  165. type="text"
  166. />
  167. </view>
  168. </view>
  169. <view
  170. class="unit-btn"
  171. @click="singleQuery"
  172. v-if="
  173. item.currentTaskDiagram &&
  174. item.currentTaskDiagram.isFirstTask == 1 &&
  175. item.semiProductList &&
  176. item.semiProductList.length == 0
  177. "
  178. >创建在制品</view
  179. >
  180. </view>
  181. </view>
  182. </view>
  183. </view>
  184. </template>
  185. <script>
  186. import { createInProductBatchTG } from "@/api/pda/jobBooking.js";
  187. export default {
  188. props: {
  189. item: {
  190. type: Object,
  191. default: () => {},
  192. },
  193. notFormed: {
  194. type: Array,
  195. default: () => [],
  196. },
  197. isDetails: {
  198. type: Boolean,
  199. default: false,
  200. },
  201. },
  202. watch: {
  203. notFormed: {
  204. immediate: true,
  205. deep: true,
  206. handler(newVal) {
  207. this.notFormedList = newVal;
  208. },
  209. },
  210. item: {
  211. immediate: true,
  212. deep: true,
  213. handler(newVal) {
  214. console.log("ccccc吃饭了", newVal);
  215. this.$forceUpdate();
  216. },
  217. },
  218. },
  219. data() {
  220. return {
  221. batchNo: "",
  222. notFormedList: [],
  223. clientEnvironmentId:
  224. uni.getStorageSync("userInfo") &&
  225. uni.getStorageSync("userInfo").clientEnvironmentId, // *1 主环境-601环境 2 soll-索尔环境 3 tg-碳谷环境
  226. formedNum: "",
  227. formedWeight: "",
  228. notFormedNum: "",
  229. notFormedWeight: "",
  230. };
  231. },
  232. created() {
  233. if (this.isDetails) {
  234. this.notFormedList = this.notFormedList.map((m) => {
  235. return {
  236. notFormedNum: Number(m.quantity),
  237. notFormedWeight: m.weight,
  238. ...m,
  239. };
  240. });
  241. }
  242. },
  243. methods: {
  244. fWeightInput(formedWeight, notFormedWeight) {
  245. this.formedWeight = formedWeight;
  246. this.$forceUpdate();
  247. },
  248. formedTotal(
  249. formedNumCount,
  250. formedWeightCount,
  251. notFormedNumCount,
  252. notFormedWeightCount
  253. ) {
  254. this.formedNum = formedNumCount;
  255. this.formedWeight = formedWeightCount;
  256. (this.notFormedNum = notFormedNumCount),
  257. (this.notFormedWeight = notFormedWeightCount),
  258. this.$forceUpdate();
  259. },
  260. batchNoNew(e) {
  261. this.item.workReportInfo.batchNo = this.item.batchNo + e.target.value;
  262. },
  263. setFormedNum(num) {
  264. this.item.workReportInfo.formedNum = num;
  265. let weight =
  266. Number(this.item.workReportInfo.formedNum) *
  267. Number(this.item.singleWeight) *
  268. Number(this.item.weightMultiple);
  269. if (["G", "g", "克"].includes(this.item.singleWeightUnit)) {
  270. weight = parseFloat((weight / 1000).toFixed(2));
  271. } else {
  272. weight = parseFloat(weight.toFixed(2));
  273. }
  274. this.$set(this.item.workReportInfo, "formedWeight", weight);
  275. this.$forceUpdate();
  276. },
  277. penalize() {
  278. this.$emit("penalize", null);
  279. },
  280. handleView(name) {
  281. uni.showToast({
  282. icon: "none",
  283. title: name || "未设置",
  284. });
  285. },
  286. blurNum(value) {
  287. this.$set(this.item.workReportInfo, "formedNum", this.formedNum);
  288. let total = 0;
  289. //匹配非数字
  290. let val = value.formedNum;
  291. let reg = new RegExp("([^0-9]*)", "g");
  292. let ma = val.match(reg);
  293. //如果有非数字,替换成""
  294. if (ma.length > 0) {
  295. for (let k in ma) {
  296. if (ma[k] != "") {
  297. val = val.replace(ma[k], 0);
  298. }
  299. }
  300. }
  301. //可以为0,但不能以0开头
  302. if (val.startsWith("0") && val.length > 1) {
  303. val = val.substring(1, val.length);
  304. }
  305. value.formedNum = val;
  306. if (this.item.currentTaskDiagram.isFirstTask) {
  307. // formingNum 生产数量 feedQuantity this.item.product[0] //投料数量
  308. if (value.formedNum > this.item.formingNum) {
  309. this.$set(
  310. this.item.workReportInfo,
  311. "workReportInfo",
  312. this.item.formingNum
  313. );
  314. this.$set(this.notFormedList[0], "notFormedNum", 0);
  315. this.formedNum = 0;
  316. this.$forceUpdate();
  317. this.notForme();
  318. return uni.showToast({
  319. icon: "none",
  320. title: "合格品数量不能大于要求生产数量",
  321. });
  322. }
  323. } else {
  324. if (this.item.product.length) {
  325. if (value.formedNum > this.item.product[0].feedQuantity) {
  326. console.log(this.item.product[0].feedQuantity);
  327. this.$set(
  328. this.item.workReportInfo,
  329. "workReportInfo",
  330. this.item.product[0].feedQuantity
  331. );
  332. this.$set(this.notFormedList[0], "notFormedNum", 0);
  333. this.formedNum = 0;
  334. this.$forceUpdate();
  335. this.notForme();
  336. return uni.showToast({
  337. icon: "none",
  338. title: "合格品数量不能大于投料数量",
  339. });
  340. }
  341. }
  342. }
  343. if (
  344. this.item.product[0] &&
  345. this.item.product[0].feedQuantity > 0 &&
  346. Number(this.item.workReportInfo.formedNum)
  347. ) {
  348. this.$set(
  349. this.notFormedList[0],
  350. "notFormedNum",
  351. this.item.product[0].feedQuantity -
  352. Number(this.item.workReportInfo.formedNum)
  353. );
  354. this.notForme();
  355. }
  356. let weight =
  357. Number(this.item.workReportInfo.formedNum) *
  358. Number(this.item.singleWeight) *
  359. Number(this.item.weightMultiple);
  360. if (["G", "g", "克"].includes(this.item.singleWeightUnit)) {
  361. weight = parseFloat((weight / 1000).toFixed(2));
  362. } else {
  363. weight = parseFloat(weight.toFixed(2));
  364. }
  365. this.$set(this.item.workReportInfo, "formedWeight", weight);
  366. total =
  367. Number(this.item.workReportInfo.formedNum) +
  368. Number(this.notFormedList[0].notFormedNum);
  369. console.log(total);
  370. this.$emit("modeNum", total);
  371. this.$forceUpdate();
  372. },
  373. blurNum2(value) {
  374. this.$set(this.item.workReportInfo, "notFormedNum", this.notFormedNum);
  375. let total = 0;
  376. //匹配非数字
  377. let val = value.notFormedNum;
  378. let reg = new RegExp("([^0-9]*)", "g");
  379. let ma = val.match(reg);
  380. //如果有非数字,替换成""
  381. if (ma.length > 0) {
  382. for (let k in ma) {
  383. if (ma[k] != "") {
  384. val = val.replace(ma[k], 0);
  385. }
  386. }
  387. }
  388. //可以为0,但不能以0开头
  389. if (val.startsWith("0") && val.length > 1) {
  390. val = val.substring(1, val.length);
  391. }
  392. value.notFormedNum = val;
  393. if (this.item.currentTaskDiagram.isFirstTask) {
  394. // formingNum 生产数量 feedQuantity this.item.product[0] //投料数量
  395. if (value.notFormedNum > this.item.formingNum) {
  396. this.$set(
  397. this.item.workReportInfo,
  398. "workReportInfo",
  399. this.item.formingNum
  400. );
  401. this.$set(this.notFormedList[0], "notFormedNum", 0);
  402. this.notFormedNum = 0;
  403. this.$forceUpdate();
  404. this.notForme();
  405. return uni.showToast({
  406. icon: "none",
  407. title: "不合格品数量不能大于要求生产数量",
  408. });
  409. }
  410. } else {
  411. if (this.item.product.length) {
  412. if (value.formedNum > this.item.product[0].feedQuantity) {
  413. console.log(this.item.product[0].feedQuantity);
  414. this.$set(
  415. this.item.workReportInfo,
  416. "workReportInfo",
  417. this.item.product[0].feedQuantity
  418. );
  419. this.$set(this.notFormedList[0], "notFormedNum", 0);
  420. this.notFormedNum = 0;
  421. this.$forceUpdate();
  422. this.notForme();
  423. return uni.showToast({
  424. icon: "none",
  425. title: "合格品数量不能大于投料数量",
  426. });
  427. }
  428. }
  429. }
  430. },
  431. blurWeight() {
  432. this.$set(this.item.workReportInfo, "formedWeight", this.formedWeight);
  433. },
  434. blurWeight2() {
  435. this.$set(
  436. this.item.workReportInfo,
  437. "notFormedWeight",
  438. this.notFormedWeight
  439. );
  440. },
  441. notForme() {
  442. let weight =
  443. Number(this.notFormedList[0].notFormedNum) *
  444. Number(this.item.singleWeight) *
  445. Number(this.item.weightMultiple);
  446. if (
  447. this.item.singleWeightUnit == "G" ||
  448. this.item.singleWeightUnit == "g" ||
  449. this.item.singleWeightUnit == "克"
  450. ) {
  451. weight = parseFloat((weight / 1000).toFixed(2));
  452. } else {
  453. weight = parseFloat(weight.toFixed(2));
  454. }
  455. this.$set(this.notFormedList[0], "notFormedWeight", weight);
  456. if (
  457. this.item.product[0] &&
  458. this.item.product[0].feedQuantity > 0 &&
  459. Number(this.notFormedList[0].notFormedNum)
  460. ) {
  461. this.$set(
  462. this.item.workReportInfo,
  463. "formedNum",
  464. this.item.product[0].feedQuantity -
  465. Number(this.notFormedList[0].notFormedNum)
  466. );
  467. let weight =
  468. Number(this.item.workReportInfo.formedNum) *
  469. Number(this.item.singleWeight) *
  470. Number(this.item.weightMultiple);
  471. if (
  472. this.item.singleWeightUnit == "G" ||
  473. this.item.singleWeightUnit == "g" ||
  474. this.item.singleWeightUnit == "克"
  475. ) {
  476. weight = parseFloat((weight / 1000).toFixed(2));
  477. } else {
  478. weight = parseFloat(weight.toFixed(2));
  479. }
  480. this.$set(this.item.workReportInfo, "formedWeight", weight);
  481. }
  482. this.$forceUpdate();
  483. },
  484. singleQuery() {},
  485. changeNum(value) {
  486. // 不合格数量
  487. let val = value.notFormedNum;
  488. //匹配非数字
  489. let reg = new RegExp("([^0-9]*)", "g");
  490. let ma = val.match(reg);
  491. //如果有非数字,替换成""
  492. if (ma.length > 0) {
  493. for (let k in ma) {
  494. if (ma[k] != "") {
  495. val = val.replace(ma[k], "0");
  496. }
  497. }
  498. }
  499. //可以为0,但不能以0开头
  500. if (val.startsWith("0") && val.length > 1) {
  501. val = val.substring(1, val.length);
  502. }
  503. // this.$set(this.item.workReportInfo, 'formedNum', val)
  504. value.notFormedNum = val;
  505. console.log(Number(this.item.workReportInfo.formedNum), 1);
  506. console.log(Number(this.notFormedList[0].notFormedNum), 2);
  507. let total =
  508. Number(this.item.workReportInfo.formedNum) +
  509. Number(this.notFormedList[0].notFormedNum);
  510. console.log(total);
  511. this.$emit("modeNum", total);
  512. this.notForme();
  513. // this.blurNum()
  514. },
  515. },
  516. };
  517. </script>
  518. <style lang="scss" scoped>
  519. .title_box {
  520. margin-top: 20rpx;
  521. .name {
  522. font-size: 28rpx;
  523. font-style: normal;
  524. font-weight: 400;
  525. color: $theme-color;
  526. padding-left: 20rpx;
  527. position: relative;
  528. &:before {
  529. position: absolute;
  530. content: "";
  531. left: 0rpx;
  532. top: 0rpx;
  533. bottom: 0rpx;
  534. width: 4rpx;
  535. height: 28rpx;
  536. background: $theme-color;
  537. margin: auto;
  538. }
  539. }
  540. }
  541. .material {
  542. margin-top: 10rpx;
  543. .content_table {
  544. width: 100%;
  545. border: 2rpx solid $border-color;
  546. .item {
  547. display: flex;
  548. border-bottom: 2rpx solid $border-color;
  549. .lable {
  550. width: 132rpx;
  551. text-align: center;
  552. background-color: #f7f9fa;
  553. font-size: 26rpx;
  554. border-right: 2rpx solid $border-color;
  555. flex-shrink: 0;
  556. }
  557. .lable220 {
  558. width: 220rpx !important;
  559. font-size: 24rpx;
  560. }
  561. .lable150 {
  562. width: 156rpx !important;
  563. font-size: 24rpx;
  564. }
  565. .ww80 {
  566. width: 80rpx;
  567. }
  568. .content {
  569. width: 518rpx;
  570. min-height: 64rpx;
  571. font-size: 28rpx;
  572. line-height: 28rpx;
  573. font-style: normal;
  574. font-weight: 400;
  575. padding: 18rpx 8rpx;
  576. box-sizing: border-box;
  577. word-wrap: break-word;
  578. flex-grow: 1 !important;
  579. .unit {
  580. padding: 0 4rpx;
  581. font-size: 24rpx;
  582. color: #404446;
  583. }
  584. .penalize {
  585. width: 160rpx;
  586. line-height: 60rpx;
  587. background: $theme-color;
  588. font-size: 24rpx;
  589. text-align: center;
  590. color: #fff;
  591. }
  592. }
  593. .content_num {
  594. display: flex;
  595. align-items: center;
  596. padding: 0 4rpx;
  597. /deep/ .uni-input-input {
  598. border: 2rpx solid #f0f8f2;
  599. background: #f0f8f2;
  600. color: $theme-color;
  601. }
  602. }
  603. .pd4 {
  604. padding: 4rpx 8rpx;
  605. }
  606. &:last-child {
  607. border-bottom: none;
  608. }
  609. }
  610. .ww55 {
  611. width: 55%;
  612. }
  613. .ww45 {
  614. width: 45%;
  615. }
  616. }
  617. }
  618. </style>