import { isMobile, isPhone } from "/@/utils/validate";

const validatemobile = (rule, value, callback) => {
  if (value !== "") {
    if (isPhone(value) || isMobile(value)) {
      callback();
    } else {
      callback(new Error("联系电话格式不正确！"));
    }
  } else {
    callback(new Error("联系电话！"));
  }
};

export const formRules = {
  platform_id: [
    {
      required: true,
      message: "请选择所属平台",
      trigger: "change"
    }
  ],
  sale_id: [
    {
      required: true,
      message: "销售员不能为空！",
      trigger: "blur"
    }
  ],
  // sale_depart: [
  //   {
  //     required: true,
  //     message: "销售员部门不能为空！",
  //     trigger: "change"
  //   }
  // ],
  buyerid: [
    {
      required: true,
      message: "采购员不能为空！",
      trigger: "change"
    }
  ],
  // cgd_depart: [
  //   {
  //     required: true,
  //     message: "采购员部门不能为空！",
  //     trigger: "change"
  //   }
  // ],
  cgd_tax: [
    {
      required: true,
      message: "采购毛利率",
      trigger: "blur"
    }
  ],
  cat: [
    {
      required: true,
      message: "商品分类",
      trigger: "change"
    }
  ],
  supplierNo: [
    {
      required: true,
      message: "供应商公司",
      trigger: "change"
    }
  ],
  qrdType: [
    {
      required: true,
      message: "订单类型",
      trigger: "blur"
    }
  ],
  good_total: [
    {
      required: true,
      message: "货款总金额",
      trigger: "blur"
    }
  ],
  workCode: [
    {
      required: true,
      message: "单据号",
      trigger: "blur"
    }
  ],
  poCode: [
    {
      required: true,
      message: "平台订单编码",
      trigger: "blur"
    }
  ],
  khNo: [
    {
      required: true,
      message: "购买方公司",
      trigger: "change"
    }
  ],
  tax: [
    {
      required: true,
      message: "税率",
      trigger: "change"
    }
  ],
  companyNo: [
    {
      required: true,
      message: "销售方公司",
      trigger: "change"
    }
  ],
  contactor: [
    {
      required: true,
      message: "收货人",
      trigger: "blur"
    }
  ],
  mobile: [
    {
      required: true,
      trigger: "blur",
      validator: validatemobile
    }
  ],
  addr: [
    {
      required: true,
      message: "联系地址",
      trigger: "blur"
    }
  ],

  sendtime: [
    {
      required: true,
      message: "发货时间",
      trigger: "change"
    }
  ],

  goodName: [
    {
      required: true,
      message: "商品名称",
      trigger: "blur"
    }
  ],
  goodPrice: [
    {
      required: true,
      message: "单价",
      trigger: "blur"
    }
  ],
  goodNum: [
    {
      required: true,
      message: "数量",
      trigger: "blur"
    }
  ]
};

export const saleDepartOptions = [
  {
    status: "1",
    value: "网络部"
  },
  {
    status: "1",
    value: "客服部"
  },
  {
    status: "0",
    value: "项目部"
  },
  {
    status: "0",
    value: "平台部"
  },
  {
    status: "0",
    value: "财务部"
  },
  {
    status: "0",
    value: "采购部"
  },
  {
    status: "0",
    value: "产品部"
  }
];

export const purchaseDepartOptions = [
  {
    status: "1",
    value: "网络部"
  },
  {
    status: "1",
    value: "采购部"
  },
  {
    status: "0",
    value: "客服部"
  },
  {
    status: "0",
    value: "项目部"
  },
  {
    status: "0",
    value: "平台部"
  },
  {
    status: "0",
    value: "财务部"
  },

  {
    status: "0",
    value: "产品部"
  }
];

export const qrdTypeOptions = [
  {
    value: "1",
    label: "库存销售"
  },
  {
    value: "2",
    label: "非库存"
  },
  {
    value: "3",
    label: "咨询"
  }
];

export const defaultData = {
  sale_id: "",
  sale_name: "",
  companyNo: "",
  poCode: "",
  workCode: "",
  qrdType: "2",
  goodName: "",
  tax: "",
  goodNum: "",
  goodPrice: "",
  addr: "",
  mobile: "",
  contactor: "",
  buyerid: "",
  sendtime: "",
  cat: "",
  supplierNo: "",
  cgd_tax: "",
  // sale_depart: "",
  // cgd_depart: "",
  khNo: "",
  platform_id: ""
};
