-
-
Notifications
You must be signed in to change notification settings - Fork 163
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
11 changed files
with
194 additions
and
58 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,3 +10,4 @@ fighting-add-component | |
scripts/** | ||
fighting-eslint-config | ||
fighting-icon | ||
start |
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 was deleted.
Oops, something went wrong.
19 changes: 0 additions & 19 deletions
19
packages/fighting-design/table/components/table-colgroup/index.vue
This file was deleted.
Oops, something went wrong.
1 change: 0 additions & 1 deletion
1
packages/fighting-design/table/components/table-colgroup/interface.ts
This file was deleted.
Oops, something went wrong.
11 changes: 0 additions & 11 deletions
11
packages/fighting-design/table/components/table-colgroup/props.ts
This file was deleted.
Oops, something went wrong.
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,153 @@ | ||
<script lang="ts" setup> | ||
import { Props } from './props' | ||
import { h } from 'vue' | ||
import { useList } from '../../_hooks' | ||
// import { FEmpty } from '../../empty' | ||
import { TableColgroupVue } from '../components' | ||
import { isFunction } from '../../_utils' | ||
import type { VNode } from 'vue' | ||
import type { | ||
TableColumns, | ||
TableRenderData, | ||
TableRenderHeader, | ||
TableRender | ||
} from './interface' | ||
defineOptions({ name: 'FTable' }) | ||
const prop = defineProps(Props) | ||
const { styles, classes } = useList(prop, 'table') | ||
/** | ||
* 处理自定义渲染内容 | ||
* | ||
* @param { Function } render 渲染函数 | ||
*/ | ||
const columnsSlotData = ( | ||
render: TableRenderData, | ||
row: Record<string, any>, | ||
column: TableColumns, | ||
index: number | ||
): VNode => { | ||
return render(h as TableRender, row, column, index) | ||
} | ||
/** | ||
* 处理自定义渲染内容 | ||
* | ||
* @param { Function } render 渲染函数 | ||
*/ | ||
const columnsSlotHeader = ( | ||
render: TableRenderHeader, | ||
item: TableColumns, | ||
index: number | ||
): VNode => { | ||
return render(h as TableRender, item, index) | ||
} | ||
/** 样式列表 */ | ||
const styleList = styles(['zebraColor', 'bgColor', 'headBgColor', 'height']) | ||
/** 类名列表 */ | ||
const classList = classes(['border', 'zebra'], 'f-table') | ||
</script> | ||
|
||
<template> | ||
<div role="table" :class="classList" :style="styleList"> | ||
<div class="f-table__container"> | ||
<!-- 内置数据驱动表格 --> | ||
<template v-if="columns || data"> | ||
<!-- 在限制高度时展示的头部 --> | ||
<header v-if="height && showHead" class="f-table__header"> | ||
<table class="f-table__table"> | ||
<table-colgroup-vue :columns="columns" /> | ||
|
||
<thead :align="align"> | ||
<tr> | ||
<th v-if="num">序号</th> | ||
<th v-for="(column, index) in columns" :key="index"> | ||
<!-- 如果是一个函数,则调用方法 --> | ||
<template v-if="isFunction(column.title)"> | ||
<component :is="columnsSlotHeader(column.title, column, index)" /> | ||
</template> | ||
|
||
<!-- 否则全部当字符串处理 --> | ||
<template v-else> | ||
{{ column.title }} | ||
</template> | ||
</th> | ||
</tr> | ||
</thead> | ||
</table> | ||
</header> | ||
|
||
<!-- 身体 --> | ||
<div class="f-table__body"> | ||
<!-- 有数据 --> | ||
<table class="f-table__table"> | ||
<table-colgroup-vue :columns="columns" /> | ||
|
||
<!-- 在没有限制高度时候展示的表头 --> | ||
<thead v-if="!height && showHead" :align="align"> | ||
<tr> | ||
<th v-if="num">序号</th> | ||
<th v-for="(column, index) in columns" :key="index"> | ||
<!-- 如果是一个函数,则调用方法 --> | ||
<template v-if="isFunction(column.title)"> | ||
<component :is="columnsSlotHeader(column.title, column, index)" /> | ||
</template> | ||
|
||
<!-- 否则全部当字符串处理 --> | ||
<template v-else> | ||
{{ column.title }} | ||
</template> | ||
</th> | ||
</tr> | ||
</thead> | ||
|
||
<!-- 主要渲染内容的表体 --> | ||
<tbody v-if="data && data.length" :align="align"> | ||
<tr v-for="(item, m) in data" :key="m"> | ||
<!-- 序号列表 --> | ||
<td v-if="num">{{ m + 1 }}</td> | ||
|
||
<!-- 主内容 --> | ||
<td v-for="(column, i) in columns" :key="i"> | ||
<!-- 如果有自定义插槽渲染 --> | ||
<template v-if="column.render"> | ||
<component :is="columnsSlotData(column.render, item, column, m)" /> | ||
</template> | ||
|
||
<!-- 普通渲染数据 --> | ||
<template v-else> | ||
<template v-if="column.key"> | ||
{{ item[column.key] }} | ||
</template> | ||
</template> | ||
</td> | ||
</tr> | ||
</tbody> | ||
|
||
<!-- 没有数据 --> | ||
<!-- <tfoot v-else> | ||
<slot> | ||
<f-empty content="暂无数据" /> | ||
</slot> | ||
</tfoot> --> | ||
|
||
<!-- 自定义也叫 --> | ||
<tfoot v-if="$slots.tfoot"> | ||
<slot name="tfoot" /> | ||
</tfoot> | ||
</table> | ||
</div> | ||
</template> | ||
|
||
<!-- 原生驱动表格 --> | ||
<table v-else> | ||
<slot /> | ||
</table> | ||
</div> | ||
</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
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