Skip to content

Commit 9d9ae43

Browse files
committed
feat: add operation log clear policy and related dialog for cleanup time setting
1 parent bbab216 commit 9d9ae43

File tree

3 files changed

+109
-27
lines changed

3 files changed

+109
-27
lines changed

ui/src/api/system/operate-log.ts

Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
1-
import { Result } from '@/request/Result'
2-
import { get, exportExcelPost } from '@/request/index'
3-
import type { pageRequest } from '@/api/type/common'
4-
import { type Ref } from 'vue'
1+
import {Result} from '@/request/Result'
2+
import {get, exportExcelPost, post} from '@/request/index'
3+
import type {pageRequest} from '@/api/type/common'
4+
import {type Ref} from 'vue'
55

66
const prefix = '/operate_log'
77
/**
88
* 日志分页列表
99
* @param 参数
1010
* page {
11-
"current_page": "string",
12-
"page_size": "string",
13-
}
11+
"current_page": "string",
12+
"page_size": "string",
13+
}
1414
* @query 参数
15-
param: any
15+
param: any
1616
*/
1717
const getOperateLog: (
1818
page: pageRequest,
@@ -39,8 +39,20 @@ const exportOperateLog: (
3939
)
4040
}
4141

42+
const saveCleanTime: (
43+
data: any,
44+
loading?: Ref<boolean>
45+
) => Promise<Result<any>> = (data, loading) => {
46+
return post(`${prefix}/save`, data, undefined, loading)
47+
}
48+
const getCleanTime: () => Promise<Result<any>> = () => {
49+
return get(`${prefix}/get_clean_time`, undefined, undefined)
50+
}
51+
4252
export default {
4353
getOperateLog,
4454
getMenuList,
45-
exportOperateLog
55+
exportOperateLog,
56+
saveCleanTime,
57+
getCleanTime
4658
}

ui/src/utils/permission/data.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -272,12 +272,12 @@ const PermissionConst = {
272272
RESOURCE_MODEL_READ: new Permission('SYSTEM_RESOURCE_MODEL:READ'),
273273
RESOURCE_MODEL_EDIT: new Permission('SYSTEM_RESOURCE_MODEL:READ+EDIT'),
274274
RESOURCE_MODEL_DELETE: new Permission('SYSTEM_RESOURCE_MODEL:READ+DELETE'),
275-
275+
276276
RESOURCE_MODEL_AUTH: new Permission('SYSTEM_RESOURCE_MODEL:READ+AUTH'),
277277
RESOURCE_APPLICATION_AUTH: new Permission('SYSTEM_RESOURCE_APPLICATION:READ+AUTH'),
278278
RESOURCE_KNOWLEDGE_AUTH: new Permission('SYSTEM_RESOURCE_KNOWLEDGE:READ+AUTH'),
279279
RESOURCE_TOOL_AUTH: new Permission('SYSTEM_RESOURCE_TOOL:READ+AUTH'),
280-
280+
281281
APPEARANCE_SETTINGS_READ: new Permission('APPEARANCE_SETTINGS:READ'),
282282
APPEARANCE_SETTINGS_EDIT: new Permission('APPEARANCE_SETTINGS:READ+EDIT'),
283283

@@ -289,6 +289,7 @@ const PermissionConst = {
289289

290290
OPERATION_LOG_READ: new Permission('OPERATION_LOG:READ'),
291291
OPERATION_LOG_EXPORT: new Permission('OPERATION_LOG:READ+EXPORT'),
292+
OPERATION_LOG_CLEAR_POLICY: new Permission('OPERATION_LOG:READ+CLEAR_POLICY'),
292293

293294
ABOUT_READ: new Permission('OTHER:READ'),
294295
SWITCH_LANGUAGE: new Permission('OTHER:READ+EDIT'),

ui/src/views/system/operate-log/index.vue

Lines changed: 85 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,18 @@
7070
/>
7171
</div>
7272
<el-button @click="exportLog" style="margin-left: 10px"
73-
>{{ $t('common.export') }}
73+
v-hasPermission="
74+
new ComplexPermission([RoleConst.ADMIN],
75+
[PermissionConst.OPERATION_LOG_EXPORT],
76+
[EditionConst.IS_EE, EditionConst.IS_PE], 'OR')"
77+
>{{ $t('common.export') }}
78+
</el-button>
79+
<el-button @click="dialogVisible = true"
80+
v-hasPermission="
81+
new ComplexPermission([RoleConst.ADMIN],
82+
[PermissionConst.OPERATION_LOG_CLEAR_POLICY],
83+
[EditionConst.IS_EE, EditionConst.IS_PE], 'OR')">
84+
{{ $t('views.chatLog.buttons.clearStrategy') }}
7485
</el-button>
7586
</div>
7687
</div>
@@ -96,7 +107,7 @@
96107
@click="popoverVisible = !popoverVisible"
97108
>
98109
<el-icon>
99-
<Filter />
110+
<Filter/>
100111
</el-icon>
101112
</el-button>
102113
</template>
@@ -121,10 +132,10 @@
121132
</div>
122133
<div class="text-right">
123134
<el-button size="small" @click="filterChange('clear')"
124-
>{{ $t('common.clear') }}
135+
>{{ $t('common.clear') }}
125136
</el-button>
126137
<el-button type="primary" @click="filterChange" size="small"
127-
>{{ $t('common.confirm') }}
138+
>{{ $t('common.confirm') }}
128139
</el-button>
129140
</div>
130141
</el-popover>
@@ -173,7 +184,7 @@
173184
@click="workspaceVisible = !workspaceVisible"
174185
>
175186
<el-icon>
176-
<Filter />
187+
<Filter/>
177188
</el-icon>
178189
</el-button>
179190
</template>
@@ -198,10 +209,10 @@
198209
</div>
199210
<div class="text-right">
200211
<el-button size="small" @click="filterWorkspaceChange('clear')"
201-
>{{ $t('common.clear') }}
212+
>{{ $t('common.clear') }}
202213
</el-button>
203214
<el-button type="primary" @click="filterWorkspaceChange" size="small"
204-
>{{ $t('common.confirm') }}
215+
>{{ $t('common.confirm') }}
205216
</el-button>
206217
</div>
207218
</el-popover>
@@ -215,8 +226,8 @@
215226
>
216227
<template #default="{ row }">
217228
<span v-if="row.status === 200">{{
218-
$t('views.operateLog.table.status.success')
219-
}}</span>
229+
$t('views.operateLog.table.status.success')
230+
}}</span>
220231
<span v-else style="color: red">{{ $t('views.operateLog.table.status.fail') }}</span>
221232
</template>
222233
</el-table-column>
@@ -233,7 +244,8 @@
233244
<el-table-column :label="$t('common.operation')" width="60" align="left" fixed="right">
234245
<template #default="{ row }">
235246
<span class="mr-4">
236-
<el-tooltip effect="dark" :content="$t('views.operateLog.table.opt.label')" placement="top">
247+
<el-tooltip effect="dark" :content="$t('views.operateLog.table.opt.label')"
248+
placement="top">
237249
<el-button type="primary" text @click.stop="showDetails(row)" class="text-button">
238250
<AppIcon iconName="app-operate-log"></AppIcon>
239251
</el-button>
@@ -243,20 +255,53 @@
243255
</el-table-column>
244256
</app-table>
245257
</div>
246-
<DetailDialog ref="DetailDialogRef" />
258+
<DetailDialog ref="DetailDialogRef"/>
247259
</el-card>
248260
</div>
261+
<el-dialog
262+
:title="$t('views.chatLog.buttons.clearStrategy')"
263+
v-model="dialogVisible"
264+
width="25%"
265+
:close-on-click-modal="false"
266+
:close-on-press-escape="false"
267+
>
268+
<span>{{ $t('common.delete') }}</span>
269+
<el-input-number
270+
v-model="days"
271+
controls-position="right"
272+
:min="1"
273+
:max="100000"
274+
:value-on-clear="0"
275+
step-strictly
276+
style="width: 110px; margin-left: 8px; margin-right: 8px"
277+
></el-input-number>
278+
<span>{{ $t('views.chatLog.daysText') }}</span>
279+
<template #footer>
280+
<div class="dialog-footer" style="margin-top: 16px">
281+
<el-button @click="dialogVisible = false">{{ $t('common.cancel') }}</el-button>
282+
<el-button type="primary" @click="saveCleanTime">
283+
{{ $t('common.save') }}
284+
</el-button>
285+
</div>
286+
</template>
287+
</el-dialog>
249288
</template>
289+
250290
<script setup lang="ts">
251-
import { ref, onMounted, reactive } from 'vue'
291+
import {ref, onMounted, reactive} from 'vue'
252292
import operateLog from '@/api/system/operate-log'
253293
import DetailDialog from './component/DetailDialog.vue'
254-
import { t } from '@/locales'
255-
import { beforeDay, datetimeFormat, nowDate } from '@/utils/time'
294+
import {t} from '@/locales'
295+
import {beforeDay, datetimeFormat, nowDate} from '@/utils/time'
256296
import useStore from '@/stores'
257297
import WorkspaceApi from '@/api/system/workspace.ts'
298+
import {hasPermission} from "@/utils/permission";
299+
import {EditionConst, PermissionConst, RoleConst} from "@/utils/permission/data.ts";
300+
import {ComplexPermission} from "@/utils/permission/type.ts";
301+
import {loadSharedApi} from "@/utils/dynamics-api/shared-api.ts";
302+
import {MsgSuccess} from "@/utils/message.ts";
258303
259-
const { user } = useStore()
304+
const {user} = useStore()
260305
const popoverVisible = ref(false)
261306
const operateTypeArr = ref<any[]>([])
262307
const workspaceVisible = ref(false)
@@ -278,6 +323,8 @@ const daterange = ref({
278323
end_time: '',
279324
})
280325
const daterangeValue = ref('')
326+
const dialogVisible = ref(false)
327+
const days = ref<number>(180)
281328
const dayOptions = [
282329
{
283330
value: 7,
@@ -411,7 +458,7 @@ function getMenuList() {
411458
arr
412459
.filter((item, index, self) => index === self.findIndex((i) => i['menu'] === item['menu']))
413460
.forEach((ele) => {
414-
operateOptions.value.push({ label: ele.menu_label, value: ele.menu })
461+
operateOptions.value.push({label: ele.menu_label, value: ele.menu})
415462
})
416463
})
417464
}
@@ -430,8 +477,30 @@ async function getWorkspaceList() {
430477
}
431478
}
432479
480+
function saveCleanTime() {
481+
const obj = {
482+
clean_time: days.value,
483+
}
484+
operateLog.saveCleanTime(obj, loading).then(() => {
485+
MsgSuccess(t('common.saveSuccess'))
486+
dialogVisible.value = false
487+
getCleanTime()
488+
})
489+
.catch(() => {
490+
dialogVisible.value = false
491+
})
492+
}
493+
494+
495+
function getCleanTime() {
496+
operateLog.getCleanTime().then((res) => {
497+
days.value = res.data
498+
})
499+
}
500+
433501
onMounted(() => {
434502
getMenuList()
503+
getCleanTime()
435504
getWorkspaceList()
436505
changeDayHandle(history_day.value)
437506
})

0 commit comments

Comments
 (0)