fix: 修复授权配置复制功能,无法复制已加密字段的问题

v2-dev
xiaojunnuo 2025-08-09 18:11:20 +08:00
parent 1bdceeecf4
commit 221e068bac
2 changed files with 26 additions and 1 deletions

View File

@ -34,7 +34,18 @@ export class AccessService extends BaseService<AccessEntity> {
}
async add(param) {
this.encryptSetting(param, null);
let oldEntity = null;
if (param._copyFrom){
oldEntity = await this.info(param._copyFrom);
if (oldEntity == null) {
throw new ValidateException('该授权配置不存在,请确认是否已被删除');
}
if (oldEntity.userId !== param.userId) {
throw new ValidateException('您无权查看该授权配置');
}
}
delete param._copyFrom
this.encryptSetting(param, oldEntity);
return await super.add(param);
}

View File

@ -44,6 +44,20 @@ export default function ({ crudExpose, context }: CreateCrudOptionsProps): Creat
},
rowHandle: {
width: 200,
buttons: {
copy: {
async click(ctx: any) {
const { row, index } = ctx;
await crudExpose.openCopy({
row: {
...row,
_copyFrom: row.id,
},
index: index,
});
},
},
},
},
columns: {
id: {