117 lines
2.2 KiB
Vue
117 lines
2.2 KiB
Vue
<template>
|
|
<custom-echart-line :chart-data="state.data" height="100%" :option="state.option" />
|
|
</template>
|
|
<script setup>
|
|
import { reactive, watch } from 'vue';
|
|
import { isEmpty, sleep } from '@/utils';
|
|
|
|
const props = defineProps({
|
|
data: {
|
|
type: Array,
|
|
default: () => [],
|
|
},
|
|
query: {
|
|
type: String,
|
|
default: '',
|
|
},
|
|
});
|
|
|
|
const state = reactive({
|
|
option: {
|
|
color: ['#35D0C0'],
|
|
grid: {
|
|
left: '5%',
|
|
right: '5%',
|
|
bottom: '5%',
|
|
top: '10%',
|
|
containLabel: true,
|
|
},
|
|
tooltip: {
|
|
trigger: 'axis',
|
|
axisPointer: {
|
|
type: 'shadow',
|
|
},
|
|
backgroundColor: 'rgba(18, 55, 85, 0.8);',
|
|
borderColor: '#35d0c0',
|
|
formatter: (data) => {
|
|
const params = data[0];
|
|
let str = `<div class="custom-echarts-tips">
|
|
<span>${params.name}</span><br/>
|
|
<span>${params.marker} ${params.data} 万元</span>
|
|
</div>`;
|
|
return str;
|
|
},
|
|
},
|
|
xAxis: {
|
|
type: 'category',
|
|
// name: '年份',
|
|
axisTick: {
|
|
show: false,
|
|
alignWithLabel: false,
|
|
interval: 'auto',
|
|
inside: false,
|
|
length: 5,
|
|
lineStyle: {
|
|
type: 'solid',
|
|
width: 1,
|
|
color: 'rgba(28, 158, 222, 1)',
|
|
},
|
|
},
|
|
},
|
|
yAxis: {
|
|
type: 'value',
|
|
// name: '',
|
|
},
|
|
},
|
|
data: [],
|
|
});
|
|
|
|
const loadData = async (code = '') => {
|
|
state.loading = true;
|
|
// GetInputsInfo()
|
|
// .then((res) => {
|
|
// if (res.code === 200) {
|
|
// state.data = res.data;
|
|
// }
|
|
// })
|
|
// .catch((err) => {
|
|
// app.$message.error(err.msg);
|
|
// });
|
|
await sleep(500);
|
|
state.data = [
|
|
{ value: 5, name: '2020' },
|
|
{ value: 36, name: '2021' },
|
|
{ value: 70, name: '2022' },
|
|
{ value: 56, name: '2023' },
|
|
{ value: 70, name: '2024' },
|
|
{ value: 20, name: '2025' },
|
|
];
|
|
};
|
|
|
|
watch(
|
|
() => props.data,
|
|
(val) => {
|
|
if (!isEmpty(val)) {
|
|
state.data = val;
|
|
}
|
|
},
|
|
{
|
|
deep: true,
|
|
immediate: true,
|
|
}
|
|
);
|
|
|
|
watch(
|
|
() => props.query,
|
|
(val) => {
|
|
if (!isEmpty(val)) {
|
|
loadData(val);
|
|
}
|
|
},
|
|
{
|
|
deep: true,
|
|
immediate: true,
|
|
}
|
|
);
|
|
</script>
|