singleJobBom.vue 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714
  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 class="uni-input" v-model="item.workReportInfo.formedNum" :disabled="isDetails"
  38. @input="blurNum(item.workReportInfo)" type="digit"></input>
  39. <view class="unit">{{ item.unit }}</view>
  40. </view>
  41. </view>
  42. <view class="rx ww45">
  43. <view class="lable rx-cc ww80">重量</view>
  44. <view class="content content_num">
  45. <input class="uni-input" v-model="item.workReportInfo.formedWeight" type="digit"
  46. :disabled="isDetails"></input>
  47. <view class="unit">{{ item.weightUnit }}</view>
  48. </view>
  49. </view>
  50. </view>
  51. <view class="item rx-sc" v-for="(not, notIndex) in notFormedList" :key='notIndex'>
  52. <view class="rx ww55 ">
  53. <view class="lable lable150 rx-cc ">不合格数量</view>
  54. <view class="content content_num">
  55. <!-- //详情 -->
  56. <input class="uni-input" v-model="item.workReportInfo.notFormedNum" type="digit"
  57. :disabled="isDetails" v-if="isDetails" @input="changeNum"></input>
  58. <input class="uni-input" v-model="not.notFormedNum" type="number" v-else
  59. @input="changeNum(not)"></input>
  60. <view class="unit">{{ item.unit }}</view>
  61. </view>
  62. </view>
  63. <view class="rx ww45">
  64. <view class="lable rx-cc ww80">重量</view>
  65. <view class="content content_num">
  66. <input class="uni-input" v-model="item.workReportInfo.notFormedWeight" type="digit"
  67. :disabled="isDetails" v-if="isDetails"></input>
  68. <input class="uni-input" v-model="not.notFormedWeight" type="digit" :disabled="isDetails"
  69. v-else></input>
  70. <view class="unit">{{ item.weightUnit }}</view>
  71. <!-- <view class="penalize" v-if='!isDetails'
  72. :style="{ background: not.warehouseId ? '#FFA07A' : '' }" @click="penalize">处置</view> -->
  73. <!-- <view class="penalize" v-if='isDetails'
  74. :style="{ background: not.warehouseId ? '#FFA07A' : '' }"
  75. @click="handleView(isDetails ? not.warehouseName : item.warehouseName)">查看</view> -->
  76. </view>
  77. </view>
  78. </view>
  79. <view class="item rx-sc">
  80. <view class="rx ww55 ">
  81. <view class="lable lable150 rx-cc ">报工备注</view>
  82. <view class="content content_num" style="width: 100%;">
  83. <input class="uni-input" v-model="item.workReportInfo.remark" :disabled="isDetails"
  84. type="text"></input>
  85. </view>
  86. </view>
  87. <!-- v-if="clientEnvironmentId==2" -->
  88. <view class="rx ww45 " v-if="clientEnvironmentId == 2">
  89. <view class="lable ww80 rx-cc ">批次号</view>
  90. <view class="content content_num" style="width: 100%;">
  91. {{ item.batchNo }}
  92. <input class="uni-input" v-model="batchNo" @input="batchNoNew" :disabled="isDetails"
  93. type="text"></input>
  94. </view>
  95. </view>
  96. <!-- 不是首工序展示这个按钮 -->
  97. <view class="unit-btn" @click='singleQuery' v-if="item.currentTaskDiagram.isFirstTask">确认</view>
  98. </view>
  99. </view>
  100. <view class="content_table">
  101. <!-- <view class="item rx-sc">
  102. <view class="rx ww55 ">
  103. <view class="lable lable150 rx-cc ">名称</view>
  104. <view class="content content_num ">
  105. <view>{{ forValue.name }}</view>
  106. </view>
  107. </view>
  108. <view class="rx ww45">
  109. <view class="lable rx-cc ww80">编码</view>
  110. <view class="content content_num">
  111. <view>{{ forValue.code }}</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 ww80">单位</view>
  118. <view class="content content_num">
  119. <view>{{ forValue.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 rx-sc">
  125. <view>{{ forValue.specification }}</view>
  126. </view>
  127. </view>
  128. </view>
  129. <view class="item rx-sc">
  130. <view class="rx ww55">
  131. <view class="lable lable150 rx-cc ww80">牌号</view>
  132. <view class="content content_num">
  133. <view>{{ forValue.brandNum }}</view>
  134. </view>
  135. </view>
  136. <view class="rx ww45">
  137. <view class="lable rx-cc ww80">型号</view>
  138. <view class="content content_num">
  139. <view>{{ forValue.modelType }}</view>
  140. </view>
  141. </view>
  142. </view> -->
  143. <checkboxTable :tableData="tableData" :itemData="item" @tableDataFn="tableDataFn"></checkboxTable>
  144. </view>
  145. </view>
  146. </view>
  147. </template>
  148. <script>
  149. import {
  150. createInProduct,
  151. } from '@/api/pda/jobBooking.js'
  152. import checkboxTable from '../componentsTable/checkbox/checkbox.vue'
  153. export default {
  154. props: {
  155. item: {
  156. type: Object,
  157. default: () => { }
  158. },
  159. notFormed: {
  160. type: Array,
  161. default: () => []
  162. },
  163. isDetails: {
  164. type: Boolean,
  165. default: false
  166. },
  167. },
  168. watch: {
  169. notFormed: {
  170. immediate: true,
  171. deep: true,
  172. handler(newVal) {
  173. this.notFormedList = newVal
  174. }
  175. },
  176. item: {
  177. immediate: true,
  178. deep: true,
  179. handler(newVal) {
  180. if (!newVal.currentTaskDiagram.isFirstTask) {
  181. this.getSemiProductList(newVal)
  182. }
  183. }
  184. }
  185. },
  186. components: { checkboxTable },
  187. data() {
  188. return {
  189. forValue: {},
  190. tableData: [],
  191. batchNo: '',
  192. notFormedList: [],
  193. clientEnvironmentId: uni.getStorageSync("userInfo") && uni.getStorageSync("userInfo")
  194. .clientEnvironmentId, // *1 主环境-601环境 2 soll-索尔环境 3 tg-碳谷环境
  195. }
  196. },
  197. created() {
  198. if (this.isDetails) {
  199. this.notFormedList = this.notFormedList.map(m => {
  200. return {
  201. notFormedNum: Number(m.quantity),
  202. notFormedWeight: m.weight,
  203. ...m
  204. }
  205. })
  206. }
  207. },
  208. methods: {
  209. tableDataFn(tableData) {
  210. console.log(tableData);
  211. let adultCount = 0;
  212. let noAdultCount = 0;
  213. this.arrDataStatistics(tableData);
  214. tableData.forEach(v => {
  215. if(v.selected){
  216. console.log(11111);
  217. if(v.extInfo.isQualified==1){
  218. adultCount+=1
  219. }else{
  220. noAdultCount+=1
  221. }
  222. }
  223. })
  224. this.$set(this.item.workReportInfo, 'formedNum', adultCount);
  225. this.$set(this.notFormedList[0], 'notFormedNum', noAdultCount);
  226. // this.tableData = this.notFormedList;
  227. if (!(this.clientEnvironmentId == 3 || this.item.singleReport !== 1)) {
  228. this.item.semiProductList = tableData;
  229. }
  230. },
  231. arrDataStatistics(arr) {
  232. console.log(arr);
  233. const adultCount = arr.filter(user => user.extInfo.isQualified == 1).length;
  234. const noAdultCount = arr.filter(user => user.extInfo.isQualified !== 1).length;
  235. console.log(adultCount, noAdultCount);
  236. this.$set(this.item.workReportInfo, 'formedNum', adultCount);
  237. this.$set(this.notFormedList[0], 'notFormedNum', noAdultCount);
  238. },
  239. getSemiProductList(newVal) {
  240. console.log(newVal);
  241. if (newVal.semiProductList.length) {
  242. newVal.semiProductList.map(v => {
  243. v.selected = true;
  244. })
  245. this.arrDataStatistics(newVal.semiProductList);
  246. this.tableData = newVal.semiProductList;
  247. }
  248. if (newVal.pickOutInList.length) {
  249. newVal.pickOutInList.map(v => {
  250. v.selected = true;
  251. })
  252. this.arrDataStatistics(newVal.pickOutInList);
  253. this.tableData = newVal.pickOutInList;
  254. }
  255. },
  256. singleQuery() {
  257. console.log(this.item.workReportInfo);
  258. if (!this.item.workReportInfo.formedNum) return uni.showToast({
  259. icon: 'none',
  260. title: "请输入合格品数"
  261. })
  262. if (this.notFormedList[0].notFormedNum == '' || this.notFormedList[0].notFormedNum == null) return uni.showToast({
  263. icon: 'none',
  264. title: "请输入不合格品数"
  265. })
  266. const req = {
  267. "formedNum": this.item.workReportInfo.formedNum,
  268. "notFormedNum": this.notFormedList[0].notFormedNum,
  269. "taskId": this.item.workReportInfo.taskId,
  270. "workOrderId": this.item.workReportInfo.workOrderId
  271. };
  272. createInProduct(req).then(res => {
  273. if (res && res.length) {
  274. this.forValue = res[0];
  275. res.map(v => {
  276. v.selected = true;
  277. })
  278. this.tableData = res;
  279. this.item.semiProductList = res;
  280. }
  281. })
  282. },
  283. /**
  284. * 更新批次号
  285. *
  286. * @param e 事件对象
  287. */
  288. batchNoNew(e) {
  289. this.item.workReportInfo.batchNo = this.item.batchNo + e.target.value;
  290. },
  291. setFormedNum(num) {
  292. this.item.workReportInfo.formedNum = num
  293. let weight = Number(this.item.workReportInfo.formedNum) * Number(this.item.singleWeight) * Number(this
  294. .item.weightMultiple)
  295. if (['G', 'g', '克'].includes(this.item.singleWeightUnit)) {
  296. weight = parseFloat((weight / 1000).toFixed(2))
  297. } else {
  298. weight = parseFloat(weight.toFixed(2))
  299. }
  300. this.$set(this.item.workReportInfo, 'formedWeight', weight)
  301. this.$forceUpdate()
  302. },
  303. penalize() {
  304. this.$emit('penalize', null)
  305. },
  306. handleView(name) {
  307. uni.showToast({
  308. icon: 'none',
  309. title: name || '未设置'
  310. })
  311. },
  312. blurNum(value) {
  313. let total = 0;
  314. //匹配非数字
  315. let val = value.formedNum;
  316. let reg = new RegExp("([^0-9]*)", "g");
  317. let ma = val.match(reg);
  318. //如果有非数字,替换成""
  319. if (ma.length > 0) {
  320. for (let k in ma) {
  321. if (ma[k] != "") {
  322. val = val.replace(ma[k], 0);
  323. }
  324. }
  325. }
  326. //可以为0,但不能以0开头
  327. if (val.startsWith("0") && val.length > 1) {
  328. val = val.substring(1, val.length);
  329. }
  330. value.formedNum = val;
  331. if (this.item.currentTaskDiagram.isFirstTask) {
  332. // formingNum 生产数量 feedQuantity this.item.product[0] //投料数量
  333. if (value.formedNum > this.item.formingNum) {
  334. this.$set(this.item.workReportInfo, 'workReportInfo', this.item.formingNum)
  335. this.$set(this.notFormedList[0], 'notFormedNum', 0)
  336. this.notForme()
  337. return uni.showToast({
  338. icon: 'none',
  339. title: '合格品数量不能大于要求生产数量'
  340. })
  341. }
  342. } else {
  343. if (this.item.product.length) {
  344. if (value.formedNum > this.item.product[0].feedQuantity) {
  345. console.log(this.item.product[0].feedQuantity);
  346. this.$set(this.item.workReportInfo, 'workReportInfo', this.item.product[0].feedQuantity)
  347. this.$set(this.notFormedList[0], 'notFormedNum', 0)
  348. this.notForme()
  349. return uni.showToast({
  350. icon: 'none',
  351. title: '合格品数量不能大于投料数量'
  352. })
  353. }
  354. }
  355. }
  356. if (this.item.product[0] && this.item.product[0].feedQuantity > 0 && Number(this.item.workReportInfo
  357. .formedNum)) {
  358. this.$set(this.notFormedList[0], 'notFormedNum', this.item.product[0].feedQuantity - Number(this.item
  359. .workReportInfo.formedNum))
  360. this.notForme()
  361. }
  362. let weight = Number(this.item.workReportInfo.formedNum) * Number(this.item.singleWeight) * Number(this
  363. .item.weightMultiple)
  364. if (['G', 'g', '克'].includes(this.item.singleWeightUnit)) {
  365. weight = parseFloat((weight / 1000).toFixed(2))
  366. } else {
  367. weight = parseFloat(weight.toFixed(2))
  368. }
  369. this.$set(this.item.workReportInfo, 'formedWeight', weight)
  370. total = Number(this.item.workReportInfo.formedNum) + Number(this.notFormedList[0].notFormedNum)
  371. console.log(total);
  372. this.$emit('modeNum', total)
  373. this.$forceUpdate()
  374. },
  375. notForme() {
  376. let weight = Number(this.notFormedList[0].notFormedNum) * Number(this.item.singleWeight) * Number(this
  377. .item.weightMultiple)
  378. if (this.item.singleWeightUnit == 'G' || this.item.singleWeightUnit == 'g' || this.item.singleWeightUnit ==
  379. '克') {
  380. weight = parseFloat((weight / 1000).toFixed(2))
  381. } else {
  382. weight = parseFloat(weight.toFixed(2))
  383. }
  384. this.$set(this.notFormedList[0], 'notFormedWeight', weight)
  385. if (this.item.product[0] && this.item.product[0].feedQuantity > 0 && Number(this.notFormedList[0]
  386. .notFormedNum)) {
  387. this.$set(this.item.workReportInfo, 'formedNum', this.item.product[0].feedQuantity - Number(this
  388. .notFormedList[0]
  389. .notFormedNum))
  390. let weight = Number(this.item.workReportInfo.formedNum) * Number(this.item.singleWeight) * Number(this
  391. .item.weightMultiple)
  392. if (this.item.singleWeightUnit == 'G' || this.item.singleWeightUnit == 'g' || this.item
  393. .singleWeightUnit == '克') {
  394. weight = parseFloat((weight / 1000).toFixed(2))
  395. } else {
  396. weight = parseFloat(weight.toFixed(2))
  397. }
  398. this.$set(this.item.workReportInfo, 'formedWeight', weight)
  399. }
  400. this.$forceUpdate()
  401. },
  402. changeNum(value) {
  403. // 不合格数量
  404. let val = value.notFormedNum;
  405. //匹配非数字
  406. let reg = new RegExp("([^0-9]*)", "g");
  407. let ma = val.match(reg);
  408. //如果有非数字,替换成""
  409. if (ma.length > 0) {
  410. for (let k in ma) {
  411. if (ma[k] != "") {
  412. val = val.replace(ma[k], "0");
  413. }
  414. }
  415. }
  416. //可以为0,但不能以0开头
  417. if (val.startsWith("0") && val.length > 1) {
  418. val = val.substring(1, val.length);
  419. }
  420. // this.$set(this.item.workReportInfo, 'formedNum', val)
  421. value.notFormedNum = val;
  422. console.log(Number(this.item.workReportInfo.formedNum), 1);
  423. console.log(Number(this.notFormedList[0].notFormedNum), 2);
  424. let total = Number(this.item.workReportInfo.formedNum) + Number(this.notFormedList[0].notFormedNum)
  425. console.log(total);
  426. this.$emit('modeNum', total)
  427. this.notForme()
  428. // this.blurNum()
  429. },
  430. }
  431. }
  432. </script>
  433. <style lang="scss" scoped>
  434. .unit-btn {
  435. background-color: #157A2C;
  436. height: 48rpx;
  437. padding: 0 20rpx;
  438. line-height: 48rpx;
  439. color: #fff;
  440. }
  441. .content_num {
  442. display: flex;
  443. align-items: center;
  444. padding: 0 4rpx;
  445. font-size: 26rpx !important;
  446. /deep/ .uni-input-input {
  447. border: 2rpx solid #F0F8F2;
  448. background: #F0F8F2;
  449. color: $theme-color;
  450. }
  451. }
  452. .item {
  453. display: flex;
  454. justify-content: space-between;
  455. }
  456. .title_box {
  457. margin-top: 20rpx;
  458. .name {
  459. font-size: 28rpx;
  460. font-style: normal;
  461. font-weight: 400;
  462. color: $theme-color;
  463. padding-left: 20rpx;
  464. position: relative;
  465. &:before {
  466. position: absolute;
  467. content: '';
  468. left: 0rpx;
  469. top: 0rpx;
  470. bottom: 0rpx;
  471. width: 4rpx;
  472. height: 28rpx;
  473. background: $theme-color;
  474. margin: auto;
  475. }
  476. }
  477. }
  478. .material {
  479. margin-top: 10rpx;
  480. .content_table {
  481. width: 100%;
  482. border: 2rpx solid $border-color;
  483. .item {
  484. display: flex;
  485. border-bottom: 2rpx solid $border-color;
  486. .lable {
  487. width: 132rpx;
  488. text-align: center;
  489. background-color: #F7F9FA;
  490. font-size: 26rpx;
  491. border-right: 2rpx solid $border-color;
  492. flex-shrink: 0;
  493. }
  494. .lable220 {
  495. width: 220rpx !important;
  496. font-size: 24rpx;
  497. }
  498. .lable150 {
  499. width: 156rpx !important;
  500. font-size: 24rpx;
  501. }
  502. .ww80 {
  503. width: 80rpx;
  504. }
  505. .content {
  506. width: 518rpx;
  507. min-height: 64rpx;
  508. font-size: 28rpx;
  509. line-height: 28rpx;
  510. font-style: normal;
  511. font-weight: 400;
  512. padding: 18rpx 8rpx;
  513. box-sizing: border-box;
  514. word-wrap: break-word;
  515. flex-grow: 1 !important;
  516. .unit {
  517. padding: 0 4rpx;
  518. font-size: 24rpx;
  519. color: #404446;
  520. }
  521. .penalize {
  522. width: 160rpx;
  523. line-height: 60rpx;
  524. background: $theme-color;
  525. font-size: 24rpx;
  526. text-align: center;
  527. color: #fff;
  528. }
  529. }
  530. .pd4 {
  531. padding: 4rpx 8rpx;
  532. }
  533. &:last-child {
  534. border-bottom: none;
  535. }
  536. }
  537. .ww55 {
  538. width: 55%;
  539. }
  540. .ww45 {
  541. width: 45%;
  542. }
  543. }
  544. }
  545. </style>