import { CascaderOptionType, CascaderProps } from 'antd/lib/cascader';
import { SelectProps } from 'antd/lib/select';
import { AntTreeNodeProps, TreeProps } from 'antd/lib/tree';

export interface YGoodsCategoriesProps<VT> {
  originalProps: TreeProps | CascaderProps | SelectProps<VT>;
  config: YGoodsCategoriesConfig;
  /** 选择完成后的回调 */
  onChange: (value: any) => void;
}
export interface YGoodsCategoriesConfig {
  /* 模式选择 */
  mode?: 'singe' | 'cascader' | 'tree';
  /* 父级ID */
  parentNo?: string;
  /* 是否显示“全部类目”。仅 singe 模式可用 */
  isShowAll?: false | true;
  /* 全部类目 文案 */
  selectAllText?: string;
  /* 是否多选 */
  multiple?: boolean;
  /* 开启多选时的额外配置。目前只级联模式可用 */
  multipleConfig?: any | GoodsCategoriesMultipleConfigItem;
}

/* 级联选择时条目定义 */
export interface GoodsCategoriesCascaderModeOption extends CascaderOptionType {
  /* 类目ID */
  value: string;
  /* 类目名称 */
  label: string;
  /* API返回的原始数据.已进行(JSON.stringify) */
  orgData: string;
  /* 是否需要加载下一级 */
  isLeaf: true | false;
}

/* tree node props interface */
export interface GoodsCategoriesTreeNodeProps extends AntTreeNodeProps {
  title: string;
  key: string;
  isLeaf?: boolean;
  orgData?: string;
  children?: GoodsCategoriesTreeNodeProps[];
  categoryNoPath: string;
}

/* GoodsCategories Cascader mode Multiple Config Item */
export interface GoodsCategoriesMultipleConfigItem {
  /* “添加”按钮展示文案 */
  addBtnLabel?: string;
  /* “添加”按钮配置 */
  btnConfig?: any;
}

/* 类目选择后返回数据结构 */
export interface GoodsCategoriesValueItem {
  categoryName: string;
  categoryNo: string;
  parentNo: string;
  categoryNoPath: string;
  hasChild: 0 | 1;
  level: number;
  isLeaf: number;
  icon?: string;
}
