Commit 8f9fff5e authored by leon's avatar leon

feat: real time add data format

parent f2b97eca
...@@ -2,14 +2,12 @@ ...@@ -2,14 +2,12 @@
<view> <view>
<div class="timer"> <div class="timer">
<NormalTitle :elementInfo="elementInfo"></NormalTitle> <NormalTitle :elementInfo="elementInfo"></NormalTitle>
<div <div :style="{
:style="{
'font-size':`${elementInfo.option.time.textStyle.fontSize}px`, 'font-size':`${elementInfo.option.time.textStyle.fontSize}px`,
'color': elementInfo.option.time.textStyle.color, 'color': elementInfo.option.time.textStyle.color,
'font-weight': elementInfo.option.time.textStyle.fontWeight, 'font-weight': elementInfo.option.time.textStyle.fontWeight,
'text-align': elementInfo.option.time.left, 'text-align': elementInfo.option.time.left,
}" }">
>
{{ realTime }} {{ realTime }}
</div> </div>
</div> </div>
...@@ -17,10 +15,10 @@ ...@@ -17,10 +15,10 @@
</template> </template>
<script> <script>
import echartElementData from '@/mixins/echartElementData.js' import echartElementData from '@/mixins/echartElementData.js'
export default { export default {
name:"BasicText", name: "BasicText",
mixins: [echartElementData], mixins: [echartElementData],
data() { data() {
return { return {
...@@ -35,19 +33,38 @@ export default { ...@@ -35,19 +33,38 @@ export default {
methods: { methods: {
initChart() { initChart() {
this.timer = setInterval(() => { this.timer = setInterval(() => {
this.realTime = this.$u.common.dateFormat() const timestamp = new Date().getTime()
this.realTime = this.$u.timeFormat(timestamp, this.getDateFormat())
}, 1000) }, 1000)
},
// 大屏报表时间格式和uniapp的不一致,需要转换
getDateFormat() {
const dateFormat = this.elementInfo.option.time.dateFormat
if(dateFormat === "YYYY-MM-DD") {
return "yyyy-mm-dd"
}
if(dateFormat === "YYYY-MM-DD HH:mm") {
return "yyyy-mm-dd hh:MM"
}
if(dateFormat === "HH:mm") {
return "hh:MM"
}
if(dateFormat === "HH:mm:ss") {
return "hh:MM:ss"
}
return "yyyy-mm-dd hh:MM:ss"
}
} }
} }
}
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>
.timer { .timer {
display: flex; display: flex;
flex-flow: column; flex-flow: column;
justify-content: center; justify-content: center;
width: 100%; width: 100%;
color: #fff; color: #fff;
} }
</style> </style>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment