diff --git a/src/api/admin/i18n.ts b/src/api/admin/i18n.ts index 8277887a..de42bbe1 100644 --- a/src/api/admin/i18n.ts +++ b/src/api/admin/i18n.ts @@ -1,4 +1,5 @@ import request from '/@/utils/request'; +import { getObjDetails } from '/@/api/admin/param'; export function fetchList(query?: Object) { return request({ @@ -18,11 +19,19 @@ export function addObj(obj?: Object) { export function getObj(id?: string) { return request({ - url: '/admin/i18n/' + id, + url: '/admin/i18n/details/' + id, method: 'get', }); } +export function getObjDetails(obj?: object) { + return request({ + url: '/admin/i18n/details/', + method: 'get', + params: obj, + }); +} + export function delObj(ids?: object) { return request({ url: '/admin/i18n', @@ -50,5 +59,50 @@ export function refreshCache() { return request({ url: '/admin/i18n/sync', method: 'put', - }) + }); +} + +export function validateName(rule: any, value: any, callback: any, isEdit: boolean) { + if (isEdit) { + return callback(); + } + + getObjDetails({ name: value }).then((response) => { + const result = response.data; + if (result !== null) { + callback(new Error('国际化编码已经存在')); + } else { + callback(); + } + }); +} + +export function validateZhCn(rule: any, value: any, callback: any, isEdit: boolean) { + if (isEdit) { + return callback(); + } + + getObjDetails({ zhCn: value }).then((response) => { + const result = response.data; + if (result !== null) { + callback(new Error('国际化中文已经存在')); + } else { + callback(); + } + }); +} + +export function validateEn(rule: any, value: any, callback: any, isEdit: boolean) { + if (isEdit) { + return callback(); + } + + getObjDetails({ en: value }).then((response) => { + const result = response.data; + if (result !== null) { + callback(new Error('国际化英文已经存在')); + } else { + callback(); + } + }); } diff --git a/src/views/admin/i18n/form.vue b/src/views/admin/i18n/form.vue index b6bdbea8..c0a97b16 100644 --- a/src/views/admin/i18n/form.vue +++ b/src/views/admin/i18n/form.vue @@ -1,131 +1,149 @@ diff --git a/src/views/admin/i18n/index.vue b/src/views/admin/i18n/index.vue index 946cc049..3c4b12c2 100644 --- a/src/views/admin/i18n/index.vue +++ b/src/views/admin/i18n/index.vue @@ -1,174 +1,165 @@ diff --git a/src/views/admin/param/form.vue b/src/views/admin/param/form.vue index 9bb6cc3a..6e1ddde5 100644 --- a/src/views/admin/param/form.vue +++ b/src/views/admin/param/form.vue @@ -103,7 +103,7 @@ const dataRules = reactive({ ], publicKey: [ { required: true, message: '参数键不能为空', trigger: 'blur' }, - { validator: rule.validatorLowercase, trigger: 'blur' }, + { validator: rule.validatorCapital, trigger: 'blur' }, { validator: (rule: any, value: any, callback: any) => { validateParamsCode(rule, value, callback, form.publicId !== '');