feat: 患者信息身份证改成非必填

This commit is contained in:
李琦
2026-08-08 18:36:38 +08:00
parent d4a5115a80
commit 53c6f3fcfd
5 changed files with 297 additions and 102 deletions

View File

@@ -337,6 +337,14 @@ function getRes(obj, isDecode = true) {
} else if (obj[key] !== null && typeof obj[key] === 'object') {
obj[key] = getRes(obj[key], isDecode)
} else if (arr.indexOf(key) !== -1) {
// 未填写的敏感字段保持空串,禁止加解密(避免空值被解成密文乱码)
if (obj[key] == null || obj[key] === '') {
obj[key] = ''
if (isDecode === true && (sensitiveData.indexOf(key) !== -1 || displayMaskFields.indexOf(key) !== -1)) {
obj[key + '_tm'] = ''
}
continue
}
let plainValue = ''
if (isDecode === true) {
plainValue = customBase64Decode(obj[key])
@@ -369,17 +377,22 @@ function getRes(obj, isDecode = true) {
}
function customBase64Decode(data) {
// 空值直接返回空串,避免 Base64.decode(null/'' ) 失败后回退成密文原串
if (data == null || data === '') {
return ''
}
// return data
try {
// 第一次Base64解码
const decodedFirst = Base64.decode(data)
// 截取从第30个字符开始往后的内容
const subStr = decodedFirst.slice(30)
// 第二次Base64解码
return Base64.decode(subStr) != '' ? Base64.decode(subStr) : data
// 第二次Base64解码;解出空串说明业务上就是未填写,不要回退成密文
const decodedSecond = Base64.decode(subStr)
return decodedSecond !== '' ? decodedSecond : ''
} catch (error) {
console.error(`解码Base64字符串【${data}】时发生错误`, error)
return data
return ''
}
}