update 校验重复接口调整
This commit is contained in:
+49
-2
@@ -343,9 +343,14 @@ export function jsExpand (options = {}) {
|
||||
* @param dataId 数据ID,可空
|
||||
* @param callback
|
||||
*/
|
||||
export function validateDuplicateValue (tableName, fieldName, fieldVal, dataId, callback) {
|
||||
export function validateDuplicateValue (isEncrypt, tableName, fieldName, fieldVal, dataId, callback) {
|
||||
if (fieldVal) {
|
||||
const params = { tableName, fieldName, fieldVal, dataId }
|
||||
const confusionCode = getConfusionCode(tableName, fieldName)
|
||||
const params = { confusionCode, fieldVal, dataId }
|
||||
// 是否数据库中存储的加密信息
|
||||
if (isEncrypt) {
|
||||
params.encrypt = 1
|
||||
}
|
||||
api.duplicateCheck(params).then(res => {
|
||||
res.success ? callback() : callback(res.message)
|
||||
}).catch(err => {
|
||||
@@ -622,3 +627,45 @@ export function urlToParams (url) {
|
||||
})
|
||||
return paramsObj
|
||||
}
|
||||
|
||||
/**
|
||||
* 重复校验:表名和字段名获取混淆code
|
||||
* @param tableName
|
||||
* @param fieldName
|
||||
* @return {string}
|
||||
*/
|
||||
export function getConfusionCode (tableName, fieldName) {
|
||||
// map对象对应数据库中 sys_confusion 表
|
||||
const map = {
|
||||
sys_user: {
|
||||
username: 'sys_username',
|
||||
phone: 'user_phone',
|
||||
email: 'user_email'
|
||||
},
|
||||
sys_role: {
|
||||
role_code: 'sys_rolecode'
|
||||
},
|
||||
sys_dict: {
|
||||
dict_code: 'sys_dictcode'
|
||||
},
|
||||
sys_depart: {
|
||||
depart_name: 'depart_name'
|
||||
},
|
||||
sys_check_rule: {
|
||||
rule_code: 'check_rule_code'
|
||||
},
|
||||
sys_data_source: {
|
||||
code: 'data_source_code'
|
||||
},
|
||||
sys_fill_rule: {
|
||||
rule_code: 'fill_rule_code'
|
||||
},
|
||||
sys_sms_template: {
|
||||
template_code: 'sms_template_code'
|
||||
}
|
||||
}
|
||||
if (map[tableName] && map[tableName][fieldName]) {
|
||||
return map[tableName][fieldName]
|
||||
}
|
||||
return ''
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user