给单据中商品的搜索框增加500毫秒的延迟搜索功能

This commit is contained in:
季圣华
2023-03-23 19:36:12 +08:00
parent 7029b8d8a1
commit fcb2979f5e

View File

@@ -57,6 +57,7 @@
ids: "", ids: "",
names: "", names: "",
materialData: [], materialData: [],
setTimeFlag: null
} }
}, },
mounted() { mounted() {
@@ -74,7 +75,7 @@
methods: { methods: {
initComp(name) { initComp(name) {
if(this.kind === 'material') { if(this.kind === 'material') {
this.names = name?name:'输入条码或名称' this.names = name?name:'输入条码或名称'
} else { } else {
this.names = name this.names = name
} }
@@ -83,11 +84,17 @@
this.$refs.selectModal.showModal() this.$refs.selectModal.showModal()
}, },
handleSearch(value) { handleSearch(value) {
getMaterialByParam({q: value}).then((res) => { let that = this
if (res && res.code === 200) { if(this.setTimeFlag != null){
this.materialData = res.data clearTimeout(this.setTimeFlag);
} }
}) this.setTimeFlag = setTimeout(()=>{
getMaterialByParam({q: value}).then((res) => {
if (res && res.code === 200) {
that.materialData = res.data
}
})
},500)
}, },
handleChange(value) { handleChange(value) {
this.$emit("change", value) this.$emit("change", value)