|
@@ -1,16 +1,4 @@
|
|
-<!-- 📚📚📚 Pro-Table 文档: https://juejin.cn/post/7166068828202336263 -->
|
|
|
|
-
|
|
|
|
<template>
|
|
<template>
|
|
- <!-- 查询表单 -->
|
|
|
|
- <SearchForm
|
|
|
|
- v-show="isShowSearch"
|
|
|
|
- :search="_search"
|
|
|
|
- :reset="_reset"
|
|
|
|
- :columns="searchColumns"
|
|
|
|
- :search-param="searchParam"
|
|
|
|
- :search-col="searchCol"
|
|
|
|
- />
|
|
|
|
-
|
|
|
|
<!-- 表格主体 -->
|
|
<!-- 表格主体 -->
|
|
<div class="card table-main">
|
|
<div class="card table-main">
|
|
<!-- 表格头部 操作按钮 -->
|
|
<!-- 表格头部 操作按钮 -->
|
|
@@ -20,13 +8,11 @@
|
|
</div>
|
|
</div>
|
|
<div v-if="toolButton" class="header-button-ri">
|
|
<div v-if="toolButton" class="header-button-ri">
|
|
<slot name="toolButton">
|
|
<slot name="toolButton">
|
|
- <el-button v-if="showToolButton('refresh')" :icon="Refresh" circle @click="getTableList" />
|
|
|
|
- <el-button v-if="showToolButton('setting') && columns.length" :icon="Operation" circle @click="openColSetting" />
|
|
|
|
- <el-button
|
|
|
|
- v-if="showToolButton('search') && searchColumns?.length"
|
|
|
|
- :icon="Search"
|
|
|
|
- circle
|
|
|
|
- @click="isShowSearch = !isShowSearch"
|
|
|
|
|
|
+ <img
|
|
|
|
+ class="setting"
|
|
|
|
+ src="@/assets/images/setting.png"
|
|
|
|
+ v-if="showToolButton('setting') && columns.length"
|
|
|
|
+ @click="openColSetting"
|
|
/>
|
|
/>
|
|
</slot>
|
|
</slot>
|
|
</div>
|
|
</div>
|
|
@@ -110,9 +96,7 @@ import { useTable } from "@/hooks/useTable";
|
|
import { useSelection } from "@/hooks/useSelection";
|
|
import { useSelection } from "@/hooks/useSelection";
|
|
import { BreakPoint } from "@/components/Grid/interface";
|
|
import { BreakPoint } from "@/components/Grid/interface";
|
|
import { ColumnProps, TypeProps } from "@/components/ProTable/interface";
|
|
import { ColumnProps, TypeProps } from "@/components/ProTable/interface";
|
|
-import { Refresh, Operation, Search } from "@element-plus/icons-vue";
|
|
|
|
import { generateUUID, handleProp } from "@/utils";
|
|
import { generateUUID, handleProp } from "@/utils";
|
|
-import SearchForm from "@/components/SearchForm/index.vue";
|
|
|
|
import Pagination from "./components/Pagination.vue";
|
|
import Pagination from "./components/Pagination.vue";
|
|
import ColSetting from "./components/ColSetting.vue";
|
|
import ColSetting from "./components/ColSetting.vue";
|
|
import TableColumn from "./components/TableColumn.vue";
|
|
import TableColumn from "./components/TableColumn.vue";
|
|
@@ -129,7 +113,7 @@ export interface ProTableProps {
|
|
pagination?: boolean; // 是否需要分页组件 ==> 非必传(默认为true)
|
|
pagination?: boolean; // 是否需要分页组件 ==> 非必传(默认为true)
|
|
initParam?: any; // 初始化请求参数 ==> 非必传(默认为{})
|
|
initParam?: any; // 初始化请求参数 ==> 非必传(默认为{})
|
|
border?: boolean; // 是否带有纵向边框 ==> 非必传(默认为true)
|
|
border?: boolean; // 是否带有纵向边框 ==> 非必传(默认为true)
|
|
- toolButton?: ("refresh" | "setting" | "search")[] | boolean; // 是否显示表格功能按钮 ==> 非必传(默认为true)
|
|
|
|
|
|
+ toolButton?: "setting"[] | boolean; // 是否显示表格功能按钮 ==> 非必传(默认为true)
|
|
rowKey?: string; // 行数据的 Key,用来优化 Table 的渲染,当表格数据多选时,所指定的 id ==> 非必传(默认为 id)
|
|
rowKey?: string; // 行数据的 Key,用来优化 Table 的渲染,当表格数据多选时,所指定的 id ==> 非必传(默认为 id)
|
|
searchCol?: number | Record<BreakPoint, number>; // 表格搜索项 每列占比配置 ==> 非必传 { xs: 1, sm: 2, md: 2, lg: 3, xl: 4 }
|
|
searchCol?: number | Record<BreakPoint, number>; // 表格搜索项 每列占比配置 ==> 非必传 { xs: 1, sm: 2, md: 2, lg: 3, xl: 4 }
|
|
}
|
|
}
|
|
@@ -155,9 +139,6 @@ const uuid = ref("id-" + generateUUID());
|
|
// column 列类型
|
|
// column 列类型
|
|
const columnTypes: TypeProps[] = ["selection", "radio", "index", "expand", "sort"];
|
|
const columnTypes: TypeProps[] = ["selection", "radio", "index", "expand", "sort"];
|
|
|
|
|
|
-// 是否显示搜索模块
|
|
|
|
-const isShowSearch = ref(true);
|
|
|
|
-
|
|
|
|
// 控制 ToolButton 显示
|
|
// 控制 ToolButton 显示
|
|
const showToolButton = (key: "refresh" | "setting" | "search") => {
|
|
const showToolButton = (key: "refresh" | "setting" | "search") => {
|
|
return Array.isArray(props.toolButton) ? props.toolButton.includes(key) : props.toolButton;
|
|
return Array.isArray(props.toolButton) ? props.toolButton.includes(key) : props.toolButton;
|
|
@@ -274,16 +255,6 @@ const emit = defineEmits<{
|
|
dragSort: [{ newIndex?: number; oldIndex?: number }];
|
|
dragSort: [{ newIndex?: number; oldIndex?: number }];
|
|
}>();
|
|
}>();
|
|
|
|
|
|
-const _search = () => {
|
|
|
|
- search();
|
|
|
|
- emit("search");
|
|
|
|
-};
|
|
|
|
-
|
|
|
|
-const _reset = () => {
|
|
|
|
- reset();
|
|
|
|
- emit("reset");
|
|
|
|
-};
|
|
|
|
-
|
|
|
|
// 表格拖拽排序
|
|
// 表格拖拽排序
|
|
const dragSort = () => {
|
|
const dragSort = () => {
|
|
const tbody = document.querySelector(`#${uuid.value} tbody`) as HTMLElement;
|
|
const tbody = document.querySelector(`#${uuid.value} tbody`) as HTMLElement;
|
|
@@ -320,3 +291,12 @@ defineExpose({
|
|
enumMap
|
|
enumMap
|
|
});
|
|
});
|
|
</script>
|
|
</script>
|
|
|
|
+<style>
|
|
|
|
+.setting {
|
|
|
|
+ height: 20px;
|
|
|
|
+ width: 20px;
|
|
|
|
+ margin-top: 10px;
|
|
|
|
+ margin-right: 5px;
|
|
|
|
+ cursor: pointer;
|
|
|
|
+}
|
|
|
|
+</style>
|