Browse Source

日志管理

李宇 7 months ago
parent
commit
0bd86cd91b

File diff suppressed because it is too large
+ 74 - 0
logs/aijiuyi-admin-dev.log


+ 30 - 1
openspec/backend/src/main/java/com/aijiuyi/admin/common/service/SysLogService.java

@@ -1,10 +1,15 @@
 package com.aijiuyi.admin.common.service;
 
 import com.aijiuyi.admin.common.entity.SysLog;
+import com.aijiuyi.admin.controller.dto.SysLogQueryDTO;
+import com.baomidou.mybatisplus.core.metadata.IPage;
+
+import java.util.List;
+import java.util.Map;
 
 /**
  * 系统日志 Service 接口
- * 提供操作日志的保存功能
+ * 提供操作日志的保存、分页查询和全量导出功能
  */
 public interface SysLogService {
 
@@ -15,4 +20,28 @@ public interface SysLogService {
      * @param sysLog 操作日志对象
      */
     void saveLog(SysLog sysLog);
+
+    /**
+     * 分页查询操作日志列表
+     *
+     * @param queryDTO 查询条件
+     * @return 分页结果
+     */
+    IPage<SysLog> pageList(SysLogQueryDTO queryDTO);
+
+    /**
+     * 查询全部操作日志(用于 Excel 导出)
+     *
+     * @param queryDTO 查询条件(不含分页参数)
+     * @return 日志列表
+     */
+    List<SysLog> listAll(SysLogQueryDTO queryDTO);
+
+    /**
+     * 获取系统管理员选项列表(用于前端操作人下拉框)
+     *
+     * @return id 和 nickname/username 组成的选项列表
+     */
+    List<Map<String, Object>> getSysUserOptions();
 }
+

+ 65 - 0
openspec/backend/src/main/java/com/aijiuyi/admin/common/service/impl/SysLogServiceImpl.java

@@ -3,11 +3,22 @@ package com.aijiuyi.admin.common.service.impl;
 import com.aijiuyi.admin.common.entity.SysLog;
 import com.aijiuyi.admin.common.service.SysLogService;
 import com.aijiuyi.admin.common.util.LogUtil;
+import com.aijiuyi.admin.controller.dto.SysLogQueryDTO;
+import com.aijiuyi.admin.entity.SysUser;
 import com.aijiuyi.admin.mapper.SysLogMapper;
+import com.aijiuyi.admin.mapper.SysUserMapper;
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.scheduling.annotation.Async;
 import org.springframework.stereotype.Service;
 
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
 /**
  * 系统日志 Service 实现类
  * saveLog 方法使用 @Async 异步执行,不阻塞主请求线程
@@ -18,6 +29,9 @@ public class SysLogServiceImpl implements SysLogService {
     @Autowired
     private SysLogMapper sysLogMapper;
 
+    @Autowired
+    private SysUserMapper sysUserMapper;
+
     /**
      * 异步保存操作日志
      * 使用 asyncExecutor 线程池执行,与主请求线程解耦
@@ -34,4 +48,55 @@ public class SysLogServiceImpl implements SysLogService {
             LogUtil.error(SysLogServiceImpl.class, "操作日志保存失败: {}", e.getMessage());
         }
     }
+
+    /**
+     * 分页查询操作日志列表
+     *
+     * @param queryDTO 查询条件
+     * @return 分页结果
+     */
+    @Override
+    public IPage<SysLog> pageList(SysLogQueryDTO queryDTO) {
+        Page<SysLog> page = new Page<>(queryDTO.getPageNum(), queryDTO.getPageSize());
+        return sysLogMapper.selectLogPage(page, queryDTO);
+    }
+
+    /**
+     * 查询全部操作日志(用于 Excel 导出,不分页)
+     *
+     * @param queryDTO 查询条件
+     * @return 日志列表
+     */
+    @Override
+    public List<SysLog> listAll(SysLogQueryDTO queryDTO) {
+        return sysLogMapper.selectLogList(queryDTO);
+    }
+
+    /**
+     * 获取系统管理员选项列表(用于前端操作人下拉框)
+     * 返回所有未删除的系统用户的 id、username 和 nickname
+     *
+     * @return 选项列表,每项含 id、label(nickname 或 username)
+     */
+    @Override
+    public List<Map<String, Object>> getSysUserOptions() {
+        List<SysUser> users = sysUserMapper.selectList(
+                new LambdaQueryWrapper<SysUser>()
+                        .select(SysUser::getId, SysUser::getUsername, SysUser::getNickname)
+                        .orderByAsc(SysUser::getId)
+        );
+        List<Map<String, Object>> options = new ArrayList<>();
+        for (SysUser user : users) {
+            Map<String, Object> option = new HashMap<>();
+            option.put("id", user.getId());
+            // 优先展示昵称,无昵称则展示用户名
+            String label = (user.getNickname() != null && !user.getNickname().isEmpty())
+                    ? user.getNickname() : user.getUsername();
+            option.put("label", label);
+            option.put("username", user.getUsername());
+            options.add(option);
+        }
+        return options;
+    }
 }
