This commit is contained in:
gongjiale 2024-12-05 16:28:16 +08:00
commit aff024c6f9
3 changed files with 19 additions and 12 deletions

View File

@ -49,20 +49,17 @@ export default {
watch: {
queryParam: {
handler: function (newVal, oldVal) {
this.refreshDebounce();
this.refresh();
},
deep: true,
},
selectedDept: {
handler: function (newVal, oldVal) {
this.refreshDebounce();
this.refresh();
},
deep: true,
},
},
mounted() {
this.refreshDebounce = debounce(this.refresh, 100);
},
methods: {
refresh() {
if (this.selectedDept && this.selectedDept.sn && this.queryParam) {
@ -81,12 +78,17 @@ export default {
this.chartData.Xdata = axisData;
this.chartData.Ydata = seriesData;
} else {
this.chartData.Xdata = [];
this.chartData.Ydata = [];
this.resetChart();
}
});
} else {
this.resetChart();
}
},
resetChart() {
this.chartData.Xdata = [];
this.chartData.Ydata = [];
},
},
};
</script>

View File

@ -4,7 +4,7 @@
:center="position"
:zoom="16" :scroll-wheel-zoom=true
style="width: auto; height: 40vh;"
:map-type="currentMapType"
:map-type="currentMapType"
>
<bm-map-type
:map-types="['BMAP_NORMAL_MAP', 'BMAP_HYBRID_MAP']"
@ -32,15 +32,15 @@ export default {
computed: {
position() {
return {
lng: parseFloat(this.selectedDept.longitude),
lat: parseFloat(this.selectedDept.latitude),
lng: parseFloat(this.selectedDept?.longitude),
lat: parseFloat(this.selectedDept?.latitude),
};
},
},
data() {
return {
currentMapType: 'BMAP_HYBRID_MAP',
}}
};
</script>

View File

@ -87,7 +87,12 @@ export default {
refresh() {
if (this.queryParam.deptId) {
getDeviceList(this.queryParam.deptId, this.pager).then((res) => {
if (res.code === 200 && res.rows.length > 0) {
if (res.code === 200) {
if (res.rows.length === 0) {
this.tableData = [];
this.deptSelect(null);
return;
}
this.tableData = res.rows;
this.radio = res.rows[0].id;
this.pager.total = res.total;