拖旺项目:聊城公交辅助决策系统
zhaoxing
2022-05-08 d5859b70023f40c195c58f81d3abcd14980cb722
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
<template>
 <div class="vc-basic-passenger-flow-time-line">
     <div class="_title-box title-box1">
        <div class="__title title-name ml20 mr20">{{ $route.query.name }}{{ $route.query.typeName }}分时段客流</div>
        <el-date-picker
            v-model="timeRange"
            type="daterange"
            style="width: 204px"
            start-placeholder="开始日期"
              end-placeholder="结束日期"
            :clearable="false"
            @change="handleTimeChange"
        >
        </el-date-picker>
    </div>
    <div style="height: 30vh">
        <Lines height="28vh" :option="option" width="100%" id="line2"></Lines>
    </div>
    
 </div>
</template>
 
<script>
import moment from "moment";
import commonEcharts from "../../common/echart/echart.vue"
import Lines from "../../echart/line"
export default {
     name: 'timeLine',
    components: { commonEcharts, Lines },
    data () {
        return {
            isShow: false,
             option: {
                title: '',
                xData: [],
                legendData: ['分时段客流'],
                unit: '',
                yData: [],
            },
            timeRange: [moment().subtract(1, 'days'), moment().subtract(1, 'days')],
            filterInfo: {
                startDate: moment().subtract(1, 'day').format("yyyy-MM-DD"),
                endDate: moment().subtract(1, 'day').format("yyyy-MM-DD")
            }
        }
    },
    computed: {
    },
    created() {
        
    },
    activated() {
        this.loadData()
    },
    methods: {
        loadData() {
            const { id, typeName, name } = this.$route.query;
            
            let url = '';
            let  params = {
                ...this.filterInfo
            }
            if(typeName == '站点') {
                url = 'getStationPassFlow';
                params.stationId = id;
 
            } else {
                url = 'getLinePassFlow';
                params.lineName = name;
            }
            this.$axios.get(this.$Interface.basicResource[url], {
                params,
            }).then((res) => {
                let seriesData = [];
                let data = [];
                this.isShow = true;
                res.data.forEach(e => {
                    data.push(e.hour);
                    seriesData.push(e.sumVolumePeople);
                });
                this.option.xData = [...data];
                this.option.yData = [ {data: seriesData}];
                this.option.legendData = [name];
            });
        },
        handleTimeChange(e) {
            if(e[0]) {
                this.filterInfo.startDate = moment(e[0]).format("yyyy-MM-DD");
                this.filterInfo.endDate = moment(e[1]).format("yyyy-MM-DD");
                this.loadData();
            }
            
        },
 
    }
}
</script>
 
<style lang="less">
    .vc-basic-passenger-flow-time-line {
        margin: 0 72px;
    }
 
</style>