深色模式
SortTable 排序表格
拖拽排序表格,对 s-table 进行了二次封装,提供了拖拽排序功能。
基本用法
点击查看代码
vue
<template>
<s-sort-table :columns="tableColumns" v-model:dataSource="tableData" border></s-sort-table>
</template>
<script setup lang="ts">
import { ref, reactive } from "vue";
const tableColumns = reactive([
{ prop: "name", label: "姓名" },
{ prop: "phone", label: "电话" },
{ prop: "date", label: "日期" }
]);
const tableData = ref([
{ id: "111", name: "张三", phone: "17611111111", date: "2024-07-01" },
{ id: "222", name: "李四", phone: "17622222222", date: "2024-07-02" },
{ id: "333", name: "王五", phone: "17633333333", date: "2024-07-03" }
]);
</script>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
数据选择
点击查看代码
vue
<template>
<s-form labelWidth="120px" showColon>
<s-form-item label="选择器类型">
<el-radio-group v-model="selectionType">
<el-radio value="checkbox">多选</el-radio>
<el-radio value="radio">单选</el-radio>
</el-radio-group>
</s-form-item>
</s-form>
<s-sort-table :columns="tableColumns" v-model:dataSource="tableData" :selection="selection" border></s-sort-table>
</template>
<script setup lang="ts">
import { ref, reactive, computed } from "vue";
const selectionType = ref("checkbox");
const selectedRows = ref([]);
const selectedRowKeys = ref([]);
const tableColumns = reactive([
{ prop: "name", label: "姓名" },
{ prop: "phone", label: "电话" },
{ prop: "date", label: "日期" }
]);
const tableData = ref([
{ id: "111", name: "张三", phone: "17611111111", date: "2024-07-01" },
{ id: "222", name: "李四", phone: "17622222222", date: "2024-07-02" },
{ id: "333", name: "王五", phone: "17633333333", date: "2024-07-03" }
]);
const selection = computed(() => {
return {
type: selectionType.value,
selectedRows: selectedRows.value,
selectedRowKeys: selectedRowKeys.value,
onChange: (record: Record<string, any>) => {
selectedRows.value = record.selectedRows;
selectedRowKeys.value = record.selectedRowKeys;
}
};
});
</script>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
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
固定列
点击查看代码
vue
<template>
<s-sort-table :columns="tableColumns" v-model:dataSource="tableData" border></s-sort-table>
</template>
<script setup lang="ts">
import { ref, reactive } from "vue";
const tableColumns = reactive([
{ prop: "name", label: "姓名", width: "300px", fixed: true },
{ prop: "phone", label: "电话", width: "600px" },
{ prop: "date", label: "日期", width: "600px" }
]);
const tableData = ref([
{ id: "111", name: "张三", phone: "17611111111", date: "2024-07-01" },
{ id: "222", name: "李四", phone: "17622222222", date: "2024-07-02" },
{ id: "333", name: "王五", phone: "17633333333", date: "2024-07-03" }
]);
</script>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19