feat: 细化设备树自动定位的触发条件
- 添加 `hasFromPage` 属性,辅助区分选择设备的来源是用户操作还是路由参数
This commit is contained in:
@@ -46,6 +46,7 @@ const {
|
||||
selectedStationCode,
|
||||
selectedDeviceType,
|
||||
selectedDevice,
|
||||
hasFromPage,
|
||||
selectDevice,
|
||||
routeDevice,
|
||||
// 设备管理
|
||||
@@ -460,12 +461,15 @@ const onLocateDeviceTree = async () => {
|
||||
|
||||
animated.value = true;
|
||||
};
|
||||
// 渲染全线设备树时,若是首次选择设备,则定位设备树
|
||||
const unwatch = watch(selectedDevice, async (newDevice, oldDevice) => {
|
||||
// 渲染全线设备树时,若是首次经过路由跳转而来选择设备,则定位设备树
|
||||
const unwatchLocate = watch(selectedDevice, async (newDevice, oldDevice) => {
|
||||
if (!!station.value) return;
|
||||
if (!!newDevice && !oldDevice && !!deviceTreeInst.value) {
|
||||
await onLocateDeviceTree();
|
||||
unwatch();
|
||||
if (!hasFromPage.value) return;
|
||||
if (!!newDevice && !oldDevice) {
|
||||
if (!!deviceTreeInst.value) {
|
||||
await onLocateDeviceTree();
|
||||
unwatchLocate();
|
||||
}
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
||||
Reference in New Issue
Block a user