commit
4d808e240b
@ -14,7 +14,9 @@ async def get_audit_log_list(
|
|||||||
page_size: int = Query(10, description="每页数量"),
|
page_size: int = Query(10, description="每页数量"),
|
||||||
username: str = Query("", description="操作人名称"),
|
username: str = Query("", description="操作人名称"),
|
||||||
module: str = Query("", description="功能模块"),
|
module: str = Query("", description="功能模块"),
|
||||||
|
method: str = Query("", description="请求方法"),
|
||||||
summary: str = Query("", description="接口描述"),
|
summary: str = Query("", description="接口描述"),
|
||||||
|
status: int = Query(None, description="状态码"),
|
||||||
start_time: str = Query("", description="开始时间"),
|
start_time: str = Query("", description="开始时间"),
|
||||||
end_time: str = Query("", description="结束时间"),
|
end_time: str = Query("", description="结束时间"),
|
||||||
):
|
):
|
||||||
@ -23,8 +25,12 @@ async def get_audit_log_list(
|
|||||||
q &= Q(username__icontains=username)
|
q &= Q(username__icontains=username)
|
||||||
if module:
|
if module:
|
||||||
q &= Q(module__icontains=module)
|
q &= Q(module__icontains=module)
|
||||||
|
if method:
|
||||||
|
q &= Q(method__icontains=method)
|
||||||
if summary:
|
if summary:
|
||||||
q &= Q(summary__icontains=summary)
|
q &= Q(summary__icontains=summary)
|
||||||
|
if status:
|
||||||
|
q &= Q(status__icontains=status)
|
||||||
if start_time and end_time:
|
if start_time and end_time:
|
||||||
q &= Q(created_at__range=[start_time, end_time])
|
q &= Q(created_at__range=[start_time, end_time])
|
||||||
elif start_time:
|
elif start_time:
|
||||||
|
|||||||
@ -24,7 +24,7 @@ class User(BaseModel, TimestampMixin):
|
|||||||
|
|
||||||
class Role(BaseModel, TimestampMixin):
|
class Role(BaseModel, TimestampMixin):
|
||||||
name = fields.CharField(max_length=20, unique=True, description="角色名称", index=True)
|
name = fields.CharField(max_length=20, unique=True, description="角色名称", index=True)
|
||||||
desc = fields.CharField(max_length=500, null=True, blank=True, description="角色描述")
|
desc = fields.CharField(max_length=500, null=True, description="角色描述")
|
||||||
menus = fields.ManyToManyField("models.Menu", related_name="role_menus")
|
menus = fields.ManyToManyField("models.Menu", related_name="role_menus")
|
||||||
apis = fields.ManyToManyField("models.Api", related_name="role_apis")
|
apis = fields.ManyToManyField("models.Api", related_name="role_apis")
|
||||||
|
|
||||||
@ -44,16 +44,16 @@ class Api(BaseModel, TimestampMixin):
|
|||||||
|
|
||||||
class Menu(BaseModel, TimestampMixin):
|
class Menu(BaseModel, TimestampMixin):
|
||||||
name = fields.CharField(max_length=20, description="菜单名称", index=True)
|
name = fields.CharField(max_length=20, description="菜单名称", index=True)
|
||||||
remark = fields.JSONField(null=True, description="保留字段", blank=True)
|
remark = fields.JSONField(null=True, description="保留字段")
|
||||||
menu_type = fields.CharEnumField(MenuType, null=True, blank=True, description="菜单类型")
|
menu_type = fields.CharEnumField(MenuType, null=True, description="菜单类型")
|
||||||
icon = fields.CharField(max_length=100, null=True, blank=True, description="菜单图标")
|
icon = fields.CharField(max_length=100, null=True, description="菜单图标")
|
||||||
path = fields.CharField(max_length=100, description="菜单路径", index=True)
|
path = fields.CharField(max_length=100, description="菜单路径", index=True)
|
||||||
order = fields.IntField(default=0, description="排序", index=True)
|
order = fields.IntField(default=0, description="排序", index=True)
|
||||||
parent_id = fields.IntField(default=0, max_length=10, description="父菜单ID", index=True)
|
parent_id = fields.IntField(default=0, max_length=10, description="父菜单ID", index=True)
|
||||||
is_hidden = fields.BooleanField(default=False, description="是否隐藏")
|
is_hidden = fields.BooleanField(default=False, description="是否隐藏")
|
||||||
component = fields.CharField(max_length=100, description="组件")
|
component = fields.CharField(max_length=100, description="组件")
|
||||||
keepalive = fields.BooleanField(default=True, description="存活")
|
keepalive = fields.BooleanField(default=True, description="存活")
|
||||||
redirect = fields.CharField(max_length=100, null=True, blank=True, description="重定向")
|
redirect = fields.CharField(max_length=100, null=True, description="重定向")
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
table = "menu"
|
table = "menu"
|
||||||
@ -61,7 +61,7 @@ class Menu(BaseModel, TimestampMixin):
|
|||||||
|
|
||||||
class Dept(BaseModel, TimestampMixin):
|
class Dept(BaseModel, TimestampMixin):
|
||||||
name = fields.CharField(max_length=20, unique=True, description="部门名称", index=True)
|
name = fields.CharField(max_length=20, unique=True, description="部门名称", index=True)
|
||||||
desc = fields.CharField(max_length=500, null=True, blank=True, description="备注")
|
desc = fields.CharField(max_length=500, null=True, description="备注")
|
||||||
is_deleted = fields.BooleanField(default=False, description="软删除标记", index=True)
|
is_deleted = fields.BooleanField(default=False, description="软删除标记", index=True)
|
||||||
order = fields.IntField(default=0, description="排序", index=True)
|
order = fields.IntField(default=0, description="排序", index=True)
|
||||||
parent_id = fields.IntField(default=0, max_length=10, description="父部门ID", index=True)
|
parent_id = fields.IntField(default=0, max_length=10, description="父部门ID", index=True)
|
||||||
|
|||||||
@ -124,7 +124,7 @@ function handleSearch() {
|
|||||||
async function handleReset() {
|
async function handleReset() {
|
||||||
const queryItems = { ...props.queryItems }
|
const queryItems = { ...props.queryItems }
|
||||||
for (const key in queryItems) {
|
for (const key in queryItems) {
|
||||||
queryItems[key] = ''
|
queryItems[key] = null
|
||||||
}
|
}
|
||||||
emit('update:queryItems', { ...queryItems, ...initQuery })
|
emit('update:queryItems', { ...queryItems, ...initQuery })
|
||||||
await nextTick()
|
await nextTick()
|
||||||
|
|||||||
@ -2,7 +2,6 @@
|
|||||||
import '@/styles/reset.css'
|
import '@/styles/reset.css'
|
||||||
import 'uno.css'
|
import 'uno.css'
|
||||||
import '@/styles/global.scss'
|
import '@/styles/global.scss'
|
||||||
import 'virtual:svg-icons-register'
|
|
||||||
|
|
||||||
import { createApp } from 'vue'
|
import { createApp } from 'vue'
|
||||||
import { setupRouter } from '@/router'
|
import { setupRouter } from '@/router'
|
||||||
|
|||||||
@ -1,47 +1,18 @@
|
|||||||
<script setup>
|
<script setup>
|
||||||
import { onMounted, ref, resolveDirective } from 'vue'
|
import { onMounted, ref } from 'vue'
|
||||||
import { NInput, NSelect } from 'naive-ui'
|
import { NInput, NSelect } from 'naive-ui'
|
||||||
|
|
||||||
import CommonPage from '@/components/page/CommonPage.vue'
|
import CommonPage from '@/components/page/CommonPage.vue'
|
||||||
import QueryBarItem from '@/components/query-bar/QueryBarItem.vue'
|
import QueryBarItem from '@/components/query-bar/QueryBarItem.vue'
|
||||||
import CrudTable from '@/components/table/CrudTable.vue'
|
import CrudTable from '@/components/table/CrudTable.vue'
|
||||||
|
|
||||||
import { useCRUD } from '@/composables'
|
|
||||||
import api from '@/api'
|
import api from '@/api'
|
||||||
|
|
||||||
defineOptions({ name: '操作日志' })
|
defineOptions({ name: '审计日志' })
|
||||||
|
|
||||||
const $table = ref(null)
|
const $table = ref(null)
|
||||||
const queryItems = ref({})
|
const queryItems = ref({})
|
||||||
|
|
||||||
const {
|
|
||||||
modalVisible,
|
|
||||||
modalTitle,
|
|
||||||
modalLoading,
|
|
||||||
handleSave,
|
|
||||||
modalForm,
|
|
||||||
modalFormRef,
|
|
||||||
handleEdit,
|
|
||||||
handleDelete,
|
|
||||||
handleAdd,
|
|
||||||
} = useCRUD({
|
|
||||||
name: '操作日志',
|
|
||||||
initForm: {
|
|
||||||
args: {
|
|
||||||
ping_sleep: 1,
|
|
||||||
ping_threshold: 500,
|
|
||||||
agent_data_check_threshold: 2,
|
|
||||||
agent_incoming_traffic_threshold: 30,
|
|
||||||
before_start_clean_sleep: 2,
|
|
||||||
before_stop_disposal_sleep: 20,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
doCreate: api.createHostMonitor,
|
|
||||||
doUpdate: api.updateHostMonitor,
|
|
||||||
doDelete: api.deleteHostMonitor,
|
|
||||||
refresh: () => $table.value?.handleSearch(),
|
|
||||||
})
|
|
||||||
|
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
$table.value?.handleSearch()
|
$table.value?.handleSearch()
|
||||||
})
|
})
|
||||||
@ -75,14 +46,21 @@ function getEndOfDayTimestamp() {
|
|||||||
return now.getTime()
|
return now.getTime()
|
||||||
}
|
}
|
||||||
|
|
||||||
// 示例使用
|
|
||||||
const startOfDayTimestamp = getStartOfDayTimestamp()
|
const startOfDayTimestamp = getStartOfDayTimestamp()
|
||||||
const endOfDayTimestamp = getEndOfDayTimestamp()
|
const endOfDayTimestamp = getEndOfDayTimestamp()
|
||||||
|
|
||||||
|
queryItems.value.start_time = formatTimestamp(startOfDayTimestamp)
|
||||||
|
queryItems.value.end_time = formatTimestamp(endOfDayTimestamp)
|
||||||
|
|
||||||
const datetimeRange = ref([startOfDayTimestamp, endOfDayTimestamp])
|
const datetimeRange = ref([startOfDayTimestamp, endOfDayTimestamp])
|
||||||
const handleDateRangeChange = (value) => {
|
const handleDateRangeChange = (value) => {
|
||||||
queryItems.value.start_time = formatTimestamp(value[0])
|
if (value == null) {
|
||||||
queryItems.value.end_time = formatTimestamp(value[1])
|
queryItems.value.start_time = null
|
||||||
|
queryItems.value.end_time = null
|
||||||
|
} else {
|
||||||
|
queryItems.value.start_time = formatTimestamp(value[0])
|
||||||
|
queryItems.value.end_time = formatTimestamp(value[1])
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const methodOptions = [
|
const methodOptions = [
|
||||||
@ -200,19 +178,28 @@ const columns = [
|
|||||||
</QueryBarItem>
|
</QueryBarItem>
|
||||||
<QueryBarItem label="请求方法" :label-width="70">
|
<QueryBarItem label="请求方法" :label-width="70">
|
||||||
<NSelect
|
<NSelect
|
||||||
v-model:value="modalForm.method"
|
v-model:value="queryItems.method"
|
||||||
style="width: 150px"
|
style="width: 180px"
|
||||||
:options="methodOptions"
|
:options="methodOptions"
|
||||||
clearable
|
clearable
|
||||||
placeholder="请选择请求方法"
|
placeholder="请选择请求方法"
|
||||||
/>
|
/>
|
||||||
</QueryBarItem>
|
</QueryBarItem>
|
||||||
<QueryBarItem label="API路径" :label-width="70">
|
<QueryBarItem label="请求路径" :label-width="70">
|
||||||
<NInput
|
<NInput
|
||||||
v-model:value="queryItems.path"
|
v-model:value="queryItems.path"
|
||||||
clearable
|
clearable
|
||||||
type="text"
|
type="text"
|
||||||
placeholder="请输入API路径"
|
placeholder="请输入请求路径"
|
||||||
|
@keypress.enter="$table?.handleSearch()"
|
||||||
|
/>
|
||||||
|
</QueryBarItem>
|
||||||
|
<QueryBarItem label="状态码" :label-width="70">
|
||||||
|
<NInput
|
||||||
|
v-model:value="queryItems.status"
|
||||||
|
clearable
|
||||||
|
type="text"
|
||||||
|
placeholder="请输入状态码"
|
||||||
@keypress.enter="$table?.handleSearch()"
|
@keypress.enter="$table?.handleSearch()"
|
||||||
/>
|
/>
|
||||||
</QueryBarItem>
|
</QueryBarItem>
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user