fuliqi
2024-01-24 29c1e7eb5ac16e90d8991a86c1c071bc312ec8d9
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
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
<template>
  <div class="data_box">
    <span class="chart_title">
      {{chartData.name}}
    </span>
    <div class="popoverStyle" >
      <el-popover placement="bottom" :title="chartData.name" width="200"
                  trigger="click">
        <span v-html="chartData.tip"></span>
        <i class="chartTip el-icon-question" slot="reference"></i>
      </el-popover>
    </div>
    <div class="chart_content">
      <div class="chart_query">
        <el-select v-model="chartData.timeType" v-show="chartData.timeType" class="query_type"
                   size="mini">
          <el-option v-for="item in dataArray" :key="item.id" :value="item.id" :label="item.name">
          </el-option>
        </el-select>
        <span class="chart_data">
          <el-date-picker v-model="chartData.time" type="daterange" align="right" unlink-panels
                          range-separator="至" start-placeholder="开始日期" end-placeholder="结束日期"
                          size="mini" value-format="yyyy-MM-dd" @change="changeTime"
                          :picker-options="pickerOptions">
          </el-date-picker>
        </span>
      </div>
      <div class="chart_box">
        <slot name="content" :data="chartData"></slot>
      </div>
    </div>
  </div>
</template>
 
<script>
export default {
  props: {
    chartData: {
      type: Object,
      default: function () {
        return {}
      }
    }
  },
  data () {
    return {
      dataArray: [
        {
          id: '1',
          name: '日'
        },
        {
          id: '2',
          name: '月'
        },
        {
          id: '3',
          name: '年'
        }
      ],
      pickerOptions: {
        shortcuts: [{
          text: '最近一周',
          onClick (picker) {
            const end = new Date()
            const start = new Date()
            start.setTime(start.getTime() - 3600 * 1000 * 24 * 7)
            end.setTime(end.getTime() - 86400000)
            picker.$emit('pick', [start, end])
          }
        }, {
          text: '最近一个月',
          onClick (picker) {
            const end = new Date()
            const start = new Date()
            start.setTime(start.getTime() - 3600 * 1000 * 24 * 30)
            end.setTime(end.getTime() - 86400000)
            picker.$emit('pick', [start, end])
          }
        }, {
          text: '最近三个月',
          onClick (picker) {
            const end = new Date()
            const start = new Date()
            start.setTime(start.getTime() - 3600 * 1000 * 24 * 90)
            end.setTime(end.getTime() - 86400000)
            picker.$emit('pick', [start, end])
          }
        }],
        disabledDate (time) {
          const end = new Date()
          return time.getTime() > end.getTime() - 86400000
        }
      }
    }
  },
  methods: {
    changeTime () {
      this.$emit('hand-date-time', this.chartData)
    }
  }
}
</script>
 
<style lang="scss">
.data_box {
  // border: 1px solid #cccccc;
  height: 100%;
  margin-right: 10px;
  .chart_title {
    font-size: 20px;
    font-weight: 400;
    // border-bottom: 1px solid #cccccc;
    padding: 10px;
    margin-bottom: 10px;
    display: inline-block;
    .chartTip {
      cursor: pointer;
      float: right;
    }
  }
  .chart_content {
    padding: 20px;
    border: 1px solid #bfbfbf;
    border-radius: 4px;
    .chart_query {
      height: 28px;
    }
    .query_type {
      .el-input {
        width: 100px;
      }
    }
    .chart_data {
      float: right;
    }
    .chart_box {
      width: 100%;
      height: 330px;
    }
    .chart_box > div {
      width: 100%;
      height: 100%;
      margin: 0 auto;
    }
  }
}
.popoverStyle{
  display: inline-block;
  .el-popper{
    overflow-y: hidden;
  }
}
</style>