From 479bcb4c870f92285b3fa5fe3ac242214905e0e6 Mon Sep 17 00:00:00 2001 From: chenjinsong <523037378@qq.com> Date: Fri, 5 Nov 2021 20:19:26 +0800 Subject: [PATCH] =?UTF-8?q?NEZ-1174=20fix:=20=E5=9C=B0=E5=9B=BE=E9=97=AE?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/components/common/js/validate.js | 15 ++++ .../src/components/common/latlngPicker.vue | 65 ++++++++------- .../src/components/common/rightBox/dcBox.vue | 80 +++++++++---------- .../src/components/page/config/dc.vue | 11 ++- .../src/components/page/config/system.vue | 63 ++++++--------- 5 files changed, 118 insertions(+), 116 deletions(-) diff --git a/nezha-fronted/src/components/common/js/validate.js b/nezha-fronted/src/components/common/js/validate.js index c58066919..4433fd9f6 100644 --- a/nezha-fronted/src/components/common/js/validate.js +++ b/nezha-fronted/src/components/common/js/validate.js @@ -86,6 +86,21 @@ export function noSpecialChar (rule, value, callback) { }, 100) } +export function latlng (rule, value, callback) { + const lngReg = /^[\-\+]?(0?\d{1,2}\.\d{1,7}|1[0-7]?\d{1}\.\d{1,7}|180\.0{1,7})$/ + const latReg = /^[\-\+]?([1-8]?\d{1}\.\d{1,7}|90\.0{1,7})$/ + setTimeout(() => { + const lnglat = value.split(',') + if (!lnglat || lnglat.length !== 2) { + callback(new Error(vm.$t('tip.lnglatError'))) + } else if (!lngReg.test(lnglat[0]) || !latReg.test(lnglat[1])) { + callback(new Error(vm.$t('tip.lnglatError'))) + } else { + callback() + } + }, 100) +} + export function integer (rule, value, callback) { setTimeout(() => { if (isNaN(Number(value))) { diff --git a/nezha-fronted/src/components/common/latlngPicker.vue b/nezha-fronted/src/components/common/latlngPicker.vue index 94c721d8e..8f188d9f5 100644 --- a/nezha-fronted/src/components/common/latlngPicker.vue +++ b/nezha-fronted/src/components/common/latlngPicker.vue @@ -1,14 +1,14 @@