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;