+

+ 63 - 0
openspec/backend/src/main/java/com/aijiuyi/admin/controller/SysLogController.java

@@ -0,0 +1,63 @@
+package com.aijiuyi.admin.controller;
+
+import com.aijiuyi.admin.common.annotation.Log;
+import com.aijiuyi.admin.common.entity.Result;
+import com.aijiuyi.admin.common.entity.SysLog;
+import com.aijiuyi.admin.common.enums.OperationType;
+import com.aijiuyi.admin.common.service.SysLogService;
+import com.aijiuyi.admin.controller.dto.SysLogQueryDTO;
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+import java.util.List;
+import java.util.Map;
+
+/**
+ * 日志管理 Controller
+ * 提供操作日志的分页查询、全量导出和管理员选项接口
+ */
+@RestController
+@RequestMapping("/log")
+public class SysLogController {
+
+    @Autowired
+    private SysLogService sysLogService;
+
+    /**
+     * 分页查询操作日志列表
+     *
+     * @param queryDTO 查询条件(操作人、操作类型、操作模块、时间范围、分页参数)
+     * @return 分页日志列表
+     */
+    @GetMapping("/page")
+    @Log(value = "查询操作日志列表", module = "日志管理", operationType = OperationType.QUERY)
+    public Result<IPage<SysLog>> page(SysLogQueryDTO queryDTO) {
+        return Result.success(sysLogService.pageList(queryDTO));
+    }
+
+    /**
+     * 导出全部操作日志(返回全量数据供前端 Excel 导出使用)
+     *
+     * @param queryDTO 查询条件(不含分页参数)
+     * @return 日志列表
+     */
+    @GetMapping("/export")
+    @Log(value = "导出操作日志", module = "日志管理", operationType = OperationType.OTHER)
+    public Result<List<SysLog>> export(SysLogQueryDTO queryDTO) {
+        return Result.success(sysLogService.listAll(queryDTO));
+    }
+
+    /**
+     * 获取系统管理员选项列表(用于前端操作人下拉框)
+     *
+     * @return 管理员选项列表(含 id、label、username)
+     */
+    @GetMapping("/user/options")
+    @Log(value = "获取管理员选项", module = "日志管理", operationType = OperationType.QUERY)
+    public Result<List<Map<String, Object>>> getSysUserOptions() {
+        return Result.success(sysLogService.getSysUserOptions());
+    }
+}

+ 32 - 0
openspec/backend/src/main/java/com/aijiuyi/admin/controller/dto/SysLogQueryDTO.java

