Unverified 提交 b3caf75a authored 作者: fit2cloud-chenyw's avatar fit2cloud-chenyw 提交者: GitHub

Merge pull request #1454 from dataease/pr@dev@refactor_filter_default_value

feat: 新增时间控件动态默认值
...@@ -12,6 +12,7 @@ import org.springframework.web.bind.annotation.*; ...@@ -12,6 +12,7 @@ import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource; import javax.annotation.Resource;
import java.util.List; import java.util.List;
import java.util.stream.Collectors;
/** /**
* @Author gin * @Author gin
...@@ -75,4 +76,11 @@ public class DataSetTableFieldController { ...@@ -75,4 +76,11 @@ public class DataSetTableFieldController {
public List<Object> fieldValues(@PathVariable String fieldId) { public List<Object> fieldValues(@PathVariable String fieldId) {
return dataSetFieldService.fieldValues(fieldId); return dataSetFieldService.fieldValues(fieldId);
} }
@ApiOperation("多字段值枚举")
@PostMapping("multFieldValues")
public List<Object> multFieldValues(@RequestBody List<String> fieldIds) {
List<Object> results = fieldIds.stream().map(fieldId -> dataSetFieldService.fieldValues(fieldId)).flatMap(list -> list.stream()).distinct().collect(Collectors.toList());
return results;
}
} }
...@@ -138,6 +138,15 @@ export function fieldValues(fieldId) { ...@@ -138,6 +138,15 @@ export function fieldValues(fieldId) {
}) })
} }
export function multFieldValues(data) {
return request({
url: '/dataset/field/multFieldValues',
method: 'post',
loading: true,
data
})
}
export function isKettleRunning(showLoading = true) { export function isKettleRunning(showLoading = true) {
return request({ return request({
url: '/dataset/group/isKettleRunning', url: '/dataset/group/isKettleRunning',
......
...@@ -40,7 +40,7 @@ export default { ...@@ -40,7 +40,7 @@ export default {
props: { props: {
element: { element: {
type: Object, type: Object,
default: null default: () => {}
}, },
inDraw: { inDraw: {
type: Boolean, type: Boolean,
......
<template> <template>
<el-date-picker <el-date-picker
v-if="options!== null && options.attrs!==null" v-if="element.options!== null && element.options.attrs!==null"
ref="dateRef" ref="dateRef"
v-model="values" v-model="values"
:type="options.attrs.type" :type="element.options.attrs.type"
:range-separator="$t(options.attrs.rangeSeparator)" :range-separator="$t(element.options.attrs.rangeSeparator)"
:start-placeholder="$t(options.attrs.startPlaceholder)" :start-placeholder="$t(element.options.attrs.startPlaceholder)"
:end-placeholder="$t(options.attrs.endPlaceholder)" :end-placeholder="$t(element.options.attrs.endPlaceholder)"
:placeholder="$t(options.attrs.placeholder)" :placeholder="$t(element.options.attrs.placeholder)"
:append-to-body="inScreen" :append-to-body="inScreen"
value-format="timestamp" value-format="timestamp"
:size="size" :size="size"
...@@ -17,6 +17,7 @@ ...@@ -17,6 +17,7 @@
</template> </template>
<script> <script>
import { ApplicationContext } from '@/utils/ApplicationContext'
import { timeSection } from '@/utils' import { timeSection } from '@/utils'
export default { export default {
...@@ -38,20 +39,53 @@ export default { ...@@ -38,20 +39,53 @@ export default {
}, },
data() { data() {
return { return {
options: null,
operator: 'between', operator: 'between',
values: null values: null
} }
}, },
computed: {
defaultoptions() {
if (!this.element || !this.element.options || !this.element.options.attrs.default) return ''
return JSON.stringify(this.element.options.attrs.default)
}
},
watch: {
'element.options.value': function(value, old) {
if (this.element.serviceName === 'timeDateWidget' && this.element.options.attrs.default.isDynamic) {
// 如果设置了动态时间 不做任何操作
return
}
if (value === old) return
this.values = this.fillValueDerfault()
this.dateChange(value)
},
'defaultoptions': function(val, old) {
// console.log('default chaneg')
if (this.element.serviceName !== 'timeDateWidget') {
if (!this.element.options.attrs.default.isDynamic) {
this.values = this.fillValueDerfault()
this.dateChange(this.values)
return
}
}
if (val === old) return
const widget = ApplicationContext.getService(this.element.serviceName)
this.values = widget.dynamicDateFormNow(this.element)
this.dateChange(this.values)
}
},
created() { created() {
this.options = this.element.options if (this.element.serviceName === 'timeDateWidget' && this.element.options.attrs.default.isDynamic) {
if (this.element.options.attrs.default) {
if (this.options.value) { const widget = ApplicationContext.getService(this.element.serviceName)
if (this.options.attrs.type !== 'daterange') { this.values = widget.dynamicDateFormNow(this.element)
this.values = Array.isArray(this.options.value) ? this.options.value[0] : this.options.value this.dateChange(this.values)
} else {
this.values = this.options.value
} }
return
}
if (this.element.options.value) {
this.values = this.fillValueDerfault()
this.dateChange(this.values)
} }
}, },
methods: { methods: {
...@@ -59,32 +93,35 @@ export default { ...@@ -59,32 +93,35 @@ export default {
this.setCondition() this.setCondition()
}, },
setCondition() { setCondition() {
if (this.values) {
if (this.options.attrs.type !== 'daterange') {
this.options.value = Array.isArray(this.values) ? this.values[0] : this.values
} else {
this.options.value = this.values
}
} else {
this.options.value = []
}
const param = { const param = {
component: this.element, component: this.element,
value: Array.isArray(this.options.value) ? this.options.value : [this.options.value], value: this.formatFilterValue(),
operator: this.operator operator: this.operator
} }
param.value = this.formatValues(param.value) param.value = this.formatValues(param.value)
this.inDraw && this.$store.commit('addViewFilter', param) this.inDraw && this.$store.commit('addViewFilter', param)
}, },
dateChange(value) { dateChange(value) {
if (!this.inDraw) {
if (value === null) {
this.element.options.value = ''
} else {
this.element.options.value = Array.isArray(value) ? value.join() : value.toString()
}
}
this.setCondition() this.setCondition()
this.styleChange() this.styleChange()
}, },
formatFilterValue() {
if (this.values === null) return []
if (Array.isArray(this.values)) return this.values
return [this.values]
},
formatValues(values) { formatValues(values) {
if (!values || values.length === 0) { if (!values || values.length === 0) {
return [] return []
} }
if (this.options.attrs.type === 'daterange') { if (this.element.options.attrs.type === 'daterange') {
if (values.length !== 2) { if (values.length !== 2) {
return null return null
} }
...@@ -96,11 +133,21 @@ export default { ...@@ -96,11 +133,21 @@ export default {
return results return results
} else { } else {
const value = values[0] const value = values[0]
return timeSection(value, this.options.attrs.type) return timeSection(parseFloat(value), this.element.options.attrs.type)
} }
}, },
styleChange() { styleChange() {
this.$store.commit('recordStyleChange') this.$store.commit('recordStyleChange')
},
fillValueDerfault() {
const defaultV = this.element.options.value === null ? '' : this.element.options.value.toString()
if (this.element.options.attrs.type === 'daterange') {
if (defaultV === null || typeof defaultV === 'undefined' || defaultV === '') return []
return defaultV.split(',').map(item => parseFloat(item))
} else {
if (defaultV === null || typeof defaultV === 'undefined' || defaultV === '') return null
return parseFloat(defaultV.split(',')[0])
}
} }
} }
} }
......
<template> <template>
<el-input <el-input
v-if="options!== null && options.attrs!==null" v-if="element.options!== null && element.options.attrs!==null"
v-model="value" v-model="value"
resize="vertical" resize="vertical"
:placeholder="$t(options.attrs.placeholder)" :placeholder="$t(element.options.attrs.placeholder)"
@input="valueChange"
@keypress.enter.native="search" @keypress.enter.native="search"
@dblclick="setEdit" @dblclick="setEdit"
:size="size" :size="size"
...@@ -31,38 +32,46 @@ export default { ...@@ -31,38 +32,46 @@ export default {
}, },
data() { data() {
return { return {
options: null,
operator: 'like', operator: 'like',
value: null, value: null,
canEdit: false canEdit: false
} }
}, },
watch: {
'element.options.value': function(value, old) {
if (value === old) return
this.value = value
this.search()
}
},
created() { created() {
this.options = this.element.options if (this.element.options.value) {
if (this.inDraw && this.options.value && this.options.value.length > 0) { this.value = this.element.options.value
this.value = this.options.value[0] this.search()
} }
}, },
methods: { methods: {
search() { search() {
// this.options.value && this.setCondition() if (!this.inDraw) {
this.options.value = [] this.element.options.value = this.value
if (this.inDraw && this.value) {
this.options.value = [this.value]
} }
this.setCondition() this.setCondition()
}, },
setCondition() { setCondition() {
const param = { const param = {
component: this.element, component: this.element,
value: !this.options.value ? [] : Array.isArray(this.options.value) ? this.options.value : [this.options.value], value: !this.value ? [] : [this.value],
operator: this.operator operator: this.operator
} }
this.inDraw && this.$store.commit('addViewFilter', param) this.inDraw && this.$store.commit('addViewFilter', param)
}, },
setEdit() { setEdit() {
this.canEdit = true this.canEdit = true
},
valueChange(val) {
if (!this.inDraw) {
this.element.options.value = val
}
} }
} }
} }
......
<template> <template>
<el-form v-if="options!== null && options.attrs!==null" ref="form" style="max-height:34px" :model="form" :rules="rules"> <el-form v-if="element.options!== null && element.options.attrs!==null" ref="form" :model="form" :rules="rules">
<div class="de-number-range-container"> <div class="de-number-range-container">
<el-form-item prop="min"> <el-form-item prop="min">
<el-input v-model="form.min" :placeholder="$t(options.attrs.placeholder_min)" :size="size" @change="handleMinChange" /> <el-input v-model="form.min" :placeholder="$t(element.options.attrs.placeholder_min)" @input="inputChange" @change="handleMinChange" />
</el-form-item> </el-form-item>
<span>{{ $t('denumberrange.split_placeholder') }}</span> <span>{{ $t('denumberrange.split_placeholder') }}</span>
<el-form-item prop="max"> <el-form-item prop="max">
<el-input v-model="form.max" :placeholder="$t(options.attrs.placeholder_max)" :size="size" @change="handleMaxChange" /> <el-input v-model="form.max" :placeholder="$t(element.options.attrs.placeholder_max)" @input="inputChange" @change="handleMaxChange" />
</el-form-item> </el-form-item>
</div> </div>
</el-form> </el-form>
...@@ -27,13 +27,11 @@ export default { ...@@ -27,13 +27,11 @@ export default {
inDraw: { inDraw: {
type: Boolean, type: Boolean,
default: true default: true
}, }
size: String
}, },
data() { data() {
return { return {
options: null,
operator: 'between', operator: 'between',
values: null, values: null,
canEdit: false, canEdit: false,
...@@ -55,7 +53,24 @@ export default { ...@@ -55,7 +53,24 @@ export default {
timeMachine: null timeMachine: null
} }
}, },
computed: {
defaultvalues() {
if (!this.element.options.value) {
return JSON.stringify([])
}
return JSON.stringify(this.element.options.value)
}
},
watch: { watch: {
'defaultvalues': function(value, old) {
if (value === old) return
const values = this.element.options.value
this.form.min = values[0]
if (values.length > 1) {
this.form.max = values[1]
}
this.search()
},
form: { form: {
handler(value) { handler(value) {
this.destryTimeMachine() this.destryTimeMachine()
...@@ -66,12 +81,13 @@ export default { ...@@ -66,12 +81,13 @@ export default {
} }
}, },
created() { created() {
this.options = this.element.options if (this.element.options.value && this.element.options.value.length > 0) {
if (this.inDraw && this.options.value && this.options.value.length > 0) { const values = this.element.options.value
this.form.min = this.options.value[0] this.form.min = values[0]
if (this.options.value.length > 1) { if (values.length > 1) {
this.form.max = this.options.value[1] this.form.max = values[1]
} }
this.search()
} }
}, },
methods: { methods: {
...@@ -137,13 +153,15 @@ export default { ...@@ -137,13 +153,15 @@ export default {
}, },
search() { search() {
this.$refs.form.validate(valid => { this.$nextTick(() => {
if (!valid) { this.$refs.form.validate(valid => {
return false if (!valid) {
} return false
}
this.setCondition() this.setCondition()
this.$store.commit('recordStyleChange') this.$store.commit('recordStyleChange')
})
}) })
}, },
setCondition() { setCondition() {
...@@ -154,7 +172,6 @@ export default { ...@@ -154,7 +172,6 @@ export default {
operator: this.operator operator: this.operator
} }
this.inDraw && (this.options.value = param.value)
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)
return return
...@@ -179,6 +196,13 @@ export default { ...@@ -179,6 +196,13 @@ export default {
}, },
styleChange() { styleChange() {
this.$store.commit('recordStyleChange') this.$store.commit('recordStyleChange')
},
inputChange(val) {
if (!this.inDraw) {
const values = [this.form.min, this.form.max]
this.element.options.value = values
}
} }
} }
} }
...@@ -187,7 +211,6 @@ export default { ...@@ -187,7 +211,6 @@ export default {
<style lang="scss" scoped> <style lang="scss" scoped>
.de-number-range-container { .de-number-range-container {
display: inline; display: inline;
max-height: 40px;
>>>div.el-form-item { >>>div.el-form-item {
width: calc(50% - 10px) !important; width: calc(50% - 10px) !important;
display: inline-block; display: inline-block;
......
<template> <template>
<el-select <el-select
v-if="options!== null && options.attrs!==null" v-if="element.options!== null && element.options.attrs!==null && show"
ref="deSelect" ref="deSelect"
v-model="options.value" v-model="value"
:collapse-tags="showNumber" :collapse-tags="showNumber"
:clearable="!options.attrs.multiple" :clearable="!element.options.attrs.multiple"
:multiple="options.attrs.multiple" :multiple="element.options.attrs.multiple"
:placeholder="$t(options.attrs.placeholder)" :placeholder="$t(element.options.attrs.placeholder)"
:popper-append-to-body="inScreen" :popper-append-to-body="inScreen"
:size="size" :size="size"
@change="changeValue" @change="changeValue"
@focus="setOptionWidth" @focus="setOptionWidth"
> >
<el-option <el-option
v-for="item in options.attrs.datas" v-for="item in datas"
:key="item[options.attrs.key]" :key="item[element.options.attrs.key]"
:style="{width:selectOptionWidth}" :style="{width:selectOptionWidth}"
:label="item[options.attrs.label]" :label="item[element.options.attrs.label]"
:value="item[options.attrs.value]" :value="item[element.options.attrs.value]"
> >
<span :title="item[options.attrs.label]" style="display:inline-block;width:100%;white-space:nowrap;text-overflow:ellipsis;overflow:hidden;">{{ item[options.attrs.label] }}</span> <span :title="item[element.options.attrs.label]" style="display:inline-block;width:100%;white-space:nowrap;text-overflow:ellipsis;overflow:hidden;">{{ item[element.options.attrs.label] }}</span>
</el-option> </el-option>
</el-select> </el-select>
</template> </template>
<script> <script>
import { fieldValues } from '@/api/dataset/dataset' import { multFieldValues } from '@/api/dataset/dataset'
export default { export default {
props: { props: {
element: { element: {
type: Object, type: Object,
default: null default: () => {}
}, },
inDraw: { inDraw: {
type: Boolean, type: Boolean,
...@@ -48,54 +48,80 @@ export default { ...@@ -48,54 +48,80 @@ export default {
}, },
data() { data() {
return { return {
options: null,
showNumber: false, showNumber: false,
selectOptionWidth: 0 selectOptionWidth: 0,
show: true,
value: null,
datas: []
} }
}, },
computed: { computed: {
operator() { operator() {
return this.options.attrs.multiple ? 'in' : 'eq' return this.element.options.attrs.multiple ? 'in' : 'eq'
} }
}, },
watch: { watch: {
'options.attrs.multiple': function(value) { 'element.options.value': function(value, old) {
const sourceValue = this.options.value if (value === old) return
const sourceValid = !!sourceValue && Object.keys(sourceValue).length > 0 this.value = this.fillValueDerfault()
if (value) { this.changeValue(value)
!sourceValid && (this.options.value = []) },
sourceValid && !Array.isArray(sourceValue) && (this.options.value = sourceValue.split(',')) 'element.options.attrs.fieldId': function(value, old) {
!this.inDraw && (this.options.value = []) if (typeof value === 'undefined' || value === old) return
} else { this.datas = []
!sourceValid && (this.options.value = null) this.element.options.attrs.fieldId &&
sourceValid && Array.isArray(sourceValue) && (this.options.value = sourceValue[0]) this.element.options.attrs.fieldId.length > 0 &&
!this.inDraw && (this.options.value = null) multFieldValues(this.element.options.attrs.fieldId.split(',')).then(res => {
this.datas = this.optionDatas(res.data)
}) || (this.element.options.value = '')
},
'element.options.attrs.multiple': function(value, old) {
if (typeof old === 'undefined' || value === old) return
if (!this.inDraw) {
this.value = value ? [] : null
this.element.options.value = ''
} }
}
}, this.show = false
created() { this.$nextTick(() => {
this.options = this.element.options this.show = true
if (this.options.attrs.fieldId) {
fieldValues(this.options.attrs.fieldId).then(res => {
this.options.attrs.datas = this.optionDatas(res.data)
}) })
} }
// this.setCondition()
}, },
mounted() { created() {
// this.$nextTick(() => { this.initLoad()
// this.options && this.options.value && this.changeValue(this.options.value)
// })
this.options && this.options.value && Object.keys(this.options.value).length > 0 && this.changeValue(this.options.value)
}, },
methods: { methods: {
initLoad() {
this.value = this.fillValueDerfault()
this.datas = []
if (this.element.options.attrs.fieldId) {
multFieldValues(this.element.options.attrs.fieldId.split(',')).then(res => {
this.datas = this.optionDatas(res.data)
})
}
if (this.element.options.value) {
this.value = this.fillValueDerfault()
this.changeValue(this.value)
}
},
changeValue(value) { changeValue(value) {
if (!this.inDraw) {
if (value === null) {
this.element.options.value = ''
} else {
this.element.options.value = Array.isArray(value) ? value.join() : value
}
}
this.setCondition() this.setCondition()
this.styleChange() this.styleChange()
this.showNumber = false this.showNumber = false
this.$nextTick(() => { this.$nextTick(() => {
if (!this.$refs.deSelect.$refs.tags || !this.options.attrs.multiple) { if (!this.element.options.attrs.multiple || !this.$refs.deSelect || !this.$refs.deSelect.$refs.tags) {
return return
} }
const kids = this.$refs.deSelect.$refs.tags.children[0].children const kids = this.$refs.deSelect.$refs.tags.children[0].children
...@@ -110,11 +136,26 @@ export default { ...@@ -110,11 +136,26 @@ export default {
setCondition() { setCondition() {
const param = { const param = {
component: this.element, component: this.element,
value: Array.isArray(this.options.value) ? this.options.value : [this.options.value], value: this.formatFilterValue(),
operator: this.operator operator: this.operator
} }
this.inDraw && this.$store.commit('addViewFilter', param) this.inDraw && this.$store.commit('addViewFilter', param)
}, },
formatFilterValue() {
if (this.value === null) return []
if (Array.isArray(this.value)) return this.value
return this.value.split(',')
},
fillValueDerfault() {
const defaultV = this.element.options.value === null ? '' : this.element.options.value.toString()
if (this.element.options.attrs.multiple) {
if (defaultV === null || typeof defaultV === 'undefined' || defaultV === '') return []
return defaultV.split(',')
} else {
if (defaultV === null || typeof defaultV === 'undefined' || defaultV === '') return null
return defaultV.split(',')[0]
}
},
styleChange() { styleChange() {
this.$store.commit('recordStyleChange') this.$store.commit('recordStyleChange')
}, },
......
...@@ -11,7 +11,9 @@ const dialogPanel = { ...@@ -11,7 +11,9 @@ const dialogPanel = {
attrs: { attrs: {
placeholder_min: 'denumberrange.please_key_min', placeholder_min: 'denumberrange.please_key_min',
placeholder_max: 'denumberrange.please_key_max', placeholder_max: 'denumberrange.please_key_max',
viewIds: [] viewIds: [],
fieldId: '',
dragItems: []
}, },
value: '' value: ''
}, },
......
...@@ -16,7 +16,9 @@ const dialogPanel = { ...@@ -16,7 +16,9 @@ const dialogPanel = {
datas: [], datas: [],
key: 'id', key: 'id',
label: 'text', label: 'text',
value: 'id' value: 'id',
fieldId: '',
dragItems: []
}, },
value: '' value: ''
}, },
......
...@@ -13,9 +13,12 @@ const dialogPanel = { ...@@ -13,9 +13,12 @@ const dialogPanel = {
multiple: false, multiple: false,
placeholder: 'denumberselect.placeholder', placeholder: 'denumberselect.placeholder',
datas: [], datas: [],
viewIds: [],
key: 'id', key: 'id',
label: 'text', label: 'text',
value: 'id' value: 'id',
fieldId: '',
dragItems: []
}, },
value: '' value: ''
}, },
......
...@@ -10,7 +10,9 @@ const dialogPanel = { ...@@ -10,7 +10,9 @@ const dialogPanel = {
options: { options: {
attrs: { attrs: {
placeholder: 'deinputsearch.placeholder', placeholder: 'deinputsearch.placeholder',
viewIds: [] viewIds: [],
fieldId: '',
dragItems: []
}, },
value: '' value: ''
......
...@@ -16,7 +16,9 @@ const dialogPanel = { ...@@ -16,7 +16,9 @@ const dialogPanel = {
datas: [], datas: [],
key: 'id', key: 'id',
label: 'text', label: 'text',
value: 'id' value: 'id',
fieldId: '',
dragItems: []
}, },
value: '' value: ''
}, },
......
...@@ -16,7 +16,9 @@ const dialogPanel = { ...@@ -16,7 +16,9 @@ const dialogPanel = {
datas: [], datas: [],
key: 'id', key: 'id',
label: 'text', label: 'text',
value: 'id' value: 'id',
fieldId: '',
dragItems: []
}, },
value: '' value: ''
}, },
......
...@@ -13,7 +13,9 @@ const dialogPanel = { ...@@ -13,7 +13,9 @@ const dialogPanel = {
rangeSeparator: 'dedaterange.split_placeholder', rangeSeparator: 'dedaterange.split_placeholder',
startPlaceholder: 'dedaterange.from_placeholder', startPlaceholder: 'dedaterange.from_placeholder',
endPlaceholder: 'dedaterange.to_placeholder', endPlaceholder: 'dedaterange.to_placeholder',
viewIds: [] viewIds: [],
fieldId: '',
dragItems: []
}, },
value: '' value: ''
}, },
......
...@@ -11,7 +11,16 @@ const dialogPanel = { ...@@ -11,7 +11,16 @@ const dialogPanel = {
attrs: { attrs: {
type: 'date', type: 'date',
placeholder: 'dedate.placeholder', placeholder: 'dedate.placeholder',
viewIds: [] viewIds: [],
fieldId: '',
dragItems: [],
default: {
isDynamic: false,
dkey: 0,
dynamicPrefix: 1,
dynamicInfill: 'day',
dynamicSuffix: 'before'
}
}, },
value: '' value: ''
}, },
...@@ -62,6 +71,69 @@ class TimeDateServiceImpl extends WidgetService { ...@@ -62,6 +71,69 @@ class TimeDateServiceImpl extends WidgetService {
return field['deType'] === 1 return field['deType'] === 1
}) })
} }
dynamicDateFormNow(element) {
if (element.options.attrs.default === null || typeof element.options.attrs.default === 'undefined' || !element.options.attrs.default.isDynamic) return null
if (element.options.attrs.default.dkey === 0) {
return Date.now()
}
if (element.options.attrs.default.dkey === 1) {
const oneday = 24 * 3600 * 1000
return Date.now() - oneday
}
if (element.options.attrs.default.dkey === 2) {
const now = new Date()
const nowMonth = now.getMonth()
var nowYear = now.getFullYear()
return new Date(nowYear, nowMonth, 1).getTime()
}
if (element.options.attrs.default.dkey === 3) {
const dynamicPrefix = element.options.attrs.default.dynamicPrefix
const dynamicInfill = element.options.attrs.default.dynamicInfill
const dynamicSuffix = element.options.attrs.default.dynamicSuffix
if (dynamicInfill === 'day') {
const oneday = 24 * 3600 * 1000
const step = oneday * dynamicPrefix
return dynamicSuffix === 'before' ? (Date.now() - step) : (Date.now() + step)
}
if (dynamicInfill === 'week') {
const oneday = 24 * 3600 * 1000
const step = oneday * dynamicPrefix * 7
return dynamicSuffix === 'before' ? (Date.now() - step) : (Date.now() + step)
}
if (dynamicInfill === 'month') {
const now = new Date()
const nowMonth = now.getMonth()
const nowYear = now.getFullYear()
const nowDate = now.getDate()
const tarYear = nowYear
if (dynamicSuffix === 'before') {
const deffMonth = nowMonth - dynamicPrefix
let diffYear = deffMonth / 12
if (deffMonth < 0) {
diffYear -= 1
}
return new Date(tarYear + diffYear, nowMonth - dynamicPrefix % 12, nowDate).getTime()
} else {
const deffMonth = nowMonth + dynamicPrefix
const diffYear = deffMonth / 12
return new Date(tarYear + diffYear, deffMonth % 12, nowDate).getTime()
}
}
if (dynamicInfill === 'year') {
const now = new Date()
const nowMonth = now.getMonth()
const nowYear = now.getFullYear()
const nowDate = now.getDate()
return new Date(nowYear - 1, nowMonth, nowDate).getTime()
}
}
}
} }
const timeDateServiceImpl = new TimeDateServiceImpl({ name: 'timeDateWidget' }) const timeDateServiceImpl = new TimeDateServiceImpl({ name: 'timeDateWidget' })
export default timeDateServiceImpl export default timeDateServiceImpl
...@@ -11,7 +11,9 @@ const dialogPanel = { ...@@ -11,7 +11,9 @@ const dialogPanel = {
attrs: { attrs: {
type: 'month', type: 'month',
placeholder: 'deyearmonth.placeholder', placeholder: 'deyearmonth.placeholder',
viewIds: [] viewIds: [],
fieldId: '',
dragItems: []
}, },
value: '' value: ''
}, },
......
...@@ -11,7 +11,9 @@ const dialogPanel = { ...@@ -11,7 +11,9 @@ const dialogPanel = {
attrs: { attrs: {
type: 'year', type: 'year',
placeholder: 'deyear.placeholder', placeholder: 'deyear.placeholder',
viewIds: [] viewIds: [],
fieldId: '',
dragItems: []
}, },
value: '' value: ''
}, },
......
...@@ -146,20 +146,18 @@ ...@@ -146,20 +146,18 @@
custom-class="de-filter-dialog" custom-class="de-filter-dialog"
@close="cancelFilter" @close="cancelFilter"
> >
<filter-dialog v-if="filterVisible && currentWidget" :widget-info="currentWidget" :component-info="currentFilterCom" @re-fresh-component="reFreshComponent"> <filter-dialog
<component v-if="filterVisible && currentWidget"
:is="currentFilterCom.component" :ref="'filter-setting-' + currentFilterCom.id"
:id="'component' + currentFilterCom.id" :widget-info="currentWidget"
class="component" :element="currentFilterCom"
:style="currentFilterCom.style" @sure-button-status="sureStatusChange"
:element="currentFilterCom" @re-fresh-component="reFreshComponent"
:in-draw="false" />
/>
</filter-dialog>
<div style="text-align: end !important;margin: 0 15px 10px !important;"> <div style="text-align: end !important;margin: 0 15px 10px !important;">
<span slot="footer"> <span slot="footer">
<el-button size="mini" @click="cancelFilter">{{ $t('commons.cancel') }}</el-button> <el-button size="mini" @click="cancelFilter">{{ $t('commons.cancel') }}</el-button>
<el-button :disabled="!currentFilterCom.options.attrs.fieldId" type="primary" size="mini" @click="sureFilter">{{ $t('commons.confirm') }}</el-button> <el-button :disabled="!enableSureButton" type="primary" size="mini" @click="sureFilter">{{ $t('commons.confirm') }}</el-button>
</span> </span>
</div> </div>
</el-dialog> </el-dialog>
...@@ -217,9 +215,7 @@ import { uuid } from 'vue-uuid' ...@@ -217,9 +215,7 @@ import { uuid } from 'vue-uuid'
import Toolbar from '@/components/canvas/components/Toolbar' import Toolbar from '@/components/canvas/components/Toolbar'
import { findOne } from '@/api/panel/panel' import { findOne } from '@/api/panel/panel'
import { getPanelAllLinkageInfo } from '@/api/panel/linkage' import { getPanelAllLinkageInfo } from '@/api/panel/linkage'
import PreviewFullScreen from '@/components/canvas/components/Editor/PreviewFullScreen'
import Preview from '@/components/canvas/components/Editor/Preview' import Preview from '@/components/canvas/components/Editor/Preview'
import AttrList from '@/components/canvas/components/AttrList'
import AttrListExtend from '@/components/canvas/components/AttrListExtend' import AttrListExtend from '@/components/canvas/components/AttrListExtend'
import elementResizeDetectorMaker from 'element-resize-detector' import elementResizeDetectorMaker from 'element-resize-detector'
import AssistComponent from '@/views/panel/AssistComponent' import AssistComponent from '@/views/panel/AssistComponent'
...@@ -234,9 +230,7 @@ import FilterDialog from '../filter/filterDialog' ...@@ -234,9 +230,7 @@ import FilterDialog from '../filter/filterDialog'
import toast from '@/components/canvas/utils/toast' import toast from '@/components/canvas/utils/toast'
import { commonStyle, commonAttr } from '@/components/canvas/custom-component/component-list' import { commonStyle, commonAttr } from '@/components/canvas/custom-component/component-list'
import generateID from '@/components/canvas/utils/generateID' import generateID from '@/components/canvas/utils/generateID'
import RectangleAttr from '@/components/canvas/components/RectangleAttr'
import TextAttr from '@/components/canvas/components/TextAttr' import TextAttr from '@/components/canvas/components/TextAttr'
import FilterTextAttr from '@/components/canvas/components/FilterTextAttr'
import { queryPanelJumpInfo } from '@/api/panel/linkJump' import { queryPanelJumpInfo } from '@/api/panel/linkJump'
import ComponentWait from '@/views/panel/edit/ComponentWait' import ComponentWait from '@/views/panel/edit/ComponentWait'
...@@ -253,16 +247,12 @@ export default { ...@@ -253,16 +247,12 @@ export default {
Toolbar, Toolbar,
FilterDialog, FilterDialog,
SubjectSetting, SubjectSetting,
PreviewFullScreen,
Preview, Preview,
AttrList,
AttrListExtend, AttrListExtend,
AssistComponent, AssistComponent,
PanelTextEditor, PanelTextEditor,
RectangleAttr,
TextAttr, TextAttr,
ChartGroup, ChartGroup
FilterTextAttr
}, },
data() { data() {
return { return {
...@@ -295,7 +285,6 @@ export default { ...@@ -295,7 +285,6 @@ export default {
width: null, width: null,
height: null height: null
}, },
beforeDialogValue: [],
styleDialogVisible: false, styleDialogVisible: false,
currentDropElement: null, currentDropElement: null,
adviceGroupId: null, adviceGroupId: null,
...@@ -312,7 +301,8 @@ export default { ...@@ -312,7 +301,8 @@ export default {
'rect-shape', 'rect-shape',
'de-show-date', 'de-show-date',
'de-video' 'de-video'
] ],
enableSureButton: false
} }
}, },
...@@ -674,11 +664,9 @@ export default { ...@@ -674,11 +664,9 @@ export default {
} }
}, },
openFilterDialog() { openFilterDialog() {
this.beforeDialogValue = []
this.filterVisible = true this.filterVisible = true
}, },
closeFilter() { closeFilter() {
this.beforeDialogValue = []
this.filterVisible = false this.filterVisible = false
this.currentWidget = null this.currentWidget = null
this.clearCurrentInfo() this.clearCurrentInfo()
...@@ -688,9 +676,10 @@ export default { ...@@ -688,9 +676,10 @@ export default {
bus.$emit('onRemoveLastItem') bus.$emit('onRemoveLastItem')
}, },
sureFilter() { sureFilter() {
this.currentFilterCom.options.value = [] this.currentFilterCom = this.$refs['filter-setting-' + this.currentFilterCom.id].getElementInfo()
this.$store.commit('setComponentWithId', this.currentFilterCom) this.$store.commit('setComponentWithId', this.currentFilterCom)
this.$store.commit('recordSnapshot', 'sureFilter') this.$store.commit('recordSnapshot', 'sureFilter')
this.$store.commit('setCurComponent', { component: this.currentFilterCom, index: this.curComponentIndex })
this.closeFilter() this.closeFilter()
}, },
reFreshComponent(component) { reFreshComponent(component) {
...@@ -701,9 +690,9 @@ export default { ...@@ -701,9 +690,9 @@ export default {
if (this.curComponent && this.curComponent.serviceName) { if (this.curComponent && this.curComponent.serviceName) {
const serviceName = this.curComponent.serviceName const serviceName = this.curComponent.serviceName
this.currentWidget = ApplicationContext.getService(serviceName) this.currentWidget = ApplicationContext.getService(serviceName)
this.currentFilterCom = this.curComponent
this.openFilterDialog()
} }
this.currentFilterCom = this.curComponent
this.openFilterDialog()
}, },
closeLeftPanel() { closeLeftPanel() {
this.show = false this.show = false
...@@ -880,6 +869,9 @@ export default { ...@@ -880,6 +869,9 @@ export default {
e.preventDefault() e.preventDefault()
e.dataTransfer.dropEffect = 'copy' e.dataTransfer.dropEffect = 'copy'
this.$refs.canvasEditor.handleDragOver(e) this.$refs.canvasEditor.handleDragOver(e)
},
sureStatusChange(status) {
this.enableSureButton = status
} }
} }
} }
......
<template>
<div v-if="element">
<el-form ref="form" :model="element.options.attrs.default" label-width="100px">
<el-form-item label="设定默认值">
<el-radio-group v-model="element.options.attrs.default.isDynamic" @change="dynamicChange">
<el-radio :label="false">固定时间</el-radio>
<el-radio :label="true">动态时间</el-radio>
</el-radio-group>
</el-form-item>
<el-form-item v-if="element.options.attrs.default.isDynamic" label="相对当前时间">
<el-select v-model="element.options.attrs.default.dkey" placeholder="" class="relative-time" @change="dkeyChange">
<el-option label="今天" :value="0" />
<el-option label="昨天" :value="1" />
<el-option label="本月首日" :value="2" />
<el-option label="自定义" :value="3" />
</el-select>
</el-form-item>
<div class="inline">
<el-form-item v-if="element.options.attrs.default.isDynamic && element.options.attrs.default.dkey === 3" label="">
<el-input v-model="element.options.attrs.default.dynamicPrefix" type="number" size="mini" :min="1" :max="10" @input="dynamicPrefixChange" />
</el-form-item>
<el-form-item v-if="element.options.attrs.default.isDynamic && element.options.attrs.default.dkey === 3" label="" class="no-label-item">
<el-select v-model="element.options.attrs.default.dynamicInfill" size="mini" placeholder="" @change="dynamicInfillChange">
<el-option label="天" value="day" />
<el-option label="周" value="week" />
<el-option label="月" value="month" />
<el-option label="年" value="year" />
</el-select>
</el-form-item>
<el-form-item v-if="element.options.attrs.default.isDynamic && element.options.attrs.default.dkey === 3" label="" class="no-label-item">
<el-select v-model="element.options.attrs.default.dynamicSuffix" size="mini" placeholder="" @change="dynamicSuffixChange">
<el-option label="前" value="before" />
<el-option label="后" value="after" />
</el-select>
</el-form-item>
</div>
<el-form-item v-if="element.options.attrs.default.isDynamic" label="预览">
<el-date-picker
v-model="dval"
type="date"
disabled
placeholder=""
class="relative-time"
/>
</el-form-item>
<el-form-item v-else label="设置">
<component
:is="element.component"
:id="'component' + element.id"
class="relative-time"
:style="element.style"
:element="element"
:in-draw="false"
/>
</el-form-item>
</el-form>
</div>
</template>
<script>
import { ApplicationContext } from '@/utils/ApplicationContext'
export default {
name: 'DeDateDefault',
props: {
element: {
type: Object,
default: null
}
},
data() {
return {
dval: null
}
},
created() {
this.setDval()
},
methods: {
dynamicChange(value) {
this.setDval()
},
dkeyChange(value) {
this.setDval()
},
dynamicPrefixChange(value) {
this.setDval()
},
dynamicInfillChange(value) {
this.setDval()
},
dynamicSuffixChange(value) {
this.setDval()
},
setDval() {
const widget = ApplicationContext.getService(this.element.serviceName)
const time = widget.dynamicDateFormNow(this.element)
this.dval = time
}
}
}
</script>
<style lang="scss" scoped>
.inline {
display: flex;
>>>.el-input--mini {
min-width: 70px;
}
}
.relative-time {
width: 100%;
}
</style>
<template>
<el-row>
<el-col :span="8">
<div class="filter-options-left">
<el-switch
v-if="widget.showSwitch"
v-model="attrs.multiple"
:active-text="$t('panel.multiple_choice')"
:inactive-text="$t('panel.single_choice')"
@change="multipleChange"
/>
</div>
</el-col>
<el-col :span="16">
<div class="filter-options-right">
<span style="padding-right: 10px;">
<el-checkbox v-model="attrs.showTitle" @change="showTitleChange">显示标题
</el-checkbox>
<el-popover v-model="titlePopovervisible" placement="bottom-end" :disabled="!attrs.showTitle" width="200">
<div style="width: 100%;overflow-y: auto;overflow-x: hidden;word-break: break-all;position: relative;">
<el-input v-model="attrs.title" placeholder="请输入标题" type="textarea" maxlength="15" show-word-limit />
</div>
<i
slot="reference"
:class="{'i-filter-active': attrs.showTitle, 'i-filter-inactive': !attrs.showTitle}"
class="el-icon-setting i-filter"
/>
</el-popover>
</span>
<span style="padding-left: 10px;">
<el-checkbox v-model="attrs.enableRange" @change="enableRangeChange"><span>
{{ $t('panel.custom_scope') }} </span> </el-checkbox>
<el-popover v-model="popovervisible" placement="bottom-end" :disabled="!attrs.enableRange" width="200">
<div class="view-container-class">
<el-checkbox-group v-model="attrs.viewIds" @change="checkedViewsChange">
<el-checkbox
v-for="(item ) in childViews.viewInfos"
:key="item.id"
:label="item.id"
class="de-checkbox"
>
<div class="span-div">
<svg-icon :icon-class="item.type" class="chart-icon" />
<span v-if="item.name && item.name.length <= 7" style="margin-left: 6px">{{ item.name }}</span>
<el-tooltip v-else class="item" effect="dark" :content="item.name" placement="left">
<span style="margin-left: 6px">{{ item.name }}</span>
</el-tooltip>
</div>
</el-checkbox>
</el-checkbox-group>
</div>
<i
slot="reference"
:class="{'i-filter-active': attrs.enableRange, 'i-filter-inactive': !attrs.enableRange}"
class="el-icon-setting i-filter"
/>
</el-popover>
</span>
</div>
</el-col>
</el-row>
</template>
<script>
export default {
name: 'FilterControl',
props: {
widget: {
type: Object,
default: null
},
controlAttrs: {
type: Object,
default: null
},
childViews: {
type: Object,
default: () => {}
},
element: {
type: Object,
default: null
}
},
data() {
return {
attrs: null,
titlePopovervisible: false,
popovervisible: false
}
},
created() {
this.attrs = this.controlAttrs
},
methods: {
multipleChange(value) {
this.fillAttrs2Filter()
},
checkedViewsChange(values) {
this.fillAttrs2Filter()
},
enableRangeChange(value) {
if (!value) {
this.attrs.viewIds = []
}
this.fillAttrs2Filter()
},
showTitleChange(value) {
if (!value) {
this.attrs.title = ''
// this.componentInfo.style.backgroundColor = ''
}
this.fillAttrs2Filter()
},
fillAttrs2Filter() {}
}
}
</script>
<style lang="scss" scoped>
.filter-options-left {
align-items: center;
display: flex;
flex-direction: row;
justify-content: flex-start;
flex-wrap: nowrap;
height: 50px;
}
.filter-options-right {
align-items: center;
display: flex;
flex-direction: row;
justify-content: flex-end;
flex-wrap: nowrap;
height: 50px;
}
.i-filter {
text-align: center;
margin-left: 5px;
margin-top: 1px;
}
.i-filter-inactive {
color: #9ea6b2 !important;
cursor: not-allowed !important;
}
.i-filter-active {
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;
}
.span-div {
width: 135px;
white-space: nowrap;
text-overflow: ellipsis;
overflow: hidden;
}
</style>
<template>
<el-row>
<el-col :span="24">
<div class="filter-content">
<el-card v-if="element.serviceName && element.serviceName !== 'timeDateWidget'" class="box-card">
<div style="margin-bottom: 10px;">
<span>默认值设置</span>
</div>
<div class="custom-component-class">
<component
:is="element.component"
:id="'component' + element.id"
class="component"
:style="element.style"
:element="element"
:in-draw="false"
/>
</div>
</el-card>
<el-card v-if="element.serviceName && element.serviceName === 'timeDateWidget'" class="box-card">
<de-date-default v-if="element.serviceName && element.serviceName === 'timeDateWidget'" :element="element" />
</el-card>
</div>
</el-col>
</el-row>
</template>
<script>
import DeDateDefault from '@/views/panel/filter/defaultValue/DeDateDefault'
export default {
name: 'FilterFoot',
components: {
DeDateDefault
},
props: {
element: {
type: Object,
default: null
}
},
data() {
return {
}
},
methods: {
}
}
</script>
<style lang="scss" scoped>
.filter-content {
height: calc(50vh - 120px);
top: 160px;
}
.box-card {
width: 100%;
height: 100%;
}
</style>
<template>
<el-row>
<el-col :span="24">
<div class="filter-field">
<div class="field-content">
<div class="field-content-right">
<el-row style="display:flex;height: 32px;">
<draggable
v-model="element.options.attrs.dragItems"
group="dimension"
animation="300"
:move="onMove"
class="theme-drag"
style="width:100%;height: 100%;margin:0 10px;border-radius: 4px;overflow-x: auto;display: flex;align-items: center;"
@end="end2"
>
<div class="list-group-container">
<drag-item
v-for="(item,index) in element.options.attrs.dragItems"
:key="item.id"
:item="item"
:index="index"
@closeItem="closeItem"
/>
</div>
<transition-group class="list-group" :data-value="$t('panel.drag_here')" />
</draggable>
</el-row>
</div>
</div>
</div>
</el-col>
</el-row>
</template>
<script>
import draggable from 'vuedraggable'
import DragItem from '@/components/DragItem'
export default {
name: 'FilterHead',
components: {
draggable,
DragItem
},
props: {
element: {
type: Object,
default: () => {}
}
},
data() {
return {
targets: []
}
},
watch: {
},
created() {
},
methods: {
onMove(e, originalEvent) {
// this.moveId = e.draggedContext.element.id
return true
},
end2(e) {},
closeItem(tag) {
const index = tag.index
this.element.options.attrs.dragItems.splice(index, 1)
}
}
}
</script>
<style lang="scss" scoped>
.filter-field {
border-radius: 4px;
height: 45px;
.field-content {
position: relative;
display: table;
width: 100%;
height: 100%;
white-space: nowrap;
.field-content-left {
width: 50px;
max-width: 50px;
position: relative;
display: table-cell;
vertical-align: middle;
margin: 0px;
padding: 8px;
height: 100%;
border-right: none;
border: 1px solid var(--TableBorderColor, #E6E6E6);
;
.field-content-text {
box-sizing: border-box;
overflow: hidden;
overflow-x: hidden;
overflow-y: hidden;
word-break: break-all;
}
}
.field-content-right {
border-left: none;
color: #9ea6b2;
border: 1px solid var(--TableBorderColor, #E6E6E6);
width: 0%;
max-width: 0%;
position: relative;
display: table-cell;
vertical-align: middle;
margin: 0px;
padding: 0 0 0 0;
height: 100%;
}
}
}
.list-group-container:empty,.list-group-container>div:empty {
display: none;
}
.list-group:empty,
.list-group>div:empty {
display: inline-block;
width: 100%;
height: calc(100% - 13px);
}
.list-group:empty:before,
.list-group>div:empty:before {
content: attr(data-value);
}
.blackTheme .theme-drag {
background-color: var(--MainBG, #fff);
}
</style>
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论