From 6196d5efa014fc9d16227d5c77f20758c802715f Mon Sep 17 00:00:00 2001 From: whycq <10027870+whycq@user.noreply.gitee.com> Date: 星期五, 01 十二月 2023 14:00:30 +0800 Subject: [PATCH] 优化pakin --- pages/api/common/common.js | 1 components/z-input/z-input.vue | 9 +- pages/api/addMat.js | 11 -- pages/api/pakin/pakin.js | 0 pages.json | 8 ++ pages/project/pakin/pakin.vue | 121 ++++++++++++++++++----------- static/js/util.js | 30 +++++++ pages/common/mat/matPick.vue | 22 +++++ 8 files changed, 141 insertions(+), 61 deletions(-) diff --git a/components/z-input/z-input.vue b/components/z-input/z-input.vue index cabe92b..287ed1b 100644 --- a/components/z-input/z-input.vue +++ b/components/z-input/z-input.vue @@ -85,10 +85,11 @@ return } if (val.length != this.lenCheck) { + console.log(val); setTimeout(()=>{ this.data = '' this.$emit('input','') - },0) + },10) } else { this.$emit('input',val) } @@ -115,17 +116,15 @@ this.$emit('clickBtn'); }, inputVal() { - this.$emit('inputVal',[this.data,this.name]); + this.$emit('inputVal',{title:this.name,value:this.data}); }, scanCode() { let _this = this uni.scanCode({ onlyFromCamera: true, success(res) { - _this.$parent.scanCode(res.result) _this.data = res.result - console.log('鎵埌浜�'); - console.log(res); + _this.$emit('inputVal',{title:_this.name,value:_this.data}) } }) } diff --git a/pages.json b/pages.json index d3e4543..0a2a409 100644 --- a/pages.json +++ b/pages.json @@ -105,6 +105,14 @@ } + }, + { + "path" : "pages/common/mat/matPick", + "style" : + { + "navigationBarTitleText" : "鎻愬彇鐗╂枡", + "enablePullDownRefresh" : false + } } ], "globalStyle": { diff --git a/pages/api/addMat.js b/pages/api/addMat.js index e2fcae4..00bf2d7 100644 --- a/pages/api/addMat.js +++ b/pages/api/addMat.js @@ -10,16 +10,7 @@ header: {'token': uni.getStorageSync('token')}, data: {matnr: matnr}, }).then((result)=> { - let mat = result.data.data - item = mat - console.log(mat); - // item['detl'] = [ - // {key: '鍟嗗搧鐮�',value: mat.matnr}, - // {key: '鍟嗗搧鍚嶇О',value: mat.maktx}, - // {key: '瑙勬牸',value: mat.specs}, - // {key: '鎵瑰彿',value: '',type: 'input'}, - // {key: '鏁伴噺',value: 0,type: 'number-box',valText: 'val-num'}, - // ] + item = result.data },(res)=>{ console.log(res); }) diff --git a/pages/api/common/common.js b/pages/api/common/common.js index 5b4a46d..7133231 100644 --- a/pages/api/common/common.js +++ b/pages/api/common/common.js @@ -16,6 +16,7 @@ password: md5.hex_md5(user.password) }, }).then((result) => { + console.log(result); result = result.data if (result.code === 200 && result.data.token) { uni.setStorageSync('token', result.data.token); diff --git a/pages/api/pakin/pakin.js b/pages/api/pakin/pakin.js new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/pages/api/pakin/pakin.js diff --git a/pages/common/mat/matPick.vue b/pages/common/mat/matPick.vue new file mode 100644 index 0000000..8183fd0 --- /dev/null +++ b/pages/common/mat/matPick.vue @@ -0,0 +1,22 @@ +<template> + <view> + + </view> +</template> + +<script> + export default { + data() { + return { + + } + }, + methods: { + + } + } +</script> + +<style> + +</style> diff --git a/pages/project/pakin/pakin.vue b/pages/project/pakin/pakin.vue index 9661dbf..1d989e4 100644 --- a/pages/project/pakin/pakin.vue +++ b/pages/project/pakin/pakin.vue @@ -8,24 +8,20 @@ v-model="barcode" :index="input1.id" :lenCheck="input1.lenCheck" - :focus="input1.focus" - @inputVal='input3' + :focus="barcodeFocus" + @inputVal='barcodeInput' /> - <z-input - :desc="input2.title" - :name="input2.name" - :btn="input2.btn" - :btn-name="input2.btnName" - v-model="matnr" - :index="input2.id" - :lenCheck="input2.lenCheck" - :focus="input2.focus" - @inputVal='input3' + <z-input :desc="input2.title" + :name="input2.name" + :btn="input2.btn" + :btn-name="input2.btnName" + v-model="matnr" + :index="input2.id" + :lenCheck="input2.lenCheck" + :focus="matnrFocus" + @inputVal='matnrInput' /> </view> - <!-- 鍩烘湰灞炴�х粦瀹� --> - <!-- 鍏夋爣澶嶄綅 --> - <!-- 闀垮害鍒ゆ柇 --> <u-sticky > @@ -35,12 +31,6 @@ <view class="flex1"></view> </view> </u-sticky> - <view>barcode:{{barcode}}</view> - <!-- <zzz v-model="barcode" @change1='change' @input="inputz"></zzz> --> - <view>matnr:{{matnr}}</view> - <!-- <zzz v-model="matnr" @change1='change' @input="inputz"></zzz> --> - - <z-data-list class="data-list" v-for="(it,i) in zDataList" @@ -51,10 +41,10 @@ @goDetail='goDetail(it,i)' ></z-data-list> <!-- 鍨珮 --> - <view style="height: 100rpx;"></view> + <view style="height: 100rpx;" /> <view class="z-floor"> - <view class="z-default">閲嶇疆</view> + <view class="z-default" @click="clean">閲嶇疆</view> <view class="z-primary" @click="comb">缁勬墭</view> </view> @@ -64,13 +54,16 @@ <script> import { mapState } from 'vuex' import addMat from '@/pages/api/addMat.js' + import util from '@/static/js/util.js' export default { data() { return { - zDataList: [ ], - barcode: '80009991', + zDataList: [], + barcode: '', matnr: '', inputCode: '鎵樼洏鐮�', + barcodeFocus: true, + matnrFocus: false } }, onShow() { @@ -83,28 +76,16 @@ lable: state => state.project.menu[0].page.lable }), methods: { - inputz() { - // console.log(this.barcode); - console.log(this.matnr); + barcodeInput(arr) { + this.barcodeFocus = false + setTimeout(()=>{ + this.matnrFocus = true + },10) }, - change() { - // console.log(this.barcode); - // console.log(this.matnr); - - }, - scanCode(data) { - // console.log(data); - - }, - input3(arr) { - if(arr[1] == 'matnr') { - this.getMat(arr[0]) + matnrInput(arr) { + if(arr.title == 'matnr') { + this.getMat(arr.value) } - }, - async getMat(matnr) { - let mat = await addMat.addMat(matnr) - mat['count'] = 0 - this.zDataList.push(mat) }, goDetail(param,index) { let _this = this @@ -128,10 +109,58 @@ }, }) }, + // 鑾峰彇鐗╂枡 + async getMat(matnr) { + let res = await addMat.addMat(matnr) + if (res.code === 200 && res.data) { + res.data['count'] = 1 + this.zDataList = util.matCheck(res.data,this.zDataList) + this.matnr = '' + } else if (res.code === 200 && !res.data) { + let msg = `${this.matnr} 鐗╂枡寮傚父锛岃閲嶈瘯` + uni.showToast({ title: msg, icon: "none", position: 'top' }) + } else if (res.code == 403) { + uni.showToast({ title: res.msg, icon: "none", position: 'top' }) + setTimeout(() => { + uni.reLaunch({ + url: '../../LoginDemo/LoginDemo' + }); + }, 1000); + } else { + uni.showToast({ title: res.msg, icon: "none", position: 'top' }) + } + }, + // 璺宠浆鐗╂枡鎻愬彇椤甸潰 + matPick() { + uni.navigateTo({ + url: '/pages/common/data-list/dataDetail', + // 浼� + success: function(data) { + data.eventChannel.emit('param', { + param: param, + index: index + }) + }, + // 鎺� + events: { + dataList: function(data) { + console.log(data); + }, + del: function(data) { + _this.zDataList.splice(data.data,1) + } + }, + }) + }, + // 缁勬墭 comb() { console.log(this.barcode); - console.log(this.matnr); + console.log(this.zDataList); + }, + clean() { + } + } } </script> diff --git a/static/js/util.js b/static/js/util.js new file mode 100644 index 0000000..8298586 --- /dev/null +++ b/static/js/util.js @@ -0,0 +1,30 @@ +/* +* 娣诲姞鐗╂枡 +* mat -- 鐗╂枡璇︽儏 +* matList -- 宸叉坊鍔犵墿鏂� +* +*/ +function matCheck(mat, matList) { + let newMatList = [], + add = true; + if (matList.length > 0) { + for (let item of matList) { + if (item.matnr == mat.matnr) { + if (item.batch == mat.batch) { + add = false + item.count = item.count + mat.count + } else { + + } + } + + } + } + if (add) { + matList.unshift(mat) + } + return matList +} +module.exports = { + matCheck: matCheck, +} \ No newline at end of file -- Gitblit v1.9.1