44 <template #header >
55 <DrawerHeader :header =" $t('setting.systemIP')" :back =" handleClose" />
66 </template >
7- <el-form ref =" formRef" label-position =" top" :model =" form" @submit.prevent v-loading =" loading" >
7+ <el-form
8+ ref =" formRef"
9+ label-position =" top"
10+ :model =" form"
11+ :rules =" rules"
12+ @submit.prevent
13+ v-loading =" loading"
14+ >
815 <el-row type =" flex" justify =" center" >
916 <el-col :span =" 22" >
10- <el-form-item :label =" $t('setting.systemIP')" prop =" systemIP" :rules = " Rules.ipV4V6OrDomain " >
17+ <el-form-item :label =" $t('setting.systemIP')" prop =" systemIP" >
1118 <el-input clearable v-model =" form.systemIP" />
1219 <span class =" input-help" >{{ $t('commons.rule.hostHelper') }}</span >
1320 </el-form-item >
@@ -31,8 +38,8 @@ import i18n from '@/lang';
3138import { MsgSuccess } from ' @/utils/message' ;
3239import { updateSetting } from ' @/api/modules/setting' ;
3340import { FormInstance } from ' element-plus' ;
34- import { Rules } from ' @/global/form-rules' ;
3541import DrawerHeader from ' @/components/drawer-header/index.vue' ;
42+ import { checkDomain , checkIpV4V6 } from ' @/utils/util' ;
3643
3744const emit = defineEmits <{ (e : ' search' ): void }>();
3845
@@ -47,6 +54,18 @@ const form = reactive({
4754});
4855
4956const formRef = ref <FormInstance >();
57+ const rules = reactive ({
58+ systemIP: [{ validator: checkSystemIP , trigger: ' blur' }],
59+ });
60+
61+ function checkSystemIP(rule : any , value : any , callback : any ) {
62+ if (form .systemIP !== ' ' ) {
63+ if (checkIpV4V6 (form .systemIP ) && checkDomain (form .systemIP )) {
64+ return callback (new Error (i18n .global .t (' commons.rule.host' )));
65+ }
66+ }
67+ callback ();
68+ }
5069
5170const acceptParams = (params : DialogProps ): void => {
5271 form .systemIP = params .systemIP ;
0 commit comments