forked from angelo/web-retail-h5
65 lines
1.7 KiB
JavaScript
65 lines
1.7 KiB
JavaScript
import { getRegionAreaList } from '@/config/order.js'
|
|
|
|
export default {
|
|
data() {
|
|
return {
|
|
regionList: [],
|
|
provinceList: [],
|
|
cityList: [],
|
|
countyList: [],
|
|
regionCity: '',
|
|
regionProvince: '',
|
|
regionCounty: '',
|
|
gradeValue: null,
|
|
defaultRegionSelectCode: [],
|
|
}
|
|
},
|
|
computed: {},
|
|
methods: {
|
|
getRegionAreaList(gradeValue) {
|
|
if (!gradeValue) return
|
|
this.gradeValue = gradeValue
|
|
const params = {
|
|
type: gradeValue === 80 ? 'city' : 'county',
|
|
}
|
|
getRegionAreaList(params).then(res => {
|
|
this.provinceList = res.data.filter(item => item.parent === 0)
|
|
this.cityList = res.data.filter(item =>
|
|
this.provinceList.find(province => province.pkId === item.parent)
|
|
)
|
|
this.countyList = res.data.filter(item =>
|
|
this.cityList.find(city => city.pkId === item.parent)
|
|
)
|
|
this.getProvinceFilterList()
|
|
this.getCityFilterList()
|
|
this.getCountyFilterList()
|
|
})
|
|
},
|
|
getProvinceFilterList() {
|
|
if (!this.cityList.length) {
|
|
this.provinceList = []
|
|
}
|
|
this.provinceList = this.provinceList.filter(
|
|
item => !!this.cityList.find(city => city.parent === item.pkId)
|
|
)
|
|
},
|
|
getCityFilterList() {
|
|
if (this.gradeValue === 80) return
|
|
if (!this.countyList.length) {
|
|
this.cityList = []
|
|
}
|
|
this.cityList = this.cityList.filter(
|
|
item => !!this.countyList.find(county => county.parent === item.pkId)
|
|
)
|
|
},
|
|
getCountyFilterList() {
|
|
if (!this.gradeValue || this.gradeValue === 80) {
|
|
this.countyList = []
|
|
}
|
|
},
|
|
},
|
|
onShow() {
|
|
// this.getRegionAreaList()
|
|
},
|
|
}
|