chartPage.san 2.0 KB
Newer Older
B
BingBlog 已提交
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
<template>
    <div class="visaul-dl-chart-page">
        <ui-expand-panel title="{{title}}">
            <div class="visaul-dl-chart-box">
                <ui-chart
                    san-for="tag in filteredTagList"
                    tagInfo="{{tag}}"
                    config="{{config}}"
                    runsItems="{{runsItems}}"
                ></ui-chart>
            </div>
            <ui-pagination
                san-if="total > pageSize"
                on-pageChange="handlePageChange($event)"
                current="{{currentPage}}"
                pageSize="{{pageSize}}"
                total="{{total}}"
                showSizeChanger="{{false}}"
            />
        </ui-expand-panel>
    </div>
</template>
<script>
import ExpandPanel from '../../common/ui/ExpandPanel';
import chart from '../../common/ui/Charts/chart';
import Pagination from 'san-mui/Pagination';

export default {
    components: {
        'ui-chart': chart,
        'ui-expand-panel': ExpandPanel,
        'ui-pagination': Pagination
    },
    computed: {
        filteredTagList() {
            let tagList = this.data.get('tagList') || [];
            let currentPage = this.data.get('currentPage');
            let pageSize = this.data.get('pageSize');
            return tagList.slice((currentPage - 1) * pageSize, currentPage * pageSize);
        },
        total() {
            let tagList = this.data.get('tagList') || [];
            return tagList.length;
        }
    },
    initData() {
        return {
            // current page
            currentPage: 1,
            // item per page
            pageSize: 8
        };
    },

    handlePageChange({pageNum}) {
        this.data.set('currentPage', pageNum);
    }
};
</script>
<style lang="stylus">
@import '../../style/variables';

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