Merge branch 'dev' into pr@dev_one_dot_x

This commit is contained in:
dataeaseShu 2023-12-27 16:07:28 +08:00
commit 67592ee968
49 changed files with 619 additions and 210 deletions

View File

@ -183,8 +183,13 @@ public class PgQueryProvider extends QueryProvider {
String whereTrees = transFilterTrees(tableObj, rowPermissionsTree);
List<String> wheres = new ArrayList<>();
if (customWheres != null) wheres.add(customWheres);
if (StringUtils.isNotBlank(keyword)) {
String keyWhere = "(" + transKeywordFilterList(tableObj, xFields, keyword) + ")";
if (StringUtils.isNotBlank(keyword) && CollectionUtils.isNotEmpty(xFields)) {
List<SQLObj> formatFields = xFields.stream().peek(f -> {
String fieldOriginName = f.getFieldOriginName();
String format = String.format(PgConstants.CAST, fieldOriginName, "VARCHAR");
f.setFieldOriginName(format);
}).collect(Collectors.toList());
String keyWhere = "(" + transKeywordFilterList(tableObj, formatFields, keyword) + ")";
wheres.add(keyWhere);
}
if (whereTrees != null) wheres.add(whereTrees);

View File

@ -436,10 +436,10 @@ public class SqlserverQueryProvider extends QueryProvider {
@Override
public String getSQLTableInfo(String table, List<ChartViewFieldDTO> xAxis, FilterTreeObj fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree, List<ChartExtFilterRequest> extFilterRequestList, Datasource ds, ChartViewWithBLOBs view) {
return originTableInfo(table, xAxis, fieldCustomFilter, rowPermissionsTree, extFilterRequestList, ds, view, true);
return originTableInfo(table, xAxis, fieldCustomFilter, rowPermissionsTree, extFilterRequestList, ds, view, true, true);
}
public String originTableInfo(String table, List<ChartViewFieldDTO> xAxis, FilterTreeObj fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree, List<ChartExtFilterRequest> extFilterRequestList, Datasource ds, ChartViewWithBLOBs view, boolean needOrder) {
public String originTableInfo(String table, List<ChartViewFieldDTO> xAxis, FilterTreeObj fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree, List<ChartExtFilterRequest> extFilterRequestList, Datasource ds, ChartViewWithBLOBs view, boolean needOrder, boolean needResultCount) {
SQLObj tableObj = SQLObj.builder()
.tableName((table.startsWith("(") && table.endsWith(")")) ? table : String.format(SqlServerSQLConstants.KEYWORD_TABLE, table))
.tableAlias(String.format(TABLE_ALIAS_PREFIX, 0))
@ -518,7 +518,7 @@ public class SqlserverQueryProvider extends QueryProvider {
.build();
if (CollectionUtils.isNotEmpty(orders)) st.add("orders", orders);
if (ObjectUtils.isNotEmpty(tableSQL)) st.add("table", tableSQL);
if (StringUtils.equalsIgnoreCase(view.getResultMode(), "custom")) {
if (StringUtils.equalsIgnoreCase(view.getResultMode(), "custom") && needResultCount) {
SQLObj limitFiled = SQLObj.builder().limitFiled("top " + view.getResultCount() + " ").build();
st.add("limitFiled", limitFiled);
}
@ -526,16 +526,17 @@ public class SqlserverQueryProvider extends QueryProvider {
}
public String originSQLAsTmpTableInfo(String sql, List<ChartViewFieldDTO> xAxis, FilterTreeObj fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree, List<ChartExtFilterRequest> extFilterRequestList, Datasource ds, ChartViewWithBLOBs view, boolean needOrder) {
return originTableInfo("(" + sqlFix(sql) + ")", xAxis, fieldCustomFilter, rowPermissionsTree, extFilterRequestList, null, view, needOrder);
return originTableInfo("(" + sqlFix(sql) + ")", xAxis, fieldCustomFilter, rowPermissionsTree, extFilterRequestList, null, view, needOrder, true);
}
@Override
public String getSQLWithPage(boolean isTable, String sql, List<ChartViewFieldDTO> xAxis, FilterTreeObj fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree, List<ChartExtFilterRequest> extFilterRequestList, Datasource ds, ChartViewWithBLOBs view, PageInfo pageInfo) {
String limit = ((pageInfo.getGoPage() != null && pageInfo.getPageSize() != null) ? " OFFSET " + (pageInfo.getGoPage() - 1) * pageInfo.getPageSize() + " ROW FETCH NEXT " + pageInfo.getPageSize() + " ROW ONLY " : "");
boolean isPage = (pageInfo.getGoPage() != null && pageInfo.getPageSize() != null);
String limit = (isPage ? " OFFSET " + (pageInfo.getGoPage() - 1) * pageInfo.getPageSize() + " ROW FETCH NEXT " + pageInfo.getPageSize() + " ROW ONLY " : "");
if (isTable) {
return getSQLTableInfo(sql, xAxis, fieldCustomFilter, rowPermissionsTree, extFilterRequestList, ds, view) + limit;
return originTableInfo(sql, xAxis, fieldCustomFilter, rowPermissionsTree, extFilterRequestList, ds, view, true, !isPage) + limit;
} else {
return getSQLTableInfo("(" + sqlFix(sql) + ")", xAxis, fieldCustomFilter, rowPermissionsTree, extFilterRequestList, ds, view) + limit;
return originTableInfo("(" + sqlFix(sql) + ")", xAxis, fieldCustomFilter, rowPermissionsTree, extFilterRequestList, ds, view, true, !isPage) + limit;
}
}
@ -1765,7 +1766,7 @@ public class SqlserverQueryProvider extends QueryProvider {
@Override
public String getResultCount(boolean isTable, String sql, List<ChartViewFieldDTO> xAxis, FilterTreeObj fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree, List<ChartExtFilterRequest> extFilterRequestList, Datasource ds, ChartViewWithBLOBs view) {
if (isTable) {
return "SELECT COUNT(*) AS count from (" + originTableInfo(sql, xAxis, fieldCustomFilter, rowPermissionsTree, extFilterRequestList, ds, view, false) + ") COUNT_TEMP";
return "SELECT COUNT(*) AS count from (" + originTableInfo(sql, xAxis, fieldCustomFilter, rowPermissionsTree, extFilterRequestList, ds, view, false, true) + ") COUNT_TEMP";
} else {
return "SELECT COUNT(*) AS count from (" + originSQLAsTmpTableInfo(sql, xAxis, fieldCustomFilter, rowPermissionsTree, extFilterRequestList, ds, view, false) + ") COUNT_TEMP";
}

View File

@ -1503,7 +1503,7 @@ public class ChartViewService {
if (CollectionUtils.isNotEmpty(detailData)) {
mapTableNormal = ChartDataBuild.transTableNormalWithDetail(xAxis, yAxis, data, detailFieldList, detailData, desensitizationList);
} else {
if (StringUtils.equalsIgnoreCase(view.getType(), "bar-time-range") && !drillRequestList.isEmpty() && !xAxisExt.isEmpty()) { // 针对区间条形图还需要给xAxis排个序, 把xAxisExt放到最后
if (StringUtils.equalsIgnoreCase(view.getType(), "bar-time-range") && CollectionUtils.isNotEmpty(drillRequestList) && CollectionUtils.isNotEmpty(xAxisExt)) { // 针对区间条形图还需要给xAxis排个序, 把xAxisExt放到最后
int count = 0;
for (int i = xAxis.size() - drillRequestList.size() - 1; i >= 0; i--) {
xAxis.remove(i);

View File

@ -91,6 +91,7 @@ public class DirectFieldService implements DataSetFieldService {
return CollectionUtil.sort(list, (v1, v2) -> {
Collator instance = Collator.getInstance(Locale.CHINESE);
if (ObjectUtils.isEmpty(v1) || ObjectUtils.isEmpty(v2)) return 0;
if (StringUtils.equals("desc", sortStr)) {
return instance.compare(v2, v1);
}

View File

@ -166,6 +166,7 @@ export function delGroup(groupId) {
}
export function initPanelData(panelId, useCache = false, callback) {
store.commit('resetLastValidFilters')
const queryMethod = useCache ? findUserCacheRequest : findOne
// 加载视图数据
queryMethod(panelId).then(response => {

View File

@ -5,6 +5,7 @@ import { $error } from '@/utils/message'
import i18n from '@/lang'
export function proxyInitPanelData(panelId, proxy, callback) {
store.commit('resetLastValidFilters')
// 加载视图数据
findOne(panelId, proxy).then(response => {
if (response.data) {

View File

@ -4,7 +4,7 @@ export function get(url) {
return request({
url: url,
method: 'get',
loading: true
loading: false
})
}

View File

@ -509,6 +509,7 @@ export default {
this.$store.commit('setComponentWithId', this.currentFilterCom)
this.$store.commit('recordSnapshot', 'sureFilter')
this.$store.commit('setCurComponent', { component: this.currentFilterCom, index: this.curComponentIndex })
this.$store.commit('delLastValidFilterWithId', this.currentFilterCom.id)
bus.$emit('reset-default-value', this.currentFilterCom)
this.closeFilter()
},

View File

@ -367,9 +367,7 @@ export default {
show: 0
},
view: {},
cancelTime: null,
// true
searchButtonReady: true
cancelTime: null
}
},
@ -424,7 +422,7 @@ export default {
},
filter() {
const filter = {}
filter.filter = (this.initLoad && this.cfilters?.length === 0) || !this.searchButtonReady ? this.filters : this.cfilters
filter.filter = this.initLoad && this.cfilters?.length === 0 ? this.filters : this.cfilters
filter.linkageFilters = this.element.linkageFilters
filter.outerParamsFilters = this.element.outerParamsFilters
filter.drill = this.drillClickDimensionList
@ -544,18 +542,17 @@ export default {
},
//
'hw': {
handler(newVal, oldVla) {
if (newVal !== oldVla && this.$refs[this.element.propValue.id]) {
handler(newVal, oldVal) {
if (!newVal) {
return
}
if (this.requestStatus === 'waiting') {
return
}
if (newVal !== oldVal && this.$refs[this.element.propValue.id]) {
this.resizeChart()
}
},
deep: true
},
//
outStyle: {
handler(newVal, oldVla) {
},
deep: true
}
},
//
searchCount: function(val1) {
@ -587,13 +584,7 @@ export default {
},
mounted() {
bus.$on('tab-canvas-change', this.tabSwitch)
bus.$on('trigger-search-button', this.triggerSearchButton)
this.bindPluginEvent()
this.$nextTick(() => {
if (this.filters && this.filters.length > 0) {
this.searchButtonReady = false
}
})
},
beforeDestroy() {
@ -632,9 +623,6 @@ export default {
}
},
methods: {
triggerSearchButton() {
this.searchButtonReady = true
},
groupFilter(filters) {
const result = {
ready: [],
@ -666,6 +654,7 @@ export default {
equalsAny,
tabSwitch(tabCanvasId) {
if (this.charViewS2ShowFlag && tabCanvasId === this.canvasId && this.$refs[this.element.propValue.id]) {
// do nothing
this.$refs[this.element.propValue.id].chartResize()
}
},
@ -797,9 +786,10 @@ export default {
param.viewId && param.viewId === this.element.propValue.viewId && this.getDataEdit(param)
},
clearPanelLinkage(param) {
console.log('clear linkage')
if (param.viewId === 'all' || param.viewId === this.element.propValue.viewId) {
try {
this.$refs[this.element.propValue.id]?.reDrawView?.()
// do nothing
} catch (e) {
console.error('reDrawView-error', this.element.propValue.id)
}
@ -853,9 +843,7 @@ export default {
this.getDataLoading = false
this.getData(id, cache, dataBroadcast)
clearTimeout(this.cancelTime)
this.cancelTime = setTimeout(() => {
this.requestStatus = 'waiting'
}, 0)
return
}
this.requestStatus = 'waiting'

View File

@ -459,6 +459,9 @@ export default {
return param
},
setCondition() {
if (this.showRequiredTips) {
return
}
const param = this.getCondition()
!this.isRelation && this.inDraw && this.$store.commit('addViewFilter', param)
},
@ -472,6 +475,12 @@ export default {
this.element.options.manualModify = false
} else {
this.element.options.manualModify = true
if (!this.showRequiredTips) {
this.$store.commit('setLastValidFilters', {
componentId: this.element.id,
val: (this.values && Array.isArray(this.values)) ? this.values.join(',') : this.values
})
}
}
this.setCondition()
},
@ -501,7 +510,16 @@ export default {
}
},
fillValueDerfault() {
const defaultV = this.element.options.value === null ? '' : this.element.options.value.toString()
let defaultV = this.element.options.value === null ? '' : this.element.options.value.toString()
if (this.inDraw) {
let lastFilters = null
if (this.$store.state.lastValidFilters) {
lastFilters = this.$store.state.lastValidFilters[this.element.id]
if (lastFilters) {
defaultV = (lastFilters.val === null || typeof lastFilters.val === 'undefined') ? '' : lastFilters.val.toString()
}
}
}
if (this.element.options.attrs.type === 'daterange') {
if (defaultV === null || typeof defaultV === 'undefined' || defaultV === '' || defaultV ===
'[object Object]') {

View File

@ -114,6 +114,11 @@ export default {
search() {
if (!this.inDraw) {
this.element.options.value = this.value
} else if (!this.showRequiredTips) {
this.$store.commit('setLastValidFilters', {
componentId: this.element.id,
val: (this.value && Array.isArray(this.value)) ? this.value.join(',') : this.value
})
}
this.setCondition()
},
@ -127,6 +132,9 @@ export default {
return param
},
setCondition() {
if (this.showRequiredTips) {
return
}
const param = this.getCondition()
!this.isRelation && this.inDraw && this.$store.commit('addViewFilter', param)
},
@ -142,7 +150,16 @@ export default {
}
},
fillValueDerfault() {
const defaultV = this.element.options.value === null ? '' : this.element.options.value.toString()
let defaultV = this.element.options.value === null ? '' : this.element.options.value.toString()
if (this.inDraw) {
let lastFilters = null
if (this.$store.state.lastValidFilters) {
lastFilters = this.$store.state.lastValidFilters[this.element.id]
if (lastFilters) {
defaultV = lastFilters.val === null ? '' : lastFilters.val.toString()
}
}
}
if (defaultV === null || typeof defaultV === 'undefined' || defaultV === '' || defaultV === '[object Object]') return null
return defaultV.split(',')[0]
}

View File

@ -127,7 +127,7 @@ export default {
},
'defaultvalues': function(value, old) {
if (value === old) return
const values = this.element.options.value
const values = this.fillValueDerfault()
this.form.min = values[0]
if (values.length > 1) {
this.form.max = values[1]
@ -145,7 +145,7 @@ export default {
},
created() {
if (this.element.options.value && this.element.options.value.length > 0) {
const values = this.element.options.value
const values = this.fillValueDerfault()
this.form.min = values[0]
if (values.length > 1) {
this.form.max = values[1]
@ -174,13 +174,12 @@ export default {
this.form.min = null
this.form.max = null
} else {
const values = this.element.options.value
const values = this.fillValueDerfault()
this.form.min = values[0]
if (values.length > 1) {
this.form.max = values[1]
}
}
this.search()
}
},
@ -251,7 +250,13 @@ export default {
if (!valid) {
return false
}
if (!this.showRequiredTips) {
const values = [this.form.min, this.form.max]
this.$store.commit('setLastValidFilters', {
componentId: this.element.id,
val: (values && Array.isArray(values)) ? values.join(',') : values
})
}
this.setCondition()
})
})
@ -283,6 +288,9 @@ export default {
return param
},
setCondition() {
if (this.showRequiredTips) {
return
}
const param = this.getCondition()
if (this.form.min && this.form.max) {
@ -316,6 +324,20 @@ export default {
} else {
this.element.options.manualModify = true
}
},
fillValueDerfault() {
let defaultV = this.element.options.value === null ? '' : this.element.options.value.toString()
if (this.inDraw) {
let lastFilters = null
if (this.$store.state.lastValidFilters) {
lastFilters = this.$store.state.lastValidFilters[this.element.id]
if (lastFilters) {
defaultV = lastFilters.val === null ? '' : lastFilters.val.toString()
}
}
}
if (defaultV === null || typeof defaultV === 'undefined' || defaultV === '' || defaultV === '[object Object]') return []
return defaultV.split(',')
}
}
}

View File

@ -98,7 +98,8 @@ export default {
separator: ',',
timeMachine: null,
changeIndex: 0,
flag: uuid.v1()
flag: uuid.v1(),
hasDestroy: false
}
},
computed: {
@ -145,7 +146,7 @@ export default {
return this.element.serviceName === 'textSelectWidget' && this.element.options.attrs.selectFirst
},
showRequiredTips() {
return this.inDraw && this.element.options.attrs.required && !this.value
return this.inDraw && this.element.options.attrs.required && (!this.value || this.value.length === 0)
}
},
@ -276,6 +277,7 @@ export default {
bus.$off('select-pop-change', this.popChange)
bus.$off('onScroll', this.onScroll)
bus.$off('reset-default-value', this.resetDefaultValue)
this.hasDestroy = true
},
methods: {
popChange(id) {
@ -380,7 +382,6 @@ export default {
}, 500)
},
initLoad() {
// this.value = this.fillValueDerfault()
this.initOptions(this.fillFirstSelected)
if (this.element.options.value && !this.selectFirst) {
this.value = this.fillValueDerfault()
@ -388,6 +389,9 @@ export default {
}
},
fillFirstSelected() {
if (this.hasDestroy) {
return
}
if (this.selectFirst && this.data?.length) {
this.fillFirstValue()
this.$emit('filter-loaded', {
@ -441,6 +445,12 @@ export default {
this.element.options.manualModify = false
} else {
this.element.options.manualModify = true
if (!this.showRequiredTips) {
this.$store.commit('setLastValidFilters', {
componentId: this.element.id,
val: (this.value && Array.isArray(this.value)) ? this.value.join(',') : this.value
})
}
}
this.setCondition()
this.handleShowNumber()
@ -477,6 +487,9 @@ export default {
return param
},
setCondition() {
if (this.showRequiredTips) {
return
}
const param = this.getCondition()
!this.isRelation && this.inDraw && this.$store.commit('addViewFilter', param)
},
@ -492,7 +505,16 @@ export default {
if (!this.selectFirst) {
return
}
const defaultV = this.data[0].id
let defaultV = this.data[0].id
if (this.inDraw) {
let lastFilters = null
if (this.$store.state.lastValidFilters) {
lastFilters = this.$store.state.lastValidFilters[this.element.id]
if (lastFilters) {
defaultV = lastFilters.val === null ? '' : lastFilters.val.toString()
}
}
}
if (this.element.options.attrs.multiple) {
if (defaultV === null || typeof defaultV === 'undefined' || defaultV === '' || defaultV === '[object Object]') return []
this.value = defaultV.split(this.separator)
@ -503,7 +525,17 @@ export default {
this.firstChange(this.value)
},
fillValueDerfault() {
const defaultV = this.element.options.value === null ? '' : this.element.options.value.toString()
let defaultV = this.element.options.value === null ? '' : this.element.options.value.toString()
if (this.inDraw) {
let lastFilters = null
if (this.$store.state.lastValidFilters) {
lastFilters = this.$store.state.lastValidFilters[this.element.id]
if (lastFilters) {
defaultV = lastFilters.val === null ? '' : lastFilters.val.toString()
}
}
}
if (this.element.options.attrs.multiple) {
if (defaultV === null || typeof defaultV === 'undefined' || defaultV === '' || defaultV === '[object Object]') return []
return defaultV.split(this.separator)

View File

@ -381,6 +381,12 @@ export default {
this.element.options.manualModify = false
} else {
this.element.options.manualModify = true
if (!this.showRequiredTips) {
this.$store.commit('setLastValidFilters', {
componentId: this.element.id,
val: (this.value && Array.isArray(this.value)) ? this.value.join(',') : this.value
})
}
}
this.setCondition()
},
@ -394,6 +400,9 @@ export default {
return param
},
setCondition() {
if (this.showRequiredTips) {
return
}
const param = this.getCondition()
!this.isRelation && this.inDraw && this.$store.commit('addViewFilter', param)
},
@ -403,7 +412,16 @@ export default {
return this.value.split(',')
},
fillValueDerfault() {
const defaultV = this.element.options.value === null ? '' : this.element.options.value.toString()
let defaultV = this.element.options.value === null ? '' : this.element.options.value.toString()
if (this.inDraw) {
let lastFilters = null
if (this.$store.state.lastValidFilters) {
lastFilters = this.$store.state.lastValidFilters[this.element.id]
if (lastFilters) {
defaultV = lastFilters.val === null ? '' : lastFilters.val.toString()
}
}
}
if (this.element.options.attrs.multiple) {
if (defaultV === null || typeof defaultV === 'undefined' || defaultV === '' || defaultV === '[object Object]') {
return []

View File

@ -313,6 +313,12 @@ export default {
this.element.options.manualModify = false
} else {
this.element.options.manualModify = true
if (!this.showRequiredTips) {
this.$store.commit('setLastValidFilters', {
componentId: this.element.id,
val: (this.value && Array.isArray(this.value)) ? this.value.join(',') : this.value
})
}
}
this.setCondition()
},
@ -331,6 +337,9 @@ export default {
},
setCondition() {
if (this.showRequiredTips) {
return
}
const param = this.getCondition()
!this.isRelation && this.inDraw && this.$store.commit('addViewFilter', param)
},
@ -370,7 +379,16 @@ export default {
},
fillValueDerfault() {
const defaultV = this.element.options.value === null ? '' : this.element.options.value.toString()
let defaultV = this.element.options.value === null ? '' : this.element.options.value.toString()
if (this.inDraw) {
let lastFilters = null
if (this.$store.state.lastValidFilters) {
lastFilters = this.$store.state.lastValidFilters[this.element.id]
if (lastFilters) {
defaultV = lastFilters.val === null ? '' : lastFilters.val.toString()
}
}
}
if (this.element.options.attrs.multiple) {
if (defaultV === null || typeof defaultV === 'undefined' || defaultV === '' || defaultV === '[object Object]') return []
return defaultV.split(',')
@ -433,7 +451,9 @@ export default {
.test-class-wrap {
background: var(--BgSelectTreeColor, #FFFFFF) !important;
border-color: var(--BrSelectTreeColor, #E4E7ED) !important;
.el-tree__empty-text {
position: relative !important;
}
.popper__arrow,
.popper__arrow::after {
display: none !important;
@ -471,5 +491,6 @@ export default {
border-left: none;
}
}
}
</style>

View File

@ -67,9 +67,14 @@ class NumberRangeServiceImpl extends WidgetService {
})
}
getParam(element) {
if (element.options.value && element.options.value.length > 0) {
const values = element.options.value
getParam(element, val) {
let values = null
if (val === null || val === '' || typeof val === 'undefined') {
values = element.options.value
} else {
values = val.split(',')
}
if (values && values.length > 0) {
const min = values[0]
let max = null
if (values.length > 1) {

View File

@ -82,8 +82,13 @@ class NumberSelectGridServiceImpl extends WidgetService {
}
})
}
getParam(element) {
const value = this.fillValueDerfault(element)
getParam(element, val) {
let value = null
if (val === null || val === '' || typeof val === 'undefined') {
value = this.fillValueDerfault(element)
} else {
value = [val]
}
const param = {
component: element,
value: !value ? [] : Array.isArray(value) ? value : value.toString().split(','),

View File

@ -84,8 +84,13 @@ class NumberSelectServiceImpl extends WidgetService {
}
})
}
getParam(element) {
const value = this.fillValueDerfault(element)
getParam(element, val) {
let value = null
if (val === null || val === '' || typeof val === 'undefined') {
value = this.fillValueDerfault(element)
} else {
value = [val]
}
const param = {
component: element,
value: !value ? [] : Array.isArray(value) ? value : value.toString().split(','),

View File

@ -68,8 +68,13 @@ class TextInputServiceImpl extends WidgetService {
return field['deType'] === 0
})
}
getParam(element) {
const value = this.fillValueDerfault(element)
getParam(element, val) {
let value = null
if (!val) {
value = this.fillValueDerfault(element)
} else {
value = [val]
}
const param = {
component: element,
value: !value ? [] : Array.isArray(value) ? value : [value],

View File

@ -83,8 +83,13 @@ class TextSelectGridServiceImpl extends WidgetService {
}
})
}
getParam(element) {
const value = this.fillValueDerfault(element)
getParam(element, val) {
let value = null
if (!val) {
value = this.fillValueDerfault(element)
} else {
value = [val]
}
const param = {
component: element,
value: !value ? [] : Array.isArray(value) ? value : value.toString().split(','),

View File

@ -86,8 +86,13 @@ class TextSelectTreeServiceImpl extends WidgetService {
})
}
getParam(element) {
const value = this.fillValueDerfault(element)
getParam(element, val) {
let value = null
if (!val) {
value = this.fillValueDerfault(element)
} else {
value = [val]
}
const param = {
component: element,
value: !value ? [] : Array.isArray(value) ? value : value.toString().split(','),

View File

@ -310,9 +310,13 @@ class TimeDateRangeServiceImpl extends WidgetService {
return false
}
}
getParam(element) {
getParam(element, val) {
let timeArr = []
if (element.options.attrs.default && element.options.attrs.default.isDynamic) {
if (val) {
let value = [val]
value = this.formatFilterValue(value)
timeArr = this.formatValues(value, element)
} else if (element.options.attrs.default && element.options.attrs.default.isDynamic) {
let value = this.dynamicDateFormNow(element)
value = this.formatFilterValue(value)
timeArr = this.formatValues(value, element)

View File

@ -167,9 +167,13 @@ class TimeDateServiceImpl extends WidgetService {
}
}
}
getParam(element) {
getParam(element, val) {
let timeArr = []
if (element.options.attrs.default && element.options.attrs.default.isDynamic) {
if (val) {
let value = [val]
value = this.formatFilterValue(value)
timeArr = this.formatValues(value, element)
} else if (element.options.attrs.default && element.options.attrs.default.isDynamic) {
let value = this.dynamicDateFormNow(element)
value = this.formatFilterValue(value)
timeArr = this.formatValues(value, element)

View File

@ -128,9 +128,13 @@ class TimeMonthServiceImpl extends WidgetService {
}
}
}
getParam(element) {
getParam(element, val) {
let timeArr = []
if (element.options.attrs.default && element.options.attrs.default.isDynamic) {
if (val) {
let value = [val]
value = this.formatFilterValue(value)
timeArr = this.formatValues(value, element)
} else if (element.options.attrs.default && element.options.attrs.default.isDynamic) {
let value = this.dynamicDateFormNow(element)
value = this.formatFilterValue(value)
timeArr = this.formatValues(value, element)

View File

@ -115,9 +115,13 @@ class TimeYearServiceImpl extends WidgetService {
return new Date(dynamicSuffix === 'before' ? (nowYear - dynamicPrefix) : (nowYear + dynamicPrefix), 0, 1).getTime()
}
}
getParam(element) {
getParam(element, val) {
let timeArr = []
if (element.options.attrs.default && element.options.attrs.default.isDynamic) {
if (val) {
let value = [val]
value = this.formatFilterValue(value)
timeArr = this.formatValues(value, element)
} else if (element.options.attrs.default && element.options.attrs.default.isDynamic) {
let value = this.dynamicDateFormNow(element)
value = this.formatFilterValue(value)
timeArr = this.formatValues(value, element)

View File

@ -1594,7 +1594,8 @@ export default {
gauge_axis_label: 'Axis Label',
word_size_range: 'Word Size Range',
word_spacing: 'Word Spacing',
axis_multi_select_tip: 'Hold down the Ctrl/Cmd or Shift key and click to select more than one'
axis_multi_select_tip: 'Hold down the Ctrl/Cmd or Shift key and click to select more than one',
needs_to_be_integer: 'Needs to be an integer'
},
dataset: {
scope_edit: 'Effective only when editing',
@ -2785,7 +2786,7 @@ export default {
fire_now_success: 'Task executing',
larkgroups: 'Lark group',
ext_wait_time: 'Additional waiting time for dashboard loading (unit: seconds)',
wat_time_limit: 'The additional waiting time must be between [0 - 30]'
wat_time_limit: 'The additional waiting time must be an integer between [0 - 30]'
},
dynamic_time: {
set_default: 'Set Default',

View File

@ -1586,7 +1586,8 @@ export default {
gauge_axis_label: '刻度標籤',
word_size_range: '字號區間',
word_spacing: '文字間隔',
axis_multi_select_tip: '按住 Ctrl/Cmd 鍵或者 Shift 鍵再點擊可多選'
axis_multi_select_tip: '按住 Ctrl/Cmd 鍵或者 Shift 鍵再點擊可多選',
needs_to_be_integer: '需要為整數'
},
dataset: {
scope_edit: '僅編輯時生效',
@ -2777,7 +2778,7 @@ export default {
fire_now_success: '任務發起成功',
larkgroups: '飛書群',
ext_wait_time: '加載儀表板額外等待時間(單位:秒)',
wat_time_limit: '額外等待時間必須在[0 - 30]'
wat_time_limit: '額外等待時間必須是[0 - 30]之間整數'
},
dynamic_time: {
set_default: '設置默認值',

View File

@ -1586,7 +1586,8 @@ export default {
gauge_axis_label: '刻度标签',
word_size_range: '字号区间',
word_spacing: '文字间隔',
axis_multi_select_tip: '按住 Ctrl/Cmd 键或者 Shift 键再点击可多选'
axis_multi_select_tip: '按住 Ctrl/Cmd 键或者 Shift 键再点击可多选',
needs_to_be_integer: '需要为整数'
},
dataset: {
scope_edit: '仅编辑时生效',
@ -2780,7 +2781,7 @@ export default {
fire_now_success: '任务发起成功',
larkgroups: '飞书群',
ext_wait_time: '加载仪表板额外等待时间(单位:秒)',
wat_time_limit: '额外等待时间必须在[0 - 30]'
wat_time_limit: '额外等待时间必须是[0 - 30]之间整数'
},
dynamic_time: {
set_default: '设置默认值',

View File

@ -156,7 +156,8 @@ const data = {
previewComponentData: [],
currentCanvasNewId: [],
lastViewRequestInfo: {},
multiplexingStyleAdapt: true // 复用样式跟随主题
multiplexingStyleAdapt: true, // 复用样式跟随主题
lastValidFilters: {}
},
mutations: {
...animation.mutations,
@ -562,6 +563,9 @@ const data = {
state.componentData.push(component)
},
deleteComponentWithId(state, id) {
if (state.lastValidFilters && state.lastValidFilters[id]) {
delete state.lastValidFilters[id]
}
for (let index = 0; index < state.componentData.length; index++) {
const element = state.componentData[index]
if (element.id && element.id === id) {
@ -819,6 +823,7 @@ const data = {
state.changeProperties[propertyInfo.custom][propertyInfo.property] = propertyInfo.value
},
initCanvasBase(state) {
this.commit('resetLastValidFilters')
this.commit('setCurComponent', { component: null, index: null })
this.commit('clearLinkageSettingInfo', false)
this.commit('resetViewEditInfo')
@ -889,6 +894,10 @@ const data = {
for (let index = 0; index < state.componentData.length; index++) {
const element = state.componentData[index]
if (element.canvasId && element.canvasId.includes(canvasId)) {
const cid = state.componentData[index]
if (state.lastValidFilters && state.lastValidFilters[cid]) {
delete state.lastValidFilters[cid]
}
state.componentData.splice(index, 1)
}
}
@ -913,6 +922,17 @@ const data = {
},
setMultiplexingStyleAdapt(state, value) {
state.multiplexingStyleAdapt = value
},
setLastValidFilters(state, data) {
state.lastValidFilters[data.componentId] = data
},
resetLastValidFilters(state) {
state.lastValidFilters = {}
},
delLastValidFilterWithId(state, id) {
if (state.lastValidFilters[id]) {
delete state.lastValidFilters[id]
}
}
},
modules: {

View File

@ -96,6 +96,7 @@ export const buildViewKeyFilters = (panelItems, result, isEdit = false) => {
return result
}
const buildItems = panelItems[0].canvasId === 'canvas-main' ? panelItems : store.state.componentData
const lastValidFilters = store.state.lastValidFilters
const canvasIdMap = buildCanvasIdMap(buildItems)
buildItems.forEach((element, index) => {
if (element.type !== 'custom') {
@ -105,15 +106,22 @@ export const buildViewKeyFilters = (panelItems, result, isEdit = false) => {
let param = null
const widget = ApplicationContext.getService(element.serviceName)
param = widget.getParam(element)
let lastFilter = null
if (lastValidFilters) {
lastFilter = lastValidFilters[element.id]
}
param = widget.getParam(element, lastFilter?.val)
const condition = formatCondition(param)
const vValid = valueValid(condition)
let vValid = valueValid(condition)
if (lastFilter && !lastFilter.val) {
vValid = false
}
const filterComponentId = condition.componentId
Object.keys(result).forEach(viewId => {
// 进行过滤时 如果过滤组件在主画布 则条件适用于所有画布视图 否则需要过滤组件和视图在相同画布
if (element.canvasId === 'canvas-main' || element.canvasId === canvasIdMap[viewId]) {
const vidMatch = viewIdMatch(condition.viewIds, viewId)
if (vidMatch && selectFirst && !element.options.loaded) {
if (vidMatch && selectFirst && !element.options.loaded && !lastFilter) {
const obj = {}
const promise = new Promise(resolve => {
cacheCondition(cbParam => {

View File

@ -121,11 +121,9 @@ export function baseTableInfo(s2, container, chart, action, tableData, pageInfo)
}
}
s2Options.colCell = (node) => {
if (node.colIndex === 0) {
node.label = ' '
}
}
}
// 开始渲染
if (s2) {
@ -312,11 +310,9 @@ export function baseTableNormal(s2, container, chart, action, tableData) {
}
}
s2Options.colCell = (node) => {
if (node.colIndex === 0) {
node.label = ' '
}
}
}
// 开始渲染
if (s2) {

View File

@ -144,7 +144,8 @@ export default {
'line',
'line-stack',
'scatter'
]
],
resizeTimer: null
}
},
@ -511,9 +512,16 @@ export default {
},
chartResize() {
//
const chart = this.myChart
chart.resize()
this.resizeTimer && clearTimeout(this.resizeTimer)
this.resizeTimer = setTimeout(() => {
const { offsetWidth, offsetHeight } = document.getElementById(this.chartId)
const chartWidth = this.myChart.getWidth()
const chartHeight = this.myChart.getHeight()
if (offsetWidth !== chartWidth || offsetHeight !== chartHeight) {
this.myChart.resize()
this.reDrawMap()
}
}, 100)
},
reDrawMap() {
const chart = this.chart

View File

@ -127,8 +127,8 @@ export default {
remarkCfg: {
show: false,
content: ''
}
},
resizeTimer: null
}
},
@ -156,17 +156,9 @@ export default {
chart: {
handler(newVal, oldVla) {
this.initTitle()
this.calcHeightDelay()
new Promise((resolve) => {
resolve()
}).then(() => {
this.drawView()
})
this.calcHeightRightNow(this.drawView)
},
deep: true
},
resize() {
this.drawEcharts()
}
},
beforeDestroy() {
@ -192,7 +184,7 @@ export default {
for (const key in this.pointParam) {
this.$delete(this.pointParam, key)
}
window.removeEventListener('resize', this.calcHeightDelay)
window.removeEventListener('resize', this.chartResize)
this.myChart = null
},
mounted() {
@ -238,13 +230,8 @@ export default {
},
preDraw() {
this.initTitle()
this.calcHeightDelay()
new Promise((resolve) => {
resolve()
}).then(() => {
this.drawView()
})
window.addEventListener('resize', this.calcHeightDelay)
this.calcHeightRightNow(this.drawView)
window.addEventListener('resize', this.chartResize)
},
async drawView() {
const chart = JSON.parse(JSON.stringify(this.chart))
@ -380,7 +367,10 @@ export default {
}
},
chartResize() {
this.calcHeightDelay()
this.resizeTimer && clearTimeout(this.resizeTimer)
this.resizeTimer = setTimeout(() => {
this.calcHeightRightNow()
}, 100)
},
trackClick(trackAction) {
const param = this.pointParam
@ -470,22 +460,19 @@ export default {
this.initRemark()
},
calcHeightRightNow() {
calcHeightRightNow(callback) {
this.$nextTick(() => {
if (this.$refs.chartContainer) {
const currentHeight = this.$refs.chartContainer.offsetHeight
const { offsetHeight } = this.$refs.chartContainer
let titleHeight = 0
if (this.$refs.title) {
const titleHeight = this.$refs.title.offsetHeight
this.chartHeight = (currentHeight - titleHeight) + 'px'
titleHeight = this.$refs.title.offsetHeight
}
this.chartHeight = (offsetHeight - titleHeight) + 'px'
this.$nextTick(() => callback?.())
}
})
},
calcHeightDelay() {
setTimeout(() => {
this.calcHeightRightNow()
}, 100)
},
initRemark() {
this.remarkCfg = getRemark(this.chart)
}

View File

@ -34,7 +34,7 @@
<div
ref="tableContainer"
style="width: 100%;overflow: hidden;"
:style="{background:container_bg_class.background}"
:style="{background:container_bg_class.background, height: chartHeight}"
>
<div
v-if="chart.type === 'table-normal'"
@ -180,7 +180,8 @@ export default {
totalStyle: {
color: '#606266'
},
not_support_page_dataset: NOT_SUPPORT_PAGE_DATASET
not_support_page_dataset: NOT_SUPPORT_PAGE_DATASET,
resizeTimer: null
}
},
@ -225,17 +226,9 @@ export default {
handler(newVal, oldVla) {
this.initData()
this.initTitle()
this.calcHeightDelay()
new Promise((resolve) => {
resolve()
}).then(() => {
this.drawView()
})
this.calcHeightRightNow(this.drawView)
},
deep: true
},
resize() {
this.drawEcharts()
}
},
mounted() {
@ -243,7 +236,7 @@ export default {
},
beforeDestroy() {
clearInterval(this.scrollTimer)
window.removeEventListener('resize', this.onResize)
window.removeEventListener('resize', this.chartResize)
this.myChart?.destroy?.()
this.myChart = null
},
@ -282,18 +275,10 @@ export default {
this.tableData = data
},
preDraw() {
this.onResize()
window.addEventListener('resize', this.onResize)
},
onResize() {
this.initData()
this.initTitle()
this.calcHeightDelay()
new Promise((resolve) => {
resolve()
}).then(() => {
this.drawView()
})
this.calcHeightRightNow(this.drawView)
window.addEventListener('resize', this.chartResize)
},
drawView() {
const chart = this.chart
@ -403,14 +388,22 @@ export default {
}
},
chartResize() {
this.resizeTimer && clearTimeout(this.resizeTimer)
this.resizeTimer = setTimeout(() => {
this.initData()
this.initTitle()
this.calcHeightDelay()
new Promise((resolve) => {
resolve()
}).then(() => {
this.drawView()
this.calcHeightRightNow((width, height) => {
const { width: chartWidth, height: chartHeight } = this.myChart.options
if (width !== chartWidth || height !== chartHeight) {
this.myChart?.changeSheetSize(width, height)
// tab
if (chartWidth || chartHeight || !(chartHeight || chartWidth)) {
this.myChart.render()
}
this.initScroll()
}
})
}, 100)
},
trackClick(trackAction) {
const param = this.pointParam
@ -483,24 +476,19 @@ export default {
this.initRemark()
},
calcHeightRightNow() {
calcHeightRightNow(callback) {
this.$nextTick(() => {
if (this.$refs.chartContainer) {
const currentHeight = this.$refs.chartContainer.offsetHeight
const { offsetWidth, offsetHeight } = this.$refs.chartContainer
let titleHeight = 0
if (this.$refs.title) {
const titleHeight = this.$refs.title.offsetHeight
this.chartHeight = (currentHeight - titleHeight) + 'px'
this.$refs.tableContainer.style.height = this.chartHeight
titleHeight = this.$refs.title.offsetHeight
}
this.chartHeight = (offsetHeight - titleHeight) + 'px'
this.$nextTick(() => callback?.(offsetWidth, offsetHeight - titleHeight))
}
})
},
calcHeightDelay() {
this.calcHeightRightNow()
setTimeout(() => {
this.calcHeightRightNow()
}, 100)
},
pageChange(val) {
this.currentPage.pageSize = val
if (this.chart.datasetMode === 0 && !NOT_SUPPORT_PAGE_DATASET.includes(this.chart.datasourceType)) {
@ -536,23 +524,28 @@ export default {
const senior = JSON.parse(this.chart.senior)
this.scrollTop = 0
this.myChart.store.set('scrollY', this.scrollTop)
this.myChart.render()
if (senior && senior.scrollCfg && senior.scrollCfg.open && (this.chart.type === 'table-normal' || (this.chart.type === 'table-info' && !this.showPage))) {
const rowHeight = customAttr.size.tableItemHeight
const headerHeight = customAttr.size.tableTitleHeight
this.scrollTimer = setInterval(() => {
const offsetHeight = document.getElementById(this.chartId).offsetHeight
const top = rowHeight * senior.scrollCfg.row
const dom = document.getElementById(this.chartId)
if ((dom.offsetHeight - headerHeight + this.scrollTop) < rowHeight * this.chart.data.tableRow.length) {
if ((offsetHeight - headerHeight + this.scrollTop) < rowHeight * this.chart.data.tableRow.length) {
this.scrollTop += top
} else {
this.scrollTop = 0
}
this.myChart.store.set('scrollY', this.scrollTop)
this.myChart.render()
if (!offsetHeight) {
return
}
this.myChart.facet.scrollWithAnimation({
offsetY: {
value: this.scrollTop,
animate: false
}
})
}, senior.scrollCfg.interval)
}
},

View File

@ -1307,6 +1307,11 @@ export default {
this.$message.error(this.$t('chart.max_more_than_mix'))
return
}
const reg = /^\d+$/m
if (!reg.test(this.sizeForm.tableColumnFreezeHead)) {
this.$message.error(this.$t('chart.table_freeze') + this.$t('chart.needs_to_be_integer'))
return
}
this.$emit('onSizeChange', this.sizeForm)
},
showProperty(property) {

View File

@ -1782,6 +1782,11 @@ export default {
this.$message.error(this.$t('chart.max_more_than_mix'))
return
}
const reg = /^\d+$/m
if (!reg.test(this.sizeForm.tableRowFreezeHead) || !reg.test(this.sizeForm.tableColumnFreezeHead)) {
this.$message.error(this.$t('chart.table_freeze') + this.$t('chart.needs_to_be_integer'))
return
}
this.$emit('onSizeChange', this.sizeForm)
},
showProperty(property) {

View File

@ -214,7 +214,8 @@ export default {
top: '0px'
},
pointParam: null,
showSummary: true
showSummary: true,
resizeTimer: null
}
},
computed: {
@ -425,7 +426,8 @@ export default {
})
},
calcHeightDelay() {
setTimeout(() => {
this.resizeTimer && clearTimeout(this.resizeTimer)
this.resizeTimer = setTimeout(() => {
this.calcHeightRightNow()
}, 100)
},
@ -478,16 +480,6 @@ export default {
}
}
this.table_item_class_stripe = JSON.parse(JSON.stringify(this.table_item_class))
//
// if (customAttr.color.tableStripe) {
// // this.table_item_class_stripe.background = hexColorToRGBA(customAttr.color.tableItemBgColor, customAttr.color.alpha - 40)
// if (this.chart.customStyle) {
// const customStyle = JSON.parse(this.chart.customStyle)
// if (customStyle.background) {
// this.table_item_class_stripe.background = hexColorToRGBA(customStyle.background.color, customStyle.background.alpha)
// }
// }
// }
if (customAttr.color.enableTableCrossBG) {
this.table_item_class_stripe.background = hexColorToRGBA(customAttr.color.tableItemSubBgColor, customAttr.color.alpha)
}
@ -607,12 +599,6 @@ export default {
const scrollContainer = document.getElementsByClassName(this.chart.id)[0].getElementsByClassName('elx-table--body-wrapper')[0]
this.scrollTop = 0
setTimeout(() => {
scrollContainer.scrollTo({
top: this.scrollTop,
behavior: this.scrollTop === 0 ? 'instant' : 'smooth'
})
}, 0)
if (senior && senior.scrollCfg && senior.scrollCfg.open && (this.chart.type === 'table-normal' || (this.chart.type === 'table-info' && !this.showPage))) {
let rowHeight = customAttr.size.tableItemHeight
@ -631,11 +617,16 @@ export default {
top = rowHeight * senior.scrollCfg.row
}
if (scrollContainer.clientHeight + scrollContainer.scrollTop < scrollContainer.scrollHeight) {
const { clientHeight, scrollTop, scrollHeight } = scrollContainer
if (clientHeight + scrollTop < scrollHeight) {
this.scrollTop += top
} else {
this.scrollTop = 0
}
if (!clientHeight) {
return
}
scrollContainer.scrollTo({
top: this.scrollTop,
behavior: this.scrollTop === 0 ? 'instant' : 'smooth'

View File

@ -2436,6 +2436,7 @@ export default {
}
},
resetChangeTable() {
this.view.customFilter = {}
const compareData = {}
this.dimensionData.forEach(deimension => {
compareData[deimension.originName] = deimension
@ -2443,7 +2444,7 @@ export default {
this.quotaData.forEach(quota => {
compareData[quota.originName] = quota
})
const compareCols = ['xaxis', 'xaxisExt', 'yaxis', 'yaxisExt', 'customFilter', 'extStack', 'extBubble', 'drillFields']
const compareCols = ['xaxis', 'xaxisExt', 'yaxis', 'yaxisExt', 'extStack', 'extBubble', 'drillFields']
this.viewFieldChange(compareData, compareCols)
},
viewFieldChange(compareData, compareCols) {

View File

@ -1269,6 +1269,7 @@ export default {
this.$store.commit('recordSnapshot', 'sureFilter')
this.$store.commit('setCurComponent', { component: this.currentFilterCom, index: this.curComponentIndex })
this.$store.commit('setComponentFromList', this.currentFilterCom)
this.$store.commit('delLastValidFilterWithId', this.currentFilterCom.id)
bus.$emit('reset-default-value', this.currentFilterCom)
this.closeFilter()
},

View File

@ -1,8 +1,8 @@
#!/bin/sh
mvn clean package
cp view-chartmix-backend/target/view-chartmix-backend-1.18.13.jar .
cp view-chartmix-backend/target/view-chartmix-backend-1.18.14.jar .
zip -r chartmix.zip ./view-chartmix-backend-1.18.13.jar ./plugin.json
zip -r chartmix.zip ./view-chartmix-backend-1.18.14.jar ./plugin.json
rm -f ./view-chartmix-backend-1.18.13.jar
rm -f ./view-chartmix-backend-1.18.14.jar

View File

@ -0,0 +1,14 @@
package io.dataease.plugins.view.official.impl;
/**
* @Author gin
* @Date 2021/12/9 3:58 下午
*/
public class ChartConstants {
public static final String YEAR_MOM = "year_mom";
public static final String MONTH_MOM = "month_mom";
public static final String YEAR_YOY = "year_yoy";
public static final String DAY_MOM = "day_mom";
public static final String MONTH_YOY = "month_yoy";
public static final String[] M_Y = {YEAR_MOM, MONTH_MOM, YEAR_YOY, DAY_MOM, MONTH_YOY};
}

View File

@ -1,20 +1,20 @@
package io.dataease.plugins.view.official.impl;
import com.google.gson.Gson;
import io.dataease.plugins.common.dto.StaticResource;
import io.dataease.plugins.common.dto.chart.ChartFieldCompareDTO;
import io.dataease.plugins.view.entity.*;
import io.dataease.plugins.view.official.handler.ChartMixViewStatHandler;
import io.dataease.plugins.view.service.ViewPluginService;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.ObjectUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;
import java.io.InputStream;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.math.RoundingMode;
import java.text.SimpleDateFormat;
import java.util.*;
@Service
public class ChartMixService extends ViewPluginService {
@ -114,7 +114,6 @@ public class ChartMixService extends ViewPluginService {
return null;
}
String sql = new ChartMixViewStatHandler().build(param, this);
System.out.println(sql);
return sql;
}
@ -125,7 +124,6 @@ public class ChartMixService extends ViewPluginService {
List<PluginViewField> xAxis = new ArrayList<>();
List<PluginViewField> yAxis = new ArrayList<>();
System.out.println("pluginViewParam: " + new Gson().toJson(pluginViewParam));
pluginViewParam.getPluginViewFields().forEach(pluginViewField -> {
if (StringUtils.equals(pluginViewField.getTypeField(), "xAxis")) {
@ -141,12 +139,117 @@ public class ChartMixService extends ViewPluginService {
map.put("data", series);
System.out.println(new Gson().toJson(map));
return map;
}
private List<PluginSeries> format(String type, List<String[]> data, List<PluginViewField> xAxis, List<PluginViewField> yAxis) {
// 同比/环比计算
// 调整data数据
for (int i = 0; i < yAxis.size(); i++) {
PluginViewField chartViewFieldDTO = yAxis.get(i);
ChartFieldCompareDTO compareCalc = chartViewFieldDTO.getCompareCalc();
if (ObjectUtils.isEmpty(compareCalc)) {
continue;
}
if (StringUtils.isNotEmpty(compareCalc.getType())
&& !StringUtils.equalsIgnoreCase(compareCalc.getType(), "none")) {
String compareFieldId = compareCalc.getField();// 选中字段
// 计算指标对应的下标
int dataIndex = 0;// 数据字段下标
dataIndex = xAxis.size() + i;
if (Arrays.asList(ChartConstants.M_Y).contains(compareCalc.getType())) {
String resultData = compareCalc.getResultData();// 数据设置
// 获取选中字段以及下标
List<PluginViewField> checkedField = new ArrayList<>(xAxis);
int timeIndex = 0;// 时间字段下标
PluginViewField timeField = null;
for (int j = 0; j < checkedField.size(); j++) {
if (StringUtils.equalsIgnoreCase(checkedField.get(j).getId(), compareFieldId)) {
timeIndex = j;
timeField = checkedField.get(j);
}
}
// 无选中字段或者选中字段已经不在维度list中或者选中字段日期格式不符合对比类型的直接将对应数据置为null
if (ObjectUtils.isEmpty(timeField) || !checkCalcType(timeField.getDateStyle(), compareCalc.getType())) {
// set null
for (String[] item : data) {
item[dataIndex] = null;
}
} else {
// 计算 同比/环比
// 1处理当期数据2根据type计算上一期数据3根据resultData计算结果
Map<String, String> currentMap = new LinkedHashMap<>();
for (String[] item : data) {
String[] dimension = Arrays.copyOfRange(item, 0, checkedField.size());
currentMap.put(StringUtils.join(dimension, "-"), item[dataIndex]);
}
for (int index = 0; index < data.size(); index++) {
String[] item = data.get(index);
String cTime = item[timeIndex];
String cValue = item[dataIndex];
// 获取计算后的时间并且与所有维度拼接
String lastTime = calcLastTime(cTime, compareCalc.getType(), timeField.getDateStyle(), timeField.getDatePattern());
String[] dimension = Arrays.copyOfRange(item, 0, checkedField.size());
dimension[timeIndex] = lastTime;
String lastValue = currentMap.get(StringUtils.join(dimension, "-"));
if (StringUtils.isEmpty(cValue) || StringUtils.isEmpty(lastValue)) {
item[dataIndex] = null;
} else {
if (StringUtils.equalsIgnoreCase(resultData, "sub")) {
item[dataIndex] = new BigDecimal(cValue).subtract(new BigDecimal(lastValue)).toString();
} else if (StringUtils.equalsIgnoreCase(resultData, "percent")) {
if (new BigDecimal(lastValue).compareTo(BigDecimal.ZERO) == 0) {
item[dataIndex] = null;
} else {
item[dataIndex] = new BigDecimal(cValue)
.divide(new BigDecimal(lastValue), 8, RoundingMode.HALF_UP)
.subtract(new BigDecimal(1))
.setScale(8, RoundingMode.HALF_UP)
.toString();
}
}
}
}
}
} else if (StringUtils.equalsIgnoreCase(compareCalc.getType(), "percent")) {
// 求和
BigDecimal sum = new BigDecimal(0);
for (int index = 0; index < data.size(); index++) {
String[] item = data.get(index);
String cValue = item[dataIndex];
if (StringUtils.isEmpty(cValue)) {
continue;
}
sum = sum.add(new BigDecimal(cValue));
}
// 计算占比
for (int index = 0; index < data.size(); index++) {
String[] item = data.get(index);
String cValue = item[dataIndex];
if (StringUtils.isEmpty(cValue)) {
continue;
}
if (sum.equals(new BigDecimal(0))) {
continue;
}
item[dataIndex] = new BigDecimal(cValue)
.divide(sum, 8, RoundingMode.HALF_UP)
.toString();
}
}
}
}
// 同比/环比计算 over
List<PluginSeries> series = new ArrayList<>();
for (PluginViewField y : yAxis) {
PluginSeries series1 = new PluginSeries();
@ -188,4 +291,96 @@ public class ChartMixService extends ViewPluginService {
return series;
}
private boolean checkCalcType(String dateStyle, String calcType) {
switch (dateStyle) {
case "y":
return StringUtils.equalsIgnoreCase(calcType, "year_mom");
case "y_M":
return StringUtils.equalsIgnoreCase(calcType, "month_mom")
|| StringUtils.equalsIgnoreCase(calcType, "year_yoy");
case "y_M_d":
return StringUtils.equalsIgnoreCase(calcType, "day_mom")
|| StringUtils.equalsIgnoreCase(calcType, "month_yoy")
|| StringUtils.equalsIgnoreCase(calcType, "year_yoy");
}
return false;
}
private String calcLastTime(String cTime, String type, String dateStyle, String datePattern) {
try {
String lastTime = null;
Calendar calendar = Calendar.getInstance();
if (StringUtils.equalsIgnoreCase(type, ChartConstants.YEAR_MOM)) {
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy");
Date date = simpleDateFormat.parse(cTime);
calendar.setTime(date);
calendar.add(Calendar.YEAR, -1);
lastTime = simpleDateFormat.format(calendar.getTime());
} else if (StringUtils.equalsIgnoreCase(type, ChartConstants.MONTH_MOM)) {
SimpleDateFormat simpleDateFormat = null;
if (StringUtils.equalsIgnoreCase(datePattern, "date_split")) {
simpleDateFormat = new SimpleDateFormat("yyyy/MM");
} else {
simpleDateFormat = new SimpleDateFormat("yyyy-MM");
}
Date date = simpleDateFormat.parse(cTime);
calendar.setTime(date);
calendar.add(Calendar.MONTH, -1);
lastTime = simpleDateFormat.format(calendar.getTime());
} else if (StringUtils.equalsIgnoreCase(type, ChartConstants.YEAR_YOY)) {
SimpleDateFormat simpleDateFormat = null;
if (StringUtils.equalsIgnoreCase(dateStyle, "y_M")) {
if (StringUtils.equalsIgnoreCase(datePattern, "date_split")) {
simpleDateFormat = new SimpleDateFormat("yyyy/MM");
} else {
simpleDateFormat = new SimpleDateFormat("yyyy-MM");
}
} else if (StringUtils.equalsIgnoreCase(dateStyle, "y_M_d")) {
if (StringUtils.equalsIgnoreCase(datePattern, "date_split")) {
simpleDateFormat = new SimpleDateFormat("yyyy/MM/dd");
} else {
simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
}
}
Date date = simpleDateFormat.parse(cTime);
calendar.setTime(date);
calendar.add(Calendar.YEAR, -1);
lastTime = simpleDateFormat.format(calendar.getTime());
} else if (StringUtils.equalsIgnoreCase(type, ChartConstants.DAY_MOM)) {
SimpleDateFormat simpleDateFormat = null;
if (StringUtils.equalsIgnoreCase(datePattern, "date_split")) {
simpleDateFormat = new SimpleDateFormat("yyyy/MM/dd");
} else {
simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
}
Date date = simpleDateFormat.parse(cTime);
calendar.setTime(date);
calendar.add(Calendar.DAY_OF_MONTH, -1);
lastTime = simpleDateFormat.format(calendar.getTime());
} else if (StringUtils.equalsIgnoreCase(type, ChartConstants.MONTH_YOY)) {
SimpleDateFormat simpleDateFormat = null;
if (StringUtils.equalsIgnoreCase(dateStyle, "y_M")) {
if (StringUtils.equalsIgnoreCase(datePattern, "date_split")) {
simpleDateFormat = new SimpleDateFormat("yyyy/MM");
} else {
simpleDateFormat = new SimpleDateFormat("yyyy-MM");
}
} else if (StringUtils.equalsIgnoreCase(dateStyle, "y_M_d")) {
if (StringUtils.equalsIgnoreCase(datePattern, "date_split")) {
simpleDateFormat = new SimpleDateFormat("yyyy/MM/dd");
} else {
simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
}
}
Date date = simpleDateFormat.parse(cTime);
calendar.setTime(date);
calendar.add(Calendar.MONTH, -1);
lastTime = simpleDateFormat.format(calendar.getTime());
}
return lastTime;
} catch (Exception e) {
return cTime;
}
}
}

View File

@ -235,6 +235,9 @@ export default {
this.customColor = this.colorForm.colors[0]
this.colorIndex = 0
}
if(this.colorForm.gradient === undefined){
this.colorForm.gradient = false
}
}
}

View File

@ -11,12 +11,12 @@ export function getItemType(dimensionData, quotaData, item) {
for (let i = 0; i < dimensionData.length; i++) {
const ele = dimensionData[i]
if (item.chartId) {
if (ele.dataeaseName === item.dataeaseName && ele.deType === item.deType && ele.groupType === item.groupType) {
if (ele.dataeaseName === item.dataeaseName && ele.deType === item.deType && ele.groupType === item.groupType && ele.originName === item.originName) {
checked = true
break
}
} else {
if (ele.id === item.id && ele.deType === item.deType && ele.groupType === item.groupType) {
if (ele.id === item.id && ele.deType === item.deType && ele.groupType === item.groupType && ele.originName === item.originName) {
checked = true
break
}
@ -27,12 +27,12 @@ export function getItemType(dimensionData, quotaData, item) {
for (let i = 0; i < quotaData.length; i++) {
const ele = quotaData[i]
if (item.chartId) {
if (ele.dataeaseName === item.dataeaseName && ele.deType === item.deType && ele.groupType === item.groupType) {
if (ele.dataeaseName === item.dataeaseName && ele.deType === item.deType && ele.groupType === item.groupType && ele.originName === item.originName) {
checked = true
break
}
} else {
if (ele.id === item.id && ele.deType === item.deType && ele.groupType === item.groupType) {
if (ele.id === item.id && ele.deType === item.deType && ele.groupType === item.groupType && ele.originName === item.originName) {
checked = true
break
}

View File

@ -142,7 +142,7 @@ public class SymbolMapRSHandler implements PluginViewRSHandler<Map> {
if (StringUtils.isBlank(val)) return val;
String typeField = field.getTypeField();
if (StringUtils.isNotBlank(typeField) && trans2Ykeys.contains(typeField)) {
return Arrays.stream(val.split(",")).distinct().collect(Collectors.joining(","));
return Arrays.stream(val.split(",")).map(StringUtils::trim).distinct().collect(Collectors.joining(","));
}
return val;
}

View File

@ -15,6 +15,8 @@ DE_DORIS_FE_IP=172.19.0.198
DE_DORIS_BE_IP=172.19.0.199
## 登录超时时间单位min。如果不设置则默认8小时也就是480
DE_LOGIN_TIMEOUT=480
## 新建用户初始密码
DE_INIT_PASSWORD=DataEase123456
# 数据库配置
## 是否使用外部数据库

View File

@ -75,10 +75,12 @@ echo -e "*******************************************************\n" 2>&1 | tee -
if [[ -f $dataease_conf ]]; then
DE_LOGIN_TIMEOUT=$(prop $dataease_conf dataease.login_timeout)
DE_INIT_PASSWORD=$(prop $dataease_conf dataease.init_password)
DE_MYSQL_PARAMS=$(grep -P "^\s*[^#]?spring.datasource.url=.*$" $dataease_conf | cut -d'=' --complement -f1 | awk -F'?' '{print $2}')
fi
export DE_MYSQL_PARAMS
export DE_LOGIN_TIMEOUT=$([[ -z $DE_LOGIN_TIMEOUT ]] && echo -n 480 || echo -n $DE_LOGIN_TIMEOUT)
export DE_INIT_PASSWORD=$([[ -z $DE_INIT_PASSWORD ]] && echo -n DataEase123456 || echo -n $DE_INIT_PASSWORD)
if [[ -f $dataease_conf ]] && [[ ! ${DE_EXTERNAL_DORIS} ]]; then
export DE_DORIS_DB=$(prop $dataease_conf doris.db)

View File

@ -16,7 +16,7 @@ doris.port=${DE_DORIS_PORT}
doris.httpPort=${DE_DORIS_HTTPPORT}
#新建用户初始密码
dataease.init_password=DataEase123456
dataease.init_password=${DE_INIT_PASSWORD}
#登录超时时间单位min 如果不设置 默认8小时也就是480
dataease.login_timeout=${DE_LOGIN_TIMEOUT}

View File

@ -1,5 +1,6 @@
package io.dataease.plugins.view.entity;
import io.dataease.plugins.common.dto.chart.ChartFieldCompareDTO;
import lombok.Data;
import java.util.List;
@ -11,5 +12,7 @@ public class PluginViewField extends PluginChartViewFieldBase {
private List<PluginChartCustomFilterItem> filter;
private ChartFieldCompareDTO compareCalc;
private String busiType;
}