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

Table DragSort Column 列拖拽排序 #755

Merged
merged 44 commits into from
Apr 19, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
49072ba
docs(notification): 插件调用与函数式调用
Feb 11, 2022
8e5badf
Merge remote-tracking branch 'upstream/develop' into develop
Feb 14, 2022
5d3dd2a
Merge remote-tracking branch 'upstream/develop' into develop
Feb 15, 2022
df1f39a
Merge remote-tracking branch 'upstream/develop' into develop
chaishi Mar 23, 2022
e9a6f2e
Merge remote-tracking branch 'upstream/develop' into develop
chaishi Mar 28, 2022
993a2a4
Merge remote-tracking branch 'upstream/develop' into develop
chaishi Mar 29, 2022
bbe4c10
fix(table): merged cells border style
chaishi Mar 29, 2022
51a9b4b
feat: merge from upstream/develop
chaishi Mar 31, 2022
ca8b1f5
fix(table): pagination
chaishi Mar 31, 2022
4e72529
fix(table): add default width for table-layout: auto
chaishi Mar 31, 2022
88c3efb
fix(table): support ellipsis for safari browser
chaishi Mar 31, 2022
737e0ec
fix(table): add rowKey validate
chaishi Mar 31, 2022
b591bbd
fix(table): improve ellipsis
chaishi Mar 31, 2022
19e8645
feat(table): toggleExpandData
chaishi Apr 1, 2022
b3e19a3
fix(table): rowValue could be 0
chaishi Apr 1, 2022
755e6e1
docs(table): update documents
chaishi Apr 1, 2022
bcfd35c
Merge remote-tracking branch 'upstream/develop' into fix_table_pagina…
chaishi Apr 1, 2022
9f4efcc
fix(table): dragSort rowKey
chaishi Apr 1, 2022
b601793
fix(table): 去掉非必要的 col width
chaishi Apr 1, 2022
6b20a1e
fix(table): selectedRowKeys
chaishi Apr 2, 2022
df4b6de
feat: update common & update docs
chaishi Apr 2, 2022
d3a7b5a
fix(table): rowClass
chaishi Apr 2, 2022
6e595fa
docs: deprecated map-props
chaishi Apr 2, 2022
70cb448
refactor(table): code improve
chaishi Apr 3, 2022
db164f9
feat(table): add event params
chaishi Apr 3, 2022
ba2d2ff
feat: merge from upstream/develop
chaishi Apr 3, 2022
8f6baa1
refactor(table): drag-sort
chaishi Apr 3, 2022
02da661
feat(table): remove dragSort=drag-col
chaishi Apr 3, 2022
5fcbab4
feat(table): 全局配置
chaishi Apr 4, 2022
5eb1251
docs(config-provider): 添加全局配置示例
chaishi Apr 5, 2022
4ce535a
feat(config-provider): update docs
chaishi Apr 5, 2022
aed5d96
feat(table): 无内置按钮场景下的列配置
chaishi Apr 5, 2022
44b38f6
fix(table): rowClassName
chaishi Apr 5, 2022
52dd188
refactor(table): 整理懒加载代码
chaishi Apr 6, 2022
2cab141
feat: update common
chaishi Apr 6, 2022
50cdd86
feat: update common
chaishi Apr 6, 2022
837acf5
feat(table): some little things
chaishi Apr 13, 2022
2a45e9c
feat(table): some features
chaishi Apr 16, 2022
15ce240
chore: some little thing
chaishi Apr 16, 2022
02c9bc0
feat(table): column drag sort
chaishi Apr 17, 2022
d969def
fix(table): affixed header
chaishi Apr 17, 2022
b84406f
feat: merge from upstream/develop
chaishi Apr 18, 2022
eaac4e3
test(table): fix test error
chaishi Apr 18, 2022
5d571dd
feat: update common
chaishi Apr 18, 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
7 changes: 2 additions & 5 deletions examples/swiper/demos/current.vue
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,8 @@
</t-swiper-item>
</t-swiper>
<div class="tdesign-demo-block-row">
<t-button
size="small"
@click="current = current + 2 > 6 ? 0 : current + 1"
>
跳转到第 {{current + 2 >= 7 ? 1 : current + 2}} 项
<t-button size="small" @click="current = current + 2 > 6 ? 0 : current + 1">
跳转到第 {{ current + 2 >= 7 ? 1 : current + 2 }} 项
</t-button>
</div>
</div>
Expand Down
35 changes: 14 additions & 21 deletions examples/table/demos/drag-col-sort.vue
Original file line number Diff line number Diff line change
@@ -1,40 +1,31 @@
<template>
<div class="demo-container t-table-demo-sort">
<div class="item">
<!-- 拖拽排序涉及到 data 的变更,相对比较慎重,因此仅支持受控用法 -->

