import { valid } from "semver";

var validateNormal = (rule, value, callback) => {
    if (value === "") {
        callback(new Error("必填字段"));
    } else {
        callback();
    }
};

var validatePhone = (rule, value, callback) => {
    console.log("validatePhone", value)
    if (!/^1[3456789]\d{9}$/.test(value)) {
        callback(new Error("请填写正确的手机号"));
    } else {
        callback();
    }
};

var rulesData = (validatePass) => {
    return {
        phone: [
            { required: true, validator: validatePhone, trigger: "blur" }
        ],
        cardId: [
            { required: true, validator: validateNormal, trigger: "blur" }
        ],
        pass: [
            { required: true, validator: validateNormal, trigger: "blur" }
        ],
        rePass: [
            { required: true, validator: validatePass, trigger: "blur" }
        ],
        phone: [
            { required: true, validator: validateNormal, trigger: "blur" }
        ],
        code: [
            { required: true, validator: validateNormal, trigger: "blur" }
        ],
        name: [
            { required: true, validator: validateNormal, trigger: "blur" }
        ],
        cname: [
            { required: true, validator: validateNormal, trigger: "blur" }
        ],
        level: [
            { required: true, validator: validateNormal, trigger: "blur" }
        ]
    }
}

var rulesProfile = {
    cardId: [
        { required: true, validator: validateNormal, trigger: "blur" }
    ],
    gender: [
        { required: true, validator: validateNormal, trigger: "blur" }
    ],
    address: [
        { required: true, validator: validateNormal, trigger: "blur" }
    ],
    company: [
        { required: true, validator: validateNormal, trigger: "blur" }
    ],
    nickname: [
        { required: true, validator: validateNormal, trigger: "blur" }
    ],
    education: [
        { required: true, validator: validateNormal, trigger: "blur" }
    ],
    years: [
        { required: true, validator: validateNormal, trigger: "blur" }
    ]
}

var typeList =[
  "施工现场专业人员",
  "建筑施工企业特种作业人员",
  "二级注册建造师",
  "建筑技术工人",
  "园林绿化技术工人",
  "建筑施工企业“三类人员"
]


var nameOption = {
    "绿化工": "绿化工",
    "花卉工": "花卉工",
}
var levelOption = {
    "三级": "三级",
    "四级": "四级",
}

var educationOption = {
    "小学": "小学",
    "初中": "初中",
    "高中": "高中",
    "大专": "大专",
    "本科": "本科",
    "研究生": "研究生",
    "博士": "博士",
}

var data = {
    rulesData,
    validateNormal,
    validatePhone,
    rulesProfile,
    nameOption,
    educationOption,
    levelOption,
    typeList
};

export default data
