下拉框搜索

This commit is contained in:
2023-04-27 18:47:58 +08:00
parent 9783c1debe
commit 386ea12405
2 changed files with 47 additions and 14 deletions

View File

@@ -18,7 +18,7 @@
<view class="filter_item">
<view class="filter_label">物料</view>
<view class="filter_input_wraper">
<uni-data-select v-model="index3" :localdata="options3" @change="selectChange3"></uni-data-select>
<uni-data-select v-model="index3" :searchInput="true" :localdata="newoptions3" @change="selectChange3" @handleChange="handleChange" @showSelector="showSelector"></uni-data-select>
</view>
</view>
<view class="filter_item">
@@ -30,7 +30,7 @@
</view>
</view>
<view class="submit-bar">
<button class="submit-button" :class="{'btn-disabled': !qty || !index1 || !index3}" :disabled="disabled" @tap="_emptyConfirm">入库设置</button>
<button class="submit-button" :class="{'btn-disabled': !index1 || !index3}" :disabled="disabled" @tap="_emptyConfirm">入库设置</button>
<button class="submit-button" :class="{'btn-disabled': !index2}" @tap="_taskQuerydevice">查询</button>
</view>
</view>
@@ -54,7 +54,9 @@
options3: [],
index3: '',
qty: '',
disabled: false
disabled: false,
val1: '',
newoptions3: []
};
},
created () {
@@ -75,6 +77,27 @@
selectChange3(e) {
this.index3 = e
},
/** 模糊匹配 */
selectMatchItem (lists, keyWord) {
let resArr = []
lists.filter((item) => {
if (item.text.indexOf(keyWord) > -1) {
resArr.push(item)
}
})
return resArr
},
handleChange (e) {
if (e){
this.index3 = ''
this.newoptions3 = this.selectMatchItem(this.options3, e)
} else {
this.newoptions3 = this.options3
}
},
showSelector () {
this.newoptions3 = this.options3
},
/** 生产区域下拉框查询 */
async _queryProductArea () {
let res = await queryProductArea()
@@ -89,6 +112,7 @@
async _queryPaperMaterial (code) {
let res = await queryPaperMaterial(code)
this.options3 = [...res.rows]
this.newoptions3 = [...res.rows]
res.rows.map(el => {
if (el.value === code) {
this.index3 = res.material_code
@@ -127,14 +151,6 @@
this.disabled = false
return
}
if (!this.qty) {
uni.showToast({
title: '数量不能为空',
icon: 'none'
})
this.disabled = false
return
}
try {
let res = await emptyConfirm(this.qty, this.index3, this.index2, '1')
this.disabled = false