From a1d7e81859f554f3a53680cc35f0f49bf1f77098 Mon Sep 17 00:00:00 2001
From: wwf <1971391498@qq.com>
Date: 星期四, 14 五月 2026 14:37:02 +0800
Subject: [PATCH] 导入项目

---
 src/views/infra/apiAccessLog/index.vue |  226 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 226 insertions(+), 0 deletions(-)

diff --git a/src/views/infra/apiAccessLog/index.vue b/src/views/infra/apiAccessLog/index.vue
new file mode 100644
index 0000000..570f579
--- /dev/null
+++ b/src/views/infra/apiAccessLog/index.vue
@@ -0,0 +1,226 @@
+<template>
+  <doc-alert title="绯荤粺鏃ュ織" url="https://doc.iocoder.cn/system-log/" />
+
+  <ContentWrap>
+    <!-- 鎼滅储宸ヤ綔鏍� -->
+    <el-form
+      class="-mb-15px"
+      :model="queryParams"
+      ref="queryFormRef"
+      :inline="true"
+      label-width="68px"
+    >
+      <el-form-item label="鐢ㄦ埛缂栧彿" prop="userId">
+        <el-input
+          v-model="queryParams.userId"
+          placeholder="璇疯緭鍏ョ敤鎴风紪鍙�"
+          clearable
+          @keyup.enter="handleQuery"
+          class="!w-240px"
+        />
+      </el-form-item>
+      <el-form-item label="鐢ㄦ埛绫诲瀷" prop="userType">
+        <el-select
+          v-model="queryParams.userType"
+          placeholder="璇烽�夋嫨鐢ㄦ埛绫诲瀷"
+          clearable
+          class="!w-240px"
+        >
+          <el-option
+            v-for="dict in getIntDictOptions(DICT_TYPE.USER_TYPE)"
+            :key="dict.value"
+            :label="dict.label"
+            :value="dict.value"
+          />
+        </el-select>
+      </el-form-item>
+      <el-form-item label="搴旂敤鍚�" prop="applicationName">
+        <el-input
+          v-model="queryParams.applicationName"
+          placeholder="璇疯緭鍏ュ簲鐢ㄥ悕"
+          clearable
+          @keyup.enter="handleQuery"
+          class="!w-240px"
+        />
+      </el-form-item>
+      <el-form-item label="璇锋眰鏃堕棿" prop="beginTime">
+        <el-date-picker
+          v-model="queryParams.beginTime"
+          value-format="YYYY-MM-DD HH:mm:ss"
+          type="daterange"
+          start-placeholder="寮�濮嬫棩鏈�"
+          end-placeholder="缁撴潫鏃ユ湡"
+          :default-time="[new Date('1 00:00:00'), new Date('1 23:59:59')]"
+          class="!w-240px"
+        />
+      </el-form-item>
+      <el-form-item label="鎵ц鏃堕暱" prop="duration">
+        <el-input
+          v-model="queryParams.duration"
+          placeholder="璇疯緭鍏ユ墽琛屾椂闀�"
+          clearable
+          @keyup.enter="handleQuery"
+          class="!w-240px"
+        />
+      </el-form-item>
+      <el-form-item label="缁撴灉鐮�" prop="resultCode">
+        <el-input
+          v-model="queryParams.resultCode"
+          placeholder="璇疯緭鍏ョ粨鏋滅爜"
+          clearable
+          @keyup.enter="handleQuery"
+          class="!w-240px"
+        />
+      </el-form-item>
+      <el-form-item>
+        <el-button @click="handleQuery"><Icon icon="ep:search" class="mr-5px" /> 鎼滅储</el-button>
+        <el-button @click="resetQuery"><Icon icon="ep:refresh" class="mr-5px" /> 閲嶇疆</el-button>
+        <el-button
+          type="success"
+          plain
+          @click="handleExport"
+          :loading="exportLoading"
+          v-hasPermi="['infra:api-access-log:export']"
+        >
+          <Icon icon="ep:download" class="mr-5px" /> 瀵煎嚭
+        </el-button>
+      </el-form-item>
+    </el-form>
+  </ContentWrap>
+
+  <!-- 鍒楄〃 -->
+  <ContentWrap>
+    <el-table v-loading="loading" :data="list">
+      <el-table-column label="鏃ュ織缂栧彿" align="center" prop="id" width="100" fix="right" />
+      <el-table-column label="鐢ㄦ埛缂栧彿" align="center" prop="userId" />
+      <el-table-column label="鐢ㄦ埛绫诲瀷" align="center" prop="userType">
+        <template #default="scope">
+          <dict-tag :type="DICT_TYPE.USER_TYPE" :value="scope.row.userType" />
+        </template>
+      </el-table-column>
+      <el-table-column label="搴旂敤鍚�" align="center" prop="applicationName" width="150" />
+      <el-table-column label="璇锋眰鏂规硶" align="center" prop="requestMethod" width="80" />
+      <el-table-column label="璇锋眰鍦板潃" align="center" prop="requestUrl" width="500" />
+      <el-table-column label="璇锋眰鏃堕棿" align="center" prop="beginTime" width="180">
+        <template #default="scope">
+          <span>{{ formatDate(scope.row.beginTime) }}</span>
+        </template>
+      </el-table-column>
+      <el-table-column label="鎵ц鏃堕暱" align="center" prop="duration" width="180">
+        <template #default="scope"> {{ scope.row.duration }} ms </template>
+      </el-table-column>
+      <el-table-column label="鎿嶄綔缁撴灉" align="center" prop="status">
+        <template #default="scope">
+          {{ scope.row.resultCode === 0 ? '鎴愬姛' : '澶辫触(' + scope.row.resultMsg + ')' }}
+        </template>
+      </el-table-column>
+      <el-table-column label="鎿嶄綔妯″潡" align="center" prop="operateModule" width="180" />
+      <el-table-column label="鎿嶄綔鍚�" align="center" prop="operateName" width="180" />
+      <el-table-column label="鎿嶄綔绫诲瀷" align="center" prop="operateType">
+        <template #default="scope">
+          <dict-tag :type="DICT_TYPE.INFRA_OPERATE_TYPE" :value="scope.row.operateType" />
+        </template>
+      </el-table-column>
+      <el-table-column label="鎿嶄綔" align="center" fixed="right" width="60">
+        <template #default="scope">
+          <el-button
+            link
+            type="primary"
+            @click="openDetail(scope.row)"
+            v-hasPermi="['infra:api-access-log:query']"
+          >
+            璇︾粏
+          </el-button>
+        </template>
+      </el-table-column>
+    </el-table>
+    <!-- 鍒嗛〉缁勪欢 -->
+    <Pagination
+      :total="total"
+      v-model:page="queryParams.pageNo"
+      v-model:limit="queryParams.pageSize"
+      @pagination="getList"
+    />
+  </ContentWrap>
+
+  <!-- 琛ㄥ崟寮圭獥锛氳鎯� -->
+  <ApiAccessLogDetail ref="detailRef" />
+</template>
+<script lang="ts" setup>
+import { DICT_TYPE, getIntDictOptions } from '@/utils/dict'
+import download from '@/utils/download'
+import { formatDate } from '@/utils/formatTime'
+import * as ApiAccessLogApi from '@/api/infra/apiAccessLog'
+import ApiAccessLogDetail from './ApiAccessLogDetail.vue'
+
+defineOptions({ name: 'InfraApiAccessLog' })
+
+const message = useMessage() // 娑堟伅寮圭獥
+
+const loading = ref(true) // 鍒楄〃鐨勫姞杞戒腑
+const total = ref(0) // 鍒楄〃鐨勬�婚〉鏁�
+const list = ref([]) // 鍒楄〃鐨勬暟鎹�
+const queryParams = reactive({
+  pageNo: 1,
+  pageSize: 10,
+  userId: null,
+  userType: null,
+  applicationName: null,
+  requestUrl: null,
+  duration: null,
+  resultCode: null,
+  beginTime: []
+})
+const queryFormRef = ref() // 鎼滅储鐨勮〃鍗�
+const exportLoading = ref(false) // 瀵煎嚭鐨勫姞杞戒腑
+
+/** 鏌ヨ鍒楄〃 */
+const getList = async () => {
+  loading.value = true
+  try {
+    const data = await ApiAccessLogApi.getApiAccessLogPage(queryParams)
+    list.value = data.list
+    total.value = data.total
+  } finally {
+    loading.value = false
+  }
+}
+
+/** 鎼滅储鎸夐挳鎿嶄綔 */
+const handleQuery = () => {
+  queryParams.pageNo = 1
+  getList()
+}
+
+/** 閲嶇疆鎸夐挳鎿嶄綔 */
+const resetQuery = () => {
+  queryFormRef.value.resetFields()
+  handleQuery()
+}
+
+/** 璇︽儏鎿嶄綔 */
+const detailRef = ref()
+const openDetail = (data: ApiAccessLogApi.ApiAccessLogVO) => {
+  detailRef.value.open(data)
+}
+
+/** 瀵煎嚭鎸夐挳鎿嶄綔 */
+const handleExport = async () => {
+  try {
+    // 瀵煎嚭鐨勪簩娆$‘璁�
+    await message.exportConfirm()
+    // 鍙戣捣瀵煎嚭
+    exportLoading.value = true
+    const data = await ApiAccessLogApi.exportApiAccessLog(queryParams)
+    download.excel(data, 'API 璁块棶鏃ュ織.xls')
+  } catch {
+  } finally {
+    exportLoading.value = false
+  }
+}
+
+/** 鍒濆鍖� **/
+onMounted(() => {
+  getList()
+})
+</script>

--
Gitblit v1.8.0