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

export const khOptions =  [
  { value: '0', label: "组织" },
  { value: '1', label: "企业" },
]

const validate_rate = (rule, value, callback) => {
  const { required } = rule
  if ((value === '' || value === undefined) && required) {
    callback(new Error('主管利率毛利率不能为空！'))
  } else {
    callback()
  }
}
const validate_order_rate = (rule, value, callback) => {
  const { required } = rule
  if ((value === '' || value === undefined) && required) {
    callback(new Error('预算→成本毛利率不能为空！'))
  } else {
    callback()
  }
}
const validate_sale_rate = (rule, value, callback) => {
  const { required } = rule
  if ((value === '' || value === undefined) && required) {
    callback(new Error('成本→售价毛利率不能为空！'))
  } else {
    callback()
  }
}

const validate_lower_rate = (rule, value, callback) => {
  const { required } = rule
  if ((value === '' || value === undefined) && required) {
    callback(new Error('BOSS毛利率不能为空！'))
  } else {
    callback()
  }
}
const validate_low_rate = (rule, value, callback) => {
  const { required } = rule
  if ((value === '' || value === undefined) && required) {
    callback(new Error('项目最低毛利率不能为空！'))
  } else {
    callback()
  }
}
const validate_money_rate = (rule, value, callback) => {
  const { required } = rule
  if ((value === '' || value === undefined) && required) {
    callback(new Error('财务毛利率不能为空！'))
  } else {
    callback()
  }
}

export const rules =  {
  order_rate: [{ required: true, validator: validate_order_rate, trigger: 'blur' }],
  sale_rate: [{ required: true, validator: validate_sale_rate, trigger: 'blur' }],
  lower_rate: [{ required: false, validator: validate_lower_rate, trigger: 'blur' }],
  rate: [{ required: true, validator: validate_rate, trigger: 'blur' }],
  low_rate: [{ required: true, validator: validate_low_rate, trigger: 'blur' }],
  money_rate: [{ required: true, validator: validate_money_rate, trigger: 'blur' }]
}
