罗世杰:fixed:修复各个使用下拉框处异常请求问题

This commit is contained in:
LuoShijie
2023-11-24 21:44:39 +08:00
parent 67dd393a7f
commit 742f2a7023
9 changed files with 153 additions and 109 deletions

View File

@@ -15,8 +15,8 @@
</view>
</view>
<view class="item-border">
<DropDownItem v-if="activeIndex !== -1" :list="tablist" @cancelDrop="cancelDrop" @getQueryInfo="getQueryInfo"
:type="title[activeIndex]" :activeChoose = "setActiveTag"/>
<DropDownItem v-show="activeIndex !== -1" :list="tablist" @cancelDrop="cancelDrop" @getQueryInfo="getQueryInfo"
:type="title[activeIndex]" :activeChoose = "setActiveTag" :key="tablist" ref="dropdownitem" @cancelPageNum="cancelPageNum"/>
</view>
</view>
</template>
@@ -35,6 +35,8 @@
return {
title: ['行业', '区域', '面积', '筛选'],
activeIndex: -1,
// 是否显示下拉框
isShow: false,
postlist: [
[],
[],
@@ -47,19 +49,30 @@
areatype: '',
business: ''
},
// 当前行业下拉列表
currentClassList: 0,
// 当前区域下拉列表
currentRegionList: 0,
// 当前面积下拉列表
currentAreaList: 0,
// 当前筛选下拉列表
currentFilterList: 0,
// 当前选中的行业下拉列表
currentClassActive: 0,
// 当前选中的区域下拉列表
currentRegionActive: 0,
// 当前选中的面积下拉列表
currentAreaActive: 0,
// 当前选中的筛选下拉列表
currentFilterActive: 0,
};
},
computed: {
tablist: function() {
return this.postlist[this.activeIndex]
},
setActiveTag: function(){
if(this.activeIndex == 0){
return this.currentClassActive
}else if(this.activeIndex == 1){
return this.currentRegionActive
}else if(this.activeIndex == 2){
return this.currentAreaActive
}else if(this.activeIndex == 3){
return this.currentFilterActive
}
}
},
created() {
@@ -70,6 +83,11 @@
// this.postlist[2].unshift('所有面积')
// this.postlist[3].unshift('全部')
},
watch: {
setActiveTag (reset){
}
},
methods: {
changeActiveIndex(index) {
if (this.activeIndex === index) {
@@ -80,49 +98,54 @@
cancelDrop() {
this.activeIndex = -1;
},
cancelPageNum(){
this.$emit('cancelPageNum')
},
getQueryInfo(querys) {
console.log(querys, 'getquerysinfo');
// 修改当前选择的各选项卡下标
if (this.activeIndex === 0) {
this.currentClassList = querys.business
}else if (this.activeIndex === 1) {
this.currentRegionList = querys.region
}else if (this.activeIndex === 2) {
this.currentAreaList = querys.areatype
}else if (this.activeIndex === 3) {
this.currentFilterList = querys.sortType
}
// 记忆各下拉框数据
if(querys.business==0){
querys.business = ''
}else{
querys.business = this.postlist[0][this.currentClassList]
}
if(querys.region==0){
querys.region = ''
}else querys.region = this.postlist[1][this.currentRegionList]
if (this.activeIndex === 0) {
this.currentClassActive = querys.business
}else if (this.activeIndex === 1) {
this.currentRegionActive = querys.region
}else if (this.activeIndex === 2) {
this.currentAreaActive = querys.areatype
}else if (this.activeIndex === 3) {
this.currentFilterActive = querys.sortType
}
// 特殊处理行业、区域
if(querys.business){
querys.business = this.tablist[this.currentClassActive]
}
if(querys.region){
querys.region = this.tablist[this.currentRegionActive]
}
this.queryInfo = {
...this.queryInfo,
...querys
}
const query = this.$u.queryParams(this.queryInfo)
console.log(query, 'dropquery');
console.log(querys, 'dropquery');
this.$emit('getQueryInfo', this.queryInfo)
},
setActiveTag(){
if(this.activeIndex == 0){
return this.currentClassList
}else if(this.activeIndex == 1){
return this.currentRegionList
}else if(this.activeIndex == 2){
return this.currentAreaList
}else{
return this.currentFilterList
resetInfo(){
console.log("重置了Dropdown");
this.queryInfo = {
region: '',
sortType: '',
areatype: '',
business: ''
}
this.currentClassActive = 0
this.currentRegionActive = 0
this.currentAreaActive = 0
this.currentFilterActive = 0
// 重置各下拉框保存的数据
this.$refs.dropdownitem.resetQueryInfo()
}
}
}