import {
  isMobile,
  isqz,
  isz,
  iszf,
  isqzf
} from '/@/utils/validator'

export const statusOptions = [
  { value: "1", label: "启用", type: 'success' },
  { value: "0", label: "禁用", type: 'danger' }
]

export const isSettleOptions = [
  { value: "0", label: "否", type: 'danger' },
  { value: "1", label: "是", type: 'success' }
]

export const hasPlatformOptions = []
export const platformOptions = []
export const platformTypeOptions = []

export const contactOptions = [
  {
    value: "0",
    label: "区-固-分",
    rule: {
      validator(_, value) {
        if(!value) return true
        return isqzf(value);
      }
    }
  },
  {
    value: "1",
    label: "区-固",
    rule: {
      validator(_, value) {
        if(!value) return true
        return isqz(value);
      }
    }
  },
  {
    value: "2",
    label: "固-分",
    rule: {
      validator(_, value) {
        if(!value) return true
        return iszf(value || "");
      }
    }
  },
  {
    value: "3",
    label: "固",
    rule: {
      validator(_, value) {
        if(!value) return true
        return isz(value || "");
      }
    }
  },
  {
    value: "4",
    label: "手机号",
    rule: {
      validator(_, value) {
        if(!value) return true
        return isMobile(value || "");
      }
    }
  }
];

export const rules =  {
  code: [{ required: true, message: '请选择供应商', trigger: 'change'}],
  bank_name: [{ required: true, message: '请输入开户银行', trigger: 'change'}],
  bank_no: [{ required: true, message: '请输入银行卡号', trigger: 'change'}],
  contact_name: [{ message: '请输入联系人', trigger: 'change'}],
  contact_mobile: [{ validator: contactOptions[0].rule.validator, message: '联系方式格式不正确' }]
}

export const initialData = () => ({
  contact_mobile: '',
  contact_name: '',
  bank_name: '',
  bank_no: '',
  code: []
})