@@ -0,0 +1,32 @@
+package com.aijiuyi.admin.controller.dto;
+
+import lombok.Data;
+
+/**
+ * 日志查询请求参数 DTO
+ * 用于 /log/page 和 /log/export 接口的查询条件封装
+ */
+@Data
+public class SysLogQueryDTO {
+
+    /** 操作人ID(对应 sys_log.user_id) */
+    private Long userId;
+
+    /** 操作类型(查询/新增/更新/删除/其他) */
+    private String operationType;
+
+    /** 操作模块(用户管理/穴位管理/方案管理/设备管理等) */
+    private String operationModule;
+
+    /** 开始时间(格式:yyyy-MM-dd HH:mm:ss) */
+    private String startTime;
+
+    /** 结束时间(格式:yyyy-MM-dd HH:mm:ss) */
+    private String endTime;
+
+    /** 当前页(默认第1页) */
+    private Integer pageNum = 1;
+
+    /** 每页条数(默认10条) */
+    private Integer pageSize = 10;
+}

+ 23 - 0
openspec/backend/src/main/java/com/aijiuyi/admin/mapper/SysLogMapper.java

@@ -1,8 +1,14 @@
 package com.aijiuyi.admin.mapper;
 
 import com.aijiuyi.admin.common.entity.SysLog;
+import com.aijiuyi.admin.controller.dto.SysLogQueryDTO;
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import org.apache.ibatis.annotations.Mapper;
+import org.apache.ibatis.annotations.Param;
+
+import java.util.List;
 
 /**
  * 系统日志 Mapper
@@ -10,4 +16,21 @@ import org.apache.ibatis.annotations.Mapper;
  */
 @Mapper
 public interface SysLogMapper extends BaseMapper<SysLog> {
+
+    /**
+     * 分页查询操作日志(含多条件筛选)
+     *
+     * @param page 分页参数
+     * @param dto  查询条件
+     * @return 分页结果
+     */
+    IPage<SysLog> selectLogPage(Page<SysLog> page, @Param("dto") SysLogQueryDTO dto);
+
+    /**
+     * 查询全部操作日志(用于 Excel 导出)
+     *
+     * @param dto 查询条件
+     * @return 日志列表
+     */
+    List<SysLog> selectLogList(@Param("dto") SysLogQueryDTO dto);
 }

+ 7 - 0
openspec/backend/src/main/java/com/aijiuyi/admin/service/impl/SysUserServiceImpl.java

@@ -1,6 +1,7 @@
 package com.aijiuyi.admin.service.impl;
 
 import com.aijiuyi.admin.common.constant.ResultCode;
+import com.aijiuyi.admin.common.context.RequestContext;
 import com.aijiuyi.admin.common.entity.Result;
 import com.aijiuyi.admin.common.exception.BusinessException;
 import com.aijiuyi.admin.common.interceptor.TokenInterceptor;
@@ -79,6 +80,12 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
         // 将 Token 存入 Redis,3年过期
         redisUtil.set(TOKEN_REDIS_PREFIX + token, user.getId(), TOKEN_EXPIRE_SECONDS);
 
+        // 登录成功后将用户信息写入 RequestContext,供 LogAspect 正确记录操作人和类型
+        // (登录接口无 Token,拦截器不会设置,需在此手动补充)
+        RequestContext.setUserId(user.getId());
+        RequestContext.setUserName(user.getUsername());
+        RequestContext.setUserType(1);
+
         LogUtil.info(SysUserServiceImpl.class, "用户[{}]登录成功", user.getUsername());
 
         // 组装返回数据

+ 20 - 8
openspec/backend/src/main/resources/mapper/SysLogMapper.xml

@@ -4,16 +4,28 @@
 
     <!-- 基础 CRUD 由 MyBatis Plus 提供,此处定义复杂查询 -->
 
-    <!-- 按时间范围分页查询日志(示例) -->
-    <select id="selectByCondition" resultType="com.aijiuyi.admin.common.entity.SysLog">
-        SELECT * FROM sys_log
+    <!-- 公共查询条件片段 -->
+    <sql id="queryCondition">
         <where>
