fix: 导出功能为全量,行头文字多语言翻译

This commit is contained in:
TsMask
2024-04-19 17:21:33 +08:00
parent 0c45cbd195
commit e05c2a6a51
15 changed files with 358 additions and 216 deletions

View File

@@ -412,15 +412,22 @@ func (s *SysRoleController) AuthUserChecked(c *gin.Context) {
func (s *SysRoleController) Export(c *gin.Context) {
language := ctx.AcceptLanguage(c)
// 查询结果,根据查询条件结果,单页最大值限制
querys := ctx.BodyJSONMap(c)
// querys := ctx.BodyJSONMap(c)
dataScopeSQL := ctx.LoginUserToDataScopeSQL(c, "d", "")
data := s.sysRoleService.SelectRolePage(querys, dataScopeSQL)
if data["total"].(int64) == 0 {
// data := s.sysRoleService.SelectRolePage(querys, dataScopeSQL)
// if data["total"].(int64) == 0 {
// // 导出数据记录为空
// c.JSON(200, result.ErrMsg(i18n.TKey(language, "app.common.exportEmpty")))
// return
// }
// rows := data["rows"].([]model.SysRole)
rows := s.sysRoleService.SelectRoleList(model.SysRole{}, dataScopeSQL)
if len(rows) <= 0 {
// 导出数据记录为空
c.JSON(200, result.ErrMsg(i18n.TKey(language, "app.common.exportEmpty")))
return
}
rows := data["rows"].([]model.SysRole)
// 闭包函数处理多语言
converI18n := func(language string, arr *[]model.SysRole) {
@@ -439,23 +446,23 @@ func (s *SysRoleController) Export(c *gin.Context) {
"B1": i18n.TKey(language, "role.export.name"),
"C1": i18n.TKey(language, "role.export.key"),
"D1": i18n.TKey(language, "role.export.sort"),
"E1": i18n.TKey(language, "role.export.dataScope"),
"F1": i18n.TKey(language, "role.export.status"),
"E1": i18n.TKey(language, "role.export.status"),
// "F1": i18n.TKey(language, "role.export.dataScope"),
}
// 读取系统角色数据范围字典数据
dictSysRoleDatascope := s.sysDictDataService.SelectDictDataByType("sys_role_datascope")
// dictSysRoleDatascope := s.sysDictDataService.SelectDictDataByType("sys_role_datascope")
// 从第二行开始的数据
dataCells := make([]map[string]any, 0)
for i, row := range rows {
idx := strconv.Itoa(i + 2)
// 数据范围
dataScope := row.DataScope
for _, v := range dictSysRoleDatascope {
if row.DataScope == v.DictValue {
dataScope = i18n.TKey(language, v.DictLabel)
break
}
}
// dataScope := row.DataScope
// for _, v := range dictSysRoleDatascope {
// if row.DataScope == v.DictValue {
// dataScope = i18n.TKey(language, v.DictLabel)
// break
// }
// }
// 角色状态
statusValue := i18n.TKey(language, "dictData.disable")
if row.Status == "1" {
@@ -466,8 +473,8 @@ func (s *SysRoleController) Export(c *gin.Context) {
"B" + idx: row.RoleName,
"C" + idx: row.RoleKey,
"D" + idx: row.RoleSort,
"E" + idx: dataScope,
"F" + idx: statusValue,
"E" + idx: statusValue,
// "F" + idx: dataScope,
})
}