feat: 增加下拉框筛选

This commit is contained in:
沈昭朝 2024-06-24 13:36:00 +08:00
parent fe60927baf
commit 7ef046949b
2 changed files with 20 additions and 2 deletions

View File

@ -18,6 +18,7 @@
v-model="selected[index]"
:placeholder="category.categoryName"
multiple
filterable
:collapse-tags="collapse"
clearable
>
@ -993,6 +994,11 @@ export default {
//
const result = await this.$API.select.reqGetRegionAndCity()
this.regionAndCityList = result.data
//
const cities = this.regionAndCityList.map(item => {
return item.cities.split(',')
})
this.cityList = cities.flat()
this.regionList = result.data.map(item => { return { value: item.region, label: item.region } })
},
//
@ -1132,8 +1138,16 @@ export default {
return index + 1 + (page - 1) * limit
},
handleRegion(region) {
const data = this.regionAndCityList.filter(item => item.region === region)
this.cityList = data[0].cities.split(',')
//
if (region) {
const data = this.regionAndCityList.filter(item => item.region === region)
this.cityList = data[0].cities.split(',')
} else {
const data = this.regionAndCityList.map(item => {
return item.cities.split(',')
})
this.cityList = data.flat()
}
this.city = ''
console.log(this.cityList)
},
@ -1279,6 +1293,9 @@ export default {
//
resetDepartmentSearch() {
this.region = ''
this.city = ''
this.selected = []
this.departmentId = ''
this.getTableDataByDept()
},

View File

@ -9,6 +9,7 @@
v-model="selected[index]"
:placeholder="category.categoryName"
multiple
filterable
:collapse-tags="collapse"
clearable
>