mirror of
https://gitee.com/xiangheng/x_admin.git
synced 2025-12-24 08:12:55 +08:00
慢接口
This commit is contained in:
77
admin/src/api/monitor/slow.ts
Normal file
77
admin/src/api/monitor/slow.ts
Normal file
@@ -0,0 +1,77 @@
|
||||
import request from '@/utils/request'
|
||||
import type { Pages } from '@/utils/request'
|
||||
|
||||
import config from '@/config'
|
||||
import queryString from 'query-string'
|
||||
import { getToken } from '@/utils/auth'
|
||||
import { clearEmpty } from '@/utils/util'
|
||||
|
||||
export type type_monitor_slow = {
|
||||
Id?: number
|
||||
ProjectKey?: string
|
||||
ClientId?: string
|
||||
UserId?: string
|
||||
Path?: string
|
||||
Time?: number
|
||||
CreateTime?: string
|
||||
}
|
||||
// 查询
|
||||
export type type_monitor_slow_query = {
|
||||
ProjectKey?: string
|
||||
ClientId?: string
|
||||
UserId?: string
|
||||
Path?: string
|
||||
Time?: number
|
||||
CreateTimeStart?: string
|
||||
CreateTimeEnd?: string
|
||||
}
|
||||
// 添加编辑
|
||||
export type type_monitor_slow_edit = {
|
||||
Id?: number
|
||||
ProjectKey?: string
|
||||
ClientId?: string
|
||||
UserId?: string
|
||||
Path?: string
|
||||
Time?: number
|
||||
}
|
||||
|
||||
// 监控-错误列列表
|
||||
export function monitor_slow_list(params?: type_monitor_slow_query) {
|
||||
return request.get<Pages<type_monitor_slow>>({ url: '/monitor_slow/list', params: clearEmpty(params) })
|
||||
}
|
||||
// 监控-错误列列表-所有
|
||||
export function monitor_slow_list_all(params?: type_monitor_slow_query) {
|
||||
return request.get<type_monitor_slow[]>({ url: '/monitor_slow/listAll', params: clearEmpty(params) })
|
||||
}
|
||||
|
||||
// 监控-错误列详情
|
||||
export function monitor_slow_detail(Id: number | string) {
|
||||
return request.get<type_monitor_slow>({ url: '/monitor_slow/detail', params: { Id } })
|
||||
}
|
||||
|
||||
// 监控-错误列新增
|
||||
export function monitor_slow_add(data: type_monitor_slow_edit) {
|
||||
return request.post<null>({ url: '/monitor_slow/add', data })
|
||||
}
|
||||
|
||||
// 监控-错误列编辑
|
||||
export function monitor_slow_edit(data: type_monitor_slow_edit) {
|
||||
return request.post<null>({ url: '/monitor_slow/edit', data })
|
||||
}
|
||||
|
||||
// 监控-错误列删除
|
||||
export function monitor_slow_delete(Id: number | string) {
|
||||
return request.post<null>({ url: '/monitor_slow/del', data: { Id } })
|
||||
}
|
||||
// 监控-错误列删除-批量
|
||||
export function monitor_slow_delete_batch(data: { Ids: string }) {
|
||||
return request.post<null>({ url: '/monitor_slow/delBatch', data })
|
||||
}
|
||||
|
||||
// 监控-错误列导入
|
||||
export const monitor_slow_import_file = '/monitor_slow/ImportFile'
|
||||
|
||||
// 监控-错误列导出
|
||||
export function monitor_slow_export_file(params: any) {
|
||||
return (window.location.href =`${config.baseUrl}${config.urlPrefix}/monitor_slow/ExportFile?token=${getToken()}&` + queryString.stringify(clearEmpty(params)))
|
||||
}
|
||||
@@ -13,16 +13,17 @@ import VForm3 from 'vform3-builds' //引入VForm3库
|
||||
|
||||
import { XErr, XErrWeb } from '../../x_err_sdk/web/index'
|
||||
// { XErr, XErrWeb }
|
||||
new XErr(
|
||||
const xErr = new XErr(
|
||||
{
|
||||
Dns: 'http://localhost:5174/api',
|
||||
Dns: `${location.origin}/api`,
|
||||
Pid: 'e19e3be20de94f49b68fafb4c30668bc',
|
||||
Uid: '10'
|
||||
Uid: ''
|
||||
},
|
||||
new XErrWeb({
|
||||
onloadTimeOut: 3000
|
||||
})
|
||||
)
|
||||
xErr.SetUid(1) //设置用户ID
|
||||
|
||||
const app = createApp(App)
|
||||
app.use(install)
|
||||
|
||||
@@ -66,7 +66,7 @@
|
||||
/>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="事件类型" prop="EventType" width="100" />
|
||||
<el-table-column label="事件类型" prop="EventType" width="130" />
|
||||
<el-table-column label="URL地址" prop="Path" min-width="130" />
|
||||
<el-table-column label="错误消息" prop="Message" min-width="130" />
|
||||
|
||||
|
||||
158
admin/src/views/monitor/slow/edit.vue
Normal file
158
admin/src/views/monitor/slow/edit.vue
Normal file
@@ -0,0 +1,158 @@
|
||||
<template>
|
||||
<div class="edit-popup">
|
||||
<popup
|
||||
ref="popupRef"
|
||||
:title="popupTitle"
|
||||
:async="true"
|
||||
width="550px"
|
||||
:clickModalClose="true"
|
||||
@confirm="handleSubmit"
|
||||
@close="handleClose"
|
||||
>
|
||||
<el-form ref="formRef" :model="formData" label-width="84px" :rules="formRules">
|
||||
<el-form-item label="项目key" prop="ProjectKey">
|
||||
<el-input v-model="formData.ProjectKey" placeholder="请输入项目key" />
|
||||
</el-form-item>
|
||||
<el-form-item label="sdk生成的客户端id" prop="ClientId">
|
||||
<el-input v-model="formData.ClientId" placeholder="请输入sdk生成的客户端id" />
|
||||
</el-form-item>
|
||||
<el-form-item label="用户id" prop="UserId">
|
||||
<el-input v-model="formData.UserId" placeholder="请输入用户id" />
|
||||
</el-form-item>
|
||||
<el-form-item label="URL地址" prop="Path">
|
||||
<el-input
|
||||
v-model="formData.Path"
|
||||
placeholder="请输入URL地址"
|
||||
type="textarea"
|
||||
:autosize="{ minRows: 4, maxRows: 6 }"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item label="时间" prop="Time">
|
||||
<el-input v-model="formData.Time" type="number" placeholder="请输入时间" />
|
||||
</el-form-item>
|
||||
|
||||
</el-form>
|
||||
</popup>
|
||||
</div>
|
||||
</template>
|
||||
<script lang="ts" setup>
|
||||
import type { FormInstance } from 'element-plus'
|
||||
import { monitor_slow_edit, monitor_slow_add, monitor_slow_detail } from '@/api/monitor/slow'
|
||||
import Popup from '@/components/popup/index.vue'
|
||||
import feedback from '@/utils/feedback'
|
||||
import { ref, shallowRef, computed, reactive } from 'vue'
|
||||
import type { PropType } from 'vue'
|
||||
defineProps({
|
||||
dictData: {
|
||||
type: Object as PropType<Record<string, any[]>>,
|
||||
default: () => ({})
|
||||
},
|
||||
listAllData:{
|
||||
type: Object as PropType<Record<string, any[]>>,
|
||||
default: () => ({})
|
||||
}
|
||||
})
|
||||
const emit = defineEmits(['success', 'close'])
|
||||
const formRef = shallowRef<FormInstance>()
|
||||
const popupRef = shallowRef<InstanceType<typeof Popup>>()
|
||||
const mode = ref('add')
|
||||
const popupTitle = computed(() => {
|
||||
return mode.value == 'edit' ? '编辑监控-错误列' : '新增监控-错误列'
|
||||
})
|
||||
|
||||
const formData = reactive({
|
||||
Id: null,
|
||||
ProjectKey: null,
|
||||
ClientId: null,
|
||||
UserId: null,
|
||||
Path: null,
|
||||
Time: null,
|
||||
})
|
||||
|
||||
const formRules = {
|
||||
Id: [
|
||||
{
|
||||
required: true,
|
||||
message: '请输入错误id',
|
||||
trigger: ['blur']
|
||||
}
|
||||
],
|
||||
ProjectKey: [
|
||||
{
|
||||
required: true,
|
||||
message: '请输入项目key',
|
||||
trigger: ['blur']
|
||||
}
|
||||
],
|
||||
ClientId: [
|
||||
{
|
||||
required: true,
|
||||
message: '请输入sdk生成的客户端id',
|
||||
trigger: ['blur']
|
||||
}
|
||||
],
|
||||
UserId: [
|
||||
{
|
||||
required: true,
|
||||
message: '请输入用户id',
|
||||
trigger: ['blur']
|
||||
}
|
||||
],
|
||||
Path: [
|
||||
{
|
||||
required: true,
|
||||
message: '请输入URL地址',
|
||||
trigger: ['blur']
|
||||
}
|
||||
],
|
||||
Time: [
|
||||
{
|
||||
required: true,
|
||||
message: '请输入时间',
|
||||
trigger: ['blur']
|
||||
}
|
||||
],
|
||||
}
|
||||
|
||||
const handleSubmit = async () => {
|
||||
try {
|
||||
await formRef.value?.validate()
|
||||
const data: any = { ...formData }
|
||||
mode.value == 'edit' ? await monitor_slow_edit(data) : await monitor_slow_add(data)
|
||||
popupRef.value?.close()
|
||||
feedback.msgSuccess('操作成功')
|
||||
emit('success')
|
||||
} catch (error) {}
|
||||
}
|
||||
|
||||
const open = (type = 'add') => {
|
||||
mode.value = type
|
||||
popupRef.value?.open()
|
||||
}
|
||||
|
||||
const setFormData = async (data: Record<string, any>) => {
|
||||
for (const key in formData) {
|
||||
if (data[key] != null && data[key] != undefined) {
|
||||
//@ts-ignore
|
||||
formData[key] = data[key]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const getDetail = async (row: Record<string, any>) => {
|
||||
try {
|
||||
const data = await monitor_slow_detail(row.Id)
|
||||
setFormData(data)
|
||||
} catch (error) {}
|
||||
}
|
||||
|
||||
const handleClose = () => {
|
||||
emit('close')
|
||||
}
|
||||
|
||||
defineExpose({
|
||||
open,
|
||||
setFormData,
|
||||
getDetail
|
||||
})
|
||||
</script>
|
||||
201
admin/src/views/monitor/slow/index.vue
Normal file
201
admin/src/views/monitor/slow/index.vue
Normal file
@@ -0,0 +1,201 @@
|
||||
<template>
|
||||
<div class="index-lists">
|
||||
<el-card class="!border-none" shadow="never">
|
||||
<el-form
|
||||
ref="formRef"
|
||||
class="mb-[-16px]"
|
||||
:model="queryParams"
|
||||
:inline="true"
|
||||
label-width="70px"
|
||||
label-position="left"
|
||||
>
|
||||
<el-form-item label="项目key" prop="ProjectKey" class="w-[280px]">
|
||||
<el-input v-model="queryParams.ProjectKey" />
|
||||
</el-form-item>
|
||||
<el-form-item label="sdk生成的客户端id" prop="ClientId" class="w-[280px]">
|
||||
<el-input v-model="queryParams.ClientId" />
|
||||
</el-form-item>
|
||||
<el-form-item label="用户id" prop="UserId" class="w-[280px]">
|
||||
<el-input v-model="queryParams.UserId" />
|
||||
</el-form-item>
|
||||
<el-form-item label="创建时间" prop="CreateTime" class="w-[280px]">
|
||||
<daterange-picker
|
||||
v-model:startTime="queryParams.CreateTimeStart"
|
||||
v-model:endTime="queryParams.CreateTimeEnd"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item>
|
||||
<el-button type="primary" @click="resetPage">查询</el-button>
|
||||
<el-button @click="resetParams">重置</el-button>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
</el-card>
|
||||
<el-card class="!border-none mt-4" shadow="never">
|
||||
<div class="text-right">
|
||||
<el-button v-perms="['admin:monitor_slow:add']" type="primary" @click="handleAdd()">
|
||||
<template #icon>
|
||||
<icon name="el-icon-Plus" />
|
||||
</template>
|
||||
新增
|
||||
</el-button>
|
||||
<upload
|
||||
v-perms="['admin:monitor_slow:ImportFile']"
|
||||
class="ml-3 mr-3"
|
||||
:url="monitor_slow_import_file"
|
||||
:data="{ cid: 0 }"
|
||||
type="file"
|
||||
:show-progress="true"
|
||||
@change="resetPage"
|
||||
>
|
||||
<el-button type="primary">
|
||||
<template #icon>
|
||||
<icon name="el-icon-Upload" />
|
||||
</template>
|
||||
导入
|
||||
</el-button>
|
||||
</upload>
|
||||
<el-button
|
||||
v-perms="['admin:monitor_slow:ExportFile']"
|
||||
type="primary"
|
||||
@click="exportFile"
|
||||
>
|
||||
<template #icon>
|
||||
<icon name="el-icon-Download" />
|
||||
</template>
|
||||
导出
|
||||
</el-button>
|
||||
<el-button
|
||||
v-perms="['admin:monitor_slow:delBatch']"
|
||||
type="danger"
|
||||
:disabled="!multipleSelection.length"
|
||||
@click="deleteBatch"
|
||||
>
|
||||
批量删除
|
||||
</el-button>
|
||||
</div>
|
||||
<el-table
|
||||
class="mt-4"
|
||||
size="large"
|
||||
v-loading="pager.loading"
|
||||
:data="pager.lists"
|
||||
@selection-change="handleSelectionChange"
|
||||
>
|
||||
<el-table-column type="selection" width="55" />
|
||||
<el-table-column label="项目key" prop="ProjectKey" min-width="130" />
|
||||
<el-table-column label="sdk生成的客户端id" prop="ClientId" min-width="130" />
|
||||
<el-table-column label="用户id" prop="UserId" min-width="130" />
|
||||
<el-table-column label="URL地址" prop="Path" min-width="130" />
|
||||
<el-table-column label="时间" prop="Time" min-width="130" />
|
||||
<el-table-column label="创建时间" prop="CreateTime" min-width="130" />
|
||||
<el-table-column label="操作" width="120" fixed="right">
|
||||
<template #default="{ row }">
|
||||
<el-button
|
||||
v-perms="['admin:monitor_slow:edit']"
|
||||
type="primary"
|
||||
link
|
||||
@click="handleEdit(row)"
|
||||
>
|
||||
编辑
|
||||
</el-button>
|
||||
<el-button
|
||||
v-perms="['admin:monitor_slow:del']"
|
||||
type="danger"
|
||||
link
|
||||
@click="handleDelete(row.Id)"
|
||||
>
|
||||
删除
|
||||
</el-button>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
<div class="flex justify-end mt-4">
|
||||
<pagination v-model="pager" @change="getLists" />
|
||||
</div>
|
||||
</el-card>
|
||||
<edit-popup v-if="showEdit" ref="editRef" @success="getLists" @close="showEdit = false" />
|
||||
</div>
|
||||
</template>
|
||||
<script lang="ts" setup>
|
||||
import { ref, reactive, shallowRef, nextTick } from 'vue'
|
||||
import {
|
||||
monitor_slow_delete,
|
||||
monitor_slow_delete_batch,
|
||||
monitor_slow_list,
|
||||
monitor_slow_import_file,
|
||||
monitor_slow_export_file
|
||||
} from '@/api/monitor/slow'
|
||||
import type { type_monitor_slow, type_monitor_slow_query } from '@/api/monitor/slow'
|
||||
|
||||
import { usePaging } from '@/hooks/usePaging'
|
||||
import feedback from '@/utils/feedback'
|
||||
import EditPopup from './edit.vue'
|
||||
defineOptions({
|
||||
name: 'monitor_slow'
|
||||
})
|
||||
const editRef = shallowRef<InstanceType<typeof EditPopup>>()
|
||||
const showEdit = ref(false)
|
||||
const queryParams = reactive<type_monitor_slow_query>({
|
||||
ProjectKey: null,
|
||||
ClientId: null,
|
||||
UserId: null,
|
||||
Path: null,
|
||||
Time: null,
|
||||
CreateTimeStart: null,
|
||||
CreateTimeEnd: null
|
||||
})
|
||||
|
||||
const { pager, getLists, resetPage, resetParams } = usePaging<type_monitor_slow>({
|
||||
fetchFun: monitor_slow_list,
|
||||
params: queryParams
|
||||
})
|
||||
|
||||
const handleAdd = async () => {
|
||||
showEdit.value = true
|
||||
await nextTick()
|
||||
editRef.value?.open('add')
|
||||
}
|
||||
|
||||
const handleEdit = async (data: any) => {
|
||||
showEdit.value = true
|
||||
await nextTick()
|
||||
editRef.value?.open('edit')
|
||||
editRef.value?.getDetail(data)
|
||||
}
|
||||
const multipleSelection = ref<type_monitor_slow[]>([])
|
||||
const handleSelectionChange = (val: type_monitor_slow[]) => {
|
||||
console.log(val)
|
||||
multipleSelection.value = val
|
||||
}
|
||||
|
||||
const handleDelete = async (Id: number) => {
|
||||
try {
|
||||
await feedback.confirm('确定要删除?')
|
||||
await monitor_slow_delete(Id)
|
||||
feedback.msgSuccess('删除成功')
|
||||
getLists()
|
||||
} catch (error) {}
|
||||
}
|
||||
// 批量删除
|
||||
const deleteBatch = async () => {
|
||||
if (multipleSelection.value.length === 0) {
|
||||
feedback.msgError('请选择要删除的数据')
|
||||
return
|
||||
}
|
||||
try {
|
||||
await feedback.confirm('确定要删除?')
|
||||
await monitor_slow_delete_batch({
|
||||
Ids: multipleSelection.value.map((item) => item.Id).join(',')
|
||||
})
|
||||
feedback.msgSuccess('删除成功')
|
||||
getLists()
|
||||
} catch (error) {}
|
||||
}
|
||||
|
||||
const exportFile = async () => {
|
||||
try {
|
||||
await feedback.confirm('确定要导出?')
|
||||
await monitor_slow_export_file(queryParams)
|
||||
} catch (error) {}
|
||||
}
|
||||
getLists()
|
||||
</script>
|
||||
Reference in New Issue
Block a user