From 742d561c330ec70981e20f58b9419ffbe8190f04 Mon Sep 17 00:00:00 2001 From: yangsy Date: Wed, 17 Dec 2025 14:36:10 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E8=AE=BE=E5=A4=87?= =?UTF-8?q?=E6=9B=B4=E6=96=B0=E9=9D=A2=E6=9D=BF=E4=B8=AD=E9=94=99=E8=AF=AF?= =?UTF-8?q?=E7=9A=84=E8=A1=A8=E5=8D=95=E6=A0=A1=E9=AA=8C=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../device-card/ndm-alarm-host/alarm-host-update.vue | 7 +++++-- .../device/device-card/ndm-camera/camera-update.vue | 7 +++++-- .../device/device-card/ndm-decoder/decoder-update.vue | 7 +++++-- .../device/device-card/ndm-keyboard/keyboard-update.vue | 7 +++++-- src/components/device/device-card/ndm-nvr/nvr-update.vue | 7 +++++-- .../device-card/ndm-security-box/security-box-update.vue | 7 +++++-- .../device/device-card/ndm-server/server-update.vue | 7 +++++-- .../device/device-card/ndm-switch/switch-update.vue | 7 +++++-- 8 files changed, 40 insertions(+), 16 deletions(-) diff --git a/src/components/device/device-card/ndm-alarm-host/alarm-host-update.vue b/src/components/device/device-card/ndm-alarm-host/alarm-host-update.vue index 7e6a91b..63f2fe3 100644 --- a/src/components/device/device-card/ndm-alarm-host/alarm-host-update.vue +++ b/src/components/device/device-card/ndm-alarm-host/alarm-host-update.vue @@ -55,6 +55,9 @@ const { mutateAsync: validateDeviceIdDuplicated } = useMutation({ const deviceIdPattern = /^\d{4}01\d{4}$/; if (!deviceIdPattern.test(deviceId)) throw new Error('设备ID不符合规范'); + // 如果没有修改设备ID,则不做ID唯一性校验 + if (deviceId === ndmDevice.value.deviceId) return; + validatorAbortController.value.abort(); validatorAbortController.value = new AbortController(); @@ -69,8 +72,7 @@ const { mutateAsync: validateDeviceIdDuplicated } = useMutation({ const { mutate: updateDevice, isPending: loading } = useMutation({ mutationFn: async () => { await formInst.value?.validate().catch(() => { - window.$message.error('表单验证失败'); - return; + throw new Error('表单校验失败'); }); abortController.value.abort(); @@ -85,6 +87,7 @@ const { mutate: updateDevice, isPending: loading } = useMutation({ onSuccess: (newDevice) => { localDevice.value = { ...newDevice }; deviceStore.patchDevice(station.value.code, { ...newDevice }); + window.$message.success('更新成功'); }, onError: (error) => { if (isCancel(error)) return; diff --git a/src/components/device/device-card/ndm-camera/camera-update.vue b/src/components/device/device-card/ndm-camera/camera-update.vue index 9816117..12f7e15 100644 --- a/src/components/device/device-card/ndm-camera/camera-update.vue +++ b/src/components/device/device-card/ndm-camera/camera-update.vue @@ -54,6 +54,9 @@ const { mutateAsync: validateDeviceIdDuplicated } = useMutation({ const deviceIdPattern = /^\d{4}06\d{4}$/; if (!deviceIdPattern.test(deviceId)) throw new Error('设备ID不符合规范'); + // 如果没有修改设备ID,则不做ID唯一性校验 + if (deviceId === ndmDevice.value.deviceId) return; + validatorAbortController.value.abort(); validatorAbortController.value = new AbortController(); @@ -68,8 +71,7 @@ const { mutateAsync: validateDeviceIdDuplicated } = useMutation({ const { mutate: updateDevice, isPending: loading } = useMutation({ mutationFn: async () => { await formInst.value?.validate().catch(() => { - window.$message.error('表单验证失败'); - return; + throw new Error('表单校验失败'); }); abortController.value.abort(); @@ -84,6 +86,7 @@ const { mutate: updateDevice, isPending: loading } = useMutation({ onSuccess: (newDevice) => { localDevice.value = { ...newDevice }; deviceStore.patchDevice(station.value.code, { ...newDevice }); + window.$message.success('更新成功'); }, onError: (error) => { if (isCancel(error)) return; diff --git a/src/components/device/device-card/ndm-decoder/decoder-update.vue b/src/components/device/device-card/ndm-decoder/decoder-update.vue index 7b5640a..f92573e 100644 --- a/src/components/device/device-card/ndm-decoder/decoder-update.vue +++ b/src/components/device/device-card/ndm-decoder/decoder-update.vue @@ -54,6 +54,9 @@ const { mutateAsync: validateDeviceIdDuplicated } = useMutation({ const deviceIdPattern = /^\d{4}07\d{4}$/; if (!deviceIdPattern.test(deviceId)) throw new Error('设备ID不符合规范'); + // 如果没有修改设备ID,则不做ID唯一性校验 + if (deviceId === ndmDevice.value.deviceId) return; + validatorAbortController.value.abort(); validatorAbortController.value = new AbortController(); @@ -68,8 +71,7 @@ const { mutateAsync: validateDeviceIdDuplicated } = useMutation({ const { mutate: updateDevice, isPending: loading } = useMutation({ mutationFn: async () => { await formInst.value?.validate().catch(() => { - window.$message.error('表单验证失败'); - return; + throw new Error('表单校验失败'); }); abortController.value.abort(); @@ -84,6 +86,7 @@ const { mutate: updateDevice, isPending: loading } = useMutation({ onSuccess: (newDevice) => { localDevice.value = { ...newDevice }; deviceStore.patchDevice(station.value.code, { ...newDevice }); + window.$message.success('更新成功'); }, onError: (error) => { if (isCancel(error)) return; diff --git a/src/components/device/device-card/ndm-keyboard/keyboard-update.vue b/src/components/device/device-card/ndm-keyboard/keyboard-update.vue index dae572c..8b28505 100644 --- a/src/components/device/device-card/ndm-keyboard/keyboard-update.vue +++ b/src/components/device/device-card/ndm-keyboard/keyboard-update.vue @@ -54,6 +54,9 @@ const { mutateAsync: validateDeviceIdDuplicated } = useMutation({ const deviceIdPattern = /^\d{4}08\d{4}$/; if (!deviceIdPattern.test(deviceId)) throw new Error('设备ID不符合规范'); + // 如果没有修改设备ID,则不做ID唯一性校验 + if (deviceId === ndmDevice.value.deviceId) return; + validatorAbortController.value.abort(); validatorAbortController.value = new AbortController(); @@ -68,8 +71,7 @@ const { mutateAsync: validateDeviceIdDuplicated } = useMutation({ const { mutate: updateDevice, isPending: loading } = useMutation({ mutationFn: async () => { await formInst.value?.validate().catch(() => { - window.$message.error('表单验证失败'); - return; + throw new Error('表单校验失败'); }); abortController.value.abort(); @@ -84,6 +86,7 @@ const { mutate: updateDevice, isPending: loading } = useMutation({ onSuccess: (newDevice) => { localDevice.value = { ...newDevice }; deviceStore.patchDevice(station.value.code, { ...newDevice }); + window.$message.success('更新成功'); }, onError: (error) => { if (isCancel(error)) return; diff --git a/src/components/device/device-card/ndm-nvr/nvr-update.vue b/src/components/device/device-card/ndm-nvr/nvr-update.vue index 598824e..9ea11d4 100644 --- a/src/components/device/device-card/ndm-nvr/nvr-update.vue +++ b/src/components/device/device-card/ndm-nvr/nvr-update.vue @@ -54,6 +54,9 @@ const { mutateAsync: validateDeviceIdDuplicated } = useMutation({ const deviceIdPattern = /^\d{4}05\d{4}$/; if (!deviceIdPattern.test(deviceId)) throw new Error('设备ID不符合规范'); + // 如果没有修改设备ID,则不做ID唯一性校验 + if (deviceId === ndmDevice.value.deviceId) return; + validatorAbortController.value.abort(); validatorAbortController.value = new AbortController(); @@ -68,8 +71,7 @@ const { mutateAsync: validateDeviceIdDuplicated } = useMutation({ const { mutate: updateDevice, isPending } = useMutation({ mutationFn: async () => { await formInst.value?.validate().catch(() => { - window.$message.error('表单验证失败'); - return; + throw new Error('表单校验失败'); }); abortController.value.abort(); @@ -84,6 +86,7 @@ const { mutate: updateDevice, isPending } = useMutation({ onSuccess: (newDevice) => { localDevice.value = { ...newDevice }; deviceStore.patchDevice(station.value.code, { ...newDevice }); + window.$message.success('更新成功'); }, onError: (error) => { if (isCancel(error)) return; diff --git a/src/components/device/device-card/ndm-security-box/security-box-update.vue b/src/components/device/device-card/ndm-security-box/security-box-update.vue index 21d4192..a3dceb2 100644 --- a/src/components/device/device-card/ndm-security-box/security-box-update.vue +++ b/src/components/device/device-card/ndm-security-box/security-box-update.vue @@ -54,6 +54,9 @@ const { mutateAsync: validateDeviceIdDuplicated } = useMutation({ const deviceIdPattern = /^\d{4}03\d{4}$/; if (!deviceIdPattern.test(deviceId)) throw new Error('设备ID不符合规范'); + // 如果没有修改设备ID,则不做ID唯一性校验 + if (deviceId === ndmDevice.value.deviceId) return; + validatorAbortController.value.abort(); validatorAbortController.value = new AbortController(); @@ -68,8 +71,7 @@ const { mutateAsync: validateDeviceIdDuplicated } = useMutation({ const { mutate: updateDevice, isPending } = useMutation({ mutationFn: async () => { await formInst.value?.validate().catch(() => { - window.$message.error('表单验证失败'); - return; + throw new Error('表单校验失败'); }); abortController.value.abort(); @@ -84,6 +86,7 @@ const { mutate: updateDevice, isPending } = useMutation({ onSuccess: (newDevice) => { localDevice.value = { ...newDevice }; deviceStore.patchDevice(station.value.code, { ...newDevice }); + window.$message.success('更新成功'); }, onError: (error) => { if (isCancel(error)) return; diff --git a/src/components/device/device-card/ndm-server/server-update.vue b/src/components/device/device-card/ndm-server/server-update.vue index ad1701b..3f7765b 100644 --- a/src/components/device/device-card/ndm-server/server-update.vue +++ b/src/components/device/device-card/ndm-server/server-update.vue @@ -66,6 +66,9 @@ const { mutateAsync: validateDeviceIdDuplicated } = useMutation({ const deviceIdPattern = /^\d{4}(09|11)\d{4}$/; if (!deviceIdPattern.test(deviceId)) throw new Error('设备ID不符合规范'); + // 如果没有修改设备ID,则不做ID唯一性校验 + if (deviceId === ndmDevice.value.deviceId) return; + validatorAbortController.value.abort(); validatorAbortController.value = new AbortController(); @@ -80,8 +83,7 @@ const { mutateAsync: validateDeviceIdDuplicated } = useMutation({ const { mutate: updateDevice, isPending } = useMutation({ mutationFn: async () => { await formInst.value?.validate().catch(() => { - window.$message.error('表单验证失败'); - return; + throw new Error('表单校验失败'); }); abortController.value.abort(); @@ -103,6 +105,7 @@ const { mutate: updateDevice, isPending } = useMutation({ onSuccess: (newDevice) => { localDevice.value = { ...newDevice }; deviceStore.patchDevice(station.value.code, { ...newDevice }); + window.$message.success('更新成功'); }, onError: (error) => { if (isCancel(error)) return; diff --git a/src/components/device/device-card/ndm-switch/switch-update.vue b/src/components/device/device-card/ndm-switch/switch-update.vue index 670efac..0006736 100644 --- a/src/components/device/device-card/ndm-switch/switch-update.vue +++ b/src/components/device/device-card/ndm-switch/switch-update.vue @@ -54,6 +54,9 @@ const { mutateAsync: validateDeviceIdDuplicated } = useMutation({ const deviceIdPattern = /^\d{4}04\d{4}$/; if (!deviceIdPattern.test(deviceId)) throw new Error('设备ID不符合规范'); + // 如果没有修改设备ID,则不做ID唯一性校验 + if (deviceId === ndmDevice.value.deviceId) return; + validatorAbortController.value.abort(); validatorAbortController.value = new AbortController(); @@ -68,8 +71,7 @@ const { mutateAsync: validateDeviceIdDuplicated } = useMutation({ const { mutate: updateDevice, isPending: loading } = useMutation({ mutationFn: async () => { await formInst.value?.validate().catch(() => { - window.$message.error('表单验证失败'); - return; + throw new Error('表单校验失败'); }); abortController.value.abort(); @@ -84,6 +86,7 @@ const { mutate: updateDevice, isPending: loading } = useMutation({ onSuccess: (newDevice) => { localDevice.value = { ...newDevice }; deviceStore.patchDevice(station.value.code, { ...newDevice }); + window.$message.success('更新成功'); }, onError: (error) => { if (isCancel(error)) return;