import { isSpecialSymbol ,hasSpace} from "@/utils/validate";
const validate_budget_price = (rule, value, callback) => {
  if (value === "") {
    callback(new Error("预算单价不能为空！"));
  } else if (
    value === "0" ||
    value === "0." ||
    value === "0.0" ||
    value === "0.00"
  ) {
    callback(new Error("预算单价不能为零！"));
  } else {
    callback();
  }
};
const validate_num = (rule, value, callback) => {
  if (value === "") {
    callback(new Error("购买数量不能为空！"));
  } else if (value === "0") {
    callback(new Error("购买数量不能为零！"));
  } else {
    callback();
  }
};
const validate_total_weight = (rule, value, callback) => {
  const { required } = rule;
  if (required && value === "") {
    callback(new Error("商品重量不能为空！"));
  } else if (
    required &&
    (value === "0" ||
      value === "0." ||
      value === "0.0" ||
      value === "0.00" ||
      value === "0.000")
  ) {
    callback(new Error("商品重量不能为零！"));
  } else {
    callback();
  }
};
const validate_specs_weight = (rule, value, callback) => {
  const { required } = rule;
  if (required && value === "") {
    callback(new Error("金属克重不能为空！"));
  } else if (
    required &&
    (value === "0" ||
      value === "0." ||
      value === "0.0" ||
      value === "0.00" ||
      value === "0.000")
  ) {
    callback(new Error("金属克重不能为零！"));
  } else {
    callback();
  }
};
const validate_desc = (rule, value, callback) => {
  const { required } = rule;
  if (required && value === "") {
    callback(new Error("不能为空！"));
  } else if (value.length > 0 && isSpecialSymbol(value)) {
    callback(new Error("不能使用英文特殊字符！"));
  } else {
    callback();
  }
};
const validate_good_name = (rule, value, callback) => {
  const { required } = rule;
  if (required && value.length == 0) {
    callback(new Error("不能为空！"));
  } else if (hasSpace(value)) {
    callback(new Error("不能出现/回车/换行符！"));
  } else if (isSpecialSymbol(value)) {
    callback(new Error("不能使用英文特殊字符！"));
  } else {
    callback();
  }
};
const rules = {
  arrival_time: [
    {
      required: true,
      message: "到货时间不能为空",
      trigger: "change",
    },
  ],
  budget_price: [
    {
      required: true,
      validator: validate_budget_price,
      trigger: "change",
    },
  ],
  num: [
    {
      required: true,
      validator: validate_num,
      trigger: "change",
    },
  ],
  brand_id: [
    {
      type: "array",
      required: true,
      message: "请选择品牌",
      trigger: "change",
    },
  ],
  unit: [
    {
      type: "array",
      required: true,
      message: "请选择单位",
      trigger: "change",
    },
  ],
  cat_id: [
    {
      type: "array",
      required: true,
      message: "请选择商品分类",
      trigger: "change",
    },
  ],
  good_img: [
    {
      required: true,
      message: "商品图片不能为空",
      trigger: "change",
    },
  ],
  good_name: [{ required: true, validator: validate_good_name, trigger: "blur" }],

  model: [
    {
      required: true,
      message: "型号不能为空",
      trigger: "blur",
    },
  ],
  color: [
    {
      required: true,
      message: "颜色不能为空",
      trigger: "blur",
    },
  ],
  material: [
    {
      required: true,
      message: "材质不能为空",
      trigger: "blur",
    },
  ],
  total_weight: [
    {
      required: false,
      validator: validate_total_weight,
      trigger: "blur",
    },
  ],
  is_addrs: [
    {
      required: true,
      message: "请选择是否多地",
      trigger: "change",
    },
  ],
  is_custom: [
    {
      required: true,
      message: "请选择是否定制",
      trigger: "change",
    },
  ],
  is_gold_price: [
    {
      required: true,
      message: "请选择是否启用实时金价",
      trigger: "change",
    },
  ],
  config: [
    {
      required: true,
      type: "array",
      message: "至少选择一个配置",
      trigger: "change",
    },
  ],
  specs_weight: [
    {
      required: true,
      validator: validate_specs_weight,
      trigger: "blur",
    },
  ],
  other_config: [
    {
      required: true,
      message: "其他要求不能为空",
      trigger: "blur",
    },
  ],
  cost_desc: [
    {
      required: false,
      validator: validate_desc,
      trigger: "blur",
    },
  ],
  use_desc: [
    {
      required: true,
      validator: validate_desc,
      trigger: "blur",
    },
  ],
  remark: [
    {
      required: true,
      validator: validate_desc,
      trigger: "blur",
    },
  ],
  metal_id: [
    {
      required: true,
      message: "贵金属种类不能为空",
      trigger: "blur",
    },
  ],
  gold_price: [
    {
      required: true,
      message: "当前金价不能为空",
      trigger: "blur",
    },
  ],
  enclosure_file: [
    {
      required: false,
      message: "请上传附件",
      trigger: "change",
    },
  ],
};
const edutRules = {
  companyNo: [
    {
      required: true,
      message: "请选择销售方公司",
      trigger: "change",
    },
  ],
  khNo: [
    {
      type: "array",
      required: true,
      message: "请选择购买方公司",
      trigger: "change",
    },
  ],
  platform_code: [
    {
      // type: "array",
      required: true,
      message: "请选择所属平台",
      trigger: "change",
    },
  ],
  endtime: [
    {
      required: true,
      message: "竞价截止时间不能为空",
      trigger: "change",
    },
  ],

  is_project: [
    {
      required: true,
      message: "请选择竞价类型！",
      trigger: "change",
    },
  ],
  projectNo: [
    {
      type: "array",
      required: true,
      message: "请选择项目",
      trigger: "change",
    },
  ],
  arrival_time: [
    {
      required: true,
      message: "到货时间不能为空",
      trigger: "change",
    },
  ],
  budget_price: [
    {
      required: true,
      validator: validate_budget_price,
      trigger: "change",
    },
  ],
  num: [
    {
      required: true,
      validator: validate_num,
      trigger: "change",
    },
  ],
  brand_id: [
    {
      type: "array",
      required: true,
      message: "请选择品牌",
      trigger: "change",
    },
  ],
  unit: [
    {
      type: "array",
      required: true,
      message: "请选择单位",
      trigger: "change",
    },
  ],
  cat_id: [
    {
      type: "array",
      required: true,
      message: "请选择商品分类",
      trigger: "change",
    },
  ],
  good_img: [
    {
      required: true,
      message: "商品图片不能为空",
      trigger: "change",
    },
  ],
  good_name: [{ required: true, message: "商品名称不能为空", trigger: "blur" }],

  model: [
    {
      required: true,
      message: "型号不能为空",
      trigger: "blur",
    },
  ],
  color: [
    {
      required: true,
      message: "颜色不能为空",
      trigger: "blur",
    },
  ],
  material: [
    {
      required: true,
      message: "材质不能为空",
      trigger: "blur",
    },
  ],
  total_weight: [
    {
      required: true,
      validator: validate_total_weight,
      trigger: "blur",
    },
  ],
  is_addrs: [
    {
      required: true,
      message: "请选择是否多地",
      trigger: "change",
    },
  ],
  is_custom: [
    {
      required: true,
      message: "请选择是否定制",
      trigger: "change",
    },
  ],
  is_gold_price: [
    {
      required: true,
      message: "请选择是否启用实时金价",
      trigger: "change",
    },
  ],
  config: [
    {
      required: true,
      type: "array",
      message: "至少选择一个配置",
      trigger: "change",
    },
  ],
  specs_weight: [
    {
      required: true,
      validator: validate_specs_weight,
      trigger: "blur",
    },
  ],
  other_config: [
    {
      required: true,
      message: "其他要求不能为空",
      trigger: "blur",
    },
  ],
  cost_desc: [
    {
      required: false,
      message: "工艺说明不能为空",
      trigger: "blur",
    },
  ],
  use_desc: [
    {
      required: true,
      message: "产品用途不能为空",
      trigger: "blur",
    },
  ],
  remark: [
    {
      required: true,
      message: "商品备注不能为空",
      trigger: "blur",
    },
  ],
  metal_id: [
    {
      required: true,
      message: "贵金属种类不能为空",
      trigger: "blur",
    },
  ],
  gold_price: [
    {
      required: true,
      message: "当前金价不能为空",
      trigger: "blur",
    },
  ],
};
const feedbackListCol = [
  {
    prop: "bidNo",
    label: "反馈商品编号",
    width: "160",
  },
  {
    prop: " origin_price",
    label: "议价前销售单价",
    width: "110",
  },
  {
    prop: "sale_price",
    label: "议价后销售单价",
    width: "110",
  },
  {
    prop: "cost_fee",
    label: "议价前工艺费",
    width: "110",
  },
  {
    prop: "sale_cost_fee",
    label: "议价后工艺费",
    width: "110",
  },

  // {
  //   prop: "good_img",
  //   label: "图片",
  //   _slot_: "good_img",
  //   "width": "50"
  // },
  {
    prop: "good_name",
    label: "商品名称",
    "min-width": "100",
  },
  {
    prop: "specinfo",
    label: "型号",
    _slot_: "specinfo",
    "min-width": "100",
  },

  {
    prop: "status",
    label: "状态",
    _slot_: "status",
    width: "120px",
  },
  {
    prop: "expire_day",
    label: "信息有效期",
    width: "85",
  },
  // {
  //   prop: "origin_addr",
  //   label: "产地",
  //   "width": "135"
  // },

  {
    prop: "delivery_place_cn",
    label: "发货地",
    width: "135",
  },
  {
    prop: "delivery_day",
    label: "物流时间",
    width: "85",
  },
  {
    prop: "work_day",
    label: "生产工期",
    width: "85",
  },
  {
    prop: "cgder",
    label: "供应商负责人",
    width: "95",
  },
  {
    prop: "good_creater",
    label: "商品创建人",
    width: "95",
  },

  
  {
    prop: "addtime",
    label: "添加时间",
    width: 142,
  },
  {
    prop: "",
    label: "操作",
    fixed: "right",
    _noset_: true,
    _slot_: "operation",
    width: 155,
  },
];

