Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor Table with Composition API and Some New Features #468

Merged
Merged
Show file tree
Hide file tree
Changes from 14 commits
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
bd986b6
feat(table): initial table
chaishi Mar 19, 2022
a6588d8
feat(table): base-table finished
chaishi Mar 19, 2022
89a472a
feat(primary-table): finished
chaishi Mar 20, 2022
f6cc38f
fix(table): affix: onFixedChange
chaishi Mar 20, 2022
dfa3c9d
feat(table): unit tests
chaishi Mar 21, 2022
f589997
Merge remote-tracking branch 'upstream/develop' into 20220319_feature…
chaishi Mar 21, 2022
07fd77f
style(table): fix lint error
chaishi Mar 21, 2022
a5b1ced
docs(tabl): bufferSize 10
chaishi Mar 21, 2022
a72eb4a
fix(table): first level tree-col ellipsis
chaishi Mar 21, 2022
6ee487a
docs(table): improve
chaishi Mar 21, 2022
2614fc6
feat(table): export refreshTable; add fullHeight
chaishi Mar 23, 2022
1601d2e
feat: merge from upstream/develop
chaishi Mar 23, 2022
db6aa1d
fix(table): 父元素为 display: none 时,也需正常渲染表格内容
chaishi Mar 23, 2022
558b180
test(table): update snapshots
chaishi Mar 23, 2022
95819e5
fix(table): global config
chaishi Mar 24, 2022
fda3d88
refactor(table): typo error
chaishi Mar 26, 2022
d12997d
refactor(table): rename, spell, test
chaishi Mar 27, 2022
0f44cf6
refactor(table): pagination
chaishi Mar 27, 2022
5c8b328
test(table): update snapshots
chaishi Mar 27, 2022
2b48157
chore(table): typo error & update base demo
chaishi Mar 27, 2022
0123796
fix(table): custom footer
chaishi Mar 27, 2022
f6a8b3a
fix(table): ts lint
chaishi Mar 28, 2022
078db4c
feat: merge from upstream/develop
chaishi Mar 28, 2022
ae6f7c1
feat(table): some feature
chaishi Mar 29, 2022
f354411
feat(table): add displayColumns and onDisplayColumnsChange
chaishi Mar 29, 2022
565be3a
feat(table): some features and bugs
chaishi Apr 2, 2022
e208307
feat(table): some features
chaishi Apr 3, 2022
0ef3a58
feat: merge from upstream/develop
chaishi Apr 3, 2022
410a40b
feat(table): drag-sort
chaishi Apr 3, 2022
75d27ab
style(calendar): typo error
chaishi Apr 3, 2022
abe043b
feat(table): drag-col-sort
chaishi Apr 3, 2022
c77497b
feat(tabl): remove dragSort=drag-col
chaishi Apr 3, 2022
9c1973f
feat(table): 全面支持表格内部文本语言配置
chaishi Apr 4, 2022
7270d78
docs(config-provder): udpate docs
chaishi Apr 5, 2022
0e5783c
feat(config-provider): global
chaishi Apr 5, 2022
9892e8c
feat(table): some features
chaishi Apr 5, 2022
cfdcd2a
fix(table): eslint error
chaishi Apr 5, 2022
b871534
fix(table): rowClassName
chaishi Apr 5, 2022
87e2a33
refactor(table): 懒加载代码整理
chaishi Apr 6, 2022
3bf96ac
feat(table): width 延时获取
chaishi Apr 6, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
192 changes: 96 additions & 96 deletions examples/config-provider/config-provider.md

Large diffs are not rendered by default.

