From 28b9fbb4d270855e8d6fdbbbbc584e8e08f7abde Mon Sep 17 00:00:00 2001 From: RuoYi Date: Tue, 19 Jul 2022 15:55:03 +0800 Subject: [PATCH 1/5] =?UTF-8?q?=E4=BC=98=E5=8C=96=E5=A4=9A=E4=B8=AA?= =?UTF-8?q?=E7=9B=B8=E5=90=8C=E8=A7=92=E8=89=B2=E6=95=B0=E6=8D=AE=E5=AF=BC?= =?UTF-8?q?=E8=87=B4=E6=9D=83=E9=99=90SQL=E9=87=8D=E5=A4=8D=E9=97=AE?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/ruoyi/framework/aspectj/DataScopeAspect.java | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/ruoyi-framework/src/main/java/com/ruoyi/framework/aspectj/DataScopeAspect.java b/ruoyi-framework/src/main/java/com/ruoyi/framework/aspectj/DataScopeAspect.java index ff84bcdd..5b0215cb 100644 --- a/ruoyi-framework/src/main/java/com/ruoyi/framework/aspectj/DataScopeAspect.java +++ b/ruoyi-framework/src/main/java/com/ruoyi/framework/aspectj/DataScopeAspect.java @@ -1,5 +1,7 @@ package com.ruoyi.framework.aspectj; +import java.util.ArrayList; +import java.util.List; import org.aspectj.lang.JoinPoint; import org.aspectj.lang.annotation.Aspect; import org.aspectj.lang.annotation.Before; @@ -79,15 +81,21 @@ public class DataScopeAspect * * @param joinPoint 切点 * @param user 用户 - * @param userAlias 别名 + * @param deptAlias 部门别名 + * @param userAlias 用户别名 */ public static void dataScopeFilter(JoinPoint joinPoint, SysUser user, String deptAlias, String userAlias) { StringBuilder sqlString = new StringBuilder(); + List conditions = new ArrayList(); for (SysRole role : user.getRoles()) { String dataScope = role.getDataScope(); + if (conditions.contains(dataScope)) + { + continue; + } if (DATA_SCOPE_ALL.equals(dataScope)) { sqlString = new StringBuilder(); @@ -121,6 +129,7 @@ public class DataScopeAspect sqlString.append(StringUtils.format(" OR {}.dept_id = 0 ", deptAlias)); } } + conditions.add(dataScope); } if (StringUtils.isNotBlank(sqlString.toString())) From 1f0e742710af7917ecde23a761acd7c28ea3dd53 Mon Sep 17 00:00:00 2001 From: RuoYi Date: Wed, 20 Jul 2022 09:39:58 +0800 Subject: [PATCH 2/5] =?UTF-8?q?Excel=E6=B3=A8=E8=A7=A3=E6=94=AF=E6=8C=81ba?= =?UTF-8?q?ckgroundColor=E5=B1=9E=E6=80=A7=E8=AE=BE=E7=BD=AE=E8=83=8C?= =?UTF-8?q?=E6=99=AF=E8=89=B2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/ruoyi/common/annotation/Excel.java | 17 ++++- .../com/ruoyi/common/utils/poi/ExcelUtil.java | 64 +++++++++++++------ 2 files changed, 60 insertions(+), 21 deletions(-) diff --git a/ruoyi-common/src/main/java/com/ruoyi/common/annotation/Excel.java b/ruoyi-common/src/main/java/com/ruoyi/common/annotation/Excel.java index a57529b7..804db72f 100644 --- a/ruoyi-common/src/main/java/com/ruoyi/common/annotation/Excel.java +++ b/ruoyi-common/src/main/java/com/ruoyi/common/annotation/Excel.java @@ -109,7 +109,22 @@ public @interface Excel public ColumnType cellType() default ColumnType.STRING; /** - * 导出字体颜色 + * 导出列头背景色 + */ + public IndexedColors headerBackgroundColor() default IndexedColors.GREY_50_PERCENT; + + /** + * 导出列头字体颜色 + */ + public IndexedColors headerColor() default IndexedColors.WHITE; + + /** + * 导出单元格背景色 + */ + public IndexedColors backgroundColor() default IndexedColors.WHITE; + + /** + * 导出单元格字体颜色 */ public IndexedColors color() default IndexedColors.BLACK; diff --git a/ruoyi-common/src/main/java/com/ruoyi/common/utils/poi/ExcelUtil.java b/ruoyi-common/src/main/java/com/ruoyi/common/utils/poi/ExcelUtil.java index e868511a..724f69c2 100644 --- a/ruoyi-common/src/main/java/com/ruoyi/common/utils/poi/ExcelUtil.java +++ b/ruoyi-common/src/main/java/com/ruoyi/common/utils/poi/ExcelUtil.java @@ -649,20 +649,6 @@ public class ExcelUtil style.setFont(dataFont); styles.put("data", style); - style = wb.createCellStyle(); - style.cloneStyleFrom(styles.get("data")); - style.setAlignment(HorizontalAlignment.CENTER); - style.setVerticalAlignment(VerticalAlignment.CENTER); - style.setFillForegroundColor(IndexedColors.GREY_50_PERCENT.getIndex()); - style.setFillPattern(FillPatternType.SOLID_FOREGROUND); - Font headerFont = wb.createFont(); - headerFont.setFontName("Arial"); - headerFont.setFontHeightInPoints((short) 10); - headerFont.setBold(true); - headerFont.setColor(IndexedColors.WHITE.getIndex()); - style.setFont(headerFont); - styles.put("header", style); - style = wb.createCellStyle(); style.setAlignment(HorizontalAlignment.CENTER); style.setVerticalAlignment(VerticalAlignment.CENTER); @@ -672,24 +658,60 @@ public class ExcelUtil style.setFont(totalFont); styles.put("total", style); - styles.putAll(annotationStyles(wb)); + styles.putAll(annotationHeaderStyles(wb, styles)); + + styles.putAll(annotationDataStyles(wb)); return styles; } /** - * 根据Excel注解创建表格样式 + * 根据Excel注解创建表格头样式 * * @param wb 工作薄对象 * @return 自定义样式列表 */ - private Map annotationStyles(Workbook wb) + private Map annotationHeaderStyles(Workbook wb, Map styles) + { + Map headerStyles = new HashMap(); + for (Object[] os : fields) + { + Excel excel = (Excel) os[1]; + String key = StringUtils.format("header_{}_{}", excel.headerColor(), excel.headerBackgroundColor()); + if (!headerStyles.containsKey(key)) + { + CellStyle style = wb.createCellStyle(); + style = wb.createCellStyle(); + style.cloneStyleFrom(styles.get("data")); + style.setAlignment(HorizontalAlignment.CENTER); + style.setVerticalAlignment(VerticalAlignment.CENTER); + style.setFillForegroundColor(excel.headerBackgroundColor().index); + style.setFillPattern(FillPatternType.SOLID_FOREGROUND); + Font headerFont = wb.createFont(); + headerFont.setFontName("Arial"); + headerFont.setFontHeightInPoints((short) 10); + headerFont.setBold(true); + headerFont.setColor(excel.headerColor().index); + style.setFont(headerFont); + headerStyles.put(key, style); + } + } + return headerStyles; + } + + /** + * 根据Excel注解创建表格列样式 + * + * @param wb 工作薄对象 + * @return 自定义样式列表 + */ + private Map annotationDataStyles(Workbook wb) { Map styles = new HashMap(); for (Object[] os : fields) { Excel excel = (Excel) os[1]; - String key = "data_" + excel.align() + "_" + excel.color(); + String key = StringUtils.format("data_{}_{}_{}", excel.align(), excel.color(), excel.backgroundColor()); if (!styles.containsKey(key)) { CellStyle style = wb.createCellStyle(); @@ -704,6 +726,8 @@ public class ExcelUtil style.setTopBorderColor(IndexedColors.GREY_50_PERCENT.getIndex()); style.setBorderBottom(BorderStyle.THIN); style.setBottomBorderColor(IndexedColors.GREY_50_PERCENT.getIndex()); + style.setFillPattern(FillPatternType.SOLID_FOREGROUND); + style.setFillForegroundColor(excel.backgroundColor().getIndex()); Font dataFont = wb.createFont(); dataFont.setFontName("Arial"); dataFont.setFontHeightInPoints((short) 10); @@ -725,7 +749,7 @@ public class ExcelUtil // 写入列信息 cell.setCellValue(attr.name()); setDataValidation(attr, row, column); - cell.setCellStyle(styles.get("header")); + cell.setCellStyle(styles.get(StringUtils.format("header_{}_{}", attr.headerColor(), attr.headerBackgroundColor()))); return cell; } @@ -833,7 +857,7 @@ public class ExcelUtil { // 创建cell cell = row.createCell(column); - cell.setCellStyle(styles.get("data_" + attr.align() + "_" + attr.color())); + cell.setCellStyle(styles.get(StringUtils.format("data_{}_{}_{}", attr.align(), attr.color(), attr.backgroundColor()))); // 用于读取对象中的属性 Object value = getTargetValue(vo, field, attr); From 5ec5e1a65d678d441cd03d1b775423c77dbc8b00 Mon Sep 17 00:00:00 2001 From: RuoYi Date: Wed, 20 Jul 2022 19:38:16 +0800 Subject: [PATCH 3/5] =?UTF-8?q?=E4=BC=98=E5=8C=96=E5=AD=97=E5=85=B8?= =?UTF-8?q?=E6=95=B0=E6=8D=AE=E4=BD=BF=E7=94=A8store=E5=AD=98=E5=8F=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ruoyi-ui/src/components/DictData/index.js | 30 +++++++++++++- ruoyi-ui/src/store/getters.js | 1 + ruoyi-ui/src/store/index.js | 2 + ruoyi-ui/src/store/modules/dict.js | 50 +++++++++++++++++++++++ ruoyi-ui/src/views/system/dict/data.vue | 3 ++ ruoyi-ui/src/views/system/dict/index.vue | 1 + 6 files changed, 86 insertions(+), 1 deletion(-) create mode 100644 ruoyi-ui/src/store/modules/dict.js diff --git a/ruoyi-ui/src/components/DictData/index.js b/ruoyi-ui/src/components/DictData/index.js index 24e3e9c8..d43d8165 100644 --- a/ruoyi-ui/src/components/DictData/index.js +++ b/ruoyi-ui/src/components/DictData/index.js @@ -1,7 +1,23 @@ import Vue from 'vue' +import store from '@/store' import DataDict from '@/utils/dict' import { getDicts as getDicts } from '@/api/system/dict/data' +function searchDictByKey(dict, key) { + if (key == null && key == "") { + return null + } + try { + for (let i = 0; i < dict.length; i++) { + if (dict[i].key == key) { + return dict[i].value + } + } + } catch (e) { + return null + } +} + function install() { Vue.use(DataDict, { metas: { @@ -9,7 +25,19 @@ function install() { labelField: 'dictLabel', valueField: 'dictValue', request(dictMeta) { - return getDicts(dictMeta.type).then(res => res.data) + const storeDict = searchDictByKey(store.getters.dict, dictMeta.type) + if (storeDict) { + return new Promise(resolve => { resolve(storeDict) }) + } else { + return new Promise((resolve, reject) => { + getDicts(dictMeta.type).then(res => { + store.dispatch('dict/setDict', { key: dictMeta.type, value: res.data }) + resolve(res.data) + }).catch(error => { + reject(error) + }) + }) + } }, }, }, diff --git a/ruoyi-ui/src/store/getters.js b/ruoyi-ui/src/store/getters.js index 8d723813..5920c6e8 100644 --- a/ruoyi-ui/src/store/getters.js +++ b/ruoyi-ui/src/store/getters.js @@ -2,6 +2,7 @@ const getters = { sidebar: state => state.app.sidebar, size: state => state.app.size, device: state => state.app.device, + dict: state => state.dict.dict, visitedViews: state => state.tagsView.visitedViews, cachedViews: state => state.tagsView.cachedViews, token: state => state.user.token, diff --git a/ruoyi-ui/src/store/index.js b/ruoyi-ui/src/store/index.js index eceb2cd2..2ee6e43b 100644 --- a/ruoyi-ui/src/store/index.js +++ b/ruoyi-ui/src/store/index.js @@ -1,6 +1,7 @@ import Vue from 'vue' import Vuex from 'vuex' import app from './modules/app' +import dict from './modules/dict' import user from './modules/user' import tagsView from './modules/tagsView' import permission from './modules/permission' @@ -12,6 +13,7 @@ Vue.use(Vuex) const store = new Vuex.Store({ modules: { app, + dict, user, tagsView, permission, diff --git a/ruoyi-ui/src/store/modules/dict.js b/ruoyi-ui/src/store/modules/dict.js new file mode 100644 index 00000000..f48df422 --- /dev/null +++ b/ruoyi-ui/src/store/modules/dict.js @@ -0,0 +1,50 @@ +const state = { + dict: new Array() +} +const mutations = { + SET_DICT: (state, { key, value }) => { + if (key !== null && key !== "") { + state.dict.push({ + key: key, + value: value + }) + } + }, + REMOVE_DICT: (state, key) => { + try { + for (let i = 0; i < state.dict.length; i++) { + if (state.dict[i].key == key) { + state.dict.splice(i, i) + return true + } + } + } catch (e) { + } + }, + CLEAN_DICT: (state) => { + state.dict = new Array() + } +} + +const actions = { + // 设置字典 + setDict({ commit }, data) { + commit('SET_DICT', data) + }, + // 删除字典 + removeDict({ commit }, key) { + commit('REMOVE_DICT', key) + }, + // 清空字典 + cleanDict({ commit }) { + commit('CLEAN_DICT') + } +} + +export default { + namespaced: true, + state, + mutations, + actions +} + diff --git a/ruoyi-ui/src/views/system/dict/data.vue b/ruoyi-ui/src/views/system/dict/data.vue index a68a6012..d78af129 100644 --- a/ruoyi-ui/src/views/system/dict/data.vue +++ b/ruoyi-ui/src/views/system/dict/data.vue @@ -364,12 +364,14 @@ export default { if (valid) { if (this.form.dictCode != undefined) { updateData(this.form).then(response => { + this.$store.dispatch('dict/removeDict', this.queryParams.dictType); this.$modal.msgSuccess("修改成功"); this.open = false; this.getList(); }); } else { addData(this.form).then(response => { + this.$store.dispatch('dict/removeDict', this.queryParams.dictType); this.$modal.msgSuccess("新增成功"); this.open = false; this.getList(); @@ -386,6 +388,7 @@ export default { }).then(() => { this.getList(); this.$modal.msgSuccess("删除成功"); + this.$store.dispatch('dict/removeDict', this.queryParams.dictType); }).catch(() => {}); }, /** 导出按钮操作 */ diff --git a/ruoyi-ui/src/views/system/dict/index.vue b/ruoyi-ui/src/views/system/dict/index.vue index d26d1406..13a5f3d4 100644 --- a/ruoyi-ui/src/views/system/dict/index.vue +++ b/ruoyi-ui/src/views/system/dict/index.vue @@ -339,6 +339,7 @@ export default { handleRefreshCache() { refreshCache().then(() => { this.$modal.msgSuccess("刷新成功"); + this.$store.dispatch('dict/cleanDict'); }); } } From bc8b5f107906c7fd37ddbf3d20c099ee952cbd87 Mon Sep 17 00:00:00 2001 From: RuoYi Date: Thu, 21 Jul 2022 08:50:48 +0800 Subject: [PATCH 4/5] =?UTF-8?q?=E4=BC=98=E5=8C=96=E5=B8=83=E5=B1=80?= =?UTF-8?q?=E8=AE=BE=E7=BD=AE=E4=BD=BF=E7=94=A8el-drawer=E6=8A=BD=E5=B1=89?= =?UTF-8?q?=E6=98=BE=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ruoyi-ui/src/components/RightPanel/index.vue | 43 +----- .../src/layout/components/Settings/index.vue | 139 +++++++++--------- 2 files changed, 74 insertions(+), 108 deletions(-) diff --git a/ruoyi-ui/src/components/RightPanel/index.vue b/ruoyi-ui/src/components/RightPanel/index.vue index 1534b9be..42b5a6be 100644 --- a/ruoyi-ui/src/components/RightPanel/index.vue +++ b/ruoyi-ui/src/components/RightPanel/index.vue @@ -1,5 +1,5 @@ - -