const listCol = [
  {
    prop: "infoNo",
    label: "竞价编号",
    width: "160",
  },
  {
    prop: "bargain_num",
    label: "竞价次数",
    width: "70",
  },

  {
    prop: "good_img",
    label: "图片",
    _slot_: "good_img",
    width: "50",
  },
  {
    prop: "good_name",
    label: "商品名称",
    "min-width": "120",
  },

  {
    prop: "status",
    label: "状态",
    _slot_: "status",
    width: "120px",
  },
  {
    prop: "is_project",
    label: "竞价单类型",
    _slot_: "is_project",
    width: "110px",
  },

  {
    prop: "khNo",
    label: "客户编号",
    width: "160",
  },
  {
    prop: "khname",
    label: "客户名称",
    "min-width": "135",
  },

  {
    prop: "budget_price",
    label: "预算单价",
    width: 110,
  },
  {
    prop: "num",
    label: "竞价数量",
    width: 110,
  },
  {
    prop: "company_name",
    label: "申请人部门",
    minWidth: "150px",
  },
  {
    prop: "creater",
    label: "申请人",
    width: "60",
  },

  {
    prop: "addtime",
    label: "添加时间",
    width: 142,
  },
  {
    prop: "",
    label: "操作",
    fixed: "right",
    _noset_: true,
    _slot_: "operation",
    width: 50,
  },
];

export { listCol, rules, edutRules, feedbackListCol };
