common.js工具类
export function desensitization(str,begin,end) {
if (!str && (begin + end) >= str.length) {
return "";
}
let leftStr = str.substring(0, begin);
let rightStr = str.substring(end);
let midStr = str.substring(begin,end);
let strCon = "";
for (let i = 0; i < midStr.length; i++) {
strCon += "*";
}
retu
export function equals(str, that) {
return str == that;
}
使用
<el-table-column label="租户手机号" align="center" key="tenantPhone" prop="tenantPhone" :show-overflow-tooltip="true">
<template scope="scope">
<span>{{ phoneFormatter(scope.row.tenantPhone) }}</span>
</template>
</el-table-column>
/** 手机号脱敏 */
phoneFormatter(phone){
if(!equals(phone,undefined)){
return desensitization(phone,3,7);
}
},
/** 身份证号脱敏 */
cardFormatter(card){
if(!equals(card,undefined)){
return desensitization(card,6,14);
}
},