From c3e8ae4d41f84b1f9297a73d3fb2e307f89fade7 Mon Sep 17 00:00:00 2001 From: taojinlong Date: Mon, 7 Jun 2021 14:58:56 +0800 Subject: [PATCH 01/54] =?UTF-8?q?fix:=20=E6=8A=BD=E5=8F=96=E6=95=B0?= =?UTF-8?q?=E6=8D=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/io/dataease/service/dataset/ExtractDataService.java | 1 + 1 file changed, 1 insertion(+) diff --git a/backend/src/main/java/io/dataease/service/dataset/ExtractDataService.java b/backend/src/main/java/io/dataease/service/dataset/ExtractDataService.java index 1dd7b19c67..228bc27373 100644 --- a/backend/src/main/java/io/dataease/service/dataset/ExtractDataService.java +++ b/backend/src/main/java/io/dataease/service/dataset/ExtractDataService.java @@ -692,6 +692,7 @@ public class ExtractDataService { tmp_code = tmp_code.replace("handleExcelWraps", handleExcelWraps); }else { tmp_code = tmp_code.replace("handleExcelIntColumn", ""); + tmp_code = tmp_code.replace("handleExcelWraps", ""); } UserDefinedJavaClassDef userDefinedJavaClassDef = new UserDefinedJavaClassDef(UserDefinedJavaClassDef.ClassType.TRANSFORM_CLASS, "Processor", tmp_code); From f1c552ff445ce2b4b274632abbca2665bb0a12e1 Mon Sep 17 00:00:00 2001 From: junjie Date: Mon, 7 Jun 2021 15:42:24 +0800 Subject: [PATCH 02/54] =?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 03/54] =?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 04/54] =?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 05/54] =?UTF-8?q?feat:=20=E5=88=A0=E9=99=A4debugger?= =?UTF-8?q?=E5=92=8Cconsole.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 06/54] =?UTF-8?q?feat(=E6=95=B0=E6=8D=AE=E9=9B=86):?= =?UTF-8?q?=E7=BC=96=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 07/54] =?UTF-8?q?feat(=E6=95=B0=E6=8D=AE=E9=9B=86):?= =?UTF-8?q?=E7=BC=96=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 } }, From a196430d8518e3836f3f3a660c8af12a5534711e Mon Sep 17 00:00:00 2001 From: taojinlong Date: Tue, 8 Jun 2021 12:16:25 +0800 Subject: [PATCH 08/54] =?UTF-8?q?feat:=20=E6=9B=BF=E6=8D=A2svg=20logo?= =?UTF-8?q?=E5=9B=BE=E7=89=87?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- frontend/src/components/SvgIcon/index.vue | 10 ++- frontend/src/icons/svg/DataEase.svg | 86 +++++++++++++++++++ frontend/src/layout/components/Topbar.vue | 3 +- frontend/src/styles/index.scss | 10 +++ frontend/src/utils/permission.js | 1 - frontend/src/views/login/index.vue | 4 +- .../src/views/panel/list/EditPanel/index.vue | 1 - 7 files changed, 108 insertions(+), 7 deletions(-) create mode 100644 frontend/src/icons/svg/DataEase.svg diff --git a/frontend/src/components/SvgIcon/index.vue b/frontend/src/components/SvgIcon/index.vue index 9a3318e5e6..0446ae9079 100644 --- a/frontend/src/components/SvgIcon/index.vue +++ b/frontend/src/components/SvgIcon/index.vue @@ -19,6 +19,10 @@ export default { className: { type: String, default: '' + }, + customClass: { + type: String, + default: '' } }, computed: { @@ -31,9 +35,11 @@ export default { svgClass() { if (this.className) { return 'svg-icon ' + this.className - } else { - return 'svg-icon' } + if (this.customClass) { + return this.customClass + } + return 'svg-icon' }, styleExternalIcon() { return { diff --git a/frontend/src/icons/svg/DataEase.svg b/frontend/src/icons/svg/DataEase.svg new file mode 100644 index 0000000000..c3fdc13e07 --- /dev/null +++ b/frontend/src/icons/svg/DataEase.svg @@ -0,0 +1,86 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/frontend/src/layout/components/Topbar.vue b/frontend/src/layout/components/Topbar.vue index 03c016a265..efc96b11ee 100644 --- a/frontend/src/layout/components/Topbar.vue +++ b/frontend/src/layout/components/Topbar.vue @@ -1,7 +1,8 @@ @@ -32,11 +32,13 @@ export default { props: { config: { type: Object, - require: true + require: true, + default: null }, filter: { type: Object, - require: false + require: false, + default: null } }, mounted() { diff --git a/frontend/src/components/canvas/components/Editor/ContextMenu.vue b/frontend/src/components/canvas/components/Editor/ContextMenu.vue index 81173c5546..d0216824da 100644 --- a/frontend/src/components/canvas/components/Editor/ContextMenu.vue +++ b/frontend/src/components/canvas/components/Editor/ContextMenu.vue @@ -89,7 +89,7 @@ export default { deleteCurCondition() { if (this.curComponent.type === 'custom') { - this.$store.dispatch('conditions/delete', { componentId: this.curComponent.id }) + this.$store.commit('removeViewFilter', this.curComponent.id) bus.$emit('delete-condition', { componentId: this.curComponent.id }) } }, diff --git a/frontend/src/components/canvas/components/Editor/Preview.vue b/frontend/src/components/canvas/components/Editor/Preview.vue index 41fe23c0cb..a0d82477b2 100644 --- a/frontend/src/components/canvas/components/Editor/Preview.vue +++ b/frontend/src/components/canvas/components/Editor/Preview.vue @@ -102,7 +102,7 @@ export default { }, created() { // 先清除查询条件 - this.$store.dispatch('conditions/clear') + // this.$store.dispatch('conditions/clear') }, methods: { changeStyleWithScale, diff --git a/frontend/src/components/canvas/components/Editor/index.vue b/frontend/src/components/canvas/components/Editor/index.vue index 7c5ef1d56c..374cef2f84 100644 --- a/frontend/src/components/canvas/components/Editor/index.vue +++ b/frontend/src/components/canvas/components/Editor/index.vue @@ -40,7 +40,7 @@ :style="getComponentStyle(item.style)" :prop-value="item.propValue" :element="item" - :filter="filter" + :filter="item.filters" :out-style="getShapeStyleInt(item.style)" /> { this.hideArea() }) - bus.$on('delete-condition', condition => { - this.deleteCondition(condition) - }) + // bus.$on('delete-condition', condition => { + // this.deleteCondition(condition) + // }) }, created() { - this.$store.dispatch('conditions/clear') + // this.$store.dispatch('conditions/clear') }, methods: { changeStyleWithScale, @@ -400,40 +395,6 @@ export default { return height > newHeight ? height : newHeight }, - filterValueChange(value) { - // console.log('emit:' + value) - }, - - setConditionValue(obj) { - const { component, value, operator } = obj - const fieldId = component.options.attrs.fieldId - const viewIds = component.options.attrs.viewIds - const condition = new Condition(component.id, fieldId, operator, value, viewIds) - this.addCondition(condition) - }, - addCondition(condition) { - let conditionExist = false - for (let index = 0; index < this.conditions.length; index++) { - const element = this.conditions[index] - if (condition.componentId === element.componentId) { - this.conditions[index] = condition - conditionExist = true - } - } - !conditionExist && this.conditions.push(condition) - this.executeSearch() - }, - deleteCondition(condition) { - this.conditions = this.conditions.filter(item => { - const componentIdSuitable = !condition.componentId || (item.componentId === condition.componentId) - const fieldIdSuitable = !condition.fieldId || (item.fieldId === condition.fieldId) - return !(componentIdSuitable && fieldIdSuitable) - }) - this.executeSearch() - }, - executeSearch() { - // console.log('当前查询条件是: ' + JSON.stringify(this.conditions)) - }, format(value, scale) { // 自适应画布区域 返回原值 if (this.canvasStyleData.selfAdaption) { diff --git a/frontend/src/components/widget/DeWidget/DeDate.vue b/frontend/src/components/widget/DeWidget/DeDate.vue index 1370afde61..bdc86c10cc 100644 --- a/frontend/src/components/widget/DeWidget/DeDate.vue +++ b/frontend/src/components/widget/DeWidget/DeDate.vue @@ -47,7 +47,7 @@ export default { operator: this.operator } param.value = this.formatValues(param.value) - this.inDraw && this.$store.dispatch('conditions/add', param) + this.inDraw && this.$store.commit('addViewFilter', param) }, dateChange(value) { this.setCondition() diff --git a/frontend/src/components/widget/DeWidget/DeInputSearch.vue b/frontend/src/components/widget/DeWidget/DeInputSearch.vue index 988dad687f..3927e7822e 100644 --- a/frontend/src/components/widget/DeWidget/DeInputSearch.vue +++ b/frontend/src/components/widget/DeWidget/DeInputSearch.vue @@ -49,7 +49,7 @@ export default { value: [this.options.value], operator: this.operator } - this.inDraw && this.$store.dispatch('conditions/add', param) + this.inDraw && this.$store.commit('addViewFilter', param) }, setEdit() { this.canEdit = true diff --git a/frontend/src/components/widget/DeWidget/DeSelect.vue b/frontend/src/components/widget/DeWidget/DeSelect.vue index 267f116da4..c25fccc52b 100644 --- a/frontend/src/components/widget/DeWidget/DeSelect.vue +++ b/frontend/src/components/widget/DeWidget/DeSelect.vue @@ -37,8 +37,6 @@ export default { data() { return { options: null, - // operator: 'eq', - values: null, showNumber: false } }, @@ -49,15 +47,21 @@ export default { }, watch: { 'options.attrs.multiple': function(value) { + const sourceValue = this.options.value if (value) { - this.values = [] + !sourceValue && (this.options.value = []) + sourceValue && !Array.isArray(sourceValue) && (this.options.value = sourceValue.split(',')) + !this.inDraw && (this.options.value = []) } else { - this.values = null + !sourceValue && (this.options.value = null) + sourceValue && Array.isArray(sourceValue) && (this.options.value = sourceValue[0]) + !this.inDraw && (this.options.value = null) } } }, created() { this.options = this.element.options + this.setCondition() }, mounted() { @@ -68,7 +72,6 @@ export default { methods: { changeValue(value) { this.setCondition() - // this.inDraw && this.$emit('set-condition-value', { component: this.element, value: [value], operator: this.operator }) this.showNumber = false this.$nextTick(() => { if (!this.$refs.deSelect.$refs.tags || !this.options.attrs.multiple) { @@ -89,7 +92,7 @@ export default { value: Array.isArray(this.options.value) ? this.options.value : [this.options.value], operator: this.operator } - this.inDraw && this.$store.dispatch('conditions/add', param) + this.inDraw && this.$store.commit('addViewFilter', param) } } } diff --git a/frontend/src/store/index.js b/frontend/src/store/index.js index 7d91bf307c..2455e51e15 100644 --- a/frontend/src/store/index.js +++ b/frontend/src/store/index.js @@ -11,7 +11,6 @@ import request from './modules/request' import panel from './modules/panel' import application from './modules/application' import lic from './modules/lic' -import conditions from './modules/conditions' import animation from '@/components/canvas/store/animation' import compose from '@/components/canvas/store/compose' import contextmenu from '@/components/canvas/store/contextmenu' @@ -20,13 +19,23 @@ import event from '@/components/canvas/store/event' import layer from '@/components/canvas/store/layer' import snapshot from '@/components/canvas/store/snapshot' import lock from '@/components/canvas/store/lock' - +import { Condition } from '@/components/widget/bean/Condition' import { DEFAULT_COMMON_CANVAS_STYLE } from '@/views/panel/panel' Vue.use(Vuex) +const valueValid = condition => { + return condition && condition.value && condition.value.length > 0 && condition.value[0] +} +const formatCondition = obj => { + const { component, value, operator } = obj + const fieldId = component.options.attrs.fieldId + const viewIds = component.options.attrs.viewIds + const condition = new Condition(component.id, fieldId, operator, value, viewIds) + return condition +} const data = { state: { ...animation.state, @@ -105,7 +114,46 @@ const data = { state.componentData.push(component) } }, + removeViewFilter(state, componentId) { + state.componentData = state.componentData.map(item => { + const newItem = item + newItem.filters = newItem.filters && newItem.filters.filter(filter => filter.componentId !== componentId) || [] + return newItem + }) + }, + addViewFilter(state, data) { + const condition = formatCondition(data) + const vValid = valueValid(condition) + // 1.根据componentId过滤 + const filterComponentId = condition.componentId + // 2.循环每个Component 得到 三种情况 a增加b删除c无操作 + const viewIdMatch = (viewIds, viewId) => !viewIds || viewIds.length === 0 || viewIds.includes(viewId) + + for (let index = 0; index < state.componentData.length; index++) { + const element = state.componentData[index] + if (!element.type || element.type !== 'view') continue + const currentFilters = element.filters || [] + const vidMatch = viewIdMatch(condition.viewIds, element.propValue.viewId) + + let j = currentFilters.length + let filterExist = false + while (j--) { + const filter = currentFilters[j] + if (filter.componentId === filterComponentId) { + filterExist = true + // 已存在该条件 且 条件值有效 直接替换原体检 + vidMatch && vValid && (currentFilters[j] = condition) + // 已存在该条件 且 条件值无效 直接删除原条件 + vidMatch && !vValid && (currentFilters.splice(j, 1)) + } + } + // 不存在该条件 且 条件有效 直接保存该条件 + !filterExist && vValid && currentFilters.push(condition) + element.filters = currentFilters + state.componentData[index] = element + } + }, setComponentWithId(state, component) { for (let index = 0; index < state.componentData.length; index++) { const element = state.componentData[index] @@ -143,8 +191,7 @@ const data = { request, panel, application, - lic, - conditions + lic }, getters } diff --git a/frontend/src/store/modules/conditions.js b/frontend/src/store/modules/conditions.js deleted file mode 100644 index 908f94ad9f..0000000000 --- a/frontend/src/store/modules/conditions.js +++ /dev/null @@ -1,94 +0,0 @@ -import { Condition } from '@/components/widget/bean/Condition' -const state = { - conditions: [] -} - -const mutations = { - ADD_CONDITION: (state, condition) => { - condition && valueValid(condition) && state.conditions.push(condition) - }, - REDUCE_CONDITION: (state, index) => { - state.conditions && state.conditions.length > index && state.conditions.splice(index, 1) - }, - CLEAR: (state) => { - state.conditions = [] - } -} - -const actions = { - add({ commit }, data) { - const condition = formatCondition(data) - if (!state.conditions || state.conditions.length === 0) { - state.conditions = [] - } - const validResult = isValid(condition) - if (!validResult.statu && validResult.hasOwnProperty('existIndex') && validResult.existIndex !== -1) { - commit('REDUCE_CONDITION', validResult.existIndex) - commit('ADD_CONDITION', condition) - } - if (validResult.statu) { - commit('ADD_CONDITION', condition) - } - }, - reduce({ commit }, index) { - commit('ADD_CONDITION', index) - }, - delete({ commit }, component) { - for (let index = 0; index < state.conditions.length; index++) { - const element = state.conditions[index] - if (element.componentId === component.componentId) { - commit('REDUCE_CONDITION', index) - } - } - }, - clear({ commit }) { - commit('CLEAR') - } - -} -// 判断条件condition是否有效 -const isValid = condition => { - const nullResult = { - statu: false, - msg: 'condition is null' - } - const repeatResult = { - statu: false, - existIndex: -1, - msg: 'condition is exist' - } - const validResult = { - statu: true, - msg: null - } - if (!condition) { - return nullResult - } - for (let index = 0; index < state.conditions.length; index++) { - const item = state.conditions[index] - if (item.componentId === condition.componentId) { - repeatResult.existIndex = index - return repeatResult - } - } - return validResult -} - -const valueValid = condition => { - return condition && condition.value && condition.value.length > 0 && condition.value[0] -} - -const formatCondition = obj => { - const { component, value, operator } = obj - const fieldId = component.options.attrs.fieldId - const viewIds = component.options.attrs.viewIds - const condition = new Condition(component.id, fieldId, operator, value, viewIds) - return condition -} - -export default { - namespaced: true, - state, - mutations, - actions -} diff --git a/frontend/src/views/panel/edit/index.vue b/frontend/src/views/panel/edit/index.vue index f697075755..1e7516bd9d 100644 --- a/frontend/src/views/panel/edit/index.vue +++ b/frontend/src/views/panel/edit/index.vue @@ -223,7 +223,8 @@ export default { outStyle: { width: null, height: null - } + }, + beforeDialogValue: null } }, @@ -432,15 +433,19 @@ export default { } }, openFilterDiolog() { + this.beforeDialogValue = this.curComponent.options.value this.filterVisible = true }, cancelFilter() { + this.beforeDialogValue = null this.filterVisible = false this.currentWidget = null this.clearCurrentInfo() }, sureFilter() { + this.currentFilterCom.options.value = this.beforeDialogValue const component = deepCopy(this.currentFilterCom) + // this.$store.commit('addComponent', { component }) this.$store.commit('setComponentWithId', component) this.$store.commit('recordSnapshot') From d44bbddbcb0b83a679c094b37432718cfe8f75ac Mon Sep 17 00:00:00 2001 From: taojinlong Date: Tue, 8 Jun 2021 14:52:26 +0800 Subject: [PATCH 12/54] =?UTF-8?q?feat:=20=E3=80=90UI=E3=80=91=E7=B3=BB?= =?UTF-8?q?=E7=BB=9F=E4=B8=AD=E5=90=8D=E7=A7=B0=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/dataset/ExtractDataService.java | 46 ++++++++++--------- frontend/src/lang/en.js | 18 ++++---- frontend/src/lang/tw.js | 34 +++++++------- frontend/src/lang/zh.js | 38 +++++++-------- 4 files changed, 70 insertions(+), 66 deletions(-) diff --git a/backend/src/main/java/io/dataease/service/dataset/ExtractDataService.java b/backend/src/main/java/io/dataease/service/dataset/ExtractDataService.java index 228bc27373..cf9ef8b2bd 100644 --- a/backend/src/main/java/io/dataease/service/dataset/ExtractDataService.java +++ b/backend/src/main/java/io/dataease/service/dataset/ExtractDataService.java @@ -27,6 +27,9 @@ import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.io.FileUtils; import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.exception.ExceptionUtils; +import org.apache.http.HttpResponse; +import org.apache.http.client.HttpClient; +import org.apache.http.client.methods.HttpGet; import org.apache.poi.hssf.usermodel.HSSFSheet; import org.apache.poi.hssf.usermodel.HSSFWorkbook; import org.apache.poi.xssf.usermodel.XSSFSheet; @@ -34,6 +37,7 @@ import org.apache.poi.xssf.usermodel.XSSFWorkbook; import org.pentaho.di.cluster.SlaveServer; import org.pentaho.di.core.database.DatabaseMeta; import org.pentaho.di.core.row.ValueMetaInterface; +import org.pentaho.di.core.util.HttpClientManager; import org.pentaho.di.job.Job; import org.pentaho.di.job.JobExecutionConfiguration; import org.pentaho.di.job.JobHopMeta; @@ -66,6 +70,7 @@ import javax.annotation.Resource; import java.io.File; import java.io.FileInputStream; import java.io.InputStream; +import java.net.InetAddress; import java.util.ArrayList; import java.util.List; import java.util.stream.Collectors; @@ -707,27 +712,26 @@ public class ExtractDataService { } public boolean isKettleRunning() { - return true; -// try { -// if (!InetAddress.getByName(carte).isReachable(1000)) { -// return false; -// } -// HttpClient httpClient; -// HttpGet getMethod = new HttpGet("http://" + carte + ":" + port); -// HttpClientManager.HttpClientBuilderFacade clientBuilder = HttpClientManager.getInstance().createBuilder(); -// clientBuilder.setConnectionTimeout(1); -// clientBuilder.setCredentials(user, passwd); -// httpClient = clientBuilder.build(); -// HttpResponse httpResponse = httpClient.execute(getMethod); -// int statusCode = httpResponse.getStatusLine().getStatusCode(); -// if (statusCode != -1 && statusCode < 400) { -// return true; -// } else { -// return false; -// } -// } catch (Exception e) { -// return false; -// } + try { + if (!InetAddress.getByName(carte).isReachable(1000)) { + return false; + } + HttpClient httpClient; + HttpGet getMethod = new HttpGet("http://" + carte + ":" + port); + HttpClientManager.HttpClientBuilderFacade clientBuilder = HttpClientManager.getInstance().createBuilder(); + clientBuilder.setConnectionTimeout(1); + clientBuilder.setCredentials(user, passwd); + httpClient = clientBuilder.build(); + HttpResponse httpResponse = httpClient.execute(getMethod); + int statusCode = httpResponse.getStatusLine().getStatusCode(); + if (statusCode != -1 && statusCode < 400) { + return true; + } else { + return false; + } + } catch (Exception e) { + return false; + } } private static String alterColumnTypeCode = " if(\"FILED\".equalsIgnoreCase(filed)){\n" + diff --git a/frontend/src/lang/en.js b/frontend/src/lang/en.js index 6ca12bd0d0..6de6261846 100644 --- a/frontend/src/lang/en.js +++ b/frontend/src/lang/en.js @@ -455,7 +455,7 @@ export default { admin: 'Administrator', org_admin: 'Organization Administrator', org_member: 'Organization Member', - add: 'Add Role', + add: 'Create Role', delete: 'Delete Role', modify: 'Modify Role', tips: 'Tips', @@ -532,15 +532,15 @@ export default { cancel: 'Cancel', search: 'Search', back: 'Back', - add_table: 'Add Table', + add_table: 'Add Dataset', process: 'Speed of progress', add_chart: 'Add Chart', - db_data: 'Database Table', + db_data: 'Database Dataset', sql_data: 'SQL data set', excel_data: 'Excel data set', custom_data: 'Custom data set', pls_slc_tbl_left: 'Please select the chart from the left', - add_db_table: 'Add database table', + add_db_table: 'Add Database Dataset', pls_slc_data_source: 'Please select data source', table: 'Table', edit: 'Edit', @@ -737,12 +737,12 @@ export default { add_table: 'Add Table', process: 'Speed of progress', update: 'update', - db_data: 'Database Table', + db_data: 'Database Dataset', sql_data: 'SQL data set', excel_data: 'Excel data set', custom_data: 'Custom data set', pls_slc_tbl_left: 'Please select the chart from the left', - add_db_table: 'Add database table', + add_db_table: 'Add Database Dataset', pls_slc_data_source: 'Please select data source', table: 'Table', edit: 'Edit', @@ -785,7 +785,7 @@ export default { close: 'Close', required: 'Required', input_content: 'Please input the content', - add_sql_table: 'Add SQL', + add_sql_table: 'Add SQL Dataset', preview: 'Preview', pls_input_name: 'Please enter a name', connect_mode: 'Connection Mode', @@ -795,7 +795,7 @@ export default { last_update_time: 'Last update time', current_update_time: 'Current update time', param: 'Parameter', - edit_sql: 'Edit SQL', + edit_sql: 'Edit SQL Dataset', showRow: 'Display line', add_excel_table: 'Add excel dataset', add_custom_table: 'Add self help dataset', @@ -844,7 +844,7 @@ export default { data_base: 'Database name', user_name: 'User Name', password: 'Password', - host: 'Host', + host: 'Host name / IP address', port: 'Port', please_input_data_base: 'Please enter the database name', please_input_user_name: 'Please enter user name', diff --git a/frontend/src/lang/tw.js b/frontend/src/lang/tw.js index 755f7438db..bda209374a 100644 --- a/frontend/src/lang/tw.js +++ b/frontend/src/lang/tw.js @@ -425,7 +425,7 @@ export default { no_such_user: '无此用戶信息, 請輸入正确的用戶 ID 或者 用戶郵箱!' }, user: { - create: '創建用戶', + create: '新建用戶', modify: '修改用戶', input_name: '請輸入用戶姓名', input_id: '請輸入ID', @@ -455,7 +455,7 @@ export default { admin: '系統管理員', org_admin: '組織管理员', org_member: '組織成員', - add: '添加角色', + add: '新建角色', delete: '删除角色', modify: '修改角色', tips: '提示', @@ -489,7 +489,7 @@ export default { sort: '組織排序', sub_organizations: '下屬組織數', create_time: '創建日期', - create: '創建組織', + create: '新建組織', modify: '修改組織', delete: '删除組織', delete_confirm: '删除該組織會關聯刪除該組織的下屬組織,確定要删除吗?', @@ -532,13 +532,13 @@ export default { cancel: '取消', search: '搜索', back: '返回', - add_table: '添加表', + add_table: '添加數據集', process: '進度', add_chart: '添加視圖', - db_data: '數據庫表', + db_data: '數據庫數據集', sql_data: 'SQL數據集', excel_data: 'Excel數據集', - custom_data: '自助數據集', + custom_data: '自定義數據集', pls_slc_tbl_left: '請從左側選擇視圖', add_db_table: '添加數據庫表', pls_slc_data_source: '請選擇數據源', @@ -734,15 +734,15 @@ export default { cancel: '取消', search: '搜索', back: '返回', - add_table: '添加表', + add_table: '添加數據集', process: '進度', update: '更新', - db_data: '數據庫表', - sql_data: 'SQL數據集', - excel_data: 'Excel數據集', - custom_data: '自助數據集', + db_data: '數據庫數據集', + sql_data: 'SQL 數據集', + excel_data: 'Excel 數據集', + custom_data: '自定義數據集', pls_slc_tbl_left: '請從左側選擇表', - add_db_table: '添加數據庫表', + add_db_table: '添加數據庫數據集', pls_slc_data_source: '請選擇數據源', table: '表', edit: '編輯', @@ -785,7 +785,7 @@ export default { close: '關閉', required: '必填', input_content: '請輸入內容', - add_sql_table: '添加 SQL', + add_sql_table: '添加 SQL 數據集', preview: '預覽', pls_input_name: '請輸入名稱', connect_mode: '鏈接模式', @@ -795,10 +795,10 @@ export default { last_update_time: '上次更新時間', current_update_time: '當前更新時間', param: '參數', - edit_sql: '編輯 SQL', + edit_sql: '編輯 SQL 數據集', showRow: '顯示行', - add_excel_table: ' 添加Excel數據集', - add_custom_table: '添加自助數據集', + add_excel_table: ' 添加 Excel 數據集', + add_custom_table: '添加自定義數據集', upload_file: '上傳文件', detail: '詳情', type: '類型', @@ -844,7 +844,7 @@ export default { data_base: '數據庫名稱', user_name: '用戶名', password: '密碼', - host: '主機', + host: '主機名/IP地址', port: '端口', please_input_data_base: '請輸入數據庫名稱', please_input_user_name: '請輸入用戶名', diff --git a/frontend/src/lang/zh.js b/frontend/src/lang/zh.js index 977e1530bb..47d6e30a7d 100644 --- a/frontend/src/lang/zh.js +++ b/frontend/src/lang/zh.js @@ -425,7 +425,7 @@ export default { no_such_user: '无此用户信息, 请输入正确的用户 ID 或者 用户邮箱!' }, user: { - create: '创建用户', + create: '新建用户', modify: '修改用户', input_name: '请输入用户姓名', input_id: '请输入ID', @@ -455,7 +455,7 @@ export default { admin: '系统管理员', org_admin: '组织管理员', org_member: '组织成员', - add: '添加角色', + add: '新建角色', delete: '删除角色', modify: '修改角色', tips: '提示', @@ -489,7 +489,7 @@ export default { sort: '组织排序', sub_organizations: '下属组织数', create_time: '创建日期', - create: '创建组织', + create: '新建组织', modify: '修改组织', delete: '删除组织', delete_confirm: '删除该组织会关联删除该组织的下属组织,确定要删除吗?', @@ -532,15 +532,15 @@ export default { cancel: '取消', search: '搜索', back: '返回', - add_table: '添加表', + add_table: '添加数据集', process: '进度', add_chart: '添加视图', - db_data: '数据库表', + db_data: '数据库数据集', sql_data: 'SQL数据集', excel_data: 'Excel数据集', - custom_data: '自助数据集', + custom_data: '自定义数据集', pls_slc_tbl_left: '请从左侧选视图', - add_db_table: '添加数据库表', + add_db_table: '添加数据库数据集', pls_slc_data_source: '请选择数据源', table: '表', edit: '编辑', @@ -718,7 +718,7 @@ export default { chart_error_tips: '如有疑问请联系管理员' }, dataset: { - sheet_warn: '有多个Sheet页,默认抽取第一个', + sheet_warn: '有多个 Sheet 页,默认抽取第一个', datalist: '数据集', add_group: '添加分组', add_scene: '添加场景', @@ -734,15 +734,15 @@ export default { cancel: '取消', search: '搜索', back: '返回', - add_table: '添加表', + add_table: '添加数据集', process: '进度', update: '更新', - db_data: '数据库表', - sql_data: 'SQL数据集', - excel_data: 'Excel数据集', - custom_data: '自助数据集', + db_data: '数据库数据集', + sql_data: 'SQL 数据集', + excel_data: 'Excel 数据集', + custom_data: '自定义数据集', pls_slc_tbl_left: '请从左侧选择表', - add_db_table: '添加数据库表', + add_db_table: '添加数据库数据集', pls_slc_data_source: '请选择数据源', table: '表', edit: '编辑', @@ -785,7 +785,7 @@ export default { close: '关闭', required: '必填', input_content: '请输入内容', - add_sql_table: '添加SQL', + add_sql_table: '添加 SQL 数据集', preview: '预览', pls_input_name: '请输入名称', connect_mode: '连接模式', @@ -795,10 +795,10 @@ export default { last_update_time: '上次更新时间', current_update_time: '当前更新时间', param: '参数', - edit_sql: '编辑SQL', + edit_sql: '编辑 SQL 数据集', showRow: '显示行', add_excel_table: '添加Excel数据集', - add_custom_table: '添加自助数据集', + add_custom_table: '添加自定义数据集', upload_file: '上传文件', detail: '详情', type: '类型', @@ -825,7 +825,7 @@ export default { check_all: '全选', can_not_union_self: '被关联表不能与关联表相同', float: '小数', - edit_custom_table: '编辑自助数据集', + edit_custom_table: '编辑自定义数据集', edit_field: '编辑字段', preview_100_data: '显示前100行数据', invalid_table_check: '非直连数据集请先完成数据同步', @@ -844,7 +844,7 @@ export default { data_base: '数据库名称', user_name: '用户名', password: '密码', - host: '主机', + host: '主机名/IP地址', port: '端口', please_input_data_base: '请输入数据库名称', please_input_user_name: '请输入用户名', From 1b1f3e056c7a8e61a224392fdd28a6d5d486c832 Mon Sep 17 00:00:00 2001 From: junjie Date: Tue, 8 Jun 2021 15:00:13 +0800 Subject: [PATCH 13/54] =?UTF-8?q?feat(frontend):=E5=88=86=E7=BB=84?= =?UTF-8?q?=E5=9C=BA=E6=99=AF=E8=8F=9C=E5=8D=95=E6=8E=A7=E5=88=B6=E4=BC=98?= =?UTF-8?q?=E5=8C=96=EF=BC=8C=E9=BB=98=E8=AE=A4=E9=9A=90=E8=97=8F=EF=BC=8C?= =?UTF-8?q?=E9=BC=A0=E6=A0=87=E7=A7=BB=E4=B8=8A=E5=90=8E=E6=98=BE=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- frontend/src/views/chart/group/Group.vue | 14 ++++++++++---- frontend/src/views/dataset/group/Group.vue | 14 ++++++++++---- 2 files changed, 20 insertions(+), 8 deletions(-) diff --git a/frontend/src/views/chart/group/Group.vue b/frontend/src/views/chart/group/Group.vue index d88ab7fb66..941b077e0f 100644 --- a/frontend/src/views/chart/group/Group.vue +++ b/frontend/src/views/chart/group/Group.vue @@ -41,7 +41,7 @@ :expand-on-click-node="true" @node-click="nodeClick" > - + @@ -53,7 +53,7 @@ {{ data.name }} - + @@ -150,12 +150,12 @@ highlight-current @node-click="sceneClick" > - + {{ data.name }} - + @@ -692,4 +692,10 @@ export default { white-space: nowrap; text-overflow: ellipsis; } + .father .child { + display: none; + } + .father:hover .child { + display: inline; + } diff --git a/frontend/src/views/dataset/group/Group.vue b/frontend/src/views/dataset/group/Group.vue index ec9f694d7e..acc8cb2fd4 100644 --- a/frontend/src/views/dataset/group/Group.vue +++ b/frontend/src/views/dataset/group/Group.vue @@ -41,7 +41,7 @@ :expand-on-click-node="true" @node-click="nodeClick" > - + @@ -53,7 +53,7 @@ {{ data.name }} - + @@ -179,7 +179,7 @@ highlight-current @node-click="sceneClick" > - + @@ -193,7 +193,7 @@ {{ data.name }} - + @@ -634,4 +634,10 @@ export default { white-space: nowrap; text-overflow: ellipsis; } + .father .child { + display: none; + } + .father:hover .child { + display: inline; + } From 28635839718d59a2be682bf28ca564b6b58eea2d Mon Sep 17 00:00:00 2001 From: taojinlong Date: Tue, 8 Jun 2021 15:39:29 +0800 Subject: [PATCH 14/54] =?UTF-8?q?feat:=20excel=20=E6=95=B8=E6=93=9A?= =?UTF-8?q?=E9=9B=86=20=E6=9B=BF=E6=8F=9B=E3=80=81=E8=BF=BD=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/dataset/ExtractDataService.java | 74 +++++++++++-------- 1 file changed, 44 insertions(+), 30 deletions(-) diff --git a/backend/src/main/java/io/dataease/service/dataset/ExtractDataService.java b/backend/src/main/java/io/dataease/service/dataset/ExtractDataService.java index cf9ef8b2bd..dd1c12274c 100644 --- a/backend/src/main/java/io/dataease/service/dataset/ExtractDataService.java +++ b/backend/src/main/java/io/dataease/service/dataset/ExtractDataService.java @@ -129,6 +129,7 @@ public class ExtractDataService { " exit 1\n" + "fi\n" + "rm -rf %s\n"; + private String createDorisTablColumnSql(List datasetTableFields) { String Column_Fields = "dataease_uuid varchar(50), `"; for (DatasetTableField datasetTableField : datasetTableFields) { @@ -244,7 +245,11 @@ public class ExtractDataService { switch (updateType) { // 全量更新 case all_scope: - datasetTableTaskLog = getDatasetTableTaskLog(datasetTableTaskLog, datasetTableId, taskId); + if(datasource.getType().equalsIgnoreCase("excel")){ + datasetTableTaskLog = writeDatasetTableTaskLog(datasetTableTaskLog, datasetTableId, null); + }else { + datasetTableTaskLog = getDatasetTableTaskLog(datasetTableTaskLog, datasetTableId, taskId); + } createDorisTable(DorisTableUtils.dorisName(datasetTableId), dorisTablColumnSql); createDorisTable(DorisTableUtils.dorisTmpName(DorisTableUtils.dorisName(datasetTableId)), dorisTablColumnSql); generateTransFile("all_scope", datasetTable, datasource, datasetTableFields, null); @@ -258,35 +263,43 @@ public class ExtractDataService { // 增量更新 case add_scope: - DatasetTableIncrementalConfig datasetTableIncrementalConfig = dataSetTableService.incrementalConfig(datasetTableId); - if (datasetTableIncrementalConfig == null || StringUtils.isEmpty(datasetTableIncrementalConfig.getTableId())) { - return; - } - DatasetTableTaskLog request = new DatasetTableTaskLog(); - request.setTableId(datasetTableId); - request.setStatus(JobStatus.Completed.name()); - List dataSetTaskLogDTOS = dataSetTableTaskLogService.list(request); - if (CollectionUtils.isEmpty(dataSetTaskLogDTOS)) { - return; - } - datasetTableTaskLog = writeDatasetTableTaskLog(datasetTableTaskLog, datasetTableId, taskId); - - // 增量添加 - if (StringUtils.isNotEmpty(datasetTableIncrementalConfig.getIncrementalAdd().replace(" ", ""))) { - String sql = datasetTableIncrementalConfig.getIncrementalAdd().replace(lastUpdateTime, dataSetTaskLogDTOS.get(0).getStartTime().toString() - .replace(currentUpdateTime, Long.valueOf(System.currentTimeMillis()).toString())); - generateTransFile("incremental_add", datasetTable, datasource, datasetTableFields, sql); - generateJobFile("incremental_add", datasetTable, fetchSqlField(sql, datasource)); + if(datasource.getType().equalsIgnoreCase("excel")){ + datasetTableTaskLog = writeDatasetTableTaskLog(datasetTableTaskLog, datasetTableId, null); + generateTransFile("incremental_add", datasetTable, datasource, datasetTableFields, null); + generateJobFile("incremental_add", datasetTable, String.join(",", datasetTableFields.stream().map(DatasetTableField::getDataeaseName).collect(Collectors.toList()))); extractData(datasetTable, "incremental_add"); - } + return; + }else { + DatasetTableIncrementalConfig datasetTableIncrementalConfig = dataSetTableService.incrementalConfig(datasetTableId); + if (datasetTableIncrementalConfig == null || StringUtils.isEmpty(datasetTableIncrementalConfig.getTableId())) { + return; + } + DatasetTableTaskLog request = new DatasetTableTaskLog(); + request.setTableId(datasetTableId); + request.setStatus(JobStatus.Completed.name()); + List dataSetTaskLogDTOS = dataSetTableTaskLogService.list(request); + if (CollectionUtils.isEmpty(dataSetTaskLogDTOS)) { + return; + } + datasetTableTaskLog = writeDatasetTableTaskLog(datasetTableTaskLog, datasetTableId, taskId); - // 增量删除 - if (StringUtils.isNotEmpty(datasetTableIncrementalConfig.getIncrementalDelete())) { - String sql = datasetTableIncrementalConfig.getIncrementalDelete().replace(lastUpdateTime, dataSetTaskLogDTOS.get(0).getStartTime().toString() - .replace(currentUpdateTime, Long.valueOf(System.currentTimeMillis()).toString())); - generateTransFile("incremental_delete", datasetTable, datasource, datasetTableFields, sql); - generateJobFile("incremental_delete", datasetTable, fetchSqlField(sql, datasource)); - extractData(datasetTable, "incremental_delete"); + // 增量添加 + if (StringUtils.isNotEmpty(datasetTableIncrementalConfig.getIncrementalAdd().replace(" ", ""))) { + String sql = datasetTableIncrementalConfig.getIncrementalAdd().replace(lastUpdateTime, dataSetTaskLogDTOS.get(0).getStartTime().toString() + .replace(currentUpdateTime, Long.valueOf(System.currentTimeMillis()).toString())); + generateTransFile("incremental_add", datasetTable, datasource, datasetTableFields, sql); + generateJobFile("incremental_add", datasetTable, fetchSqlField(sql, datasource)); + extractData(datasetTable, "incremental_add"); + } + + // 增量删除 + if (StringUtils.isNotEmpty(datasetTableIncrementalConfig.getIncrementalDelete())) { + String sql = datasetTableIncrementalConfig.getIncrementalDelete().replace(lastUpdateTime, dataSetTaskLogDTOS.get(0).getStartTime().toString() + .replace(currentUpdateTime, Long.valueOf(System.currentTimeMillis()).toString())); + generateTransFile("incremental_delete", datasetTable, datasource, datasetTableFields, sql); + generateJobFile("incremental_delete", datasetTable, fetchSqlField(sql, datasource)); + extractData(datasetTable, "incremental_delete"); + } } datasetTableTaskLog.setStatus(JobStatus.Completed.name()); datasetTableTaskLog.setEndTime(System.currentTimeMillis()); @@ -358,6 +371,9 @@ public class ExtractDataService { if(CollectionUtils.isNotEmpty(datasetTableTaskLogs)){ return datasetTableTaskLogs.get(0); } + try { + Thread.sleep(1000); + }catch (Exception ignore){} } datasetTableTaskLog.setStartTime(System.currentTimeMillis()); dataSetTableTaskLogService.save(datasetTableTaskLog); @@ -365,8 +381,6 @@ public class ExtractDataService { } private void extractData(DatasetTable datasetTable, String extractType) throws Exception { - - KettleFileRepository repository = CommonBeanFactory.getBean(KettleFileRepository.class); RepositoryDirectoryInterface repositoryDirectoryInterface = repository.loadRepositoryDirectoryTree(); JobMeta jobMeta = null; From 880a26cd0a47207103f3078a184ca542d8c05610 Mon Sep 17 00:00:00 2001 From: fit2cloud-chenyw Date: Tue, 8 Jun 2021 16:03:49 +0800 Subject: [PATCH 15/54] =?UTF-8?q?feat:=20=E4=BB=AA=E8=A1=A8=E6=9D=BF?= =?UTF-8?q?=E8=BF=87=E6=BB=A4=20=E5=B1=80=E9=83=A8=E5=88=B7=E6=96=B0=20?= =?UTF-8?q?=E5=9F=BA=E6=9C=AC=E5=8A=9F=E8=83=BD=E5=AE=8C=E5=96=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../components/Editor/ComponentWrapper.vue | 1 - .../canvas/components/Editor/index.vue | 7 +++- .../canvas/custom-component/UserView.vue | 42 ++++++++++++------- frontend/src/layout/components/Topbar.vue | 4 +- frontend/src/store/index.js | 24 ++++------- frontend/src/utils/conditionUtil.js | 32 ++++++++++++++ frontend/src/views/login/index.vue | 2 +- frontend/src/views/panel/edit/index.vue | 15 +++++-- frontend/src/views/panel/list/PanelList.vue | 6 ++- 9 files changed, 93 insertions(+), 40 deletions(-) create mode 100644 frontend/src/utils/conditionUtil.js diff --git a/frontend/src/components/canvas/components/Editor/ComponentWrapper.vue b/frontend/src/components/canvas/components/Editor/ComponentWrapper.vue index e6058d1c83..57ec8b0c8e 100644 --- a/frontend/src/components/canvas/components/Editor/ComponentWrapper.vue +++ b/frontend/src/components/canvas/components/Editor/ComponentWrapper.vue @@ -17,7 +17,6 @@ :style="getStyle(config.style)" :prop-value="config.propValue" :element="config" - :filter="config.filters" />
diff --git a/frontend/src/components/canvas/components/Editor/index.vue b/frontend/src/components/canvas/components/Editor/index.vue index 374cef2f84..1f0bd7ecd9 100644 --- a/frontend/src/components/canvas/components/Editor/index.vue +++ b/frontend/src/components/canvas/components/Editor/index.vue @@ -40,7 +40,6 @@ :style="getComponentStyle(item.style)" :prop-value="item.propValue" :element="item" - :filter="item.filters" :out-style="getShapeStyleInt(item.style)" />
- - + +
{ - return condition && condition.value && condition.value.length > 0 && condition.value[0] -} -const formatCondition = obj => { - const { component, value, operator } = obj - const fieldId = component.options.attrs.fieldId - const viewIds = component.options.attrs.viewIds - const condition = new Condition(component.id, fieldId, operator, value, viewIds) - return condition -} const data = { state: { ...animation.state, @@ -137,19 +127,21 @@ const data = { const vidMatch = viewIdMatch(condition.viewIds, element.propValue.viewId) let j = currentFilters.length - let filterExist = false + // let filterExist = false while (j--) { const filter = currentFilters[j] if (filter.componentId === filterComponentId) { - filterExist = true + // filterExist = true // 已存在该条件 且 条件值有效 直接替换原体检 - vidMatch && vValid && (currentFilters[j] = condition) + // vidMatch && vValid && (currentFilters[j] = condition) // 已存在该条件 且 条件值无效 直接删除原条件 - vidMatch && !vValid && (currentFilters.splice(j, 1)) + // vidMatch && !vValid && (currentFilters.splice(j, 1)) + currentFilters.splice(j, 1) } } // 不存在该条件 且 条件有效 直接保存该条件 - !filterExist && vValid && currentFilters.push(condition) + // !filterExist && vValid && currentFilters.push(condition) + vidMatch && vValid && currentFilters.push(condition) element.filters = currentFilters state.componentData[index] = element } diff --git a/frontend/src/utils/conditionUtil.js b/frontend/src/utils/conditionUtil.js new file mode 100644 index 0000000000..0e010b8665 --- /dev/null +++ b/frontend/src/utils/conditionUtil.js @@ -0,0 +1,32 @@ + +import { Condition } from '@/components/widget/bean/Condition' +/** + * 判断两个conditions数组是否相同 + * @param {*} conditions1 + * @param {*} conditions2 + * @returns + */ +export const isChange = (conditions1, conditions2) => { + // 两个都null + if (!conditions1 && !conditions2) return false + if (!conditions1 || !conditions2) return true + // 数组长度不一样 肯定发生了改变 + if (conditions1.length !== conditions2.length) return true + let arr1 = JSON.parse(JSON.stringify(conditions1)) + let arr2 = JSON.parse(JSON.stringify(conditions2)) + arr1 = arr1.sort((s1, s2) => s1.componentId > s2.componentId) + arr2 = arr2.sort((s1, s2) => s1.componentId > s2.componentId) + return JSON.stringify(arr1) !== JSON.stringify(arr2) +} + +export const valueValid = condition => { + return condition && condition.value && condition.value.length > 0 && condition.value[0] +} + +export const formatCondition = obj => { + const { component, value, operator } = obj + const fieldId = component.options.attrs.fieldId + const viewIds = component.options.attrs.viewIds + const condition = new Condition(component.id, fieldId, operator, value, viewIds) + return condition +} diff --git a/frontend/src/views/login/index.vue b/frontend/src/views/login/index.vue index a8e7f68b4a..dcae4b81be 100644 --- a/frontend/src/views/login/index.vue +++ b/frontend/src/views/login/index.vue @@ -5,7 +5,7 @@