-            <if test="userId != null">AND user_id = #{userId}</if>
-            <if test="requestId != null and requestId != ''">AND request_id = #{requestId}</if>
-            <if test="operationType != null and operationType != ''">AND operation_type = #{operationType}</if>
-            <if test="startTime != null">AND create_time >= #{startTime}</if>
-            <if test="endTime != null">AND create_time &lt;= #{endTime}</if>
+            <if test="dto.userId != null">AND user_id = #{dto.userId}</if>
+            <if test="dto.operationType != null and dto.operationType != ''">AND operation_type = #{dto.operationType}</if>
+            <if test="dto.operationModule != null and dto.operationModule != ''">AND operation_module = #{dto.operationModule}</if>
+            <if test="dto.startTime != null and dto.startTime != ''">AND create_time >= #{dto.startTime}</if>
+            <if test="dto.endTime != null and dto.endTime != ''">AND create_time &lt;= #{dto.endTime}</if>
         </where>
+    </sql>
+
+    <!-- 分页查询操作日志(MybatisPlus 自动注入分页参数) -->
+    <select id="selectLogPage" resultType="com.aijiuyi.admin.common.entity.SysLog">
+        SELECT * FROM sys_log
+        <include refid="queryCondition"/>
+        ORDER BY create_time DESC
+    </select>
+
+    <!-- 查询全部操作日志(用于导出,不分页) -->
+    <select id="selectLogList" resultType="com.aijiuyi.admin.common.entity.SysLog">
+        SELECT * FROM sys_log
+        <include refid="queryCondition"/>
         ORDER BY create_time DESC
     </select>
 

+ 5 - 3
openspec/frontend/src/api/index.js

@@ -8,6 +8,8 @@
 // 认证模块
 export * as authApi from './auth'
 
-// 后续新增业务模块在此追加,例如:
-// export * as userApi from './user'
-// export * as orderApi from './order'
+// 用户管理模块
+export * as userApi from './user'
+
+// 日志管理模块
+export * as logApi from './log'

+ 29 - 0
openspec/frontend/src/api/log.js

@@ -0,0 +1,29 @@
+import request from '@/utils/request'
+
+/**
+ * 日志管理模块 API
+ * 对应后端 SysLogController
+ */
+
+/**
+ * 分页查询操作日志列表
+ * @param {Object} params 查询参数(userId, operationType, operationModule, startTime, endTime, pageNum, pageSize)
+ */
+export function getLogPage(params) {
+  return request.get('/log/page', { params })
+}
+
+/**
+ * 导出操作日志(全量,用于 Excel 导出)
+ * @param {Object} params 查询条件(不含分页参数)
+ */
+export function exportLog(params) {
+  return request.get('/log/export', { params })
+}
+
+/**
+ * 获取系统管理员选项列表(用于操作人下拉框)
+ */
+export function getSysUserOptions() {
+  return request.get('/log/user/options')
+}

+ 7 - 3
openspec/frontend/src/layout/index.vue

@@ -100,10 +100,14 @@ const activeMenu = computed(() => route.path)
 // 当前路由
 const currentRoute = computed(() => route)
 
-// 动态菜单(从路由配置中读取 Layout 下的子路由)
+// 动态菜单(从路由配置中读取 Layout 下的子路由,使用绝对路径避免相对路径导航问题)
 const menuRoutes = computed(() => {
-  const layoutRoute = router.getRoutes().find(r => r.path === '/')
-  return layoutRoute?.children?.filter(r => r.meta?.title) || []
+  return router.getRoutes().filter(r =>
+    r.meta?.title &&
+    r.path !== '/' &&
+    r.path !== '/login' &&
+    r.path !== '/404'
+  )
 })
 
 // 切换侧边栏折叠

