-
Notifications
You must be signed in to change notification settings - Fork 363
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
34 changed files
with
752 additions
and
285 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.