This commit is contained in:
ray
2024-08-11 12:54:03 +08:00
3 changed files with 47 additions and 4 deletions

View File

@@ -52,6 +52,8 @@ export default LogAPI;
export interface LogPageQuery extends PageQuery { export interface LogPageQuery extends PageQuery {
/** 搜索关键字 */ /** 搜索关键字 */
keywords?: string; keywords?: string;
/** 操作时间 */
createTime?: [string, string];
} }
/** /**

View File

@@ -1,6 +1,7 @@
<!-- 左侧边菜单包括左侧布局(left)顶部布局(all)混合布局(left) --> <!-- 左侧边菜单包括左侧布局(left)顶部布局(all)混合布局(left) -->
<template> <template>
<el-menu <el-menu
ref="menuRef"
:default-active="currentRoute.path" :default-active="currentRoute.path"
:collapse="!appStore.sidebar.opened" :collapse="!appStore.sidebar.opened"
:background-color="variables['menu-background']" :background-color="variables['menu-background']"
@@ -9,6 +10,8 @@
:unique-opened="false" :unique-opened="false"
:collapse-transition="false" :collapse-transition="false"
:mode="mode" :mode="mode"
@open="handleOpen"
@close="handleClose"
> >
<SidebarMenuItem <SidebarMenuItem
v-for="route in menuList" v-for="route in menuList"
@@ -25,7 +28,9 @@ import { isExternal } from "@/utils/index";
import path from "path-browserify"; import path from "path-browserify";
import variables from "@/styles/variables.module.scss"; import variables from "@/styles/variables.module.scss";
import { LayoutEnum } from "@/enums/LayoutEnum"; import { LayoutEnum } from "@/enums/LayoutEnum";
import type { MenuInstance } from "element-plus";
const menuRef = ref<MenuInstance>();
const settingsStore = useSettingsStore(); const settingsStore = useSettingsStore();
const appStore = useAppStore(); const appStore = useAppStore();
const currentRoute = useRoute(); const currentRoute = useRoute();
@@ -63,4 +68,22 @@ function resolvePath(routePath: string) {
const fullPath = path.resolve(props.basePath, routePath); const fullPath = path.resolve(props.basePath, routePath);
return fullPath; return fullPath;
} }
/**
* 修复切换到horizontal时展开的菜单显示问题切换时关闭全部菜单
*/
const menuIndexArray = ref<string[]>([]);
const handleOpen = (index: string, keyPath: string[]) => {
menuIndexArray.value.push(index);
};
const handleClose = (index: string) => {
menuIndexArray.value = menuIndexArray.value.filter((item) => item !== index);
};
watch(
() => mode.value,
() => {
if (mode.value === "horizontal") {
menuIndexArray.value.map((item: string) => menuRef.value!.close(item));
}
}
);
</script> </script>

View File

@@ -10,12 +10,28 @@
@keyup.enter="handleQuery" @keyup.enter="handleQuery"
/> />
</el-form-item> </el-form-item>
<el-form-item prop="createTime" label="操作时间">
<el-date-picker
:editable="false"
class="!w-[240px]"
v-model="queryParams.createTime"
type="daterange"
range-separator="~"
start-placeholder="开始时间"
end-placeholder="截止时间"
value-format="YYYY-MM-DD"
/>
</el-form-item>
<el-form-item> <el-form-item>
<el-button type="primary" @click="handleQuery" <el-button type="primary" @click="handleQuery">
><i-ep-search />搜索</el-button <i-ep-search />
> 搜索
<el-button @click="handleResetQuery"><i-ep-refresh />重置</el-button> </el-button>
<el-button @click="handleResetQuery">
<i-ep-refresh />
重置
</el-button>
</el-form-item> </el-form-item>
</el-form> </el-form>
</div> </div>
@@ -75,6 +91,7 @@ const queryParams = reactive<LogPageQuery>({
pageNum: 1, pageNum: 1,
pageSize: 10, pageSize: 10,
keywords: "", keywords: "",
createTime: ["", ""],
}); });
// 日志表格数据 // 日志表格数据
@@ -96,6 +113,7 @@ function handleQuery() {
function handleResetQuery() { function handleResetQuery() {
queryFormRef.value.resetFields(); queryFormRef.value.resetFields();
queryParams.pageNum = 1; queryParams.pageNum = 1;
queryParams.createTime = undefined;
handleQuery(); handleQuery();
} }