0.1.6 • Published 2 years ago

u-calendar-table v0.1.6

Weekly downloads
-
License
MIT
Repository
-
Last release
2 years ago

UCalendarTable 日历表格

Table

用于展示大量结构化数据。支持按月展示月内每天的数据。

示例

基本用法

<template>
    <u-calendar-table
        first-title="姓名"
        first-field="${parent.name} (${parent.age}) [${parent.home}]"
        :data-source-parent="dateSourceParent"
        :data-source-child="dateSourceChild"
        parent-key="parent.name"
        child-key="child.name"
        start-key="child.startTime"
        first-width="160"
        width="88"
    >
        <template #default="scope">
            <p v-if="scope.item.child && scope.item.child.count">Count: {{scope.item.child.count}}</p>
            <p v-if="scope.item.child && scope.item.child.name">Name: {{scope.item.child.name}}</p>
        </template>
    </u-calendar-table>
</template>
<script>
export default {
    data() {
        return {
            dateSourceParent: {
                content: [
                    { parent: { name: '张三', age: 17, home: '浙江' } },
                    { parent: { name: '李四', age: 18, home: '浙江' } },
                    { parent: { name: '王五', age: 19, home: '浙江' } },
                    { parent: { name: '阿大', age: 20, home: '浙江' } },
                    { parent: { name: '阿二', age: 21, home: '浙江' } },
                ],
                number: 1,
                size: 20,
                totalElements: 5,
                totalPages: 1,
            },
            dateSourceChild: {
                content: [
                    { child: { name: '张三', count: 3, startTime: '2021-10-14' } },
                    { child: { name: '李四', count: 4, startTime: '2021-10-01' } },
                    { child: { name: '王五', count: 5, startTime: '2021-10-02' } },
                    { child: { name: '阿大', count: 1, startTime: '2021-10-03' } },
                    { child: { name: '阿二', count: 2, startTime: '2021-10-04' } },
                    { child: { name: '张三', count: 3, startTime: '2021-10-01' } },
                    { child: { name: '李四', count: 4, startTime: '2021-10-04' } },
                    { child: { name: '张三', count: 8, startTime: '2021-10-13' } },
                    { child: { name: '王五', count: 5, startTime: '2021-10-01' } },
                    { child: { name: '张三', count: 9, startTime: '2021-10-12' } },
                    { child: { name: '李四', count: 4, startTime: '2021-10-05' } },
                ],
                number: 1,
                size: 20,
                totalElements: 11,
                totalPages: 1,
            },
        };
    },
    methods: {},
};
</script>

API

Props/Attrs

Prop/AttrTypeOptionsDefaultDescription
data-source-parentArray\<Item> | Function | object日历表格主数据源,数组方式表示直接的数据,函数需要返回一个 Promise
data-source-childArray\<Item> | Function | object日历表格子数据源,数组方式表示直接的数据,函数需要返回一个 Promise
first-titlestring'姓名'表格第一项内容的标题
first-fieldstring'parent.name'表格第一项内容的在 data-source 中的标识
parent-keyString'parent.name'主数据源中的关键字段,用来将主/子数据源的数据关联
child-keyString'child.name'子数据源中的关键字段,用来将主/子数据源的数据关联
page-sizestring | number20每页条数
data-schemaschema日历表格中每项的数据类型
start-keystring'child.startTime'数据内表示开始时间的字段
end-keystring'child.endTime'数据内表示结束时间的字段
min-dateDate | string | number最小日期,默认 5 年前
max-dateDate | string | number最大日期,默认 4 年后
widthstring | number48表格每一项内容的宽度,默认 48 表示 '48px'
first-widthstring | number64表格首项宽度,默认 64 表示 '64px'

Slots

(default)

插入文本或 HTML 至表格项

Methods

load()

带缓存地加载

ParamTypeDefaultDescription

reload()

清除缓存,重新加载

ParamTypeDefaultDescription