qinxianzhangyao
2023-11-17 1397987a02dd4896bb2286f8eb1d787ee5663194
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
<template>
    <div>
        <el-form :model="queryParams" ref="tableList" :inline="true" label-width="76px" style="margin: 10px 10px">
            <el-form-item label="体检时间" prop="date">
                <el-date-picker v-model="value1" type="date" placeholder="选择日期">
                </el-date-picker>
            </el-form-item>
            <el-form-item>
                <el-button type="primary" @click="submitForm">搜索</el-button>
            </el-form-item>
        </el-form>
 
        <div class="data-view">
            <div id="main"></div>
        </div>
    </div>
</template>
    
        
<script>
import { GetChartByDate } from "@/api/count/chart";
const echarts = require("echarts/lib/echarts");
require("echarts/lib/component/title");
require("echarts/lib/component/tooltip");
require("echarts/lib/component/legend");
require("echarts/lib/chart/pie");
 
export default {
    name: "chart",
    data() {
        return {
            pickerOptions: {
                shortcuts: [{
                    text: '最近一周',
                    onClick(picker) {
                        const end = new Date();
                        const start = new Date();
                        start.setTime(start.getTime() - 3600 * 1000 * 24 * 7);
                        picker.$emit('pick', [start, end]);
                    }
                }, {
                    text: '最近一个月',
                    onClick(picker) {
                        const end = new Date();
                        const start = new Date();
                        start.setTime(start.getTime() - 3600 * 1000 * 24 * 30);
                        picker.$emit('pick', [start, end]);
                    }
                }, {
                    text: '最近三个月',
                    onClick(picker) {
                        const end = new Date();
                        const start = new Date();
                        start.setTime(start.getTime() - 3600 * 1000 * 24 * 90);
                        picker.$emit('pick', [start, end]);
                    }
                }]
            },
            value1: "",
            DateList: [],
            startTime: "",
            dateAll: [],
            queryParams: {
                date: null,
                startDate: null,
                endDate: null,
            },
        };
    },
 
 
    methods: {
        getList() {
            this.queryParams.startDate = this.startTime[0];
            this.queryParams.endDate = this.startTime[1];
            let myChart = this.$echarts.init(document.getElementById("main"));
            //你进入页面先把图表渲染了  然后才获取的数据把
            myChart.setOption({
                color: ['#5470c6'],
                legend: {},
                tooltip: {},
                xAxis: {
                    type: 'category',
                    data: ['体检人数', '男生数量', '女生数量', '收入', '个检人数', '单位体检人数']
                },
                yAxis: {
                    type: 'value'
                },
                series: [
                    {
                        data: [120, 80, 40, {
                            value: 380,
                            itemStyle: {
                                color: '#a90000'
                            }
                        }, 100, 200],
                        type: 'bar'
                    }
                ]
            });
 
        },
        // 时间
        dateChangebirthday1(val) {
            this.startTime = val;
        },
 
        // 搜索
        submitForm() {
            this.queryParams.pageNum = 1;
            this.getList();
        },
    },
 
    mounted() {
        this.getList();
    },
};
</script>
<style>
.data-view {
    margin: 5px 15px;
    height: 580px;
}
 
#main {
    padding: 10px;
    height: 580px;
    background-color: #fff;
}
</style>