jobBom.vue 11 KB

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