Skip to content

Commit b8661a3

Browse files
committed
feat: add operate log
1 parent 4a68129 commit b8661a3

File tree

2 files changed

+78
-14
lines changed

2 files changed

+78
-14
lines changed

ui/src/api/operate-log.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,11 @@ const getOperateLog: (
2222
return get(`${prefix}/${page.current_page}/${page.page_size}`, param, loading)
2323
}
2424

25+
const getMenuList: () => Promise<Result<any>> = () => {
26+
return get(`${prefix}/menu_operate_option/`, undefined, undefined)
27+
}
28+
2529
export default {
26-
getOperateLog
30+
getOperateLog,
31+
getMenuList
2732
}

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

Lines changed: 72 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,49 @@
7676
@changePage="getList"
7777
v-loading="loading"
7878
>
79-
<el-table-column prop="menu" :label="$t('views.operateLog.table.menu.label')" width="160" />
79+
<el-table-column prop="menu" :label="$t('views.operateLog.table.menu.label')" width="160">
80+
<template #header>
81+
<div>
82+
<span>{{ $t('views.operateLog.table.menu.label') }}</span>
83+
<el-popover :width="200" trigger="click" :visible="popoverVisible">
84+
<template #reference>
85+
<el-button
86+
style="margin-top: -2px"
87+
:type="operateTypeArr && operateTypeArr.length > 0 ? 'primary' : ''"
88+
link
89+
@click="popoverVisible = !popoverVisible"
90+
>
91+
<el-icon>
92+
<Filter />
93+
</el-icon>
94+
</el-button>
95+
</template>
96+
<div class="filter">
97+
<div class="form-item mb-16">
98+
<div @click.stop>
99+
<el-scrollbar height="300" style="margin: 0 0 0 10px;">
100+
<el-checkbox-group v-model="operateTypeArr" style="display: flex; flex-direction: column;">
101+
<el-checkbox v-for="item in operateOptions"
102+
:key="item.value"
103+
:label="item.label"
104+
:value="item.value" />
105+
</el-checkbox-group>
106+
</el-scrollbar>
107+
</div>
108+
</div>
109+
</div>
110+
<div class="text-right">
111+
<el-button size="small" @click="filterChange('clear')">{{
112+
$t('common.clear')
113+
}}</el-button>
114+
<el-button type="primary" @click="filterChange" size="small">{{
115+
$t('common.confirm')
116+
}}</el-button>
117+
</div>
118+
</el-popover>
119+
</div>
120+
</template>
121+
</el-table-column>
80122
<el-table-column prop="operate" :label="$t('views.operateLog.table.operate.label')" />
81123
<el-table-column
82124
width="120"
@@ -119,11 +161,13 @@
119161
</template>
120162
<script setup lang="ts">
121163
import { ref, onMounted, reactive } from 'vue'
122-
import getOperateLog from '@/api/operate-log'
164+
import operateLog from '@/api/operate-log'
123165
import DetailDialog from './component/DetailDialog.vue'
124166
import { t } from '@/locales'
125167
import { beforeDay, datetimeFormat, nowDate } from '@/utils/time'
126168
169+
const popoverVisible = ref(false)
170+
const operateTypeArr = ref<any[]>([])
127171
const DetailDialogRef = ref()
128172
const loading = ref(false)
129173
const paginationConfig = reactive({
@@ -134,7 +178,7 @@ const paginationConfig = reactive({
134178
const searchValue = ref('')
135179
const tableData = ref<any[]>([])
136180
const history_day = ref<number | string>(7)
137-
const filter_type = ref<string>('menu')
181+
const filter_type = ref<string>('user')
138182
const filter_status = ref<string>('')
139183
const daterange = ref({
140184
start_time: '',
@@ -165,14 +209,6 @@ const dayOptions = [
165209
}
166210
]
167211
const filterOptions = [
168-
{
169-
value: 'menu',
170-
label: t('views.operateLog.table.menu.label')
171-
},
172-
{
173-
value: 'operate',
174-
label: t('views.operateLog.table.operate.label')
175-
},
176212
{
177213
value: 'user',
178214
label: t('views.operateLog.table.user.label')
@@ -196,6 +232,15 @@ const statusOptions = [
196232
label: t('views.operateLog.table.status.fail')
197233
}
198234
]
235+
const operateOptions = ref<any[]>([])
236+
237+
function filterChange(val: string) {
238+
if (val === 'clear') {
239+
operateTypeArr.value = []
240+
}
241+
getList()
242+
popoverVisible.value = false
243+
}
199244
200245
function changeStatusHandle(val: string) {
201246
getList()
@@ -241,15 +286,29 @@ function getList() {
241286
if (filter_type.value === 'status') {
242287
obj['status'] = filter_status.value
243288
}
244-
return getOperateLog.getOperateLog(paginationConfig, obj, loading).then((res) => {
289+
if(operateTypeArr.value.length > 0) {
290+
obj['menu'] = JSON.stringify(operateTypeArr.value)
291+
}
292+
return operateLog.getOperateLog(paginationConfig, obj, loading).then((res) => {
245293
tableData.value = res.data.records
246294
paginationConfig.total = res.data.total
247295
})
248296
}
249297
298+
function getMenuList() {
299+
return operateLog.getMenuList().then((res) => {
300+
let arr: any[] = res.data
301+
arr.filter((item, index, self) =>
302+
index === self.findIndex((i) => i['menu'] === item['menu'])
303+
).forEach(ele => {
304+
operateOptions.value.push({label:ele.menu_label, value:ele.menu})
305+
})
306+
})
307+
}
308+
250309
onMounted(() => {
310+
getMenuList()
251311
changeDayHandle(history_day.value)
252-
getList()
253312
})
254313
</script>
255314
<style lang="scss" scoped>

0 commit comments

Comments
 (0)