feat: add operation log clear policy and related dialog for cleanup time setting

v3.2
wxg0103 2025-10-11 17:40:15 +08:00
parent bbab216f4c
commit 9d9ae437d4
3 changed files with 109 additions and 27 deletions

View File

@ -1,18 +1,18 @@
import { Result } from '@/request/Result' import {Result} from '@/request/Result'
import { get, exportExcelPost } from '@/request/index' import {get, exportExcelPost, post} from '@/request/index'
import type { pageRequest } from '@/api/type/common' import type {pageRequest} from '@/api/type/common'
import { type Ref } from 'vue' import {type Ref} from 'vue'
const prefix = '/operate_log' const prefix = '/operate_log'
/** /**
* *
* @param * @param
* page { * page {
"current_page": "string", "current_page": "string",
"page_size": "string", "page_size": "string",
} }
* @query * @query
param: any param: any
*/ */
const getOperateLog: ( const getOperateLog: (
page: pageRequest, page: pageRequest,
@ -39,8 +39,20 @@ const exportOperateLog: (
) )
} }
const saveCleanTime: (
data: any,
loading?: Ref<boolean>
) => Promise<Result<any>> = (data, loading) => {
return post(`${prefix}/save`, data, undefined, loading)
}
const getCleanTime: () => Promise<Result<any>> = () => {
return get(`${prefix}/get_clean_time`, undefined, undefined)
}
export default { export default {
getOperateLog, getOperateLog,
getMenuList, getMenuList,
exportOperateLog exportOperateLog,
saveCleanTime,
getCleanTime
} }

View File

