jobBom.vue 11 KB

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