+ 8 - 2
openspec/frontend/src/router/index.js

@@ -1,4 +1,4 @@
-import { createRouter, createWebHistory } from 'vue-router'
+import { createRouter, createWebHashHistory } from 'vue-router'
 import { getToken } from '@/utils/storage'
 
 /**
@@ -42,6 +42,12 @@ const routes = [
         name: 'UserDevice',
         component: () => import('@/views/user/device/index.vue'),
         meta: { requiresAuth: true, title: '设备管理', icon: 'Monitor' }
+      },
+      {
+        path: 'log',
+        name: 'Log',
+        component: () => import('@/views/log/index.vue'),
+        meta: { requiresAuth: true, title: '日志管理', icon: 'Document' }
       }
     ]
   },
@@ -59,7 +65,7 @@ const routes = [
 ]
 
 const router = createRouter({
-  history: createWebHistory(),
+  history: createWebHashHistory(),
   routes
 })
 

+ 353 - 0
openspec/frontend/src/views/log/index.vue

@@ -0,0 +1,353 @@
+<template>
+  <div class="page-container">
+    <!-- 搜索区域 -->
+    <el-card class="search-card">
+      <el-form :model="queryForm" inline>
+        <el-form-item label="操作人">
+          <el-select
+            v-model="queryForm.userId"
+            placeholder="全部"
+            clearable
+            style="width: 150px"
+          >
+            <el-option
+              v-for="item in userOptions"
+              :key="item.id"
+              :label="item.label"
+              :value="item.id"
+            />
+          </el-select>
+        </el-form-item>
+        <el-form-item label="操作类型">
+          <el-select
+            v-model="queryForm.operationType"
+            placeholder="全部"
+            clearable
+            style="width: 120px"
+          >
+            <el-option label="查询" value="查询" />
+            <el-option label="新增" value="新增" />
+            <el-option label="更新" value="更新" />
+            <el-option label="删除" value="删除" />
+            <el-option label="其他" value="其他" />
+          </el-select>
+        </el-form-item>
+        <el-form-item label="操作模块">
+          <el-select
+            v-model="queryForm.operationModule"
+            placeholder="全部"
+            clearable
+            style="width: 140px"
+          >
+            <el-option label="用户管理" value="用户管理" />
+            <el-option label="穴位管理" value="穴位管理" />
+            <el-option label="方案管理" value="方案管理" />
+            <el-option label="设备管理" value="设备管理" />
+            <el-option label="日志管理" value="日志管理" />
+            <el-option label="认证管理" value="认证管理" />
+          </el-select>
+        </el-form-item>
+        <el-form-item label="操作时间">
+          <el-date-picker
+            v-model="dateRange"
+            type="datetimerange"
+            range-separator="~"
+            start-placeholder="开始日期"
+            end-placeholder="结束日期"
+            value-format="YYYY-MM-DD HH:mm:ss"
+            style="width: 360px"
+          />
+        </el-form-item>
+        <el-form-item>
+          <el-button type="primary" :icon="Search" @click="handleSearch">搜索</el-button>
+          <el-button :icon="Refresh" @click="handleReset">重置</el-button>
+        </el-form-item>
+      </el-form>
+    </el-card>
+
+    <!-- 表格区域 -->
+    <el-card class="table-card">
+      <template #header>
+        <div class="card-header">
+          <span class="title">操作日志列表</span>
+          <ExcelExport
+            :headers="exportHeaders"
+            :fetch-data="fetchExportData"
+            file-name="操作日志"
+            button-text="导出"
+          />
+        </div>
+      </template>
+
+      <el-table :data="tableData" v-loading="loading" border stripe>
+        <el-table-column type="index" label="序号" width="60" align="center" />
+        <el-table-column prop="userName" label="操作人" width="110" />
+        <el-table-column prop="userType" label="操作人类型" width="110" align="center">
+          <template #default="{ row }">
+            <el-tag v-if="row.userType === 1" type="primary" size="small">系统管理员</el-tag>
+            <el-tag v-else-if="row.userType === 2" type="warning" size="small">App用户</el-tag>
+            <span v-else class="empty-text">—</span>
+          </template>
+        </el-table-column>
+        <el-table-column prop="operationType" label="操作类型" width="90" align="center">
+          <template #default="{ row }">
+            <el-tag :type="operationTypeTag(row.operationType)" size="small">
+              {{ row.operationType }}
+            </el-tag>
+          </template>
+        </el-table-column>
+        <el-table-column prop="operationModule" label="操作模块" width="100" align="center" />
+        <el-table-column prop="apiDesc" label="操作内容" min-width="160" show-overflow-tooltip />
+        <el-table-column prop="requestIp" label="IP地址" width="130" />
+        <el-table-column prop="requestUrl" label="请求URL" min-width="180" show-overflow-tooltip />
+        <el-table-column label="请求参数" width="90" align="center">
+          <template #default="{ row }">
+            <el-button
+              v-if="row.requestParams"
+              size="small"
+              type="primary"
+              link
+              @click="showDetail('请求参数', row.requestParams)"
+            >
+              查看
+            </el-button>
+            <span v-else class="empty-text">—</span>
+          </template>
+        </el-table-column>
+        <el-table-column label="响应结果" width="90" align="center">
+          <template #default="{ row }">
+            <el-button
+              v-if="row.requestResult"
+              size="small"
+              type="success"
+              link
+              @click="showDetail('响应结果', row.requestResult)"
+            >
+              查看
+            </el-button>
+            <span v-else class="empty-text">—</span>
+          </template>
+        </el-table-column>
+        <el-table-column prop="createTime" label="操作时间" width="170" />
+      </el-table>
+
+      <!-- 分页 -->
+      <el-pagination
+        v-model:current-page="queryForm.pageNum"
+        v-model:page-size="queryForm.pageSize"
+        :page-sizes="[10, 20, 50, 100]"
+        :total="total"
+        layout="total, sizes, prev, pager, next, jumper"
+        class="pagination"
+        @size-change="loadData"
+        @current-change="loadData"
+      />
+    </el-card>
+
+    <!-- 参数/响应详情弹窗 -->
+    <el-dialog
+      v-model="detailVisible"
+      :title="detailTitle"
+      width="640px"
+      destroy-on-close
+    >
+      <el-input
+        v-model="detailContent"
+        type="textarea"
+        :rows="16"
+        readonly
+        resize="none"
+      />
+    </el-dialog>
+  </div>
+</template>
+
+<script setup>
+import { ref, reactive, onMounted, watch } from 'vue'
+import { ElMessage } from 'element-plus'
+import { Search, Refresh } from '@element-plus/icons-vue'
+import { getLogPage, exportLog, getSysUserOptions } from '@/api/log'
+import ExcelExport from '@/components/ExcelExport.vue'
+
+// ==================== 查询表单 ====================
+const queryForm = reactive({
+  userId: null,
+  operationType: '',
+  operationModule: '',
+  startTime: '',
+  endTime: '',
+  pageNum: 1,
+  pageSize: 10
+})
+
+/** 时间范围双向绑定 */
+const dateRange = ref([])
+
+/** 监听时间范围变化,同步到查询表单 */
+watch(dateRange, (val) => {
+  queryForm.startTime = val?.[0] || ''
+  queryForm.endTime = val?.[1] || ''
+})
+
+// ==================== 表格数据 ====================
+const tableData = ref([])
+const total = ref(0)
+const loading = ref(false)
+
+/** 操作人下拉选项 */
+const userOptions = ref([])
+
+/** 加载管理员选项 */
+async function loadUserOptions() {
+  try {
+    const res = await getSysUserOptions()
+    userOptions.value = res.data || []
+  } catch {
+    // 加载失败不影响页面使用
+  }
+}
+
+/** 加载日志列表 */
+async function loadData() {
+  loading.value = true
+  try {
+    const res = await getLogPage(queryForm)
+    tableData.value = res.data?.records || []
+    total.value = res.data?.total || 0
+  } finally {
+    loading.value = false
+  }
+}
+
+function handleSearch() {
+  queryForm.pageNum = 1
+  loadData()
+}
+
+function handleReset() {
+  queryForm.userId = null
+  queryForm.operationType = ''
+  queryForm.operationModule = ''
+  queryForm.startTime = ''
+  queryForm.endTime = ''
+  dateRange.value = []
+  queryForm.pageNum = 1
+  loadData()
+}
+
+// ==================== 详情弹窗 ====================
+const detailVisible = ref(false)
+const detailTitle = ref('')
+const detailContent = ref('')
+
+/**
+ * 展示请求参数或响应结果详情(尝试格式化 JSON)
+ * @param {string} title 弹窗标题
+ * @param {string} content 内容字符串
+ */
+function showDetail(title, content) {
+  detailTitle.value = title
+  try {
+    detailContent.value = JSON.stringify(JSON.parse(content), null, 2)
+  } catch {
+    detailContent.value = content
+  }
+  detailVisible.value = true
+}
+
+// ==================== Excel 导出 ====================
+/** 导出表头配置 */
+const exportHeaders = [
+  { label: '操作人', prop: 'userName' },
+  { label: '操作人类型', prop: 'userTypeName' },
+  { label: '操作类型', prop: 'operationType' },
+  { label: '操作模块', prop: 'operationModule' },
+  { label: '操作内容', prop: 'apiDesc' },
+  { label: 'IP地址', prop: 'requestIp' },
+  { label: '请求URL', prop: 'requestUrl' },
+  { label: '请求参数', prop: 'requestParams' },
+  { label: '响应结果', prop: 'requestResult' },
+  { label: '操作时间', prop: 'createTime' }
+]
+
+/**
+ * 获取导出数据(全量,传入当前筛选条件)
+ * @returns {Promise<Array>} 日志列表
+ */
+async function fetchExportData() {
+  const params = {
+    userId: queryForm.userId,
+    operationType: queryForm.operationType,
+    operationModule: queryForm.operationModule,
+    startTime: queryForm.startTime,
+    endTime: queryForm.endTime
+  }
+  const res = await exportLog(params)
+  const list = res.data || []
+  // 补充操作人类型文字描述
+  return list.map(item => ({
+    ...item,
+    userTypeName: item.userType === 1 ? '系统管理员' : 'App用户'
+  }))
+}
+
+// ==================== 工具函数 ====================
+/**
+ * 根据操作类型返回 Element Plus Tag 颜色
+ * @param {string} type 操作类型
+ * @returns {string} tag type
+ */
+function operationTypeTag(type) {
+  const map = {
+    查询: 'info',
+    新增: 'success',
+    更新: 'warning',
+    删除: 'danger',
+    其他: ''
+  }
+  return map[type] || ''
+}
+
+onMounted(() => {
+  loadUserOptions()
+  loadData()
+})
+</script>
+
+<style lang="scss" scoped>
+.page-container {
+  display: flex;
+  flex-direction: column;
+  gap: 16px;
+}
+
+.search-card {
+  :deep(.el-card__body) {
+    padding: 16px 20px 4px;
+  }
+}
+
+.table-card {
+  .card-header {
+    display: flex;
+    align-items: center;
+    justify-content: space-between;
+
+    .title {
+      font-weight: 600;
+      font-size: 15px;
+    }
+  }
+}
+
+.empty-text {
+  color: #c0c4cc;
+  font-size: 13px;
+}
+
+.pagination {
+  margin-top: 16px;
+  justify-content: flex-end;
+}
+</style>
+

Some files were not shown because too many files changed in this diff