入库木箱扫码优化
This commit is contained in:
@@ -19,7 +19,6 @@
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
cur: '',
|
||||
focusState: false
|
||||
};
|
||||
},
|
||||
@@ -29,10 +28,6 @@
|
||||
},
|
||||
props: {
|
||||
value: String,
|
||||
seaShow: {
|
||||
type: Boolean,
|
||||
default: false
|
||||
},
|
||||
focused: {
|
||||
type: Boolean,
|
||||
default: false
|
||||
@@ -54,15 +49,19 @@
|
||||
},
|
||||
handleBlur (e) {
|
||||
this.$emit('input', e.target.value)
|
||||
this.$emit('handleChange', e.target.value)
|
||||
this.focusState = false
|
||||
if (e.target.value.length) {
|
||||
this.$emit('handleChange', e.target.value)
|
||||
}
|
||||
this.focusState = false
|
||||
},
|
||||
toDel () {
|
||||
this.$emit('input', '')
|
||||
},
|
||||
handleSend (e) {
|
||||
this.$emit('input', e.target.value)
|
||||
this.$emit('handleChange', e.target.value)
|
||||
if (e.target.value.length) {
|
||||
this.$emit('handleChange', e.target.value)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,110 +0,0 @@
|
||||
<template>
|
||||
<view class="search_wraper">
|
||||
<input
|
||||
type="text"
|
||||
class="filter_input search_input"
|
||||
:value="value"
|
||||
:focus="focused"
|
||||
@input="handleChange($event)">
|
||||
<view class="buttons_wraper">
|
||||
<span class="iconfont icon-del" @tap="toDel"></span>
|
||||
<span class="iconfont icon_scan" @tap="toScan"></span>
|
||||
<span v-show="seaShow" class="iconfont icon_search" @tap="toSearch"></span>
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import permision from "@/utils/permission.js"
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
cur: ''
|
||||
};
|
||||
},
|
||||
model: {
|
||||
prop: 'value',
|
||||
event: 'input'
|
||||
},
|
||||
props: {
|
||||
value: String,
|
||||
seaShow: {
|
||||
type: Boolean,
|
||||
default: false
|
||||
},
|
||||
focused: {
|
||||
type: Boolean,
|
||||
default: false
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
handleChange ($event) {
|
||||
this.cur = $event.target.value
|
||||
this.$emit('input', this.cur)
|
||||
this.$emit('handleChange', this.cur)
|
||||
},
|
||||
toSearch () {
|
||||
this.$emit('toSearch', this.cur)
|
||||
},
|
||||
toDel () {
|
||||
this.$emit('input', '')
|
||||
},
|
||||
async toScan() {
|
||||
// #ifdef APP-PLUS
|
||||
let status = await this.checkPermission();
|
||||
if (status !== 1) {
|
||||
return;
|
||||
}
|
||||
// #endif
|
||||
uni.scanCode({
|
||||
success: (res) => {
|
||||
this.$emit('input', res.result)
|
||||
this.$emit('handleChange', res.result)
|
||||
},
|
||||
fail: (err) => {
|
||||
// uni.showToast({
|
||||
// title: '出错',
|
||||
// icon: 'none'
|
||||
// })
|
||||
}
|
||||
});
|
||||
}
|
||||
// #ifdef APP-PLUS
|
||||
,
|
||||
async checkPermission(code) {
|
||||
let status = permision.isIOS ? await permision.requestIOS('camera') :
|
||||
await permision.requestAndroid('android.permission.CAMERA');
|
||||
|
||||
if (status === null || status === 1) {
|
||||
status = 1;
|
||||
} else {
|
||||
uni.showModal({
|
||||
content: "需要相机权限",
|
||||
confirmText: "设置",
|
||||
success: function(res) {
|
||||
if (res.confirm) {
|
||||
permision.gotoAppSetting();
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
return status;
|
||||
}
|
||||
// #endif
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="stylus" scoped>
|
||||
@import '../common/style/mixin.styl';
|
||||
.search_wraper
|
||||
position relative
|
||||
_wh(100%, 80rpx)
|
||||
.search_input
|
||||
padding-right: 160rpx;
|
||||
.buttons_wraper
|
||||
position absolute
|
||||
top 0
|
||||
right 0
|
||||
_wh(auto, 80rpx)
|
||||
</style>
|
||||
@@ -1,68 +1,58 @@
|
||||
<template>
|
||||
<view class="zd-row scan_wraper">
|
||||
<slot></slot>
|
||||
<uni-icons class="mgr20" type="clear" size="24" color="#666" @tap="toDel"></uni-icons>
|
||||
<uni-icons type="scan" size="22" :color="focused ? '#D7592F' : '#666'" @tap="toScan"></uni-icons>
|
||||
<input
|
||||
type="text"
|
||||
class="zd-col-24 search_input"
|
||||
confirm-type="go"
|
||||
:value="value"
|
||||
:focus="focusState"
|
||||
@focus="handleFocus"
|
||||
@blur="handleBlur"
|
||||
@confirm="handleSend"
|
||||
@tap="handleFocus">
|
||||
<uni-icons v-show="value.length" class="mgr20" type="clear" size="24" color="#666" @tap="toDel"></uni-icons>
|
||||
<uni-icons type="scan" size="22" :color="focusState ? '#D7592F' : '#666'" @tap="focusState=true"></uni-icons>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import permision from "@/utils/permission.js"
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
focusState: false
|
||||
};
|
||||
},
|
||||
model: {
|
||||
prop: 'value',
|
||||
event: 'input'
|
||||
},
|
||||
props: {
|
||||
focused: {
|
||||
type: Boolean,
|
||||
default: false
|
||||
}
|
||||
value: String
|
||||
},
|
||||
methods: {
|
||||
handleFocus () {
|
||||
this.focusState = true
|
||||
setTimeout(() => {
|
||||
uni.hideKeyboard()
|
||||
}, 300)
|
||||
},
|
||||
handleBlur (e) {
|
||||
this.$emit('input', e.target.value)
|
||||
if (e.target.value.length) {
|
||||
this.$emit('handleChange', e.target.value)
|
||||
}
|
||||
this.focusState = false
|
||||
},
|
||||
toDel () {
|
||||
this.$emit('inputDel')
|
||||
this.$emit('input', '')
|
||||
},
|
||||
toScan () {
|
||||
this.$emit('inputScan', '')
|
||||
},
|
||||
async toPhone() {
|
||||
// #ifdef APP-PLUS
|
||||
let status = await this.checkPermission();
|
||||
if (status !== 1) {
|
||||
return;
|
||||
handleSend (e) {
|
||||
this.$emit('input', e.target.value)
|
||||
if (e.target.value.length) {
|
||||
this.$emit('handleChange', e.target.value)
|
||||
}
|
||||
// #endif
|
||||
uni.scanCode({
|
||||
success: (res) => {
|
||||
this.$emit('toPhone', res.result)
|
||||
},
|
||||
fail: (err) => {
|
||||
// uni.showToast({
|
||||
// title: '出错',
|
||||
// icon: 'none'
|
||||
// })
|
||||
}
|
||||
});
|
||||
}
|
||||
// #ifdef APP-PLUS
|
||||
,
|
||||
async checkPermission(code) {
|
||||
let status = permision.isIOS ? await permision.requestIOS('camera') :
|
||||
await permision.requestAndroid('android.permission.CAMERA');
|
||||
|
||||
if (status === null || status === 1) {
|
||||
status = 1;
|
||||
} else {
|
||||
uni.showModal({
|
||||
content: "需要相机权限",
|
||||
confirmText: "设置",
|
||||
success: function(res) {
|
||||
if (res.confirm) {
|
||||
permision.gotoAppSetting();
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
return status;
|
||||
}
|
||||
// #endif
|
||||
}
|
||||
}
|
||||
</script>
|
||||
@@ -77,13 +67,8 @@
|
||||
border-radius: 10rpx;
|
||||
padding: 0 10rpx
|
||||
.search_input
|
||||
padding-right: 160rpx;
|
||||
.buttons_wraper
|
||||
position absolute
|
||||
top 0
|
||||
right 10rpx
|
||||
_wh(auto, 80rpx)
|
||||
_fj(flex-end)
|
||||
.icon_scan_active
|
||||
color $red
|
||||
height 80rpx;
|
||||
_font(28rpx, 80rpx, #606266,,)
|
||||
border: 0;
|
||||
background-color: transparent;
|
||||
</style>
|
||||
|
||||
Reference in New Issue
Block a user