liukangdong
2024-09-29 b2d360d9113b6955287108ca9e90d76a1f3c1419
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
<template>
  <div style="display: inline">
  <el-form-item :label="labelName|| '起止时间'" prop="startDate">
    <el-date-picker
        @change="seleTime"
        v-model="time"
        type="datetimerange"
        format="yyyy-MM-dd HH:mm:ss"
        value-format="yyyy-MM-dd HH:mm:ss"
        range-separator="至"
        start-placeholder="开始时间"
        end-placeholder="结束时间">
    </el-date-picker>
  </el-form-item>
  <el-radio-group v-model="radioVal" size="small" @input="changeRadio">
    <el-radio-button label="0">当天</el-radio-button>
    <el-radio-button label="1">近7天</el-radio-button>
    <el-radio-button label="2">近30天</el-radio-button>
  </el-radio-group>
  </div>
</template>
 
<script>
// import Bus from '@/utils/eventBus'
import {timeForMat} from "@/utils/util";
export default {
  name: 'timerRange',
  props: {
    radio: {
      type: Number,
      required: false,
      default: 0
    },
    labelName: {
      type: String,
      required: false,
      default: '起止时间'
    }
  },
  data() {
    return {
      startDate:null,
      endDate:null,
      radioVal:null,
      time: []
    }
  },
  created() {
    this.radioVal =this.radio
    this.changeRadio(this.radioVal)
  },
  methods: {
    changeRadio (e) {
      if (e === '0') {
        this.startDate = timeForMat(0)[0]
        this.endDate = timeForMat(0)[1]
        this.time = timeForMat(0)
      } else if (e === '1') {
        this.startDate = timeForMat(6)[0]
        this.endDate = timeForMat(6)[1]
        this.time = timeForMat(6)
      } else if (e === '2') {
        this.startDate = timeForMat(29)[0]
        this.endDate = timeForMat(29)[1]
        this.time = timeForMat(29)
      }
      this.callback()
    },
    seleTime (e) {
      this.startDate = e[0]
      this.endDate = e[1]
      this.radio = null
      this.callback()
    },
    callback () {
      this.$emit('callback', this.time)
    }
  }
}
</script>
 
<style lang="scss" scoped>
.tree {
    /*width: 100%;*/
    /*height: auto;*/
    /*border-radius: 5px;*/
    /*overflow: hidden;*/
    /*border: 1px solid #eeeeee;*/
    /*box-sizing: border-box;*/
    .tree_childern {
        margin-left: 20px;
    }
    .activeItem {
        background: #F4F7FC;
    }
    .tree_item {
        display: flex;
        align-items: center;
        height: 48px;
        cursor: pointer;
        padding-left: 10px;
        .tree_item_label {
            font-size: 14px;
            font-weight: 400;
            color: #333333;
            white-space: nowrap;
        }
        i {
            margin-right: 5px;
        }
        .color {
            color: #999999 !important;
        }
        .activeColor {
            color: #305ED5 !important;
        }
    }
}
</style>