Merge remote-tracking branch 'origin/dev' into dev
This commit is contained in:
commit
bd63ce34dc
@ -1,11 +1,18 @@
|
|||||||
package io.dataease.service.chart.build;
|
package io.dataease.service.chart.build;
|
||||||
|
|
||||||
|
import cn.hutool.core.bean.BeanUtil;
|
||||||
|
import io.dataease.commons.utils.LogUtil;
|
||||||
|
import io.dataease.controller.dataset.DataSetTableFieldController;
|
||||||
|
import io.dataease.controller.request.dataset.MultFieldValuesRequest;
|
||||||
import io.dataease.dto.chart.FilterParamTO;
|
import io.dataease.dto.chart.FilterParamTO;
|
||||||
|
import io.dataease.dto.dataset.DeSortDTO;
|
||||||
import io.dataease.service.chart.FilterBuildTemplate;
|
import io.dataease.service.chart.FilterBuildTemplate;
|
||||||
|
import org.apache.commons.collections4.CollectionUtils;
|
||||||
import org.apache.commons.lang3.ObjectUtils;
|
import org.apache.commons.lang3.ObjectUtils;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import javax.annotation.Resource;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@ -14,6 +21,10 @@ import java.util.stream.Collectors;
|
|||||||
|
|
||||||
@Service("selectWidget")
|
@Service("selectWidget")
|
||||||
public class SelectBuild extends FilterBuildTemplate {
|
public class SelectBuild extends FilterBuildTemplate {
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private DataSetTableFieldController dataSetTableFieldController;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected FilterParamTO buildParam(Map<String, Object> component) {
|
protected FilterParamTO buildParam(Map<String, Object> component) {
|
||||||
FilterParamTO result = new FilterParamTO();
|
FilterParamTO result = new FilterParamTO();
|
||||||
@ -23,30 +34,34 @@ public class SelectBuild extends FilterBuildTemplate {
|
|||||||
Object valueObj = null;
|
Object valueObj = null;
|
||||||
|
|
||||||
List<String> realValues = null;
|
List<String> realValues = null;
|
||||||
if(ObjectUtils.isEmpty(component.get("options"))) return result;
|
if (ObjectUtils.isEmpty(component.get("options"))) return result;
|
||||||
Map<String, Object> options = (Map<String, Object>)component.get("options");
|
Map<String, Object> options = (Map<String, Object>) component.get("options");
|
||||||
|
|
||||||
valueObj = options.get("value");
|
valueObj = options.get("value");
|
||||||
String defaultValue = "";
|
String defaultValue = "";
|
||||||
Map<String, Object> attrs = (Map<String, Object>) options.get("attrs");
|
Map<String, Object> attrs = (Map<String, Object>) options.get("attrs");
|
||||||
boolean multiple = (boolean) attrs.get("multiple");
|
boolean multiple = (boolean) attrs.get("multiple");
|
||||||
if(!ObjectUtils.isEmpty(valueObj)) {
|
if (!ObjectUtils.isEmpty(valueObj)) {
|
||||||
if(valueObj instanceof List) {
|
if (valueObj instanceof List) {
|
||||||
defaultValue = "";
|
defaultValue = "";
|
||||||
}else {
|
} else {
|
||||||
defaultValue = valueObj.toString();
|
defaultValue = valueObj.toString();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(multiple) {
|
boolean isSelectFirst = StringUtils.equals("custom", component.get("type").toString()) && ObjectUtils.isNotEmpty(attrs.get("selectFirst")) && (boolean) attrs.get("selectFirst");
|
||||||
|
if (isSelectFirst) {
|
||||||
|
defaultValue = getFirst(attrs);
|
||||||
|
}
|
||||||
|
if (multiple) {
|
||||||
if (StringUtils.isBlank(defaultValue)) {
|
if (StringUtils.isBlank(defaultValue)) {
|
||||||
realValues = new ArrayList<>();
|
realValues = new ArrayList<>();
|
||||||
}else {
|
} else {
|
||||||
realValues = Arrays.asList(defaultValue.split(","));
|
realValues = Arrays.asList(defaultValue.split(","));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (StringUtils.isBlank(defaultValue)) {
|
if (StringUtils.isBlank(defaultValue)) {
|
||||||
realValues = new ArrayList<>();
|
realValues = new ArrayList<>();
|
||||||
}else {
|
} else {
|
||||||
realValues = Arrays.asList(defaultValue.split(",")).stream().limit(1).collect(Collectors.toList());
|
realValues = Arrays.asList(defaultValue.split(",")).stream().limit(1).collect(Collectors.toList());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -54,4 +69,22 @@ public class SelectBuild extends FilterBuildTemplate {
|
|||||||
result.setValue(realValues);
|
result.setValue(realValues);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private String getFirst(Map<String, Object> attrs) {
|
||||||
|
MultFieldValuesRequest request = new MultFieldValuesRequest();
|
||||||
|
request.setFieldIds(Arrays.stream(attrs.get("fieldId").toString().split(",")).collect(Collectors.toList()));
|
||||||
|
if (ObjectUtils.isNotEmpty(attrs.get("sort"))) {
|
||||||
|
DeSortDTO sort = BeanUtil.copyProperties(attrs.get("sort"), DeSortDTO.class);
|
||||||
|
request.setSort(sort);
|
||||||
|
}
|
||||||
|
List<Object> list = null;
|
||||||
|
try {
|
||||||
|
list = dataSetTableFieldController.multFieldValues(request);
|
||||||
|
} catch (Exception e) {
|
||||||
|
LogUtil.error(e.getMessage());
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
if (CollectionUtils.isEmpty(list)) return null;
|
||||||
|
return list.get(0).toString();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -827,6 +827,9 @@ export default {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
getData(id, cache = true, dataBroadcast = false) {
|
getData(id, cache = true, dataBroadcast = false) {
|
||||||
|
if (this.requestStatus === 'waiting') {
|
||||||
|
return
|
||||||
|
}
|
||||||
if (id) {
|
if (id) {
|
||||||
const filters = this.filter.filter
|
const filters = this.filter.filter
|
||||||
const group = this.groupRequiredInvalid(filters)
|
const group = this.groupRequiredInvalid(filters)
|
||||||
@ -933,6 +936,12 @@ export default {
|
|||||||
return true
|
return true
|
||||||
}).catch(err => {
|
}).catch(err => {
|
||||||
console.error('err-' + err)
|
console.error('err-' + err)
|
||||||
|
// 还没有构内部刷新
|
||||||
|
if (!this.innerRefreshTimer) {
|
||||||
|
setTimeout(() => {
|
||||||
|
this.getData(this.element.propValue.viewId)
|
||||||
|
}, 5000)
|
||||||
|
}
|
||||||
this.requestStatus = 'error'
|
this.requestStatus = 'error'
|
||||||
if (err.message && err.message.indexOf('timeout') > -1) {
|
if (err.message && err.message.indexOf('timeout') > -1) {
|
||||||
this.message = this.$t('panel.timeout_refresh')
|
this.message = this.$t('panel.timeout_refresh')
|
||||||
|
|||||||
@ -164,8 +164,10 @@ export default {
|
|||||||
'defaultValueStr': function(value, old) {
|
'defaultValueStr': function(value, old) {
|
||||||
if (value === old) return
|
if (value === old) return
|
||||||
this.$nextTick(() => {
|
this.$nextTick(() => {
|
||||||
|
if (!this.selectFirst) {
|
||||||
this.value = this.fillValueDerfault()
|
this.value = this.fillValueDerfault()
|
||||||
this.changeValue(value)
|
this.changeValue(value)
|
||||||
|
}
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
'element.options.attrs.fieldId': function(value, old) {
|
'element.options.attrs.fieldId': function(value, old) {
|
||||||
@ -363,8 +365,8 @@ export default {
|
|||||||
const id = ele.id
|
const id = ele.id
|
||||||
const eleVal = ele.options.value.toString()
|
const eleVal = ele.options.value.toString()
|
||||||
if (this.inDraw && this.manualModify && this.element.id === id) {
|
if (this.inDraw && this.manualModify && this.element.id === id) {
|
||||||
if (this.selectFirst) {
|
if (ele.options.attrs.selectFirst) {
|
||||||
this.fillFirstValue()
|
this.fillFirstValue(true)
|
||||||
this.firstChange(this.value)
|
this.firstChange(this.value)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@ -503,8 +505,8 @@ export default {
|
|||||||
}
|
}
|
||||||
return this.value.split(',')
|
return this.value.split(',')
|
||||||
},
|
},
|
||||||
fillFirstValue() {
|
fillFirstValue(isSelectFirst) {
|
||||||
if (!this.selectFirst) {
|
if (!this.selectFirst && !isSelectFirst) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
let defaultV = this.data[0].id
|
let defaultV = this.data[0].id
|
||||||
|
|||||||
@ -1112,6 +1112,7 @@ export default {
|
|||||||
desc: 'Descending Order',
|
desc: 'Descending Order',
|
||||||
sort: 'Sort',
|
sort: 'Sort',
|
||||||
filter: 'Filter',
|
filter: 'Filter',
|
||||||
|
is_set: 'Is Set',
|
||||||
none: 'None',
|
none: 'None',
|
||||||
background: 'Background',
|
background: 'Background',
|
||||||
|
|
||||||
|
|||||||
@ -1112,6 +1112,7 @@ export default {
|
|||||||
desc: '降序',
|
desc: '降序',
|
||||||
sort: '排序',
|
sort: '排序',
|
||||||
filter: '過濾',
|
filter: '過濾',
|
||||||
|
is_set: '已設定',
|
||||||
none: '無',
|
none: '無',
|
||||||
background: '背景',
|
background: '背景',
|
||||||
border: '邊角',
|
border: '邊角',
|
||||||
|
|||||||
@ -1111,6 +1111,7 @@ export default {
|
|||||||
desc: '降序',
|
desc: '降序',
|
||||||
sort: '排序',
|
sort: '排序',
|
||||||
filter: '过滤',
|
filter: '过滤',
|
||||||
|
is_set: '已设置',
|
||||||
none: '无',
|
none: '无',
|
||||||
background: '背景',
|
background: '背景',
|
||||||
border: '边角',
|
border: '边角',
|
||||||
|
|||||||
@ -452,7 +452,11 @@ const data = {
|
|||||||
currentFilters.push(condition)
|
currentFilters.push(condition)
|
||||||
}
|
}
|
||||||
if (element.type === 'custom' && element.id === targetViewId) { // 过滤组件处理
|
if (element.type === 'custom' && element.id === targetViewId) { // 过滤组件处理
|
||||||
|
if (['de-select-tree'].includes(element.component)) {
|
||||||
|
element.options.value = dimension.value
|
||||||
|
} else {
|
||||||
element.options.value = [dimension.value]
|
element.options.value = [dimension.value]
|
||||||
|
}
|
||||||
// 去掉动态时间
|
// 去掉动态时间
|
||||||
if (element.options.manualModify) {
|
if (element.options.manualModify) {
|
||||||
element.options.manualModify = false
|
element.options.manualModify = false
|
||||||
@ -486,10 +490,20 @@ const data = {
|
|||||||
Object.keys(params).forEach(function(sourceInfo) {
|
Object.keys(params).forEach(function(sourceInfo) {
|
||||||
// 获取外部参数的值 sourceInfo 是外部参数名称 支持数组传入
|
// 获取外部参数的值 sourceInfo 是外部参数名称 支持数组传入
|
||||||
let paramValue = params[sourceInfo]
|
let paramValue = params[sourceInfo]
|
||||||
|
let paramValueStr = params[sourceInfo]
|
||||||
let operator = 'in'
|
let operator = 'in'
|
||||||
if (paramValue && !Array.isArray(paramValue)) {
|
if (paramValue && !Array.isArray(paramValue)) {
|
||||||
paramValue = [paramValue]
|
paramValue = [paramValue]
|
||||||
operator = 'eq'
|
operator = 'eq'
|
||||||
|
} else if (paramValue && Array.isArray(paramValue)) {
|
||||||
|
paramValueStr = ''
|
||||||
|
paramValue.forEach((innerValue, index) => {
|
||||||
|
if (index === 0) {
|
||||||
|
paramValueStr = innerValue
|
||||||
|
} else {
|
||||||
|
paramValueStr = paramValueStr + ',' + innerValue
|
||||||
|
}
|
||||||
|
})
|
||||||
}
|
}
|
||||||
// 获取所有目标联动信息
|
// 获取所有目标联动信息
|
||||||
const targetInfoList = trackInfo[sourceInfo] || []
|
const targetInfoList = trackInfo[sourceInfo] || []
|
||||||
@ -513,7 +527,11 @@ const data = {
|
|||||||
currentFilters.push(condition)
|
currentFilters.push(condition)
|
||||||
}
|
}
|
||||||
if (element.type === 'custom' && element.id === targetViewId) { // 过滤组件处理
|
if (element.type === 'custom' && element.id === targetViewId) { // 过滤组件处理
|
||||||
|
if (['de-select-tree'].includes(element.component)) {
|
||||||
|
element.options.value = paramValueStr
|
||||||
|
} else {
|
||||||
element.options.value = paramValue
|
element.options.value = paramValue
|
||||||
|
}
|
||||||
// 去掉动态时间
|
// 去掉动态时间
|
||||||
if (element.options.manualModify) {
|
if (element.options.manualModify) {
|
||||||
element.options.manualModify = false
|
element.options.manualModify = false
|
||||||
|
|||||||
@ -1121,7 +1121,7 @@
|
|||||||
<span
|
<span
|
||||||
v-if="!!view.customFilter.logic"
|
v-if="!!view.customFilter.logic"
|
||||||
class="setting"
|
class="setting"
|
||||||
>已设置</span>
|
>{{ $t('chart.is_set') }}</span>
|
||||||
<i
|
<i
|
||||||
class="el-icon-arrow-down el-icon-delete data-area-clear"
|
class="el-icon-arrow-down el-icon-delete data-area-clear"
|
||||||
@click="deleteTreeFilter"
|
@click="deleteTreeFilter"
|
||||||
@ -1136,7 +1136,7 @@
|
|||||||
class="svg-background"
|
class="svg-background"
|
||||||
icon-class="icon-filter_outlined"
|
icon-class="icon-filter_outlined"
|
||||||
/>
|
/>
|
||||||
<span>过滤</span>
|
<span>{{ $t('chart.filter') }}</span>
|
||||||
</div>
|
</div>
|
||||||
</el-row>
|
</el-row>
|
||||||
<el-row
|
<el-row
|
||||||
|
|||||||
@ -76,7 +76,7 @@
|
|||||||
<span
|
<span
|
||||||
v-if="!!view.customFilter.logic"
|
v-if="!!view.customFilter.logic"
|
||||||
class="setting"
|
class="setting"
|
||||||
>已设置</span>
|
>{{ $t('chart.is_set') }}</span>
|
||||||
<i
|
<i
|
||||||
class="el-icon-arrow-down el-icon-delete data-area-clear"
|
class="el-icon-arrow-down el-icon-delete data-area-clear"
|
||||||
@click="deleteTreeFilter"
|
@click="deleteTreeFilter"
|
||||||
@ -91,7 +91,7 @@
|
|||||||
class="svg-background"
|
class="svg-background"
|
||||||
icon-class="icon-filter_outlined"
|
icon-class="icon-filter_outlined"
|
||||||
/>
|
/>
|
||||||
<span>过滤</span>
|
<span>{{ $t('chart.filter') }}</span>
|
||||||
</div>
|
</div>
|
||||||
</el-row>
|
</el-row>
|
||||||
|
|
||||||
|
|||||||
@ -96,7 +96,7 @@
|
|||||||
<span
|
<span
|
||||||
v-if="!!view.customFilter.logic"
|
v-if="!!view.customFilter.logic"
|
||||||
class="setting"
|
class="setting"
|
||||||
>已设置</span>
|
>{{ $t('chart.is_set') }}</span>
|
||||||
<i
|
<i
|
||||||
class="el-icon-arrow-down el-icon-delete data-area-clear"
|
class="el-icon-arrow-down el-icon-delete data-area-clear"
|
||||||
@click="deleteTreeFilter"
|
@click="deleteTreeFilter"
|
||||||
@ -111,7 +111,7 @@
|
|||||||
class="svg-background"
|
class="svg-background"
|
||||||
icon-class="icon-filter_outlined"
|
icon-class="icon-filter_outlined"
|
||||||
/>
|
/>
|
||||||
<span>过滤</span>
|
<span>{{ $t('chart.filter') }}</span>
|
||||||
</div>
|
</div>
|
||||||
</el-row>
|
</el-row>
|
||||||
|
|
||||||
|
|||||||
@ -116,7 +116,7 @@
|
|||||||
<span
|
<span
|
||||||
v-if="!!view.customFilter.logic"
|
v-if="!!view.customFilter.logic"
|
||||||
class="setting"
|
class="setting"
|
||||||
>已设置</span>
|
>{{ $t('chart.is_set') }}</span>
|
||||||
<i
|
<i
|
||||||
class="el-icon-arrow-down el-icon-delete data-area-clear"
|
class="el-icon-arrow-down el-icon-delete data-area-clear"
|
||||||
@click="deleteTreeFilter"
|
@click="deleteTreeFilter"
|
||||||
@ -131,7 +131,7 @@
|
|||||||
class="svg-background"
|
class="svg-background"
|
||||||
icon-class="icon-filter_outlined"
|
icon-class="icon-filter_outlined"
|
||||||
/>
|
/>
|
||||||
<span>过滤</span>
|
<span>{{ $t('chart.filter') }}</span>
|
||||||
</div>
|
</div>
|
||||||
</el-row>
|
</el-row>
|
||||||
<FilterTree
|
<FilterTree
|
||||||
|
|||||||
@ -119,7 +119,7 @@
|
|||||||
<span
|
<span
|
||||||
v-if="!!view.customFilter.logic"
|
v-if="!!view.customFilter.logic"
|
||||||
class="setting"
|
class="setting"
|
||||||
>已设置</span>
|
>{{ $t('chart.is_set') }}</span>
|
||||||
<i
|
<i
|
||||||
class="el-icon-arrow-down el-icon-delete data-area-clear"
|
class="el-icon-arrow-down el-icon-delete data-area-clear"
|
||||||
@click="deleteTreeFilter"
|
@click="deleteTreeFilter"
|
||||||
@ -134,7 +134,7 @@
|
|||||||
class="svg-background"
|
class="svg-background"
|
||||||
icon-class="icon-filter_outlined"
|
icon-class="icon-filter_outlined"
|
||||||
/>
|
/>
|
||||||
<span>过滤</span>
|
<span>{{ $t('chart.filter') }}</span>
|
||||||
</div>
|
</div>
|
||||||
</el-row>
|
</el-row>
|
||||||
<FilterTree
|
<FilterTree
|
||||||
|
|||||||
@ -117,7 +117,7 @@
|
|||||||
<span
|
<span
|
||||||
v-if="!!view.customFilter.logic"
|
v-if="!!view.customFilter.logic"
|
||||||
class="setting"
|
class="setting"
|
||||||
>已设置</span>
|
>{{ $t('chart.is_set') }}</span>
|
||||||
<i
|
<i
|
||||||
class="el-icon-arrow-down el-icon-delete data-area-clear"
|
class="el-icon-arrow-down el-icon-delete data-area-clear"
|
||||||
@click="deleteTreeFilter"
|
@click="deleteTreeFilter"
|
||||||
@ -132,7 +132,7 @@
|
|||||||
class="svg-background"
|
class="svg-background"
|
||||||
icon-class="icon-filter_outlined"
|
icon-class="icon-filter_outlined"
|
||||||
/>
|
/>
|
||||||
<span>过滤</span>
|
<span>{{ $t('chart.filter') }}</span>
|
||||||
</div>
|
</div>
|
||||||
</el-row>
|
</el-row>
|
||||||
<FilterTree
|
<FilterTree
|
||||||
|
|||||||
@ -117,7 +117,7 @@
|
|||||||
<span
|
<span
|
||||||
v-if="!!view.customFilter.logic"
|
v-if="!!view.customFilter.logic"
|
||||||
class="setting"
|
class="setting"
|
||||||
>已设置</span>
|
>{{ $t('chart.is_set') }}</span>
|
||||||
<i
|
<i
|
||||||
class="el-icon-arrow-down el-icon-delete data-area-clear"
|
class="el-icon-arrow-down el-icon-delete data-area-clear"
|
||||||
@click="deleteTreeFilter"
|
@click="deleteTreeFilter"
|
||||||
@ -132,7 +132,7 @@
|
|||||||
class="svg-background"
|
class="svg-background"
|
||||||
icon-class="icon-filter_outlined"
|
icon-class="icon-filter_outlined"
|
||||||
/>
|
/>
|
||||||
<span>过滤</span>
|
<span>{{ $t('chart.filter') }}</span>
|
||||||
</div>
|
</div>
|
||||||
</el-row>
|
</el-row>
|
||||||
<FilterTree
|
<FilterTree
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user