<t-table rowKey="id" :columns="columns" :data="data" dragSort="col" @drag-sort="onDragSort">
<template #status="{ row }">
<p class="status" :class="['', 'warning', 'unhealth'][row.status]">
{{ ['健康', '警告', '异常'][row.status] }}
<p class="status" :class="['', 'warning', 'unhealth'][row && row.status]">
{{ ['健康', '警告', '异常'][row && row.status] }}
</p>
</template>
</t-table>
</div>
</div>
</template>

<script lang="jsx">
import { MoveIcon } from 'tdesign-icons-vue';
const columns = [
{
colKey: 'drag', // 列拖拽排序必要参数
title: '排序',
// eslint-disable-next-line @typescript-eslint/no-unused-vars
cell: (h) => <MoveIcon />,
width: 80,
},
{ colKey: 'instance', title: '集群名称' },
<script>
const initialColumns = [
{ colKey: 'instance', title: '集群名称', width: 150 },
{
colKey: 'status',
title: '状态',
width: 100,
},
{
colKey: 'survivalTime',
title: '存活时间(s)',
width: 200,
},
{ colKey: 'owner', title: '管理员' },
{ colKey: 'owner', title: '管理员', width: 100 },
];
const initialData = new Array(4).fill(5).map((_, i) => ({
Expand All @@ -49,15 +40,17 @@ export default {
data() {
return {
data: [...initialData],
columns,
columns: [...initialColumns],
};
},
methods: {
onDragSort({
currentIndex, current, targetIndex, target, currentData, e,
currentIndex, current, targetIndex, target, currentData, e, sort,
}) {
console.log('交换行', currentIndex, current, targetIndex, target, currentData, e);
this.data = currentData;
console.log('重新排序', currentIndex, current, targetIndex, target, currentData, e, sort);
if (sort === 'col') {
this.columns = currentData;
}
},
},
};
Expand Down
64 changes: 64 additions & 0 deletions examples/table/demos/drag-sort-handler.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
<template>
<div class="demo-container t-table-demo-sort">
<div class="item">
<!-- 拖拽排序涉及到 data 的变更,相对比较慎重,因此仅支持受控用法 -->

<t-table rowKey="id" :columns="columns" :data="data" dragSort="row-handler" @drag-sort="onDragSort">
<template #status="{ row }">
<p class="status" :class="['', 'warning', 'unhealth'][row.status]">
{{ ['健康', '警告', '异常'][row.status] }}
</p>
</template>
</t-table>
</div>
</div>
</template>

<script lang="jsx">
import { MoveIcon } from 'tdesign-icons-vue';
const columns = [
{
colKey: 'drag', // 列拖拽排序必要参数
title: '排序',
// eslint-disable-next-line @typescript-eslint/no-unused-vars
cell: (h) => <MoveIcon />,
width: 80,
},
{ colKey: 'instance', title: '集群名称' },
{
colKey: 'status',
title: '状态',
},
{
colKey: 'survivalTime',
title: '存活时间(s)',
},
{ colKey: 'owner', title: '管理员' },
];
const initialData = new Array(4).fill(5).map((_, i) => ({
id: i + 1,
instance: `JQTest${i + 1}`,
status: [0, 1, 2, 1][i % 4],
owner: ['jenny;peter', 'jenny', 'jenny', 'peter'][i % 4],
survivalTime: [1000, 1000, 500, 1500][i % 4],
}));
export default {
data() {
return {
data: [...initialData],
columns,
};
},
methods: {
onDragSort({
currentIndex, current, targetIndex, target, currentData, e,
}) {
console.log('交换行', currentIndex, current, targetIndex, target, currentData, e);
this.data = currentData;
},
},
};
</script>
8 changes: 4 additions & 4 deletions examples/table/demos/expandable.vue
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

<div>
<t-checkbox v-model="expandOnRowClick">允许点击行之后展开/收起</t-checkbox>
<t-checkbox v-model="fixedColums" style="margin-left: 32px">固定列</t-checkbox>
<t-checkbox v-model="fixedColumns" style="margin-left: 32px">固定列</t-checkbox>
<t-checkbox v-model="emptyData" style="margin-left: 32px">空数据</t-checkbox>
</div>

Expand Down Expand Up @@ -61,7 +61,7 @@
<script lang="jsx">
import { ChevronRightIcon, ChevronRightCircleIcon } from 'tdesign-icons-vue';
const getColums = (isFixedColumn) => [
const getColumns = (isFixedColumn) => [
{ colKey: 'instance', title: '集群名称', fixed: isFixedColumn ? 'left' : '' },
{
colKey: 'status',
Expand Down Expand Up @@ -104,7 +104,7 @@ export default {
expandControl: 'true',
expandIcon: true,
expandOnRowClick: true,
fixedColums: false,
fixedColumns: false,
emptyData: false,
data,
// 有哪些 data.id 在 expandedRowKeys 中,就显示这些 id 对应的行
Expand Down Expand Up @@ -137,7 +137,7 @@ export default {
},
computed: {
columns() {
return getColums(this.fixedColums);
return getColumns(this.fixedColumns);
},
},
watch: {
Expand Down
7 changes: 4 additions & 3 deletions examples/table/demos/multi-header.vue
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,15 @@
<!-- 只要有 maxHeight,就有固定表头,无论该值是否存在 -->
<t-checkbox v-model="fixedHeader">显示固定表头</t-checkbox>
<!-- 为保证组件收益最大化,当数据量小于 `100` 时,无论虚拟滚动的配置是否存在,组件内部都不会开启虚拟滚动 -->
<t-checkbox v-model="virtualScroll">虚拟滚动</t-checkbox>
<!-- <t-checkbox v-model="virtualScroll">虚拟滚动</t-checkbox> -->
<t-checkbox v-model="fixedLeftCol">固定左侧列</t-checkbox>
<t-checkbox v-model="fixedRightCol">固定右侧列</t-checkbox>
<t-checkbox v-model="headerAffixedTop">表头吸顶</t-checkbox>
</div>

<!-- tableContentWidth 必须大于表格的外层宽度,否则请设置 width: 100% -->
<!-- 多级表头中,如果要使用固定列功能,则必须设置 colKey 和 fixed -->
<!-- :scroll="{ type: 'virtual' }" -->
<t-table
row-key="index"
:data="data"
Expand All @@ -26,15 +27,15 @@
:filterRow="() => null"
:headerAffixProps="{ offsetTop: 0 }"
:headerAffixedTop="headerAffixedTop"
:scroll="virtualScroll ? { type: 'virtual', threshold: 2, rowHeight: 48, bufferSize: 10 } : undefined"
:scroll="{ type: 'virtual' }"
@data-change="onDataChange"
@filter-change="onFilterChange"
></t-table>
</div>
</template>
<script>
const data = [];
for (let i = 0; i < 600; i++) {
for (let i = 0; i < 1000; i++) {
data.push({
index: i,
platform: i % 2 === 0 ? '共有' : '私有',
Expand Down
1 change: 1 addition & 0 deletions examples/table/demos/tree-select.vue
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ export default {
// 禁用行选中方式二:使用 checkProps 禁用行(示例代码有效,勿删)
// 这种方式禁用行选中,行文本不会变灰
checkProps: ({ row }) => ({ disabled: row.status !== 0 }),
// 自由调整宽度,如果发现元素看不见,请加大宽度
width: 20,
},
{
Expand Down
Loading