setOption debug

This commit is contained in:
koko 2025-07-28 16:49:44 +08:00
parent acb1f89b0a
commit edd7469ef2
4 changed files with 53 additions and 30 deletions

View File

@ -27,7 +27,12 @@ async function updateSvg(svg, option) {
axios.get(svg.path).then(async ({ data }) => {
echarts.registerMap(svg.full_name, { svg: data });
await nextTick();
// 調 setOption
setTimeout(() => {
if (chart.value && !chart.value.isDisposed()) {
chart.value.setOption(option);
}
}, 0);
if (props.getCoordinate) {
chart.value.getZr().on("click", function (params) {
var pixelPoint = [params.offsetX, params.offsetY];
@ -45,11 +50,15 @@ async function updateSvg(svg, option) {
value: dataPoint, //
itemStyle: { color: "#0000FF" }, //
});
setTimeout(() => {
if (chart.value && !chart.value.isDisposed()) {
chart.value.setOption({
series: {
data: updatedData,
},
});
}
}, 0);
});
}
});

View File

@ -37,7 +37,9 @@ watch(
formState.value.building_guid = newBuilding.building_guid;
imgBaseUrl.value = store.previewImageExt
? `${FILE_BASEURL}/upload/setting/previewImage/${newBuilding.building_guid}${store.previewImageExt}`
: "";
: import.meta.env.MODE === "production"
? "dist/build_img.jpg"
: "/build_img.jpg";
}
},
{ immediate: true, deep: true }
@ -111,7 +113,7 @@ onUnmounted(() => {
<!-- setting頁面要新增讓他能上傳圖片 -->
<img
alt="build"
:src="imgBaseUrl || '/build_img.jpg'"
:src="imgBaseUrl"
:class="
twMerge(
'absolute w-full h-full transition-opacity duration-300',

View File

@ -132,7 +132,9 @@ watch(
getData();
imgBaseUrl.value = buildingStore.previewImageExt
? `${FILE_BASEURL}/upload/setting/previewImage/${newBuilding.building_guid}${buildingStore.previewImageExt}`
: "";
: import.meta.env.MODE === "production"
? "dist/build_img.jpg"
: "/build_img.jpg";
}
},
{
@ -368,7 +370,7 @@ onUnmounted(() => {
<div class="h-full relative">
<img
alt="build"
:src="imgBaseUrl || '/build_img.jpg'"
:src="imgBaseUrl"
:class="
twMerge(
'absolute w-full h-full transition-opacity duration-300',

View File

@ -70,18 +70,19 @@ const defaultOption = (map, data = []) => {
watch(
realtimeData,
() => {
nextTick(() => {
setTimeout(() => {
if (
selectedFloor.value &&
asset_floor_chart.value &&
asset_floor_chart.value.chart
asset_floor_chart.value.chart &&
asset_floor_chart.value.chart.isDisposed() === false
) {
asset_floor_chart.value.chart.setOption(
defaultOption(selectedFloor.value?.title, selectedData.value),
true
);
}
});
}, 0);
},
{ deep: true }
);
@ -150,10 +151,13 @@ watch(
if (
selectedFloor.value &&
asset_floor_chart.value &&
asset_floor_chart.value.chart
asset_floor_chart.value.chart &&
asset_floor_chart.value.chart.isDisposed() === false
) {
const selected = allData.value.filter((d) => d[2].is2DActive);
const unSelected = allData.value.filter((d) => !d[2].is2DActive);
setTimeout(() => {
if (asset_floor_chart.value?.chart && !asset_floor_chart.value.chart.isDisposed()) {
asset_floor_chart.value.chart.setOption({
series: [
{ data: unSelected },
@ -163,6 +167,8 @@ watch(
],
});
}
}, 0);
}
},
{
deep: true,
@ -188,6 +194,8 @@ watch(
const unSelected = selectedData.value.filter((d) => !d[2].is2DActive);
console.log("allData.value", allData.value, selected, unSelected);
setTimeout(() => {
if (asset_floor_chart.value?.chart && !asset_floor_chart.value.chart.isDisposed()) {
asset_floor_chart.value.chart.setOption({
series: [
{ data: unSelected },
@ -197,6 +205,8 @@ watch(
],
});
}
}, 0);
}
},
{
deep: true,