jobBom.vue 12 KB

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