修改公告页城市列表逻辑-更换接口后的数据处理

This commit is contained in:
熊丽君
2021-08-20 18:11:21 +08:00
parent 19f379a826
commit fff8b4df04
3 changed files with 64 additions and 28 deletions

View File

@ -49,3 +49,10 @@ export function getRead(params) {
params params
}); });
} }
// 根据level查询城市 1->省 2->市 3->合肥
export function getCityByLevel(params) {
return request({
url: '/dict/getCityByLevel',
params
});
}

View File

@ -21,7 +21,7 @@
target="_blank" target="_blank"
:to="{ :to="{
path: '/portrait', path: '/portrait',
query: { key: 'policyRead', val: '归口' }, query: { key: 'policyRead', val: '归口' }
}" }"
> >
<div class="title_top_r pointer"> <div class="title_top_r pointer">
@ -54,7 +54,7 @@
target="_blank" target="_blank"
:to="{ :to="{
path: '/result', path: '/result',
query: { key: 'policyRead', id: item.id }, query: { key: 'policyRead', id: item.id }
}" }"
> >
{{ item.title }} {{ item.title }}
@ -93,7 +93,7 @@
target="_blank" target="_blank"
:to="{ :to="{
path: '/result', path: '/result',
query: { key: 'policy', id: item.id }, query: { key: 'policy', id: item.id }
}" }"
> >
{{ item.title }} {{ item.title }}
@ -113,7 +113,7 @@
target="_blank" target="_blank"
:to="{ :to="{
path: '/portrait', path: '/portrait',
query: { key: 'information', val: '' }, query: { key: 'information', val: '' }
}" }"
> >
<div class="title_top_r pointer"> <div class="title_top_r pointer">
@ -129,7 +129,7 @@
target="_blank" target="_blank"
:to="{ :to="{
path: '/result', path: '/result',
query: { key: 'information', id: item.id }, query: { key: 'information', id: item.id }
}" }"
> >
{{ item.title }} {{ item.title }}
@ -146,7 +146,7 @@
<div> <div>
<router-link <router-link
target="_blank" target="_blank"
:to="{ path: '/notice', query: { key: '1', val: '安徽' } }" :to="{ path: '/notice', query: { key: 'AH', val: '安徽' } }"
> >
<img src="@/assets/image/city/01.png" alt="" /> <img src="@/assets/image/city/01.png" alt="" />
<span>安徽</span> <span>安徽</span>
@ -392,19 +392,19 @@ export default {
return { return {
bannerList: [logoImg1, logoImg2, logoImg3], bannerList: [logoImg1, logoImg2, logoImg3],
queryParams: { queryParams: {
labelId: '1415156808053559296', labelId: '1415156808053559296'
}, },
queryParams2: { queryParams2: {
attributeId: 'JXJ', attributeId: 'JXJ'
}, },
queryParams3: { queryParams3: {
pageNum: 1, pageNum: 1,
pageSize: 7, pageSize: 7
}, },
date: this.parseTime(new Date(), '{y}-{m}-{d}'), date: this.parseTime(new Date(), '{y}-{m}-{d}'),
list: [], list: [],
list2: [], list2: [],
list3: [], list3: []
}; };
}, },
methods: { methods: {
@ -419,7 +419,7 @@ export default {
getPolicyRead(this.queryParams2).then(({ data }) => { getPolicyRead(this.queryParams2).then(({ data }) => {
this.list2 = data.list; this.list2 = data.list;
}); });
}, }
}, },
created() { created() {
this.handleClick(); this.handleClick();
@ -427,7 +427,7 @@ export default {
getInformation(this.queryParams3).then(({ data }) => { getInformation(this.queryParams3).then(({ data }) => {
this.list3 = data.list; this.list3 = data.list;
}); });
}, }
}; };
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>

View File

