diff --git a/src/views/iot/device/DeviceForm.vue b/src/views/iot/device/DeviceForm.vue index 6a53b879..e5a744ac 100644 --- a/src/views/iot/device/DeviceForm.vue +++ b/src/views/iot/device/DeviceForm.vue @@ -167,7 +167,14 @@ const open = async (type: string, id?: number) => { type === 'setting' ? t('DataCollection.Device.settingDialogTitle') : t('action.' + type) formType.value = type resetForm() - // 修改时,设置数据 + + try { + const models = await DeviceModelApi.getDeviceModelList() + modelList.value = Array.isArray(models) ? models : [] + } catch { + modelList.value = [] + } + if (id) { formLoading.value = true try { @@ -244,8 +251,4 @@ const resetForm = () => { } /** 初始化 **/ -onMounted(async () => { - modelList.value = await DeviceModelApi.getDeviceModelList() - -})