表格
This commit is contained in:
21
src/components/table/column/index.vue
Normal file
21
src/components/table/column/index.vue
Normal file
@@ -0,0 +1,21 @@
|
||||
<script lang="ts">
|
||||
import { defineComponent, createVNode, reactive } from 'vue'
|
||||
import { ElTableColumn } from 'element-plus'
|
||||
import { uuid } from '@/utils/random'
|
||||
export default defineComponent({
|
||||
name: 'Column',
|
||||
props: {
|
||||
attr: {
|
||||
type: Object,
|
||||
required: true
|
||||
}
|
||||
},
|
||||
setup(props, { slots }) {
|
||||
const attr = reactive(props.attr)
|
||||
attr['column-key'] = attr['column-key'] ? attr['column-key'] : attr.prop || uuid()
|
||||
return () => {
|
||||
return createVNode(ElTableColumn, attr, slots.default)
|
||||
}
|
||||
}
|
||||
})
|
||||
</script>
|
||||
229
src/components/table/fieldRender/index.vue
Normal file
229
src/components/table/fieldRender/index.vue
Normal file
@@ -0,0 +1,229 @@
|
||||
<template>
|
||||
<!-- Icon -->
|
||||
<Icon class="ba-icon-dark" v-if="field.render == 'icon'" :name="fieldValue ? fieldValue : field.default ?? ''" />
|
||||
|
||||
<!-- switch -->
|
||||
<el-switch
|
||||
v-if="field.render == 'switch'"
|
||||
@change="onChangeField"
|
||||
:model-value="fieldValue.toString()"
|
||||
:loading="row.loading"
|
||||
active-value="1"
|
||||
inactive-value="0"
|
||||
/>
|
||||
|
||||
<!-- image -->
|
||||
<div v-if="field.render == 'image' && fieldValue" class="ba-render-image">
|
||||
<el-image
|
||||
:hide-on-click-modal="true"
|
||||
:preview-teleported="true"
|
||||
:preview-src-list="[fullUrl(fieldValue)]"
|
||||
:src="fullUrl(fieldValue)"
|
||||
></el-image>
|
||||
</div>
|
||||
|
||||
<!-- tag -->
|
||||
<div v-if="field.render == 'tag' && fieldValue !== ''">
|
||||
<el-tag :type="getTagType(fieldValue, field.custom)" effect="dark">
|
||||
{{ field.replaceValue ? field.replaceValue[fieldValue] : fieldValue }}
|
||||
</el-tag>
|
||||
</div>
|
||||
|
||||
<!-- datetime -->
|
||||
<div v-if="field.render == 'datetime'">
|
||||
{{ !fieldValue ? '-' : timeFormat(fieldValue, field.timeFormat ?? undefined) }}
|
||||
</div>
|
||||
|
||||
<!-- color -->
|
||||
<div v-if="field.render == 'color'">
|
||||
<div :style="{ background: fieldValue }" class="ba-render-color"></div>
|
||||
</div>
|
||||
|
||||
<!-- customTemplate 自定义模板 -->
|
||||
<div
|
||||
v-if="field.render == 'customTemplate'"
|
||||
v-html="field.customTemplate ? field.customTemplate(row, field, fieldValue, column, index) : ''"
|
||||
></div>
|
||||
|
||||
<!-- 自定义组件/函数渲染 -->
|
||||
<component
|
||||
v-if="field.render == 'customRender'"
|
||||
:is="field.customRender"
|
||||
:renderRow="row"
|
||||
:renderField="field"
|
||||
:renderValue="fieldValue"
|
||||
:renderColumn="column"
|
||||
:renderIndex="index"
|
||||
/>
|
||||
|
||||
<!-- 按钮组 -->
|
||||
<!-- 只对默认的编辑、删除、排序按钮进行鉴权,其他按钮请通过 display 属性控制按钮是否显示 -->
|
||||
<div v-if="field.render == 'buttons' && field.buttons">
|
||||
<template v-for="(btn, idx) in field.buttons" :key="idx">
|
||||
<!-- 常规按钮 -->
|
||||
<el-button
|
||||
v-if="btn.render == 'basicButton'"
|
||||
@click="onButtonClick(btn)"
|
||||
:class="btn.class"
|
||||
class="table-operate"
|
||||
:type="btn.type"
|
||||
:disabled="btn.disabled && btn.disabled(row, field)"
|
||||
v-bind="btn.attr"
|
||||
>
|
||||
<Icon :name="btn.icon" />
|
||||
<div v-if="btn.text" class="table-operate-text">{{ btn.text }}</div>
|
||||
</el-button>
|
||||
|
||||
<!-- 带提示信息的按钮 -->
|
||||
<el-tooltip
|
||||
v-if="btn.render == 'tipButton'"
|
||||
:disabled="btn.title && !btn.disabledTip ? false : true"
|
||||
:content="btn.title"
|
||||
placement="top"
|
||||
>
|
||||
<el-button
|
||||
@click="onButtonClick(btn)"
|
||||
:class="btn.class"
|
||||
class="table-operate"
|
||||
:type="btn.type"
|
||||
:disabled="btn.disabled && btn.disabled(row, field)"
|
||||
v-bind="btn.attr"
|
||||
>
|
||||
<Icon :name="btn.icon" />
|
||||
<div v-if="btn.text" class="table-operate-text">{{ btn.text }}</div>
|
||||
</el-button>
|
||||
</el-tooltip>
|
||||
|
||||
<!-- 带确认框的按钮 -->
|
||||
<el-popconfirm
|
||||
v-if="btn.render == 'confirmButton'"
|
||||
:disabled="btn.disabled && btn.disabled(row, field)"
|
||||
v-bind="btn.popconfirm"
|
||||
@confirm="onButtonClick(btn)"
|
||||
>
|
||||
<template #reference>
|
||||
<div class="ml-6">
|
||||
<el-tooltip :disabled="btn.title ? false : true" :content="btn.title" placement="top">
|
||||
<el-button
|
||||
:class="btn.class"
|
||||
class="table-operate"
|
||||
:type="btn.type"
|
||||
:disabled="btn.disabled && btn.disabled(row, field)"
|
||||
v-bind="btn.attr"
|
||||
>
|
||||
<Icon :name="btn.icon" />
|
||||
<div v-if="btn.text" class="table-operate-text">{{ btn.text }}</div>
|
||||
</el-button>
|
||||
</el-tooltip>
|
||||
</div>
|
||||
</template>
|
||||
</el-popconfirm>
|
||||
|
||||
<!-- 带提示的可拖拽按钮 -->
|
||||
<el-tooltip
|
||||
v-if="btn.render == 'moveButton' && btn.name == 'weigh-sort'"
|
||||
:disabled="btn.title && !btn.disabledTip ? false : true"
|
||||
:content="btn.title"
|
||||
placement="top"
|
||||
>
|
||||
<el-button
|
||||
:class="btn.class"
|
||||
class="table-operate move-button"
|
||||
:type="btn.type"
|
||||
:disabled="btn.disabled && btn.disabled(row, field)"
|
||||
v-bind="btn.attr"
|
||||
>
|
||||
<Icon :name="btn.icon" />
|
||||
<div v-if="btn.text" class="table-operate-text">{{ btn.text }}</div>
|
||||
</el-button>
|
||||
</el-tooltip>
|
||||
</template>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { ref, inject } from 'vue'
|
||||
import type { TagProps, TableColumnCtx } from 'element-plus'
|
||||
import type TableStoreClass from '@/utils/tableStore'
|
||||
import { fullUrl, timeFormat } from '@/utils/common'
|
||||
const TableStore = inject('tableStore') as TableStoreClass
|
||||
|
||||
interface Props {
|
||||
row: TableRow
|
||||
field: TableColumn
|
||||
column: TableColumnCtx<TableRow>
|
||||
index: number
|
||||
}
|
||||
const props = defineProps<Props>()
|
||||
|
||||
// 字段值(单元格值)
|
||||
const fieldName = ref(props.field.prop)
|
||||
const fieldValue = ref(fieldName.value ? props.row[fieldName.value] : '')
|
||||
if (fieldName.value && fieldName.value.indexOf('.') > -1) {
|
||||
let fieldNameArr = fieldName.value.split('.')
|
||||
let val: any = ref(props.row[fieldNameArr[0]])
|
||||
for (let index = 1; index < fieldNameArr.length; index++) {
|
||||
val.value = val.value ? val.value[fieldNameArr[index]] ?? '' : ''
|
||||
}
|
||||
fieldValue.value = val.value
|
||||
}
|
||||
|
||||
if (props.field.renderFormatter && typeof props.field.renderFormatter == 'function') {
|
||||
fieldValue.value = props.field.renderFormatter(props.row, props.field, fieldValue.value, props.column, props.index)
|
||||
}
|
||||
|
||||
const onChangeField = (value: any) => {
|
||||
TableStore.onTableAction('field-change', { value: value, ...props })
|
||||
}
|
||||
|
||||
const onButtonClick = (btn: OptButton) => {
|
||||
btn.click && btn.click(props.row, props.field)
|
||||
}
|
||||
|
||||
const getTagType = (value: string, custom: any): TagProps['type'] => {
|
||||
return custom && custom[value] ? custom[value] : ''
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped lang="scss">
|
||||
.m-10 {
|
||||
margin: 4px;
|
||||
}
|
||||
.ba-render-image {
|
||||
text-align: center;
|
||||
}
|
||||
.images-item {
|
||||
width: 50px;
|
||||
margin: 0 5px;
|
||||
}
|
||||
.el-image {
|
||||
height: 36px;
|
||||
width: 36px;
|
||||
}
|
||||
.table-operate-text {
|
||||
padding-left: 5px;
|
||||
}
|
||||
.table-operate {
|
||||
padding: 4px 5px;
|
||||
height: auto;
|
||||
}
|
||||
.table-operate .icon {
|
||||
font-size: 14px !important;
|
||||
color: var(--ba-bg-color-overlay) !important;
|
||||
}
|
||||
.move-button {
|
||||
cursor: move;
|
||||
}
|
||||
.ml-6 {
|
||||
display: inline-flex;
|
||||
vertical-align: middle;
|
||||
margin-left: 6px;
|
||||
}
|
||||
.ml-6 + .el-button {
|
||||
margin-left: 6px;
|
||||
}
|
||||
.ba-render-color {
|
||||
height: 25px;
|
||||
width: 100%;
|
||||
}
|
||||
</style>
|
||||
0
src/components/table/header/index.vue
Normal file
0
src/components/table/header/index.vue
Normal file
127
src/components/table/index.vue
Normal file
127
src/components/table/index.vue
Normal file
@@ -0,0 +1,127 @@
|
||||
<template>
|
||||
<el-table
|
||||
ref="tableRef"
|
||||
class="ba-data-table w100"
|
||||
header-cell-class-name="table-header-cell"
|
||||
:data="tableStore.table.data"
|
||||
:row-key="tableStore.pk"
|
||||
:border="true"
|
||||
v-loading="tableStore.table.loading"
|
||||
stripe
|
||||
@selection-change="onSelectionChange"
|
||||
v-bind="$attrs"
|
||||
>
|
||||
<!-- Column 组件内部是 el-table-column -->
|
||||
<Column
|
||||
:attr="item"
|
||||
:key="key + '-column'"
|
||||
v-for="(item, key) in tableStore.table.column"
|
||||
>
|
||||
<!-- tableStore 预设的列 render 方案 -->
|
||||
<template v-if="item.render" #default="scope">
|
||||
<FieldRender
|
||||
:field="item"
|
||||
:row="scope.row"
|
||||
:column="scope.column"
|
||||
:index="scope.$index"
|
||||
:key="
|
||||
key +
|
||||
'-' +
|
||||
scope.$index +
|
||||
'-' +
|
||||
item.render +
|
||||
'-' +
|
||||
(item.prop ? '-' + item.prop + '-' + scope.row[item.prop] : '')
|
||||
"
|
||||
/>
|
||||
</template>
|
||||
</Column>
|
||||
<slot name="columnAppend"></slot>
|
||||
</el-table>
|
||||
<div v-if="props.pagination" class="table-pagination">
|
||||
<el-pagination
|
||||
:currentPage="tableStore.table.params!.pageNum"
|
||||
:page-size="tableStore.table.params!.pageSize"
|
||||
:page-sizes="pageSizes"
|
||||
background
|
||||
:layout="config.layout.shrink ? 'prev, next, jumper' : 'sizes,total, ->, prev, pager, next, jumper'"
|
||||
:total="tableStore.table.total"
|
||||
@size-change="onTableSizeChange"
|
||||
@current-change="onTableCurrentChange"
|
||||
></el-pagination>
|
||||
</div>
|
||||
<slot name="footer"></slot>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { ref, nextTick, inject, computed } from 'vue'
|
||||
import type { ElTable, TableInstance } from 'element-plus'
|
||||
import FieldRender from '@/components/table/fieldRender/index.vue'
|
||||
import Column from '@/components/table/column/index.vue'
|
||||
import { useConfig } from '@/stores/config'
|
||||
import type TableStoreClass from '@/utils/tableStore'
|
||||
|
||||
const config = useConfig()
|
||||
const tableRef = ref<TableInstance>()
|
||||
const tableStore = inject('tableStore') as TableStoreClass
|
||||
|
||||
interface Props extends /* @vue-ignore */ Partial<InstanceType<typeof ElTable>> {
|
||||
pagination?: boolean
|
||||
}
|
||||
const props = withDefaults(defineProps<Props>(), {
|
||||
pagination: true
|
||||
})
|
||||
|
||||
const onTableSizeChange = (val: number) => {
|
||||
tableStore.onTableAction('page-size-change', { size: val })
|
||||
}
|
||||
|
||||
const onTableCurrentChange = (val: number) => {
|
||||
tableStore.onTableAction('current-page-change', { page: val })
|
||||
}
|
||||
|
||||
const pageSizes = computed(() => {
|
||||
let defaultSizes = [10, 20, 50, 100]
|
||||
if (tableStore.table.params!.pageSize) {
|
||||
if (!defaultSizes.includes(tableStore.table.params!.pageSize)) {
|
||||
defaultSizes.push(tableStore.table.params!.pageSize)
|
||||
}
|
||||
}
|
||||
return defaultSizes
|
||||
})
|
||||
|
||||
|
||||
/*
|
||||
* 记录选择的项
|
||||
*/
|
||||
const onSelectionChange = (selection: TableRow[]) => {
|
||||
tableStore.onTableAction('selection-change', selection)
|
||||
}
|
||||
|
||||
const getRef = () => {
|
||||
return tableRef.value
|
||||
}
|
||||
|
||||
defineExpose({
|
||||
getRef
|
||||
})
|
||||
</script>
|
||||
|
||||
<style scoped lang="scss">
|
||||
.ba-data-table :deep(.el-button + .el-button) {
|
||||
margin-left: 6px;
|
||||
}
|
||||
.ba-data-table :deep(.table-header-cell) .cell {
|
||||
color: var(--el-text-color-primary);
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
.table-pagination {
|
||||
box-sizing: border-box;
|
||||
width: 100%;
|
||||
max-width: 100%;
|
||||
background-color: var(--ba-bg-color-overlay);
|
||||
padding: 13px 15px;
|
||||
}
|
||||
</style>
|
||||
0
src/components/table/search/index.vue
Normal file
0
src/components/table/search/index.vue
Normal file
@@ -54,7 +54,7 @@
|
||||
<Icon
|
||||
:color="configStore.getColorVal('headerBarTabColor')"
|
||||
class="nav-menu-icon"
|
||||
name="fa fa-cogs"
|
||||
name="el-icon-Setting"
|
||||
size="18"
|
||||
/>
|
||||
</div>
|
||||
|
||||
@@ -79,6 +79,53 @@ const init = () => {
|
||||
extend: 'none'
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
'id': 2,
|
||||
'pid': 0,
|
||||
'type': 'menu_dir',
|
||||
'title': '权限管理',
|
||||
'name': 'auth',
|
||||
'path': 'auth',
|
||||
'icon': 'fa fa-group',
|
||||
'menu_type': null,
|
||||
'url': '',
|
||||
'component': '',
|
||||
'keepalive': 0,
|
||||
'extend': 'none',
|
||||
'children': [
|
||||
{
|
||||
'id': 3,
|
||||
'pid': 2,
|
||||
'type': 'menu',
|
||||
'title': '角色管理',
|
||||
'name': 'auth/role',
|
||||
'path': 'auth/role',
|
||||
'icon': 'fa fa-group',
|
||||
'menu_type': 'tab',
|
||||
'url': '',
|
||||
'component': '/src/views/auth/role.vue',
|
||||
'keepalive': 'auth/role',
|
||||
'extend': 'none',
|
||||
'children': []
|
||||
},
|
||||
{
|
||||
'id': 13,
|
||||
'pid': 2,
|
||||
'type': 'menu',
|
||||
'title': '菜单规则管理',
|
||||
'name': 'auth/menu',
|
||||
'path': 'auth/menu',
|
||||
'icon': 'el-icon-Grid',
|
||||
'menu_type': 'tab',
|
||||
'url': '',
|
||||
'component': '/src/views/auth/menu/index.vue',
|
||||
'keepalive': 'auth/menu',
|
||||
'extend': 'none',
|
||||
'children': []
|
||||
}
|
||||
|
||||
]
|
||||
}
|
||||
])
|
||||
// 预跳转到上次路径
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<div
|
||||
v-loading="true"
|
||||
element-loading-background="var(--ba-bg-color-overlay)"
|
||||
element-loading-text="$'utils.Loading'"
|
||||
element-loading-text="加载中"
|
||||
class="default-main ba-main-loading"
|
||||
></div>
|
||||
<div v-if="state.showReload" class="loading-footer">
|
||||
|
||||
@@ -63,3 +63,68 @@ export const fullUrl = (relativeUrl: string, domain = '') => {
|
||||
export function isExternal(path: string): boolean {
|
||||
return /^(https?|ftp|mailto|tel):/.test(path)
|
||||
}
|
||||
|
||||
/**
|
||||
* 全局防抖
|
||||
* 与 _.debounce 不同的是,间隔期间如果再次传递不同的函数,两个函数也只会执行一次
|
||||
* @param fn 执行函数
|
||||
* @param ms 间隔毫秒数
|
||||
*/
|
||||
export const debounce = (fn: Function, ms: number) => {
|
||||
return (...args: any[]) => {
|
||||
if (window.lazy) {
|
||||
clearTimeout(window.lazy)
|
||||
}
|
||||
window.lazy = window.setTimeout(() => {
|
||||
fn(...args)
|
||||
}, ms)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 字符串补位
|
||||
*/
|
||||
const padStart = (str: string, maxLength: number, fillString = ' ') => {
|
||||
if (str.length >= maxLength) return str
|
||||
|
||||
const fillLength = maxLength - str.length
|
||||
let times = Math.ceil(fillLength / fillString.length)
|
||||
while ((times >>= 1)) {
|
||||
fillString += fillString
|
||||
if (times === 1) {
|
||||
fillString += fillString
|
||||
}
|
||||
}
|
||||
return fillString.slice(0, fillLength) + str
|
||||
}
|
||||
|
||||
/**
|
||||
* 格式化时间戳
|
||||
* @param dateTime 时间戳
|
||||
* @param fmt 格式化方式,默认:yyyy-mm-dd hh:MM:ss
|
||||
*/
|
||||
export const timeFormat = (dateTime: string | number | null = null, fmt = 'yyyy-mm-dd hh:MM:ss') => {
|
||||
if (dateTime == 'none') return '-'
|
||||
if (!dateTime) dateTime = Number(new Date())
|
||||
if (dateTime.toString().length === 10) {
|
||||
dateTime = +dateTime * 1000
|
||||
}
|
||||
|
||||
const date = new Date(dateTime)
|
||||
let ret
|
||||
const opt: anyObj = {
|
||||
'y+': date.getFullYear().toString(), // 年
|
||||
'm+': (date.getMonth() + 1).toString(), // 月
|
||||
'd+': date.getDate().toString(), // 日
|
||||
'h+': date.getHours().toString(), // 时
|
||||
'M+': date.getMinutes().toString(), // 分
|
||||
's+': date.getSeconds().toString() // 秒
|
||||
}
|
||||
for (const k in opt) {
|
||||
ret = new RegExp('(' + k + ')').exec(fmt)
|
||||
if (ret) {
|
||||
fmt = fmt.replace(ret[1], ret[1].length == 1 ? opt[k] : padStart(opt[k], ret[1].length, '0'))
|
||||
}
|
||||
}
|
||||
return fmt
|
||||
}
|
||||
|
||||
1914
src/utils/tableStore.ts
Normal file
1914
src/utils/tableStore.ts
Normal file
File diff suppressed because it is too large
Load Diff
48
src/views/auth/menu/index.vue
Normal file
48
src/views/auth/menu/index.vue
Normal file
@@ -0,0 +1,48 @@
|
||||
<template>
|
||||
<Table ref="tableRef" :pagination="false" />
|
||||
</template>
|
||||
<script setup lang="ts">
|
||||
import { ref, onMounted, provide } from 'vue'
|
||||
import TableStore from '@/utils/tableStore'
|
||||
import Table from '@/components/table/index.vue'
|
||||
defineOptions({
|
||||
name: 'auth/menu'
|
||||
})
|
||||
const tableRef = ref()
|
||||
const tableStore = new TableStore({
|
||||
url: '/menu',
|
||||
column: [
|
||||
{ type: 'selection', align: 'center', width: '60' },
|
||||
{ label: '标题', prop: 'title', align: 'left' },
|
||||
{
|
||||
label: '图标',
|
||||
prop: 'icon',
|
||||
align: 'center',
|
||||
width: '60',
|
||||
render: 'icon',
|
||||
default: 'fa fa-circle-o'
|
||||
},
|
||||
{
|
||||
label: '操作',
|
||||
align: 'center',
|
||||
width: '130',
|
||||
render: 'buttons',
|
||||
buttons: [
|
||||
{
|
||||
name: 'edit',
|
||||
title: '编辑',
|
||||
type: 'primary',
|
||||
icon: 'el-icon-EditPen',
|
||||
render: 'tipButton'
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
})
|
||||
provide('tableStore', tableStore)
|
||||
|
||||
onMounted(() => {
|
||||
tableStore.table.ref = tableRef.value
|
||||
tableStore.index()
|
||||
})
|
||||
</script>
|
||||
0
src/views/auth/menu/popupForm.vue
Normal file
0
src/views/auth/menu/popupForm.vue
Normal file
3
src/views/auth/role.vue
Normal file
3
src/views/auth/role.vue
Normal file
@@ -0,0 +1,3 @@
|
||||
<template>
|
||||
role
|
||||
</template>
|
||||
93
types/table.d.ts
vendored
Normal file
93
types/table.d.ts
vendored
Normal file
@@ -0,0 +1,93 @@
|
||||
import Table from '@/components/table/index.vue'
|
||||
import { Component } from 'vue'
|
||||
|
||||
import type { PopconfirmProps, ButtonType, FormInstance, ButtonProps, TableColumnCtx, ColProps } from 'element-plus'
|
||||
import { Mutable } from 'element-plus/es/utils'
|
||||
|
||||
declare global {
|
||||
interface CnTable {
|
||||
ref: typeof Table | null
|
||||
data: TableRow[]
|
||||
// 表格加载状态
|
||||
loading: boolean
|
||||
// 当前选中行
|
||||
selection: TableRow[]
|
||||
// 表格列定义
|
||||
column: TableColumn[]
|
||||
// 数据总量
|
||||
total: number
|
||||
params: {
|
||||
pageNum?: number
|
||||
pageSize?: number
|
||||
[key: string]: any
|
||||
}
|
||||
}
|
||||
|
||||
/* 表格行 */
|
||||
interface TableRow extends anyObj {
|
||||
children?: TableRow[]
|
||||
}
|
||||
|
||||
/* 表格列 */
|
||||
interface TableColumn extends Partial<TableColumnCtx<TableRow>> {
|
||||
render?:
|
||||
| 'icon'
|
||||
| 'switch'
|
||||
| 'image'
|
||||
| 'tag'
|
||||
| 'datetime'
|
||||
| 'color'
|
||||
| 'buttons'
|
||||
| 'slot'
|
||||
| 'customTemplate'
|
||||
| 'customRender'
|
||||
// 默认值
|
||||
default?: any
|
||||
// 操作按钮组
|
||||
buttons?: OptButton[]
|
||||
// 自定义数据:比如渲染为Tag时,可以指定不同值时的Tag的Type属性 { open: 'success', close: 'info' }
|
||||
custom?: any
|
||||
// 值替换数据,如{open: '开'}
|
||||
replaceValue?: any
|
||||
// 时间格式化
|
||||
timeFormat?: string
|
||||
// 自定义组件/函数渲染
|
||||
customRender?: string | Component
|
||||
// 使用了 render 属性时,渲染前对字段值的预处理方法,请返回新值
|
||||
renderFormatter?: (
|
||||
row: TableRow,
|
||||
field: TableColumn,
|
||||
value: any,
|
||||
column: TableColumnCtx<TableRow>,
|
||||
index: number
|
||||
) => any
|
||||
// 自定义渲染模板,方法可返回html内容
|
||||
customTemplate?: (
|
||||
row: TableRow,
|
||||
field: TableColumn,
|
||||
value: any,
|
||||
column: TableColumnCtx<TableRow>,
|
||||
index: number
|
||||
) => string
|
||||
}
|
||||
|
||||
/* 表格右侧操作按钮 */
|
||||
interface OptButton {
|
||||
// 渲染方式:tipButton=带tip的按钮,confirmButton=带确认框的按钮,moveButton=移动按钮,basicButton=普通按钮
|
||||
render: 'tipButton' | 'confirmButton' | 'moveButton' | 'basicButton'
|
||||
name: string
|
||||
title?: string
|
||||
text?: string
|
||||
class?: string
|
||||
type: ButtonType
|
||||
icon: string
|
||||
popconfirm?: Partial<Mutable<PopconfirmProps>>
|
||||
disabledTip?: boolean
|
||||
// 自定义点击事件
|
||||
click?: (row: TableRow, field: TableColumn) => void
|
||||
// 按钮是否禁用,请返回布尔值
|
||||
disabled?: (row: TableRow, field: TableColumn) => boolean
|
||||
// 自定义el-button属性
|
||||
attr?: Partial<Mutable<ButtonProps>>
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user