From f1c552ff445ce2b4b274632abbca2665bb0a12e1 Mon Sep 17 00:00:00 2001 From: junjie Date: Mon, 7 Jun 2021 15:42:24 +0800 Subject: [PATCH 1/6] =?UTF-8?q?feat(chart):=E8=A1=A8=E6=A0=BCchart?= =?UTF-8?q?=E5=A2=9E=E5=8A=A0id?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../views/chart/components/table/TableNormal.vue | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/frontend/src/views/chart/components/table/TableNormal.vue b/frontend/src/views/chart/components/table/TableNormal.vue index 427dc50ad2..f1198f1e04 100644 --- a/frontend/src/views/chart/components/table/TableNormal.vue +++ b/frontend/src/views/chart/components/table/TableNormal.vue @@ -2,6 +2,7 @@

{{ chart.title }}

{ + this.initStyle() + }) window.onresize = function() { that.calcHeight() } @@ -165,15 +168,18 @@ export default { this.bg_class.background = hexColorToRGBA(customStyle.background.color, customStyle.background.alpha) } } - // 修改footer合计样式 - const s_table = document.getElementsByClassName('elx-table--footer')[0] + const table = document.getElementById(this.chart.id) + const s_table = table.getElementsByClassName('elx-table--footer') // console.log(s_table) let s = '' for (const i in this.table_header_class) { s += (i === 'fontSize' ? 'font-size' : i) + ':' + this.table_header_class[i] + ';' } - s_table.setAttribute('style', s) + console.log(s_table) + for (let i = 0; i < s_table.length; i++) { + s_table[i].setAttribute('style', s) + } }, getRowStyle({ row, rowIndex }) { if (rowIndex % 2 === 0) { From f297fd7aa25900219a2c819b7bfe0266b2765495 Mon Sep 17 00:00:00 2001 From: fit2cloud-chenyw Date: Mon, 7 Jun 2021 16:11:06 +0800 Subject: [PATCH 2/6] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96=20=E6=8E=88?= =?UTF-8?q?=E6=9D=83=E3=80=81=E5=AE=89=E8=A3=85=E6=8F=92=E4=BB=B6=E3=80=81?= =?UTF-8?q?=E6=9B=B4=E6=96=B0lic=E3=80=81lic=E5=88=B0=E6=9C=9F=20=E4=B8=8D?= =?UTF-8?q?=E9=9C=80=E8=A6=81=E9=87=8D=E6=96=B0=E7=99=BB=E5=BD=95(?= =?UTF-8?q?=E9=9C=80=E8=A6=81=E5=88=B7=E6=96=B0=E6=B5=8F=E8=A7=88=E5=99=A8?= =?UTF-8?q?)=E6=89=8D=E8=83=BD=E5=88=B7=E6=96=B0=E6=9D=83=E9=99=90?= =?UTF-8?q?=E6=95=B0=E6=8D=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../io/dataease/auth/config/F2CRealm.java | 7 ++ .../java/io/dataease/auth/util/JWTUtils.java | 3 - .../listener/LicCacheEventListener.java | 80 +++++++++++++++++++ .../io/dataease/listener/util/CacheUtils.java | 61 ++++++++++++++ .../dataease/plugins/server/XAuthServer.java | 12 +++ .../io/dataease/service/AboutService.java | 13 ++- .../dataease/service/sys/PluginService.java | 12 +++ .../src/main/resources/ehcache/ehcache.xml | 13 +++ frontend/src/utils/request.js | 4 + 9 files changed, 201 insertions(+), 4 deletions(-) create mode 100644 backend/src/main/java/io/dataease/listener/LicCacheEventListener.java create mode 100644 backend/src/main/java/io/dataease/listener/util/CacheUtils.java diff --git a/backend/src/main/java/io/dataease/auth/config/F2CRealm.java b/backend/src/main/java/io/dataease/auth/config/F2CRealm.java index c91dbe1ff3..29c269f10f 100644 --- a/backend/src/main/java/io/dataease/auth/config/F2CRealm.java +++ b/backend/src/main/java/io/dataease/auth/config/F2CRealm.java @@ -8,6 +8,8 @@ import io.dataease.auth.entity.TokenInfo; import io.dataease.auth.service.AuthUserService; import io.dataease.auth.util.JWTUtils; import io.dataease.commons.utils.BeanUtils; +import io.dataease.commons.utils.LogUtil; +import io.dataease.listener.util.CacheUtils; import org.apache.shiro.authc.AuthenticationException; import org.apache.shiro.authc.AuthenticationInfo; import org.apache.shiro.authc.AuthenticationToken; @@ -54,6 +56,11 @@ public class F2CRealm extends AuthorizingRealm { @Override protected AuthenticationInfo doGetAuthenticationInfo(AuthenticationToken auth) throws AuthenticationException { + try { + CacheUtils.get("lic_info", "lic"); + }catch (Exception e) { + LogUtil.error(e); + } String token = (String) auth.getCredentials(); // 解密获得username,用于和数据库进行对比 TokenInfo tokenInfo = JWTUtils.tokenInfoByToken(token); diff --git a/backend/src/main/java/io/dataease/auth/util/JWTUtils.java b/backend/src/main/java/io/dataease/auth/util/JWTUtils.java index 8b3b7e4c92..1fa0a37f8f 100644 --- a/backend/src/main/java/io/dataease/auth/util/JWTUtils.java +++ b/backend/src/main/java/io/dataease/auth/util/JWTUtils.java @@ -6,12 +6,9 @@ import com.auth0.jwt.algorithms.Algorithm; import com.auth0.jwt.exceptions.JWTDecodeException; import com.auth0.jwt.interfaces.DecodedJWT; import io.dataease.auth.entity.TokenInfo; -import io.dataease.auth.filter.JWTFilter; import io.dataease.commons.utils.CommonBeanFactory; import org.apache.commons.lang3.ObjectUtils; import org.apache.commons.lang3.StringUtils; -import org.apache.shiro.authc.AuthenticationException; - import org.springframework.core.env.Environment; import java.util.Date; diff --git a/backend/src/main/java/io/dataease/listener/LicCacheEventListener.java b/backend/src/main/java/io/dataease/listener/LicCacheEventListener.java new file mode 100644 index 0000000000..632916a56f --- /dev/null +++ b/backend/src/main/java/io/dataease/listener/LicCacheEventListener.java @@ -0,0 +1,80 @@ +package io.dataease.listener; + +import io.dataease.commons.constants.AuthConstants; +import io.dataease.listener.util.CacheUtils; +import net.sf.ehcache.CacheException; +import net.sf.ehcache.Ehcache; +import net.sf.ehcache.Element; +import net.sf.ehcache.event.CacheEventListener; +import net.sf.ehcache.event.CacheEventListenerFactory; +import org.springframework.stereotype.Component; +import java.util.Properties; + +@Component +public class LicCacheEventListener extends CacheEventListenerFactory implements CacheEventListener { + + private static CacheEventListener cacheEventListener; + + public LicCacheEventListener() { + cacheEventListener = cacheEventListener == null ? this : cacheEventListener; + } + + @Override + public void notifyElementRemoved(Ehcache ehcache, Element element) throws CacheException { + /*System.out.println("notifyElementRemoved");*/ + } + + @Override + public void notifyElementPut(Ehcache ehcache, Element element) throws CacheException { + + /*long expirationTime = element.getExpirationTime(); + System.out.println(expirationTime); + System.out.println("notifyElementPut");*/ + } + + @Override + public void notifyElementUpdated(Ehcache ehcache, Element element) throws CacheException { + /*System.out.println("notifyElementUpdated");*/ + } + + /** + * lic过期触发: 清除用户、角色、权限缓存 + * @param ehcache + * @param element + */ + @Override + public void notifyElementExpired(Ehcache ehcache, Element element) { + // System.out.println("notifyElementExpired"); + /*String token = ServletUtils.getToken(); + Long userId = JWTUtils.tokenInfoByToken(token).getUserId(); + authUserService.clearCache(userId);*/ + CacheUtils.removeAll(AuthConstants.USER_CACHE_NAME); + CacheUtils.removeAll(AuthConstants.USER_ROLE_CACHE_NAME); + CacheUtils.removeAll(AuthConstants.USER_PERMISSION_CACHE_NAME); + } + + @Override + public void notifyElementEvicted(Ehcache ehcache, Element element) { + /*System.out.println("notifyElementEvicted");*/ + } + + @Override + public void notifyRemoveAll(Ehcache ehcache) { + /*System.out.println("notifyRemoveAll");*/ + } + + @Override + public void dispose() { + + } + + @Override + public CacheEventListener createCacheEventListener(Properties properties) { + return cacheEventListener; + } + + @Override + public Object clone() throws CloneNotSupportedException { + return super.clone(); + } +} diff --git a/backend/src/main/java/io/dataease/listener/util/CacheUtils.java b/backend/src/main/java/io/dataease/listener/util/CacheUtils.java new file mode 100644 index 0000000000..09e656315a --- /dev/null +++ b/backend/src/main/java/io/dataease/listener/util/CacheUtils.java @@ -0,0 +1,61 @@ +package io.dataease.listener.util; + +import net.sf.ehcache.Cache; +import net.sf.ehcache.Element; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.cache.CacheManager; +import org.springframework.cache.ehcache.EhCacheCacheManager; +import org.springframework.context.annotation.Configuration; +import java.util.Date; + +@Configuration +public class CacheUtils { + + private static CacheManager manager; + + @Autowired + public void setManager(CacheManager manager) { + CacheUtils.manager = manager; + } + + public static Object get(String cacheName, Object key) { + Element element = cache(cacheName).get(key); + if (null == element) return null; + return element.getObjectValue(); + } + + private static void put(String cacheName, Object key, Object value, Integer ttl, Integer tti) { + Element e = new Element(key, value); + //不设置则使用xml配置 + if (ttl != null) + e.setEternal(false); + e.setTimeToLive(ttl); + if (tti != null) + e.setTimeToIdle(tti); + cache(cacheName).put(e); + } + + private static boolean remove(String cacheName, Object key) { + return cache(cacheName).remove(key); + } + + public static void removeAll(String cacheName) { + cache(cacheName).removeAll(); + } + + private static Cache cache(String cacheName) { + net.sf.ehcache.CacheManager cacheManager = ((EhCacheCacheManager) manager).getCacheManager(); + if (!cacheManager.cacheExists(cacheName)) + cacheManager.addCache(cacheName); + Cache cacheManagerCache = cacheManager.getCache(cacheName); + return cacheManagerCache; + } + + public static void updateLicCache(Date expDate){ + long time = expDate.getTime(); + long exp = (time - System.currentTimeMillis()) / 1000; + int intExp = (int)exp; + removeAll("lic_info"); + put("lic_info", "lic", "lic", intExp, intExp); + } +} diff --git a/backend/src/main/java/io/dataease/plugins/server/XAuthServer.java b/backend/src/main/java/io/dataease/plugins/server/XAuthServer.java index 3c7d0665d4..9121d531d1 100644 --- a/backend/src/main/java/io/dataease/plugins/server/XAuthServer.java +++ b/backend/src/main/java/io/dataease/plugins/server/XAuthServer.java @@ -2,18 +2,22 @@ package io.dataease.plugins.server; import io.dataease.auth.api.dto.CurrentUserDto; +import io.dataease.commons.constants.AuthConstants; import io.dataease.commons.utils.AuthUtils; import io.dataease.controller.handler.annotation.I18n; +import io.dataease.listener.util.CacheUtils; import io.dataease.plugins.config.SpringContextUtil; import io.dataease.plugins.xpack.auth.dto.request.XpackBaseTreeRequest; import io.dataease.plugins.xpack.auth.dto.request.XpackSysAuthRequest; import io.dataease.plugins.xpack.auth.dto.response.XpackSysAuthDetail; import io.dataease.plugins.xpack.auth.dto.response.XpackSysAuthDetailDTO; import io.dataease.plugins.xpack.auth.dto.response.XpackVAuthModelDTO; +import org.apache.commons.lang3.StringUtils; import org.springframework.web.bind.annotation.*; import io.dataease.plugins.xpack.auth.service.AuthXpackService; import java.util.List; import java.util.Map; +import java.util.Optional; @RequestMapping("/plugin/auth") @RestController @@ -45,5 +49,13 @@ public class XAuthServer { AuthXpackService sysAuthService = SpringContextUtil.getBean(AuthXpackService.class); CurrentUserDto user = AuthUtils.getUser(); sysAuthService.authChange(request, user.getUserId(), user.getUsername(), user.getIsAdmin()); + // 当权限发生变化 前端实时刷新对应菜单 + Optional.ofNullable(request.getAuthSourceType()).ifPresent(type -> { + if (StringUtils.equals("menu", type)) { + CacheUtils.removeAll(AuthConstants.USER_CACHE_NAME); + CacheUtils.removeAll(AuthConstants.USER_ROLE_CACHE_NAME); + CacheUtils.removeAll(AuthConstants.USER_PERMISSION_CACHE_NAME); + } + }); } } diff --git a/backend/src/main/java/io/dataease/service/AboutService.java b/backend/src/main/java/io/dataease/service/AboutService.java index e144a975e9..9568c4f6b9 100644 --- a/backend/src/main/java/io/dataease/service/AboutService.java +++ b/backend/src/main/java/io/dataease/service/AboutService.java @@ -1,16 +1,18 @@ package io.dataease.service; +import io.dataease.commons.constants.AuthConstants; import io.dataease.commons.license.DefaultLicenseService; import io.dataease.commons.license.F2CLicenseResponse; import io.dataease.commons.utils.CommonBeanFactory; import io.dataease.commons.utils.LogUtil; +import io.dataease.listener.util.CacheUtils; import org.apache.commons.io.FileUtils; import org.apache.commons.lang3.StringUtils; import org.springframework.core.env.Environment; import org.springframework.stereotype.Service; - import javax.annotation.Resource; import java.io.File; +import java.util.Date; import java.util.Optional; @Service @@ -23,6 +25,15 @@ public class AboutService { public F2CLicenseResponse updateLicense(String licenseKey) { F2CLicenseResponse f2CLicenseResponse = defaultLicenseService.updateLicense(product, licenseKey); + Optional.ofNullable(f2CLicenseResponse).ifPresent(resp -> { + if (resp.getStatus() == F2CLicenseResponse.Status.valid){ + CacheUtils.updateLicCache(new Date(f2CLicenseResponse.getLicense().getExpired())); + + CacheUtils.removeAll(AuthConstants.USER_CACHE_NAME); + CacheUtils.removeAll(AuthConstants.USER_ROLE_CACHE_NAME); + CacheUtils.removeAll(AuthConstants.USER_PERMISSION_CACHE_NAME); + } + }); return f2CLicenseResponse; } diff --git a/backend/src/main/java/io/dataease/service/sys/PluginService.java b/backend/src/main/java/io/dataease/service/sys/PluginService.java index b911103bcf..880a5df0c9 100644 --- a/backend/src/main/java/io/dataease/service/sys/PluginService.java +++ b/backend/src/main/java/io/dataease/service/sys/PluginService.java @@ -5,9 +5,11 @@ import io.dataease.base.domain.MyPlugin; import io.dataease.base.mapper.MyPluginMapper; import io.dataease.base.mapper.ext.ExtSysPluginMapper; import io.dataease.base.mapper.ext.query.GridExample; +import io.dataease.commons.constants.AuthConstants; import io.dataease.commons.utils.DeFileUtils; import io.dataease.commons.utils.ZipUtils; import io.dataease.controller.sys.base.BaseGridRequest; +import io.dataease.listener.util.CacheUtils; import io.dataease.plugins.config.LoadjarUtil; import org.apache.commons.lang3.ArrayUtils; import org.apache.commons.lang3.StringUtils; @@ -89,6 +91,10 @@ public class PluginService { jarPath = DeFileUtils.copy(jarFile, targetDir); loadJar(jarPath, myPlugin); myPluginMapper.insert(myPlugin); + + CacheUtils.removeAll(AuthConstants.USER_CACHE_NAME); + CacheUtils.removeAll(AuthConstants.USER_ROLE_CACHE_NAME); + CacheUtils.removeAll(AuthConstants.USER_PERMISSION_CACHE_NAME); } catch (Exception e) { if (StringUtils.isNotEmpty(targetDir)) { DeFileUtils.deleteFile(targetDir); @@ -137,6 +143,9 @@ public class PluginService { * @return */ public Boolean uninstall(Long pluginId) { + CacheUtils.removeAll(AuthConstants.USER_CACHE_NAME); + CacheUtils.removeAll(AuthConstants.USER_ROLE_CACHE_NAME); + CacheUtils.removeAll(AuthConstants.USER_PERMISSION_CACHE_NAME); myPluginMapper.deleteByPrimaryKey(pluginId); return true; } @@ -148,6 +157,9 @@ public class PluginService { * @return */ public Boolean changeStatus(Long pluginId, Boolean status) { + CacheUtils.removeAll(AuthConstants.USER_CACHE_NAME); + CacheUtils.removeAll(AuthConstants.USER_ROLE_CACHE_NAME); + CacheUtils.removeAll(AuthConstants.USER_PERMISSION_CACHE_NAME); return false; } diff --git a/backend/src/main/resources/ehcache/ehcache.xml b/backend/src/main/resources/ehcache/ehcache.xml index 9491e0fa0d..a85f1cbf10 100644 --- a/backend/src/main/resources/ehcache/ehcache.xml +++ b/backend/src/main/resources/ehcache/ehcache.xml @@ -69,5 +69,18 @@ memoryStoreEvictionPolicy="LRU" /> + + + + \ No newline at end of file diff --git a/frontend/src/utils/request.js b/frontend/src/utils/request.js index e3e39b01a8..f7d7a837fc 100644 --- a/frontend/src/utils/request.js +++ b/frontend/src/utils/request.js @@ -83,6 +83,10 @@ const checkAuth = response => { const linkToken = response.headers[LinkTokenKey.toLocaleLowerCase()] setLinkToken(linkToken) } + // 许可状态改变 刷新页面 +// if (response.headers['lic-status']) { +// location.reload() +// } } // 请根据实际需求修改 From e520101af1ec9b4b54171d09b9f4d1f3a7f16725 Mon Sep 17 00:00:00 2001 From: fit2cloud-chenyw Date: Mon, 7 Jun 2021 17:08:57 +0800 Subject: [PATCH 3/6] =?UTF-8?q?feat:=20=E6=A0=BC=E5=BC=8F=E5=8C=96?= =?UTF-8?q?=E5=89=8D=E7=AB=AF=E6=8A=A5=E9=94=99=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../canvas/components/Editor/Shape.vue | 10 ++- .../canvas/custom-component/UserView.vue | 64 +++++++++---------- .../system/authority/components/LazyTree.vue | 8 ++- .../src/views/system/datasource/index.vue | 2 +- 4 files changed, 44 insertions(+), 40 deletions(-) diff --git a/frontend/src/components/canvas/components/Editor/Shape.vue b/frontend/src/components/canvas/components/Editor/Shape.vue index 2fdc44c1b8..2191c2886e 100644 --- a/frontend/src/components/canvas/components/Editor/Shape.vue +++ b/frontend/src/components/canvas/components/Editor/Shape.vue @@ -36,15 +36,18 @@ export default { }, element: { require: true, - type: Object + type: Object, + default: null }, defaultStyle: { require: true, - type: Object + type: Object, + default: null }, index: { require: true, - type: [Number, String] + type: [Number, String], + default: null } }, data() { @@ -200,6 +203,7 @@ export default { pointList.forEach(point => { const angle = mod360(initialAngle[point] + rotate) const len = angleToCursor.length + // eslint-disable-next-line no-constant-condition while (true) { lastMatchIndex = (lastMatchIndex + 1) % len const angleLimit = angleToCursor[lastMatchIndex] diff --git a/frontend/src/components/canvas/custom-component/UserView.vue b/frontend/src/components/canvas/custom-component/UserView.vue index aef84fac77..77a6809e46 100644 --- a/frontend/src/components/canvas/custom-component/UserView.vue +++ b/frontend/src/components/canvas/custom-component/UserView.vue @@ -40,7 +40,8 @@ export default { components: { ChartComponent, TableNormal, LabelNormal }, props: { element: { - type: Object + type: Object, + default: null }, filter: { type: Object, @@ -59,38 +60,6 @@ export default { } } }, - watch: { - '$store.getters.conditions': function(newVal, oldVal) { - this.filter.filter = newVal - this.getData(this.element.propValue.viewId) - }, - filter(val) { - this.getData(this.element.propValue.viewId) - }, - // deep监听panel 如果改变 提交到 store - canvasStyleData: { - handler(newVal, oldVla) { - // this.chart.stylePriority == panel 优先使用仪表板样式 - this.mergeStyle() - }, - deep: true - }, - // 监听外部的样式变化 - outStyle: { - handler(newVal, oldVla) { - if (this.$refs[this.element.propValue.id]) { - this.$refs[this.element.propValue.id].chartResize() - } - }, - deep: true - } - }, - created() { - this.refId = uuid.v1 - }, - computed: mapState([ - 'canvasStyleData' - ]), data() { return { refId: null, @@ -120,8 +89,35 @@ export default { message: null } }, + computed: mapState([ + 'canvasStyleData' + ]), + watch: { + filter(val) { + this.getData(this.element.propValue.viewId) + }, + // deep监听panel 如果改变 提交到 store + canvasStyleData: { + handler(newVal, oldVla) { + // this.chart.stylePriority == panel 优先使用仪表板样式 + this.mergeStyle() + }, + deep: true + }, + // 监听外部的样式变化 + outStyle: { + handler(newVal, oldVla) { + if (this.$refs[this.element.propValue.id]) { + this.$refs[this.element.propValue.id].chartResize() + } + }, + deep: true + } + }, + created() { - this.filter.filter = this.$store.getters.conditions + this.refId = uuid.v1 + // this.filter.filter = this.$store.getters.conditions this.getData(this.element.propValue.viewId) }, mounted() { diff --git a/frontend/src/views/system/authority/components/LazyTree.vue b/frontend/src/views/system/authority/components/LazyTree.vue index 126e2f0b92..c341d1cb1c 100644 --- a/frontend/src/views/system/authority/components/LazyTree.vue +++ b/frontend/src/views/system/authority/components/LazyTree.vue @@ -57,7 +57,8 @@ export default { }, authCondition: { type: Object, - required: false + required: false, + default: null }, dataInfo: { type: Object, @@ -67,7 +68,10 @@ export default { type: String, required: true }, - attachActiveName: String, + attachActiveName: { + type: String, + default: null + }, defaultProps: { type: Object, required: false, diff --git a/frontend/src/views/system/datasource/index.vue b/frontend/src/views/system/datasource/index.vue index f3c0b77c96..f476f3c2b7 100644 --- a/frontend/src/views/system/datasource/index.vue +++ b/frontend/src/views/system/datasource/index.vue @@ -92,7 +92,7 @@ import LayoutContent from '@/components/business/LayoutContent' import ComplexTable from '@/components/business/complex-table' -import { checkPermission, hasDataPermission } from '@/utils/permission' +import { hasDataPermission } from '@/utils/permission' import { formatCondition } from '@/utils/index' import { dsGrid, addDs, editDs, delDs, validateDs } from '@/api/system/datasource' From 198208fc8c692d326f1545ba729ae9d5c0270ae7 Mon Sep 17 00:00:00 2001 From: fit2cloud-chenyw Date: Mon, 7 Jun 2021 17:11:33 +0800 Subject: [PATCH 4/6] =?UTF-8?q?feat:=20=E5=88=A0=E9=99=A4debugger=E5=92=8C?= =?UTF-8?q?console.log?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- frontend/src/utils/permission.js | 1 - frontend/src/views/panel/list/EditPanel/index.vue | 1 - frontend/src/views/system/role/index.vue | 2 +- frontend/src/views/system/systemParamSettings/EmailSetting.vue | 2 +- 4 files changed, 2 insertions(+), 4 deletions(-) diff --git a/frontend/src/utils/permission.js b/frontend/src/utils/permission.js index faffd0c727..db5b34a68e 100644 --- a/frontend/src/utils/permission.js +++ b/frontend/src/utils/permission.js @@ -9,7 +9,6 @@ export function checkPermission(pers) { } export function hasDataPermission(pTarget, pSource) { - debugger if (pSource && pTarget) { return pSource.indexOf(pTarget) > -1 } diff --git a/frontend/src/views/panel/list/EditPanel/index.vue b/frontend/src/views/panel/list/EditPanel/index.vue index 277004fab7..7583d3b31b 100644 --- a/frontend/src/views/panel/list/EditPanel/index.vue +++ b/frontend/src/views/panel/list/EditPanel/index.vue @@ -82,7 +82,6 @@ export default { }, methods: { showCurrentTemplateInfo(data) { - debugger this.editPanel.panelInfo.name = data.name this.editPanel.panelInfo.panelStyle = data.templateStyle this.editPanel.panelInfo.panelData = data.templateData diff --git a/frontend/src/views/system/role/index.vue b/frontend/src/views/system/role/index.vue index b3cb42f3ba..27a2399d88 100644 --- a/frontend/src/views/system/role/index.vue +++ b/frontend/src/views/system/role/index.vue @@ -146,7 +146,7 @@ export default { }, methods: { handleClick(tab, event) { - console.log(tab, event) + // console.log(tab, event) }, create() { this.$router.push({ name: 'system-role-form' }) diff --git a/frontend/src/views/system/systemParamSettings/EmailSetting.vue b/frontend/src/views/system/systemParamSettings/EmailSetting.vue index 7ec25228fa..1f529b79a5 100644 --- a/frontend/src/views/system/systemParamSettings/EmailSetting.vue +++ b/frontend/src/views/system/systemParamSettings/EmailSetting.vue @@ -152,7 +152,7 @@ export default { this.formInline = response.data this.formInline.ssl = this.formInline.ssl === 'true' this.formInline.tls = this.formInline.tls === 'true' - console.log(this.formInline) + // console.log(this.formInline) this.$nextTick(() => { this.$refs.formInline.clearValidate() }) From 0195edea45747fd31192f2b14ba8cbeb50130fa9 Mon Sep 17 00:00:00 2001 From: junjie Date: Tue, 8 Jun 2021 11:12:40 +0800 Subject: [PATCH 5/6] =?UTF-8?q?feat(=E6=95=B0=E6=8D=AE=E9=9B=86):=E7=BC=96?= =?UTF-8?q?=E8=BE=91excel=E5=89=8D=E7=AB=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- frontend/src/lang/en.js | 6 +++- frontend/src/lang/tw.js | 8 +++-- frontend/src/lang/zh.js | 6 +++- frontend/src/views/dataset/add/AddExcel.vue | 7 ++-- frontend/src/views/dataset/data/ViewTable.vue | 35 +++++++++++++++++-- 5 files changed, 53 insertions(+), 9 deletions(-) diff --git a/frontend/src/lang/en.js b/frontend/src/lang/en.js index 4542e1f208..6ca12bd0d0 100644 --- a/frontend/src/lang/en.js +++ b/frontend/src/lang/en.js @@ -830,7 +830,11 @@ export default { preview_100_data: 'Show 100 lines data', invalid_table_check: 'Please sync data first.', parse_error: 'Parse Error', - origin_field_type: 'Origin Type' + origin_field_type: 'Origin Type', + edit_excel_table: 'Edit Excel Dataset', + edit_excel: 'Edit Excel', + excel_replace: 'Replace', + excel_add: 'Add' }, datasource: { datasource: 'Data Source', diff --git a/frontend/src/lang/tw.js b/frontend/src/lang/tw.js index 87b36e018b..755f7438db 100644 --- a/frontend/src/lang/tw.js +++ b/frontend/src/lang/tw.js @@ -797,7 +797,7 @@ export default { param: '參數', edit_sql: '編輯 SQL', showRow: '顯示行', - add_excel_table: ' 添加 Excel 數據集', + add_excel_table: ' 添加Excel數據集', add_custom_table: '添加自助數據集', upload_file: '上傳文件', detail: '詳情', @@ -830,7 +830,11 @@ export default { preview_100_data: '顯示前100行數據', invalid_table_check: '非直連數據集請先完成數據同步', parse_error: '解析錯誤', - origin_field_type: '原始類型' + origin_field_type: '原始類型', + edit_excel_table: '編輯Excel數據集', + edit_excel: '編輯Excel', + excel_replace: '替換', + excel_add: '追加' }, datasource: { datasource: '數據源', diff --git a/frontend/src/lang/zh.js b/frontend/src/lang/zh.js index 4ac04da602..977e1530bb 100644 --- a/frontend/src/lang/zh.js +++ b/frontend/src/lang/zh.js @@ -830,7 +830,11 @@ export default { preview_100_data: '显示前100行数据', invalid_table_check: '非直连数据集请先完成数据同步', parse_error: '解析错误', - origin_field_type: '原始类型' + origin_field_type: '原始类型', + edit_excel_table: '编辑Excel数据集', + edit_excel: '编辑Excel', + excel_replace: '替换', + excel_add: '追加' }, datasource: { datasource: '数据源', diff --git a/frontend/src/views/dataset/add/AddExcel.vue b/frontend/src/views/dataset/add/AddExcel.vue index 48b6eede1b..a93aad123d 100644 --- a/frontend/src/views/dataset/add/AddExcel.vue +++ b/frontend/src/views/dataset/add/AddExcel.vue @@ -3,7 +3,7 @@ - {{ $t('dataset.add_excel_table') }} + {{ param.tableId?$t('dataset.edit_excel_table'):$t('dataset.add_excel_table') }} @@ -20,7 +20,7 @@ - + { this.$store.dispatch('dataset/setSceneData', new Date().getTime()) diff --git a/frontend/src/views/dataset/data/ViewTable.vue b/frontend/src/views/dataset/data/ViewTable.vue index e466a18a98..4326fb470a 100644 --- a/frontend/src/views/dataset/data/ViewTable.vue +++ b/frontend/src/views/dataset/data/ViewTable.vue @@ -14,6 +14,19 @@ + + + {{ $t('dataset.edit_excel') }} + + + + {{ $t('dataset.excel_replace') }} + + + {{ $t('dataset.excel_add') }} + + + {{ $t('dataset.edit_custom_table') }} @@ -108,10 +121,10 @@ export default { this.fields = response.data.fields this.data = response.data.data this.page = response.data.page - if(response.data.status === 'warnning'){ + if (response.data.status === 'warnning') { this.$warning(response.data.msg, 3000) } - if(response.data.status === 'error') { + if (response.data.status === 'error') { this.$error(response.data.msg, 3000) } }).catch(response => { @@ -147,6 +160,24 @@ export default { }, hideTab() { this.tabStatus = false + }, + + clickEditExcel(param) { + // console.log(param); + switch (param.type) { + case '0': + this.$emit('switchComponent', { name: 'AddExcel', param: { id: this.table.sceneId, tableId: this.table.id, editType: 0 }}) + break + case '1': + this.$emit('switchComponent', { name: 'AddExcel', param: { id: this.table.sceneId, tableId: this.table.id, editType: 1 }}) + break + } + }, + + beforeEditExcel(type) { + return { + 'type': type + } } } } From c839b3cba4fdb12cee0e0c6dc817156192a25f58 Mon Sep 17 00:00:00 2001 From: junjie Date: Tue, 8 Jun 2021 11:30:26 +0800 Subject: [PATCH 6/6] =?UTF-8?q?feat(=E6=95=B0=E6=8D=AE=E9=9B=86):=E7=BC=96?= =?UTF-8?q?=E8=BE=91excel=E5=89=8D=E7=AB=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../dataset/DataSetTableController.java | 4 +-- .../request/dataset/DataSetTableRequest.java | 2 ++ .../service/dataset/DataSetTableService.java | 6 ++-- frontend/src/views/dataset/add/AddExcel.vue | 33 +++++++++++++------ frontend/src/views/dataset/data/ViewTable.vue | 4 +-- 5 files changed, 32 insertions(+), 17 deletions(-) diff --git a/backend/src/main/java/io/dataease/controller/dataset/DataSetTableController.java b/backend/src/main/java/io/dataease/controller/dataset/DataSetTableController.java index 7f1a4fe577..b40d009e66 100644 --- a/backend/src/main/java/io/dataease/controller/dataset/DataSetTableController.java +++ b/backend/src/main/java/io/dataease/controller/dataset/DataSetTableController.java @@ -25,12 +25,12 @@ public class DataSetTableController { private DataSetTableService dataSetTableService; @PostMapping("batchAdd") - public void batchAdd(@RequestBody List datasetTable) throws Exception { + public void batchAdd(@RequestBody List datasetTable) throws Exception { dataSetTableService.batchInsert(datasetTable); } @PostMapping("update") - public DatasetTable save(@RequestBody DatasetTable datasetTable) throws Exception { + public DatasetTable save(@RequestBody DataSetTableRequest datasetTable) throws Exception { return dataSetTableService.save(datasetTable); } diff --git a/backend/src/main/java/io/dataease/controller/request/dataset/DataSetTableRequest.java b/backend/src/main/java/io/dataease/controller/request/dataset/DataSetTableRequest.java index 9eea8a6819..2341b12407 100644 --- a/backend/src/main/java/io/dataease/controller/request/dataset/DataSetTableRequest.java +++ b/backend/src/main/java/io/dataease/controller/request/dataset/DataSetTableRequest.java @@ -18,4 +18,6 @@ public class DataSetTableRequest extends DatasetTable { private String row = "1000"; private String userId; + + private Integer editType; } diff --git a/backend/src/main/java/io/dataease/service/dataset/DataSetTableService.java b/backend/src/main/java/io/dataease/service/dataset/DataSetTableService.java index 9c88a595c2..353fd7dea6 100644 --- a/backend/src/main/java/io/dataease/service/dataset/DataSetTableService.java +++ b/backend/src/main/java/io/dataease/service/dataset/DataSetTableService.java @@ -84,13 +84,13 @@ public class DataSetTableService { @Value("${upload.file.path}") private String path; - public void batchInsert(List datasetTable) throws Exception { - for (DatasetTable table : datasetTable) { + public void batchInsert(List datasetTable) throws Exception { + for (DataSetTableRequest table : datasetTable) { save(table); } } - public DatasetTable save(DatasetTable datasetTable) throws Exception { + public DatasetTable save(DataSetTableRequest datasetTable) throws Exception { checkName(datasetTable); if (StringUtils.equalsIgnoreCase(datasetTable.getType(), "sql")) { DataSetTableRequest dataSetTableRequest = new DataSetTableRequest(); diff --git a/frontend/src/views/dataset/add/AddExcel.vue b/frontend/src/views/dataset/add/AddExcel.vue index a93aad123d..e5de317cb3 100644 --- a/frontend/src/views/dataset/add/AddExcel.vue +++ b/frontend/src/views/dataset/add/AddExcel.vue @@ -20,7 +20,7 @@ - + { this.$store.dispatch('dataset/setSceneData', new Date().getTime()) diff --git a/frontend/src/views/dataset/data/ViewTable.vue b/frontend/src/views/dataset/data/ViewTable.vue index 4326fb470a..a331c94b1b 100644 --- a/frontend/src/views/dataset/data/ViewTable.vue +++ b/frontend/src/views/dataset/data/ViewTable.vue @@ -166,10 +166,10 @@ export default { // console.log(param); switch (param.type) { case '0': - this.$emit('switchComponent', { name: 'AddExcel', param: { id: this.table.sceneId, tableId: this.table.id, editType: 0 }}) + this.$emit('switchComponent', { name: 'AddExcel', param: { id: this.table.sceneId, tableId: this.table.id, editType: 0, table: this.table }}) break case '1': - this.$emit('switchComponent', { name: 'AddExcel', param: { id: this.table.sceneId, tableId: this.table.id, editType: 1 }}) + this.$emit('switchComponent', { name: 'AddExcel', param: { id: this.table.sceneId, tableId: this.table.id, editType: 1, table: this.table }}) break } },