木箱不允许输入

This commit is contained in:
2023-08-16 18:37:56 +08:00
parent 9b9d5eb172
commit 8b5d490595
5 changed files with 246 additions and 40 deletions

View File

@@ -0,0 +1,88 @@
<template>
<view class="search_wraper">
<slot></slot>
<view class="buttons_wraper">
<view class="iconfont icon_del" @tap="toDel">&#xe6dc;</view>
<view class="iconfont icon_scan" :class="{'icon_scan_active': focused === true}" @tap="toScan">&#xe6e2;</view>
<view class="iconfont icon_phone" @tap="toPhone">&#xe663;</view>
</view>
</view>
</template>
<script>
import permision from "@/utils/permission.js"
export default {
props: {
focused: {
type: Boolean,
default: false
}
},
methods: {
toDel () {
this.$emit('inputDel')
},
toScan () {
this.$emit('inputScan', '')
},
async toPhone() {
// #ifdef APP-PLUS
let status = await this.checkPermission();
if (status !== 1) {
return;
}
// #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>
<style lang="stylus">
@import '../common/style/mixin.styl';
.search_wraper
position relative
_wh(100%, 70rpx)
.search_input
padding-right: 160rpx;
.buttons_wraper
position absolute
top 0
right 10rpx
_wh(auto, 70rpx)
_fj(flex-end)
.icon_scan_active
color $red
</style>

View File

@@ -8,11 +8,9 @@
<span class="filter_label">木箱</span> <span class="filter_label">木箱</span>
</view> </view>
<view class="filter_input_wraper"> <view class="filter_input_wraper">
<search-box <search-box-mx :focused="focused" @inputDel="inputDel" @inputScan="inputScan" @toPhone="toPhone">
v-model="val1" <input type="text" v-model="val1" class="filter_input search_input" :focus="focused" @input="onKeyInput($event)" @blur="onBlur" @focus="focused = true">
:focused="true" </search-box-mx>
@handleChange="handleChange"
/>
</view> </view>
</view> </view>
<view class="filter_item"> <view class="filter_item">
@@ -71,11 +69,14 @@
<script> <script>
import NavBar from '@/components/NavBar.vue' import NavBar from '@/components/NavBar.vue'
import SearchBox from '@/components/SearchBox.vue' import SearchBox from '@/components/SearchBox.vue'
import SearchBoxMx from '@/components/SearchBoxMx.vue'
import permision from "@/utils/permission.js"
import {boxQuery, stConfirm, stPrint} from '@/utils/getData2.js' import {boxQuery, stConfirm, stPrint} from '@/utils/getData2.js'
export default { export default {
components: { components: {
NavBar, NavBar,
SearchBox SearchBox,
SearchBoxMx
}, },
data() { data() {
return { return {
@@ -84,17 +85,20 @@
isV: '0', isV: '0',
dataList: [], dataList: [],
disabled: false, disabled: false,
disabled1: false disabled1: false,
focused: true
}; };
}, },
mounted () {
setTimeout(() => {
uni.hideKeyboard()
}, 500)
},
methods: { methods: {
/** 虚拟库 */ /** 虚拟库 */
isVirtual () { isVirtual () {
this.isV = this.isV === '0' ? '1' : '0' this.isV = this.isV === '0' ? '1' : '0'
}, },
handleChange (e) {
this._boxQuery(e)
},
/** 初始化查询 */ /** 初始化查询 */
async _boxQuery (e) { async _boxQuery (e) {
let res = await boxQuery(e, '2') let res = await boxQuery(e, '2')
@@ -141,6 +145,32 @@
} catch (e) { } catch (e) {
this.disabled1 = false this.disabled1 = false
} }
},
onKeyInput ($event) {
if ($event.target.value.length < 5) {
this.$nextTick(function(){
this.val1 = ''
uni.hideKeyboard()
})
return
}
this._boxQuery(this.val1)
},
onBlur () {
this.focused = false
},
inputDel () {
this.val1 = ''
},
inputScan () {
this.focused = true
setTimeout(() => {
uni.hideKeyboard()
}, 300)
},
toPhone (e) {
this.val1 = e
this._boxQuery(this.val1)
} }
} }
} }

View File

@@ -8,11 +8,9 @@
<span class="filter_label">木箱</span> <span class="filter_label">木箱</span>
</view> </view>
<view class="filter_input_wraper"> <view class="filter_input_wraper">
<search-box <search-box-mx :focused="focused" @inputDel="inputDel" @inputScan="inputScan" @toPhone="toPhone">
v-model="val1" <input type="text" v-model="val1" class="filter_input search_input" :focus="focused" @input="onKeyInput($event)" @blur="onBlur" @focus="focused = true">
:focused="true" </search-box-mx>
@handleChange="handleChange"
/>
</view> </view>
</view> </view>
<view class="filter_item"> <view class="filter_item">
@@ -71,11 +69,13 @@
<script> <script>
import NavBar from '@/components/NavBar.vue' import NavBar from '@/components/NavBar.vue'
import SearchBox from '@/components/SearchBox.vue' import SearchBox from '@/components/SearchBox.vue'
import SearchBoxMx from '@/components/SearchBoxMx.vue'
import {boxQuery, stConfirm, stPrint} from '@/utils/getData2.js' import {boxQuery, stConfirm, stPrint} from '@/utils/getData2.js'
export default { export default {
components: { components: {
NavBar, NavBar,
SearchBox SearchBox,
SearchBoxMx
}, },
data() { data() {
return { return {
@@ -84,17 +84,20 @@
isV: '0', isV: '0',
dataList: [], dataList: [],
disabled: false, disabled: false,
disabled1: false disabled1: false,
focused: true
}; };
}, },
mounted () {
setTimeout(() => {
uni.hideKeyboard()
}, 500)
},
methods: { methods: {
/** 虚拟库 */ /** 虚拟库 */
isVirtual () { isVirtual () {
this.isV = this.isV === '0' ? '1' : '0' this.isV = this.isV === '0' ? '1' : '0'
}, },
handleChange (e) {
this._boxQuery(e)
},
/** 初始化查询 */ /** 初始化查询 */
async _boxQuery (e) { async _boxQuery (e) {
let res = await boxQuery(e, '4') let res = await boxQuery(e, '4')
@@ -141,6 +144,32 @@
} catch (e) { } catch (e) {
this.disabled1 = false this.disabled1 = false
} }
},
onKeyInput ($event) {
if ($event.target.value.length < 5) {
this.$nextTick(function(){
this.val1 = ''
uni.hideKeyboard()
})
return
}
this._boxQuery(this.val1)
},
onBlur () {
this.focused = false
},
inputDel () {
this.val1 = ''
},
inputScan () {
this.focused = true
setTimeout(() => {
uni.hideKeyboard()
}, 300)
},
toPhone (e) {
this.val1 = e
this._boxQuery(this.val1)
} }
} }
} }

