export const statusOptions =  [
  { value: "1", label: "待商品反馈" },
  { value: "2", label: "待客户选择商品" },
  { value: "3", label: "待项目方案制定" },
  { value: "4", label: "待方案选择" },
  { value: "5", label: "项目待下单" },
  { value: "6", label: "项目已结束" },
]

export const goodTypeOptions =  [
  { value: '1', label: '竞品' },
  { value: '2', label: '竞聘' }
]

const validate_sale_price = (rule, value, callback) => {
  if (!value || value === '') {
    callback(new Error('项目总预算不能为空！'))
  } else if (
    value === '0' ||
    value === '0.' ||
    value === '0.0' ||
    value === '0.00'
  ) {
    callback(new Error('项目总预算不能为零！'))
  } else {
    callback()
  }
}

export const rules =  {
  name: [
    {
      required: true,
      message: '项目名称不能为空！',
      trigger: 'blur'
    }
  ],
  platform: [
    {
      required: true,
      message: '请选择所属平台',
      trigger: 'change'
    }
  ],
  companyNo: [
    {
      required: true,
      message: '请选择销售方公司',
      trigger: 'change'
    }
  ],
  khNo: [
    {
      required: true,
      message: '请选择购买方公司',
      trigger: 'change'
    }
  ],

  budget_total: [
    {
      required: true,
      validator: validate_sale_price,
      trigger: 'blur'
    }
  ],

  arrtime: [
    {
      required: true,
      message: '要求到货时间不能为空！',
      trigger: 'change'
    }
  ],

  endtime: [
    {
      required: true,
      message: '竞价截止时间不能为空！',
      trigger: 'change'
    }
  ],
  use_desc: [
    {
      required: true,
      message: '项目用途不能为空',
      trigger: 'blur'
    }
  ],
  ladder: [
    {
      type: 'array',
      required: true,
      message: '至少添加两个商品要求',
      trigger: 'change'
    }
  ]
}


const validate_min_num = (rule, value, callback) => {
  if (!value || value === '') {
    callback(new Error('购买数量不能为空！'))
  } else if (value === '0') {
    callback(new Error('购买数量不能为零！'))
  } else {
    callback()
  }
}

export const ladderRules = {
  good_type: [{ required: true, message: '请选择商品类型', trigger: 'change' }],
  good_name: [{ required: false, message: '商品名称不能为空', trigger: 'blur' }],
  good_img: [{ required: false, message: '商品图片不能为空', trigger: 'change' }],
  budget_price: [{ required: true, validator: validate_sale_price, trigger: 'blur' }],
  num: [{ required: true, validator: validate_min_num, trigger: 'blur' }],
  can: [{ required: true, message: '请选择商品分类', trigger: 'change' }]
}
