diff --git a/mock/demo/system.ts b/mock/demo/system.ts index 9cde354c9c5..e24f50cb28f 100644 --- a/mock/demo/system.ts +++ b/mock/demo/system.ts @@ -1,5 +1,5 @@ import { MockMethod } from 'vite-plugin-mock'; -import { resultPageSuccess, resultSuccess } from '../_util'; +import { resultError, resultPageSuccess, resultSuccess } from '../_util'; const accountList = (() => { const result: any[] = []; @@ -185,4 +185,17 @@ export default [ return resultSuccess(menuList); }, }, + { + url: '/basic-api/system/accountExist', + timeout: 500, + method: 'post', + response: ({ body }) => { + const { account } = body || {}; + if (account && account.indexOf('admin') !== -1) { + return resultError('该字段不能包含admin'); + } else { + return resultSuccess(`${account} can use`); + } + }, + }, ] as MockMethod[]; diff --git a/src/api/demo/system.ts b/src/api/demo/system.ts index 69f1ac09b31..f5c296b5da7 100644 --- a/src/api/demo/system.ts +++ b/src/api/demo/system.ts @@ -14,6 +14,7 @@ import { defHttp } from '/@/utils/http/axios'; enum Api { AccountList = '/system/getAccountList', + IsAccountExist = '/system/accountExist', DeptList = '/system/getDeptList', setRoleStatus = '/system/setRoleStatus', MenuList = '/system/getMenuList', @@ -38,3 +39,6 @@ export const getAllRoleList = (params?: RoleParams) => export const setRoleStatus = (id: number, status: string) => defHttp.post({ url: Api.setRoleStatus, params: { id, status } }); + +export const isAccountExist = (account: string) => + defHttp.post({ url: Api.IsAccountExist, params: { account } }, { errorMessageMode: 'none' }); diff --git a/src/views/demo/form/RuleForm.vue b/src/views/demo/form/RuleForm.vue index 6af3232c768..8124dae7539 100644 --- a/src/views/demo/form/RuleForm.vue +++ b/src/views/demo/form/RuleForm.vue @@ -15,9 +15,10 @@