重复校验 每次都会触发,输入快了,前端就不会显示“该值不可用”(加防抖逻辑)
							parent
							
								
									55a09678cd
								
							
						
					
					
						commit
						26ab89b700
					
				|  | @ -1,5 +1,5 @@ | |||
| import { dateUtil } from '/@/utils/dateUtil'; | ||||
| import { duplicateCheck } from '/@/views/system/user/user.api'; | ||||
| import { duplicateCheckDelay } from '/@/views/system/user/user.api'; | ||||
| 
 | ||||
| export const rules = { | ||||
|   rule(type, required) { | ||||
|  | @ -107,7 +107,7 @@ export const rules = { | |||
|             return Promise.reject(`请输入${schema.label}`); | ||||
|           } | ||||
|           return new Promise<void>((resolve, reject) => { | ||||
|             duplicateCheck({ | ||||
|             duplicateCheckDelay({ | ||||
|               tableName, | ||||
|               fieldName, | ||||
|               fieldVal: value, | ||||
|  |  | |||
|  | @ -1,6 +1,6 @@ | |||
| import { BasicColumn, FormSchema } from '/@/components/Table'; | ||||
| import { render } from '/@/utils/common/renderUtils'; | ||||
| import { duplicateCheck } from '/@/views/system/user/user.api'; | ||||
| import { duplicateCheckDelay } from '/@/views/system/user/user.api'; | ||||
| import { validateCheckRule } from '/@/views/system/checkRule/check.rule.api'; | ||||
| import { array } from 'vue-types'; | ||||
| 
 | ||||
|  | @ -80,7 +80,7 @@ export const formSchema: FormSchema[] = [ | |||
|                 fieldVal: value, | ||||
|                 dataId: model.id, | ||||
|               }; | ||||
|               duplicateCheck(params) | ||||
|               duplicateCheckDelay(params) | ||||
|                 .then((res) => { | ||||
|                   res.success ? resolve() : reject('规则编码已存在!'); | ||||
|                 }) | ||||
|  |  | |||
|  | @ -1,5 +1,5 @@ | |||
| import { Ref } from 'vue'; | ||||
| import { duplicateCheck } from '/@/views/system/user/user.api'; | ||||
| import { duplicateCheckDelay } from '/@/views/system/user/user.api'; | ||||
| import { BasicColumn, FormSchema } from '/@/components/Table'; | ||||
| import { DescItem } from '/@/components/Description'; | ||||
| import { findTree } from '/@/utils/common/compUtils'; | ||||
|  | @ -115,7 +115,7 @@ export const departRoleModalFormSchema: FormSchema[] = [ | |||
|                 fieldVal: value, | ||||
|                 dataId: model.id, | ||||
|               }; | ||||
|               duplicateCheck(params) | ||||
|               duplicateCheckDelay(params) | ||||
|                 .then((res) => { | ||||
|                   res.success ? resolve() : reject(res.message || '校验失败'); | ||||
|                 }) | ||||
|  |  | |||
|  | @ -1,5 +1,5 @@ | |||
| import { BasicColumn, FormSchema } from '/@/components/Table'; | ||||
| import { duplicateCheck } from '/@/views/system/user/user.api'; | ||||
| import { duplicateCheckDelay } from '/@/views/system/user/user.api'; | ||||
| 
 | ||||
| export const columns: BasicColumn[] = [ | ||||
|   { | ||||
|  | @ -80,7 +80,7 @@ export const formSchema: FormSchema[] = [ | |||
|                 fieldVal: value, | ||||
|                 dataId: model.id, | ||||
|               }; | ||||
|               duplicateCheck(params) | ||||
|               duplicateCheckDelay(params) | ||||
|                 .then((res) => { | ||||
|                   res.success ? resolve() : reject('规则编码已存在!'); | ||||
|                 }) | ||||
|  |  | |||
|  | @ -82,7 +82,24 @@ export const saveOrUpdateRole = (params, isUpdate) => { | |||
|  * 编码校验 | ||||
|  * @param params | ||||
|  */ | ||||
| export const isRoleExist = (params) => defHttp.get({ url: Api.isRoleExist, params }, { isTransformResponse: false }); | ||||
| // update-begin--author:liaozhiyang---date:20231215---for:【QQYUN-7415】表单调用接口进行校验的添加防抖
 | ||||
| let timer; | ||||
| export const isRoleExist = (params) => { | ||||
|   return new Promise((resolve, rejected) => { | ||||
|     clearTimeout(timer); | ||||
|     timer = setTimeout(() => { | ||||
|       defHttp | ||||
|         .get({ url: Api.isRoleExist, params }, { isTransformResponse: false }) | ||||
|         .then((res) => { | ||||
|           resolve(res); | ||||
|         }) | ||||
|         .catch((error) => { | ||||
|           rejected(error); | ||||
|         }); | ||||
|     }, 500); | ||||
|   }); | ||||
| }; | ||||
| // update-end--author:liaozhiyang---date:20231215---for:【QQYUN-7415】表单调用接口进行校验的添加防抖
 | ||||
| /** | ||||
|  * 根据角色查询树信息 | ||||
|  */ | ||||
|  |  | |||
|  | @ -96,6 +96,29 @@ export const saveOrUpdateUser = (params, isUpdate) => { | |||
|  * @param params | ||||
|  */ | ||||
| export const duplicateCheck = (params) => defHttp.get({ url: Api.duplicateCheck, params }, { isTransformResponse: false }); | ||||
| 
 | ||||
| /** | ||||
|  * 20231215 | ||||
|  * liaozhiyang | ||||
|  * 唯一校验( 延迟【防抖】) | ||||
|  * @param params | ||||
|  */ | ||||
| let timer; | ||||
| export const duplicateCheckDelay = (params) => { | ||||
|   return new Promise((resove, rejected) => { | ||||
|     clearTimeout(timer); | ||||
|     timer = setTimeout(() => { | ||||
|       defHttp | ||||
|         .get({ url: Api.duplicateCheck, params }, { isTransformResponse: false }) | ||||
|         .then((res: any) => { | ||||
|           resove(res as any); | ||||
|         }) | ||||
|         .catch((error) => { | ||||
|           rejected(error); | ||||
|         }); | ||||
|     }, 500); | ||||
|   }); | ||||
| }; | ||||
| /** | ||||
|  * 获取全部角色(租户隔离) | ||||
|  * @param params | ||||
|  |  | |||
		Loading…
	
		Reference in New Issue
	
	 zhangdaiscott
						zhangdaiscott