🐞 fix: 实时统计页面BUG修复

This commit is contained in:
LokerL 2024-12-05 16:22:00 +08:00
parent 0953591ae8
commit 4d1f2e6fec
3 changed files with 19 additions and 12 deletions

View File

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

View File

@ -32,8 +32,8 @@ export default {
computed: { computed: {
position() { position() {
return { return {
lng: parseFloat(this.selectedDept.longitude), lng: parseFloat(this.selectedDept?.longitude),
lat: parseFloat(this.selectedDept.latitude), lat: parseFloat(this.selectedDept?.latitude),
}; };
}, },
}, },

View File

@ -87,7 +87,12 @@ export default {
refresh() { refresh() {
if (this.queryParam.deptId) { if (this.queryParam.deptId) {
getDeviceList(this.queryParam.deptId, this.pager).then((res) => { 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.tableData = res.rows;
this.radio = res.rows[0].id; this.radio = res.rows[0].id;
this.pager.total = res.total; this.pager.total = res.total;