mirror of
https://github.com/fastapiadmin/FastapiAdmin.git
synced 2026-09-26 06:19:04 +00:00
refactor(frontend): 清理无用依赖和配置,优化代码格式
移除未使用的依赖如vxe-table和lodash-es 删除冗余的lint和prettier配置文件 统一代码格式,简化模板语法 调整表格列宽和操作按钮布局 修复profile页面性别默认值问题
This commit is contained in:
+78
-79
@@ -9,10 +9,14 @@
|
||||
<el-card shadow="hover">
|
||||
<template #header>
|
||||
<div class="flex items-center gap-2">
|
||||
<el-icon><Monitor /></el-icon>
|
||||
<el-icon>
|
||||
<Monitor />
|
||||
</el-icon>
|
||||
<span>Redis监控信息</span>
|
||||
<el-tooltip content="展示Redis监控信息详情">
|
||||
<el-icon><QuestionFilled /></el-icon>
|
||||
<el-icon>
|
||||
<QuestionFilled />
|
||||
</el-icon>
|
||||
</el-tooltip>
|
||||
</div>
|
||||
</template>
|
||||
@@ -36,7 +40,8 @@
|
||||
{{ cache.info?.used_memory_human || '-' }}
|
||||
</el-descriptions-item>
|
||||
<el-descriptions-item label="使用CPU">
|
||||
{{ cache.info?.used_cpu_user_children ? parseFloat(cache.info.used_cpu_user_children).toFixed(2) : '-' }}
|
||||
{{ cache.info?.used_cpu_user_children ? parseFloat(cache.info.used_cpu_user_children).toFixed(2) : '-'
|
||||
}}
|
||||
</el-descriptions-item>
|
||||
<el-descriptions-item label="内存配置">
|
||||
{{ cache.info?.maxmemory_human || '-' }}
|
||||
@@ -51,7 +56,8 @@
|
||||
{{ cache.db_size || 0 }}
|
||||
</el-descriptions-item>
|
||||
<el-descriptions-item label="网络入口/出口">
|
||||
{{ `${cache.info?.instantaneous_input_kbps || 0}kps/${cache.info?.instantaneous_output_kbps || 0}kps` }}
|
||||
{{ `${cache.info?.instantaneous_input_kbps || 0}kps/${cache.info?.instantaneous_output_kbps || 0}kps`
|
||||
}}
|
||||
</el-descriptions-item>
|
||||
</el-descriptions>
|
||||
</el-card>
|
||||
@@ -62,25 +68,33 @@
|
||||
<el-card shadow="hover">
|
||||
<template #header>
|
||||
<div class="flex items-center gap-2">
|
||||
<el-icon><Stopwatch /></el-icon>
|
||||
<el-icon>
|
||||
<Stopwatch />
|
||||
</el-icon>
|
||||
<span class="title">命令统计</span>
|
||||
<el-tooltip content="展示命令统计详情">
|
||||
<el-icon><QuestionFilled /></el-icon>
|
||||
<el-icon>
|
||||
<QuestionFilled />
|
||||
</el-icon>
|
||||
</el-tooltip>
|
||||
</div>
|
||||
</template>
|
||||
<div ref="commandstats" class="chart-container" />
|
||||
</el-card>
|
||||
</el-col>
|
||||
|
||||
|
||||
<el-col :span="12" class="mt-4">
|
||||
<el-card shadow="hover">
|
||||
<template #header>
|
||||
<div class="flex items-center gap-2">
|
||||
<el-icon><Stopwatch /></el-icon>
|
||||
<el-icon>
|
||||
<Stopwatch />
|
||||
</el-icon>
|
||||
<span>内存信息</span>
|
||||
<el-tooltip content="展示内存信息详情">
|
||||
<el-icon><QuestionFilled /></el-icon>
|
||||
<el-icon>
|
||||
<QuestionFilled />
|
||||
</el-icon>
|
||||
</el-tooltip>
|
||||
</div>
|
||||
</template>
|
||||
@@ -95,14 +109,18 @@
|
||||
<el-row :gutter="16">
|
||||
<!-- 缓存列表 -->
|
||||
<el-col :span="8">
|
||||
<el-card :loading="loading" shadow="hover" >
|
||||
<el-card :loading="loading" shadow="hover">
|
||||
<template #header>
|
||||
<div class="flex justify-between items-center">
|
||||
<div class="flex items-center gap-2">
|
||||
<el-icon><Tickets /></el-icon>
|
||||
<el-icon>
|
||||
<Tickets />
|
||||
</el-icon>
|
||||
<span class="flex items-center gap-2">缓存列表</span>
|
||||
<el-tooltip content="展示缓存列表详情">
|
||||
<el-icon><QuestionFilled /></el-icon>
|
||||
<el-icon>
|
||||
<QuestionFilled />
|
||||
</el-icon>
|
||||
</el-tooltip>
|
||||
</div>
|
||||
<div>
|
||||
@@ -110,16 +128,10 @@
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
<el-table
|
||||
:loading="loading"
|
||||
:data="cacheNames"
|
||||
row-key="cache_name"
|
||||
height="600"
|
||||
border
|
||||
>
|
||||
<template #empty>
|
||||
<el-empty :image-size="80" description="暂无数据" />
|
||||
</template>
|
||||
<el-table :loading="loading" :data="cacheNames" row-key="cache_name" height="600" border>
|
||||
<template #empty>
|
||||
<el-empty :image-size="80" description="暂无数据" />
|
||||
</template>
|
||||
<el-table-column prop="cache_name" label="缓存名称" show-overflow-tooltip>
|
||||
<template #default="{ row }">
|
||||
<el-button type="primary" link @click="getCacheKeyList(row)">{{ row.cache_name }}</el-button>
|
||||
@@ -128,12 +140,7 @@
|
||||
<el-table-column prop="remark" label="备注" show-overflow-tooltip />
|
||||
<el-table-column label="操作" width="60" align="center">
|
||||
<template #default="{ row }">
|
||||
<el-popconfirm
|
||||
class="box-item"
|
||||
:title="`确认删除缓存 ${row.cache_name} 吗?`"
|
||||
placement="top"
|
||||
@confirm="handleClearCacheName(row)"
|
||||
>
|
||||
<el-popconfirm class="box-item" :title="`确认删除缓存 ${row.cache_name} 吗?`" placement="top" @confirm="handleClearCacheName(row)">
|
||||
<template #reference>
|
||||
<el-button type="danger" size="small" link icon="delete" />
|
||||
</template>
|
||||
@@ -146,14 +153,18 @@
|
||||
|
||||
<!-- 键名列表 -->
|
||||
<el-col :span="8">
|
||||
<el-card :loading="loading" shadow="hover">
|
||||
<el-card :loading="loading" shadow="hover">
|
||||
<template #header>
|
||||
<div class="flex justify-between items-center">
|
||||
<div class="flex items-center gap-2">
|
||||
<el-icon><Key /></el-icon>
|
||||
<el-icon>
|
||||
<Key />
|
||||
</el-icon>
|
||||
<span class="flex items-center gap-2">键名列表</span>
|
||||
<el-tooltip content="展示键名列表详情">
|
||||
<el-icon><QuestionFilled /></el-icon>
|
||||
<el-icon>
|
||||
<QuestionFilled />
|
||||
</el-icon>
|
||||
</el-tooltip>
|
||||
</div>
|
||||
<div>
|
||||
@@ -161,29 +172,19 @@
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
<el-table
|
||||
:loading="subLoading"
|
||||
:data="cacheKeys.map(key => ({ cacheKey: key }))"
|
||||
height="600"
|
||||
row-key="cacheKey"
|
||||
border
|
||||
>
|
||||
<el-table :loading="subLoading" :data="cacheKeys.map(key => ({ cacheKey: key }))" height="600" row-key="cacheKey" border>
|
||||
<template #empty>
|
||||
<el-empty :image-size="80" description="暂无数据" />
|
||||
</template>
|
||||
<el-table-column prop="cacheKey" label="缓存键名" show-overflow-tooltip>
|
||||
<template #default="{ row }">
|
||||
<el-button type="primary" link @click="handleCacheValue(row.cacheKey)">{{ row.cacheKey }}</el-button>
|
||||
<el-button type="primary" link @click="handleCacheValue(row.cacheKey)">{{ row.cacheKey
|
||||
}}</el-button>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="操作" width="60" align="center">
|
||||
<template #default="{ row }">
|
||||
<el-popconfirm
|
||||
class="box-item"
|
||||
:title="`确认删除键 ${row.cacheKey} 吗?`"
|
||||
placement="top"
|
||||
@confirm="handleClearCacheKey(row.cacheKey)"
|
||||
>
|
||||
<el-popconfirm class="box-item" :title="`确认删除键 ${row.cacheKey} 吗?`" placement="top" @confirm="handleClearCacheKey(row.cacheKey)">
|
||||
<template #reference>
|
||||
<el-button type="danger" size="small" link icon="delete" />
|
||||
</template>
|
||||
@@ -196,14 +197,18 @@
|
||||
|
||||
<!-- 缓存内容 -->
|
||||
<el-col :span="8">
|
||||
<el-card :loading="loading" shadow="hover">
|
||||
<el-card :loading="loading" shadow="hover">
|
||||
<template #header>
|
||||
<div class="flex justify-between items-center">
|
||||
<div class="flex items-center gap-2">
|
||||
<el-icon><Key /></el-icon>
|
||||
<el-icon>
|
||||
<Key />
|
||||
</el-icon>
|
||||
<span class="flex items-center gap-2">缓存内容</span>
|
||||
<el-tooltip content="展示缓存内容详情">
|
||||
<el-icon><QuestionFilled /></el-icon>
|
||||
<el-icon>
|
||||
<QuestionFilled />
|
||||
</el-icon>
|
||||
</el-tooltip>
|
||||
</div>
|
||||
<div>
|
||||
@@ -219,12 +224,7 @@
|
||||
<el-input v-model="cacheForm.cache_key" readonly />
|
||||
</el-form-item>
|
||||
<el-form-item label="缓存内容:">
|
||||
<el-input
|
||||
v-model="cacheForm.cache_value"
|
||||
type="textarea"
|
||||
:rows="18"
|
||||
readonly
|
||||
/>
|
||||
<el-input v-model="cacheForm.cache_value" type="textarea" :rows="18" readonly />
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
</el-card>
|
||||
@@ -236,7 +236,7 @@
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import CacheAPI, {type CacheInfo, type CacheForm, type CacheMonitor, type RedisInfo } from "@/api/monitor/cache";
|
||||
import CacheAPI, { type CacheInfo, type CacheForm, type CacheMonitor, type RedisInfo } from "@/api/monitor/cache";
|
||||
import * as echarts from 'echarts';
|
||||
|
||||
// 响应式状态定义
|
||||
@@ -254,7 +254,7 @@ const cache = ref<CacheMonitor>({
|
||||
});
|
||||
const cacheForm = ref<CacheForm>({
|
||||
cache_name: '',
|
||||
cache_key: '',
|
||||
cache_key: '',
|
||||
cache_value: ''
|
||||
});
|
||||
|
||||
@@ -291,7 +291,7 @@ const refreshCacheNames = () => {
|
||||
|
||||
// 清理缓存名称
|
||||
const handleClearCacheName = async (row: CacheInfo) => {
|
||||
try {
|
||||
try {
|
||||
await CacheAPI.deleteCacheName(row.cache_name);
|
||||
refreshCacheNames();
|
||||
} catch (error) {
|
||||
@@ -301,10 +301,10 @@ const handleClearCacheName = async (row: CacheInfo) => {
|
||||
|
||||
// 缓存键名相关方法
|
||||
const getCacheKeyList = async (row?: CacheInfo) => {
|
||||
try {
|
||||
try {
|
||||
const cacheName = row?.cache_name || nowCacheName.value;
|
||||
if (!cacheName) return;
|
||||
|
||||
|
||||
subLoading.value = true;
|
||||
const response = await CacheAPI.getCacheKeys(cacheName);
|
||||
cacheKeys.value = response.data.data;
|
||||
@@ -327,8 +327,8 @@ const refreshCacheKeys = () => {
|
||||
};
|
||||
|
||||
// 清理缓存键名
|
||||
async function handleClearCacheKey (cacheKey: string) {
|
||||
try {
|
||||
async function handleClearCacheKey(cacheKey: string) {
|
||||
try {
|
||||
await CacheAPI.deleteCacheKey(cacheKey);
|
||||
getCacheKeyList();
|
||||
} catch (error) {
|
||||
@@ -337,7 +337,7 @@ async function handleClearCacheKey (cacheKey: string) {
|
||||
};
|
||||
|
||||
// 缓存内容相关方法
|
||||
async function handleCacheValue (cacheKey: string) {
|
||||
async function handleCacheValue(cacheKey: string) {
|
||||
try {
|
||||
loading.value = true;
|
||||
const response = await CacheAPI.getCacheValue(nowCacheName.value, cacheKey)
|
||||
@@ -360,17 +360,17 @@ const handleClearCacheAll = async () => {
|
||||
type: 'warning',
|
||||
}
|
||||
)
|
||||
.then(async () => {
|
||||
return await CacheAPI.deleteCacheAll();
|
||||
})
|
||||
.then(() => {
|
||||
getCacheNameList();
|
||||
})
|
||||
.catch((error) => {
|
||||
if (error !== 'cancel') {
|
||||
console.error('清理全部缓存失败:', error);
|
||||
}
|
||||
});
|
||||
.then(async () => {
|
||||
return await CacheAPI.deleteCacheAll();
|
||||
})
|
||||
.then(() => {
|
||||
getCacheNameList();
|
||||
})
|
||||
.catch((error) => {
|
||||
if (error !== 'cancel') {
|
||||
console.error('清理全部缓存失败:', error);
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
// 监控数据获取
|
||||
@@ -379,11 +379,11 @@ const getInfo = async () => {
|
||||
loading.value = true;
|
||||
const response = await CacheAPI.getCacheInfo()
|
||||
cache.value = response.data.data || {
|
||||
info: {},
|
||||
command_stats: [],
|
||||
dbSize: 0
|
||||
};
|
||||
initCharts();
|
||||
info: {},
|
||||
command_stats: [],
|
||||
dbSize: 0
|
||||
};
|
||||
initCharts();
|
||||
} catch (error) {
|
||||
console.error('获取缓存监控数据失败:', error);
|
||||
} finally {
|
||||
@@ -452,7 +452,6 @@ onUnmounted(() => {
|
||||
</script>
|
||||
|
||||
<style scoped lang="scss">
|
||||
|
||||
.chart-container {
|
||||
height: 365px;
|
||||
}
|
||||
|
||||
@@ -57,8 +57,7 @@
|
||||
<div class="data-table__toolbar">
|
||||
<div class="data-table__toolbar--actions">
|
||||
<el-button type="success" icon="plus" @click="handleOpenDialog('create')">新增</el-button>
|
||||
<el-button type="danger" icon="delete" :disabled="selectIds.length === 0"
|
||||
@click="handleDelete(selectIds)">批量删除</el-button>
|
||||
<el-button type="danger" icon="delete" :disabled="selectIds.length === 0" @click="handleDelete(selectIds)">批量删除</el-button>
|
||||
</div>
|
||||
<div class="data-table__toolbar--tools">
|
||||
<el-tooltip content="导出">
|
||||
@@ -70,67 +69,41 @@
|
||||
<el-tooltip content="刷新">
|
||||
<el-button type="primary" icon="refresh" circle @click="handleRefresh" />
|
||||
</el-tooltip>
|
||||
<el-tooltip content="列表筛选">
|
||||
<el-dropdown trigger="click">
|
||||
<el-button type="default" icon="operation" circle />
|
||||
<template #dropdown>
|
||||
<el-dropdown-menu>
|
||||
<el-dropdown-item v-for="column in tableColumns" :key="column.prop"
|
||||
:command="column">
|
||||
<el-checkbox v-model="column.show">{{ column.label }}</el-checkbox>
|
||||
</el-dropdown-item>
|
||||
</el-dropdown-menu>
|
||||
</template>
|
||||
</el-dropdown>
|
||||
</el-tooltip>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 表格区域:系统配置列表 -->
|
||||
<el-table ref="dataTableRef" v-loading="loading" :data="pageTableData" highlight-current-row
|
||||
class="data-table__content" height="450" border stripe @selection-change="handleSelectionChange">
|
||||
<el-table ref="dataTableRef" v-loading="loading" :data="pageTableData" class="data-table__content"
|
||||
highlight-current-row height="450" border stripe @selection-change="handleSelectionChange">
|
||||
<template #empty>
|
||||
<el-empty :image-size="80" description="暂无数据" />
|
||||
</template>
|
||||
<el-table-column v-if="tableColumns.find(col => col.prop === 'selection')?.show" type="selection"
|
||||
min-width="55" align="center" />
|
||||
<el-table-column v-if="tableColumns.find(col => col.prop === 'index')?.show" type="index" fixed
|
||||
label="序号" min-width="60" />
|
||||
<el-table-column v-if="tableColumns.find(col => col.prop === 'name')?.show" key="name" label="任务名称"
|
||||
prop="name" min-width="140" />
|
||||
<el-table-column v-if="tableColumns.find(col => col.prop === 'func')?.show" key="func" label="执行函数"
|
||||
prop="func" min-width="140" />
|
||||
<el-table-column v-if="tableColumns.find(col => col.prop === 'trigger')?.show" key="trigger" label="触发器"
|
||||
prop="trigger" min-width="100" />
|
||||
<el-table-column v-if="tableColumns.find(col => col.prop === 'jobstore')?.show" key="jobstore"
|
||||
label="存储器" prop="jobstore" min-width="100" />
|
||||
<el-table-column v-if="tableColumns.find(col => col.prop === 'executor')?.show" key="executor"
|
||||
label="执行器" prop="executor" min-width="100" />
|
||||
<el-table-column v-if="tableColumns.find(col => col.prop === 'coalesce')?.show" key="coalesce"
|
||||
label="并发执行" prop="coalesce" min-width="100">
|
||||
<el-table-column type="selection" align="center" min-width="55" />
|
||||
<el-table-column type="index" label="序号" fixed min-width="60" />
|
||||
<el-table-column label="任务名称" prop="name" min-width="140" />
|
||||
<el-table-column label="执行函数" prop="func" min-width="140" />
|
||||
<el-table-column label="触发器" prop="trigger" min-width="100" />
|
||||
<el-table-column label="存储器" prop="jobstore" min-width="100" />
|
||||
<el-table-column label="执行器" prop="executor" min-width="100" />
|
||||
<el-table-column label="并发执行" prop="coalesce" min-width="100">
|
||||
<template #default="scope">
|
||||
<el-tag :type="scope.row.coalesce === true ? 'success' : 'danger'">
|
||||
{{ scope.row.coalesce === true ? "是" : "否" }}
|
||||
</el-tag>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column v-if="tableColumns.find(col => col.prop === 'status')?.show" key="status" label="状态"
|
||||
prop="status" min-width="100">
|
||||
<el-table-column label="状态" prop="status" min-width="100">
|
||||
<template #default="scope">
|
||||
<el-tag :type="scope.row.status === true ? 'success' : 'danger'">
|
||||
{{ scope.row.status === true ? "启用" : "停用" }}
|
||||
</el-tag>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column v-if="tableColumns.find(col => col.prop === 'description')?.show" key="description"
|
||||
label="描述" prop="description" min-width="100" />
|
||||
<el-table-column v-if="tableColumns.find(col => col.prop === 'created_at')?.show" key="created_at"
|
||||
label="创建时间" prop="created_at" min-width="200" sortable />
|
||||
<el-table-column v-if="tableColumns.find(col => col.prop === 'updated_at')?.show" key="updated_at"
|
||||
label="更新时间" prop="updated_at" min-width="200" sortable />
|
||||
<el-table-column label="描述" prop="description" min-width="100" />
|
||||
<el-table-column label="创建时间" prop="created_at" min-width="200" sortable />
|
||||
<el-table-column label="更新时间" prop="updated_at" min-width="200" sortable />
|
||||
|
||||
<el-table-column v-if="tableColumns.find(col => col.prop === 'operation')?.show" fixed="right"
|
||||
label="操作" min-width="240">
|
||||
<el-table-column fixed="right" label="操作" min-width="240">
|
||||
<template #default="scope">
|
||||
<el-button type="info" size="small" link icon="document"
|
||||
@click="handleOpenDialog('detail', scope.row.id)">详情</el-button>
|
||||
@@ -139,9 +112,7 @@
|
||||
<el-button type="danger" size="small" link icon="delete"
|
||||
@click="handleDelete([scope.row.id])">删除</el-button>
|
||||
<el-dropdown trigger="click">
|
||||
<el-button type="default" size="small" link icon="ArrowDown">
|
||||
更多
|
||||
</el-button>
|
||||
<el-button type="default" size="small" link icon="ArrowDown">更多</el-button>
|
||||
<template #dropdown>
|
||||
<el-dropdown-menu>
|
||||
<el-dropdown-item icon="Check" @click="handleOption(scope.row, 1)">暂停</el-dropdown-item>
|
||||
@@ -156,8 +127,7 @@
|
||||
|
||||
<!-- 分页区域 -->
|
||||
<template #footer>
|
||||
<pagination v-model:total="total" v-model:page="queryFormData.page_no"
|
||||
v-model:limit="queryFormData.page_size" @pagination="loadingData" />
|
||||
<pagination v-model:total="total" v-model:page="queryFormData.page_no" v-model:limit="queryFormData.page_size" @pagination="loadingData" />
|
||||
</template>
|
||||
</el-card>
|
||||
|
||||
@@ -175,30 +145,29 @@
|
||||
<el-descriptions-item label="位置参数" :span="2">{{ detailFormData.args }}</el-descriptions-item>
|
||||
<el-descriptions-item label="关键字参数" :span="2">{{ detailFormData.kwargs }}</el-descriptions-item>
|
||||
<el-descriptions-item label="并发执行" :span="2">
|
||||
<el-tag v-if="detailFormData.coalesce === true" type="success">是</el-tag>
|
||||
<el-tag v-else type="danger">否</el-tag>
|
||||
<el-tag :type="detailFormData.coalesce ? 'success' : 'danger'">
|
||||
{{ detailFormData.coalesce ? '是' : '否' }}
|
||||
</el-tag>
|
||||
</el-descriptions-item>
|
||||
<el-descriptions-item label="最大实例数" :span="2">{{ detailFormData.max_instances
|
||||
}}</el-descriptions-item>
|
||||
<el-descriptions-item label="触发器参数" :span="2">{{ detailFormData.trigger_args
|
||||
}}</el-descriptions-item>
|
||||
<el-descriptions-item label="状态" :span="2">
|
||||
<el-tag :type="detailFormData.status ? 'success' : 'danger'">
|
||||
{{ detailFormData.status ? '启用' : '停用' }}
|
||||
</el-tag>
|
||||
</el-descriptions-item>
|
||||
<el-descriptions-item label="最大实例数" :span="2">{{ detailFormData.max_instances }}</el-descriptions-item>
|
||||
<el-descriptions-item label="触发器参数" :span="2">{{ detailFormData.trigger_args }}</el-descriptions-item>
|
||||
<el-descriptions-item label="开始时间" :span="2">{{ detailFormData.start_date }}</el-descriptions-item>
|
||||
<el-descriptions-item label="结束时间" :span="2">{{ detailFormData.end_date }}</el-descriptions-item>
|
||||
<el-descriptions-item label="日志信息" :span="2">{{ detailFormData.message }}</el-descriptions-item>
|
||||
<el-descriptions-item label="状态" :span="2">
|
||||
<el-tag v-if="detailFormData.status" type="success">启用</el-tag>
|
||||
<el-tag v-else type="danger">停用</el-tag>
|
||||
</el-descriptions-item>
|
||||
<el-descriptions-item label="描述" :span="2">{{ detailFormData.description }}</el-descriptions-item>
|
||||
<el-descriptions-item label="创建人" :span="2">{{ detailFormData.creator?.name }}</el-descriptions-item>
|
||||
<el-descriptions-item label="创建时间" :span="2">{{ detailFormData.created_at }}</el-descriptions-item>
|
||||
<el-descriptions-item label="更新时间" :span="2">{{ detailFormData.updated_at }}</el-descriptions-item>
|
||||
<el-descriptions-item label="创建人" :span="2">{{ detailFormData.creator?.name
|
||||
}}</el-descriptions-item>
|
||||
<el-descriptions-item label="描述" :span="4">{{ detailFormData.description }}</el-descriptions-item>
|
||||
</el-descriptions>
|
||||
</template>
|
||||
<!-- 新增、编辑表单 -->
|
||||
<template v-else>
|
||||
<el-form ref="dataFormRef" :model="formData" :rules="rules" label-suffix=":" label-width="100px">
|
||||
<el-form ref="dataFormRef" :model="formData" :rules="rules" label-suffix=":" label-width="100px" >
|
||||
<el-form-item label="任务名称" prop="name">
|
||||
<el-input v-model="formData.name" placeholder="请输入任务名称" :maxlength="50" />
|
||||
</el-form-item>
|
||||
@@ -232,7 +201,7 @@
|
||||
</el-form-item>
|
||||
<el-form-item label="最大实例数" prop="max_instances">
|
||||
<el-input-number v-model="formData.max_instances" controls-position="right" :min="1"
|
||||
:max="100" />
|
||||
:max="10" />
|
||||
</el-form-item>
|
||||
<el-form-item label="触发器" prop="trigger">
|
||||
<el-select v-model="formData.trigger" placeholder="请选择触发器">
|
||||
@@ -271,7 +240,6 @@
|
||||
value-format="YYYY-MM-DD HH:mm:ss" placeholder="请选择结束日期" style="width: 100%" />
|
||||
</el-form-item>
|
||||
|
||||
|
||||
<el-form-item label="描述" prop="description">
|
||||
<el-input v-model="formData.description" :rows="4" :maxlength="100" show-word-limit
|
||||
type="textarea" placeholder="请输入描述" />
|
||||
@@ -296,11 +264,10 @@
|
||||
<IntervalTab ref="intervalTabRef" />
|
||||
</el-dialog>
|
||||
|
||||
<!-- core组件是由element-plus封装的vue3组件,所以需要使用element-plus -->
|
||||
<!-- core组件 -->
|
||||
<el-dialog v-model="openCron">
|
||||
<Vue3CronPlusPicker :expression="expression" @hide="closeDialog" @fill="fillValue" />
|
||||
</el-dialog>
|
||||
|
||||
</div>
|
||||
</template>
|
||||
|
||||
@@ -314,9 +281,9 @@ import JobAPI, { JobTable, JobForm, JobPageQuery } from "@/api/monitor/job";
|
||||
import { ElMessage, ElMessageBox } from "element-plus";
|
||||
import { useDebounceFn } from "@vueuse/core";
|
||||
|
||||
import IntervalTab from '@/components/IntervalTab/index.vue';
|
||||
import 'vue3-cron-plus-picker/style.css';
|
||||
import { Vue3CronPlusPicker } from 'vue3-cron-plus-picker';
|
||||
import IntervalTab from "@/components/IntervalTab/index.vue";
|
||||
import "vue3-cron-plus-picker/style.css";
|
||||
import { Vue3CronPlusPicker } from "vue3-cron-plus-picker";
|
||||
import { useDictStore } from "@/store/index";
|
||||
|
||||
const dictStore = useDictStore();
|
||||
@@ -339,8 +306,8 @@ const isExpandable = ref(true);
|
||||
// const tableLoading = ref(false);
|
||||
// const openModal = ref(false);
|
||||
const openCron = ref(false);
|
||||
const cronMode = ref('create');
|
||||
const modalTitle = ref('');
|
||||
const cronMode = ref("create");
|
||||
const modalTitle = ref("");
|
||||
// const modalSubmitLoading = ref(false);
|
||||
// const detailStateLoading = ref(false);
|
||||
// const dataSource = ref<tableJobType[]>([]);
|
||||
@@ -354,23 +321,6 @@ const expression = ref();
|
||||
// 分页表单
|
||||
const pageTableData = ref<JobTable[]>([]);
|
||||
|
||||
// 表格列配置
|
||||
const tableColumns = ref([
|
||||
{ prop: 'selection', label: '选择框', show: true },
|
||||
{ prop: 'index', label: '序号', show: true },
|
||||
{ prop: 'name', label: '任务名称', show: true },
|
||||
{ prop: 'func', label: '执行函数', show: true },
|
||||
{ prop: 'trigger', label: '触发器', show: true },
|
||||
{ prop: 'jobstore', label: '存储器', show: true },
|
||||
{ prop: 'executor', label: '执行器', show: true },
|
||||
{ prop: 'coalesce', label: '并发执行', show: true },
|
||||
{ prop: 'status', label: '状态', show: true },
|
||||
{ prop: 'description', label: '描述', show: true },
|
||||
{ prop: 'created_at', label: '创建时间', show: true },
|
||||
{ prop: 'updated_at', label: '更新时间', show: true },
|
||||
{ prop: 'operation', label: '操作', show: true }
|
||||
])
|
||||
|
||||
// 详情表单
|
||||
const detailFormData = ref<JobTable>({});
|
||||
|
||||
@@ -402,13 +352,13 @@ const formData = reactive<JobForm>({
|
||||
status: undefined,
|
||||
message: undefined,
|
||||
description: undefined,
|
||||
})
|
||||
});
|
||||
|
||||
// 弹窗状态
|
||||
const dialogVisible = reactive({
|
||||
title: "",
|
||||
visible: false,
|
||||
type: 'create' as 'create' | 'update' | 'detail',
|
||||
type: "create" as "create" | "update" | "detail",
|
||||
});
|
||||
|
||||
// 表单验证规则
|
||||
@@ -434,11 +384,9 @@ async function loadingData() {
|
||||
const response = await JobAPI.getJobList(queryFormData);
|
||||
pageTableData.value = response.data.data.items;
|
||||
total.value = response.data.data.total;
|
||||
}
|
||||
catch (error: any) {
|
||||
} catch (error: any) {
|
||||
ElMessage.error(error.message);
|
||||
}
|
||||
finally {
|
||||
} finally {
|
||||
loading.value = false;
|
||||
}
|
||||
}
|
||||
@@ -475,14 +423,17 @@ async function handleCloseDialog() {
|
||||
}
|
||||
|
||||
// 打开弹窗
|
||||
async function handleOpenDialog(type: 'create' | 'update' | 'detail', id?: number) {
|
||||
async function handleOpenDialog(
|
||||
type: "create" | "update" | "detail",
|
||||
id?: number,
|
||||
) {
|
||||
dialogVisible.type = type;
|
||||
if (id) {
|
||||
const response = await JobAPI.getJobDetail(id);
|
||||
if (type === 'detail') {
|
||||
if (type === "detail") {
|
||||
dialogVisible.title = "任务详情";
|
||||
Object.assign(detailFormData.value, response.data.data);
|
||||
} else if (type === 'update') {
|
||||
} else if (type === "update") {
|
||||
dialogVisible.title = "修改任务";
|
||||
Object.assign(formData, response.data.data);
|
||||
}
|
||||
@@ -503,7 +454,7 @@ async function handleSubmit() {
|
||||
const id = formData.id;
|
||||
if (id) {
|
||||
try {
|
||||
await JobAPI.updateJob(formData)
|
||||
await JobAPI.updateJob(formData);
|
||||
dialogVisible.visible = false;
|
||||
resetForm();
|
||||
handleCloseDialog();
|
||||
@@ -515,7 +466,7 @@ async function handleSubmit() {
|
||||
}
|
||||
} else {
|
||||
try {
|
||||
await JobAPI.createJob(formData)
|
||||
await JobAPI.createJob(formData);
|
||||
dialogVisible.visible = false;
|
||||
resetForm();
|
||||
handleCloseDialog();
|
||||
@@ -536,73 +487,74 @@ async function handleDelete(ids: number[]) {
|
||||
confirmButtonText: "确定",
|
||||
cancelButtonText: "取消",
|
||||
type: "warning",
|
||||
}).then(async () => {
|
||||
try {
|
||||
loading.value = true;
|
||||
await JobAPI.deleteJob(ids);
|
||||
handleResetQuery();
|
||||
} catch (error: any) {
|
||||
ElMessage.error(error.message);
|
||||
} finally {
|
||||
loading.value = false;
|
||||
}
|
||||
}).catch(() => {
|
||||
ElMessage.info('已取消删除');
|
||||
});
|
||||
})
|
||||
.then(async () => {
|
||||
try {
|
||||
loading.value = true;
|
||||
await JobAPI.deleteJob(ids);
|
||||
handleResetQuery();
|
||||
} catch (error: any) {
|
||||
ElMessage.error(error.message);
|
||||
} finally {
|
||||
loading.value = false;
|
||||
}
|
||||
})
|
||||
.catch(() => {
|
||||
ElMessage.info("已取消删除");
|
||||
});
|
||||
}
|
||||
|
||||
// 导出
|
||||
async function handleExport() {
|
||||
ElMessageBox.confirm('是否确认导出当前任务配置?', '警告', {
|
||||
confirmButtonText: '确定',
|
||||
cancelButtonText: '取消',
|
||||
type: 'warning'
|
||||
}).then(async () => {
|
||||
try {
|
||||
loading.value = true;
|
||||
const body = {
|
||||
...queryFormData,
|
||||
page_no: 1,
|
||||
page_size: total.value
|
||||
};
|
||||
ElMessage.warning('正在导出数据,请稍候...');
|
||||
ElMessageBox.confirm("是否确认导出当前任务配置?", "警告", {
|
||||
confirmButtonText: "确定",
|
||||
cancelButtonText: "取消",
|
||||
type: "warning",
|
||||
})
|
||||
.then(async () => {
|
||||
try {
|
||||
loading.value = true;
|
||||
const body = {
|
||||
...queryFormData,
|
||||
page_no: 1,
|
||||
page_size: total.value,
|
||||
};
|
||||
ElMessage.warning("正在导出数据,请稍候...");
|
||||
|
||||
const response = await JobAPI.exportJob(body);
|
||||
const blob = new Blob([JSON.stringify(response.data.data)], { type: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;charset=UTF-8' });
|
||||
// 从响应头获取文件名
|
||||
const contentDisposition = response.headers['content-disposition'];
|
||||
let fileName = '系统配置.xlsx';
|
||||
if (contentDisposition) {
|
||||
const fileNameMatch = contentDisposition.match(/filename=(.*?)(;|$)/);
|
||||
if (fileNameMatch) {
|
||||
fileName = decodeURIComponent(fileNameMatch[1]);
|
||||
const response = await JobAPI.exportJob(body);
|
||||
const blob = new Blob([JSON.stringify(response.data.data)], {
|
||||
type: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;charset=UTF-8",
|
||||
});
|
||||
// 从响应头获取文件名
|
||||
const contentDisposition = response.headers["content-disposition"];
|
||||
let fileName = "系统配置.xlsx";
|
||||
if (contentDisposition) {
|
||||
const fileNameMatch = contentDisposition.match(/filename=(.*?)(;|$)/);
|
||||
if (fileNameMatch) {
|
||||
fileName = decodeURIComponent(fileNameMatch[1]);
|
||||
}
|
||||
}
|
||||
const url = window.URL.createObjectURL(blob);
|
||||
const link = document.createElement("a");
|
||||
link.href = url;
|
||||
link.download = fileName;
|
||||
document.body.appendChild(link);
|
||||
link.click();
|
||||
} catch (error: any) {
|
||||
ElMessage.error("文件处理失败", error.message);
|
||||
console.error("导出错误:", error);
|
||||
} finally {
|
||||
loading.value = false;
|
||||
}
|
||||
const url = window.URL.createObjectURL(blob);
|
||||
const link = document.createElement('a');
|
||||
link.href = url;
|
||||
link.download = fileName;
|
||||
document.body.appendChild(link);
|
||||
link.click();
|
||||
} catch (error: any) {
|
||||
ElMessage.error('文件处理失败', error.message);
|
||||
console.error('导出错误:', error);
|
||||
} finally {
|
||||
loading.value = false;
|
||||
}
|
||||
}).catch(() => {
|
||||
ElMessage.info('已取消导出');
|
||||
});
|
||||
}
|
||||
|
||||
const getOptions = async () => {
|
||||
const dictOptions = await dictStore.getDict(['sys_job_group', 'sys_job_executor', 'sys_job_function', 'sys_job_trigger'])
|
||||
return dictOptions
|
||||
})
|
||||
.catch(() => {
|
||||
ElMessage.info("已取消导出");
|
||||
});
|
||||
}
|
||||
|
||||
function openIntervalTabHandle(value: any) {
|
||||
openIntervalTab.value = true;
|
||||
modalTitle.value = value
|
||||
modalTitle.value = value;
|
||||
}
|
||||
|
||||
function handleIntervalConfirm() {
|
||||
@@ -613,15 +565,15 @@ function handleIntervalConfirm() {
|
||||
const handleShowCron = () => {
|
||||
openCron.value = true;
|
||||
expression.value = formData.trigger_args;
|
||||
}
|
||||
};
|
||||
|
||||
const closeDialog = () => {
|
||||
openCron.value = false;
|
||||
}
|
||||
};
|
||||
|
||||
const fillValue = (cronValue: string) => {
|
||||
formData.trigger_args = cronValue;
|
||||
}
|
||||
};
|
||||
|
||||
// 清空按钮操作
|
||||
const handleClear = () => {
|
||||
@@ -629,28 +581,30 @@ const handleClear = () => {
|
||||
confirmButtonText: "确定",
|
||||
cancelButtonText: "取消",
|
||||
type: "warning",
|
||||
}).then(async () => {
|
||||
try {
|
||||
loading.value = true;
|
||||
await JobAPI.clearJob();
|
||||
ElMessage.success("清空成功");
|
||||
handleResetQuery();
|
||||
} catch (error: any) {
|
||||
ElMessage.error(error.message);
|
||||
} finally {
|
||||
loading.value = false;
|
||||
}
|
||||
}).catch(() => {
|
||||
ElMessage.info('已取消清空');
|
||||
});
|
||||
}
|
||||
})
|
||||
.then(async () => {
|
||||
try {
|
||||
loading.value = true;
|
||||
await JobAPI.clearJob();
|
||||
ElMessage.success("清空成功");
|
||||
handleResetQuery();
|
||||
} catch (error: any) {
|
||||
ElMessage.error(error.message);
|
||||
} finally {
|
||||
loading.value = false;
|
||||
}
|
||||
})
|
||||
.catch(() => {
|
||||
ElMessage.info("已取消清空");
|
||||
});
|
||||
};
|
||||
|
||||
// 操作按钮:操作类型 1: 暂停 2: 恢复 3: 重启(暂时移除重启)
|
||||
const handleOption = (id: number, option: number) => {
|
||||
JobAPI.OptionJob({ id, option }).then(() => {
|
||||
loadingData();
|
||||
})
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
onMounted(() => {
|
||||
loadingData();
|
||||
|
||||
@@ -59,37 +59,26 @@
|
||||
</div>
|
||||
|
||||
<!-- 表格区域:系统配置列表 -->
|
||||
<el-table ref="dataTableRef" v-loading="loading" :data="pageTableData" highlight-current-row
|
||||
class="data-table__content" height="450" border stripe @selection-change="handleSelectionChange">
|
||||
<el-table ref="dataTableRef" v-loading="loading" :data="pageTableData" highlight-current-row class="data-table__content" height="450" border stripe @selection-change="handleSelectionChange">
|
||||
<template #empty>
|
||||
<el-empty :image-size="80" description="暂无数据" />
|
||||
</template>
|
||||
|
||||
<el-table-column v-if="tableColumns.find(col => col.prop === 'selection')?.show" type="selection" min-width="55"
|
||||
align="center" />
|
||||
<el-table-column v-if="tableColumns.find(col => col.prop === 'index')?.show" type="index" fixed label="序号"
|
||||
min-width="60" />
|
||||
<el-table-column v-if="tableColumns.find(col => col.prop === 'session_id')?.show" key="session_id" label="会话编号"
|
||||
prop="session_id" min-width="250" show-overflow-tooltip/>
|
||||
<el-table-column v-if="tableColumns.find(col => col.prop === 'ipaddr')?.show" key="ipaddr" label="IP地址"
|
||||
prop="ipaddr" min-width="120">
|
||||
<el-table-column v-if="tableColumns.find(col => col.prop === 'selection')?.show" type="selection" min-width="55" align="center" />
|
||||
<el-table-column v-if="tableColumns.find(col => col.prop === 'index')?.show" type="index" fixed label="序号" min-width="60" />
|
||||
<el-table-column v-if="tableColumns.find(col => col.prop === 'session_id')?.show" key="session_id" label="会话编号" prop="session_id" min-width="250" show-overflow-tooltip/>
|
||||
<el-table-column v-if="tableColumns.find(col => col.prop === 'ipaddr')?.show" key="ipaddr" label="IP地址" prop="ipaddr" min-width="120">
|
||||
<template #default="scope">
|
||||
<el-text>{{ scope.row.ipaddr }}</el-text>
|
||||
<CopyButton v-if="scope.row.ipaddr" :text="scope.row.ipaddr" style="margin-left: 2px" />
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column v-if="tableColumns.find(col => col.prop === 'name')?.show" key="name" label="用户名" prop="name"
|
||||
min-width="80" />
|
||||
<el-table-column v-if="tableColumns.find(col => col.prop === 'user_name')?.show" key="user_name" label="用户姓名"
|
||||
prop="user_name" min-width="80" />
|
||||
<el-table-column v-if="tableColumns.find(col => col.prop === 'login_location')?.show" key="login_location"
|
||||
label="登录位置" prop="login_location" min-width="80" />
|
||||
<el-table-column v-if="tableColumns.find(col => col.prop === 'os')?.show" key="os" label="操作系统" prop="os"
|
||||
min-width="80" />
|
||||
<el-table-column v-if="tableColumns.find(col => col.prop === 'login_time')?.show" key="login_time" label="登录时间"
|
||||
prop="login_time" min-width="180" />
|
||||
<el-table-column v-if="tableColumns.find(col => col.prop === 'operation')?.show" key="operation" fixed="right"
|
||||
label="操作" min-width="100">
|
||||
<el-table-column v-if="tableColumns.find(col => col.prop === 'name')?.show" key="name" label="用户名" prop="name" min-width="80" />
|
||||
<el-table-column v-if="tableColumns.find(col => col.prop === 'user_name')?.show" key="user_name" label="用户姓名" prop="user_name" min-width="80" />
|
||||
<el-table-column v-if="tableColumns.find(col => col.prop === 'login_location')?.show" key="login_location" label="登录位置" prop="login_location" min-width="80" />
|
||||
<el-table-column v-if="tableColumns.find(col => col.prop === 'os')?.show" key="os" label="操作系统" prop="os" min-width="80" />
|
||||
<el-table-column v-if="tableColumns.find(col => col.prop === 'login_time')?.show" key="login_time" label="登录时间" prop="login_time" min-width="180" />
|
||||
<el-table-column v-if="tableColumns.find(col => col.prop === 'operation')?.show" key="operation" fixed="right" label="操作" min-width="100">
|
||||
<template #default="scope">
|
||||
<el-button type="danger" size="small" link icon="delete" @click="handleSubmit(scope.row.session_id)">强退
|
||||
</el-button>
|
||||
@@ -99,8 +88,7 @@
|
||||
|
||||
<!-- 分页区域 -->
|
||||
<template #footer>
|
||||
<pagination v-model:total="total" v-model:page="queryFormData.page_no" v-model:limit="queryFormData.page_size"
|
||||
@pagination="loadingData" />
|
||||
<pagination v-model:total="total" v-model:page="queryFormData.page_no" v-model:limit="queryFormData.page_size" @pagination="loadingData" />
|
||||
</template>
|
||||
</el-card>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user