This repository has been archived by the owner on Aug 28, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 152
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* feat: 添加固定列及点击行展示详情示例 * feat: 抽离常量及类型 * feat: 抽离常量及类型 * feat: 添加右固定列 --------- Co-authored-by: LC1 <chuan.liu@linkedsmile.com>
- Loading branch information
1 parent
46280c1
commit 777980d
Showing
11 changed files
with
1,621 additions
and
1,535 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
<template> | ||
<FixedColumn/> | ||
</template> | ||
<script lang="ts" setup> | ||
import { FixedColumn } from '@vben/demo' | ||
</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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
<script lang="ts" setup> | ||
import { reactive, ref } from 'vue' | ||
import { VbenCellClick } from '../../../vbenComponents/src/table' | ||
import { getTableData } from '../apis/table' | ||
import {columns,innerColumns,innerLabels} from './schemas' | ||
import type {Data} from './schemas' | ||
const border = ref<boolean>(false) | ||
const loading = ref<boolean>(false) | ||
const striped = ref<boolean>(false) | ||
const data = reactive<Data>({ | ||
table: { | ||
items: [], | ||
total: 0, | ||
}, | ||
}) | ||
getTableData().then((res) => { | ||
console.log(res) | ||
for (let i = 0; i < 4; i++) { | ||
res.items = res.items.concat(res.items) | ||
} | ||
console.log(res) | ||
data.table = res | ||
}) | ||
const showDetails = ref<boolean>(false) | ||
let detailData = reactive<any[]>([]) | ||
const cellClickEvent: VbenCellClick = ({ row }) => { | ||
detailData = innerLabels.map((field) => { | ||
return { label: field, value: row[field] } | ||
}) | ||
showDetails.value = true | ||
} | ||
</script> | ||
<template> | ||
<div class="p-2 h-full"> | ||
<VbenTable | ||
:options="{ | ||
title: '固定列及点击行展示详情示例', | ||
pagination: true, | ||
border: border, | ||
loading: loading, | ||
stripe: striped, | ||
}" | ||
:columns="columns" | ||
:data="data.table.items" | ||
@cell-click="cellClickEvent" | ||
> | ||
<template #[item]="data" v-for="item in Object.keys($slots)" :key="item"> | ||
<slot :name="item" v-bind="data || {}"></slot> | ||
</template> | ||
</VbenTable> | ||
<VbenModal v-model:show="showDetails" title="查看详情" preset="card"> | ||
<template #default> | ||
<VbenTable | ||
border="inner" | ||
:sync-resize="showDetails" | ||
:row-config="{ isHover: true }" | ||
:data="detailData" | ||
:columns="innerColumns" | ||
/> | ||
</template> | ||
</VbenModal> | ||
</div> | ||
</template> |
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,44 @@ | ||
|
||
import { VbenColumns } from '../../../vbenComponents/src/table' | ||
|
||
|
||
export const columns: VbenColumns = [ | ||
{ field: 'userId', title: 'id', width: 100, fixed: 'left' }, | ||
{ field: 'username', title: '名称', width: 120, fixed: 'left' }, | ||
{ field: 'realname', title: '真实名称', width: 280 }, | ||
{ field: 'address', title: '地址', width: 280 }, | ||
{ field: 'startTime', title: '开始时间', width: 280 }, | ||
{ field: 'endTime', title: '结束时间', width: 280 }, | ||
{ | ||
field: 'desc', | ||
title: '备注', | ||
width: 280, | ||
fixed:'right' | ||
}, | ||
] | ||
|
||
export const innerLabels: string[] = [ | ||
'userId', | ||
'username', | ||
'realname', | ||
'address', | ||
'startTime', | ||
'endTime', | ||
'desc', | ||
] | ||
|
||
export const innerColumns: VbenColumns = [ | ||
{ field: 'label', title: 'label' }, | ||
{ field: 'value', title: 'value' }, | ||
] | ||
|
||
|
||
|
||
|
||
|
||
export interface Data { | ||
table: { | ||
items: any[] | ||
total: number | ||
} | ||
} |
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 |
---|---|---|
|
@@ -16,6 +16,7 @@ export default { | |
table: { | ||
table: 'table', | ||
basic: 'basic', | ||
fixedColumn:'fixedColumn' | ||
}, | ||
}, | ||
} |
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 |
---|---|---|
|
@@ -16,6 +16,7 @@ export default { | |
table: { | ||
table: '表格', | ||
basic: '基础表格', | ||
fixedColumn:'固定列' | ||
}, | ||
}, | ||
} |
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.