需求发布

This commit is contained in:
”chenxuelian“
2023-01-10 09:26:31 +08:00
parent e561054b6f
commit 7b474b06ef
4 changed files with 114 additions and 31 deletions

View File

@@ -24,7 +24,10 @@
cityList: [],
cityLevel1: [],
cityLevel2: [],
cityLevel3: []
cityLevel3: [],
cityLevelCode1: [],
cityLevelCode2: [],
cityLevelCode3: []
};
},
watch: {
@@ -41,7 +44,10 @@
this.cityList = [],
this.cityLevel1 = [],
this.cityLevel2 = [],
this.cityLevel3 = []
this.cityLevel3 = [],
this.cityLevelCode1 = []
this.cityLevelCode2 = []
this.cityLevelCode3 = []
this.initCityData();
}
},
@@ -57,29 +63,42 @@
// 遍历城市js
this.cityData.forEach((item1, index1) => {
let temp2 = [];
let code2 = [];
this.cityLevel1.push(item1.provinceName);
this.cityLevelCode1.push(item1.provinceCode);
let temp4 = [];
let temp3 = [];
let code4 = [];
let code3 = [];
// 遍历市
item1.cities.forEach((item2, index2) => {
temp2.push(item2.cityName);
code2.push(item2.cityCode);
// 遍历区
item2.counties.forEach((item3, index3) => {
temp3.push(item3.countyName);
code3.push(item3.countyCode);
})
temp4[index2] = temp3;
temp3 = [];
code4[index2] = code3;
code3 = [];
})
this.cityLevel3[index1] = temp4;
this.cityLevelCode3[index1] = code4;
this.cityLevel2[index1] = temp2;
this.cityLevelCode2[index1] = code2;
})
// 选择器默认城市
this.cityList.push(this.cityLevel1, this.cityLevel2[0], this.cityLevel3[0][0]);
},
// 选中时执行
changeHandler(e) {
console.log(e)
const {
columnIndex,
index,
@@ -102,8 +121,12 @@
// 单击确认按钮时执行
confirm(e) {
// 输出数组 [省, 市, 区]
console.log(e.value);
this.$emit('confirm', e.value)
console.log(e);
console.log(this.cityLevelCode3);
console.log(this.cityLevel3);
const code = this.cityLevelCode3[e.indexs[0]][e.indexs[1]][e.indexs[2]];
console.log(code);
this.$emit('confirm', [e.value, code]);
// 隐藏城市选择器
this.show = false;
},