View File

@@ -8,11 +8,9 @@
<span class="filter_label">木箱</span> <span class="filter_label">木箱</span>
</view> </view>
<view class="filter_input_wraper"> <view class="filter_input_wraper">
<search-box <search-box-mx :focused="focused" @inputDel="inputDel" @inputScan="inputScan" @toPhone="toPhone">
v-model="val1" <input type="text" v-model="val1" class="filter_input search_input" :focus="focused" @input="onKeyInput($event)" @blur="onBlur" @focus="focused = true">
:focused="true" </search-box-mx>
@handleChange="handleChange"
/>
</view> </view>
</view> </view>
<view class="filter_item"> <view class="filter_item">
@@ -76,11 +74,13 @@
<script> <script>
import NavBar from '@/components/NavBar.vue' import NavBar from '@/components/NavBar.vue'
import SearchBox from '@/components/SearchBox.vue' import SearchBox from '@/components/SearchBox.vue'
import SearchBoxMx from '@/components/SearchBoxMx.vue'
import {boxQuery, stConfirm} from '@/utils/getData2.js' import {boxQuery, stConfirm} from '@/utils/getData2.js'
export default { export default {
components: { components: {
NavBar, NavBar,
SearchBox SearchBox,
SearchBoxMx
}, },
data() { data() {
return { return {
@@ -89,19 +89,23 @@
val3: '', val3: '',
isV: '0', isV: '0',
dataList: [], dataList: [],
disabled: false disabled: false,
focused: true
}; };
}, },
mounted () {
setTimeout(() => {
uni.hideKeyboard()
}, 500)
},
methods: { methods: {
/** 虚拟库 */ /** 虚拟库 */
isVirtual () { isVirtual () {
this.isV = this.isV === '0' ? '1' : '0' this.isV = this.isV === '0' ? '1' : '0'
}, },
handleChange (e) {
this._boxQuery(e)
},
/** 初始化查询 */ /** 初始化查询 */
async _boxQuery (e) { async _boxQuery (e) {
console.log(11)
let res = await boxQuery(e, '3') let res = await boxQuery(e, '3')
this.dataList = [...res.data] this.dataList = [...res.data]
}, },
@@ -127,6 +131,32 @@
} catch (e) { } catch (e) {
this.disabled = false this.disabled = false
} }
},
onKeyInput ($event) {
if ($event.target.value.length < 5) {
this.$nextTick(function(){
this.val1 = ''
uni.hideKeyboard()
})
return
}
this._boxQuery(this.val1)
},
onBlur () {
this.focused = false
},
inputDel () {
this.val1 = ''
},
inputScan () {
this.focused = true
setTimeout(() => {
uni.hideKeyboard()
}, 300)
},
toPhone (e) {
this.val1 = e
this._boxQuery(this.val1)
} }
} }
} }

