feat(banner管理页面): 搜索栏“国家”选项调整
This commit is contained in:
parent
e0def280bd
commit
7cdf310aa9
@ -310,7 +310,7 @@ export default {
|
|||||||
textOptTitle: "",
|
textOptTitle: "",
|
||||||
listLoading: true,
|
listLoading: true,
|
||||||
|
|
||||||
selectedCountry: {},
|
selectedCountry: {}, // 存储完整的国家对象
|
||||||
countryList: [],
|
countryList: [],
|
||||||
loadingCountry: false
|
loadingCountry: false
|
||||||
};
|
};
|
||||||
@ -381,10 +381,21 @@ export default {
|
|||||||
const that = this;
|
const that = this;
|
||||||
console.log("val", val);
|
console.log("val", val);
|
||||||
|
|
||||||
that.selectedCountry = this.countryList.filter(
|
if (!val) {
|
||||||
item => item.country.alphaTwo === val
|
// 如果没有选择国家,清空相关字段
|
||||||
)[0];
|
that.listQuery.countryCode = "";
|
||||||
that.listQuery.countryCode = this.selectedCountry.country.alphaTwo;
|
that.selectedCountry = {};
|
||||||
|
} else {
|
||||||
|
// 选择了一个国家
|
||||||
|
that.selectedCountry =
|
||||||
|
this.countryList.find(item => item.country.alphaTwo === val) || {};
|
||||||
|
|
||||||
|
// 使用传统的方式访问嵌套属性
|
||||||
|
that.listQuery.countryCode = that.selectedCountry.country
|
||||||
|
? that.selectedCountry.country.alphaTwo
|
||||||
|
: "";
|
||||||
|
}
|
||||||
|
|
||||||
this.renderData();
|
this.renderData();
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -397,7 +408,8 @@ export default {
|
|||||||
.then(res => {
|
.then(res => {
|
||||||
that.loadingCountry = false;
|
that.loadingCountry = false;
|
||||||
that.countryList = res.body || [];
|
that.countryList = res.body || [];
|
||||||
that.listQuery.countryCode = that.selectedCountry.country.alphaTwo;
|
that.listQuery.countryCode = "";
|
||||||
|
that.selectedCountry = {};
|
||||||
// that.renderData();
|
// that.renderData();
|
||||||
})
|
})
|
||||||
.catch(er => {
|
.catch(er => {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user