113 lines
2.7 KiB
TypeScript
113 lines
2.7 KiB
TypeScript
|
import { addDialog } from '@/components/BaseDialog/index';
|
||
|
import SchedulersDialog from '@/views/monitor/schedulers/schedulers-dialog.vue';
|
||
|
import { useSchedulersStore } from '@/store/monitor/schedulers.ts';
|
||
|
import { h, ref } from 'vue';
|
||
|
import { messageBox } from '@/utils/message';
|
||
|
import type { FormItemProps } from '@/views/monitor/schedulers/utils/types';
|
||
|
import { $t } from '@/plugins/i18n';
|
||
|
|
||
|
export const formRef = ref();
|
||
|
const schedulersStore = useSchedulersStore();
|
||
|
|
||
|
/**
|
||
|
* * 搜索初始化Schedulers视图
|
||
|
*/
|
||
|
export async function onSearch() {
|
||
|
schedulersStore.loading = true;
|
||
|
await schedulersStore.getSchedulersList();
|
||
|
schedulersStore.loading = false;
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* * 添加Schedulers视图
|
||
|
*/
|
||
|
export function onAdd() {
|
||
|
addDialog({
|
||
|
title: `${$t('add_new')}${$t('schedulers')}`,
|
||
|
width: '30%',
|
||
|
props: {
|
||
|
formInline: {
|
||
|
jobName: undefined,
|
||
|
jobGroup: undefined,
|
||
|
description: undefined,
|
||
|
jobClassName: undefined,
|
||
|
cronExpression: undefined,
|
||
|
triggerName: undefined,
|
||
|
triggerState: undefined,
|
||
|
},
|
||
|
},
|
||
|
draggable: true,
|
||
|
fullscreenIcon: true,
|
||
|
closeOnClickModal: false,
|
||
|
contentRenderer: () => h(SchedulersDialog, { ref: formRef }),
|
||
|
beforeSure: (done, { options }) => {
|
||
|
const form = options.props.formInline as FormItemProps;
|
||
|
formRef.value.formRef.validate(async (valid: any) => {
|
||
|
if (!valid) return;
|
||
|
|
||
|
const result = await schedulersStore.addSchedulers(form);
|
||
|
if (!result) return;
|
||
|
done();
|
||
|
await onSearch();
|
||
|
});
|
||
|
},
|
||
|
});
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* * 更新Schedulers视图
|
||
|
* @param row
|
||
|
*/
|
||
|
export function onUpdate(row: any) {
|
||
|
addDialog({
|
||
|
title: `${$t('modify')}${$t('schedulers')}`,
|
||
|
width: '30%',
|
||
|
props: {
|
||
|
formInline: {
|
||
|
jobName: row.jobName,
|
||
|
jobGroup: row.jobGroup,
|
||
|
description: row.description,
|
||
|
jobClassName: row.jobClassName,
|
||
|
cronExpression: row.cronExpression,
|
||
|
triggerName: row.triggerName,
|
||
|
triggerState: row.triggerState,
|
||
|
},
|
||
|
},
|
||
|
draggable: true,
|
||
|
fullscreenIcon: true,
|
||
|
closeOnClickModal: false,
|
||
|
contentRenderer: () => h(SchedulersDialog, { ref: formRef }),
|
||
|
beforeSure: (done, { options }) => {
|
||
|
const form = options.props.formInline as FormItemProps;
|
||
|
formRef.value.formRef.validate(async (valid: any) => {
|
||
|
if (!valid) return;
|
||
|
|
||
|
const result = await schedulersStore.updateSchedulers({ ...form, id: row.id });
|
||
|
if (!result) return;
|
||
|
done();
|
||
|
await onSearch();
|
||
|
});
|
||
|
},
|
||
|
});
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* * 删除Schedulers视图
|
||
|
*/
|
||
|
export const onDelete = async (row: any) => {
|
||
|
const id = row.id;
|
||
|
|
||
|
// 是否确认删除
|
||
|
const result = await messageBox({
|
||
|
title: $t('confirm_delete'),
|
||
|
showMessage: false,
|
||
|
confirmMessage: undefined,
|
||
|
cancelMessage: $t('cancel_delete'),
|
||
|
});
|
||
|
if (!result) return;
|
||
|
|
||
|
// 删除数据
|
||
|
await schedulersStore.deleteSchedulers([id]);
|
||
|
await onSearch();
|
||
|
};
|