jobBom.vue 17 KB

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