/*
 * @Author: zhou lei
 * @Date: 2021-11-08 12:10:26
 * @LastEditTime: 2022-01-23 09:12:40
 * @LastEditors: zhou lei
 * @Description:
 * @FilePath: /wms_haiwai_app/types/vue-form.d.ts
 * 联系方式:910592680@qq.com 18669792120
 */
declare module 'vue/types/form' {
  /**
   * 校验规则选项
   */
  type VFormRules<Form> = { [P in keyof Form]?: Rule[] };
  /**
   * 校验规则
   */
  interface Rule {
    trigger?: 'change' | 'blur' | ['change', 'blur'];
    type?: 'string' | 'number' | 'boolean' | 'method' | 'regexp' | 'integer' | 'float' | 'array' | 'object' | 'enum' | 'date' | 'url' | 'hex' | 'email' | 'any';
    required?: boolean;
    pattern?: RegExp;
    min?: number;
    max?: number;
    len?: number;
    whitespace?: boolean;
    transform?: (val: string) => any;
    message?: string;
    validator?: {
      rule: Rule;
      value: string;
      callback: (valid: boolean) => void;
    };
    asyncValidator?: {
      rule: Rule;
      value: string;
      callback: (valid: boolean) => void;
    };
  }
  interface VForm extends Vue {
    /**
     * 调用此方法，设置校验规则
     * @param rules
     */
    setRules: (rules: VFormRules) => void;
    /**
     * 对整个表单进行校验的方法w
     * @param callback
     */
    validate: (callback: (valid: boolean) => void) => void;
    /**
     * 对整个表单进行重置，将所有字段值重置为初始值并移除校验结果
     */
    resetFields: () => void;
  }
}
