feat:添加时间选择器的组件(10%)

This commit is contained in:
zhangyu
2021-06-21 11:29:26 +08:00
parent 5a02d866b8
commit e9dc7a7621
5 changed files with 89 additions and 27 deletions

View File

@@ -0,0 +1,62 @@
<template>
<div v-click-outside="{object: {a:1}, func: changeDropdown}">
<el-row @click="showDropdown">
<el-col :span="10" class="calendar-popover-text">{{dayJs.tz(startTime).format('YYYY-MM-DD HH:mm:ss')}}</el-col>
<el-col :span="4"> = </el-col>
<el-col :span="10" class="calendar-popover-text">{{dayJs.tz(endTime).format('YYYY-MM-DD HH:mm:ss')}}</el-col>
</el-row>
<div v-if="dropdownFlag" >
123123123123123123
</div>
</div>
</template>
<script>
import { ref, watch } from 'vue'
import MyDatePicker from '../MyDatePicker'
export default {
name: 'DateTimeRange',
props: {
startTime: {
type: Number,
default: window.$dayJs.tz().valueOf() - 60 * 60 * 1000
},
endTime: {
type: Number,
default: window.$dayJs.tz().valueOf()
}
},
emits: ['change'],
components: {
MyDatePicker
},
setup (props, ctx) {
// data
const myStartTime = ref(props.startTime)
const dropdownFlag = ref(false)
// methods
const showDropdown = () => {
dropdownFlag.value = !dropdownFlag.value
}
const changeDropdown = () => {
console.log(123123123)
if (dropdownFlag.value){
dropdownFlag.value = false
}
}
watch(myStartTime, (newValue, oldValue) => {
console.log('The new counter value is: ' + myStartTime.value)
})
return {
myStartTime,
dropdownFlag,
showDropdown,
changeDropdown
}
}
}
</script>
<style scoped>
</style>

View File

@@ -5,9 +5,6 @@
<!-- 顶部工具栏 --> <!-- 顶部工具栏 -->
<div class="main-container"> <div class="main-container">
<div class="top-tools"> <div class="top-tools">
<myDatePicker
v-model="value1"
type="datetime"/>
<div class="top-tool-left" style="min-width: 300px"> <div class="top-tool-left" style="min-width: 300px">
<slot name="top-tool-left"></slot> <slot name="top-tool-left"></slot>
</div> </div>
@@ -45,13 +42,11 @@
<script> <script>
import columnCustomize from '@/components/table/ColumnCustomize' import columnCustomize from '@/components/table/ColumnCustomize'
import myDatePicker from '../common/MyDatePicker'
import { fromRoute } from '@/utils/constants' import { fromRoute } from '@/utils/constants'
export default { export default {
name: 'cnDataList', name: 'cnDataList',
components: { components: {
myDatePicker,
columnCustomize columnCustomize
}, },
props: { props: {

View File

@@ -2,7 +2,7 @@ import { tableSort } from '@/utils/tools'
import { defaultPageSize, fromRoute, position } from '@/utils/constants' import { defaultPageSize, fromRoute, position } from '@/utils/constants'
import { get, del } from '@/utils/http' import { get, del } from '@/utils/http'
import { ref } from 'vue' import { ref } from 'vue'
import pagination from '@/components/common/pagination' import pagination from '@/components/common/Pagination'
export default { export default {
components: { components: {
pagination pagination

View File

@@ -1,7 +1,9 @@
<template> <template>
<div>
<DateTimeRange />
<div class="cn-panel"> <div class="cn-panel">
<chart v-for="(chart, index) in chartList" :key="index" :chart="chart"></chart> <chart v-for="(chart, index) in chartList" :key="index" :chart="chart"></chart>
<!-- <grid-layout v-model:layout="chartList" <!-- <grid-layout v-model:layout="chartList"
:col-num="12" :col-num="12"
:row-height="30" :row-height="30"
:is-draggable="draggable" :is-draggable="draggable"
@@ -20,6 +22,7 @@
</grid-item> </grid-item>
</grid-layout>--> </grid-layout>-->
</div> </div>
</div>
</template> </template>
<script> <script>
@@ -28,11 +31,13 @@ import { ref } from 'vue'
import { panelTypeAndRouteMapping } from '@/utils/constants' import { panelTypeAndRouteMapping } from '@/utils/constants'
import { api, getPanelList, getChartList } from '@/utils/api' import { api, getPanelList, getChartList } from '@/utils/api'
import Chart from './Chart' import Chart from './Chart'
import DateTimeRange from '@/components/common/TimeRange/DateTimeRange'
export default { export default {
name: 'Panel', name: 'Panel',
components: { components: {
Chart Chart,
DateTimeRange
}, },
data () { data () {
return { return {