jobBom.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538
  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="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="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" :disabled="isDetails"
  57. v-if="isDetails"
  58. @input="changeNum"></input>
  59. <input class="uni-input" v-model="not.notFormedNum" type="number"
  60. v-else
  61. @input="changeNum(not)"></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="not.notFormedWeight" type="digit"
  71. :disabled="isDetails" v-else></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. formedWeight:'',
  143. }
  144. },
  145. created() {
  146. if (this.isDetails) {
  147. this.notFormedList = this.notFormedList.map(m => {
  148. return {
  149. notFormedNum: Number(m.quantity),
  150. notFormedWeight: m.weight,
  151. ...m
  152. }
  153. })
  154. }
  155. },
  156. methods: {
  157. fWeightInput(formedWeight,notFormedWeight){
  158. this.formedWeight=formedWeight
  159. this.$forceUpdate()
  160. },
  161. batchNoNew(e){
  162. this.item.workReportInfo.batchNo = this.item.batchNo+e.target.value;
  163. },
  164. setFormedNum(num) {
  165. this.item.workReportInfo.formedNum = num
  166. let weight = Number(this.item.workReportInfo.formedNum) * Number(this.item.singleWeight) * Number(this
  167. .item.weightMultiple)
  168. if (['G', 'g', '克'].includes(this.item.singleWeightUnit)) {
  169. weight = parseFloat((weight / 1000).toFixed(2))
  170. } else {
  171. weight = parseFloat(weight.toFixed(2))
  172. }
  173. this.$set(this.item.workReportInfo, 'formedWeight', weight)
  174. this.$forceUpdate()
  175. },
  176. penalize() {
  177. this.$emit('penalize', null)
  178. },
  179. handleView(name) {
  180. uni.showToast({
  181. icon: 'none',
  182. title: name || '未设置'
  183. })
  184. },
  185. blurNum(value) {
  186. let total = 0;
  187. //匹配非数字
  188. let val=value.formedNum;
  189. let reg = new RegExp("([^0-9]*)","g");
  190. let ma = val.match(reg);
  191. //如果有非数字,替换成""
  192. if(ma.length>0){
  193. for(let k in ma){
  194. if(ma[k]!=""){
  195. val = val.replace(ma[k],0);
  196. }
  197. }
  198. }
  199. //可以为0,但不能以0开头
  200. if(val.startsWith("0")&&val.length>1){
  201. val = val.substring(1,val.length);
  202. }
  203. value.formedNum=val;
  204. if (this.item.currentTaskDiagram.isFirstTask) {
  205. // formingNum 生产数量 feedQuantity this.item.product[0] //投料数量
  206. if (value.formedNum > this.item.formingNum) {
  207. this.$set(this.item.workReportInfo, 'workReportInfo', this.item.formingNum)
  208. this.$set(this.notFormedList[0], 'notFormedNum', 0)
  209. this.notForme()
  210. return uni.showToast({
  211. icon: 'none',
  212. title: '合格品数量不能大于要求生产数量'
  213. })
  214. }
  215. } else {
  216. if (this.item.product.length) {
  217. if (value.formedNum > this.item.product[0].feedQuantity) {
  218. console.log(this.item.product[0].feedQuantity);
  219. this.$set(this.item.workReportInfo, 'workReportInfo', this.item.product[0].feedQuantity)
  220. this.$set(this.notFormedList[0], 'notFormedNum', 0)
  221. this.notForme()
  222. return uni.showToast({
  223. icon: 'none',
  224. title: '合格品数量不能大于投料数量'
  225. })
  226. }
  227. }
  228. }
  229. if (this.item.product[0] && this.item.product[0].feedQuantity > 0 && Number(this.item.workReportInfo
  230. .formedNum)) {
  231. this.$set(this.notFormedList[0], 'notFormedNum', this.item.product[0].feedQuantity - Number(this.item
  232. .workReportInfo.formedNum))
  233. this.notForme()
  234. }
  235. let weight = Number(this.item.workReportInfo.formedNum) * Number(this.item.singleWeight) * Number(this
  236. .item.weightMultiple)
  237. if (['G', 'g', '克'].includes(this.item.singleWeightUnit)) {
  238. weight = parseFloat((weight / 1000).toFixed(2))
  239. } else {
  240. weight = parseFloat(weight.toFixed(2))
  241. }
  242. this.$set(this.item.workReportInfo, 'formedWeight', weight)
  243. total = Number(this.item.workReportInfo.formedNum) + Number(this.notFormedList[0].notFormedNum)
  244. console.log(total);
  245. this.$emit('modeNum', total)
  246. this.$forceUpdate()
  247. },
  248. notForme() {
  249. let weight = Number(this.notFormedList[0].notFormedNum) * Number(this.item.singleWeight) * Number(this
  250. .item.weightMultiple)
  251. if (this.item.singleWeightUnit == 'G' || this.item.singleWeightUnit == 'g' || this.item.singleWeightUnit ==
  252. '克') {
  253. weight = parseFloat((weight / 1000).toFixed(2))
  254. } else {
  255. weight = parseFloat(weight.toFixed(2))
  256. }
  257. this.$set(this.notFormedList[0], 'notFormedWeight', weight)
  258. if (this.item.product[0] && this.item.product[0].feedQuantity > 0 && Number(this.notFormedList[0]
  259. .notFormedNum)) {
  260. this.$set(this.item.workReportInfo, 'formedNum', this.item.product[0].feedQuantity - Number(this
  261. .notFormedList[0]
  262. .notFormedNum))
  263. let weight = Number(this.item.workReportInfo.formedNum) * Number(this.item.singleWeight) * Number(this
  264. .item.weightMultiple)
  265. if (this.item.singleWeightUnit == 'G' || this.item.singleWeightUnit == 'g' || this.item
  266. .singleWeightUnit == '克') {
  267. weight = parseFloat((weight / 1000).toFixed(2))
  268. } else {
  269. weight = parseFloat(weight.toFixed(2))
  270. }
  271. this.$set(this.item.workReportInfo, 'formedWeight', weight)
  272. }
  273. this.$forceUpdate()
  274. },
  275. changeNum(value) {
  276. // 不合格数量
  277. let val = value.notFormedNum;
  278. //匹配非数字
  279. let reg = new RegExp("([^0-9]*)","g");
  280. let ma = val.match(reg);
  281. //如果有非数字,替换成""
  282. if(ma.length>0){
  283. for(let k in ma){
  284. if(ma[k]!=""){
  285. val = val.replace(ma[k],"0");
  286. }
  287. }
  288. }
  289. //可以为0,但不能以0开头
  290. if(val.startsWith("0")&&val.length>1){
  291. val = val.substring(1,val.length);
  292. }
  293. // this.$set(this.item.workReportInfo, 'formedNum', val)
  294. value.notFormedNum = val;
  295. console.log(Number(this.item.workReportInfo.formedNum),1);
  296. console.log( Number(this.notFormedList[0].notFormedNum),2);
  297. let total = Number(this.item.workReportInfo.formedNum) + Number(this.notFormedList[0].notFormedNum)
  298. console.log(total);
  299. this.$emit('modeNum', total)
  300. this.notForme()
  301. // this.blurNum()
  302. },
  303. }
  304. }
  305. </script>
  306. <style lang="scss" scoped>
  307. .title_box {
  308. margin-top: 20rpx;
  309. .name {
  310. font-size: 28rpx;
  311. font-style: normal;
  312. font-weight: 400;
  313. color: $theme-color;
  314. padding-left: 20rpx;
  315. position: relative;
  316. &:before {
  317. position: absolute;
  318. content: '';
  319. left: 0rpx;
  320. top: 0rpx;
  321. bottom: 0rpx;
  322. width: 4rpx;
  323. height: 28rpx;
  324. background: $theme-color;
  325. margin: auto;
  326. }
  327. }
  328. }
  329. .material {
  330. margin-top: 10rpx;
  331. .content_table {
  332. width: 100%;
  333. border: 2rpx solid $border-color;
  334. .item {
  335. display: flex;
  336. border-bottom: 2rpx solid $border-color;
  337. .lable {
  338. width: 132rpx;
  339. text-align: center;
  340. background-color: #F7F9FA;
  341. font-size: 26rpx;
  342. border-right: 2rpx solid $border-color;
  343. flex-shrink: 0;
  344. }
  345. .lable220 {
  346. width: 220rpx !important;
  347. font-size: 24rpx;
  348. }
  349. .lable150 {
  350. width: 156rpx !important;
  351. font-size: 24rpx;
  352. }
  353. .ww80 {
  354. width: 80rpx;
  355. }
  356. .content {
  357. width: 518rpx;
  358. min-height: 64rpx;
  359. font-size: 28rpx;
  360. line-height: 28rpx;
  361. font-style: normal;
  362. font-weight: 400;
  363. padding: 18rpx 8rpx;
  364. box-sizing: border-box;
  365. word-wrap: break-word;
  366. flex-grow: 1 !important;
  367. .unit {
  368. padding: 0 4rpx;
  369. font-size: 24rpx;
  370. color: #404446;
  371. }
  372. .penalize {
  373. width: 160rpx;
  374. line-height: 60rpx;
  375. background: $theme-color;
  376. font-size: 24rpx;
  377. text-align: center;
  378. color: #fff;
  379. }
  380. }
  381. .content_num {
  382. display: flex;
  383. align-items: center;
  384. padding: 0 4rpx;
  385. /deep/ .uni-input-input {
  386. border: 2rpx solid #F0F8F2;
  387. background: #F0F8F2;
  388. color: $theme-color;
  389. }
  390. }
  391. .pd4 {
  392. padding: 4rpx 8rpx;
  393. }
  394. &:last-child {
  395. border-bottom: none;
  396. }
  397. }
  398. .ww55 {
  399. width: 55%;
  400. }
  401. .ww45 {
  402. width: 45%;
  403. }
  404. }
  405. }
  406. </style>