work-material-edit.vue 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204
  1. <template>
  2. <view class="page">
  3. <view class="bg-white mb-2">
  4. <uni-section title="领料单信息" type="line" :strong="true"/>
  5. <list-input title="物品号">
  6. <view v-if="detail.xczwph">
  7. {{detail.xczwph}}
  8. </view>
  9. <view v-else>--</view>
  10. </list-input>
  11. </view>
  12. <view class="bg-white">
  13. <list-input title="原材料重量(公斤)">
  14. <input type="text" v-model='originWeight' placeholder="请称重" class='text-right form-item-input' @blur="onBlur('originWeight')"/>
  15. </list-input>
  16. <list-input title="容器皮重(公斤)">
  17. <view class="flex align-center">
  18. <input type="text" v-model='otherWeight' placeholder="请输入" class='text-right form-item-input' @blur="onBlur('otherWeight')"/>
  19. <scan-btn
  20. :barcodekey="barcodekey"
  21. keyname="otherWeight"
  22. :scaning="scaning"
  23. :show-clear="Boolean(otherWeight)"
  24. @scan="onScan"
  25. @clear="onClearValue"
  26. @close="onCloseScanPage"
  27. >
  28. <view class="scan-icon iconfont icon-ziyuan"></view>
  29. </scan-btn>
  30. </view>
  31. </list-input>
  32. <list-input title="库位(号)">
  33. <picker :range="defaultKwList" @change="onChangeKW" range-key="KWH">
  34. <view class="form-item-input">
  35. <template v-if="defaultKwList.length > 0">
  36. {{defaultKwList[defaultKwIndex].KWH}}
  37. </template>
  38. <template v-else>
  39. --
  40. </template>
  41. </view>
  42. </picker>
  43. </list-input>
  44. <view class="text-right p-2 font-md font-weight-bold">
  45. 生产耗料净重:{{realWeight}}公斤
  46. </view>
  47. </view>
  48. <btn-save @save='onSave' :disabledOk="disabledSubmit"/>
  49. </view>
  50. </template>
  51. <script>
  52. import uniSection from "@/components/uni-ui/uni-section/uni-section.vue"
  53. import listInput from "@/components/common/list-input.vue"
  54. import btnSave from "@/components/common/btn-save.vue"
  55. import {amount} from "@/common/utils/reg.js"
  56. import {BARCODE_TARE_KEY} from "@/common/utils/barCode.js"
  57. import scanBtn from "@/components/common/scan-btn.vue"
  58. import {mapGetters} from "vuex"
  59. import {queryStorageLocation,workreportSave,queryDefaultStorage} from "@/api/api.js"
  60. import {onScanMixin} from "@/common/utils/mixins.js"
  61. const BigNumber = require('bignumber.js');
  62. export default {
  63. mixins:[onScanMixin],
  64. components:{
  65. uniSection,
  66. listInput,
  67. btnSave,
  68. scanBtn
  69. },
  70. data () {
  71. return {
  72. originWeight:"", // 原始重量
  73. otherWeight:"", // 容器重量
  74. barcodekey:BARCODE_TARE_KEY ,// 条形码类型
  75. defaultKwIndex:0, // 库位索引
  76. GYLCKH:null, // 流转码
  77. detail:{} , // 报工明细
  78. defaultCkList:[], // 默认仓库列表
  79. }
  80. },
  81. computed:{
  82. ...mapGetters(['disabledSubmit']),
  83. // 真实重量
  84. realWeight () {
  85. let result="**"
  86. let x=0
  87. const num1=Number(this.originWeight)
  88. const num2=Number(this.otherWeight)
  89. if (num1 && num2) {
  90. result=BigNumber(num1).minus(num2).toNumber()
  91. }
  92. return result
  93. },
  94. // 默认库位列表
  95. defaultKwList () {
  96. let arr=[]
  97. if (this.defaultCkList.length > 0) {
  98. return this.defaultCkList[0].storageloca
  99. }
  100. return arr
  101. }
  102. },
  103. onLoad (e) {
  104. this.GYLCKH=e.GYLCKH
  105. this.detail=JSON.parse(e.detail)
  106. this.addListenerFn()
  107. this.initPage()
  108. },
  109. onUnload() {
  110. this.removeListenerFn()
  111. },
  112. methods:{
  113. // 初始化界面
  114. async initPage () {
  115. await this._queryDefaultStorage()
  116. },
  117. // 获取默认仓库
  118. async _queryDefaultStorage () {
  119. let resdata=await queryDefaultStorage()
  120. this.defaultCkList=resdata
  121. return this.defaultCkList
  122. },
  123. // 保存
  124. async _workreportSave () {
  125. const detail=this.detail
  126. const reqdata={
  127. "GYLCKH":this.GYLCKH,
  128. "DQYBGX":detail.GXH,
  129. "BGGXSM":detail.BGGXSM,
  130. "XYCZ":detail.XYCZ,
  131. "items":detail.items,
  132. "height":this.realWeight, //重量
  133. "xczwph":detail.xczwph, // 物品号(非必填,报工单查询中会给到你,现在没有,陆磊还没加)
  134. "kwh": this.defaultKwList[this.defaultKwIndex].KWH, //库位号(非必填) (填写领料单,)
  135. }
  136. await workreportSave(reqdata,{cz:true}).then(resdata=>{
  137. })
  138. return true
  139. },
  140. // 库位选择
  141. onChangeKW (e) {
  142. this.kwIndex=e.detail.value
  143. },
  144. // 输入重量
  145. onBlur (key,e) {
  146. // 如果为空不进行判断,避免弹窗频繁显示
  147. if(this[key]===null) return
  148. if (!amount.test(this[key])) {
  149. uni.showToast({
  150. title:"请输入准确的数字",
  151. icon:"none"
  152. })
  153. this[key]=null
  154. }
  155. },
  156. // 保存
  157. onSave () {
  158. let ok=true
  159. let msg=''
  160. if (!this.originWeight || !this.otherWeight) {
  161. msg='原材料重量和容器皮重为必填项'
  162. ok=false
  163. }else if (!amount.test(this.originWeight) || !amount.test(this.otherWeight)) {
  164. msg='请输入准确的数字'
  165. ok=false
  166. }else if (Number(this.realWeight) < 0){
  167. msg='生产耗料净重不能为负数'
  168. ok=false
  169. }
  170. if (!ok) {
  171. uni.showToast({
  172. title:msg,
  173. icon:"none"
  174. })
  175. return
  176. }
  177. uni.showModal({
  178. title:"确认保存吗?",
  179. success:async (res)=>{
  180. if (res.confirm) {
  181. await this._workreportSave()
  182. uni.showToast({
  183. title:'保存成功'
  184. })
  185. uni.reLaunch({
  186. url:"/pages/index/index"
  187. })
  188. }
  189. }
  190. })
  191. },
  192. }
  193. }
  194. </script>
  195. <style>
  196. </style>