diff --git a/src/main.js b/src/main.js index cc8e483..9ae82f8 100644 --- a/src/main.js +++ b/src/main.js @@ -26,6 +26,7 @@ import { selectDictLabels, handleTree, indexContinuation, + desensitizeIdNumber, } from '@/utils/bonus' // 分页组件 import Pagination from '@/components/Pagination' @@ -58,7 +59,7 @@ Vue.prototype.selectDictLabels = selectDictLabels Vue.prototype.download = download Vue.prototype.handleTree = handleTree Vue.prototype.indexContinuation = indexContinuation - +Vue.prototype.desensitizeIdNumber = desensitizeIdNumber // 全局组件挂载 Vue.component('DictTag', DictTag) Vue.component('Pagination', Pagination) diff --git a/src/utils/bonus.js b/src/utils/bonus.js index f1fe388..7a07d92 100644 --- a/src/utils/bonus.js +++ b/src/utils/bonus.js @@ -259,3 +259,13 @@ export function blobValidate(data) { export function indexContinuation(num, size) { return (num - 1) * size + 1 } + +// 对身份证号码进行脱敏 +export function desensitizeIdNumber(idNumber) { + // 校验身份证格式(18位,前17位为数字,最后一位可为数字或Xx) + if (!/^\d{17}[\dXx]$/.test(idNumber)) { + return idNumber // 非有效格式返回原字符串 + } + // 保留前6位和最后4位(最后一位可为Xx),中间8位用*替换 + return idNumber.replace(/^(\d{6})\d{8}([\dXx]{4})$/, '$1********$2') +} diff --git a/src/views/construction-person/entry-and-exit-manage/person-entry/config.js b/src/views/construction-person/entry-and-exit-manage/person-entry/config.js index c63f209..2c71bee 100644 --- a/src/views/construction-person/entry-and-exit-manage/person-entry/config.js +++ b/src/views/construction-person/entry-and-exit-manage/person-entry/config.js @@ -73,7 +73,7 @@ export const formLabel = [ export const columnsList = [ { t_props: 'name', t_label: '姓名' }, - { t_props: 'idNumber', t_label: '身份证' }, + { t_label: '身份证', t_slot: 'idNumber' }, { t_props: 'phone', t_label: '联系方式' }, { t_props: 'postName', t_label: '工种' }, { diff --git a/src/views/construction-person/entry-and-exit-manage/person-entry/index.vue b/src/views/construction-person/entry-and-exit-manage/person-entry/index.vue index 2c96abb..18ba12a 100644 --- a/src/views/construction-person/entry-and-exit-manage/person-entry/index.vue +++ b/src/views/construction-person/entry-and-exit-manage/person-entry/index.vue @@ -9,6 +9,9 @@ :columnsList="columnsList" :request-api="getEntryPersonListAPI" > +