| | |
| | | <view class="code"> |
| | | <view class="item"> |
| | | <view class="code-decs">托盘码:</view> |
| | | <input type="text" placeholder=" 扫码 / 输入"> |
| | | <input type="text" placeholder=" 扫码 / 输入" v-model="barcode" :focus="barcodeFocus" @confirm="barcodeInput()"> |
| | | </view> |
| | | <view class="item"> |
| | | <view class="code-decs">物料码:</view> |
| | | <input type="text" placeholder=" 扫码 / 输入"> |
| | | <input type="text" placeholder=" 扫码 / 输入" v-model="matnr" :focus="matFocus" @input="findMat()"> |
| | | <view class="item-right"> |
| | | <button></button> |
| | | <text style="text-align: right;color: #409EFF;">提取+</text> |
| | | <text style="text-align: right;color: #409EFF;" @click="selectMat()">提取+</text> |
| | | <uni-icons type="right" color="#c1c1c1"></uni-icons> |
| | | </view> |
| | | </view> |
| | |
| | | export default { |
| | | data() { |
| | | return { |
| | | dataList: |
| | | [ |
| | | { |
| | | matnr: "whycq19950222222-232321111", |
| | | maktx: "wusuowei", |
| | | specs: "个", |
| | | batch: "批号", |
| | | anfme: "100" |
| | | }, { |
| | | matnr: "whycq19950520", |
| | | maktx: "wusuowei", |
| | | specs: "个", |
| | | batch: "批号", |
| | | anfme: "12" |
| | | },{ |
| | | matnr: "whycq19950520", |
| | | maktx: "wusuowei", |
| | | specs: "个", |
| | | batch: "批号", |
| | | anfme: "12" |
| | | },{ |
| | | matnr: "whycq19950520", |
| | | maktx: "wusuowei", |
| | | specs: "个", |
| | | batch: "批号", |
| | | anfme: "12" |
| | | },{ |
| | | matnr: "whycq19950520", |
| | | maktx: "wusuowei", |
| | | specs: "个", |
| | | batch: "批号", |
| | | anfme: "12" |
| | | },{ |
| | | matnr: "whycq19950520", |
| | | maktx: "wusuowei", |
| | | specs: "个", |
| | | batch: "批号", |
| | | anfme: "12" |
| | | },{ |
| | | matnr: "whycq19950520", |
| | | maktx: "wusuowei", |
| | | specs: "个", |
| | | batch: "批号", |
| | | anfme: "12" |
| | | } |
| | | ], |
| | | baseUrl: '', |
| | | token: '', |
| | | barcode: '', |
| | | dataList: [], |
| | | count: 0, |
| | | rowNum: '', |
| | | matnr: '', |
| | |
| | | messageText: '', |
| | | title: '', |
| | | content: '', |
| | | barcodeFocus: true, |
| | | matFocus: false, |
| | | matData: '' |
| | | |
| | | } |
| | | }, |
| | | onLoad() { |
| | | |
| | | }, |
| | | onShow() { |
| | | this.baseUrl = uni.getStorageSync('baseUrl'); |
| | | this.token = uni.getStorageSync('token'); |
| | | }, |
| | | methods: { |
| | | messageToggle(type) { |
| | | this.msgType1 = type |
| | | this.$refs.message.open() |
| | | }, |
| | | // barcode input 事件 |
| | | barcodeInput() { |
| | | // 不设置定时器 会出现扫入的字符串不全 |
| | | setTimeout(()=>{ |
| | | var len = this.barcode.length |
| | | if (len != 8) { |
| | | uni.showToast({title: '托盘码有误请重试', icon: "none", position: 'top'}); |
| | | this.barcodeFocuss() |
| | | return; |
| | | } |
| | | this.focuss() |
| | | },200) |
| | | }, |
| | | // 托盘码有误重置 |
| | | barcodeFocuss() { |
| | | let that = this; |
| | | that.barcodeFocus = false; |
| | | setTimeout(()=>{ |
| | | that.barcode = ''; |
| | | that.barcodeFocus = true; |
| | | }, 100); |
| | | }, |
| | | // 商品光标清空重置 |
| | | focuss() { |
| | | // #ifdef APP |
| | | let that = this; |
| | | that.focus = false; |
| | | setTimeout(()=>{ |
| | | that.matnr = ''; |
| | | that.focus = true; |
| | | }, 100); |
| | | // #endif |
| | | }, |
| | | // 搜索物料 |
| | | findMat() { |
| | | let that = this |
| | | uni.request({ |
| | | url: that.baseUrl + '/mat/auth', |
| | | data: { |
| | | matnr:that.matnr |
| | | }, |
| | | header: { |
| | | 'token':uni.getStorageSync('token') |
| | | }, |
| | | success(result) { |
| | | result = result.data |
| | | if (result.code === 200 && result.data) { |
| | | that.matData = result.data |
| | | that.matnr = '' |
| | | that.matData['batch'] = '' |
| | | uni.navigateTo({ |
| | | url: "../mat/matSelected", |
| | | // 通过eventChannel向被打开页面传送数据 |
| | | success: function(res) { |
| | | res.eventChannel.emit('mat', { data: result.data }) |
| | | }, |
| | | // 为指定事件添加一个监听器,获取被打开页面传送到当前页面的数据 |
| | | events: { |
| | | dataList: function(data) { |
| | | that.checkMat(data.data) |
| | | // that.matList.push(data.data) |
| | | }, |
| | | }, |
| | | }); |
| | | } else if (res.code == 403) { |
| | | uni.showToast({title: res.msg, icon: "none", position: 'top'}) |
| | | setTimeout(() => { |
| | | uni.reLaunch({ |
| | | url: '../login/login' |
| | | }); |
| | | }, 1000); |
| | | } else { |
| | | console.log(res); |
| | | uni.showToast({title: res.msg, icon: "none",position: 'top'}) |
| | | } |
| | | |
| | | } |
| | | }); |
| | | |
| | | }, |
| | | selectMat() { |
| | | let that = this |
| | | uni.vibrateShort(); |
| | | uni.navigateTo({ |
| | | url: "../mat/matQuery", |
| | | success: function(res) { |
| | | // 通过eventChannel向被打开页面传送数据 向另外一个页面传递值的 |
| | | res.eventChannel.emit('commonUrl', {commonUrl:that.commonUrl }) |
| | | }, |
| | | events: { |
| | | // 为指定事件添加一个监听器,获取被打开页面传送到当前页面的数据 另外一个页面传过来的 |
| | | acceptDataFromOpenedPage: function(data) { |
| | | that.matnr = data.data |
| | | that.findMat(that.matnr) |
| | | }, |
| | | }, |
| | | |
| | | |
| | | }); |
| | | that.matnr = '' |
| | | }, |
| | | checkMat(mat) { |
| | | var len = this.dataList.length |
| | | var add = true |
| | | for (var i = 0; i < len; i++) { |
| | | if (mat.matnr == this.dataList[i].matnr) { |
| | | this.dataList[i].anfme += mat.anfme |
| | | this.$forceUpdate() // 强制刷新 |
| | | add = false |
| | | } |
| | | } |
| | | if (add) { |
| | | this.dataList.unshift(mat) |
| | | } |
| | | }, |
| | | // 修改批号 |
| | | revise(item,i) { |
| | | this.matnr = this.dataList[i].matnr |