@ -42,11 +42,11 @@
<div class="screen_l_t_item" v-if="city == 2 || city == 3"> <div class="screen_l_t_item" v-if="city == 2 || city == 3">
<el-radio-group v-model="queryParams.city" size="medium"> <el-radio-group v-model="queryParams.city" size="medium">
<el-radio-button <el-radio-button
:label="item.id" :label="item.value"
v-for="item in levelList_2" v-for="item in levelList_2"
:key="item.id" :key="item.value"
> >
{{ item.name }} {{ item.label }}
</el-radio-button> </el-radio-button>
</el-radio-group> </el-radio-group>
</div> </div>
@ -196,6 +196,7 @@
import { mapGetters } from 'vuex'; import { mapGetters } from 'vuex';
import { import {
getDictListByStatus, getDictListByStatus,
getCityByLevel,
getLabel, getLabel,
getPolicyList, getPolicyList,
getPolicyMatch getPolicyMatch
@ -221,7 +222,7 @@ export default {
dataList: [], dataList: [],
levelList: [ levelList: [
{ {
label: '1', label: 'AH',
name: '安徽省' name: '安徽省'
}, },
{ {
@ -266,17 +267,19 @@ export default {
}, },
watch: { watch: {
city(a, b) { city(a, b) {
if (a == '' || a == 1) { if (a == '' || a == 'AH') {
this.queryParams.city = this.city; this.queryParams.city = this.city;
this.getList();
} else if (a == 2) { } else if (a == 2) {
this.levelList_2 = this.levelList_3; this.levelList_2 = this.levelList_3;
this.queryParams.city = this.activeID || this.levelList_2[0].id; this.queryParams.city = this.activeID || this.levelList_2[0].value;
} else if (a == 3) { } else if (a == 3) {
this.levelList_2 = this.levelList_4; this.levelList_2 = this.levelList_4;
this.queryParams.city = this.levelList_2[0].id; this.queryParams.city = this.levelList_2[0].value;
} }
}, },
'queryParams.city'() {
this.getList();
},
'queryParams.attribute'() { 'queryParams.attribute'() {
this.getList(); this.getList();
}, },
@ -324,10 +327,16 @@ export default {
}, },
// 获取所有城市列表 // 获取所有城市列表
getCityList() { getCityList() {
getDictListByStatus({ type: 5 }).then(({ data }) => { // getDictListByStatus({ type: 5 }).then(({ data }) => {
// this.levelList_3 = data;
// });
// getDictListByStatus({ type: 6 }).then(({ data }) => {
// this.levelList_4 = data;
// });
getCityByLevel({ level: 2 }).then(({ data }) => {
this.levelList_3 = data; this.levelList_3 = data;
}); });
getDictListByStatus({ type: 6 }).then(({ data }) => { getCityByLevel({ level: 3 }).then(({ data }) => {
this.levelList_4 = data; this.levelList_4 = data;
}); });
} }
@ -341,23 +350,43 @@ export default {
this.queryParams.labelIds.push(''); this.queryParams.labelIds.push('');
} }
if (key == 2) { if (key == 2) {
getDictListByStatus({ type: 5 }).then(({ data }) => { // getDictListByStatus({ type: 5 }).then(({ data }) => {
// this.levelList_3 = data;
// this.city = key;
// this.activeID =
// data.find(item => {
// return item.name.indexOf(val) != -1;
// }).id || '';
// this.getList();
// });
// getDictListByStatus({ type: 6 }).then(({ data }) => {
// this.levelList_4 = data;
// });
getCityByLevel({ level: 2 }).then(({ data }) => {
this.levelList_3 = data; this.levelList_3 = data;
this.city = key; this.city = key;
this.activeID = this.activeID =
data.find(item => { data.find(item => {
return item.name.indexOf(val) != -1; return item.label.indexOf(val) != -1;
}).id || ''; }).value || '';
this.getList(); this.getList();
}); });
getDictListByStatus({ type: 6 }).then(({ data }) => { getCityByLevel({ level: 3 }).then(({ data }) => {
this.levelList_4 = data; this.levelList_4 = data;
}); });
} else if (key == 3) { } else if (key == 3) {
getDictListByStatus({ type: 5 }).then(({ data }) => { // getDictListByStatus({ type: 5 }).then(({ data }) => {
// this.levelList_3 = data;
// });
// getDictListByStatus({ type: 6 }).then(({ data }) => {
// this.levelList_4 = data;
// this.city = key;
// this.getList();
// });
getCityByLevel({ level: 2 }).then(({ data }) => {
this.levelList_3 = data; this.levelList_3 = data;
}); });
getDictListByStatus({ type: 6 }).then(({ data }) => { getCityByLevel({ level: 2 }).then(({ data }) => {
this.levelList_4 = data; this.levelList_4 = data;
this.city = key; this.city = key;
this.getList(); this.getList();