// 表单校验手机号
const checkphone = (rule, value, callback) => {
  // let phoneReg = /(^1[3|4|5|6|7|8|9]\d{9}$)|(^09\d{8}$)/;
  if (value == "") {
    callback(new Error("请输入手机号"));
  } else if (!isCellPhone(value)) {//引入methods中封装的检查手机格式的方法
    callback(new Error("请输入正确的手机号!"));
  } else {
    callback();
  }
};

// 手机号检查
const isCellPhone = function (val) {
  if (!/^1(3|4|5|6|7|8)\d{9}$/.test(val)) {
    return false;
  } else {
    return true;
  }
};

export const tableOption = {
  menuPosition: "center",
  border: true,
  index: true,
  indexLabel: "序号",
  stripe: true,
  menuAlign: "center",
  align: "center",
  searchMenuSpan: 8,
  searchSpan: 12,
  searchBtn: true,
  searchShowBtn: true,
  searchIcon: true,
  searchLabelWidth: 100,
  labelWidth: 120,
  menuWidth: 150,
  searchIndex: 3,
  submitBtn: true,
  submitText: "确定",
  menuBtn: true,
  menu: true,
  addBtn: true,
  editBtn: true,
  delBtn: true,
  column: [
    {
      type: "input",
      label: "客户ID",
      prop: "custId",
      span: 24,
      hide: true,
      display: false,
    },
    {
      type: "input",
      label: "客户编号",
      prop: "custNo",
      span: 24,
      search: true,
      display: false,
    },
    {
      type: "input",
      label: "客户姓名",
      prop: "custName",
      span: 24,
      search: true,
      rules: [
        {
          required: true,
          message: "请输入客户姓名！",
          trigger: "blur",
        },
      ],
    },
    {
      type: "input",
      label: "联系电话",
      prop: "contactTel",
      span: 24,
      // search: true,
      rules: [
        {
          required: true,
          validator: checkphone,
          trigger: "blur"
        }
      ],
    },
    {
      type: "select",
      label: "省",
      prop: "province",
      span: 8,
      searchSpan: 8,
      width: "100%",
      dicUrl: `/invtory/districts/getProvince`,
      props: {
        label: "name",
        value: "code",
      },
      cascaderItem: ["city", "district"],
      search: true,
    },
    {
      type: "select",
      label: "市",
      prop: "city",
      span: 8,
      searchSpan: 8,
      width: "100%",
      dicUrl: `/invtory/districts/getChildCity?cityCode={{province}}`,
      props: {
        label: "name",
        value: "code",
      },
      cascaderItem: ["district"],
      search: true,
    },
    {
      type: "select",
      label: "县区",
      prop: "district",
      span: 8,
      searchSpan: 8,
      width: "100%",
      dicUrl: `/invtory/districts/getChildCity?cityCode={{city}}`,
      props: {
        label: "name",
        value: "code",
      },
      search: true,
    },
    {
      type: "input",
      label: "联系地址",
      prop: "contactAddr",
      span: 24,
      rules: [
        {
          required: true,
          message: "请输入联系地址！",
          trigger: "blur",
        },
      ],
    },
    {
      type: "input",
      label: "联系人",
      prop: "linkMan",
      span: 24,
    },
    {
      type: "select",
      label: "所属行业",
      prop: "industry",
      dicUrl: "admin/dict/type/industry_type",
      span: 24,
      search: true
    },
    {
      type: "textarea",
      label: "备注",
      prop: "remark",
      span: 24,
    },
    {
      type: "input",
      label: "创建用户",
      prop: "crteUser",
      span: 24,
      hide: true,
      // search: true,
      editDisplay: false,
      addDisplay: false,
    },
    {
      type: "input",
      label: "最后更新用户",
      prop: "upteUser",
      span: 24,
      hide: true,
      // search: true,
      editDisplay: false,
      addDisplay: false,
    },
    {
      type: "date",
      label: "创建时间",
      prop: "crteTime",
      span: 24,
      hide: true,
      // search: true,
      // searchRange: true,
      rangeSeparator: "~",
      format: "yyyy-MM-dd HH:mm:ss",
      valueFormat: "yyyy-MM-dd HH:mm:ss",
      editDisplay: false,
      addDisplay: false,
    },
    {
      type: "date",
      label: "最后更新时间",
      prop: "upteTime",
      span: 24,
      hide: true,
      // search: true,
      // searchRange: true,
      rangeSeparator: "~",
      format: "yyyy-MM-dd HH:mm:ss",
      valueFormat: "yyyy-MM-dd HH:mm:ss",
      editDisplay: false,
      addDisplay: false,
    },
  ],
}
