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

Merge pull request #1349 from dataease/pr@v1.5@fix_panel_date_component

fix: 仪表板日期组件无法二次编辑
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
<el-date-picker <el-date-picker
v-if="options!== null && options.attrs!==null" v-if="options!== null && options.attrs!==null"
ref="dateRef" ref="dateRef"
v-model="options.value" v-model="values"
:type="options.attrs.type" :type="options.attrs.type"
:range-separator="$t(options.attrs.rangeSeparator)" :range-separator="$t(options.attrs.rangeSeparator)"
:start-placeholder="$t(options.attrs.startPlaceholder)" :start-placeholder="$t(options.attrs.startPlaceholder)"
...@@ -10,6 +10,7 @@ ...@@ -10,6 +10,7 @@
:placeholder="$t(options.attrs.placeholder)" :placeholder="$t(options.attrs.placeholder)"
:append-to-body="inScreen" :append-to-body="inScreen"
style="min-height: 36px;" style="min-height: 36px;"
value-format="timestamp"
@change="dateChange" @change="dateChange"
/> />
</template> </template>
...@@ -42,11 +43,13 @@ export default { ...@@ -42,11 +43,13 @@ export default {
}, },
created() { created() {
this.options = this.element.options this.options = this.element.options
if ((this.options.attrs.type === 'date' || this.options.attrs.type === 'daterange') && Array.isArray(this.options.value) && this.options.value.length === 0) {
this.options.value = null if (this.options.value) {
if (this.options.attrs.type !== 'daterange') {
this.values = Array.isArray(this.options.value) ? this.options.value[0] : this.options.value
} else {
this.values = this.options.value
} }
if (!!this.options && !!this.options.value && Object.keys(this.options.value).length === 0) {
this.options.value = null
} }
}, },
methods: { methods: {
...@@ -54,6 +57,15 @@ export default { ...@@ -54,6 +57,15 @@ 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: Array.isArray(this.options.value) ? this.options.value : [this.options.value],
......
...@@ -4,6 +4,9 @@ export function timeSection(date, type) { ...@@ -4,6 +4,9 @@ export function timeSection(date, type) {
if (!date) { if (!date) {
return null return null
} }
if (!(date instanceof Date)) {
date = new Date(date)
}
const timeRanger = new Array(2) const timeRanger = new Array(2)
date.setHours(0) date.setHours(0)
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论