😎代码调整优化
This commit is contained in:
parent
653c2703c2
commit
f69c66867b
@ -12,19 +12,13 @@ namespace Admin.NET.Core;
|
|||||||
[SugarTable(null, "系统差异日志表")]
|
[SugarTable(null, "系统差异日志表")]
|
||||||
[SysTable]
|
[SysTable]
|
||||||
[LogTable]
|
[LogTable]
|
||||||
public partial class SysLogDiff : EntityBase
|
public partial class SysLogDiff : EntityTenant
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 操作前记录
|
/// 差异数据
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[SugarColumn(ColumnDescription = "操作前记录", ColumnDataType = StaticConfig.CodeFirst_BigString)]
|
[SugarColumn(ColumnDescription = "差异数据", ColumnDataType = StaticConfig.CodeFirst_BigString)]
|
||||||
public string? BeforeData { get; set; }
|
public string? DiffData { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 操作后记录
|
|
||||||
/// </summary>
|
|
||||||
[SugarColumn(ColumnDescription = "操作后记录", ColumnDataType = StaticConfig.CodeFirst_BigString)]
|
|
||||||
public string? AfterData { get; set; }
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Sql
|
/// Sql
|
||||||
|
|||||||
@ -216,6 +216,7 @@ public class SysLdapService : IDynamicApiController, ITransient
|
|||||||
{
|
{
|
||||||
var sysUserLdap = CreateSysUserLdap(attrs, sysLdap.BindAttrAccount, sysLdap.BindAttrEmployeeId, deptCode);
|
var sysUserLdap = CreateSysUserLdap(attrs, sysLdap.BindAttrAccount, sysLdap.BindAttrEmployeeId, deptCode);
|
||||||
sysUserLdap.Dn = ldapEntry.Dn;
|
sysUserLdap.Dn = ldapEntry.Dn;
|
||||||
|
sysUserLdap.TenantId = sysLdap.TenantId;
|
||||||
userLdapList.Add(sysUserLdap);
|
userLdapList.Add(sysUserLdap);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -313,6 +314,7 @@ public class SysLdapService : IDynamicApiController, ITransient
|
|||||||
{
|
{
|
||||||
var sysUserLdap = CreateSysUserLdap(attrs, sysLdap.BindAttrAccount, sysLdap.BindAttrEmployeeId, deptCode);
|
var sysUserLdap = CreateSysUserLdap(attrs, sysLdap.BindAttrAccount, sysLdap.BindAttrEmployeeId, deptCode);
|
||||||
sysUserLdap.Dn = ldapEntry.Dn;
|
sysUserLdap.Dn = ldapEntry.Dn;
|
||||||
|
sysUserLdap.TenantId = sysLdap.TenantId;
|
||||||
if (string.IsNullOrEmpty(sysUserLdap.EmployeeId)) continue;
|
if (string.IsNullOrEmpty(sysUserLdap.EmployeeId)) continue;
|
||||||
userLdapList.Add(sysUserLdap);
|
userLdapList.Add(sysUserLdap);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -326,7 +326,8 @@ public class SysConfigService : IDynamicApiController, ITransient
|
|||||||
var ext = string.IsNullOrWhiteSpace(input.SysLogoFileName) ? ".png" : Path.GetExtension(input.SysLogoFileName);
|
var ext = string.IsNullOrWhiteSpace(input.SysLogoFileName) ? ".png" : Path.GetExtension(input.SysLogoFileName);
|
||||||
// 本地图标保存路径
|
// 本地图标保存路径
|
||||||
var path = "upload";
|
var path = "upload";
|
||||||
var absoluteFilePath = Path.Combine(App.WebHostEnvironment.WebRootPath, path, $"logo{ext}");
|
var fileName = $"{input.SysTitle}-logo{ext}".ToLower();
|
||||||
|
var absoluteFilePath = Path.Combine(App.WebHostEnvironment.WebRootPath, path, fileName);
|
||||||
|
|
||||||
// 删除已存在文件
|
// 删除已存在文件
|
||||||
if (File.Exists(oldSysLogoAbsoluteFilePath))
|
if (File.Exists(oldSysLogoAbsoluteFilePath))
|
||||||
@ -341,7 +342,7 @@ public class SysConfigService : IDynamicApiController, ITransient
|
|||||||
await File.WriteAllBytesAsync(absoluteFilePath, binData);
|
await File.WriteAllBytesAsync(absoluteFilePath, binData);
|
||||||
|
|
||||||
// 保存图标配置
|
// 保存图标配置
|
||||||
var relativeUrl = $"/{path}/logo{ext}";
|
var relativeUrl = $"/{path}/{fileName}";
|
||||||
await UpdateConfigValue(ConfigConst.SysWebLogo, relativeUrl);
|
await UpdateConfigValue(ConfigConst.SysWebLogo, relativeUrl);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -244,7 +244,7 @@ public class SysFileService : IDynamicApiController, ITransient
|
|||||||
var isExist = await _sysFileRep.IsAnyAsync(u => u.Id == input.Id);
|
var isExist = await _sysFileRep.IsAnyAsync(u => u.Id == input.Id);
|
||||||
if (!isExist) throw Oops.Oh(ErrorCodeEnum.D8000);
|
if (!isExist) throw Oops.Oh(ErrorCodeEnum.D8000);
|
||||||
|
|
||||||
await _sysFileRep.UpdateAsync(u => input.Adapt<SysFile>(), u => u.Id == input.Id);
|
await _sysFileRep.UpdateAsync(input);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|||||||
@ -16,18 +16,21 @@ public class SysMenuService : IDynamicApiController, ITransient
|
|||||||
private readonly SqlSugarRepository<SysMenu> _sysMenuRep;
|
private readonly SqlSugarRepository<SysMenu> _sysMenuRep;
|
||||||
private readonly SysRoleMenuService _sysRoleMenuService;
|
private readonly SysRoleMenuService _sysRoleMenuService;
|
||||||
private readonly SysUserRoleService _sysUserRoleService;
|
private readonly SysUserRoleService _sysUserRoleService;
|
||||||
|
private readonly SysUserMenuService _sysUserMenuService;
|
||||||
private readonly SysCacheService _sysCacheService;
|
private readonly SysCacheService _sysCacheService;
|
||||||
|
|
||||||
public SysMenuService(UserManager userManager,
|
public SysMenuService(UserManager userManager,
|
||||||
SqlSugarRepository<SysMenu> sysMenuRep,
|
SqlSugarRepository<SysMenu> sysMenuRep,
|
||||||
SysRoleMenuService sysRoleMenuService,
|
SysRoleMenuService sysRoleMenuService,
|
||||||
SysUserRoleService sysUserRoleService,
|
SysUserRoleService sysUserRoleService,
|
||||||
|
SysUserMenuService sysUserMenuService,
|
||||||
SysCacheService sysCacheService)
|
SysCacheService sysCacheService)
|
||||||
{
|
{
|
||||||
_userManager = userManager;
|
_userManager = userManager;
|
||||||
_sysMenuRep = sysMenuRep;
|
_sysMenuRep = sysMenuRep;
|
||||||
_sysRoleMenuService = sysRoleMenuService;
|
_sysRoleMenuService = sysRoleMenuService;
|
||||||
_sysUserRoleService = sysUserRoleService;
|
_sysUserRoleService = sysUserRoleService;
|
||||||
|
_sysUserMenuService = sysUserMenuService;
|
||||||
_sysCacheService = sysCacheService;
|
_sysCacheService = sysCacheService;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -173,6 +176,9 @@ public class SysMenuService : IDynamicApiController, ITransient
|
|||||||
|
|
||||||
// 级联删除角色菜单数据
|
// 级联删除角色菜单数据
|
||||||
await _sysRoleMenuService.DeleteRoleMenuByMenuIdList(menuIdList);
|
await _sysRoleMenuService.DeleteRoleMenuByMenuIdList(menuIdList);
|
||||||
|
|
||||||
|
// 级联删除用户收藏菜单
|
||||||
|
await _sysUserMenuService.DeleteMenuList(menuIdList);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|||||||
@ -33,7 +33,7 @@ public class SysUserLdapService : ITransient
|
|||||||
await _sysUserLdapRep.AsUpdateable()
|
await _sysUserLdapRep.AsUpdateable()
|
||||||
.InnerJoin<SysUser>((l, u) => l.EmployeeId == u.Account)
|
.InnerJoin<SysUser>((l, u) => l.EmployeeId == u.Account)
|
||||||
.SetColumns((l, u) => new SysUserLdap { UserId = u.Id })
|
.SetColumns((l, u) => new SysUserLdap { UserId = u.Id })
|
||||||
.Where((l, u) => l.TenantId == tenantId && u.Status == StatusEnum.Enable && u.IsDelete == false && l.IsDelete == false)
|
.Where((l, u) => l.TenantId == tenantId && u.Status == StatusEnum.Enable && u.IsDelete == false)
|
||||||
.ExecuteCommandAsync();
|
.ExecuteCommandAsync();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -47,7 +47,7 @@ public class SysUserLdapService : ITransient
|
|||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public async Task AddUserLdap(long tenantId, long userId, string account, string domainAccount)
|
public async Task AddUserLdap(long tenantId, long userId, string account, string domainAccount)
|
||||||
{
|
{
|
||||||
var userLdap = await _sysUserLdapRep.GetFirstAsync(u => u.TenantId == tenantId && u.IsDelete == false && (u.Account == account || u.UserId == userId || u.EmployeeId == domainAccount));
|
var userLdap = await _sysUserLdapRep.GetFirstAsync(u => u.TenantId == tenantId && (u.Account == account || u.UserId == userId || u.EmployeeId == domainAccount));
|
||||||
if (userLdap != null) await _sysUserLdapRep.DeleteByIdAsync(userLdap.Id);
|
if (userLdap != null) await _sysUserLdapRep.DeleteByIdAsync(userLdap.Id);
|
||||||
|
|
||||||
if (!string.IsNullOrWhiteSpace(domainAccount))
|
if (!string.IsNullOrWhiteSpace(domainAccount))
|
||||||
|
|||||||
@ -277,33 +277,43 @@ public static class SqlSugarSetup
|
|||||||
|
|
||||||
db.Aop.OnDiffLogEvent = async u =>
|
db.Aop.OnDiffLogEvent = async u =>
|
||||||
{
|
{
|
||||||
// 移除相同字段
|
// 记录差异数据
|
||||||
|
var diffData = new List<dynamic>();
|
||||||
for (int i = 0; i < u.AfterData.Count; i++)
|
for (int i = 0; i < u.AfterData.Count; i++)
|
||||||
{
|
{
|
||||||
|
var diffColumns = new List<dynamic>();
|
||||||
var afterColumns = u.AfterData[i].Columns;
|
var afterColumns = u.AfterData[i].Columns;
|
||||||
var beforeColumns = u.BeforeData[i].Columns;
|
var beforeColumns = u.BeforeData[i].Columns;
|
||||||
for (int j = 0; j < afterColumns.Count; j++)
|
for (int j = 0; j < afterColumns.Count; j++)
|
||||||
{
|
{
|
||||||
if (!afterColumns[j].Value.Equals(beforeColumns[j].Value)) continue;
|
if (afterColumns[j].Value.Equals(beforeColumns[j].Value)) continue;
|
||||||
|
diffColumns.Add(new
|
||||||
beforeColumns.Remove(beforeColumns[j]);
|
{
|
||||||
afterColumns.Remove(afterColumns[j]);
|
afterColumns[j].IsPrimaryKey,
|
||||||
j--;
|
afterColumns[j].ColumnName,
|
||||||
|
afterColumns[j].ColumnDescription,
|
||||||
|
BeforeValue = beforeColumns[j].Value,
|
||||||
|
AfterValue = afterColumns[j].Value,
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
diffData.Add(new
|
||||||
|
{
|
||||||
|
u.AfterData[i].TableName,
|
||||||
|
u.AfterData[i].TableDescription,
|
||||||
|
Columns = diffColumns
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
var logDiff = new SysLogDiff
|
var logDiff = new SysLogDiff
|
||||||
{
|
{
|
||||||
// 操作后记录(字段描述、列名、值、表名、表描述)
|
// 差异数据(字段描述、列名、值、表名、表描述)
|
||||||
AfterData = JSON.Serialize(u.AfterData),
|
DiffData = JSON.Serialize(diffData),
|
||||||
// 操作前记录(字段描述、列名、值、表名、表描述)
|
|
||||||
BeforeData = JSON.Serialize(u.BeforeData),
|
|
||||||
// 传进来的对象(如果对象为空,则使用首个数据的表名作为业务对象)
|
// 传进来的对象(如果对象为空,则使用首个数据的表名作为业务对象)
|
||||||
BusinessData = u.BusinessData == null ? u.AfterData.FirstOrDefault()?.TableName : JSON.Serialize(u.BusinessData),
|
BusinessData = u.BusinessData == null ? u.AfterData.FirstOrDefault()?.TableName : JSON.Serialize(u.BusinessData),
|
||||||
// 枚举(insert、update、delete)
|
// 枚举(insert、update、delete)
|
||||||
DiffType = u.DiffType.ToString(),
|
DiffType = u.DiffType.ToString(),
|
||||||
Sql = UtilMethods.GetNativeSql(u.Sql, u.Parameters),
|
Sql = u.Sql,
|
||||||
Parameters = JSON.Serialize(u.Parameters),
|
Parameters = JSON.Serialize(u.Parameters.Select(e => new { e.ParameterName, e.Value, TypeName = e.DbType.ToString() })),
|
||||||
Elapsed = u.Time == null ? 0 : (long)u.Time.Value.TotalMilliseconds
|
Elapsed = u.Time == null ? 0 : (long)u.Time.Value.TotalMilliseconds
|
||||||
};
|
};
|
||||||
var logDb = ITenant.IsAnyConnection(SqlSugarConst.LogConfigId) ? ITenant.GetConnectionScope(SqlSugarConst.LogConfigId) : ITenant.GetConnectionScope(SqlSugarConst.MainConfigId);
|
var logDb = ITenant.IsAnyConnection(SqlSugarConst.LogConfigId) ? ITenant.GetConnectionScope(SqlSugarConst.LogConfigId) : ITenant.GetConnectionScope(SqlSugarConst.MainConfigId);
|
||||||
|
|||||||
@ -2,7 +2,7 @@
|
|||||||
"name": "admin.net.pro",
|
"name": "admin.net.pro",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"version": "2.4.33",
|
"version": "2.4.33",
|
||||||
"lastBuildTime": "2024.11.26",
|
"lastBuildTime": "2024.11.30",
|
||||||
"description": "Admin.NET 站在巨人肩膀上的 .NET 通用权限开发框架",
|
"description": "Admin.NET 站在巨人肩膀上的 .NET 通用权限开发框架",
|
||||||
"author": "zuohuaijun",
|
"author": "zuohuaijun",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
@ -18,13 +18,13 @@
|
|||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@element-plus/icons-vue": "^2.3.1",
|
"@element-plus/icons-vue": "^2.3.1",
|
||||||
"@logicflow/core": "^2.0.7",
|
"@logicflow/core": "^2.0.9",
|
||||||
"@logicflow/extension": "^2.0.11",
|
"@logicflow/extension": "^2.0.13",
|
||||||
"@microsoft/signalr": "^8.0.7",
|
"@microsoft/signalr": "^8.0.7",
|
||||||
"@vue-office/docx": "^1.6.2",
|
"@vue-office/docx": "^1.6.2",
|
||||||
"@vue-office/excel": "^1.7.11",
|
"@vue-office/excel": "^1.7.11",
|
||||||
"@vue-office/pdf": "^2.0.9",
|
"@vue-office/pdf": "^2.0.9",
|
||||||
"@vueuse/core": "^11.3.0",
|
"@vueuse/core": "^12.0.0",
|
||||||
"@wangeditor/editor": "^5.1.23",
|
"@wangeditor/editor": "^5.1.23",
|
||||||
"@wangeditor/editor-for-vue": "^5.1.12",
|
"@wangeditor/editor-for-vue": "^5.1.12",
|
||||||
"animate.css": "^4.1.1",
|
"animate.css": "^4.1.1",
|
||||||
@ -36,7 +36,7 @@
|
|||||||
"echarts": "^5.5.1",
|
"echarts": "^5.5.1",
|
||||||
"echarts-gl": "^2.0.9",
|
"echarts-gl": "^2.0.9",
|
||||||
"echarts-wordcloud": "^2.1.0",
|
"echarts-wordcloud": "^2.1.0",
|
||||||
"element-plus": "^2.8.8",
|
"element-plus": "^2.9.0",
|
||||||
"exceljs": "^4.4.0",
|
"exceljs": "^4.4.0",
|
||||||
"ezuikit-js": "^8.1.1",
|
"ezuikit-js": "^8.1.1",
|
||||||
"gcoord": "^1.0.6",
|
"gcoord": "^1.0.6",
|
||||||
@ -48,18 +48,18 @@
|
|||||||
"md-editor-v3": "^5.0.2",
|
"md-editor-v3": "^5.0.2",
|
||||||
"mitt": "^3.0.1",
|
"mitt": "^3.0.1",
|
||||||
"monaco-editor": "^0.52.0",
|
"monaco-editor": "^0.52.0",
|
||||||
"mqtt": "^5.10.2",
|
"mqtt": "^5.10.3",
|
||||||
"nprogress": "^0.2.0",
|
"nprogress": "^0.2.0",
|
||||||
"ol": "^10.2.1",
|
"ol": "^10.2.1",
|
||||||
"pinia": "^2.2.6",
|
"pinia": "^2.2.8",
|
||||||
"print-js": "^1.6.0",
|
"print-js": "^1.6.0",
|
||||||
"push.js": "^1.0.12",
|
"push.js": "^1.0.12",
|
||||||
"qrcodejs2-fixes": "^0.0.2",
|
"qrcodejs2-fixes": "^0.0.2",
|
||||||
"qs": "^6.13.1",
|
"qs": "^6.13.1",
|
||||||
"relation-graph": "^2.2.9",
|
"relation-graph": "^2.2.10",
|
||||||
"screenfull": "^6.0.2",
|
"screenfull": "^6.0.2",
|
||||||
"sm-crypto-v2": "^1.9.3",
|
"sm-crypto-v2": "^1.9.3",
|
||||||
"sortablejs": "^1.15.4",
|
"sortablejs": "^1.15.6",
|
||||||
"splitpanes": "^3.1.5",
|
"splitpanes": "^3.1.5",
|
||||||
"vcrontab-3": "^3.3.22",
|
"vcrontab-3": "^3.3.22",
|
||||||
"vform3-builds": "^3.0.10",
|
"vform3-builds": "^3.0.10",
|
||||||
@ -68,13 +68,13 @@
|
|||||||
"vue-demi": "0.14.10",
|
"vue-demi": "0.14.10",
|
||||||
"vue-draggable-plus": "^0.6.0",
|
"vue-draggable-plus": "^0.6.0",
|
||||||
"vue-grid-layout": "3.0.0-beta1",
|
"vue-grid-layout": "3.0.0-beta1",
|
||||||
"vue-i18n": "^10.0.4",
|
"vue-i18n": "^10.0.5",
|
||||||
"vue-json-pretty": "^2.4.0",
|
"vue-json-pretty": "^2.4.0",
|
||||||
"vue-plugin-hiprint": "^0.0.58-fix",
|
"vue-plugin-hiprint": "^0.0.58-fix",
|
||||||
"vue-router": "^4.5.0",
|
"vue-router": "^4.5.0",
|
||||||
"vue-signature-pad": "^3.0.2",
|
"vue-signature-pad": "^3.0.2",
|
||||||
"vue3-tree-org": "^4.2.2",
|
"vue3-tree-org": "^4.2.2",
|
||||||
"vxe-pc-ui": "^4.3.6",
|
"vxe-pc-ui": "^4.3.10",
|
||||||
"vxe-table": "^4.8.10",
|
"vxe-table": "^4.8.10",
|
||||||
"vxe-table-plugin-element": "^4.0.4",
|
"vxe-table-plugin-element": "^4.0.4",
|
||||||
"vxe-table-plugin-export-xlsx": "^4.0.7",
|
"vxe-table-plugin-export-xlsx": "^4.0.7",
|
||||||
@ -85,27 +85,27 @@
|
|||||||
"@iconify/vue": "^4.1.2",
|
"@iconify/vue": "^4.1.2",
|
||||||
"@plugin-web-update-notification/vite": "^1.7.1",
|
"@plugin-web-update-notification/vite": "^1.7.1",
|
||||||
"@types/lodash-es": "^4.17.12",
|
"@types/lodash-es": "^4.17.12",
|
||||||
"@types/node": "^20.17.8",
|
"@types/node": "^20.17.9",
|
||||||
"@types/nprogress": "^0.2.3",
|
"@types/nprogress": "^0.2.3",
|
||||||
"@types/sortablejs": "^1.15.8",
|
"@types/sortablejs": "^1.15.8",
|
||||||
"@typescript-eslint/eslint-plugin": "^8.16.0",
|
"@typescript-eslint/eslint-plugin": "^8.16.0",
|
||||||
"@typescript-eslint/parser": "^8.16.0",
|
"@typescript-eslint/parser": "^8.16.0",
|
||||||
"@vitejs/plugin-vue": "^5.2.0",
|
"@vitejs/plugin-vue": "^5.2.1",
|
||||||
"@vitejs/plugin-vue-jsx": "^4.1.0",
|
"@vitejs/plugin-vue-jsx": "^4.1.1",
|
||||||
"@vue/compiler-sfc": "^3.5.13",
|
"@vue/compiler-sfc": "^3.5.13",
|
||||||
"code-inspector-plugin": "^0.18.2",
|
"code-inspector-plugin": "^0.18.2",
|
||||||
"eslint": "^9.15.0",
|
"eslint": "^9.15.0",
|
||||||
"eslint-plugin-vue": "^9.31.0",
|
"eslint-plugin-vue": "^9.31.0",
|
||||||
"globals": "^15.12.0",
|
"globals": "^15.12.0",
|
||||||
"less": "^4.2.1",
|
"less": "^4.2.1",
|
||||||
"prettier": "^3.4.0",
|
"prettier": "^3.4.1",
|
||||||
"rollup-plugin-visualizer": "^5.12.0",
|
"rollup-plugin-visualizer": "^5.12.0",
|
||||||
"sass": "^1.81.0",
|
"sass": "^1.81.0",
|
||||||
"terser": "^5.36.0",
|
"terser": "^5.36.0",
|
||||||
"typescript": "^5.7.2",
|
"typescript": "^5.7.2",
|
||||||
"vite": "^6.0.0",
|
"vite": "^6.0.1",
|
||||||
"vite-plugin-cdn-import": "^1.0.1",
|
"vite-plugin-cdn-import": "^1.0.1",
|
||||||
"vite-plugin-compression2": "^1.3.1",
|
"vite-plugin-compression2": "^1.3.3",
|
||||||
"vite-plugin-vue-setup-extend": "^0.4.0",
|
"vite-plugin-vue-setup-extend": "^0.4.0",
|
||||||
"vue-eslint-parser": "^9.4.3"
|
"vue-eslint-parser": "^9.4.3"
|
||||||
},
|
},
|
||||||
|
|||||||
@ -82,30 +82,6 @@ export interface CodeGenInput {
|
|||||||
*/
|
*/
|
||||||
descStr?: string | null;
|
descStr?: string | null;
|
||||||
|
|
||||||
/**
|
|
||||||
* 数据库表名
|
|
||||||
*
|
|
||||||
* @type {string}
|
|
||||||
* @memberof CodeGenInput
|
|
||||||
*/
|
|
||||||
tableName?: string | null;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 业务名(业务代码包名称)
|
|
||||||
*
|
|
||||||
* @type {string}
|
|
||||||
* @memberof CodeGenInput
|
|
||||||
*/
|
|
||||||
busName?: string | null;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 命名空间
|
|
||||||
*
|
|
||||||
* @type {string}
|
|
||||||
* @memberof CodeGenInput
|
|
||||||
*/
|
|
||||||
nameSpace?: string | null;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 作者姓名
|
* 作者姓名
|
||||||
*
|
*
|
||||||
@ -114,30 +90,6 @@ export interface CodeGenInput {
|
|||||||
*/
|
*/
|
||||||
authorName?: string | null;
|
authorName?: string | null;
|
||||||
|
|
||||||
/**
|
|
||||||
* 生成方式
|
|
||||||
*
|
|
||||||
* @type {string}
|
|
||||||
* @memberof CodeGenInput
|
|
||||||
*/
|
|
||||||
generateType?: string | null;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 是否生成菜单
|
|
||||||
*
|
|
||||||
* @type {boolean}
|
|
||||||
* @memberof CodeGenInput
|
|
||||||
*/
|
|
||||||
generateMenu?: boolean;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 是否使用 Api Service
|
|
||||||
*
|
|
||||||
* @type {boolean}
|
|
||||||
* @memberof CodeGenInput
|
|
||||||
*/
|
|
||||||
isApiService?: boolean;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 类名
|
* 类名
|
||||||
*
|
*
|
||||||
@ -186,6 +138,38 @@ export interface CodeGenInput {
|
|||||||
*/
|
*/
|
||||||
connectionString?: string | null;
|
connectionString?: string | null;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 生成方式
|
||||||
|
*
|
||||||
|
* @type {string}
|
||||||
|
* @memberof CodeGenInput
|
||||||
|
*/
|
||||||
|
generateType?: string | null;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 数据库表名
|
||||||
|
*
|
||||||
|
* @type {string}
|
||||||
|
* @memberof CodeGenInput
|
||||||
|
*/
|
||||||
|
tableName?: string | null;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 命名空间
|
||||||
|
*
|
||||||
|
* @type {string}
|
||||||
|
* @memberof CodeGenInput
|
||||||
|
*/
|
||||||
|
nameSpace?: string | null;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 业务名(业务代码包名称)
|
||||||
|
*
|
||||||
|
* @type {string}
|
||||||
|
* @memberof CodeGenInput
|
||||||
|
*/
|
||||||
|
busName?: string | null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 功能名(数据库表名称)
|
* 功能名(数据库表名称)
|
||||||
*
|
*
|
||||||
@ -202,6 +186,14 @@ export interface CodeGenInput {
|
|||||||
*/
|
*/
|
||||||
menuApplication?: string | null;
|
menuApplication?: string | null;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 是否生成菜单
|
||||||
|
*
|
||||||
|
* @type {boolean}
|
||||||
|
* @memberof CodeGenInput
|
||||||
|
*/
|
||||||
|
generateMenu?: boolean;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 菜单父级
|
* 菜单父级
|
||||||
*
|
*
|
||||||
@ -241,4 +233,12 @@ export interface CodeGenInput {
|
|||||||
* @memberof CodeGenInput
|
* @memberof CodeGenInput
|
||||||
*/
|
*/
|
||||||
printName?: string | null;
|
printName?: string | null;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 是否使用 Api Service
|
||||||
|
*
|
||||||
|
* @type {boolean}
|
||||||
|
* @memberof CodeGenInput
|
||||||
|
*/
|
||||||
|
isApiService?: boolean;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -45,7 +45,7 @@ export interface LoginInput {
|
|||||||
* @type {string}
|
* @type {string}
|
||||||
* @memberof LoginInput
|
* @memberof LoginInput
|
||||||
*/
|
*/
|
||||||
host: string;
|
host?: string | null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 验证码Id
|
* 验证码Id
|
||||||
|
|||||||
@ -45,7 +45,7 @@ export interface LoginPhoneInput {
|
|||||||
* @type {string}
|
* @type {string}
|
||||||
* @memberof LoginPhoneInput
|
* @memberof LoginPhoneInput
|
||||||
*/
|
*/
|
||||||
host: string;
|
host?: string | null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @type {LoginModeEnum}
|
* @type {LoginModeEnum}
|
||||||
|
|||||||
@ -85,20 +85,20 @@ export interface SysLogDiff {
|
|||||||
isDelete?: boolean;
|
isDelete?: boolean;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 操作前记录
|
* 租户Id
|
||||||
*
|
*
|
||||||
* @type {string}
|
* @type {number}
|
||||||
* @memberof SysLogDiff
|
* @memberof SysLogDiff
|
||||||
*/
|
*/
|
||||||
beforeData?: string | null;
|
tenantId?: number | null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 操作后记录
|
* 差异数据
|
||||||
*
|
*
|
||||||
* @type {string}
|
* @type {string}
|
||||||
* @memberof SysLogDiff
|
* @memberof SysLogDiff
|
||||||
*/
|
*/
|
||||||
afterData?: string | null;
|
diffData?: string | null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sql
|
* Sql
|
||||||
|
|||||||
@ -1,124 +1,160 @@
|
|||||||
import { service, cancelRequest } from '/@/utils/request';
|
import { service, cancelRequest } from '/@/utils/request';
|
||||||
import {AxiosRequestConfig, AxiosResponse} from "axios";
|
import { AxiosRequestConfig, AxiosResponse } from 'axios';
|
||||||
|
|
||||||
// 接口基类
|
// 接口基类
|
||||||
export const useBaseApi = (module: string) => {
|
export const useBaseApi = (module: string) => {
|
||||||
const baseUrl = `/api/${module}/`;
|
const baseUrl = `/api/${module}/`;
|
||||||
const request = <T>(config: AxiosRequestConfig<T>, cancel: boolean = false) => {
|
const request = <T>(config: AxiosRequestConfig<T>, cancel: boolean = false) => {
|
||||||
if (cancel) {
|
if (cancel) {
|
||||||
cancelRequest(config.url || "");
|
cancelRequest(config.url || '');
|
||||||
return Promise.resolve({} as AxiosResponse<any, any>);
|
return Promise.resolve({} as AxiosResponse<any, any>);
|
||||||
}
|
}
|
||||||
return service(config);
|
return service(config);
|
||||||
}
|
};
|
||||||
return {
|
return {
|
||||||
baseUrl: baseUrl,
|
baseUrl: baseUrl,
|
||||||
request: request,
|
request: request,
|
||||||
page: function (data: any, cancel: boolean = false) {
|
page: function (data: any, cancel: boolean = false) {
|
||||||
return request({
|
return request(
|
||||||
url: baseUrl + "page",
|
{
|
||||||
method: 'post',
|
url: baseUrl + 'page',
|
||||||
data,
|
method: 'post',
|
||||||
}, cancel);
|
data,
|
||||||
},
|
},
|
||||||
detail: function (id: any, cancel: boolean = false) {
|
cancel
|
||||||
return request({
|
);
|
||||||
url: baseUrl + "detail",
|
},
|
||||||
method: 'get',
|
detail: function (id: any, cancel: boolean = false) {
|
||||||
data: { id },
|
return request(
|
||||||
}, cancel);
|
{
|
||||||
},
|
url: baseUrl + 'detail',
|
||||||
dropdownData: function (data: any, cancel: boolean = false) {
|
method: 'get',
|
||||||
return request({
|
data: { id },
|
||||||
url: baseUrl + "dropdownData",
|
},
|
||||||
method: 'post',
|
cancel
|
||||||
data,
|
);
|
||||||
}, cancel);
|
},
|
||||||
},
|
dropdownData: function (data: any, cancel: boolean = false) {
|
||||||
add: function (data: any, cancel: boolean = false) {
|
return request(
|
||||||
return request({
|
{
|
||||||
url: baseUrl + 'add',
|
url: baseUrl + 'dropdownData',
|
||||||
method: 'post',
|
method: 'post',
|
||||||
data
|
data,
|
||||||
}, cancel);
|
},
|
||||||
},
|
cancel
|
||||||
update: function (data: any, cancel: boolean = false) {
|
);
|
||||||
return request({
|
},
|
||||||
url: baseUrl + 'update',
|
add: function (data: any, cancel: boolean = false) {
|
||||||
method: 'post',
|
return request(
|
||||||
data
|
{
|
||||||
}, cancel);
|
url: baseUrl + 'add',
|
||||||
},
|
method: 'post',
|
||||||
setStatus: function (data: any, cancel: boolean = false) {
|
data,
|
||||||
return request({
|
},
|
||||||
url: baseUrl + 'setStatus',
|
cancel
|
||||||
method: 'post',
|
);
|
||||||
data
|
},
|
||||||
}, cancel);
|
update: function (data: any, cancel: boolean = false) {
|
||||||
},
|
return request(
|
||||||
delete: function (data: any, cancel: boolean = false) {
|
{
|
||||||
return request({
|
url: baseUrl + 'update',
|
||||||
url: baseUrl + 'delete',
|
method: 'post',
|
||||||
method: 'post',
|
data,
|
||||||
data
|
},
|
||||||
}, cancel);
|
cancel
|
||||||
},
|
);
|
||||||
batchDelete: function (data: any, cancel: boolean = false) {
|
},
|
||||||
return request({
|
setStatus: function (data: any, cancel: boolean = false) {
|
||||||
url: baseUrl + 'batchDelete',
|
return request(
|
||||||
method: 'post',
|
{
|
||||||
data
|
url: baseUrl + 'setStatus',
|
||||||
}, cancel);
|
method: 'post',
|
||||||
},
|
data,
|
||||||
exportData: function (data: any, cancel: boolean = false) {
|
},
|
||||||
return request({
|
cancel
|
||||||
responseType: 'arraybuffer',
|
);
|
||||||
url: baseUrl + 'export',
|
},
|
||||||
method: 'post',
|
delete: function (data: any, cancel: boolean = false) {
|
||||||
data
|
return request(
|
||||||
}, cancel);
|
{
|
||||||
},
|
url: baseUrl + 'delete',
|
||||||
downloadTemplate: function (cancel: boolean = false) {
|
method: 'post',
|
||||||
return request({
|
data,
|
||||||
responseType: 'arraybuffer',
|
},
|
||||||
url: baseUrl + 'import',
|
cancel
|
||||||
method: 'get',
|
);
|
||||||
}, cancel);
|
},
|
||||||
},
|
batchDelete: function (data: any, cancel: boolean = false) {
|
||||||
importData: function (file: any, cancel: boolean = false) {
|
return request(
|
||||||
const formData = new FormData();
|
{
|
||||||
formData.append('file', file);
|
url: baseUrl + 'batchDelete',
|
||||||
return request({
|
method: 'post',
|
||||||
headers: { 'Content-Type': 'multipart/form-data;charset=UTF-8' },
|
data,
|
||||||
responseType: 'arraybuffer',
|
},
|
||||||
url: baseUrl + 'import',
|
cancel
|
||||||
method: 'post',
|
);
|
||||||
data: formData,
|
},
|
||||||
}, cancel);
|
exportData: function (data: any, cancel: boolean = false) {
|
||||||
},
|
return request(
|
||||||
uploadFile: function (params: any, action: string, cancel: boolean = false) {
|
{
|
||||||
const formData = new FormData();
|
responseType: 'arraybuffer',
|
||||||
formData.append('file', params.file);
|
url: baseUrl + 'export',
|
||||||
// 自定义参数
|
method: 'post',
|
||||||
if (params.data) {
|
data,
|
||||||
Object.keys(params.data).forEach((key) => {
|
},
|
||||||
const value = params.data![key];
|
cancel
|
||||||
if (Array.isArray(value)) {
|
);
|
||||||
value.forEach((item) => formData.append(`${key}[]`, item));
|
},
|
||||||
return;
|
downloadTemplate: function (cancel: boolean = false) {
|
||||||
}
|
return request(
|
||||||
formData.append(key, params.data![key]);
|
{
|
||||||
});
|
responseType: 'arraybuffer',
|
||||||
}
|
url: baseUrl + 'import',
|
||||||
return request({
|
method: 'get',
|
||||||
url: baseUrl + action,
|
},
|
||||||
method: 'POST',
|
cancel
|
||||||
data: formData,
|
);
|
||||||
headers: {
|
},
|
||||||
ContentType: 'multipart/form-data;charset=UTF-8',
|
importData: function (file: any, cancel: boolean = false) {
|
||||||
ignoreCancelToken: true,
|
const formData = new FormData();
|
||||||
},
|
formData.append('file', file);
|
||||||
}, cancel);
|
return request(
|
||||||
}
|
{
|
||||||
}
|
headers: { 'Content-Type': 'multipart/form-data;charset=UTF-8' },
|
||||||
}
|
responseType: 'arraybuffer',
|
||||||
|
url: baseUrl + 'import',
|
||||||
|
method: 'post',
|
||||||
|
data: formData,
|
||||||
|
},
|
||||||
|
cancel
|
||||||
|
);
|
||||||
|
},
|
||||||
|
uploadFile: function (params: any, action: string, cancel: boolean = false) {
|
||||||
|
const formData = new FormData();
|
||||||
|
formData.append('file', params.file);
|
||||||
|
// 自定义参数
|
||||||
|
if (params.data) {
|
||||||
|
Object.keys(params.data).forEach((key) => {
|
||||||
|
const value = params.data![key];
|
||||||
|
if (Array.isArray(value)) {
|
||||||
|
value.forEach((item) => formData.append(`${key}[]`, item));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
formData.append(key, params.data![key]);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
return request(
|
||||||
|
{
|
||||||
|
url: baseUrl + action,
|
||||||
|
method: 'POST',
|
||||||
|
data: formData,
|
||||||
|
headers: {
|
||||||
|
'Content-Type': 'multipart/form-data;charset=UTF-8',
|
||||||
|
ignoreCancelToken: true,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
cancel
|
||||||
|
);
|
||||||
|
},
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|||||||
@ -68,11 +68,13 @@ onBeforeMount(() => {
|
|||||||
state.keepAliveNameList = keepAliveNames.value.filter((name: string) => route.name !== name);
|
state.keepAliveNameList = keepAliveNames.value.filter((name: string) => route.name !== name);
|
||||||
state.refreshRouterViewKey = '';
|
state.refreshRouterViewKey = '';
|
||||||
state.iframeRefreshKey = '';
|
state.iframeRefreshKey = '';
|
||||||
nextTick(() => {
|
cachedViews.value = [];
|
||||||
state.refreshRouterViewKey = fullPath;
|
setTimeout(() => {
|
||||||
state.iframeRefreshKey = fullPath;
|
state.iframeRefreshKey = fullPath;
|
||||||
|
state.refreshRouterViewKey = fullPath;
|
||||||
|
cachedViews.value = [<string>route.name];
|
||||||
state.keepAliveNameList = keepAliveNames.value;
|
state.keepAliveNameList = keepAliveNames.value;
|
||||||
});
|
}, 10);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
// 页面加载时
|
// 页面加载时
|
||||||
|
|||||||
@ -2,10 +2,13 @@ import { defineStore } from 'pinia';
|
|||||||
import { Local, Session } from '/@/utils/storage';
|
import { Local, Session } from '/@/utils/storage';
|
||||||
import Watermark from '/@/utils/watermark';
|
import Watermark from '/@/utils/watermark';
|
||||||
import { useThemeConfig } from '/@/stores/themeConfig';
|
import { useThemeConfig } from '/@/stores/themeConfig';
|
||||||
|
import { i18n } from '/@/i18n';
|
||||||
|
|
||||||
import { getAPI } from '/@/utils/axios-utils';
|
import { getAPI } from '/@/utils/axios-utils';
|
||||||
import { SysAuthApi, SysConstApi, SysDictTypeApi, SysRoleApi } from '/@/api-services/api';
|
import { SysAuthApi, SysConstApi, SysDictTypeApi, SysRoleApi } from '/@/api-services/api';
|
||||||
|
|
||||||
|
const { t } = i18n.global;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 用户信息
|
* 用户信息
|
||||||
* @methods setUserInfos 设置用户信息
|
* @methods setUserInfos 设置用户信息
|
||||||
@ -35,7 +38,13 @@ export const useUserInfo = defineStore('userInfo', {
|
|||||||
this.dictList = await getAPI(SysDictTypeApi)
|
this.dictList = await getAPI(SysDictTypeApi)
|
||||||
.apiSysDictTypeAllDictListGet()
|
.apiSysDictTypeAllDictListGet()
|
||||||
.then((res) => res.data.result ?? {});
|
.then((res) => res.data.result ?? {});
|
||||||
for (const key in this.dictList) if (key.endsWith('Enum')) this.dictList[key].forEach((e: any) => (e.code = Number(e.code)));
|
for (const key in this.dictList) {
|
||||||
|
// 处理字典国际化
|
||||||
|
this.dictList[key].forEach((e: any) => setDictLangMessage(e));
|
||||||
|
if (key.endsWith('Enum')) {
|
||||||
|
this.dictList[key].forEach((e: any) => (e.code = Number(e.code)));
|
||||||
|
}
|
||||||
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
// 存储用户表格列到浏览器缓存
|
// 存储用户表格列到浏览器缓存
|
||||||
@ -128,3 +137,10 @@ export const useUserInfo = defineStore('userInfo', {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// 处理字典国际化, 默认显示字典中的value值
|
||||||
|
const setDictLangMessage = (dict: any) => {
|
||||||
|
dict.langMessage = `message.system.dictType.${dict.typeCode}.${dict.code}`;
|
||||||
|
const value = t(dict.langMessage);
|
||||||
|
dict.value = value !== dict.langMessage ? value : dict.value;
|
||||||
|
};
|
||||||
|
|||||||
@ -9,7 +9,7 @@ const abortControllerMap: Map<string, AbortController> = new Map();
|
|||||||
export const service = axios.create({
|
export const service = axios.create({
|
||||||
baseURL: window.__env__.VITE_API_URL as any,
|
baseURL: window.__env__.VITE_API_URL as any,
|
||||||
timeout: 50000,
|
timeout: 50000,
|
||||||
headers: { 'Content-Type': 'application/json' },
|
// headers: { 'Content-Type': 'application/json' },
|
||||||
});
|
});
|
||||||
|
|
||||||
// token 键定义
|
// token 键定义
|
||||||
|
|||||||
@ -39,7 +39,7 @@ import { ElMessageBox } from 'element-plus';
|
|||||||
import LogicFlow from '@logicflow/core';
|
import LogicFlow from '@logicflow/core';
|
||||||
import { BpmnElement, InsertNodeInPolyline, Menu, MiniMap, SelectionSelect, Snapshot } from '@logicflow/extension';
|
import { BpmnElement, InsertNodeInPolyline, Menu, MiniMap, SelectionSelect, Snapshot } from '@logicflow/extension';
|
||||||
import '@logicflow/core/dist/index.css';
|
import '@logicflow/core/dist/index.css';
|
||||||
import '@logicflow/extension/lib/index.css';
|
import '@logicflow/extension/lib/style/index.css';
|
||||||
|
|
||||||
import RegisterEdge from './LogicFlow/Register/RegisterEdge';
|
import RegisterEdge from './LogicFlow/Register/RegisterEdge';
|
||||||
import RegisterNode from './LogicFlow/Register/RegisterNode';
|
import RegisterNode from './LogicFlow/Register/RegisterNode';
|
||||||
|
|||||||
@ -16,7 +16,7 @@
|
|||||||
<el-form :model="state.ruleForm" ref="ruleFormRef" label-width="auto">
|
<el-form :model="state.ruleForm" ref="ruleFormRef" label-width="auto">
|
||||||
<el-row :gutter="10">
|
<el-row :gutter="10">
|
||||||
<el-col :xs="24" :sm="12" :md="12" :lg="12" :xl="12" class="mb20">
|
<el-col :xs="24" :sm="12" :md="12" :lg="12" :xl="12" class="mb20">
|
||||||
<el-form-item label="库定位器" prop="configId">
|
<el-form-item label="库定位器" prop="configId" :rules="[{ required: true, message: '请选择库定位器', trigger: 'blur' }]">
|
||||||
<el-select v-model="state.ruleForm.configId" placeholder="库名" filterable @change="dbChanged()" class="w100">
|
<el-select v-model="state.ruleForm.configId" placeholder="库名" filterable @change="dbChanged()" class="w100">
|
||||||
<el-option v-for="item in state.dbData" :key="item.configId" :label="item.configId" :value="item.configId" />
|
<el-option v-for="item in state.dbData" :key="item.configId" :label="item.configId" :value="item.configId" />
|
||||||
</el-select>
|
</el-select>
|
||||||
@ -54,7 +54,7 @@
|
|||||||
</el-form-item>
|
</el-form-item>
|
||||||
</el-col>
|
</el-col>
|
||||||
<el-col :xs="24" :sm="24" :md="24" :lg="24" :xl="24" class="mb20">
|
<el-col :xs="24" :sm="24" :md="24" :lg="24" :xl="24" class="mb20">
|
||||||
<el-form-item label="库地址" prop="connectionString">
|
<el-form-item label="库地址" prop="connectionString" :rules="[{ required: true, message: '库地址不能为空', trigger: 'blur' }]">
|
||||||
<el-input v-model="state.ruleForm.connectionString" disabled clearable type="textarea" />
|
<el-input v-model="state.ruleForm.connectionString" disabled clearable type="textarea" />
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
</el-col>
|
</el-col>
|
||||||
@ -74,7 +74,7 @@
|
|||||||
</el-form-item>
|
</el-form-item>
|
||||||
</el-col>
|
</el-col>
|
||||||
<el-col :xs="24" :sm="12" :md="12" :lg="12" :xl="12" class="mb20">
|
<el-col :xs="24" :sm="12" :md="12" :lg="12" :xl="12" class="mb20">
|
||||||
<el-form-item label="业务名" prop="busName">
|
<el-form-item label="业务名" prop="busName" :rules="[{ required: true, message: '业务名不能为空', trigger: 'blur' }]">
|
||||||
<el-input v-model="state.ruleForm.busName" placeholder="请输入" clearable />
|
<el-input v-model="state.ruleForm.busName" placeholder="请输入" clearable />
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
</el-col>
|
</el-col>
|
||||||
@ -120,7 +120,7 @@
|
|||||||
</el-form-item>
|
</el-form-item>
|
||||||
</el-col>
|
</el-col>
|
||||||
<el-col :xs="24" :sm="12" :md="12" :lg="12" :xl="12" class="mb20">
|
<el-col :xs="24" :sm="12" :md="12" :lg="12" :xl="12" class="mb20">
|
||||||
<el-form-item label="前端目录" prop="pagePath">
|
<el-form-item label="前端目录" prop="pagePath" :rules="[{ required: true, message: '前端目录不能为空', trigger: 'blur' }]">
|
||||||
<el-input v-model="state.ruleForm.pagePath" clearable placeholder="请输入" />
|
<el-input v-model="state.ruleForm.pagePath" clearable placeholder="请输入" />
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
</el-col>
|
</el-col>
|
||||||
|
|||||||
@ -5,12 +5,12 @@
|
|||||||
<el-row :gutter="10">
|
<el-row :gutter="10">
|
||||||
<el-col class="mb5" :xs="24" :sm="12" :md="8" :lg="6" :xl="6">
|
<el-col class="mb5" :xs="24" :sm="12" :md="8" :lg="6" :xl="6">
|
||||||
<el-form-item label="开始时间" prop="name">
|
<el-form-item label="开始时间" prop="name">
|
||||||
<el-date-picker v-model="state.queryParams.startTime" type="datetime" placeholder="开始时间" :shortcuts="shortcuts" class="w100" />
|
<el-date-picker v-model="state.queryParams.startTime" type="datetime" placeholder="开始时间" value-format="YYYY-MM-DD HH:mm:ss" :shortcuts="shortcuts" class="w100" />
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
</el-col>
|
</el-col>
|
||||||
<el-col class="mb5" :xs="24" :sm="12" :md="8" :lg="6" :xl="6">
|
<el-col class="mb5" :xs="24" :sm="12" :md="8" :lg="6" :xl="6">
|
||||||
<el-form-item label="结束时间" prop="code">
|
<el-form-item label="结束时间" prop="code">
|
||||||
<el-date-picker v-model="state.queryParams.endTime" type="datetime" placeholder="结束时间" :shortcuts="shortcuts" class="w100" />
|
<el-date-picker v-model="state.queryParams.endTime" type="datetime" placeholder="结束时间" value-format="YYYY-MM-DD HH:mm:ss" :shortcuts="shortcuts" class="w100" />
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
</el-col>
|
</el-col>
|
||||||
</el-row>
|
</el-row>
|
||||||
@ -37,13 +37,49 @@
|
|||||||
<template #empty>
|
<template #empty>
|
||||||
<el-empty :image-size="200" />
|
<el-empty :image-size="200" />
|
||||||
</template>
|
</template>
|
||||||
<template #row_buttons="{ row }">
|
<template #row_content="{ row }">
|
||||||
<el-button icon="ele-InfoFilled" text type="primary" @click="handleView({ row })">详情</el-button>
|
<el-card header="差异数据" style="width: 100%; margin: 5px">
|
||||||
|
<el-table :data="item.columns" v-for="item in row.diffData" :key="item.tableName" :span-method="(data: any) => diffTableSpanMethod(data, item)" border style="width: 100%">
|
||||||
|
<el-table-column label="表名" width="200">
|
||||||
|
<template #default>
|
||||||
|
{{ item.tableName }}
|
||||||
|
<br />
|
||||||
|
{{ item.tableDescription }}
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
<el-table-column prop="columnName" label="字段描述" width="300" :formatter="(row: any) => `${row.columnName} - ${row.columnDescription}`" />
|
||||||
|
<el-table-column prop="beforeValue" label="修改前" show-overflow-tooltip>
|
||||||
|
<template #default="columnScope">
|
||||||
|
<pre v-html="markDiff(columnScope.row.beforeValue, columnScope.row.afterValue, true)" />
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
<el-table-column prop="afterValue" label="修改后" show-overflow-tooltip>
|
||||||
|
<template #default="columnScope">
|
||||||
|
<pre v-html="markDiff(columnScope.row.beforeValue, columnScope.row.afterValue, false)" />
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
</el-table>
|
||||||
|
<el-table :data="[{ sql: row.sql }]" border style="width: 100%">
|
||||||
|
<el-table-column prop="sql" label="SQL语句">
|
||||||
|
<template #default>
|
||||||
|
<pre class="sql" v-html="formatSql(row.sql)"></pre>
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
</el-table>
|
||||||
|
<el-table :data="row.parameters" border style="width: 100%">
|
||||||
|
<el-table-column prop="parameterName" label="参数名" width="200" />
|
||||||
|
<el-table-column prop="typeName" label="类型" width="100" />
|
||||||
|
<el-table-column prop="value" label="值" />
|
||||||
|
</el-table>
|
||||||
|
</el-card>
|
||||||
</template>
|
</template>
|
||||||
|
<!-- <template #row_buttons="{ row }">
|
||||||
|
<el-button icon="ele-InfoFilled" text type="primary" @click="handleView({ row })">详情</el-button>
|
||||||
|
</template> -->
|
||||||
</vxe-grid>
|
</vxe-grid>
|
||||||
</el-card>
|
</el-card>
|
||||||
|
|
||||||
<el-dialog v-model="state.visible" draggable overflow destroy-on-close>
|
<!-- <el-dialog v-model="state.visible" draggable overflow destroy-on-close>
|
||||||
<template #header>
|
<template #header>
|
||||||
<div style="color: #fff">
|
<div style="color: #fff">
|
||||||
<el-icon size="16" style="margin-right: 3px; display: inline; vertical-align: middle"> <ele-Document /> </el-icon>
|
<el-icon size="16" style="margin-right: 3px; display: inline; vertical-align: middle"> <ele-Document /> </el-icon>
|
||||||
@ -77,7 +113,7 @@
|
|||||||
</el-scrollbar>
|
</el-scrollbar>
|
||||||
</el-tab-pane>
|
</el-tab-pane>
|
||||||
</el-tabs>
|
</el-tabs>
|
||||||
</el-dialog>
|
</el-dialog> -->
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
@ -89,9 +125,9 @@ import { VxeGridInstance, VxeGridListeners, VxeGridPropTypes } from 'vxe-table';
|
|||||||
import { useVxeTable } from '/@/hooks/useVxeTableOptionsHook';
|
import { useVxeTable } from '/@/hooks/useVxeTableOptionsHook';
|
||||||
import { Local } from '/@/utils/storage';
|
import { Local } from '/@/utils/storage';
|
||||||
|
|
||||||
import VueJsonPretty from 'vue-json-pretty';
|
// import VueJsonPretty from 'vue-json-pretty';
|
||||||
import 'vue-json-pretty/lib/styles.css';
|
// import 'vue-json-pretty/lib/styles.css';
|
||||||
import { StringToObj } from '/@/utils/json-utils';
|
// import { StringToObj } from '/@/utils/json-utils';
|
||||||
|
|
||||||
import { getAPI } from '/@/utils/axios-utils';
|
import { getAPI } from '/@/utils/axios-utils';
|
||||||
import { SysLogDiffApi } from '/@/api-services/api';
|
import { SysLogDiffApi } from '/@/api-services/api';
|
||||||
@ -129,16 +165,17 @@ const options = useVxeTable<SysLogDiff>(
|
|||||||
columns: [
|
columns: [
|
||||||
// { type: 'checkbox', width: 40 },
|
// { type: 'checkbox', width: 40 },
|
||||||
{ type: 'seq', title: '序号', width: 60, fixed: 'left' },
|
{ type: 'seq', title: '序号', width: 60, fixed: 'left' },
|
||||||
|
{ type: 'expand', width: 40, slots: { content: 'row_content' } },
|
||||||
{ field: 'diffType', title: '差异操作', minWidth: 150, showOverflow: 'tooltip' },
|
{ field: 'diffType', title: '差异操作', minWidth: 150, showOverflow: 'tooltip' },
|
||||||
{ field: 'sql', title: 'Sql语句', minWidth: 150, showOverflow: 'tooltip' },
|
// { field: 'sql', title: 'Sql语句', minWidth: 150, showOverflow: 'tooltip' },
|
||||||
{ field: 'parameters', title: '参数', minWidth: 150, showOverflow: 'tooltip' },
|
// { field: 'parameters', title: '参数', minWidth: 150, showOverflow: 'tooltip' },
|
||||||
{ field: 'elapsed', title: '耗时(ms)', minWidth: 150, showOverflow: 'tooltip' },
|
{ field: 'elapsed', title: '耗时(ms)', minWidth: 150, showOverflow: 'tooltip' },
|
||||||
{ field: 'message', title: '日志消息', minWidth: 150, showOverflow: 'tooltip' },
|
{ field: 'message', title: '日志消息', minWidth: 150, showOverflow: 'tooltip' },
|
||||||
{ field: 'beforeData', title: '操作前记录', minWidth: 150, showOverflow: 'tooltip' },
|
// { field: 'beforeData', title: '操作前记录', minWidth: 150, showOverflow: 'tooltip' },
|
||||||
{ field: 'afterData', title: '操作后记录', minWidth: 150, showOverflow: 'tooltip' },
|
// { field: 'afterData', title: '操作后记录', minWidth: 150, showOverflow: 'tooltip' },
|
||||||
{ field: 'businessData', title: '业务对象', minWidth: 150, showOverflow: 'tooltip' },
|
{ field: 'businessData', title: '业务对象', minWidth: 150, showOverflow: 'tooltip' },
|
||||||
{ field: 'createTime', title: '操作时间', minWidth: 100, showOverflow: 'tooltip' },
|
{ field: 'createTime', title: '操作时间', minWidth: 100, showOverflow: 'tooltip' },
|
||||||
{ title: '操作', fixed: 'right', width: 100, showOverflow: true, slots: { default: 'row_buttons' } },
|
// { title: '操作', fixed: 'right', width: 100, showOverflow: true, slots: { default: 'row_buttons' } },
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
// vxeGrid配置参数(此处可覆写任何参数),参考vxe-table官方文档
|
// vxeGrid配置参数(此处可覆写任何参数),参考vxe-table官方文档
|
||||||
@ -193,16 +230,158 @@ const gridEvents: VxeGridListeners<SysLogDiff> = {
|
|||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
// 查看详情
|
// // 查看详情
|
||||||
const handleView = async ({ row }: any) => {
|
// const handleView = async ({ row }: any) => {
|
||||||
const { data } = await getAPI(SysLogDiffApi).apiSysLogDiffDetailIdGet(row.id);
|
// const { data } = await getAPI(SysLogDiffApi).apiSysLogDiffDetailIdGet(row.id);
|
||||||
state.activeTab = 'message';
|
// state.activeTab = 'message';
|
||||||
state.detail.message = data?.result?.diffType;
|
// state.detail.message = data?.result?.diffType;
|
||||||
// 如果请求参数是JSON字符串,则尝试转为JSON对象
|
// // 如果请求参数是JSON字符串,则尝试转为JSON对象
|
||||||
state.detail.sql = StringToObj(data?.result?.sql);
|
// state.detail.sql = StringToObj(data?.result?.sql);
|
||||||
state.detail.parameters = StringToObj(data?.result?.parameters);
|
// state.detail.parameters = StringToObj(data?.result?.parameters);
|
||||||
state.detail.afterData = StringToObj(data?.result?.afterData);
|
// state.detail.afterData = StringToObj(data?.result?.afterData);
|
||||||
state.detail.beforeData = StringToObj(data?.result?.beforeData);
|
// state.detail.beforeData = StringToObj(data?.result?.beforeData);
|
||||||
state.visible = true;
|
// state.visible = true;
|
||||||
|
// };
|
||||||
|
|
||||||
|
// 合并差异表格表名列
|
||||||
|
const diffTableSpanMethod = ({ columnIndex, rowIndex }: any, itme: any) => {
|
||||||
|
if (columnIndex === 0) {
|
||||||
|
if (rowIndex === 0) {
|
||||||
|
return {
|
||||||
|
rowspan: itme.columns.length,
|
||||||
|
colspan: 1,
|
||||||
|
};
|
||||||
|
} else {
|
||||||
|
return {
|
||||||
|
rowspan: 0,
|
||||||
|
colspan: 0,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const formatSql = (sql: string) => {
|
||||||
|
// 移除多余的空格
|
||||||
|
let formatted = sql.replace(/\s+/g, ' ').trim();
|
||||||
|
|
||||||
|
// 替换反引号包裹的字段
|
||||||
|
formatted = formatted.replace(/`([^`]+)`/g, '<span class="sql-backtick">`$1`</span>');
|
||||||
|
|
||||||
|
// 替换@参数
|
||||||
|
formatted = formatted.replace(/(@\w+)/g, '<span class="sql-param">$1</span>');
|
||||||
|
|
||||||
|
// 替换SQL关键字
|
||||||
|
formatted = formatted.replace(
|
||||||
|
/\b(INSERT|DELETE|UPDATE|SELECT|FROM|SET|JOIN|ON|AND|OR|IN|NOT|IS|NULL|WHERE|TRUE|FALSE|LIKE|ORDER BY|GROUP BY|HAVING|LIMIT|AS|WITH|CASE|WHEN|THEN|ELSE|END)\b/g,
|
||||||
|
'<span class="sql-keyword">$1</span>'
|
||||||
|
);
|
||||||
|
|
||||||
|
// 智能换行
|
||||||
|
// 在SET和VALUES后面添加换行
|
||||||
|
formatted = formatted.replace(/(SET|VALUES)(?=\s)/g, '$1\n ');
|
||||||
|
// 在逗号后面添加换行,除非是最后一个逗号
|
||||||
|
formatted = formatted.replace(/,(?![^]*?,\s*$)(?=[^\s])/g, ',\n ');
|
||||||
|
// 在WHERE前添加换行,如果WHERE前面不是逗号
|
||||||
|
formatted = formatted.replace(/([\s\S]+)(WHERE)/g, '$1\n$2');
|
||||||
|
|
||||||
|
// 移除由于换行添加的多余空格
|
||||||
|
formatted = formatted.replace(/\n\s*\n/g, '\n');
|
||||||
|
|
||||||
|
return formatted;
|
||||||
|
};
|
||||||
|
|
||||||
|
function lcs(s1: string, s2: string): number[][] {
|
||||||
|
const m = s1.length;
|
||||||
|
const n = s2.length;
|
||||||
|
const dp = Array.from({ length: m + 1 }, () => Array(n + 1).fill(0));
|
||||||
|
|
||||||
|
for (let i = 1; i <= m; i++) {
|
||||||
|
for (let j = 1; j <= n; j++) {
|
||||||
|
if (s1[i - 1] === s2[j - 1]) {
|
||||||
|
dp[i][j] = dp[i - 1][j - 1] + 1;
|
||||||
|
} else {
|
||||||
|
dp[i][j] = Math.max(dp[i - 1][j], dp[i][j - 1]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return dp;
|
||||||
|
}
|
||||||
|
|
||||||
|
function markDiff(oldData: any, newData: any, returnOld: boolean): string {
|
||||||
|
if (typeof oldData !== 'string' || typeof newData !== 'string') {
|
||||||
|
return `<span class="diff-${returnOld ? 'delete' : 'add'}">${returnOld ? oldData : newData}</span>`;
|
||||||
|
}
|
||||||
|
|
||||||
|
const dp = lcs(oldData, newData);
|
||||||
|
const m = oldData.length;
|
||||||
|
const n = newData.length;
|
||||||
|
let oldIndex = m,
|
||||||
|
newIndex = n;
|
||||||
|
const diffResult: { type: string; content: string }[] = [];
|
||||||
|
|
||||||
|
while (oldIndex > 0 || newIndex > 0) {
|
||||||
|
if (oldIndex > 0 && newIndex > 0 && oldData[oldIndex - 1] === newData[newIndex - 1]) {
|
||||||
|
diffResult.push({ type: 'unchanged', content: oldData[oldIndex - 1] });
|
||||||
|
oldIndex--;
|
||||||
|
newIndex--;
|
||||||
|
} else if (newIndex > 0 && (oldIndex === 0 || dp[oldIndex][newIndex - 1] >= dp[oldIndex - 1][newIndex])) {
|
||||||
|
diffResult.push({ type: 'add', content: newData[newIndex - 1] });
|
||||||
|
newIndex--;
|
||||||
|
} else {
|
||||||
|
diffResult.push({ type: 'delete', content: oldData[oldIndex - 1] });
|
||||||
|
oldIndex--;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const result = diffResult
|
||||||
|
.reverse()
|
||||||
|
.map((chunk) => {
|
||||||
|
switch (chunk.type) {
|
||||||
|
case 'add':
|
||||||
|
return `<span class="diff-add">${chunk.content}</span>`;
|
||||||
|
case 'delete':
|
||||||
|
return `<span class="diff-delete">${chunk.content}</span>`;
|
||||||
|
default:
|
||||||
|
return chunk.content;
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.join('');
|
||||||
|
|
||||||
|
return result.replace(returnOld ? /<span class="diff-add">(.*?)<\/span>/g : /<span class="diff-delete">(.*?)<\/span>/g, '');
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
<style lang="scss" scoped>
|
||||||
|
.el-popper {
|
||||||
|
max-width: 60%;
|
||||||
|
}
|
||||||
|
:deep(pre.sql) {
|
||||||
|
white-space: pre-wrap;
|
||||||
|
.sql-param {
|
||||||
|
color: green;
|
||||||
|
}
|
||||||
|
.sql-keyword {
|
||||||
|
color: blue;
|
||||||
|
}
|
||||||
|
.sql-backtick {
|
||||||
|
color: blueviolet;
|
||||||
|
}
|
||||||
|
span.diff-unchanged {
|
||||||
|
color: inherit;
|
||||||
|
}
|
||||||
|
span.diff-delete {
|
||||||
|
color: red;
|
||||||
|
}
|
||||||
|
span.diff-add {
|
||||||
|
color: green;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
:deep(pre) {
|
||||||
|
span.diff-delete {
|
||||||
|
color: red;
|
||||||
|
}
|
||||||
|
span.diff-add {
|
||||||
|
color: green;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user