singleJobBom.vue 20 KB

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