import { FormItemRule } from "element-plus";
import { PropType } from "vue";

export type FormItemType =
  | "input"
  | "select"
  | "radio"
  | "checkbox"
  | "img_preview"
  | "img_upload"
  | "date_picker"
  | "range"
  | "contact"
  | "number"
  | "custom"
  | "input_group"
  | "remote-select"
  | "supplier-query"
  | "business-query"
  | "business-permission"
  | "depart-query"
  | "user-query"
  | "supplier-permission";

export type FormItem = {
  field: string;
  label?: string;
  placeholder?: any;
  rules?: Array<FormItemRule> | FormItemRule;
  type?: FormItemType;
  options?: Array<any>;
  isHidden?: boolean;
  otherOptions?: any;
  labelWidth?: string;
  span?: number;
  type_field?: string;
  slot?: string;
  trigger?: "change";
  onChange?: Function;
  noRest?: boolean;
  defaultValue?: Array<string> | string;
};

export type FormGorup = {
  title: string;
  formItems: Array<FormItem>;
};

export const basicFormProps = {
  formItems: {
    type: Array as PropType<Array<FormItem>>,
    default: () => []
  },
  formGroup: {
    type: Array as PropType<Array<FormGorup>>,
    default: () => []
  },
  itemStyle: {
    type: Object,
    default: () => ({
      paddingRight: "20px"
    })
  },
  disabled: {
    type: Boolean,
    default: false
  },
  colLayout: {
    type: Object,
    default: () => ({
      xl: 4,
      lg: 6,
      md: 8,
      sm: 8,
      xs: 12
    })
  },
  formData: {
    type: Object,
    required: true
  },
  contact: {
    type: String
  },
  divider: {
    type: Boolean
  },
  labelWidth: {
    type: String
  }
} as const;
