jobBom.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533
  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="true"
  38. 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. @input="changeNum"></input>
  58. <input class="uni-input" v-model="not.notFormedNum" type="number"
  59. ></input>
  60. <!-- @input="changeNum(not)" -->
  61. <view class="unit">{{ item.unit }}</view>
  62. </view>
  63. </view>
  64. <view class="rx ww45">
  65. <view class="lable rx-cc ww80">重量</view>
  66. <view class="content content_num">
  67. <input class="uni-input" v-model="item.workReportInfo.notFormedWeight" type="digit"
  68. :disabled="isDetails" ></input>
  69. <input class="uni-input" v-model="not.notFormedWeight" type="digit"
  70. :disabled="isDetails" ></input>
  71. <view class="unit">{{ item.weightUnit }}</view>
  72. <!-- <view class="penalize" v-if='!isDetails'
  73. :style="{ background: not.warehouseId ? '#FFA07A' : '' }" @click="penalize">处置</view> -->
  74. <!-- <view class="penalize" v-if='isDetails'
  75. :style="{ background: not.warehouseId ? '#FFA07A' : '' }"
  76. @click="handleView(isDetails ? not.warehouseName : item.warehouseName)">查看</view> -->
  77. </view>
  78. </view>
  79. </view>
  80. <view class="item rx-sc">
  81. <view class="rx ww55 ">
  82. <view class="lable lable150 rx-cc ">报工备注</view>
  83. <view class="content content_num" style="width: 100%;">
  84. <input class="uni-input" v-model="item.workReportInfo.remark" :disabled="isDetails"
  85. type="text"></input>
  86. </view>
  87. </view>
  88. <view class="rx ww45 ">
  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="item.workReportInfo.remark" :disabled="isDetails"
  93. type="text"></input>
  94. </view>
  95. </view>
  96. </view>
  97. </view>
  98. </view>
  99. </view>
  100. </template>
  101. <script>
  102. export default {
  103. props: {
  104. item: {
  105. type: Object,
  106. default: () => { }
  107. },
  108. notFormed: {
  109. type: Array,
  110. default: () => []
  111. },
  112. isDetails: {
  113. type: Boolean,
  114. default: false
  115. },
  116. },
  117. watch: {
  118. notFormed: {
  119. immediate: true,
  120. deep: true,
  121. handler(newVal) {
  122. this.notFormedList = newVal
  123. }
  124. }
  125. },
  126. data() {
  127. return {
  128. notFormedList: [],
  129. clientEnvironmentId: uni.getStorageSync("userInfo") && uni.getStorageSync("userInfo")
  130. .clientEnvironmentId, // *1 主环境-601环境 2 soll-索尔环境 3 tg-碳谷环境
  131. }
  132. },
  133. created() {
  134. if (this.isDetails) {
  135. this.notFormedList = this.notFormedList.map(m => {
  136. return {
  137. notFormedNum: Number(m.quantity),
  138. notFormedWeight: m.weight,
  139. ...m
  140. }
  141. })
  142. }
  143. },
  144. methods: {
  145. setFormedNum(num) {
  146. this.item.workReportInfo.formedNum = num
  147. let weight = Number(this.item.workReportInfo.formedNum) * Number(this.item.singleWeight) * Number(this
  148. .item.weightMultiple)
  149. if (['G', 'g', '克'].includes(this.item.singleWeightUnit)) {
  150. weight = parseFloat((weight / 1000).toFixed(2))
  151. } else {
  152. weight = parseFloat(weight.toFixed(2))
  153. }
  154. this.$set(this.item.workReportInfo, 'formedWeight', weight)
  155. this.$forceUpdate()
  156. },
  157. penalize() {
  158. this.$emit('penalize', null)
  159. },
  160. handleView(name) {
  161. uni.showToast({
  162. icon: 'none',
  163. title: name || '未设置'
  164. })
  165. },
  166. blurNum(value) {
  167. console.log(num,'6666666666666');
  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. modeNum(num) {
  231. console.log(num, '------------', this.objData.modelList.length);
  232. if (this.objData.modelList.length == 0) {
  233. return false
  234. }
  235. console.log(num);
  236. this.$refs.modelRef.setNum(num)
  237. },
  238. notForme() {
  239. console.log(num,'77777777777777');
  240. let weight = Number(this.notFormedList[0].notFormedNum||0) * Number(this.item.singleWeight) * Number(this
  241. .item.weightMultiple)
  242. if (this.item.singleWeightUnit == 'G' || this.item.singleWeightUnit == 'g' || this.item.singleWeightUnit ==
  243. '克') {
  244. weight = parseFloat((weight / 1000).toFixed(2))
  245. } else {
  246. weight = parseFloat(weight.toFixed(2))
  247. }
  248. this.$set(this.notFormedList[0], 'notFormedWeight', weight)
  249. if (this.item.product[0] && this.item.product[0].feedQuantity > 0 && Number(this.notFormedList[0]
  250. .notFormedNum)) {
  251. this.$set(this.item.workReportInfo, 'formedNum', this.item.product[0].feedQuantity - Number(this
  252. .notFormedList[0]
  253. .notFormedNum))
  254. let weight = Number(this.item.workReportInfo?.formedNum||0) * Number(this.item.singleWeight) * Number(this
  255. .item.weightMultiple)
  256. if (this.item.singleWeightUnit == 'G' || this.item.singleWeightUnit == 'g' || this.item
  257. .singleWeightUnit == '克') {
  258. weight = parseFloat((weight / 1000).toFixed(2))
  259. } else {
  260. weight = parseFloat(weight.toFixed(2))
  261. }
  262. this.$set(this.item.workReportInfo, 'formedWeight', weight)
  263. }
  264. this.$forceUpdate()
  265. },
  266. changeNum(value) {
  267. // 不合格数量
  268. let val = value.notFormedNum;
  269. //匹配非数字
  270. let reg = new RegExp("([^0-9]*)","g");
  271. let ma = val.match(reg);
  272. //如果有非数字,替换成""
  273. if(ma.length>0){
  274. for(let k in ma){
  275. if(ma[k]!=""){
  276. val = val.replace(ma[k],"0");
  277. }
  278. }
  279. }
  280. //可以为0,但不能以0开头
  281. if(val.startsWith("0")&&val.length>1){
  282. val = val.substring(1,val.length);
  283. }
  284. // this.$set(this.item.workReportInfo, 'formedNum', val)
  285. value.notFormedNum = val;
  286. let total = Number(this.item.workReportInfo.formedNum) + Number(this.notFormedList[0].notFormedNum)
  287. console.log(total);
  288. this.$emit('modeNum', total)
  289. this.notForme()
  290. // this.blurNum()
  291. },
  292. }
  293. }
  294. </script>
  295. <style lang="scss" scoped>
  296. .title_box {
  297. margin-top: 20rpx;
  298. .name {
  299. font-size: 28rpx;
  300. font-style: normal;
  301. font-weight: 400;
  302. color: $theme-color;
  303. padding-left: 20rpx;
  304. position: relative;
  305. &:before {
  306. position: absolute;
  307. content: '';
  308. left: 0rpx;
  309. top: 0rpx;
  310. bottom: 0rpx;
  311. width: 4rpx;
  312. height: 28rpx;
  313. background: $theme-color;
  314. margin: auto;
  315. }
  316. }
  317. }
  318. .material {
  319. margin-top: 10rpx;
  320. .content_table {
  321. width: 100%;
  322. border: 2rpx solid $border-color;
  323. .item {
  324. display: flex;
  325. border-bottom: 2rpx solid $border-color;
  326. .lable {
  327. width: 132rpx;
  328. text-align: center;
  329. background-color: #F7F9FA;
  330. font-size: 26rpx;
  331. border-right: 2rpx solid $border-color;
  332. flex-shrink: 0;
  333. }
  334. .lable220 {
  335. width: 220rpx !important;
  336. font-size: 24rpx;
  337. }
  338. .lable150 {
  339. width: 156rpx !important;
  340. font-size: 24rpx;
  341. }
  342. .ww80 {
  343. width: 80rpx;
  344. }
  345. .content {
  346. width: 518rpx;
  347. min-height: 64rpx;
  348. font-size: 28rpx;
  349. line-height: 28rpx;
  350. font-style: normal;
  351. font-weight: 400;
  352. padding: 18rpx 8rpx;
  353. box-sizing: border-box;
  354. word-wrap: break-word;
  355. flex-grow: 1 !important;
  356. .unit {
  357. padding: 0 4rpx;
  358. font-size: 24rpx;
  359. color: #404446;
  360. }
  361. .penalize {
  362. width: 160rpx;
  363. line-height: 60rpx;
  364. background: $theme-color;
  365. font-size: 24rpx;
  366. text-align: center;
  367. color: #fff;
  368. }
  369. }
  370. .content_num {
  371. display: flex;
  372. align-items: center;
  373. padding: 0 4rpx;
  374. /deep/ .uni-input-input {
  375. border: 2rpx solid #F0F8F2;
  376. background: #F0F8F2;
  377. color: $theme-color;
  378. }
  379. }
  380. .pd4 {
  381. padding: 4rpx 8rpx;
  382. }
  383. &:last-child {
  384. border-bottom: none;
  385. }
  386. }
  387. .ww55 {
  388. width: 55%;
  389. }
  390. .ww45 {
  391. width: 45%;
  392. }
  393. }
  394. }
  395. </style>