/* * @Author: your name * @Date: 2021-04-26 09:05:35 * @LastEditTime: 2021-04-26 10:39:08 * @LastEditors: Please set LastEditors * @Description: In User Settings Edit * @FilePath: \exclusive-cloud-admin\common\src\assets\filters\user.filter.ts */ /** * 用户类型 * value {String}用户类型 -- customer:客户|admin:管理员 */ function userType(value: any) { switch (value) { case "customer":{ return '客户' break; } case "admin":{ return '管理员' break; } } } /** * 用户操作类型 * @param value {String}操作类型编号 * @returns 编号对应业务类型 */ function optLogType(value: any) { let type = value; if (value) { switch (value.toString()) { case '1': type = '云主机'; break; case '2': type = '云磁盘'; break; case '3': type = '云IP'; break; case '4': type = '云快照'; break; case '5': type = '账号管理'; break; case '6': type = '财务管理'; break; case '7': type = 'NAT网关'; break; case '8': type = 'VPC路由'; break; case '9': type = 'VPC虚拟私有云'; break; case '10': type = '虚拟交换机'; break; case '11': type = '独立带宽包'; break; case '12': type = '共享带宽包'; break; case '13': type = 'VPC带宽'; break; case '14': type = '镜像'; break; case '15': type = '安全组'; break; case '16': type = '负载均衡'; break; case '17': type = 'RDS云数据库'; break; case '18': type = '弹性网卡'; break; case '19': type = '平台管理'; break; case '20': type = '客户管理'; break; case '21': type = '市场活动'; break; case '22': type = '合同业务'; break; case '': type = '全部'; break; } } return type; } /** * 消息类型 * @param value */ function messageType(value: any){ let obj: any = { destroy: "销毁提醒", expire: "到期提醒", opt: "操作提醒", finance: "财务消息", security: "安全消息", checkRdsStorage: "存储提醒", } return obj[value] } function messageSetType(value: any, type: any = 'label'){ let obj: any = { MESSAGE_CONFIG_DESTROY: {label: '销毁提醒', id: 'destroy'}, MESSAGE_CONFIG_EXPIRE: {label: '到期提醒', id: 'expire'}, MESSAGE_CONFIG_BALANCE_LESS: {label: "余额不足", id: 'balanceLess'}, MESSAGE_CONFIG_MONEY: {label: '余额预警', id: 'money'}, MESSAGE_CONFIG_RDS_STORAGE: {label: 'RDS存储容量提醒', id: 'rdsStorage'}, } return obj[value][type] } function desensitization(value: any, type: any){ let newVal; switch (type) { case 'set': if (!value) { newVal = '-'; } else if (value.length > 12) { newVal = value.substr(0, 5) + '***' + value.substr(value.length - 6, 6); } else if (value.length > 5) { newVal = value.substr(0, 2) + '***' + value.substr(value.length - 3, 3); } else if (value.length > 3) { newVal = value.substr(0, 1) + '***' + value.substr(value.length - 1, 1); } else { newVal = value.substr(0, 1) + '***'; } break; case 'name': if (!value) { newVal = '-'; } else if (value.length > 2) { newVal = value.substr(0, 1) + '*' + value.substr(value.length - 1, 1); } else { newVal = value.substr(0, 1) + '*'; } break; default: if(value === 'admin'){ newVal = value } else if (!value) { newVal = '-'; } else if (value.length > 5) { newVal = value.substr(0, 2) + '***' + value.substr(value.length - 3, 3); } else if (value.length > 3) { newVal = value.substr(0, 1) + '***' + value.substr(value.length - 1, 1); } else { newVal = value.substr(0, 1) + '***'; } break; } return newVal; } export default { userType, optLogType, messageType, messageSetType, desensitization, }