feat: 根据修改意见调整时间、日期时间选择器组件配置,时间格式化数据默认为自定义,去除Date对象

main
wu.jian2 2 years ago
parent 5daa4abd0f
commit 2d81127385

@ -31,8 +31,8 @@
import moment from 'moment'
import paramsMixins from 'data-room-ui/js/mixins/paramsMixins'
import { settingToTheme } from 'data-room-ui/js/utils/themeFormatting'
import cloneDeep from "lodash/cloneDeep";
import {mapMutations, mapState} from 'vuex'
import cloneDeep from 'lodash/cloneDeep'
import { mapMutations, mapState } from 'vuex'
export default {
name: 'CurrentTime',
mixins: [paramsMixins],

@ -52,7 +52,7 @@ export default {
if (val && val.customize && val.customize.formatType === 'custom') {
//
this.$nextTick(() => {
this.value = toString(this.value)
this.config.customize.value = toString(this.config.customize.value)
})
}
},
@ -65,6 +65,10 @@ export default {
document.querySelector(`.date-picker-${this.config.code}`).style.pointerEvents = 'none'
}
this.changeStyle(this.config)
// config.customize.value
if (this.config.customize.value === '') {
this.config.customize.value = new Date()
}
},
beforeDestroy () {
},

@ -137,13 +137,22 @@
/>
<!-- HH表示小时24小时制mm表示分钟ss表示秒 -->
<el-tooltip
content="时间格式示例yyyy表示年份MM表示月份dd表示日期HH表示小时24小时制mm表示分钟ss表示秒具体可参考Element-UI官网的日期选择器的时间格式化部分"
placement="top"
>
<span
class="el-icon-question"
style="color:#9e9e9e"
/>
<div slot="content">
时间格式示例<br>
yyyy表示年份<br>
MM表示月份<br>
dd表示日期<br>
HH表示小时24小时制<br>
mm表示分钟<br>
ss表示秒<br>
具体可参考Element-UI官网的日期选择器的时间格式化部分
</div>
</el-tooltip>
</div>
</el-form-item>
@ -193,7 +202,6 @@ export default {
second: 'ss',
//
formatTypeOptions: [
{ label: 'Date 对象', value: 'default' },
{ label: '时间戳', value: 'timestamp' },
{ label: '自定义', value: 'custom' }
],
@ -213,10 +221,7 @@ export default {
mounted () {},
methods: {
selectFormatType (type) {
if (type === 'default') {
this.config.customize.value = ''
this.config.customize.valueFormat = ''
} else if (type === 'timestamp') {
if (type === 'timestamp') {
this.config.customize.value = 0
this.config.customize.valueFormat = 'timestamp'
} else if (type === 'custom') {

@ -31,10 +31,10 @@ const customConfig = {
fontSize: 20,
// 显示类型 year/month/date/week/ datetime/datetimerange/daterange
type: 'datetime',
// 时间格式化类型:Date 对象default时间戳timestamp自定义custom
formatType: 'default',
// 时间格式化类型:时间戳timestamp自定义custom
formatType: 'custom',
// 绑定值的格式
valueFormat: '',
valueFormat: 'yyyy-MM-dd HH:mm:ss',
// 下拉框
dropDownBox: {
// 下拉框背景颜色

@ -14,6 +14,7 @@
</template>
<script>
import moment from 'moment'
import cloneDeep from 'lodash/cloneDeep'
import commonMixins from 'data-room-ui/js/mixins/commonMixins'
import linkageMixins from 'data-room-ui/js/mixins/linkageMixins'
@ -51,7 +52,7 @@ export default {
handler: function (val) {
if (val && val.customize && val.customize.formatType === 'custom') {
this.$nextTick(() => {
this.value = toString(this.value)
this.config.customize.value = toString(this.config.customize.value)
})
}
},
@ -64,6 +65,14 @@ export default {
// document.querySelector(`.time-picker-${this.config.code}`).style.pointerEvents = 'none'
}
this.changeStyle(this.config)
// config.customize.value HH:mm:ss
// if (this.config.customize.value === '') {
// this.config.customize.valueFormat = 'HH:mm:ss'
// this.$nextTick(() => {
// this.config.customize.value = moment(new Date()).format('HH:mm:ss')
// console.log(this.config.customize.value)
// })
// }
},
beforeDestroy () { },
methods: {

@ -111,13 +111,19 @@
clearable
/>
<el-tooltip
content="时间格式示例HH表示小时24小时制mm表示分钟ss表示秒"
placement="top"
>
<span
class="el-icon-question"
style="color:#9e9e9e"
/>
<div slot="content">
时间格式示例<br>
HH表示小时24小时制<br>
mm表示分钟<br>
ss表示秒
具体可参考Element-UI官网的日期选择器的时间格式化部分
</div>
</el-tooltip>
</div>
</el-form-item>
@ -162,12 +168,8 @@ export default {
},
data () {
return {
hour: 'HH',
minute: 'mm',
second: 'ss',
//
formatTypeOptions: [
{ label: 'Date 对象', value: 'default' },
{ label: '时间戳', value: 'timestamp' },
{ label: '自定义', value: 'custom' }
]
@ -177,10 +179,7 @@ export default {
mounted () {},
methods: {
selectFormatType (type) {
if (type === 'default') {
this.config.customize.value = ''
this.config.customize.valueFormat = ''
} else if (type === 'timestamp') {
if (type === 'timestamp') {
this.config.customize.value = 0
this.config.customize.valueFormat = 'timestamp'
} else if (type === 'custom') {

@ -39,10 +39,10 @@ const customConfig = {
dropDownHoverFontColor: '#FFFFFF',
// 下拉项激活文字颜色
dropDownSelectedFontColor: '#409EFF',
// 时间格式化类型:Date 对象default时间戳timestamp自定义custom
formatType: 'default',
// 时间格式化类型:时间戳timestamp自定义custom
formatType: 'custom',
// 绑定值的格式
valueFormat: ''
valueFormat: 'HH:mm:ss'
}
}
export const dataConfig = {

@ -278,7 +278,7 @@ export default function getComponentConfig (type) {
name: '日期时间选择器',
title: '日期时间选择器',
icon: Icon.getNameList()[23],
className: 'com.gccloud.dataroom.core.module.chart.components.ScreenTimePickerChart',
className: 'com.gccloud.dataroom.core.module.chart.components.ScreenDateTimePickerChart',
w: 260,
h: 80,
x: 0,

Loading…
Cancel
Save