ChartPage.vue 2.5 KB
Newer Older
J
Jeff Wang 已提交
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
<template>
    <div class="visual-dl-chart-page">
        <ui-expand-panel :info="tagList.length" :title="title">
            <div ref="chartPageBox" class="visual-dl-chart-page-box">
                <ui-chart
                    v-for="(tagInfo, index) in filteredTagList"
                    :key="index"
                    :tagInfo="tagInfo"
                    :groupNameReg="config.groupNameReg"
                    :smoothing="config.smoothing"
                    :horizontal="config.horizontal"
                    :sortingMethod="config.sortingMethod"
                    :downloadLink="config.downloadLink"
                    :outlier="config.outlier"
                    :runs="config.runs"
                    :running="config.running"
                    :runsItems="runsItems"
                ></ui-chart>
            </div>
            <v-pagination
                v-if="total > pageSize"
                v-model="currentPage"
                :length="pageLength"
            />
        </ui-expand-panel>
    </div>
</template>
<script>
import ExpandPanel from '../../common/component/ExpandPanel';
import Chart from './Chart';
// import Pagination from 'san-mui/Pagination';

import {cloneDeep} from 'lodash';

export default {
    components: {
        'ui-chart': Chart,
        'ui-expand-panel': ExpandPanel,
        // 'ui-pagination': Pagination
    },
    props: ['config', 'runsItems', 'tagList', 'title'],
    computed: {
        filteredRunsList() {
            let tagList = this.tagList || [];
            let runs = this.config.runs || [];
            let list = cloneDeep(tagList);
            return list.slice().map(item => {
                item.tagList = item.tagList.filter(one => runs.includes(one.run));
                return item;
            });
        },
        filteredTagList() {
            let tagList = this.filteredRunsList || [];
            return  tagList.slice((this.currentPage - 1) * this.pageSize, this.currentPage * this.pageSize);
        },
        total() {
            let tagList = this.tagList || [];
            return tagList.length;
        },
        pageLength() {
            return Math.ceil(this.total / this.pageSize)
        }
    },
    data() {
        return {
            // current page
            currentPage: 1,
            // item per page
            pageSize: 8
        };
    }
};
</script>
<style lang="stylus">
@import '~style/variables';

+prefix-classes('visual-dl-')
    .chart-page
        .chart-page-box:after
            content: "";
            clear: both;
            display: block;
</style>