<template>
|
<div>
|
<BasicTable @register="registerTable">
|
<template #toolbar>
|
<a-button type="primary" @click="handleCreate"> 新增任务 </a-button>
|
</template>
|
<template #action="{ record }">
|
<TableAction
|
:actions="[
|
{
|
icon: 'clarity:info-standard-line',
|
tooltip: '查看任务详情',
|
onClick: handleView.bind(null, record),
|
name: undefined,
|
},
|
{
|
//开始计划
|
tooltip: '开始计划',
|
icon: 'startplan|svg',
|
onClick: handleStart.bind(null, record),
|
name: undefined,
|
},
|
{
|
//立即运行
|
tooltip: '立即运行',
|
icon: 'start|svg',
|
onClick: RunImmediately.bind(null, record),
|
name: undefined,
|
},
|
{
|
//停止运行
|
tooltip: '停止运行',
|
icon: 'stop|svg',
|
onClick: handleStop.bind(null, record),
|
name: undefined,
|
},
|
{
|
tooltip: '编辑',
|
icon: 'clarity:note-edit-line',
|
onClick: handleEdit.bind(null, record),
|
name: undefined,
|
},
|
{
|
tooltip: '删除',
|
icon: 'ant-design:delete-outlined',
|
color: 'error',
|
popConfirm: {
|
title: '是否确认删除?',
|
placement: 'left',
|
confirm: handleDelete.bind(null, record),
|
},
|
name: undefined,
|
},
|
]"
|
/>
|
</template>
|
</BasicTable>
|
<jobDrawer @register="registerDrawer" @success="handleSuccess" />
|
</div>
|
</template>
|
<script lang="ts" setup>
|
import { columns, searchFormSchema } from './job.data';
|
import jobDrawer from './jobDrawer.vue';
|
import { FluentJobParam } from '/@/api/tigerapi/model/tskModel';
|
import { getListByPage } from '/@/api/tigerapi/system';
|
import { AddTskJob, DeleteTsk_Job, ImmediateRun, StopTsk_Job } from '/@/api/tigerapi/tsk/tsk_job';
|
import { useDrawer } from '/@/components/Drawer';
|
import { BasicTable, TableAction, useTable } from '/@/components/Table';
|
import { useMessage } from '/@/hooks/web/useMessage';
|
import { useGo } from '/@/hooks/web/usePage';
|
import { useI18n } from '/@/hooks/web/useI18n';
|
|
const go = useGo();
|
const { t } = useI18n();
|
const { createErrorModal } = useMessage();
|
const [registerDrawer, { openDrawer }] = useDrawer();
|
|
const [registerTable, { reload }] = useTable({
|
title: '任务列表',
|
api: getListByPage,
|
searchInfo: {
|
TABLE_NAME: 'TSK_JOB',
|
// option: {
|
// //根据据点查询,必需带这个参数
|
// UserId: useUserStore().getUserInfo.userId,
|
// ByOrg: true,
|
// CurOrg: useUserStore().getUserInfo.orgCode,
|
// },
|
NeedInclude: true,
|
},
|
afterFetch: afterFetch,
|
columns,
|
formConfig: {
|
labelWidth: 120,
|
schemas: searchFormSchema,
|
},
|
useSearchForm: true,
|
showTableSetting: true,
|
bordered: true,
|
canResize: true,
|
showIndexColumn: false,
|
actionColumn: {
|
width: 205,
|
title: '操作',
|
dataIndex: 'action',
|
slots: { customRender: 'action' },
|
fixed: undefined,
|
},
|
});
|
|
/**
|
* @description: 请求之后对返回值进行处理
|
* @param {*} t
|
* @return {*}
|
*/
|
function afterFetch(t) {
|
console.log(t);
|
t.forEach((item) => {
|
item.NextRunTime = item.Triggers[0].NextRunTime;
|
});
|
return t;
|
}
|
|
/**
|
* 添加任务
|
*/
|
function handleCreate() {
|
openDrawer(true, {
|
isUpdate: false,
|
});
|
}
|
|
function handleEdit(record: Recordable) {
|
openDrawer(true, {
|
record,
|
isUpdate: true,
|
});
|
}
|
|
/**
|
* 详情页面
|
* @param {Recordable} record - 记录
|
*/
|
function handleView(record: Recordable) {
|
console.log(record.ID);
|
go('/job_detail/' + record.ID + ',' + record.JobName + '');
|
}
|
/**
|
* @description: 开始计划
|
* @param {*} record
|
* @return {*}
|
*/
|
function handleStart(record: Recordable) {
|
const param: FluentJobParam = {
|
AssemblyName: record.AssemblyName,
|
Args: JSON.parse(record.Triggers[0].Args),
|
DataType: record.JobType,
|
JobName: record.JobName,
|
Remark: record.Remark,
|
};
|
AddTskJob(param).then((action) => {
|
if (action.IsSuccessed) {
|
reload();
|
} else {
|
createErrorModal({
|
title: t('sys.api.errorTip'),
|
content: action.Message,
|
getContainer: () => document.body,
|
});
|
}
|
});
|
}
|
/**
|
* @description: 立即运行
|
* @param {*} record
|
* @return {*}
|
*/
|
function RunImmediately(record: Recordable) {
|
const param: FluentJobParam = {
|
AssemblyName: record.AssemblyName,
|
Args: JSON.parse(record.Triggers[0].Args),
|
DataType: record.JobType,
|
JobName: record.JobName,
|
Remark: record.Remark,
|
};
|
ImmediateRun(param).then((action) => {
|
if (action.IsSuccessed) {
|
reload();
|
} else {
|
createErrorModal({
|
title: t('sys.api.errorTip'),
|
content: action.Message,
|
getContainer: () => document.body,
|
});
|
}
|
});
|
}
|
|
/**
|
* @description: 立即停止
|
* @param {*} record
|
* @return {*}
|
*/
|
function handleStop(record: Recordable) {
|
const apiAction = StopTsk_Job(record);
|
apiAction.then((action) => {
|
if (action.IsSuccessed) {
|
reload();
|
}
|
});
|
}
|
|
/**
|
* @description: 删除任务
|
* @param {*} record
|
* @return {*}
|
*/
|
function handleDelete(record: Recordable) {
|
handleStop(record);
|
const apiAction = DeleteTsk_Job(record);
|
apiAction.then((action) => {
|
if (action.IsSuccessed) {
|
reload();
|
}
|
});
|
}
|
|
/**
|
* @description: 返回成功
|
* @return {*}
|
*/
|
function handleSuccess() {
|
reload();
|
}
|
</script>
|