Merge remote-tracking branch 'origin/main' into main

This commit is contained in:
wangjiahao
2021-04-09 13:53:21 +08:00
17 changed files with 217 additions and 50 deletions

View File

@@ -111,4 +111,12 @@ export function post(url, data) {
})
}
export function fieldValues(fieldId) {
return request({
url: '/dataset/field/fieldValues/' + fieldId,
method: 'post',
loading: true
})
}
export default { loadTable, getScene, addGroup, delGroup, addTable, delTable, groupTree }

View File

@@ -32,6 +32,7 @@
:style="getComponentStyle(item.style)"
:element="item"
:item="item"
@filter-value-change="filterValueChange"
/>
<component
@@ -290,6 +291,10 @@ export default {
const newHeight = (text.split('<br>').length - 1) * lineHeight * fontSize
return height > newHeight ? height : newHeight
},
filterValueChange(value) {
console.log('emit:' + value)
}
}
}

View File

@@ -1,5 +1,6 @@
<script>
export default {
name: 'DeDrawingWidget',
functional: true,
props: {
item: {
@@ -7,14 +8,22 @@ export default {
default: null
}
},
render(createElement, context) {
const item = context.props.item
return createElement(item.component, {
props: {
options: item.options,
element: item
},
on: {
'value-change': value => {
context.listeners['filter-value-change'] && context.listeners['filter-value-change'](value)
}
}
})
},
context.data,
context.children
)
}
}
</script>

View File

@@ -1,6 +1,6 @@
<template>
<el-select v-if="options!== null && options.attrs!==null" v-model="options.value" :placeholder="options.attrs.placeholder">
<el-select v-if="options!== null && options.attrs!==null" v-model="options.value" :placeholder="options.attrs.placeholder" @change="changeValue">
<el-option
v-for="item in options.attrs.datas"
:key="item[options.attrs.key]"
@@ -15,20 +15,28 @@
export default {
props: {
options: {
element: {
type: Object,
default: null
}
},
data() {
return {
options: null
}
},
created() {
this.options = this.element.options
},
mounted() {
this.$nextTick(() => {
})
},
methods: {
changeValue(value) {
this.$emit('value-change', value)
}
}
}
</script>

View File

@@ -25,7 +25,8 @@ const defaultOptions = {
placeholder: '请输入关键字'
},
value: ''
}
},
filterDialog: true
}
class TextInputServiceImpl extends WidgetService {
@@ -49,6 +50,11 @@ class TextInputServiceImpl extends WidgetService {
'background-color': 'rgba(35,190,239,.1)'
}
}
filterFieldMethod(fields) {
return fields.filter(field => {
return field['deType'] === 0
})
}
// dynamicIconStype() {
// return {
// color: '#23beef'

View File

