webapp/src/types/task.ts

96 lines
2.1 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

// 机器人的具体动作,现在是一个对象
export interface RobotAction {
name: string;
actionId: string;
}
// 参数选项接口
export interface ParameterOption {
label: string;
value: string;
}
// 动态参数配置接口
export interface DynamicParameter {
label?: string;
type?: 'Simple' | 'Select' | 'MultiSelect' | 'Text' | 'Number';
value: string | string[] | number | RobotAction;
required?: boolean;
options?: ParameterOption[];
placeholder?: string;
min?: number;
max?: number;
}
// 任务参数 - 支持动态配置
export interface TaskParameters {
[key: string]: DynamicParameter | undefined; // 支持扩展参数
}
// 核心任务对象
export interface Task {
id: string; // 唯一ID例如使用 uuid
name: string; // 任务名称, e.g., "炉前缓存区到热处理上料交接区运输"
label: string;
description?: string;
version: number;
templateName: string;
periodicTask: boolean;
ifEnable: number;
status: number; // 任务当前状态
createDate: string; // 创建时间
remark: string;
parameters: TaskParameters; // 任务的具体执行参数
detail?: TaskDetail; // 任务详情
}
// 任务详情
export interface TaskDetail {
inputParams: InputParam[];
outputParams: any[]; // 根据需要定义
rootBlock: any; // 根据需要定义
}
// 输入参数
export interface InputParam {
name: string;
type: string;
label: string;
required: boolean;
defaultValue: any;
remark: string;
min?: number;
max?: number;
step?: number;
}
// 运行任务请求体
export interface RunTaskRequest {
taskId: string;
params: Array<{
name: string;
type: string;
label: string;
required: boolean;
defaultValue: string;
remark: string;
}>;
source_type: number;
source_system: string;
source_device: string;
}
// 运行任务响应数据
export interface RunTaskResponseData {
taskRecordId: string;
status: number;
createTime: string;
}
// 运行任务API响应
export interface RunTaskApiResponse {
code: number;
message: string;
data: RunTaskResponseData;
}