优化定时任务、在线用户、生成器

This commit is contained in:
zjl 2024-12-12 13:59:20 +08:00
parent 7d9d2c17b7
commit 53bd8f422c
5 changed files with 98 additions and 26 deletions

View File

@ -16,7 +16,7 @@ export const columns = [
{ {
title: '任务名称', title: '任务名称',
key: 'jobName', key: 'jobName',
width: 150, width: 200,
}, },
{ {
title: '任务分组', title: '任务分组',

View File

@ -132,20 +132,20 @@
const emit = defineEmits(['success', 'update:visible']); const emit = defineEmits(['success', 'update:visible']);
const formRef = ref(); const formRef = ref();
const message = useMessage();
/** /**
* 定义表单参数 * 定义表单参数
*/ */
const message = useMessage();
const formData = reactive({ const formData = reactive({
id: '', id: '',
jobName: '', jobName: '',
jobAlias: '', jobAlias: '',
jobGroup: undefined, jobGroup: '',
jobTrigger: '', jobTrigger: '',
status: undefined, status: '',
cronExpression: '', cronExpression: '',
executePolicy: undefined, executePolicy: '',
isSync: 0, isSync: 0,
url: '', url: '',
note: '', note: '',
@ -166,11 +166,10 @@
default: 0, default: 0,
}, },
}); });
const [modalRegister, { openModal, setSubLoading }] = useModal({
title: props.jobId ? '编辑任务' : '添加任务', /**
subBtuText: '确定', * 定义数据源
width: 600, */
});
const jobGroupList = [{ label: 'DEFAULT', value: 'DEFAULT' }]; const jobGroupList = [{ label: 'DEFAULT', value: 'DEFAULT' }];
const statusList = [ const statusList = [
{ label: '未发布', value: 0 }, { label: '未发布', value: 0 },
@ -183,6 +182,16 @@
{ label: '执行一次', value: 2 }, { label: '执行一次', value: 2 },
{ label: '放弃执行', value: 3 }, { label: '放弃执行', value: 3 },
]; ];
/**
* 定义模态
*/
const [modalRegister, { openModal, setSubLoading }] = useModal({
title: props.jobId ? '编辑任务' : '添加任务',
subBtuText: '确定',
width: 600,
});
/** /**
* 执行提交 * 执行提交
*/ */
@ -229,7 +238,10 @@
setFormData(); setFormData();
} }
}); });
//
/**
* 定义函数
*/
defineExpose({ defineExpose({
openModal, openModal,
}); });

View File

@ -27,7 +27,6 @@
</template> </template>
新建 新建
</n-button> </n-button>
<n-button <n-button
type="error" type="error"
@click="handleDelete" @click="handleDelete"
@ -72,13 +71,14 @@
} from '@/api/monitor/job'; } from '@/api/monitor/job';
import { columns } from './columns'; import { columns } from './columns';
import { PlusOutlined, DeleteOutlined, FormOutlined, FieldTimeOutlined } from '@vicons/antd'; import { PlusOutlined, DeleteOutlined, FormOutlined, FieldTimeOutlined } from '@vicons/antd';
import CreateModal from './CreateModal.vue';
import editDialog from './edit.vue'; import editDialog from './edit.vue';
import jobLog from './log/index.vue'; import jobLog from './log/index.vue';
import { basicModal, useModal } from '@/components/Modal';
import { schemas } from './querySchemas'; import { schemas } from './querySchemas';
import { renderIcon } from '@/utils'; import { renderIcon } from '@/utils';
/**
* 定义参数
*/
const message = useMessage(); const message = useMessage();
const dialog = useDialog(); const dialog = useDialog();
const basicTableRef = ref(); const basicTableRef = ref();
@ -87,14 +87,18 @@
const editLogVisible = ref(false); const editLogVisible = ref(false);
const jobId = ref(0); const jobId = ref(0);
const rowKeys = ref([]); const rowKeys = ref([]);
const exportLoading = ref(false);
const showModal = ref(false); /**
* 定义查询参数
*/
const formParams = reactive({ const formParams = reactive({
jobName: '', jobName: '',
status: '', status: '',
}); });
/**
* 定义操作栏
*/
const actionColumn = reactive({ const actionColumn = reactive({
width: 350, width: 350,
title: '操作', title: '操作',
@ -166,24 +170,36 @@
}, },
}); });
function addTable() { /**
showModal.value = true; * 加载数据列表
} * @param res 参数
*/
const loadDataTable = async (res) => { const loadDataTable = async (res) => {
rowKeys.value = []; rowKeys.value = [];
const result = await getJobList({ ...formParams, ...res }); const result = await getJobList({ ...formParams, ...res });
return result; return result;
}; };
/**
* 数据行选中事件
* @param keys 参数
*/
function onCheckedRow(keys) { function onCheckedRow(keys) {
rowKeys.value = keys; rowKeys.value = keys;
} }
/**
* 刷新数据列表
* @param noRefresh 参数
*/
function reloadTable(noRefresh = '') { function reloadTable(noRefresh = '') {
basicTableRef.value.reload(noRefresh ? {} : { pageNo: 1 }); basicTableRef.value.reload(noRefresh ? {} : { pageNo: 1 });
} }
/**
* 执行提交表单
* @param values 参数
*/
function handleSubmit(values: Recordable) { function handleSubmit(values: Recordable) {
for (const key in formParams) { for (const key in formParams) {
formParams[key] = ''; formParams[key] = '';
@ -194,6 +210,10 @@
reloadTable(); reloadTable();
} }
/**
* 执行重置
* @param values 参数
*/
function handleReset(values: Recordable) { function handleReset(values: Recordable) {
for (const key in formParams) { for (const key in formParams) {
formParams[key] = ''; formParams[key] = '';
@ -204,6 +224,9 @@
reloadTable(); reloadTable();
} }
/**
* 执行注册
*/
const [register, {}] = useForm({ const [register, {}] = useForm({
gridProps: { cols: '1 s:1 m:2 l:3 xl:4 2xl:4' }, gridProps: { cols: '1 s:1 m:2 l:3 xl:4 2xl:4' },
labelWidth: 110, labelWidth: 110,
@ -219,6 +242,7 @@
await nextTick(); await nextTick();
createModalRef.value.openModal(); createModalRef.value.openModal();
}; };
/** /**
* 执行编辑 * 执行编辑
*/ */
@ -228,6 +252,7 @@
await nextTick(); await nextTick();
createModalRef.value.openModal(); createModalRef.value.openModal();
} }
/** /**
* 执行变更状态 * 执行变更状态
* @param record 参数 * @param record 参数
@ -244,6 +269,7 @@
}, },
}); });
}; };
/** /**
* 执行一次 * 执行一次
*/ */
@ -259,6 +285,7 @@
}, },
}); });
}; };
/** /**
* 执行查看日志 * 执行查看日志
* @param record 参数 * @param record 参数
@ -269,6 +296,7 @@
editLogVisible.value = true; editLogVisible.value = true;
jobId.value = record.id; jobId.value = record.id;
}; };
/** /**
* 执行删除 * 执行删除
* @param id 参数 * @param id 参数

View File

@ -13,8 +13,7 @@
:style="{ minHeight: fwbHeight + 'px' }" :style="{ minHeight: fwbHeight + 'px' }"
:paginate-single-page="false" :paginate-single-page="false"
:data="onlineTableData.slice((pager.page - 1) * pager.size, pager.page * pager.size)" :data="onlineTableData.slice((pager.page - 1) * pager.size, pager.page * pager.size)"
> />
</n-data-table>
<pagination <pagination
style="justify-content: flex-end" style="justify-content: flex-end"
class="mt-10 flex" class="mt-10 flex"
@ -33,6 +32,8 @@
import { useMessage, useDialog } from 'naive-ui'; import { useMessage, useDialog } from 'naive-ui';
import { TableAction } from '@/components/Table'; import { TableAction } from '@/components/Table';
const onlineTableData = ref([]); const onlineTableData = ref([]);
const message = useMessage();
const dialog = useDialog();
/** /**
* 定义查询参数 * 定义查询参数
@ -41,8 +42,10 @@
ipAddr: '', ipAddr: '',
username: '', username: '',
}); });
const message = useMessage();
const dialog = useDialog(); /**
* 定义操作栏
*/
const columns = [ const columns = [
{ {
title: '序号', title: '序号',
@ -111,6 +114,7 @@
}, },
}, },
]; ];
/** /**
* 定义分页参数 * 定义分页参数
*/ */