View File

@@ -8,11 +8,9 @@
<span class="filter_label">木箱</span> <span class="filter_label">木箱</span>
</view> </view>
<view class="filter_input_wraper"> <view class="filter_input_wraper">
<search-box <search-box-mx :focused="focused" @inputDel="inputDel" @inputScan="inputScan" @toPhone="toPhone">
v-model="val1" <input type="text" v-model="val1" class="filter_input search_input" :focus="focused" @input="onKeyInput($event)" @blur="onBlur" @focus="focused = true">
:focused="true" </search-box-mx>
@handleChange="handleChange"
/>
</view> </view>
</view> </view>
<view class="filter_item"> <view class="filter_item">
@@ -70,11 +68,13 @@
<script> <script>
import NavBar from '@/components/NavBar.vue' import NavBar from '@/components/NavBar.vue'
import SearchBox from '@/components/SearchBox.vue' import SearchBox from '@/components/SearchBox.vue'
import SearchBoxMx from '@/components/SearchBoxMx.vue'
import {boxQuery, stConfirm} from '@/utils/getData2.js' import {boxQuery, stConfirm} from '@/utils/getData2.js'
export default { export default {
components: { components: {
NavBar, NavBar,
SearchBox SearchBox,
SearchBoxMx
}, },
data() { data() {
return { return {
@@ -82,17 +82,20 @@
val2: '', val2: '',
isV: '0', isV: '0',
dataList: [], dataList: [],
disabled: false disabled: false,
focused: true
}; };
}, },
mounted () {
setTimeout(() => {
uni.hideKeyboard()
}, 500)
},
methods: { methods: {
/** 虚拟库 */ /** 虚拟库 */
isVirtual () { isVirtual () {
this.isV = this.isV === '0' ? '1' : '0' this.isV = this.isV === '0' ? '1' : '0'
}, },
handleChange (e) {
this._boxQuery(e)
},
/** 初始化查询 */ /** 初始化查询 */
async _boxQuery (e) { async _boxQuery (e) {
let res = await boxQuery(e, '1') let res = await boxQuery(e, '1')
@@ -120,6 +123,32 @@
} catch (e) { } catch (e) {
this.disabled = false this.disabled = false
} }
},
onKeyInput ($event) {
if ($event.target.value.length < 5) {
this.$nextTick(function(){
this.val1 = ''
uni.hideKeyboard()
})
return
}
this._boxQuery(this.val1)
},
onBlur () {
this.focused = false
},
inputDel () {
this.val1 = ''
},
inputScan () {
this.focused = true
setTimeout(() => {
uni.hideKeyboard()
}, 300)
},
toPhone (e) {
this.val1 = e
this._boxQuery(this.val1)
} }
} }
} }