feat: 优化时间选择器时间戳和自定义时间格式类型互换,导致的组件报错,日期时间选择器类型是范围时,将数据转成字符串

main
wu.jian2 2 years ago
parent e268755053
commit d1d5b63f8f

@ -147,7 +147,11 @@ export default {
},
//
changeValue (val) {
console.log(val)
// val
if (Array.isArray(val)) {
val = val.join(',')
}
console.log('val', val)
this.linkage({ [this.config.code]: val })
},
focusEvent () {

@ -218,27 +218,7 @@ export default {
},
watch: {},
mounted () {},
methods: {
// selectFormatType (type) {
// if (type === 'timestamp') {
// this.config.customize.value = 0
// this.config.customize.valueFormat = 'timestamp'
// } else if (type === 'custom') {
// this.config.customize.value = ''
// this.config.customize.valueFormat = 'YYYY-MM-DD HH:mm:ss'
// }
// },
// selectDisplayType (val) {
// if (['year', 'month', 'date', 'week', 'datetime'].includes(val)) {
// this.config.customize.value = moment(new Date()).format('YYYY-MM-DD HH:mm:ss')
// } else {
// this.config.customize.value = [
// moment(new Date()).subtract(7, 'days').format('YYYY-MM-DD HH:mm:ss'),
// moment(new Date()).format('YYYY-MM-DD HH:mm:ss')
// ]
// }
// }
}
methods: { }
}
</script>

@ -1,13 +1,13 @@
<template>
<el-time-picker
v-model="config.customize.value"
v-model="value"
:picker-options="config.customize.pickerOptions"
placeholder="选择时间"
clearable
:class="['basic-component-time-picker', `time-picker-${config.code}`]"
:popper-class="'basic-component-time-picker time-picker-popper-' + config.code"
:value-format="config.customize.valueFormat"
:default-value="config.customize.value"
:default-value="value"
@focus="focusEvent"
@change="changeValue"
@mouseenter.native="mouseenter"
@ -48,14 +48,29 @@ export default {
return (this.$route.path === window?.BS_CONFIG?.routers?.previewUrl) || (this.$route.path === '/big-screen/preview')
}
},
watch: { },
watch: {
'config.customize.formatType': {
handler (val) {
if (val === 'timestamp') {
this.value = 0
this.config.customize.valueFormat = 'timestamp'
} else if (val === 'custom') {
this.config.customize.valueFormat = 'HH:mm:ss'
this.value = ''
}
},
immediate: true
}
},
created () { },
mounted () {
if (!this.isPreview) {
document.querySelector(`.time-picker-${this.config.code}`).style.pointerEvents = 'none'
}
if (this.config.customize.value === '') {
this.config.customize.value = moment(new Date()).format(this.config.customize.valueFormat)
if (this.value === '') {
this.value = moment(new Date()).format(this.config.customize.valueFormat)
}
this.changeStyle(this.config)
},
@ -115,7 +130,6 @@ export default {
},
//
changeValue (val) {
console.log('val', val)
this.linkage({ [this.config.code]: val })
},
focusEvent () {
@ -156,7 +170,7 @@ export default {
})
},
mouseenter () {
if (this.config.customize.value) {
if (this.value) {
setTimeout(() => {
//
const timePickerCloseIcon = document.querySelector(`.time-picker-${this.innerConfig.code} .el-icon-circle-close`)

@ -89,8 +89,6 @@
v-model="config.customize.formatType"
class="bs-el-select"
popper-class="bs-el-select"
clearable
@change="selectFormatType"
>
<el-option
v-for="(type) in formatTypeOptions"
@ -177,17 +175,7 @@ export default {
},
watch: {},
mounted () {},
methods: {
selectFormatType (type) {
if (type === 'timestamp') {
this.config.customize.value = 0
this.config.customize.valueFormat = 'timestamp'
} else if (type === 'custom') {
this.config.customize.valueFormat = 'HH:mm:ss'
this.config.customize.value = ''
}
}
}
methods: { }
}
</script>

@ -316,12 +316,12 @@ export default {
}
if (item.type == 'customComponent') {
plotSettings[Symbol.iterator] = function * () {
let keys=Object.keys(plotSettings)
for(let k of keys){
const keys = Object.keys(plotSettings)
for (const k of keys) {
yield [k, plotSettings[k]]
}
}
for(let [key,value] of plotSettings){
for (const [key, value] of plotSettings) {
if (item.name == value.name) {
const settings = JSON.parse(JSON.stringify(value.setting))
item.setting = settings.map((x) => {

@ -237,7 +237,6 @@ export default {
return config
},
dataFormatting (config, data) {
console.log('config', config);
// config = this.config
//
if (data.success) {

Loading…
Cancel
Save