城阳pc工作端前端代码
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

190 lines
4.2 KiB

<template>
3 years ago
<div class="m-fwqd">
<div class="tablist">
3 years ago
<div v-for="item in tabList" :key="item" :class="['item', { 'item-sel': currentTab == item }]" @click="handleClick(item)">{{ item }}</div>
</div>
<div class="pieMain">
<div class="legend">
<div class="legend-row " :key="'pie' + item.name" v-for="item in pieData" @click="handleClickItem(item)">
<div class="name">{{ item.name }}</div>
<div class="content">
<div class="num">{{ item.value }}</div>
<div class="unit"></div>
</div>
</div>
</div>
<div class="pie"><screen-echarts-frame @myChartMethod="pieInitOk" aria-controls="" ref="pieChart"></screen-echarts-frame></div>
</div>
</div>
</template>
<script>
import screenEchartsFrame from '@/views/dataBoard/cpts/screen-echarts-frame/index';
import { pieOption } from './fwqdPieOption.js';
import { requestPostBi } from '@/js/dai/request-bipass';
export default {
props: {
orgId: {
type: String,
default: ''
},
searchDate: Array
},
data() {
return {
3 years ago
data: {},
showNoData: false,
timer: null,
pieChart: '',
pieOption: {},
pieInitState: false,
pieData: [],
tabList: [
'公共服务',
'个性服务'
// "下级人口分布",
],
3 years ago
currentTab: '公共服务'
};
},
components: {
screenEchartsFrame
},
mounted() {
// this.init();
},
watch: {
orgId() {
this.init();
},
searchDate() {
this.init();
}
},
methods: {
3 years ago
handleClick(item) {
this.currentTab = item;
this.getInfo();
},
async init() {
if (this.orgId) {
await this.getInfo();
this.getPie();
}
},
handleClickItem(item) {
let typeArr = { "全部": "all",
"志愿者": "volunteer",
"社区自组织": "community_org",
"联建单位": "party_unit",
"安全应急设备":"safety_emergency_equipment",
"公共服务设备":"common_service_equipment",
"安全生产场所":"enterprise",
"应急场所":"emergency_sites",
"城市管理":"city_management" };
// 场所资源
let path = '';
if (this.currentTab == '个性服务列表') {
path = 'gexingList';
} else if (this.currentTab == '公共服务列表') {
path = 'gonggongList';
}
this.getInfo();
console.log("item.name",item.name)
this.$router.push({
path: `/dataBoard/sida/fw/${path}`,
query: {
org_id: this.orgId,
type: this.currentTab,
type2: typeArr[item.name],
start_date: this.searchDate[0],
end_date: this.searchDate[1]
}
});
},
// 获取房屋总数等
async getInfo() {
3 years ago
let url = '';
let mockId = 0;
3 years ago
if (this.currentTab == '公共服务') {
3 years ago
url = 'common_service_view';
mockId = 66900331;
3 years ago
} else {
url = 'self_service_view';
mockId = 66902813;
3 years ago
}
3 years ago
this.$refs.pieChart.showLoading();
const { data, code, msg } = await requestPostBi(
url,
{
queryParam: {
org_id: this.orgId,
start_date: this.searchDate[0],
end_date: this.searchDate[1]
}
},
{
// mockId: mockId,
}
);
this.$refs.pieChart.hideLoading();
if (code === 0) {
if (data && Array.isArray(data) && data.length > 0) {
3 years ago
let info = data[0].slice(0, 10);
this.info = {
...this.info,
...info
};
}
3 years ago
this.data = data.sort((a, b) => {
3 years ago
return b.count - a.count;
});
3 years ago
this.setPieData();
} else {
this.$message.error(msg);
}
},
pieInitOk() {
this.pieInitState = true;
},
getPie() {
if (this.pieInitState) {
this.setPieData();
} else {
setTimeout(() => {
this.getPie();
}, 500);
}
},
setPieData() {
3 years ago
let { data } = this;
3 years ago
data = JSON.parse(JSON.stringify(data).replace(/count/g, 'value'));
3 years ago
3 years ago
this.pieData = data;
this.iniPieChart();
},
// 获取饼状图
async iniPieChart() {
this.$refs.pieChart.clear();
// 获取pieChart配置
this.pieOption = pieOption();
this.pieOption.series[0].name = this.currentTab;
this.pieOption.series[0].data = this.pieData;
this.$refs.pieChart.setOption(this.pieOption);
},
handelClickMyPei(item) {
this.handleClickItem(item);
}
}
};
</script>
<style lang="scss" src="@/assets/scss/dataBoard/renfang/index.scss" scoped></style>
<style lang="scss" scoped>
.pieMain .legend{margin-top:0px;}
</style>