|
@@ -1,3 +1,9 @@
|
|
|
|
|
+<script lang="ts">
|
|
|
|
|
+export default {
|
|
|
|
|
+ inheritAttrs: false
|
|
|
|
|
+}
|
|
|
|
|
+</script>
|
|
|
|
|
+
|
|
|
<script setup lang="ts">
|
|
<script setup lang="ts">
|
|
|
import router from '@/router'
|
|
import router from '@/router'
|
|
|
import { ElMessage, ElMessageBox, type DialogProps } from 'element-plus'
|
|
import { ElMessage, ElMessageBox, type DialogProps } from 'element-plus'
|
|
@@ -13,9 +19,9 @@ interface CRUD {
|
|
|
getRecord: Function
|
|
getRecord: Function
|
|
|
}
|
|
}
|
|
|
interface CustomTable {
|
|
interface CustomTable {
|
|
|
- showOperate: boolean
|
|
|
|
|
|
|
+ showOperate?: boolean
|
|
|
|
|
+ operateWidth?: number
|
|
|
}
|
|
}
|
|
|
-type Table = Partial<Omit<TableProps<any>, 'data'> & CustomTable>
|
|
|
|
|
|
|
|
|
|
interface Props {
|
|
interface Props {
|
|
|
crud: CRUD
|
|
crud: CRUD
|
|
@@ -23,7 +29,7 @@ interface Props {
|
|
|
selection?: boolean
|
|
selection?: boolean
|
|
|
formConfig: BasicForm | AdvancedForm
|
|
formConfig: BasicForm | AdvancedForm
|
|
|
dialogConfig?: DialogProps
|
|
dialogConfig?: DialogProps
|
|
|
- tableConfig?: Table
|
|
|
|
|
|
|
+ tableConfig?: CustomTable
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
const props = withDefaults(defineProps<Props>(), {
|
|
const props = withDefaults(defineProps<Props>(), {
|
|
@@ -62,8 +68,9 @@ const tableData = ref([])
|
|
|
const total = ref(0)
|
|
const total = ref(0)
|
|
|
const curPage = ref(1)
|
|
const curPage = ref(1)
|
|
|
const loading = ref(false)
|
|
const loading = ref(false)
|
|
|
-const tableConfig = ref<Table>({
|
|
|
|
|
|
|
+const tableConfig = ref<CustomTable>({
|
|
|
showOperate: true,
|
|
showOperate: true,
|
|
|
|
|
+ operateWidth: 120,
|
|
|
...props.tableConfig
|
|
...props.tableConfig
|
|
|
})
|
|
})
|
|
|
|
|
|
|
@@ -158,7 +165,7 @@ defineExpose({
|
|
|
|
|
|
|
|
<template>
|
|
<template>
|
|
|
<div class="flex flex-col" style="height: calc(100vh - 101px - var(--main-padding) * 2)">
|
|
<div class="flex flex-col" style="height: calc(100vh - 101px - var(--main-padding) * 2)">
|
|
|
- <el-card class="mb-4" shadow="never">
|
|
|
|
|
|
|
+ <el-card class="mb-4" shadow="never" v-if="searchList.length">
|
|
|
<el-form :inline="true">
|
|
<el-form :inline="true">
|
|
|
<el-form-item :label="item.label" v-for="(item, index) in searchList" :key="index">
|
|
<el-form-item :label="item.label" v-for="(item, index) in searchList" :key="index">
|
|
|
<form-comp :item="item" v-model="query[item.name]"></form-comp>
|
|
<form-comp :item="item" v-model="query[item.name]"></form-comp>
|
|
@@ -189,16 +196,18 @@ defineExpose({
|
|
|
<el-table
|
|
<el-table
|
|
|
class="flex-grow-1 h-full"
|
|
class="flex-grow-1 h-full"
|
|
|
:data="tableData"
|
|
:data="tableData"
|
|
|
- @selection-change="handleSelectionChange"
|
|
|
|
|
v-loading="loading"
|
|
v-loading="loading"
|
|
|
- v-bind="tableConfig"
|
|
|
|
|
|
|
+ v-bind="$attrs"
|
|
|
|
|
+ @selection-change="handleSelectionChange"
|
|
|
>
|
|
>
|
|
|
<el-table-column type="selection" width="50" v-if="selection"></el-table-column>
|
|
<el-table-column type="selection" width="50" v-if="selection"></el-table-column>
|
|
|
<slot></slot>
|
|
<slot></slot>
|
|
|
- <el-table-column fixed="right" label="操作" width="120" v-if="tableConfig?.showOperate">
|
|
|
|
|
|
|
+ <el-table-column fixed="right" label="操作" :width="tableConfig.operateWidth" v-if="tableConfig.showOperate">
|
|
|
<template #default="{ row }">
|
|
<template #default="{ row }">
|
|
|
|
|
+ <slot name="operateBefore" :row="row"></slot>
|
|
|
<el-button link type="primary" size="small" @click="handleUpdate(row)">编辑</el-button>
|
|
<el-button link type="primary" size="small" @click="handleUpdate(row)">编辑</el-button>
|
|
|
<el-button link type="danger" size="small" @click="handleDelete(row.id)">删除</el-button>
|
|
<el-button link type="danger" size="small" @click="handleDelete(row.id)">删除</el-button>
|
|
|
|
|
+ <slot name="operateAfter" :row="row"></slot>
|
|
|
</template>
|
|
</template>
|
|
|
</el-table-column>
|
|
</el-table-column>
|
|
|
</el-table>
|
|
</el-table>
|