jobBom.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615
  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 class="uni-input" v-model="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="formedWeight" type="digit"
  46. :disabled="isDetails" @input="blurWeight()"></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" :disabled="isDetails"
  57. v-if="isDetails"
  58. @input="changeNum"></input>
  59. <input class="uni-input" v-model="notFormedNum" type="number"
  60. v-else
  61. @input="blurNum2(item.workReportInfo)"></input>
  62. <view class="unit">{{ item.unit }}</view>
  63. </view>
  64. </view>
  65. <view class="rx ww45">
  66. <view class="lable rx-cc ww80">重量</view>
  67. <view class="content content_num">
  68. <input class="uni-input" v-model="item.workReportInfo.notFormedWeight" type="digit"
  69. :disabled="isDetails" v-if="isDetails"></input>
  70. <input class="uni-input" v-model="notFormedWeight" type="digit"
  71. :disabled="isDetails" v-else @input="blurWeight2()"></input>
  72. <view class="unit">{{ item.weightUnit }}</view>
  73. <!-- <view class="penalize" v-if='!isDetails'
  74. :style="{ background: not.warehouseId ? '#FFA07A' : '' }" @click="penalize">处置</view> -->
  75. <!-- <view class="penalize" v-if='isDetails'
  76. :style="{ background: not.warehouseId ? '#FFA07A' : '' }"
  77. @click="handleView(isDetails ? not.warehouseName : item.warehouseName)">查看</view> -->
  78. </view>
  79. </view>
  80. </view>
  81. <view class="item rx-sc">
  82. <view class="rx ww55 ">
  83. <view class="lable lable150 rx-cc ">报工备注</view>
  84. <view class="content content_num" style="width: 100%;">
  85. <input class="uni-input" v-model="item.workReportInfo.remark" :disabled="isDetails"
  86. type="text"></input>
  87. </view>
  88. </view>
  89. <!-- v-if="clientEnvironmentId==2" -->
  90. <view class="rx ww45 " v-if="clientEnvironmentId==2">
  91. <view class="lable ww80 rx-cc ">批次号</view>
  92. <view class="content content_num" style="width: 100%;">
  93. {{ item.batchNo }}
  94. <input class="uni-input" v-model="batchNo" @input="batchNoNew" :disabled="isDetails"
  95. type="text"></input>
  96. </view>
  97. </view>
  98. </view>
  99. </view>
  100. </view>
  101. </view>
  102. </template>
  103. <script>
  104. export default {
  105. props: {
  106. item: {
  107. type: Object,
  108. default: () => { }
  109. },
  110. notFormed: {
  111. type: Array,
  112. default: () => []
  113. },
  114. isDetails: {
  115. type: Boolean,
  116. default: false
  117. },
  118. },
  119. watch: {
  120. notFormed: {
  121. immediate: true,
  122. deep: true,
  123. handler(newVal) {
  124. this.notFormedList = newVal
  125. }
  126. },
  127. // item:{
  128. // immediate: true,
  129. // deep: true,
  130. // handler(newVal) {
  131. // console.log('ccccc吃饭了',newVal)
  132. // this.$forceUpdate()
  133. // }
  134. // }
  135. },
  136. data() {
  137. return {
  138. batchNo:'',
  139. notFormedList: [],
  140. clientEnvironmentId: uni.getStorageSync("userInfo") && uni.getStorageSync("userInfo")
  141. .clientEnvironmentId, // *1 主环境-601环境 2 soll-索尔环境 3 tg-碳谷环境
  142. formedNum:'',
  143. formedWeight:'',
  144. notFormedNum:'',
  145. notFormedWeight:'',
  146. }
  147. },
  148. created() {
  149. if (this.isDetails) {
  150. this.notFormedList = this.notFormedList.map(m => {
  151. return {
  152. notFormedNum: Number(m.quantity),
  153. notFormedWeight: m.weight,
  154. ...m
  155. }
  156. })
  157. }
  158. },
  159. methods: {
  160. fWeightInput(formedWeight,notFormedWeight){
  161. this.formedWeight=formedWeight
  162. this.$forceUpdate()
  163. },
  164. formedTotal(formedNumCount,formedWeightCount,notFormedNumCount,notFormedWeightCount){
  165. this.formedNum=formedNumCount
  166. this.formedWeight=formedWeightCount
  167. this.notFormedNum=notFormedNumCount,
  168. this.notFormedWeight=notFormedWeightCount,
  169. this.$forceUpdate()
  170. },
  171. batchNoNew(e){
  172. this.item.workReportInfo.batchNo = this.item.batchNo+e.target.value;
  173. },
  174. setFormedNum(num) {
  175. this.item.workReportInfo.formedNum = num
  176. let weight = Number(this.item.workReportInfo.formedNum) * Number(this.item.singleWeight) * Number(this
  177. .item.weightMultiple)
  178. if (['G', 'g', '克'].includes(this.item.singleWeightUnit)) {
  179. weight = parseFloat((weight / 1000).toFixed(2))
  180. } else {
  181. weight = parseFloat(weight.toFixed(2))
  182. }
  183. this.$set(this.item.workReportInfo, 'formedWeight', weight)
  184. this.$forceUpdate()
  185. },
  186. penalize() {
  187. this.$emit('penalize', null)
  188. },
  189. handleView(name) {
  190. uni.showToast({
  191. icon: 'none',
  192. title: name || '未设置'
  193. })
  194. },
  195. blurNum(value) {
  196. this.$set(this.item.workReportInfo, 'formedNum', this.formedNum)
  197. let total = 0;
  198. //匹配非数字
  199. let val=value.formedNum;
  200. let reg = new RegExp("([^0-9]*)","g");
  201. let ma = val.match(reg);
  202. //如果有非数字,替换成""
  203. if(ma.length>0){
  204. for(let k in ma){
  205. if(ma[k]!=""){
  206. val = val.replace(ma[k],0);
  207. }
  208. }
  209. }
  210. //可以为0,但不能以0开头
  211. if(val.startsWith("0")&&val.length>1){
  212. val = val.substring(1,val.length);
  213. }
  214. value.formedNum=val;
  215. if (this.item.currentTaskDiagram.isFirstTask) {
  216. // formingNum 生产数量 feedQuantity this.item.product[0] //投料数量
  217. if (value.formedNum > this.item.formingNum) {
  218. this.$set(this.item.workReportInfo, 'workReportInfo', this.item.formingNum)
  219. this.$set(this.notFormedList[0], 'notFormedNum', 0)
  220. this.formedNum=0
  221. this.$forceUpdate()
  222. this.notForme()
  223. return uni.showToast({
  224. icon: 'none',
  225. title: '合格品数量不能大于要求生产数量'
  226. })
  227. }
  228. } else {
  229. if (this.item.product.length) {
  230. if (value.formedNum > this.item.product[0].feedQuantity) {
  231. console.log(this.item.product[0].feedQuantity);
  232. this.$set(this.item.workReportInfo, 'workReportInfo', this.item.product[0].feedQuantity)
  233. this.$set(this.notFormedList[0], 'notFormedNum', 0)
  234. this.formedNum=0
  235. this.$forceUpdate()
  236. this.notForme()
  237. return uni.showToast({
  238. icon: 'none',
  239. title: '合格品数量不能大于投料数量'
  240. })
  241. }
  242. }
  243. }
  244. if (this.item.product[0] && this.item.product[0].feedQuantity > 0 && Number(this.item.workReportInfo
  245. .formedNum)) {
  246. this.$set(this.notFormedList[0], 'notFormedNum', this.item.product[0].feedQuantity - Number(this.item
  247. .workReportInfo.formedNum))
  248. this.notForme()
  249. }
  250. let weight = Number(this.item.workReportInfo.formedNum) * Number(this.item.singleWeight) * Number(this
  251. .item.weightMultiple)
  252. if (['G', 'g', '克'].includes(this.item.singleWeightUnit)) {
  253. weight = parseFloat((weight / 1000).toFixed(2))
  254. } else {
  255. weight = parseFloat(weight.toFixed(2))
  256. }
  257. this.$set(this.item.workReportInfo, 'formedWeight', weight)
  258. total = Number(this.item.workReportInfo.formedNum) + Number(this.notFormedList[0].notFormedNum)
  259. console.log(total);
  260. this.$emit('modeNum', total)
  261. this.$forceUpdate()
  262. },
  263. blurNum2(value) {
  264. this.$set(this.item.workReportInfo, 'notFormedNum', this.notFormedNum)
  265. let total = 0;
  266. //匹配非数字
  267. let val=value.notFormedNum;
  268. let reg = new RegExp("([^0-9]*)","g");
  269. let ma = val.match(reg);
  270. //如果有非数字,替换成""
  271. if(ma.length>0){
  272. for(let k in ma){
  273. if(ma[k]!=""){
  274. val = val.replace(ma[k],0);
  275. }
  276. }
  277. }
  278. //可以为0,但不能以0开头
  279. if(val.startsWith("0")&&val.length>1){
  280. val = val.substring(1,val.length);
  281. }
  282. value.notFormedNum=val;
  283. if (this.item.currentTaskDiagram.isFirstTask) {
  284. // formingNum 生产数量 feedQuantity this.item.product[0] //投料数量
  285. if (value.notFormedNum > this.item.formingNum) {
  286. this.$set(this.item.workReportInfo, 'workReportInfo', this.item.formingNum)
  287. this.$set(this.notFormedList[0], 'notFormedNum', 0)
  288. this.notFormedNum=0
  289. this.$forceUpdate()
  290. this.notForme()
  291. return uni.showToast({
  292. icon: 'none',
  293. title: '不合格品数量不能大于要求生产数量'
  294. })
  295. }
  296. } else {
  297. if (this.item.product.length) {
  298. if (value.formedNum > this.item.product[0].feedQuantity) {
  299. console.log(this.item.product[0].feedQuantity);
  300. this.$set(this.item.workReportInfo, 'workReportInfo', this.item.product[0].feedQuantity)
  301. this.$set(this.notFormedList[0], 'notFormedNum', 0)
  302. this.notFormedNum=0
  303. this.$forceUpdate()
  304. this.notForme()
  305. return uni.showToast({
  306. icon: 'none',
  307. title: '合格品数量不能大于投料数量'
  308. })
  309. }
  310. }
  311. }
  312. },
  313. blurWeight(){
  314. this.$set(this.item.workReportInfo, 'formedWeight', this.formedWeight)
  315. },
  316. blurWeight2(){
  317. this.$set(this.item.workReportInfo, 'notFormedWeight', this.notFormedWeight)
  318. },
  319. notForme() {
  320. let weight = Number(this.notFormedList[0].notFormedNum) * Number(this.item.singleWeight) * Number(this
  321. .item.weightMultiple)
  322. if (this.item.singleWeightUnit == 'G' || this.item.singleWeightUnit == 'g' || this.item.singleWeightUnit ==
  323. '克') {
  324. weight = parseFloat((weight / 1000).toFixed(2))
  325. } else {
  326. weight = parseFloat(weight.toFixed(2))
  327. }
  328. this.$set(this.notFormedList[0], 'notFormedWeight', weight)
  329. if (this.item.product[0] && this.item.product[0].feedQuantity > 0 && Number(this.notFormedList[0]
  330. .notFormedNum)) {
  331. this.$set(this.item.workReportInfo, 'formedNum', this.item.product[0].feedQuantity - Number(this
  332. .notFormedList[0]
  333. .notFormedNum))
  334. let weight = Number(this.item.workReportInfo.formedNum) * Number(this.item.singleWeight) * Number(this
  335. .item.weightMultiple)
  336. if (this.item.singleWeightUnit == 'G' || this.item.singleWeightUnit == 'g' || this.item
  337. .singleWeightUnit == '克') {
  338. weight = parseFloat((weight / 1000).toFixed(2))
  339. } else {
  340. weight = parseFloat(weight.toFixed(2))
  341. }
  342. this.$set(this.item.workReportInfo, 'formedWeight', weight)
  343. }
  344. this.$forceUpdate()
  345. },
  346. changeNum(value) {
  347. // 不合格数量
  348. let val = value.notFormedNum;
  349. //匹配非数字
  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. // this.$set(this.item.workReportInfo, 'formedNum', val)
  365. value.notFormedNum = val;
  366. console.log(Number(this.item.workReportInfo.formedNum),1);
  367. console.log( Number(this.notFormedList[0].notFormedNum),2);
  368. let total = Number(this.item.workReportInfo.formedNum) + Number(this.notFormedList[0].notFormedNum)
  369. console.log(total);
  370. this.$emit('modeNum', total)
  371. this.notForme()
  372. // this.blurNum()
  373. },
  374. }
  375. }
  376. </script>
  377. <style lang="scss" scoped>
  378. .title_box {
  379. margin-top: 20rpx;
  380. .name {
  381. font-size: 28rpx;
  382. font-style: normal;
  383. font-weight: 400;
  384. color: $theme-color;
  385. padding-left: 20rpx;
  386. position: relative;
  387. &:before {
  388. position: absolute;
  389. content: '';
  390. left: 0rpx;
  391. top: 0rpx;
  392. bottom: 0rpx;
  393. width: 4rpx;
  394. height: 28rpx;
  395. background: $theme-color;
  396. margin: auto;
  397. }
  398. }
  399. }
  400. .material {
  401. margin-top: 10rpx;
  402. .content_table {
  403. width: 100%;
  404. border: 2rpx solid $border-color;
  405. .item {
  406. display: flex;
  407. border-bottom: 2rpx solid $border-color;
  408. .lable {
  409. width: 132rpx;
  410. text-align: center;
  411. background-color: #F7F9FA;
  412. font-size: 26rpx;
  413. border-right: 2rpx solid $border-color;
  414. flex-shrink: 0;
  415. }
  416. .lable220 {
  417. width: 220rpx !important;
  418. font-size: 24rpx;
  419. }
  420. .lable150 {
  421. width: 156rpx !important;
  422. font-size: 24rpx;
  423. }
  424. .ww80 {
  425. width: 80rpx;
  426. }
  427. .content {
  428. width: 518rpx;
  429. min-height: 64rpx;
  430. font-size: 28rpx;
  431. line-height: 28rpx;
  432. font-style: normal;
  433. font-weight: 400;
  434. padding: 18rpx 8rpx;
  435. box-sizing: border-box;
  436. word-wrap: break-word;
  437. flex-grow: 1 !important;
  438. .unit {
  439. padding: 0 4rpx;
  440. font-size: 24rpx;
  441. color: #404446;
  442. }
  443. .penalize {
  444. width: 160rpx;
  445. line-height: 60rpx;
  446. background: $theme-color;
  447. font-size: 24rpx;
  448. text-align: center;
  449. color: #fff;
  450. }
  451. }
  452. .content_num {
  453. display: flex;
  454. align-items: center;
  455. padding: 0 4rpx;
  456. /deep/ .uni-input-input {
  457. border: 2rpx solid #F0F8F2;
  458. background: #F0F8F2;
  459. color: $theme-color;
  460. }
  461. }
  462. .pd4 {
  463. padding: 4rpx 8rpx;
  464. }
  465. &:last-child {
  466. border-bottom: none;
  467. }
  468. }
  469. .ww55 {
  470. width: 55%;
  471. }
  472. .ww45 {
  473. width: 45%;
  474. }
  475. }
  476. }
  477. </style>