@@ -18,25 +18,7 @@ const defaultOptions = {
attrs: {
multiple: false,
placeholder: '请选择',
datas: [
{
id: '0',
text: '北京'
},
{
id: '1',
text: '上海'
},
{
id: '2',
text: '广东'
},
{
id: '3',
text: '深圳'
}
],
datas: [],
key: 'id',
label: 'text',
value: 'id'
@@ -44,7 +26,8 @@ const defaultOptions = {
value: ''
},
defaultClass: 'text-filter',
component: 'de-select'
component: 'de-select',
filterDialog: true
}
class TextSelectServiceImpl extends WidgetService {
@@ -63,6 +46,16 @@ class TextSelectServiceImpl extends WidgetService {
beforeToDraw() {
}
setOptionDatas(data) {
this.options.attrs.datas = data
}
filterFieldMethod(fields) {
return fields.filter(field => {
return field['deType'] === 0
})
}
}
const textSelectServiceImpl = new TextSelectServiceImpl({ name: 'textSelectWidget' })
export default textSelectServiceImpl

View File

@@ -24,7 +24,8 @@ const defaultOptions = {
value: ''
},
defaultClass: 'time-filter',
component: 'de-date'
component: 'de-date',
filterDialog: true
}
class TimeDateRangeServiceImpl extends WidgetService {
@@ -43,6 +44,11 @@ class TimeDateRangeServiceImpl extends WidgetService {
beforeToDraw() {
}
filterFieldMethod(fields) {
return fields.filter(field => {
return field['deType'] === 1
})
}
}
const timeDateRangeServiceImpl = new TimeDateRangeServiceImpl({ name: 'timeDateRangeWidget' })
export default timeDateRangeServiceImpl

View File

@@ -23,7 +23,8 @@ const defaultOptions = {
},
defaultClass: 'time-filter',
component: 'de-date'
component: 'de-date',
filterDialog: true
}
class TimeDateServiceImpl extends WidgetService {
@@ -42,6 +43,11 @@ class TimeDateServiceImpl extends WidgetService {
beforeToDraw() {
}
filterFieldMethod(fields) {
return fields.filter(field => {
return field['deType'] === 1
})
}
}
const timeDateServiceImpl = new TimeDateServiceImpl({ name: 'timeDateWidget' })
export default timeDateServiceImpl

View File

@@ -22,7 +22,8 @@ const defaultOptions = {
value: ''
},
defaultClass: 'time-filter',
component: 'de-date'
component: 'de-date',
filterDialog: true
}
class TimeMonthServiceImpl extends WidgetService {
@@ -41,6 +42,11 @@ class TimeMonthServiceImpl extends WidgetService {
beforeToDraw() {
}
filterFieldMethod(fields) {
return fields.filter(field => {
return field['deType'] === 1
})
}
}
const timeMonthServiceImpl = new TimeMonthServiceImpl({ name: 'timeMonthWidget' })
export default timeMonthServiceImpl

View File

@@ -22,7 +22,8 @@ const defaultOptions = {
value: ''
},
defaultClass: 'time-filter',
component: 'de-quarter'
component: 'de-quarter',
filterDialog: true
}
class TimeQuarterServiceImpl extends WidgetService {
@@ -41,6 +42,11 @@ class TimeQuarterServiceImpl extends WidgetService {
beforeToDraw() {
}
filterFieldMethod(fields) {
return fields.filter(field => {
return field['deType'] === 1
})
}
}
const timeQuarterServiceImpl = new TimeQuarterServiceImpl({ name: 'timeQuarterWidget' })
export default timeQuarterServiceImpl

View File

@@ -74,7 +74,7 @@
:visible.sync="filterVisible"
custom-class="de-filter-dialog"
>
<filter-dialog v-if="filterVisible" :widget-id="currentWidgetId">
<filter-dialog v-if="filterVisible" :component-info="currentComponent" :widget-id="currentWidgetId" @re-fresh-component="reFreshComponent">
<de-drawing-widget
v-if="filterVisible && currentComponent"
:id="'component' + currentComponent.id"
@@ -272,7 +272,7 @@ export default {
this.currentComponent.style.top = e.offsetY
this.currentComponent.style.left = e.offsetX
this.currentComponent.id = newComponentId
this.openFilterDiolog(componentInfo.id)
this.openFilterDiolog()
return
}
component = deepCopy(this.currentWidget)
@@ -308,8 +308,8 @@ export default {
this.$store.commit('hideContextMenu')
}
},
openFilterDiolog(widgetId) {
this.currentWidgetId = widgetId
openFilterDiolog() {
this.currentWidgetId = this.currentComponent.name
this.filterVisible = true
},
cancelFilter() {
@@ -323,6 +323,9 @@ export default {
this.$store.commit('addComponent', { component })
this.$store.commit('recordSnapshot')
this.cancelFilter()
},
reFreshComponent(component) {
this.currentComponent = component
}
}
}

View File

@@ -145,7 +145,7 @@ import DeAsideContainer from '@/components/dataease/DeAsideContainer'
import draggable from 'vuedraggable'
import DragItem from '@/components/DragItem'
import { ApplicationContext } from '@/utils/ApplicationContext'
import { groupTree, loadTable, fieldList } from '@/api/dataset/dataset'
import { groupTree, loadTable, fieldList, fieldValues } from '@/api/dataset/dataset'
export default {
name: 'FilterDialog',
components: {
@@ -159,6 +159,10 @@ export default {
widgetId: {
type: String,
default: null
},
componentInfo: {
type: Object,
default: null
}
},
data() {
@@ -176,7 +180,23 @@ export default {
label: 'label'
},
selectField: [],
widget: null
widget: null,
fieldValues: []
}
},
watch: {
selectField(values) {
if (values && values.length > 0) {
const value = values[0]
const fieldId = value.id
this.componentInfo && this.componentInfo.setOptionDatas && fieldValues(fieldId).then(res => {
const datas = res.data.map(item => {
return { id: item, text: item }
})
this.componentInfo.setOptionDatas(datas)
this.$emit('re-fresh-component', this.componentInfo)
})
}
}
},
created() {
@@ -192,10 +212,8 @@ export default {
},
loadDataSetTree() {
groupTree({}).then(res => {
let datas = res.data
if (this.widget && this.widget.filterFieldMethod) {
datas = this.widget.filterFieldMethod(datas)
}
const datas = res.data
this.data = datas
})
},
@@ -249,7 +267,11 @@ export default {
loadField(tableId) {
fieldList(tableId).then(res => {
this.fieldDatas = res.data
let datas = res.data
if (this.widget && this.widget.filterFieldMethod) {
datas = this.widget.filterFieldMethod(datas)
}
this.fieldDatas = datas
})
},
showFieldDatas(row) {