|
|
@@ -1,25 +1,25 @@
|
|
|
<template>
|
|
|
- <div ref="chartRef" style="width: 100%; height: 80vh;"></div>
|
|
|
+ <div ref="echartsRef" style="width: 100%; height: 80vh;"></div>
|
|
|
</template>
|
|
|
|
|
|
<script setup>
|
|
|
-// import { onMounted, onBeforeUnmount, ref } from 'vue';
|
|
|
-import {
|
|
|
- ref,
|
|
|
- onMounted,
|
|
|
- onDeactivated,
|
|
|
- onBeforeUnmount,
|
|
|
-} from "vue";
|
|
|
-
|
|
|
+import { onMounted, ref } from 'vue';
|
|
|
import * as echarts from 'echarts';
|
|
|
import { getOutputValueData } from "@/api/buscmonitoring/index";
|
|
|
-const chartRef = ref(null);
|
|
|
-const chartInstance = ref(null);
|
|
|
|
|
|
-// 重新窗口变化时,重新计算
|
|
|
-const resize = () => {
|
|
|
- chartInstance.value && chartInstance.value.resize();
|
|
|
-};
|
|
|
+const data = reactive({
|
|
|
+ form: {},
|
|
|
+ queryParams: {
|
|
|
+ pageNum: 1,
|
|
|
+ pageSize: 100000,
|
|
|
+ unifiedSocialCreditCode: '',
|
|
|
+ condition: "",
|
|
|
+ grade: null,
|
|
|
+ total: null
|
|
|
+ },
|
|
|
+})
|
|
|
+const { queryParams } = toRefs(data)
|
|
|
+const echartsRef = ref(null);
|
|
|
|
|
|
const fetchData = async () => {
|
|
|
try {
|
|
|
@@ -79,19 +79,72 @@ const fetchData = async () => {
|
|
|
}
|
|
|
};
|
|
|
|
|
|
-onMounted(() => {
|
|
|
- chartInstance.value = echarts.init(chartRef.value);
|
|
|
- fetchData();
|
|
|
- window.addEventListener("resize", resize);
|
|
|
-});
|
|
|
+/** 查询社保 */
|
|
|
+function getEchartsData() {
|
|
|
+ getOutputValueData(queryParams.value).then((res) => {
|
|
|
+ console.log(res)
|
|
|
+ const response = res.data
|
|
|
|
|
|
-// 页面keepAlive时,不监听页面
|
|
|
-onDeactivated(() => {
|
|
|
- window.removeEventListener("resize", resize);
|
|
|
-});
|
|
|
+ const namesArray = response.map(obj => obj.detailedUnitName);
|
|
|
+ const valuesArray = response.map(obj => obj.industrialOutputValue);
|
|
|
+ const valuesLastArray = response.map(obj => obj.industrialOutputValueLastYear);
|
|
|
|
|
|
-onBeforeUnmount(() => {
|
|
|
- window.removeEventListener("resize", resize);
|
|
|
-});
|
|
|
+ console.log(namesArray, valuesArray, valuesLastArray)
|
|
|
+
|
|
|
+ const chart = echarts.init(echartsRef.value);
|
|
|
+ const option = {
|
|
|
+ title: {
|
|
|
+ text: '产值产能检测'
|
|
|
+ },
|
|
|
+ tooltip: {
|
|
|
+ trigger: 'axis',
|
|
|
+ axisPointer: {
|
|
|
+ type: 'shadow'
|
|
|
+ }
|
|
|
+ },
|
|
|
+ legend: {},
|
|
|
+ grid: {
|
|
|
+ left: '3%',
|
|
|
+ right: '4%',
|
|
|
+ bottom: '3%',
|
|
|
+ containLabel: true
|
|
|
+ },
|
|
|
+ xAxis: {
|
|
|
+ type: 'value',
|
|
|
+ boundaryGap: [0, 0.01]
|
|
|
+ },
|
|
|
+ yAxis: {
|
|
|
+ type: 'category',
|
|
|
+ data: namesArray
|
|
|
+ },
|
|
|
+ series: [
|
|
|
+ {
|
|
|
+ name: '2023',
|
|
|
+ type: 'bar',
|
|
|
+ data: valuesArray
|
|
|
+ },
|
|
|
+ {
|
|
|
+ name: '2024',
|
|
|
+ type: 'bar',
|
|
|
+ data: valuesLastArray
|
|
|
+ }
|
|
|
+ ],
|
|
|
+ dataZoom: [{ // 这是一个 dataZoom 组件,可以控制 x 轴或 y 轴的区域缩放
|
|
|
+ type: 'slider', // 这里设置为 slider 类型,表示使用滑动条形式的 dataZoom 组件
|
|
|
+ yAxisIndex: 0, // 表示这个 dataZoom 组件控制第一个 y 轴
|
|
|
+ start: 10, // 数据窗口范围的起始百分比, 表示从10%的位置开始显示
|
|
|
+ end: 30 // 数据窗口范围的结束百分比, 表示到60%的位置结束
|
|
|
+ }]
|
|
|
+ };
|
|
|
|
|
|
-</script>
|
|
|
+ chart.setOption(option);
|
|
|
+ })
|
|
|
+}
|
|
|
+onMounted(() => {
|
|
|
+ getEchartsData();
|
|
|
+});
|
|
|
+</script>
|
|
|
+
|
|
|
+<style>
|
|
|
+/* 样式内容 */
|
|
|
+</style>
|