mirror of
https://github.com/cool-team-official/cool-admin-vue.git
synced 2025-12-11 13:02:49 +00:00
44 lines
1.0 KiB
TypeScript
44 lines
1.0 KiB
TypeScript
import { inject, reactive, ref } from "vue";
|
|
import { useConfig } from "../../../hooks";
|
|
import { getValue, mergeConfig } from "../../../utils";
|
|
import { ElTable } from "element-plus";
|
|
|
|
export function useTable(props: any) {
|
|
const { style } = useConfig();
|
|
|
|
const Table = ref<InstanceType<typeof ElTable>>();
|
|
|
|
// 配置
|
|
const config = reactive<ClTable.Config>(mergeConfig(props, inject("useTable__options") || {}));
|
|
|
|
// 列表项动态处理
|
|
config.columns = (config.columns || []).map((e) => getValue(e));
|
|
|
|
// 自动高度
|
|
config.autoHeight = config.autoHeight ?? style.table.autoHeight;
|
|
|
|
// 右键菜单
|
|
config.contextMenu = config.contextMenu ?? style.table.contextMenu;
|
|
|
|
// 事件
|
|
if (!config.on) {
|
|
config.on = {};
|
|
}
|
|
|
|
// 参数
|
|
if (!config.props) {
|
|
config.props = {};
|
|
}
|
|
|
|
return { Table, config };
|
|
}
|
|
|
|
export * from "./data";
|
|
export * from "./height";
|
|
export * from "./op";
|
|
export * from "./render";
|
|
export * from "./row";
|
|
export * from "./selection";
|
|
export * from "./sort";
|
|
export * from "./header";
|