城阳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.

151 lines
3.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" 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: ''
}
},
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();
}
},
methods: {
3 years ago
handleClick(item) {
this.currentTab = item;
this.getInfo();
},
async init() {
await this.getInfo();
this.getPie();
},
handleClickItem(item) {
3 years ago
// const { type, name } = item;
// this.$router.push({
// path: '/dataBoard/renfang/resi-analyze',
// query: {
// org_id: this.orgId,
// type,
// type_category: this.currentTab,
// type_name: name
// }
// });
},
// 获取房屋总数等
async getInfo() {
3 years ago
let url = '';
if (this.currentTab == '公共服务') {
3 years ago
url = 'common_service_view';
3 years ago
} else {
3 years ago
url = 'self_service_views';
3 years ago
}
3 years ago
this.$refs.pieChart.showLoading();
const { data, code, msg } = await requestPostBi(
url,
{
queryParam: {
org_id: this.orgId
}
},
{
// mockId: 60041615,
}
);
this.$refs.pieChart.hideLoading();
if (code === 0) {
if (data && Array.isArray(data) && data.length > 0) {
let info = data[0];
this.info = {
...this.info,
...info
};
}
3 years ago
this.data = data;
this.setPieData();
} else {
this.$message.error(msg);
}
},
3 years ago
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);
}
}
};
</script>
<style lang="scss" src="@/assets/scss/dataBoard/renfang/index.scss" scoped></style>