提交 5af4158d authored 作者: fit2cloud-chenyw's avatar fit2cloud-chenyw

feat:设置条件绑定视图

上级 153ac357
package io.dataease.controller.panel.api; package io.dataease.controller.panel.api;
import io.dataease.base.domain.ChartView;
import io.dataease.controller.sys.base.BaseGridRequest; import io.dataease.controller.sys.base.BaseGridRequest;
import io.dataease.dto.panel.PanelViewDto; import io.dataease.dto.panel.PanelViewDto;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
...@@ -20,6 +22,11 @@ public interface ViewApi { ...@@ -20,6 +22,11 @@ public interface ViewApi {
List<PanelViewDto> tree(BaseGridRequest request); List<PanelViewDto> tree(BaseGridRequest request);
@ApiOperation("根据仪表板Id查询视图")
@PostMapping("/viewsWithIds")
List<ChartView> viewsWithIds(List<String> viewIds);
......
package io.dataease.controller.panel.server; package io.dataease.controller.panel.server;
import io.dataease.base.domain.ChartView;
import io.dataease.commons.utils.AuthUtils; import io.dataease.commons.utils.AuthUtils;
import io.dataease.controller.panel.api.ViewApi; import io.dataease.controller.panel.api.ViewApi;
import io.dataease.controller.sys.base.BaseGridRequest; import io.dataease.controller.sys.base.BaseGridRequest;
import io.dataease.controller.sys.base.ConditionEntity; import io.dataease.controller.sys.base.ConditionEntity;
import io.dataease.dto.panel.PanelViewDto; import io.dataease.dto.panel.PanelViewDto;
import io.dataease.dto.panel.po.PanelViewPo; import io.dataease.dto.panel.po.PanelViewPo;
import io.dataease.service.chart.ChartViewService;
import io.dataease.service.panel.PanelViewService; import io.dataease.service.panel.PanelViewService;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
...@@ -20,6 +23,9 @@ public class ViewServer implements ViewApi { ...@@ -20,6 +23,9 @@ public class ViewServer implements ViewApi {
@Autowired @Autowired
private PanelViewService panelViewService; private PanelViewService panelViewService;
@Autowired
private ChartViewService chartViewService;
/** /**
* 为什么查两次? * 为什么查两次?
* 因为left join 会导致全表扫描 * 因为left join 会导致全表扫描
...@@ -40,4 +46,10 @@ public class ViewServer implements ViewApi { ...@@ -40,4 +46,10 @@ public class ViewServer implements ViewApi {
List<PanelViewDto> panelViewDtos = panelViewService.buildTree(groups, views); List<PanelViewDto> panelViewDtos = panelViewService.buildTree(groups, views);
return panelViewDtos; return panelViewDtos;
} }
@Override
public List<ChartView> viewsWithIds(@RequestBody List<String> viewIds) {
return chartViewService.viewsByIds(viewIds);
}
} }
...@@ -320,4 +320,10 @@ public class ChartViewService { ...@@ -320,4 +320,10 @@ public class ChartViewService {
} }
return map; return map;
} }
public List<ChartView> viewsByIds(List<String> viewIds){
ChartViewExample example = new ChartViewExample();
example.createCriteria().andIdIn(viewIds);
return chartViewMapper.selectByExample(example);
}
} }
...@@ -8,3 +8,12 @@ export function tree(data) { ...@@ -8,3 +8,12 @@ export function tree(data) {
data data
}) })
} }
export function viewsWithIds(data) {
return request({
url: '/api/panelView/viewsWithIds',
method: 'post',
loading: true,
data
})
}
...@@ -314,7 +314,8 @@ export default { ...@@ -314,7 +314,8 @@ export default {
setConditionValue(obj) { setConditionValue(obj) {
const { component, value, operator } = obj const { component, value, operator } = obj
const fieldId = component.options.attrs.fieldId const fieldId = component.options.attrs.fieldId
const condition = new Condition(component.id, fieldId, operator, value, null) const viewIds = component.options.attrs.viewIds
const condition = new Condition(component.id, fieldId, operator, value, viewIds)
this.addCondition(condition) this.addCondition(condition)
}, },
addCondition(condition) { addCondition(condition) {
......
...@@ -31,7 +31,7 @@ export default { ...@@ -31,7 +31,7 @@ export default {
methods: { methods: {
getData(id) { getData(id) {
if (id) { if (id) {
post('/chart/view/getData/' + id, null).then(response => { post('/chart/view/getData/' + id, {}).then(response => {
// 将视图传入echart组件 // 将视图传入echart组件
this.chart = response.data this.chart = response.data
}) })
......
<template> <template>
<el-select v-if="options!== null && options.attrs!==null" v-model="options.value" :style="element.style" :placeholder="options.attrs.placeholder" @change="changeValue"> <el-select v-if="options!== null && options.attrs!==null" v-model="options.value" :multiple="options.attrs.multiple" :style="element.style" :placeholder="options.attrs.placeholder" @change="changeValue">
<el-option <el-option
v-for="item in options.attrs.datas" v-for="item in options.attrs.datas"
:key="item[options.attrs.key]" :key="item[options.attrs.key]"
......
...@@ -110,12 +110,36 @@ ...@@ -110,12 +110,36 @@
v-model="componentInfo.options.attrs.multiple" v-model="componentInfo.options.attrs.multiple"
active-text="多选" active-text="多选"
inactive-text="单选" inactive-text="单选"
@change="multipleChange"
/> />
</div> </div>
</el-col> </el-col>
<el-col :span="16"><div class="filter-options-right"> <el-col :span="16"><div class="filter-options-right">
<el-checkbox v-model="customRange"><span> 自定义控制范围 </span> </el-checkbox> <el-checkbox v-model="customRange"><span> 自定义控制范围 </span> </el-checkbox>
<i :class="{'i-filter-active': customRange, 'i-filter-inactive': !customRange}" class="el-icon-setting i-filter" @click="showFilterRange" />
<el-popover
v-model="popovervisible"
placement="bottom-end"
:disabled="!customRange"
width="200"
>
<div class="view-container-class">
<el-checkbox-group v-model="checkedViews" @change="checkedViewsChange">
<el-checkbox v-for="(item ) in viewInfos" :key="item.id" :label="item.id" border>
<span>
<svg-icon :icon-class="item.type" class="chart-icon" />
<span style="margin-left: 6px">{{ item.name }}</span>
</span>
</el-checkbox>
</el-checkbox-group>
</div>
<!-- <div style="text-align: right; margin: 0">
<el-button size="mini" type="text" @click="popovervisible=false">取消</el-button>
<el-button type="primary" size="mini" @click="popovervisible=false">确定</el-button>
</div> -->
<i slot="reference" :class="{'i-filter-active': customRange, 'i-filter-inactive': !customRange}" class="el-icon-setting i-filter" />
</el-popover>
<!-- <el-checkbox disabled>备选项</el-checkbox> --> <!-- <el-checkbox disabled>备选项</el-checkbox> -->
</div> </div>
...@@ -147,8 +171,10 @@ import DeContainer from '@/components/dataease/DeContainer' ...@@ -147,8 +171,10 @@ import DeContainer from '@/components/dataease/DeContainer'
import DeAsideContainer from '@/components/dataease/DeAsideContainer' import DeAsideContainer from '@/components/dataease/DeAsideContainer'
import draggable from 'vuedraggable' import draggable from 'vuedraggable'
import DragItem from '@/components/DragItem' import DragItem from '@/components/DragItem'
import { mapState } from 'vuex'
// import { ApplicationContext } from '@/utils/ApplicationContext' // import { ApplicationContext } from '@/utils/ApplicationContext'
import { groupTree, loadTable, fieldList, fieldValues } from '@/api/dataset/dataset' import { groupTree, loadTable, fieldList, fieldValues } from '@/api/dataset/dataset'
import { viewsWithIds } from '@/api/panel/view'
export default { export default {
name: 'FilterDialog', name: 'FilterDialog',
components: { components: {
...@@ -169,6 +195,7 @@ export default { ...@@ -169,6 +195,7 @@ export default {
default: null default: null
} }
}, },
data() { data() {
return { return {
activeName: 'dataset', activeName: 'dataset',
...@@ -186,21 +213,35 @@ export default { ...@@ -186,21 +213,35 @@ export default {
selectField: [], selectField: [],
widget: null, widget: null,
fieldValues: [], fieldValues: [],
customRange: false customRange: false,
popovervisible: false,
viewInfos: [],
checkedViews: []
} }
}, },
computed: {
panelInfo() {
return this.$store.state.panel.panelInfo
},
...mapState([
'componentData',
'curComponent',
'isClickComponent',
'canvasStyleData',
'curComponentIndex'
])
},
watch: { watch: {
selectField(values) { selectField(values) {
if (values && values.length > 0) { if (values && values.length > 0) {
const value = values[0] const value = values[0]
const fieldId = value.id const fieldId = value.id
const info = this.componentInfo
this.widget && fieldValues(fieldId).then(res => { this.widget && fieldValues(fieldId).then(res => {
info.options.attrs.datas = this.widget.optionDatas(res.data) this.componentInfo.options.attrs.datas = this.widget.optionDatas(res.data)
info.options.attrs.fieldId = fieldId this.componentInfo.options.attrs.fieldId = fieldId
info.options.attrs.dragItems = values this.componentInfo.options.attrs.dragItems = values
this.$emit('re-fresh-component', info) this.$emit('re-fresh-component', this.componentInfo)
}) })
} }
} }
...@@ -213,9 +254,26 @@ export default { ...@@ -213,9 +254,26 @@ export default {
if (this.componentInfo && this.componentInfo.options.attrs.dragItems) { if (this.componentInfo && this.componentInfo.options.attrs.dragItems) {
this.selectField = this.componentInfo.options.attrs.dragItems this.selectField = this.componentInfo.options.attrs.dragItems
} }
this.loadViews()
}, },
methods: { methods: {
loadViews() {
const viewIds = this.componentData
.filter(item => item.type === 'view' && item.propValue && item.propValue.viewId)
.map(item => item.propValue.viewId)
viewsWithIds(viewIds).then(res => {
const datas = res.data
// for (let index = 0; index < 4; index++) {
// datas = datas.concat(datas)
// }
// datas.forEach(item => item.name += 'aaaaaaaaabbbbb')
this.viewInfos = datas
})
},
handleNodeClick(data) { handleNodeClick(data) {
if (data.type === 'scene') { if (data.type === 'scene') {
this.showSceneTable(data) this.showSceneTable(data)
...@@ -334,11 +392,16 @@ export default { ...@@ -334,11 +392,16 @@ export default {
const index = tag.index const index = tag.index
this.selectField.splice(index, 1) this.selectField.splice(index, 1)
}, },
showFilterRange() {
// 如果不是自定义范围 直接返回 multipleChange(value) {
if (!this.customRange) { // this.componentInfo.options.attrs.multiple = value
return this.componentInfo.options.value = null
} this.$emit('re-fresh-component', this.componentInfo)
},
checkedViewsChange(values) {
this.componentInfo.options.attrs.viewIds = values
this.$emit('re-fresh-component', this.componentInfo)
} }
} }
} }
...@@ -484,4 +547,18 @@ export default { ...@@ -484,4 +547,18 @@ export default {
cursor: pointer!important; cursor: pointer!important;
} }
.view-container-class {
min-height: 150px;
max-height: 200px;
width: 100%;
overflow-y: auto;
overflow-x: hidden;
word-break:break-all;
position: relative;
>>> label {
width: 100%;
}
}
</style> </style>
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论