View File

@ -52,16 +52,21 @@
const message = useMessage(); const message = useMessage();
const dialog = useDialog(); const dialog = useDialog();
const basicTableRef = ref(); const basicTableRef = ref();
const rowKeys = ref([]); const rowKeys = ref([]);
/**
* 定义查询参数
*/
const formParams = reactive({ const formParams = reactive({
tableName: '', tableName: '',
tableComment: '', tableComment: '',
}); });
/**
* 定义操作栏
*/
const actionColumn = reactive({ const actionColumn = reactive({
width: 200, width: 100,
title: '操作', title: '操作',
align: 'center', align: 'center',
key: 'action', key: 'action',
@ -82,20 +87,36 @@
}, },
}); });
/**
* 加载数据列表
* @param res 参数
*/
const loadDataTable = async (res) => { const loadDataTable = async (res) => {
rowKeys.value = []; rowKeys.value = [];
const result = await getTableList({ ...formParams, ...res }); const result = await getTableList({ ...formParams, ...res });
return result; return result;
}; };
/**
* 数据行选中事件
* @param keys 参数
*/
function onCheckedRow(keys) { function onCheckedRow(keys) {
rowKeys.value = keys; rowKeys.value = keys;
} }
/**
* 刷新数据列表
* @param noRefresh 参数
*/
function reloadTable(noRefresh = '') { function reloadTable(noRefresh = '') {
basicTableRef.value.reload(noRefresh ? {} : { pageNo: 1 }); basicTableRef.value.reload(noRefresh ? {} : { pageNo: 1 });
} }
/**
* 执行提交表单
* @param values 参数
*/
function handleSubmit(values: Recordable) { function handleSubmit(values: Recordable) {
for (const key in formParams) { for (const key in formParams) {
formParams[key] = ''; formParams[key] = '';
@ -106,6 +127,10 @@
reloadTable(); reloadTable();
} }
/**
* 执行重置
* @param values 参数
*/
function handleReset(values: Recordable) { function handleReset(values: Recordable) {
for (const key in formParams) { for (const key in formParams) {
formParams[key] = ''; formParams[key] = '';
@ -116,6 +141,9 @@
reloadTable(); reloadTable();
} }
/**
* 执行注册
*/
const [register, {}] = useForm({ const [register, {}] = useForm({
gridProps: { cols: '1 s:1 m:2 l:3 xl:4 2xl:4' }, gridProps: { cols: '1 s:1 m:2 l:3 xl:4 2xl:4' },
labelWidth: 100, labelWidth: 100,