import { isMobile, validEmail } from "@/utils/validate";
const validatemobile = (rule, value, callback) => {
  if (value === "") {
    callback(new Error("手机号不能为空！"));
  } else {
    if (!isMobile(value)) {
      callback(new Error("手机号格式不正确！"));
    } else {
      callback();
    }
  }
};

const validateEmail = (rule, value, callback) => {
  if (value === "") {
    callback(new Error("邮箱不能为空！"));
  } else {
    if (!validEmail(value)) {
      callback(new Error("邮箱格式不正确！"));
    } else {
      callback();
    }
  }
};
const rules = {
  supplier_code: [
    { required: true, message: "请选择供应商", trigger: "change" },
  ],
  store_name: [
    { required: true, message: "请输入店铺名称", trigger: "change" },
  ],
  type_id: [{ required: true, message: "请选择店铺类型", trigger: "change" }],
  store_image: [
    { required: true, message: "请上传店铺主图", trigger: "change" },
  ],
  contactor: [{ required: true, message: "姓名不能为空", trigger: "blur" }],
  mobile: [{ required: true, validator: validatemobile, trigger: "blur" }],
  email: [{ required: true, validator: validateEmail, trigger: "blur" }],
  store_post: [{ required: true, message: "职位不能为空", trigger: "blur" }],
  store_city: [
    {
      required: true,
      type: "array",
      message: "请选择地址省市区",
      trigger: "change",
    },
  ],
  store_addr: [
    { required: true, message: "店铺地址不能为空", trigger: "blur,change" },
  ],
};

const formItem = {
  id: "",
  supplier_code: "QS20230605170528",
  type_id: 34,
  store_name: "测试店铺",
  store_image:
    "http://hwpro.test241.wanyuhengtong.com/storage/default/20230607/6c4b040420fb5a1d01837d0f120d60ec5c92ea62.jpg",
  map_addr: [115.70340104103089, 39.40107657164336],
  store_addr: "顺义区",
  store_city: ["1", "2", "3"],
  contactor: "张三",
  mobile: "17777777777",
  email: "11@qq.com",
  store_post: "经理",
  status: 0,
};
const columns = [
  {
    prop: "store_image",
    label: "主图",
    width: "50",
    _slot_: "store_image",
  },

  {
    prop: "storeType",
    label: "店铺类型",
    width: "100",
    _slot_: "storeType",
  },
  {
    prop: "status",
    label: "状态",
    width: "60",
    _slot_: "status",
  },
  {
    prop: "store_name",
    label: "店铺名称",
    minWidth: "200",
  },
  {
    prop: "supplier",
    label: "供应商名称",
    minWidth: "200",
    _slot_: "supplier",
  },

  {
    prop: "contactor",
    label: "联系人",
    width: "80",
  },
  {
    prop: "mobile",
    label: "联系电话",
    width: "110",
  },

  {
    prop: "create_time",
    label: "创建时间",
    width: "145",
  },
  {
    prop: "",
    label: "操作",
    fixed: "right",
    width: "140",
    _noset_: true,
    _slot_: "operation",
  },
];
const parmValue = {
  page: 1, // 页码
  size: 999999, // 每页显示条数
  limit: 999999,
};

export { formItem, columns, rules, parmValue };
