Browse Source

增加应用名称唯一性校验规则

LT32820A 1 week ago
parent
commit
2dafbed7e4

+ 4 - 1
jeecgboot-vue3/src/views/appmanage/AppBaseInfo.api.ts

@@ -32,6 +32,7 @@ enum Api {
     isAppAdminOrDevOrOpe = '/sys/applicationInfo/isAppAdminOrDevOrOpe',
     isAppAdmin = '/sys/applicationInfo/isAppAdmin',
     checkMenuInfoisExist = '/sys/permission/checkPermDuplication',
+    checkAppNameisExist = '/sys/applicationInfo/appNameIsExist',
     workFlowTest1 = '/sys/applicationInfo/test1',
     workFlowTest2 = '/sys/applicationInfo/test2'
 }
@@ -45,7 +46,9 @@ export const JFlow_Test1=()=>{
 export const checkMenuInfoisExist=(params)=>{
     return defHttp.get({url: Api.checkMenuInfoisExist+"?url="+params+"&alwaysShow="+false},  { errorMessageMode: false, successMessageMode: false })
 }
-
+export const checkAppNameisExist=(params)=>{
+    return defHttp.get({url: Api.checkAppNameisExist+"?appName="+params},  { errorMessageMode: false, successMessageMode: false })
+}
 export const isAppAdmin=()=>{
   return defHttp.get({url: Api.isAppAdmin})
 }

+ 13 - 2
jeecgboot-vue3/src/views/appmanage/addForm/data.tsx

@@ -1,7 +1,7 @@
 import { FormSchema } from '/@/components/Form';
 import {ref} from "vue";
 import {ComponentTypes} from "@/views/system/menu/menu/menu.data";
-import {checkMenuInfoisExist} from "@/views/appmanage/AppBaseInfo.api";
+import {checkAppNameisExist, checkMenuInfoisExist} from "@/views/appmanage/AppBaseInfo.api";
 
 
 export const menuInfoisshow = ref(false)
@@ -29,7 +29,6 @@ const isValidIpAddress = (ip) => {
 };
 
 export const checkMenuInfo = async (_rule, value, callback) => {
-  console.log("菜单信息:"+value)
   const res = await checkMenuInfoisExist(value)
   if (res === '该值可用!') {
     callback(); // 校验通过
@@ -38,12 +37,24 @@ export const checkMenuInfo = async (_rule, value, callback) => {
   }
 };
 
+// 检查应用名字是否已经存在
+export const checkAppName = async (_rule, value, callback) => {
+  const res = await checkAppNameisExist(value)
+  if (res === '检查通过') {
+    callback(); // 校验通过
+  } else {
+    callback(new Error(res)); // 校验失败
+  }
+};
+
 export const step1Schemas: FormSchema[] = [
   {
     field: 'name',
     component: 'Input',
     label: '应用名称',
     required: true,
+    ifShow: ({ values }) => !(values.component === ComponentTypes.IFrame && values.internalOrExternal),
+    rules:[{ validator: checkAppName, trigger: 'blur'}],
     componentProps: {
       placeholder:"请输入应用名称"
     },