Skip to content

Commit

Permalink
feat: ma-crud表格增加表头插槽,可以自定义表头了
Browse files Browse the repository at this point in the history
  • Loading branch information
kanyxmo committed Mar 1, 2024
1 parent 1bcae7c commit 6707fef
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/components/ma-crud/components/column.vue
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,9 @@
:sortable="row.sortable"
v-else
>
<template #title>
<slot :name="`tableTitle-${row.dataIndex}`">{{ row.title }}</slot>
</template>
<template #cell="{ record, column, rowIndex }">
<!-- 操作栏 -->
<template v-if="row.dataIndex === '__operation'">
Expand Down
17 changes: 17 additions & 0 deletions src/components/ma-crud/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,10 @@
<slot name="operationAfterExtend" v-bind="{ record, column, rowIndex }"></slot>
</template>

<template v-for="slot in getTitleSlot(columns)" #[slot]>
<slot :name="`${slot}`" />
</template>

<template
v-for="(slot, slotIndex) in getSlot(columns)"
:key="slotIndex"
Expand Down Expand Up @@ -420,6 +424,19 @@ const getSlot = (cls = []) => {
return sls
}

const getTitleSlot = (cls = []) => {
let sls = []
cls.map(item => {
if (item.children && item.children.length > 0) {
let tmp = getTitleSlot(item.children)
sls.push(...tmp)
} else if (item.dataIndex) {
sls.push(`tableTitle-${item.dataIndex}`)
}
})
return sls
}

const getSearchSlot = () => {
let sls = []
columns.value.map(item => {
Expand Down

0 comments on commit 6707fef

Please sign in to comment.