mirror of
https://github.com/dataease/dataease.git
synced 2025-02-25 03:52:59 +08:00
perf(仪表板): 优化仪表板查询按钮
This commit is contained in:
parent
e10108c8e8
commit
1e32501653
@ -80,7 +80,7 @@ import UserViewDialog from '@/components/canvas/custom-component/UserViewDialog'
|
|||||||
import CanvasOptBar from '@/components/canvas/components/Editor/CanvasOptBar'
|
import CanvasOptBar from '@/components/canvas/components/Editor/CanvasOptBar'
|
||||||
import UserViewMobileDialog from '@/components/canvas/custom-component/UserViewMobileDialog'
|
import UserViewMobileDialog from '@/components/canvas/custom-component/UserViewMobileDialog'
|
||||||
import bus from '@/utils/bus'
|
import bus from '@/utils/bus'
|
||||||
import { buildFilterMap } from '@/utils/conditionUtil'
|
import { buildFilterMap, buildViewKeyMap, formatCondition, valueValid, viewIdMatch } from '@/utils/conditionUtil'
|
||||||
import { hasDataPermission } from '@/utils/permission'
|
import { hasDataPermission } from '@/utils/permission'
|
||||||
const erd = elementResizeDetectorMaker()
|
const erd = elementResizeDetectorMaker()
|
||||||
|
|
||||||
@ -171,7 +171,8 @@ export default {
|
|||||||
showChartTableInfo: {},
|
showChartTableInfo: {},
|
||||||
showChartInfoType: 'details',
|
showChartInfoType: 'details',
|
||||||
// 布局展示 1.pc pc端布局 2.mobile 移动端布局
|
// 布局展示 1.pc pc端布局 2.mobile 移动端布局
|
||||||
terminal: 'pc'
|
terminal: 'pc',
|
||||||
|
buttonFilterMap: null
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
created() {
|
created() {
|
||||||
@ -256,7 +257,7 @@ export default {
|
|||||||
'isClickComponent'
|
'isClickComponent'
|
||||||
]),
|
]),
|
||||||
filterMap() {
|
filterMap() {
|
||||||
const map = buildFilterMap(this.componentData)
|
const map = this.buttonFilterMap || buildFilterMap(this.componentData)
|
||||||
return map
|
return map
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@ -283,14 +284,79 @@ export default {
|
|||||||
if (this.terminal === 'mobile') {
|
if (this.terminal === 'mobile') {
|
||||||
this.initMobileCanvas()
|
this.initMobileCanvas()
|
||||||
}
|
}
|
||||||
|
bus.$on('trigger-search-button', this.triggerSearchButton)
|
||||||
},
|
},
|
||||||
beforeDestroy() {
|
beforeDestroy() {
|
||||||
erd.uninstall(this.$refs.canvasInfoTemp)
|
erd.uninstall(this.$refs.canvasInfoTemp)
|
||||||
erd.uninstall(this.$refs.canvasInfoMain)
|
erd.uninstall(this.$refs.canvasInfoMain)
|
||||||
clearInterval(this.timer)
|
clearInterval(this.timer)
|
||||||
eventBus.$off('openChartDetailsDialog', this.openChartDetailsDialog)
|
eventBus.$off('openChartDetailsDialog', this.openChartDetailsDialog)
|
||||||
|
bus.$on('trigger-search-button', this.triggerSearchButton)
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
|
triggerSearchButton() {
|
||||||
|
this.buttonFilterMap = this.buildButtonFilterMap(this.componentData)
|
||||||
|
},
|
||||||
|
buildButtonFilterMap(panelItems) {
|
||||||
|
const result = {
|
||||||
|
buttonExist: false,
|
||||||
|
relationFilterIds: [],
|
||||||
|
filterMap: {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!panelItems || !panelItems.length) return result
|
||||||
|
let sureButtonItem = null
|
||||||
|
result.buttonExist = panelItems.some(item => {
|
||||||
|
if (item.type === 'custom-button' && item.serviceName === 'buttonSureWidget') {
|
||||||
|
sureButtonItem = item
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
if (!result.buttonExist) return result
|
||||||
|
|
||||||
|
const customRange = sureButtonItem.options.attrs.customRange
|
||||||
|
|
||||||
|
const allFilters = panelItems.filter(item => item.type === 'custom')
|
||||||
|
|
||||||
|
const matchFilters = customRange && allFilters.filter(item => sureButtonItem.options.attrs.filterIds.includes(item.id)) || allFilters
|
||||||
|
|
||||||
|
result.relationFilterIds = matchFilters.map(item => item.id)
|
||||||
|
|
||||||
|
let viewKeyMap = buildViewKeyMap(panelItems)
|
||||||
|
viewKeyMap = this.buildViewKeyFilters(matchFilters, viewKeyMap)
|
||||||
|
result.filterMap = viewKeyMap
|
||||||
|
return result
|
||||||
|
},
|
||||||
|
buildViewKeyFilters(panelItems, result) {
|
||||||
|
const refs = this.$refs
|
||||||
|
panelItems.forEach((element, index) => {
|
||||||
|
if (element.type !== 'custom') {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
let param = null
|
||||||
|
const wrapperChild = refs['wrapperChild'][index]
|
||||||
|
param = wrapperChild.getCondition && wrapperChild.getCondition()
|
||||||
|
const condition = formatCondition(param)
|
||||||
|
const vValid = valueValid(condition)
|
||||||
|
const filterComponentId = condition.componentId
|
||||||
|
Object.keys(result).forEach(viewId => {
|
||||||
|
const vidMatch = viewIdMatch(condition.viewIds, viewId)
|
||||||
|
const viewFilters = result[viewId]
|
||||||
|
let j = viewFilters.length
|
||||||
|
while (j--) {
|
||||||
|
const filter = viewFilters[j]
|
||||||
|
if (filter.componentId === filterComponentId) {
|
||||||
|
viewFilters.splice(j, 1)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
vidMatch && vValid && viewFilters.push(condition)
|
||||||
|
})
|
||||||
|
})
|
||||||
|
return result
|
||||||
|
},
|
||||||
_isMobile() {
|
_isMobile() {
|
||||||
const flag = navigator.userAgent.match(/(phone|pad|pod|iPhone|iPod|ios|iPad|Android|Mobile|BlackBerry|IEMobile|MQQBrowser|JUC|Fennec|wOSBrowser|BrowserNG|WebOS|Symbian|Windows Phone)/i)
|
const flag = navigator.userAgent.match(/(phone|pad|pod|iPhone|iPod|ios|iPad|Android|Mobile|BlackBerry|IEMobile|MQQBrowser|JUC|Fennec|wOSBrowser|BrowserNG|WebOS|Symbian|Windows Phone)/i)
|
||||||
this.terminal = flag ? 'mobile' : 'pc'
|
this.terminal = flag ? 'mobile' : 'pc'
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
<slot name="icon" />
|
<slot name="icon" />
|
||||||
<el-dropdown-menu v-if="curComponent">
|
<el-dropdown-menu v-if="curComponent">
|
||||||
<el-dropdown-item v-if="editFilter.includes(curComponent.type)" icon="el-icon-edit-outline" @click.native="edit">{{ $t('panel.edit') }}</el-dropdown-item>
|
<el-dropdown-item v-if="editFilter.includes(curComponent.type)" icon="el-icon-edit-outline" @click.native="edit">{{ $t('panel.edit') }}</el-dropdown-item>
|
||||||
<el-dropdown-item icon="el-icon-document-copy" @click.native="copy">{{ $t('panel.copy') }}</el-dropdown-item>
|
<el-dropdown-item v-if="curComponent.type != 'custom-button'" icon="el-icon-document-copy" @click.native="copy">{{ $t('panel.copy') }}</el-dropdown-item>
|
||||||
<el-dropdown-item icon="el-icon-delete" @click.native="deleteComponent">{{ $t('panel.delete') }}</el-dropdown-item>
|
<el-dropdown-item icon="el-icon-delete" @click.native="deleteComponent">{{ $t('panel.delete') }}</el-dropdown-item>
|
||||||
<el-dropdown-item v-if="!curComponent.auxiliaryMatrix">
|
<el-dropdown-item v-if="!curComponent.auxiliaryMatrix">
|
||||||
<el-dropdown placement="right-start">
|
<el-dropdown placement="right-start">
|
||||||
@ -73,7 +73,7 @@ export default {
|
|||||||
edit() {
|
edit() {
|
||||||
if (this.curComponent.type === 'custom') {
|
if (this.curComponent.type === 'custom') {
|
||||||
bus.$emit('component-dialog-edit', 'update')
|
bus.$emit('component-dialog-edit', 'update')
|
||||||
}else if (this.curComponent.type === 'custom-button') {
|
} else if (this.curComponent.type === 'custom-button') {
|
||||||
bus.$emit('button-dialog-edit')
|
bus.$emit('button-dialog-edit')
|
||||||
} else if (this.curComponent.type === 'v-text' || this.curComponent.type === 'de-rich-text' || this.curComponent.type === 'rect-shape') {
|
} else if (this.curComponent.type === 'v-text' || this.curComponent.type === 'de-rich-text' || this.curComponent.type === 'rect-shape') {
|
||||||
bus.$emit('component-dialog-style')
|
bus.$emit('component-dialog-style')
|
||||||
|
@ -61,7 +61,7 @@
|
|||||||
@editComponent="editComponent(index,item)"
|
@editComponent="editComponent(index,item)"
|
||||||
>
|
>
|
||||||
<de-out-widget
|
<de-out-widget
|
||||||
v-if="renderOk&&item.type==='custom'"
|
v-if="renderOk && item.type==='custom'"
|
||||||
:id="'component' + item.id"
|
:id="'component' + item.id"
|
||||||
ref="wrapperChild"
|
ref="wrapperChild"
|
||||||
class="component"
|
class="component"
|
||||||
@ -74,7 +74,7 @@
|
|||||||
/>
|
/>
|
||||||
<component
|
<component
|
||||||
:is="item.component"
|
:is="item.component"
|
||||||
v-else-if="renderOk&&item.type==='other'"
|
v-else-if="renderOk && item.type==='other'"
|
||||||
:id="'component' + item.id"
|
:id="'component' + item.id"
|
||||||
ref="wrapperChild"
|
ref="wrapperChild"
|
||||||
class="component"
|
class="component"
|
||||||
@ -207,7 +207,7 @@ import CanvasOptBar from '@/components/canvas/components/Editor/CanvasOptBar'
|
|||||||
import DragShadow from '@/components/DeDrag/shadow'
|
import DragShadow from '@/components/DeDrag/shadow'
|
||||||
import bus from '@/utils/bus'
|
import bus from '@/utils/bus'
|
||||||
import LinkJumpSet from '@/views/panel/LinkJumpSet'
|
import LinkJumpSet from '@/views/panel/LinkJumpSet'
|
||||||
import { buildFilterMap } from '@/utils/conditionUtil'
|
import { buildFilterMap, buildViewKeyMap, formatCondition, valueValid, viewIdMatch } from '@/utils/conditionUtil'
|
||||||
// 挤占式画布
|
// 挤占式画布
|
||||||
import _ from 'lodash'
|
import _ from 'lodash'
|
||||||
import $ from 'jquery'
|
import $ from 'jquery'
|
||||||
@ -929,7 +929,8 @@ export default {
|
|||||||
yourList: [],
|
yourList: [],
|
||||||
linkJumpSetVisible: false,
|
linkJumpSetVisible: false,
|
||||||
linkJumpSetViewId: null,
|
linkJumpSetViewId: null,
|
||||||
editShow: false
|
editShow: false,
|
||||||
|
buttonFilterMap: null
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
@ -1004,7 +1005,7 @@ export default {
|
|||||||
'batchOptStatus'
|
'batchOptStatus'
|
||||||
]),
|
]),
|
||||||
filterMap() {
|
filterMap() {
|
||||||
return buildFilterMap(this.componentData)
|
return this.buttonFilterMap || buildFilterMap(this.componentData)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
watch: {
|
watch: {
|
||||||
@ -1055,6 +1056,7 @@ export default {
|
|||||||
eventBus.$on('startMoveIn', this.startMoveIn)
|
eventBus.$on('startMoveIn', this.startMoveIn)
|
||||||
eventBus.$on('openChartDetailsDialog', this.openChartDetailsDialog)
|
eventBus.$on('openChartDetailsDialog', this.openChartDetailsDialog)
|
||||||
bus.$on('onRemoveLastItem', this.removeLastItem)
|
bus.$on('onRemoveLastItem', this.removeLastItem)
|
||||||
|
bus.$on('trigger-search-button', this.triggerSearchButton)
|
||||||
|
|
||||||
// 矩阵定位调试模式
|
// 矩阵定位调试模式
|
||||||
if (this.psDebug) {
|
if (this.psDebug) {
|
||||||
@ -1068,10 +1070,74 @@ export default {
|
|||||||
eventBus.$off('startMoveIn', this.startMoveIn)
|
eventBus.$off('startMoveIn', this.startMoveIn)
|
||||||
eventBus.$off('openChartDetailsDialog', this.openChartDetailsDialog)
|
eventBus.$off('openChartDetailsDialog', this.openChartDetailsDialog)
|
||||||
bus.$off('onRemoveLastItem', this.removeLastItem)
|
bus.$off('onRemoveLastItem', this.removeLastItem)
|
||||||
|
bus.$off('trigger-search-button', this.triggerSearchButton)
|
||||||
},
|
},
|
||||||
created() {
|
created() {
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
|
triggerSearchButton() {
|
||||||
|
this.buttonFilterMap = this.buildButtonFilterMap(this.componentData)
|
||||||
|
},
|
||||||
|
buildButtonFilterMap(panelItems) {
|
||||||
|
const result = {
|
||||||
|
buttonExist: false,
|
||||||
|
relationFilterIds: [],
|
||||||
|
filterMap: {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!panelItems || !panelItems.length) return result
|
||||||
|
let sureButtonItem = null
|
||||||
|
result.buttonExist = panelItems.some(item => {
|
||||||
|
if (item.type === 'custom-button' && item.serviceName === 'buttonSureWidget') {
|
||||||
|
sureButtonItem = item
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
if (!result.buttonExist) return result
|
||||||
|
|
||||||
|
const customRange = sureButtonItem.options.attrs.customRange
|
||||||
|
|
||||||
|
const allFilters = panelItems.filter(item => item.type === 'custom')
|
||||||
|
|
||||||
|
const matchFilters = customRange && allFilters.filter(item => sureButtonItem.options.attrs.filterIds.includes(item.id)) || allFilters
|
||||||
|
|
||||||
|
result.relationFilterIds = matchFilters.map(item => item.id)
|
||||||
|
|
||||||
|
let viewKeyMap = buildViewKeyMap(panelItems)
|
||||||
|
viewKeyMap = this.buildViewKeyFilters(matchFilters, viewKeyMap)
|
||||||
|
result.filterMap = viewKeyMap
|
||||||
|
return result
|
||||||
|
},
|
||||||
|
buildViewKeyFilters(panelItems, result) {
|
||||||
|
const refs = this.$refs
|
||||||
|
panelItems.forEach((element, index) => {
|
||||||
|
if (element.type !== 'custom') {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
let param = null
|
||||||
|
const wrapperChild = refs['wrapperChild'][index]
|
||||||
|
param = wrapperChild.getCondition && wrapperChild.getCondition()
|
||||||
|
const condition = formatCondition(param)
|
||||||
|
const vValid = valueValid(condition)
|
||||||
|
const filterComponentId = condition.componentId
|
||||||
|
Object.keys(result).forEach(viewId => {
|
||||||
|
const vidMatch = viewIdMatch(condition.viewIds, viewId)
|
||||||
|
const viewFilters = result[viewId]
|
||||||
|
let j = viewFilters.length
|
||||||
|
while (j--) {
|
||||||
|
const filter = viewFilters[j]
|
||||||
|
if (filter.componentId === filterComponentId) {
|
||||||
|
viewFilters.splice(j, 1)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
vidMatch && vValid && viewFilters.push(condition)
|
||||||
|
})
|
||||||
|
})
|
||||||
|
return result
|
||||||
|
},
|
||||||
pluginEditHandler({ e, id }) {
|
pluginEditHandler({ e, id }) {
|
||||||
let index = -1
|
let index = -1
|
||||||
for (let i = 0; i < this.componentData.length; i++) {
|
for (let i = 0; i < this.componentData.length; i++) {
|
||||||
|
@ -27,7 +27,7 @@
|
|||||||
:is="element.component"
|
:is="element.component"
|
||||||
v-if="element.type==='custom'"
|
v-if="element.type==='custom'"
|
||||||
:id="'component' + element.id"
|
:id="'component' + element.id"
|
||||||
ref="deOutWidget"
|
ref="filter-ref"
|
||||||
class="component-custom"
|
class="component-custom"
|
||||||
:out-style="element.style"
|
:out-style="element.style"
|
||||||
:element="element"
|
:element="element"
|
||||||
@ -152,6 +152,12 @@ export default {
|
|||||||
alignItems: 'center'
|
alignItems: 'center'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
getCondition() {
|
||||||
|
if (this.$refs && this.$refs['filter-ref'] && this.$refs['filter-ref'].getCondition) {
|
||||||
|
return this.$refs['filter-ref'].getCondition()
|
||||||
|
}
|
||||||
|
return null
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -6,12 +6,14 @@
|
|||||||
:round="options.attrs.round"
|
:round="options.attrs.round"
|
||||||
:plain="options.attrs.plain"
|
:plain="options.attrs.plain"
|
||||||
:size="size"
|
:size="size"
|
||||||
|
@click="triggerSearch"
|
||||||
>
|
>
|
||||||
{{ options.value }}
|
{{ options.value }}
|
||||||
</el-button>
|
</el-button>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
|
import bus from '@/utils/bus'
|
||||||
export default {
|
export default {
|
||||||
|
|
||||||
props: {
|
props: {
|
||||||
@ -34,6 +36,11 @@ export default {
|
|||||||
},
|
},
|
||||||
created() {
|
created() {
|
||||||
this.options = this.element.options
|
this.options = this.element.options
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
triggerSearch() {
|
||||||
|
bus.$emit('trigger-search-button')
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
@ -170,13 +170,17 @@ export default {
|
|||||||
search() {
|
search() {
|
||||||
this.setCondition()
|
this.setCondition()
|
||||||
},
|
},
|
||||||
setCondition() {
|
getCondition() {
|
||||||
const param = {
|
const param = {
|
||||||
component: this.element,
|
component: this.element,
|
||||||
value: this.formatFilterValue(),
|
value: this.formatFilterValue(),
|
||||||
operator: this.operator
|
operator: this.operator
|
||||||
}
|
}
|
||||||
param.value = this.formatValues(param.value)
|
param.value = this.formatValues(param.value)
|
||||||
|
return param
|
||||||
|
},
|
||||||
|
setCondition() {
|
||||||
|
const param = this.getCondition()
|
||||||
this.inDraw && this.$store.commit('addViewFilter', param)
|
this.inDraw && this.$store.commit('addViewFilter', param)
|
||||||
},
|
},
|
||||||
dateChange(value) {
|
dateChange(value) {
|
||||||
|
@ -91,12 +91,16 @@ export default {
|
|||||||
}
|
}
|
||||||
this.setCondition()
|
this.setCondition()
|
||||||
},
|
},
|
||||||
setCondition() {
|
getCondition() {
|
||||||
const param = {
|
const param = {
|
||||||
component: this.element,
|
component: this.element,
|
||||||
value: !this.value ? [] : Array.isArray(this.value) ? this.value : [this.value],
|
value: !this.value ? [] : Array.isArray(this.value) ? this.value : [this.value],
|
||||||
operator: this.operator
|
operator: this.operator
|
||||||
}
|
}
|
||||||
|
return param
|
||||||
|
},
|
||||||
|
setCondition() {
|
||||||
|
const param = this.getCondition()
|
||||||
this.inDraw && this.$store.commit('addViewFilter', param)
|
this.inDraw && this.$store.commit('addViewFilter', param)
|
||||||
},
|
},
|
||||||
setEdit() {
|
setEdit() {
|
||||||
|
@ -194,13 +194,33 @@ export default {
|
|||||||
})
|
})
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
setCondition() {
|
getCondition() {
|
||||||
const param = {
|
const param = {
|
||||||
component: this.element,
|
component: this.element,
|
||||||
// value: !this.values ? [] : Array.isArray(this.values) ? this.values : [this.values],
|
|
||||||
value: [this.form.min, this.form.max],
|
value: [this.form.min, this.form.max],
|
||||||
operator: this.operator
|
operator: this.operator
|
||||||
}
|
}
|
||||||
|
if (this.form.min && this.form.max) {
|
||||||
|
return param
|
||||||
|
}
|
||||||
|
if (!this.form.min && !this.form.max) {
|
||||||
|
param.value = []
|
||||||
|
return param
|
||||||
|
}
|
||||||
|
if (this.form.min) {
|
||||||
|
param.value = [this.form.min]
|
||||||
|
param.operator = 'ge'
|
||||||
|
return param
|
||||||
|
}
|
||||||
|
if (this.form.max) {
|
||||||
|
param.value = [this.form.max]
|
||||||
|
param.operator = 'le'
|
||||||
|
return param
|
||||||
|
}
|
||||||
|
return param
|
||||||
|
},
|
||||||
|
setCondition() {
|
||||||
|
const param = this.getCondition()
|
||||||
|
|
||||||
if (this.form.min && this.form.max) {
|
if (this.form.min && this.form.max) {
|
||||||
this.inDraw && this.$store.commit('addViewFilter', param)
|
this.inDraw && this.$store.commit('addViewFilter', param)
|
||||||
|
@ -276,13 +276,16 @@ export default {
|
|||||||
this.handleElTagStyle()
|
this.handleElTagStyle()
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
getCondition() {
|
||||||
setCondition() {
|
|
||||||
const param = {
|
const param = {
|
||||||
component: this.element,
|
component: this.element,
|
||||||
value: this.formatFilterValue(),
|
value: this.formatFilterValue(),
|
||||||
operator: this.operator
|
operator: this.operator
|
||||||
}
|
}
|
||||||
|
return param
|
||||||
|
},
|
||||||
|
setCondition() {
|
||||||
|
const param = this.getCondition()
|
||||||
this.inDraw && this.$store.commit('addViewFilter', param)
|
this.inDraw && this.$store.commit('addViewFilter', param)
|
||||||
},
|
},
|
||||||
formatFilterValue() {
|
formatFilterValue() {
|
||||||
|
@ -273,13 +273,16 @@ export default {
|
|||||||
}
|
}
|
||||||
this.setCondition()
|
this.setCondition()
|
||||||
},
|
},
|
||||||
|
getCondition() {
|
||||||
setCondition() {
|
|
||||||
const param = {
|
const param = {
|
||||||
component: this.element,
|
component: this.element,
|
||||||
value: this.formatFilterValue(),
|
value: this.formatFilterValue(),
|
||||||
operator: this.operator
|
operator: this.operator
|
||||||
}
|
}
|
||||||
|
return param
|
||||||
|
},
|
||||||
|
setCondition() {
|
||||||
|
const param = this.getCondition()
|
||||||
this.inDraw && this.$store.commit('addViewFilter', param)
|
this.inDraw && this.$store.commit('addViewFilter', param)
|
||||||
},
|
},
|
||||||
formatFilterValue() {
|
formatFilterValue() {
|
||||||
|
@ -279,7 +279,7 @@ export default {
|
|||||||
this.setCondition()
|
this.setCondition()
|
||||||
},
|
},
|
||||||
|
|
||||||
setCondition() {
|
getCondition() {
|
||||||
const val = this.formatFilterValue()
|
const val = this.formatFilterValue()
|
||||||
|
|
||||||
const param = {
|
const param = {
|
||||||
@ -288,6 +288,11 @@ export default {
|
|||||||
operator: this.operator,
|
operator: this.operator,
|
||||||
isTree: true
|
isTree: true
|
||||||
}
|
}
|
||||||
|
return param
|
||||||
|
},
|
||||||
|
|
||||||
|
setCondition() {
|
||||||
|
const param = this.getCondition()
|
||||||
this.inDraw && this.$store.commit('addViewFilter', param)
|
this.inDraw && this.$store.commit('addViewFilter', param)
|
||||||
},
|
},
|
||||||
formatFilterValue() {
|
formatFilterValue() {
|
||||||
|
@ -24,7 +24,8 @@ const drawPanel = {
|
|||||||
round: false,
|
round: false,
|
||||||
plain: true,
|
plain: true,
|
||||||
customRange: false,
|
customRange: false,
|
||||||
filterIds: []
|
filterIds: [],
|
||||||
|
autoTrigger: true
|
||||||
},
|
},
|
||||||
value: '查询'
|
value: '查询'
|
||||||
},
|
},
|
||||||
|
@ -51,8 +51,8 @@ export const formatLinkageCondition = obj => {
|
|||||||
return condition
|
return condition
|
||||||
}
|
}
|
||||||
|
|
||||||
export const buildFilterMap = panelItems => {
|
export const viewIdMatch = (viewIds, viewId) => !viewIds || viewIds.length === 0 || viewIds.includes(viewId)
|
||||||
const viewIdMatch = (viewIds, viewId) => !viewIds || viewIds.length === 0 || viewIds.includes(viewId)
|
export const buildViewKeyMap = panelItems => {
|
||||||
const result = {}
|
const result = {}
|
||||||
panelItems.forEach(element => {
|
panelItems.forEach(element => {
|
||||||
if (element.type === 'view') {
|
if (element.type === 'view') {
|
||||||
@ -66,12 +66,18 @@ export const buildFilterMap = panelItems => {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
panelItems.forEach(element => {
|
return result
|
||||||
|
}
|
||||||
|
|
||||||
|
export const buildViewKeyFilters = (panelItems, result) => {
|
||||||
|
panelItems.forEach((element, index) => {
|
||||||
if (element.type !== 'custom') {
|
if (element.type !== 'custom') {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let param = null
|
||||||
const widget = ApplicationContext.getService(element.serviceName)
|
const widget = ApplicationContext.getService(element.serviceName)
|
||||||
const param = widget.getParam(element)
|
param = widget.getParam(element)
|
||||||
const condition = formatCondition(param)
|
const condition = formatCondition(param)
|
||||||
const vValid = valueValid(condition)
|
const vValid = valueValid(condition)
|
||||||
const filterComponentId = condition.componentId
|
const filterComponentId = condition.componentId
|
||||||
@ -90,3 +96,9 @@ export const buildFilterMap = panelItems => {
|
|||||||
})
|
})
|
||||||
return result
|
return result
|
||||||
}
|
}
|
||||||
|
export const buildFilterMap = panelItems => {
|
||||||
|
let result = buildViewKeyMap(panelItems)
|
||||||
|
|
||||||
|
result = buildViewKeyFilters(panelItems, result)
|
||||||
|
return result
|
||||||
|
}
|
||||||
|
@ -1,23 +1,25 @@
|
|||||||
<template>
|
<template>
|
||||||
<div>
|
<div>
|
||||||
<el-form size="mini" ref="form" :model="form" label-width="100px">
|
<el-form ref="form" size="mini" :model="form" label-width="90px">
|
||||||
<el-form-item label="名称">
|
<el-form-item label="名称">
|
||||||
<el-input v-model="currentElement.options.value"></el-input>
|
<el-input v-model="currentElement.options.value" />
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
|
|
||||||
|
<el-form-item label="自动触发">
|
||||||
<el-form-item label="自定义范围">
|
<el-switch v-model="myAttrs.autoTrigger" @change="autoTriggerChange" />
|
||||||
<el-switch v-model="myAttrs.customRange" @change="customRangeChange"></el-switch>
|
</el-form-item>
|
||||||
|
|
||||||
|
<el-form-item label="控制范围">
|
||||||
|
<el-switch v-model="myAttrs.customRange" @change="customRangeChange" />
|
||||||
<el-link style="margin-left: 10px;" type="warning" disabled>默认关联全部过滤组件</el-link>
|
<el-link style="margin-left: 10px;" type="warning" disabled>默认关联全部过滤组件</el-link>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
|
|
||||||
<el-form-item label="关联组件" v-if="myAttrs.customRange">
|
<el-form-item v-if="myAttrs.customRange" label="关联组件">
|
||||||
<el-select style="width: 300px;" multiple clearable v-model="myAttrs.filterIds" placeholder="请选择活动区域">
|
<el-select v-model="myAttrs.filterIds" style="width: 300px;" multiple clearable placeholder="请选择活动区域">
|
||||||
<el-option v-for="(filter, index) in filters" :key="filter.id" :label="filter.showName" :value="filter.id" />
|
<el-option v-for="(filter, index) in filters" :key="filter.id + index" :label="filter.showName" :value="filter.id" />
|
||||||
</el-select>
|
</el-select>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
|
|
||||||
|
|
||||||
<el-form-item>
|
<el-form-item>
|
||||||
<el-button type="primary" @click="sure">确定</el-button>
|
<el-button type="primary" @click="sure">确定</el-button>
|
||||||
<el-button @click="cancel">取消</el-button>
|
<el-button @click="cancel">取消</el-button>
|
||||||
@ -35,7 +37,7 @@ export default {
|
|||||||
props: {
|
props: {
|
||||||
widgetInfo: {
|
widgetInfo: {
|
||||||
type: Object,
|
type: Object,
|
||||||
default: null,
|
default: null
|
||||||
},
|
},
|
||||||
element: {
|
element: {
|
||||||
type: Object,
|
type: Object,
|
||||||
@ -45,35 +47,30 @@ export default {
|
|||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
form: {
|
form: {
|
||||||
|
|
||||||
},
|
},
|
||||||
currentElement: null,
|
currentElement: null,
|
||||||
widget: null,
|
widget: null,
|
||||||
myAttrs: null
|
myAttrs: null
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
created() {
|
|
||||||
this.widget = this.widgetInfo
|
|
||||||
this.currentElement = JSON.parse(JSON.stringify(this.element))
|
|
||||||
this.myAttrs = this.currentElement.options.attrs
|
|
||||||
},
|
|
||||||
computed: {
|
computed: {
|
||||||
|
|
||||||
...mapState([
|
...mapState([
|
||||||
'componentData'
|
'componentData'
|
||||||
]),
|
]),
|
||||||
filters() {
|
filters() {
|
||||||
const datas = this.componentData.filter(item => item.type === 'custom')
|
const datas = this.componentData.filter(item => item.type === 'custom')
|
||||||
datas.forEach(item => {
|
datas.forEach(item => {
|
||||||
|
|
||||||
const serviceName = item.serviceName
|
const serviceName = item.serviceName
|
||||||
const widget = ApplicationContext.getService(serviceName)
|
const widget = ApplicationContext.getService(serviceName)
|
||||||
const showName = widget.initLeftPanel().label
|
const showName = widget.initLeftPanel().label
|
||||||
let result = ''
|
let result = ''
|
||||||
if(showName) {
|
if (showName) {
|
||||||
result = this.$t(showName)
|
result = this.$t(showName)
|
||||||
}
|
}
|
||||||
if(item.options.attrs.title) {
|
if (item.options.attrs.title) {
|
||||||
result += '【' + item.options.attrs.title + '】'
|
result += '【' + item.options.attrs.title + '】'
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -82,6 +79,11 @@ export default {
|
|||||||
return datas
|
return datas
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
created() {
|
||||||
|
this.widget = this.widgetInfo
|
||||||
|
this.currentElement = JSON.parse(JSON.stringify(this.element))
|
||||||
|
this.myAttrs = this.currentElement.options.attrs
|
||||||
|
},
|
||||||
methods: {
|
methods: {
|
||||||
sure() {
|
sure() {
|
||||||
this.$emit('sure-handler')
|
this.$emit('sure-handler')
|
||||||
@ -94,7 +96,10 @@ export default {
|
|||||||
},
|
},
|
||||||
customRangeChange(val) {
|
customRangeChange(val) {
|
||||||
this.myAttrs.filterIds = []
|
this.myAttrs.filterIds = []
|
||||||
|
},
|
||||||
|
autoTriggerChange(val) {
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
@ -9,7 +9,7 @@
|
|||||||
v-for="(widget, index) in item"
|
v-for="(widget, index) in item"
|
||||||
:key="widget.widgetName+index"
|
:key="widget.widgetName+index"
|
||||||
:data-id="widget.widgetName"
|
:data-id="widget.widgetName"
|
||||||
draggable
|
:draggable="widget.widgetName !== 'buttonSureWidget' || !searchButtonExist"
|
||||||
:data-index="index"
|
:data-index="index"
|
||||||
:class="'filter-widget '+ (widget.defaultClass || '')"
|
:class="'filter-widget '+ (widget.defaultClass || '')"
|
||||||
>
|
>
|
||||||
@ -27,7 +27,7 @@
|
|||||||
|
|
||||||
<script>
|
<script>
|
||||||
import { ApplicationContext } from '@/utils/ApplicationContext'
|
import { ApplicationContext } from '@/utils/ApplicationContext'
|
||||||
import { deepCopy, matrixBaseChange } from '@/components/canvas/utils/utils'
|
import { deepCopy } from '@/components/canvas/utils/utils'
|
||||||
import eventBus from '@/components/canvas/utils/eventBus'
|
import eventBus from '@/components/canvas/utils/eventBus'
|
||||||
import { mapState } from 'vuex'
|
import { mapState } from 'vuex'
|
||||||
export default {
|
export default {
|
||||||
@ -35,16 +35,11 @@ export default {
|
|||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
panelInfo: this.$store.state.panel.panelInfo,
|
panelInfo: this.$store.state.panel.panelInfo,
|
||||||
// widgetSubjects: {
|
|
||||||
// '文本过滤组件': [
|
|
||||||
// 'mySelectWidget'
|
|
||||||
// ]
|
|
||||||
// }
|
|
||||||
widgetSubjects: {
|
widgetSubjects: {
|
||||||
'时间过滤组件': [
|
'时间过滤组件': [
|
||||||
'timeYearWidget',
|
'timeYearWidget',
|
||||||
'timeMonthWidget',
|
'timeMonthWidget',
|
||||||
// 'timeQuarterWidget',
|
|
||||||
'timeDateWidget',
|
'timeDateWidget',
|
||||||
'timeDateRangeWidget'
|
'timeDateRangeWidget'
|
||||||
|
|
||||||
@ -69,22 +64,44 @@ export default {
|
|||||||
computed: {
|
computed: {
|
||||||
...mapState([
|
...mapState([
|
||||||
'canvasStyleData',
|
'canvasStyleData',
|
||||||
'curCanvasScale'
|
'curCanvasScale',
|
||||||
])
|
'componentData'
|
||||||
|
]),
|
||||||
|
searchButtonExist() {
|
||||||
|
return this.componentData && this.componentData.some(component => component.type === 'custom-button' && component.serviceName === 'buttonSureWidget')
|
||||||
|
}
|
||||||
|
},
|
||||||
|
watch: {
|
||||||
|
searchButtonExist(val, old) {
|
||||||
|
if (val === old) return
|
||||||
|
if (val) {
|
||||||
|
this.widgetSubjects['按钮'][0].widgetName = 'buttonSureWidget'
|
||||||
|
this.widgetSubjects['按钮'][0].defaultClass = 'button-disable-filter'
|
||||||
|
} else {
|
||||||
|
this.widgetSubjects['按钮'][0].widgetName = 'buttonSureWidget'
|
||||||
|
this.widgetSubjects['按钮'][0].defaultClass = 'time-filter'
|
||||||
|
}
|
||||||
|
}
|
||||||
},
|
},
|
||||||
created() {
|
created() {
|
||||||
for (const key in this.widgetSubjects) {
|
this.init()
|
||||||
const widgetNames = this.widgetSubjects[key]
|
|
||||||
this.widgetSubjects[key] = widgetNames.map(widgetName => {
|
|
||||||
const widget = ApplicationContext.getService(widgetName)
|
|
||||||
const result = { widgetName: widgetName }
|
|
||||||
Object.assign(result, widget.getLeftPanel())
|
|
||||||
return result
|
|
||||||
})
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
|
|
||||||
methods: {
|
methods: {
|
||||||
|
init() {
|
||||||
|
for (const key in this.widgetSubjects) {
|
||||||
|
const widgetNames = this.widgetSubjects[key]
|
||||||
|
this.widgetSubjects[key] = widgetNames.map(widgetName => {
|
||||||
|
const widget = ApplicationContext.getService(widgetName)
|
||||||
|
const result = { widgetName: widgetName }
|
||||||
|
Object.assign(result, widget.getLeftPanel())
|
||||||
|
if (this.searchButtonExist && widgetName === 'buttonSureWidget') {
|
||||||
|
result.defaultClass = 'button-disable-filter'
|
||||||
|
}
|
||||||
|
return result
|
||||||
|
})
|
||||||
|
}
|
||||||
|
},
|
||||||
handleDragStart(ev) {
|
handleDragStart(ev) {
|
||||||
// 记录拖拽信息
|
// 记录拖拽信息
|
||||||
const dragComponentInfo = deepCopy(ApplicationContext.getService(ev.target.dataset.id).getDrawPanel())
|
const dragComponentInfo = deepCopy(ApplicationContext.getService(ev.target.dataset.id).getDrawPanel())
|
||||||
@ -171,6 +188,16 @@ export default {
|
|||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.button-disable-filter {
|
||||||
|
background-color: #ecf5ff;
|
||||||
|
.filter-widget-icon {
|
||||||
|
color: #8cc5ff;
|
||||||
|
}
|
||||||
|
.filter-widget-text {
|
||||||
|
color: var(--TextActive, #8cc5ff);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
.time-filter {
|
.time-filter {
|
||||||
background-color: rgba(54,133,242,.1);
|
background-color: rgba(54,133,242,.1);
|
||||||
.filter-widget-icon {
|
.filter-widget-icon {
|
||||||
|
Loading…
Reference in New Issue
Block a user