fix(任务中心): 项目组织列表初始化

This commit is contained in:
baiqi 2024-10-29 18:20:41 +08:00 committed by 刘瑞斌
parent 09cbe06af9
commit 0c3e3b1020
8 changed files with 182 additions and 287 deletions

View File

@ -12,6 +12,7 @@ import {
organizationExecuteTaskDetailListUrl,
organizationExecuteTaskListUrl,
organizationExecuteTaskStatisticsUrl,
organizationProjectOptionsUrl,
organizationScheduleListUrl,
organizationScheduleSwitchUrl,
organizationStopTaskDetailUrl,
@ -21,6 +22,7 @@ import {
} from '@/api/requrls/taskCenter';
import type { CommonList, TableQueryParams } from '@/models/common';
import type { ProjectListItem } from '@/models/setting/project';
import type {
TaskCenterBatchParams,
TaskCenterBatchTaskReportItem,
@ -120,3 +122,8 @@ export function organizationEditCron(cron: string, id: string) {
export function organizationBatchTaskReportList(data: TaskCenterBatchParams) {
return MSR.post<CommonList<TaskCenterBatchTaskReportItem>>({ url: organizationBatchTaskReportUrl, data });
}
// 组织任务-项目列表
export function organizationProjectOptions() {
return MSR.get<ProjectListItem[]>({ url: organizationProjectOptionsUrl });
}

View File

@ -12,6 +12,8 @@ import {
systemExecuteTaskDetailListUrl,
systemExecuteTaskListUrl,
systemExecuteTaskStatisticsUrl,
systemOrgOptionsUrl,
systemProjectOptionsUrl,
systemResourcePoolStatusUrl,
systemScheduleListUrl,
systemScheduleSwitchUrl,
@ -22,6 +24,8 @@ import {
} from '@/api/requrls/taskCenter';
import type { CommonList, TableQueryParams } from '@/models/common';
import type { ProjectListItem } from '@/models/setting/project';
import type { OrganizationListItem } from '@/models/setting/user';
import type {
TaskCenterBatchParams,
TaskCenterBatchTaskReportItem,
@ -127,3 +131,13 @@ export function systemEditCron(cron: string, id: string) {
export function systemBatchTaskReportList(data: TaskCenterBatchParams) {
return MSR.post<CommonList<TaskCenterBatchTaskReportItem>>({ url: systemBatchTaskReportUrl, data });
}
// 系统任务-组织列表
export function systemOrgOptions() {
return MSR.get<OrganizationListItem[]>({ url: systemOrgOptionsUrl });
}
// 系统任务-项目列表
export function systemProjectOptions() {
return MSR.get<ProjectListItem[]>({ url: systemProjectOptionsUrl });
}

View File

@ -37,6 +37,8 @@ export const systemBatchOpenTaskUrl = '/system/task-center/schedule/batch-enable
export const systemBatchCloseTaskUrl = '/system/task-center/schedule/batch-disable'; // 系统任务-系统后台任务-批量关闭任务
export const systemEditCronUrl = '/system/task-center/schedule/update-cron'; // 系统任务-系统后台任务-编辑 cron 表达式
export const systemBatchTaskReportUrl = '/system/task-center/exec-task/batch/page'; // 系统任务-批量任务报告列表
export const systemProjectOptionsUrl = '/system/task-center/project/options'; // 系统任务-项目列表
export const systemOrgOptionsUrl = '/system/task-center/organization/options'; // 系统任务-组织列表
export const organizationScheduleListUrl = '/organization/task-center/schedule/page'; // 组织任务-系统后台任务列表
export const organizationExecuteTaskListUrl = '/organization/task-center/exec-task/page'; // 组织任务-执行任务列表
@ -56,3 +58,4 @@ export const organizationBatchOpenTaskUrl = '/organization/task-center/schedule/
export const organizationBatchCloseTaskUrl = '/organization/task-center/schedule/batch-disable'; // 组织任务-系统后台任务-批量关闭任务
export const organizationEditCronUrl = '/organization/task-center/schedule/update-cron'; // 组织任务-系统后台任务-编辑 cron 表达式
export const organizationBatchTaskReportUrl = '/organization/task-center/exec-task/batch/page'; // 组织任务-批量任务报告列表
export const organizationProjectOptionsUrl = '/organization/task-center/project/options'; // 组织任务-项目列表

View File

@ -202,7 +202,7 @@
orgListLoading.value = true;
const res = await getOrgOptions();
originOrgList.value = res || [];
appStore.setOrdList(originOrgList.value);
appStore.setOrgList(originOrgList.value);
} catch (error) {
// eslint-disable-next-line no-console
console.log(error);

View File

@ -231,7 +231,7 @@ const useAppStore = defineStore('app', {
/**
*
*/
setOrdList(orgList: { id: string; name: string }[]) {
setOrgList(orgList: { id: string; name: string }[]) {
this.orgList = orgList;
},
/**

View File

@ -113,6 +113,7 @@
getOrganizationExecuteTaskDetailList,
getOrgTaskCenterResourcePools,
organizationBatchStopTaskDetail,
organizationProjectOptions,
organizationStopTaskDetail,
organizationTaskOrder,
} from '@/api/modules/taskCenter/organization';
@ -128,6 +129,8 @@
getSystemExecuteTaskDetailList,
getSystemTaskCenterResourcePools,
systemBatchStopTaskDetail,
systemOrgOptions,
systemProjectOptions,
systemStopTaskDetail,
systemTaskOrder,
} from '@/api/modules/taskCenter/system';
@ -309,113 +312,67 @@
},
];
if (props.type === 'system') {
columns.splice(
2,
0,
{
title: 'common.belongProject',
dataIndex: 'projectName',
showTooltip: true,
width: 200,
showDrag: true,
filterConfig: {
options: appStore.projectList.map((item) => ({
label: item.name,
value: item.id,
})),
filterSlotName: FilterSlotNameEnum.GLOBAL_TASK_CENTER_BELONG_PROJECT,
},
},
{
title: 'common.belongOrg',
dataIndex: 'organizationName',
showTooltip: true,
width: 200,
showDrag: true,
filterConfig: {
options: appStore.orgList.map((item) => ({
label: item.name,
value: item.id,
})),
filterSlotName: FilterSlotNameEnum.GLOBAL_TASK_CENTER_BELONG_PROJECT,
},
}
);
} else if (props.type === 'org') {
columns.splice(2, 0, {
title: 'common.belongProject',
dataIndex: 'projectName',
showTooltip: true,
width: 200,
showDrag: true,
filterConfig: {
options: appStore.projectList.map((item) => ({
label: item.name,
value: item.id,
})),
filterSlotName: FilterSlotNameEnum.GLOBAL_TASK_CENTER_BELONG_PROJECT,
},
});
}
watch(
() => [appStore.projectList, appStore.orgList],
() => {
if (appStore.projectList.length > 0 && appStore.orgList.length > 0) {
if (props.type === 'system') {
columns.splice(
2,
2,
{
title: 'common.belongProject',
dataIndex: 'projectName',
showTooltip: true,
width: 200,
showDrag: true,
filterConfig: {
options: appStore.projectList.map((item) => ({
label: item.name,
value: item.id,
})),
filterSlotName: FilterSlotNameEnum.GLOBAL_TASK_CENTER_BELONG_PROJECT,
},
},
{
title: 'common.belongOrg',
dataIndex: 'organizationName',
showTooltip: true,
width: 200,
showDrag: true,
filterConfig: {
options: appStore.orgList.map((item) => ({
label: item.name,
value: item.id,
})),
filterSlotName: FilterSlotNameEnum.GLOBAL_TASK_CENTER_BELONG_PROJECT,
},
}
);
} else if (props.type === 'org') {
columns.splice(2, 1, {
async function initProjectAndOrgs() {
try {
if (props.type === 'system') {
const projects = await systemProjectOptions();
const orgs = await systemOrgOptions();
columns.splice(
2,
0,
{
title: 'common.belongProject',
dataIndex: 'projectName',
showTooltip: true,
width: 200,
showDrag: true,
width: 200,
filterConfig: {
options: appStore.projectList.map((item) => ({
options: projects.map((item) => ({
label: item.name,
value: item.id,
})),
filterSlotName: FilterSlotNameEnum.GLOBAL_TASK_CENTER_BELONG_PROJECT,
},
});
}
tableRef.value?.initColumn(columns);
},
{
title: 'common.belongOrg',
dataIndex: 'organizationName',
showTooltip: true,
showDrag: true,
width: 200,
filterConfig: {
options: orgs.map((item) => ({
label: item.name,
value: item.id,
})),
filterSlotName: FilterSlotNameEnum.GLOBAL_TASK_CENTER_BELONG_PROJECT,
},
}
);
} else if (props.type === 'org') {
const projects = await organizationProjectOptions();
columns.splice(2, 0, {
title: 'common.belongProject',
dataIndex: 'projectName',
showTooltip: true,
showDrag: true,
width: 200,
filterConfig: {
options: projects.map((item) => ({
label: item.name,
value: item.id,
})),
filterSlotName: FilterSlotNameEnum.GLOBAL_TASK_CENTER_BELONG_PROJECT,
},
});
}
} catch (error) {
// eslint-disable-next-line no-console
console.log(error);
}
);
}
await initProjectAndOrgs();
function getCurrentPermission(action: 'STOP') {
return {

View File

@ -189,6 +189,7 @@
organizationBatchDeleteTask,
organizationBatchStopTask,
organizationDeleteTask,
organizationProjectOptions,
organizationStopTask,
} from '@/api/modules/taskCenter/organization';
import {
@ -205,6 +206,8 @@
systemBatchDeleteTask,
systemBatchStopTask,
systemDeleteTask,
systemOrgOptions,
systemProjectOptions,
systemStopTask,
} from '@/api/modules/taskCenter/system';
import { useI18n } from '@/hooks/useI18n';
@ -371,113 +374,67 @@
},
];
if (props.type === 'system') {
columns.splice(
2,
0,
{
title: 'common.belongProject',
dataIndex: 'projectName',
showTooltip: true,
showDrag: true,
width: 200,
filterConfig: {
options: appStore.projectList.map((item) => ({
label: item.name,
value: item.id,
})),
filterSlotName: FilterSlotNameEnum.GLOBAL_TASK_CENTER_BELONG_PROJECT,
},
},
{
title: 'common.belongOrg',
dataIndex: 'organizationName',
showTooltip: true,
showDrag: true,
width: 200,
filterConfig: {
options: appStore.orgList.map((item) => ({
label: item.name,
value: item.id,
})),
filterSlotName: FilterSlotNameEnum.GLOBAL_TASK_CENTER_BELONG_PROJECT,
},
}
);
} else if (props.type === 'org') {
columns.splice(2, 0, {
title: 'common.belongProject',
dataIndex: 'projectName',
showTooltip: true,
showDrag: true,
width: 200,
filterConfig: {
options: appStore.projectList.map((item) => ({
label: item.name,
value: item.id,
})),
filterSlotName: FilterSlotNameEnum.GLOBAL_TASK_CENTER_BELONG_PROJECT,
},
});
}
watch(
() => [appStore.projectList, appStore.orgList],
() => {
if (appStore.projectList.length > 0 && appStore.orgList.length > 0) {
if (props.type === 'system') {
columns.splice(
2,
2,
{
title: 'common.belongProject',
dataIndex: 'projectName',
showTooltip: true,
width: 200,
showDrag: true,
filterConfig: {
options: appStore.projectList.map((item) => ({
label: item.name,
value: item.id,
})),
filterSlotName: FilterSlotNameEnum.GLOBAL_TASK_CENTER_BELONG_PROJECT,
},
},
{
title: 'common.belongOrg',
dataIndex: 'organizationName',
showTooltip: true,
width: 200,
showDrag: true,
filterConfig: {
options: appStore.orgList.map((item) => ({
label: item.name,
value: item.id,
})),
filterSlotName: FilterSlotNameEnum.GLOBAL_TASK_CENTER_BELONG_PROJECT,
},
}
);
} else if (props.type === 'org') {
columns.splice(2, 1, {
async function initProjectAndOrgs() {
try {
if (props.type === 'system') {
const projects = await systemProjectOptions();
const orgs = await systemOrgOptions();
columns.splice(
2,
0,
{
title: 'common.belongProject',
dataIndex: 'projectName',
showTooltip: true,
width: 200,
showDrag: true,
width: 200,
filterConfig: {
options: appStore.projectList.map((item) => ({
options: projects.map((item) => ({
label: item.name,
value: item.id,
})),
filterSlotName: FilterSlotNameEnum.GLOBAL_TASK_CENTER_BELONG_PROJECT,
},
});
}
tableRef.value?.initColumn(columns);
},
{
title: 'common.belongOrg',
dataIndex: 'organizationName',
showTooltip: true,
showDrag: true,
width: 200,
filterConfig: {
options: orgs.map((item) => ({
label: item.name,
value: item.id,
})),
filterSlotName: FilterSlotNameEnum.GLOBAL_TASK_CENTER_BELONG_PROJECT,
},
}
);
} else if (props.type === 'org') {
const projects = await organizationProjectOptions();
columns.splice(2, 0, {
title: 'common.belongProject',
dataIndex: 'projectName',
showTooltip: true,
showDrag: true,
width: 200,
filterConfig: {
options: projects.map((item) => ({
label: item.name,
value: item.id,
})),
filterSlotName: FilterSlotNameEnum.GLOBAL_TASK_CENTER_BELONG_PROJECT,
},
});
}
} catch (error) {
// eslint-disable-next-line no-console
console.log(error);
}
);
}
await initProjectAndOrgs();
function getCurrentPermission(action: 'STOP' | 'DELETE') {
return {

View File

@ -96,6 +96,7 @@
organizationBatchOpenTask,
organizationDeleteSchedule,
organizationEditCron,
organizationProjectOptions,
organizationScheduleSwitch,
} from '@/api/modules/taskCenter/organization';
import {
@ -112,6 +113,8 @@
systemBatchOpenTask,
systemDeleteSchedule,
systemEditCron,
systemOrgOptions,
systemProjectOptions,
systemScheduleSwitch,
} from '@/api/modules/taskCenter/system';
import { useI18n } from '@/hooks/useI18n';
@ -264,113 +267,67 @@
width: 110,
},
];
if (props.type === 'system') {
columns.splice(
2,
0,
{
title: 'common.belongProject',
dataIndex: 'projectName',
showTooltip: true,
width: 200,
showDrag: true,
filterConfig: {
options: appStore.projectList.map((item) => ({
label: item.name,
value: item.id,
})),
filterSlotName: FilterSlotNameEnum.GLOBAL_TASK_CENTER_BELONG_PROJECT,
},
},
{
title: 'common.belongOrg',
dataIndex: 'organizationName',
showTooltip: true,
width: 200,
showDrag: true,
filterConfig: {
options: appStore.orgList.map((item) => ({
label: item.name,
value: item.id,
})),
filterSlotName: FilterSlotNameEnum.GLOBAL_TASK_CENTER_BELONG_PROJECT,
},
}
);
} else if (props.type === 'org') {
columns.splice(2, 0, {
title: 'common.belongProject',
dataIndex: 'projectName',
showTooltip: true,
width: 200,
showDrag: true,
filterConfig: {
options: appStore.projectList.map((item) => ({
label: item.name,
value: item.id,
})),
filterSlotName: FilterSlotNameEnum.GLOBAL_TASK_CENTER_BELONG_PROJECT,
},
});
}
watch(
() => [appStore.projectList, appStore.orgList],
() => {
if (appStore.projectList.length > 0 && appStore.orgList.length > 0) {
if (props.type === 'system') {
columns.splice(
2,
2,
{
title: 'common.belongProject',
dataIndex: 'projectName',
showTooltip: true,
width: 200,
showDrag: true,
filterConfig: {
options: appStore.projectList.map((item) => ({
label: item.name,
value: item.id,
})),
filterSlotName: FilterSlotNameEnum.GLOBAL_TASK_CENTER_BELONG_PROJECT,
},
},
{
title: 'common.belongOrg',
dataIndex: 'organizationName',
showTooltip: true,
width: 200,
showDrag: true,
filterConfig: {
options: appStore.orgList.map((item) => ({
label: item.name,
value: item.id,
})),
filterSlotName: FilterSlotNameEnum.GLOBAL_TASK_CENTER_BELONG_PROJECT,
},
}
);
} else if (props.type === 'org') {
columns.splice(2, 1, {
async function initProjectAndOrgs() {
try {
if (props.type === 'system') {
const projects = await systemProjectOptions();
const orgs = await systemOrgOptions();
columns.splice(
2,
0,
{
title: 'common.belongProject',
dataIndex: 'projectName',
showTooltip: true,
width: 200,
showDrag: true,
width: 200,
filterConfig: {
options: appStore.projectList.map((item) => ({
options: projects.map((item) => ({
label: item.name,
value: item.id,
})),
filterSlotName: FilterSlotNameEnum.GLOBAL_TASK_CENTER_BELONG_PROJECT,
},
});
}
tableRef.value?.initColumn(columns);
},
{
title: 'common.belongOrg',
dataIndex: 'organizationName',
showTooltip: true,
showDrag: true,
width: 200,
filterConfig: {
options: orgs.map((item) => ({
label: item.name,
value: item.id,
})),
filterSlotName: FilterSlotNameEnum.GLOBAL_TASK_CENTER_BELONG_PROJECT,
},
}
);
} else if (props.type === 'org') {
const projects = await organizationProjectOptions();
columns.splice(2, 0, {
title: 'common.belongProject',
dataIndex: 'projectName',
showTooltip: true,
showDrag: true,
width: 200,
filterConfig: {
options: projects.map((item) => ({
label: item.name,
value: item.id,
})),
filterSlotName: FilterSlotNameEnum.GLOBAL_TASK_CENTER_BELONG_PROJECT,
},
});
}
} catch (error) {
// eslint-disable-next-line no-console
console.log(error);
}
);
}
await initProjectAndOrgs();
await tableStore.initColumn(TableKeyEnum.TASK_CENTER_SYSTEM_TASK, columns, 'drawer');