/**
 * 种养殖任务表单类型定义
 */

/**
 * 任务类型枚举
 */
export type TaskType = 1 | 2 | 11 | 21; // 1:种植, 2:养殖, 11:种苗繁育, 21:种畜繁育

/**
 * 是否枚举
 */
export type YesNoType = '0' | '1'; // 0:否, 1:是

/**
 * 时间范围接口
 */
export interface TimeRange {
    plannedStartDate: string | null;
    plannedEndDate: string | null;
}

/**
 * 种植/养殖量信息接口
 */
export interface PlantInfo {
    plantingMgAmount: string | number | null;
    plantingMgUnit: string | null;
}

/**
 * 委托企业信息接口
 */
export interface DelegateInfo {
    cpyid: string;
    cusCode: string;
    cusName: string;
}

/**
 * 接种信息接口（用于种苗繁育）
 */
export interface InoculationInfo {
    inoculationAmount: string | number | null;
    inoculationUnit: string | null;
    inoculationDosage: string | number | null;
    inoculationDosageUnit: string | null;
}

/**
 * 基地地块信息接口（从Baseinfo组件中提取）
 */
export interface LandInfo {
    landType: number; // 1:地块, 2:圈舍, 3:培养架
    landName: string;
    area?: string | number;
    areaUnit?: string;
    capacityAmount?: string | number;
    capacityUnit?: string;
    baseId?: string;
}

/**
 * 基地选择数据接口（deawerData的类型）
 */
export interface BaseSelectData {
    baseName?: string;
    area?: string | number;
    areaUnit?: string;
    address?: string;
    adcodeName?: string;
    gapFlag?: any;
    swyqRes?: any;
    aloneChecked?: boolean;
    data: LandInfo[];
    checkBox?: any[];
    medicineName: string | null;
    swyqVarietyName: string | null;
    baseId?: string;
}

/**
 * 种养殖任务表单接口
 * 注意：这是一个联合类型，根据taskType不同，某些字段可能为可选或必填
 */
export interface PlantationTaskForm {
    // 通用字段（所有任务类型）
    deawerData: BaseSelectData | null;
    baseId: string | null;
    landIds: any[];
    taskType: TaskType | null;
    gapFlag: any;
    mgMethod: any;
    varietyId: string | null;
    plantationCode: string | null;
    plantationMethod: any;
    reproductionType: any;
    technicalFile: any[];
    plantingUnit: string | null;
    breedScale: string | number | null;
    queryType6: TimeRange;
    plantingMgUnit: any;
    plantingMgAmount: any;
    plantingAmount: string;
    remark: string | null;
    // 条件字段（根据任务类型可选）
    delegateFlag?: YesNoType; // 仅种苗繁育和种畜繁育
    delegateInfo: DelegateInfo; // 仅种苗繁育和种畜繁育
    delegate: any;
    plantationType?: any; // 仅种植和种苗繁育，当reproductionType=2时
    sowingMethod?: any; // 仅种植和种苗繁育，当reproductionType=2时
    transplantMethod?: any; // 仅种植和种苗繁育，当reproductionType=2时
    preCropId?: string | null; // 仅种植和种苗繁育
    inoculation?: InoculationInfo; // 仅种苗繁育，当landType=3时
    inoculationAmount: any;
    inoculationUnit: any;
    inoculationDosage: any;
    inoculationDosageUnit: any;
    cultureMediumFormula?: string | null; // 仅种苗繁育
    landFlag: any;
}

/**
 * 表单验证规则项接口
 */
export interface FormRuleItem {
    required?: boolean;
    message?: string;
    validator?: (rule: any, value: any, callback: any) => void;
    trigger?: string | string[];
}

/**
 * 表单验证规则接口
 */
export interface FormRules {
    [key: string]: FormRuleItem | FormRuleItem[];
}