7 changes: 5 additions & 2 deletions examples/table/demos/base.vue
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,14 @@ for (let i = 0; i < 5; i++) {

const columns = [
{
align: 'center',
width: '100',
className: 'row',
colKey: 'index',
title: '序号',
align: 'center',
className: 'custom-column-class-name',
attrs: {
'data-id': 'first-column',
},
},
{
colKey: 'platform',
Expand Down
66 changes: 66 additions & 0 deletions examples/table/demos/custom-col.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
<template>
<div class="tdesign-demo-block-column-large">
<!-- 按钮操作区域 -->
<!-- 设置哪些列允许自定义显示 :columnController="{ fields: ['platform', 'type', 'default']}" -->
<t-table
row-key="index"
:data="data"
:columns="columns"
:column-controller="{ displayType: 'fixed-width', fields: ['platform', 'type', 'default'] }"
table-layout="auto"
stripe
bordered
@column-change="onColumnChange"
></t-table>
</div>
</template>
<script setup lang="jsx">
const data = [];
for (let i = 0; i < 5; i++) {
data.push({
index: i,
platform: i % 2 === 0 ? '共有' : '私有',
type: ['String', 'Number', 'Array', 'Object'][i % 4],
default: ['-', '0', '[]', '{}'][i % 4],
detail: {
postion: `读取 ${i} 个数据的嵌套信息值`,
},
needed: i % 4 === 0 ? '是' : '否',
description: '数据源',
});
}

const columns = [
{
align: 'center',
className: 'row',
colKey: 'index',
title: '序号',
},
{
colKey: 'platform',
title: '平台',
},
{
colKey: 'type',
title: '类型',
},
{
colKey: 'default',
title: '默认值',
},
{
colKey: 'needed',
title: '是否必传',
},
{
colKey: 'detail.postion',
title: '详情信息',
ellipsis: true,
},
];

const onColumnChange = (params) => {
console.log(params);
};
</script>
74 changes: 74 additions & 0 deletions examples/table/demos/custom-footer.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
<template>
<div class="tdesign-demo-block-column-large">
<!-- rowClassName="tdesign-demo__row-custom-name" -->
<t-table row-key="index" :data="data" :columns="columns" :foot-data="footData" :row-class-name="rowClassName">
<template #t-foot-required> 插槽渲染表尾 </template>
</t-table>
</div>
</template>
<script setup lang="jsx">
const data = [];
for (let i = 0; i < 3; i++) {
data.push({
index: i,
platform: i % 2 === 0 ? '共有' : '私有',
type: ['String', 'Number', 'Array', 'Object'][i % 4],
default: ['-', '0', '[]', '{}'][i % 4],
detail: {
postion: `读取 ${i} 个数据的嵌套信息值`,
},
required: i % 4 === 0 ? '是' : '否',
description: '数据源',
});
}

// 表尾有一行数据
const footData = [{}];

const columns = [
{
align: 'center',
width: '100',
className: 'row',
colKey: 'index',
title: '序号',
foot: () => <b style="color: rgb(0, 82, 217)">表尾</b>,
},
{
width: 100,
colKey: 'platform',
title: '平台',
foot: (h, { rowIndex }) => <span>第 {rowIndex + 1} 行</span>,
},
{
colKey: 'type',
title: '类型',
foot: '-',
},
{
colKey: 'default',
title: '默认值',
foot: (h, { row }) => <span>{row.default || '空'}</span>,
},
{
colKey: 'required',
title: '是否必传',
width: 150,
// 使用插槽渲染,插槽名称为 't-foot-required'
foot: 't-foot-required',
},
{
colKey: 'detail.postion',
title: '详情信息',
width: 200,
ellipsis: true,
foot: () => <div>渲染函数输出表尾信息</div>,
},
];

// type 可选值:foot 和 body
function rowClassName({ type }) {
if (type === 'foot') return 't-tdesign__custom-footer-tr';
return 't-tdesign__custom-body-tr';
}
</script>
50 changes: 16 additions & 34 deletions examples/table/demos/data-sort.vue
Original file line number Diff line number Diff line change
Expand Up @@ -52,40 +52,17 @@ const columns = [
sortType: 'all',
sorter: (a, b) => a.survivalTime - b.survivalTime,
},
{ colKey: 'owner', title: '管理员', width: 100 },
// { colKey: 'owner', title: '管理员', width: 100 },
];

// 本地数据排序,表示组件内部会对参数 data 进行数据排序。如果 data 数据为 10 条,就仅对这 10 条数据进行排序。
const initData = [
{
id: 1,
instance: 'JQTest1',
status: 0,
owner: 'jenny;peter',
survivalTime: 1000,
},
{
id: 2,
instance: 'JQTest2',
status: 1,
owner: 'jenny',
survivalTime: 1000,
},
{
id: 3,
instance: 'JQTest3',
status: 2,
owner: 'jenny',
survivalTime: 500,
},
{
id: 4,
instance: 'JQTest4',
status: 1,
owner: 'peter',
survivalTime: 1500,
},
];
const initData = new Array(4).fill(null).map((_, i) => ({
id: i + 1,
instance: `JQTest${i + 1}`,
status: [0, 1, 2, 1][i % 3],
owner: ['jenny;peter', 'jenny', 'peter'][i % 3],
survivalTime: [1000, 1000, 500, 1500][i % 3],
}));

const data = ref([...initData]);
const sort = ref({});
Expand Down Expand Up @@ -116,14 +93,19 @@ watch(
);

const sortChange = (sortVal, options) => {
console.log('sort-change', sortVal, options);
// sort.value 和 data.value 的赋值都是必须
sort.value = sortVal;
console.log('#### sortChange:', sortVal, options);
data.value = options.currentDataSource;
};

const dataChange = (dataVal) => {
data.value = dataVal;
const dataChange = (data) => {
// 除了 sortChange,也可以在这里对 data.value 进行赋值
// data.value = data;
console.log('data-change', data);
};
</script>

<style lang="less">
:deep([class*='t-table-expandable-icon-cell']) .t-icon {
background-color: transparent;
Expand Down
Loading