fix:校验客户名称是否唯一
This commit is contained in:
@@ -53,12 +53,12 @@ export function exportCustomer(params: any) {
|
|||||||
return requestClient.download('/license/customer/export-excel', params);
|
return requestClient.download('/license/customer/export-excel', params);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** 客户名称是否存在 */
|
/** 客户名称是否唯一 */
|
||||||
async function isCustomerNameExists(
|
async function isCustomerNameUnique(
|
||||||
name: string,
|
name: string,
|
||||||
id?: CustomerApi.Customer['id'],
|
id?: CustomerApi.Customer['id'],
|
||||||
) {
|
) {
|
||||||
return requestClient.get<boolean>('/license/customer/name-exists', {
|
return requestClient.get<boolean>('/license/customer/name-unique', {
|
||||||
params: { id, name },
|
params: { id, name },
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -68,4 +68,4 @@ async function getMaxSn() {
|
|||||||
return requestClient.get<boolean>('/license/customer/max-sn');
|
return requestClient.get<boolean>('/license/customer/max-sn');
|
||||||
}
|
}
|
||||||
|
|
||||||
export { getMaxSn, isCustomerNameExists };
|
export { getMaxSn, isCustomerNameUnique };
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ import { ref } from 'vue';
|
|||||||
import { useAccess } from '@vben/access';
|
import { useAccess } from '@vben/access';
|
||||||
|
|
||||||
import { z } from '#/adapter/form';
|
import { z } from '#/adapter/form';
|
||||||
import { isCustomerNameExists } from '#/api/license/customer';
|
import { isCustomerNameUnique } from '#/api/license/customer';
|
||||||
import { getAreaTree } from '#/api/system/area';
|
import { getAreaTree } from '#/api/system/area';
|
||||||
import { $t } from '#/locales';
|
import { $t } from '#/locales';
|
||||||
import { DICT_TYPE, getDictOptions, getRangePickerDefaultProps } from '#/utils';
|
import { DICT_TYPE, getDictOptions, getRangePickerDefaultProps } from '#/utils';
|
||||||
@@ -39,7 +39,7 @@ export function useFormSchema(): VbenFormSchema[] {
|
|||||||
)
|
)
|
||||||
.refine(
|
.refine(
|
||||||
async (value: string) => {
|
async (value: string) => {
|
||||||
return !(await isCustomerNameExists(value, formData.value?.id));
|
return await isCustomerNameUnique(value, formData.value?.id);
|
||||||
},
|
},
|
||||||
(value) => ({
|
(value) => ({
|
||||||
message: $t('ui.formRules.alreadyExists', [
|
message: $t('ui.formRules.alreadyExists', [
|
||||||
|
|||||||
Reference in New Issue
Block a user