jobBom.vue 17 KB

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