feat: add operation log clear policy and related dialog for cleanup time setting
parent
bbab216f4c
commit
9d9ae437d4
|
|
@ -1,18 +1,18 @@
|
|||
import { Result } from '@/request/Result'
|
||||
import { get, exportExcelPost } from '@/request/index'
|
||||
import type { pageRequest } from '@/api/type/common'
|
||||
import { type Ref } from 'vue'
|
||||
import {Result} from '@/request/Result'
|
||||
import {get, exportExcelPost, post} from '@/request/index'
|
||||
import type {pageRequest} from '@/api/type/common'
|
||||
import {type Ref} from 'vue'
|
||||
|
||||
const prefix = '/operate_log'
|
||||
/**
|
||||
* 日志分页列表
|
||||
* @param 参数
|
||||
* page {
|
||||
"current_page": "string",
|
||||
"page_size": "string",
|
||||
}
|
||||
"current_page": "string",
|
||||
"page_size": "string",
|
||||
}
|
||||
* @query 参数
|
||||
param: any
|
||||
param: any
|
||||
*/
|
||||
const getOperateLog: (
|
||||
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 {
|
||||
getOperateLog,
|
||||
getMenuList,
|
||||
exportOperateLog
|
||||
exportOperateLog,
|
||||
saveCleanTime,
|
||||
getCleanTime
|
||||
}
|
||||
|
|
|
|||
|
|
@ -272,12 +272,12 @@ const PermissionConst = {
|
|||
RESOURCE_MODEL_READ: new Permission('SYSTEM_RESOURCE_MODEL:READ'),
|
||||
RESOURCE_MODEL_EDIT: new Permission('SYSTEM_RESOURCE_MODEL:READ+EDIT'),
|
||||
RESOURCE_MODEL_DELETE: new Permission('SYSTEM_RESOURCE_MODEL:READ+DELETE'),
|
||||
|
||||
|
||||
RESOURCE_MODEL_AUTH: new Permission('SYSTEM_RESOURCE_MODEL:READ+AUTH'),
|
||||
RESOURCE_APPLICATION_AUTH: new Permission('SYSTEM_RESOURCE_APPLICATION:READ+AUTH'),
|
||||
RESOURCE_KNOWLEDGE_AUTH: new Permission('SYSTEM_RESOURCE_KNOWLEDGE:READ+AUTH'),
|
||||
RESOURCE_TOOL_AUTH: new Permission('SYSTEM_RESOURCE_TOOL:READ+AUTH'),
|
||||
|
||||
|
||||
APPEARANCE_SETTINGS_READ: new Permission('APPEARANCE_SETTINGS:READ'),
|
||||
APPEARANCE_SETTINGS_EDIT: new Permission('APPEARANCE_SETTINGS:READ+EDIT'),
|
||||
|
||||
|
|
@ -289,6 +289,7 @@ const PermissionConst = {
|
|||
|
||||
OPERATION_LOG_READ: new Permission('OPERATION_LOG:READ'),
|
||||
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'),
|
||||
SWITCH_LANGUAGE: new Permission('OTHER:READ+EDIT'),
|
||||
|
|
|
|||
|
|
@ -70,7 +70,18 @@
|
|||
/>
|
||||
</div>
|
||||
<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>
|
||||
</div>
|
||||
</div>
|
||||
|
|
@ -96,7 +107,7 @@
|
|||
@click="popoverVisible = !popoverVisible"
|
||||
>
|
||||
<el-icon>
|
||||
<Filter />
|
||||
<Filter/>
|
||||
</el-icon>
|
||||
</el-button>
|
||||
</template>
|
||||
|
|
@ -121,10 +132,10 @@
|
|||
</div>
|
||||
<div class="text-right">
|
||||
<el-button size="small" @click="filterChange('clear')"
|
||||
>{{ $t('common.clear') }}
|
||||
>{{ $t('common.clear') }}
|
||||
</el-button>
|
||||
<el-button type="primary" @click="filterChange" size="small"
|
||||
>{{ $t('common.confirm') }}
|
||||
>{{ $t('common.confirm') }}
|
||||
</el-button>
|
||||
</div>
|
||||
</el-popover>
|
||||
|
|
@ -173,7 +184,7 @@
|
|||
@click="workspaceVisible = !workspaceVisible"
|
||||
>
|
||||
<el-icon>
|
||||
<Filter />
|
||||
<Filter/>
|
||||
</el-icon>
|
||||
</el-button>
|
||||
</template>
|
||||
|
|
@ -198,10 +209,10 @@
|
|||
</div>
|
||||
<div class="text-right">
|
||||
<el-button size="small" @click="filterWorkspaceChange('clear')"
|
||||
>{{ $t('common.clear') }}
|
||||
>{{ $t('common.clear') }}
|
||||
</el-button>
|
||||
<el-button type="primary" @click="filterWorkspaceChange" size="small"
|
||||
>{{ $t('common.confirm') }}
|
||||
>{{ $t('common.confirm') }}
|
||||
</el-button>
|
||||
</div>
|
||||
</el-popover>
|
||||
|
|
@ -215,8 +226,8 @@
|
|||
>
|
||||
<template #default="{ row }">
|
||||
<span v-if="row.status === 200">{{
|
||||
$t('views.operateLog.table.status.success')
|
||||
}}</span>
|
||||
$t('views.operateLog.table.status.success')
|
||||
}}</span>
|
||||
<span v-else style="color: red">{{ $t('views.operateLog.table.status.fail') }}</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
|
|
@ -233,7 +244,8 @@
|
|||
<el-table-column :label="$t('common.operation')" width="60" align="left" fixed="right">
|
||||
<template #default="{ row }">
|
||||
<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">
|
||||
<AppIcon iconName="app-operate-log"></AppIcon>
|
||||
</el-button>
|
||||
|
|
@ -243,20 +255,53 @@
|
|||
</el-table-column>
|
||||
</app-table>
|
||||
</div>
|
||||
<DetailDialog ref="DetailDialogRef" />
|
||||
<DetailDialog ref="DetailDialogRef"/>
|
||||
</el-card>
|
||||
</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>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { ref, onMounted, reactive } from 'vue'
|
||||
import {ref, onMounted, reactive} from 'vue'
|
||||
import operateLog from '@/api/system/operate-log'
|
||||
import DetailDialog from './component/DetailDialog.vue'
|
||||
import { t } from '@/locales'
|
||||
import { beforeDay, datetimeFormat, nowDate } from '@/utils/time'
|
||||
import {t} from '@/locales'
|
||||
import {beforeDay, datetimeFormat, nowDate} from '@/utils/time'
|
||||
import useStore from '@/stores'
|
||||
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 operateTypeArr = ref<any[]>([])
|
||||
const workspaceVisible = ref(false)
|
||||
|
|
@ -278,6 +323,8 @@ const daterange = ref({
|
|||
end_time: '',
|
||||
})
|
||||
const daterangeValue = ref('')
|
||||
const dialogVisible = ref(false)
|
||||
const days = ref<number>(180)
|
||||
const dayOptions = [
|
||||
{
|
||||
value: 7,
|
||||
|
|
@ -411,7 +458,7 @@ function getMenuList() {
|
|||
arr
|
||||
.filter((item, index, self) => index === self.findIndex((i) => i['menu'] === item['menu']))
|
||||
.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(() => {
|
||||
getMenuList()
|
||||
getCleanTime()
|
||||
getWorkspaceList()
|
||||
changeDayHandle(history_day.value)
|
||||
})
|
||||
|
|
|
|||
Loading…
Reference in New Issue