@ -289,6 +289,7 @@ const PermissionConst = {
OPERATION_LOG_READ: new Permission('OPERATION_LOG:READ'), OPERATION_LOG_READ: new Permission('OPERATION_LOG:READ'),
OPERATION_LOG_EXPORT: new Permission('OPERATION_LOG:READ+EXPORT'), OPERATION_LOG_EXPORT: new Permission('OPERATION_LOG:READ+EXPORT'),
OPERATION_LOG_CLEAR_POLICY: new Permission('OPERATION_LOG:READ+CLEAR_POLICY'),
ABOUT_READ: new Permission('OTHER:READ'), ABOUT_READ: new Permission('OTHER:READ'),
SWITCH_LANGUAGE: new Permission('OTHER:READ+EDIT'), SWITCH_LANGUAGE: new Permission('OTHER:READ+EDIT'),

View File

@ -70,7 +70,18 @@
/> />
</div> </div>
<el-button @click="exportLog" style="margin-left: 10px" <el-button @click="exportLog" style="margin-left: 10px"
>{{ $t('common.export') }} v-hasPermission="
new ComplexPermission([RoleConst.ADMIN],
[PermissionConst.OPERATION_LOG_EXPORT],
[EditionConst.IS_EE, EditionConst.IS_PE], 'OR')"
>{{ $t('common.export') }}
</el-button>
<el-button @click="dialogVisible = true"
v-hasPermission="
new ComplexPermission([RoleConst.ADMIN],
[PermissionConst.OPERATION_LOG_CLEAR_POLICY],
[EditionConst.IS_EE, EditionConst.IS_PE], 'OR')">
{{ $t('views.chatLog.buttons.clearStrategy') }}
</el-button> </el-button>
</div> </div>
</div> </div>
@ -96,7 +107,7 @@
@click="popoverVisible = !popoverVisible" @click="popoverVisible = !popoverVisible"
> >
<el-icon> <el-icon>
<Filter /> <Filter/>
</el-icon> </el-icon>
</el-button> </el-button>
</template> </template>
@ -121,10 +132,10 @@
</div> </div>
<div class="text-right"> <div class="text-right">
<el-button size="small" @click="filterChange('clear')" <el-button size="small" @click="filterChange('clear')"
>{{ $t('common.clear') }} >{{ $t('common.clear') }}
</el-button> </el-button>
<el-button type="primary" @click="filterChange" size="small" <el-button type="primary" @click="filterChange" size="small"
>{{ $t('common.confirm') }} >{{ $t('common.confirm') }}
</el-button> </el-button>
</div> </div>
</el-popover> </el-popover>
@ -173,7 +184,7 @@
@click="workspaceVisible = !workspaceVisible" @click="workspaceVisible = !workspaceVisible"
> >
<el-icon> <el-icon>
<Filter /> <Filter/>
</el-icon> </el-icon>
</el-button> </el-button>
</template> </template>
@ -198,10 +209,10 @@
</div> </div>
<div class="text-right"> <div class="text-right">
<el-button size="small" @click="filterWorkspaceChange('clear')" <el-button size="small" @click="filterWorkspaceChange('clear')"
>{{ $t('common.clear') }} >{{ $t('common.clear') }}
</el-button> </el-button>
<el-button type="primary" @click="filterWorkspaceChange" size="small" <el-button type="primary" @click="filterWorkspaceChange" size="small"
>{{ $t('common.confirm') }} >{{ $t('common.confirm') }}
</el-button> </el-button>
</div> </div>
</el-popover> </el-popover>
@ -215,8 +226,8 @@
> >
<template #default="{ row }"> <template #default="{ row }">
<span v-if="row.status === 200">{{ <span v-if="row.status === 200">{{
$t('views.operateLog.table.status.success') $t('views.operateLog.table.status.success')
}}</span> }}</span>
<span v-else style="color: red">{{ $t('views.operateLog.table.status.fail') }}</span> <span v-else style="color: red">{{ $t('views.operateLog.table.status.fail') }}</span>
</template> </template>
</el-table-column> </el-table-column>
@ -233,7 +244,8 @@
<el-table-column :label="$t('common.operation')" width="60" align="left" fixed="right"> <el-table-column :label="$t('common.operation')" width="60" align="left" fixed="right">
<template #default="{ row }"> <template #default="{ row }">
<span class="mr-4"> <span class="mr-4">
<el-tooltip effect="dark" :content="$t('views.operateLog.table.opt.label')" placement="top"> <el-tooltip effect="dark" :content="$t('views.operateLog.table.opt.label')"
placement="top">
<el-button type="primary" text @click.stop="showDetails(row)" class="text-button"> <el-button type="primary" text @click.stop="showDetails(row)" class="text-button">
<AppIcon iconName="app-operate-log"></AppIcon> <AppIcon iconName="app-operate-log"></AppIcon>
</el-button> </el-button>
@ -243,20 +255,53 @@
</el-table-column> </el-table-column>
</app-table> </app-table>
</div> </div>
<DetailDialog ref="DetailDialogRef" /> <DetailDialog ref="DetailDialogRef"/>
</el-card> </el-card>
</div> </div>
<el-dialog
:title="$t('views.chatLog.buttons.clearStrategy')"
v-model="dialogVisible"
width="25%"
:close-on-click-modal="false"
:close-on-press-escape="false"
>
<span>{{ $t('common.delete') }}</span>
<el-input-number
v-model="days"
controls-position="right"
:min="1"
:max="100000"
:value-on-clear="0"
step-strictly
style="width: 110px; margin-left: 8px; margin-right: 8px"
></el-input-number>
<span>{{ $t('views.chatLog.daysText') }}</span>
<template #footer>
<div class="dialog-footer" style="margin-top: 16px">
<el-button @click="dialogVisible = false">{{ $t('common.cancel') }}</el-button>
<el-button type="primary" @click="saveCleanTime">
{{ $t('common.save') }}
</el-button>
</div>
</template>
</el-dialog>
</template> </template>
<script setup lang="ts"> <script setup lang="ts">
import { ref, onMounted, reactive } from 'vue' import {ref, onMounted, reactive} from 'vue'
import operateLog from '@/api/system/operate-log' import operateLog from '@/api/system/operate-log'
import DetailDialog from './component/DetailDialog.vue' import DetailDialog from './component/DetailDialog.vue'
import { t } from '@/locales' import {t} from '@/locales'
import { beforeDay, datetimeFormat, nowDate } from '@/utils/time' import {beforeDay, datetimeFormat, nowDate} from '@/utils/time'
import useStore from '@/stores' import useStore from '@/stores'
import WorkspaceApi from '@/api/system/workspace.ts' import WorkspaceApi from '@/api/system/workspace.ts'
import {hasPermission} from "@/utils/permission";
import {EditionConst, PermissionConst, RoleConst} from "@/utils/permission/data.ts";
import {ComplexPermission} from "@/utils/permission/type.ts";
import {loadSharedApi} from "@/utils/dynamics-api/shared-api.ts";
import {MsgSuccess} from "@/utils/message.ts";
const { user } = useStore() const {user} = useStore()
const popoverVisible = ref(false) const popoverVisible = ref(false)
const operateTypeArr = ref<any[]>([]) const operateTypeArr = ref<any[]>([])
const workspaceVisible = ref(false) const workspaceVisible = ref(false)
@ -278,6 +323,8 @@ const daterange = ref({
end_time: '', end_time: '',
}) })
const daterangeValue = ref('') const daterangeValue = ref('')
const dialogVisible = ref(false)
const days = ref<number>(180)
const dayOptions = [ const dayOptions = [
{ {
value: 7, value: 7,
@ -411,7 +458,7 @@ function getMenuList() {
arr arr
.filter((item, index, self) => index === self.findIndex((i) => i['menu'] === item['menu'])) .filter((item, index, self) => index === self.findIndex((i) => i['menu'] === item['menu']))
.forEach((ele) => { .forEach((ele) => {
operateOptions.value.push({ label: ele.menu_label, value: ele.menu }) operateOptions.value.push({label: ele.menu_label, value: ele.menu})
}) })
}) })
} }
@ -430,8 +477,30 @@ async function getWorkspaceList() {
} }
} }
function saveCleanTime() {
const obj = {
clean_time: days.value,
}
operateLog.saveCleanTime(obj, loading).then(() => {
MsgSuccess(t('common.saveSuccess'))
dialogVisible.value = false
getCleanTime()
})
.catch(() => {
dialogVisible.value = false
})
}
function getCleanTime() {
operateLog.getCleanTime().then((res) => {
days.value = res.data
})
}
onMounted(() => { onMounted(() => {
getMenuList() getMenuList()
getCleanTime()
getWorkspaceList() getWorkspaceList()
changeDayHandle(history_day.value) changeDayHandle(history_day.value)
}) })