新增数据,开始安全巡检模块
This commit is contained in:
@@ -7,9 +7,6 @@ import { ref, onMounted, onBeforeUnmount, watch, nextTick } from 'vue';
|
||||
import * as echarts from 'echarts';
|
||||
import type { EChartsOption, ECharts } from 'echarts';
|
||||
|
||||
// ==============================================
|
||||
// ✅ 【核心修复】正确的 Vue3 + TS Props 写法
|
||||
// ==============================================
|
||||
interface Props {
|
||||
width?: string;
|
||||
height?: string;
|
||||
@@ -36,6 +33,7 @@ const emit = defineEmits<{
|
||||
|
||||
const chartRef = ref<HTMLDivElement>();
|
||||
let chartInstance: ECharts | null = null;
|
||||
let resizeObserver: ResizeObserver | null = null;
|
||||
|
||||
const initChart = () => {
|
||||
if (!chartRef.value) return;
|
||||
@@ -66,8 +64,10 @@ const updateChart = () => {
|
||||
}
|
||||
};
|
||||
|
||||
// ✅ 核心修复:支持 scale 缩放后重绘
|
||||
const resizeChart = () => {
|
||||
chartInstance?.resize();
|
||||
if (!chartInstance) return;
|
||||
chartInstance.resize();
|
||||
};
|
||||
|
||||
const getInstance = () => chartInstance;
|
||||
@@ -88,17 +88,19 @@ onMounted(() => {
|
||||
nextTick(() => initChart());
|
||||
|
||||
if (props.autoResize && chartRef.value) {
|
||||
const resizeObserver = new ResizeObserver(resizeChart);
|
||||
resizeObserver = new ResizeObserver(resizeChart);
|
||||
resizeObserver.observe(chartRef.value);
|
||||
|
||||
onBeforeUnmount(() => {
|
||||
resizeObserver.disconnect();
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
// ✅ 关键:监听 window.resize(scale 缩放会触发 window.resize)
|
||||
onMounted(() => {
|
||||
window.addEventListener('resize', resizeChart);
|
||||
});
|
||||
|
||||
onBeforeUnmount(() => {
|
||||
window.removeEventListener('resize', resizeChart);
|
||||
resizeObserver?.disconnect();
|
||||
chartInstance?.dispose();
|
||||
chartInstance = null;
|
||||
});
|
||||
@@ -114,5 +116,7 @@ defineExpose({
|
||||
<style lang="scss" scoped>
|
||||
.echarts-container {
|
||||
display: block;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
}
|
||||
</style>
|
||||
|
||||
@@ -78,10 +78,17 @@ import { ResidentVO } from '@/api/system/resident/type';
|
||||
import { getHousePathById } from '@/utils/house';
|
||||
import { ref, watch, nextTick, getCurrentInstance, ComponentInternalInstance, toRefs } from 'vue';
|
||||
import { useHouseStore } from '@/store/modules/house';
|
||||
import { storeToRefs } from 'pinia';
|
||||
|
||||
const houseStore = useHouseStore();
|
||||
const { treedata } = storeToRefs(houseStore);
|
||||
|
||||
const treedata = ref([]);
|
||||
function init() {
|
||||
houseStore.getCurrentVilageTreeHouse().then((res) => {
|
||||
console.log(res);
|
||||
treedata.value = res;
|
||||
});
|
||||
}
|
||||
init();
|
||||
|
||||
const { proxy } = getCurrentInstance() as ComponentInternalInstance;
|
||||
const { com_resident_type } = toRefs<any>(proxy?.useDict('com_resident_type'));
|
||||
|
||||
Reference in New Issue
Block a user