|
|
@@ -1,17 +1,5 @@
|
|
|
<script lang="ts" setup>
|
|
|
-interface TableColumn<T = any> {
|
|
|
- key: string
|
|
|
- label: string
|
|
|
- fixed?: 'left' | 'right'
|
|
|
- align?: 'left' | 'center' | 'right'
|
|
|
- prop?: keyof T | string
|
|
|
- visible?: boolean
|
|
|
- sortable?: boolean
|
|
|
- minWidth?: number
|
|
|
- searchable?: boolean
|
|
|
- formatter?: (row: T) => string
|
|
|
- render?: (scope: { row: T; value: any }) => any
|
|
|
-}
|
|
|
+import { TableColumn } from './types'
|
|
|
|
|
|
const props = defineProps<{
|
|
|
data: any[]
|
|
|
@@ -23,7 +11,7 @@ const props = defineProps<{
|
|
|
pageSize?: number
|
|
|
}>()
|
|
|
|
|
|
-const { pageNo, pageSize } = toRefs(props)
|
|
|
+const { pageNo, pageSize, columns } = toRefs(props)
|
|
|
|
|
|
const emits = defineEmits(['sortfn', 'handleQuery', 'handleSizeChange', 'handleCurrentChange'])
|
|
|
</script>
|
|
|
@@ -44,7 +32,32 @@ const emits = defineEmits(['sortfn', 'handleQuery', 'handleSizeChange', 'handleC
|
|
|
:width="width"
|
|
|
scrollbar-always-on
|
|
|
border
|
|
|
- />
|
|
|
+ >
|
|
|
+ <template v-for="col in columns" :key="col.key">
|
|
|
+ <el-table-column
|
|
|
+ :align="col.align"
|
|
|
+ :fixed="col.fixed"
|
|
|
+ :label="col.label"
|
|
|
+ :prop="col.prop"
|
|
|
+ :min-width="col.minWidth"
|
|
|
+ resizable
|
|
|
+ v-if="col.children && col.children.length > 0"
|
|
|
+ >
|
|
|
+ <template v-for="child in col.children" :key="child.key">
|
|
|
+ <el-table-column
|
|
|
+ :align="child.align"
|
|
|
+ :fixed="col.fixed"
|
|
|
+ :label="col.label"
|
|
|
+ :prop="col.prop"
|
|
|
+ :min-width="col.minWidth"
|
|
|
+ resizable
|
|
|
+ >
|
|
|
+ <template #header> </template>
|
|
|
+ </el-table-column>
|
|
|
+ </template>
|
|
|
+ </el-table-column>
|
|
|
+ </template>
|
|
|
+ </el-table>
|
|
|
</template>
|
|
|
</el-auto-resizer>
|
|
|
</div>
|