// ==================== 基础查询参数 ====================
export interface PageQuery {
  pageNum: number;
  pageSize: number;
}

// ==================== 配置相关 ====================
export interface OrgConfigQuery extends PageQuery {
  configCode?: string;
  configName?: string;
  branchType?: string;
  seriesCode?: string;
  version?: string;
  status?: number;
}

export interface OrgConfigVO {
  id?: string | number;
  configCode: string;
  branchType: string;
  seriesCode: string;
  version: string;
  configName: string;
  effectiveDate: string;
  expireDate?: string;
  status: number;
  description?: string;
  branchTypeName?: string;
  seriesName?: string;
  usageCount?: number;
}

export interface OrgConfigForm {
  id?: string | number;
  configCode: string;
  branchType: string;
  seriesCode: string;
  version: string;
  configName: string;
  effectiveDate: string;
  expireDate?: string;
  status: number;
  description?: string;
}

// ==================== 层级相关 ====================
export interface OrgLevelDefVO {
  id?: string | number;
  configCode: string;
  levelCode: string;
  levelName: string;
  levelOrder: number;
  parentLevel?: string;
  namePattern?: string;
  codeLength?: number;
  codeRule?: string;
  autoCreate: boolean;
  sortOrder?: number;
  status: number;
}

export interface OrgLevelDefForm {
  id?: string | number;
  configCode: string;
  levelCode: string;
  levelName: string;
  levelOrder: number;
  parentLevel?: string;
  namePattern?: string;
  codeLength?: number;
  codeRule?: string;
  autoCreate: boolean;
  sortOrder?: number;
  status: number;
}

export interface OrgLevelDefQuery extends PageQuery {
  configCode?: string;
  levelCode?: string;
  levelName?: string;
}

// ==================== 职级相关 ====================
export interface GradeDefVO {
  id?: string | number;
  configCode: string;
  gradeCode: string;
  gradeName: string;
  gradeLevel: number;
  gradeType: string;
  seriesCode: string;
  seriesName?: string;
  orgLevels: string[];
  sortOrder?: number;
  status: number;
}

export interface GradeDefForm {
  id?: string | number;
  configCode: string;
  gradeCode: string;
  gradeName: string;
  gradeLevel: number;
  gradeType: string;
  seriesCode: string;
  seriesName?: string;
  orgLevels: string[];
  sortOrder?: number;
  status: number;
}

export interface GradeDefQuery extends PageQuery {
  configCode?: string;
  gradeCode?: string;
  gradeName?: string;
  gradeType?: string;
}

export interface AutoCreateRuleForm {
  id?: string | number;
  configCode: string;
  triggerLevel: string;
  createLevel: string;
  createOrder: number;
  nameTemplate: string;
  codeSuffix?: string;
  relationType: string;
  parentRelation: string;
  status: number;
}

export interface AutoCreateRuleQuery extends PageQuery {
  configCode?: string;
  triggerLevel?: string;
  createLevel?: string;
}

// ==================== 配置使用关系相关 ====================
export interface ConfigUsageVO {
  id?: string | number;
  manageCom: string;
  branchType: string;
  configCode: string;
  seriesCode: string;
  version: string;
  effectiveDate: string;
  expireDate?: string;
  status: number;
  manageComName?: string;
  branchTypeName?: string;
  seriesName?: string;
}

export interface ConfigUsageForm {
  id?: string | number;
  manageCom: string;
  branchType: string;
  configCode: string;
  seriesCode: string;
  version: string;
  effectiveDate: string;
  expireDate?: string;
  status: number;
}

export interface ConfigUsageQuery extends PageQuery {
  manageCom?: string;
  branchType?: string;
  configCode?: string;
}

// ==================== 序列类型相关 ====================
export interface SeriesTypeDefVO {
  seriesCode: string;
  seriesName: string;
  branchType?: string;
}

// ==================== 表单状态 ====================
export interface ConfigFormState {
  mode: 'add' | 'edit' | 'view';
  visible: boolean;
  loading?: boolean;
  configCode?: string;
}

export interface DetailModalState {
  visible: boolean;
  activeTab?: string;
  configCode?: string;
  config?: OrgConfigVO;
}

// ==================== 空表单常量 ====================
export const EMPTY_ORG_CONFIG_FORM: OrgConfigForm = {
  configCode: '',
  branchType: '',
  seriesCode: '',
  configName: '',
  version: '',
  effectiveDate: '',
  status: 1
};

export const EMPTY_LEVEL_DEF_FORM: OrgLevelDefForm = {
  configCode: '',
  levelCode: '',
  levelName: '',
  levelOrder: 1,
  autoCreate: false,
  status: 1
};

export const EMPTY_GRADE_DEF_FORM: GradeDefForm = {
  configCode: '',
  gradeCode: '',
  gradeName: '',
  gradeLevel: 1,
  gradeType: '2',
  seriesCode: '',
  orgLevels: [],
  status: 1
};

export const EMPTY_AUTO_CREATE_RULE_FORM: AutoCreateRuleForm = {
  configCode: '',
  triggerLevel: '',
  createLevel: '',
  createOrder: 1,
  nameTemplate: '',
  relationType: '1',
  parentRelation: '1',
  status: 1
};
