import {
    isnumber,
    isnumber2
} from "@/utils/validate";

const validatePrice = (rule, value, callback) => {
    if (value === "") {
        callback(new Error("不能为空!"));
    } else {
        if (isnumber2(value)) {
            callback();
        } else if (isnumber(value)) {
            callback();
        } else {
            callback(new Error("仅支持整数或两位小数!"))
        }
    }
};
const validateWeight = (rule, value, callback) => {
    if (value === "") {
        callback(new Error("不能为空!"));
    } else {
        if (!isnumber(value)) {
            callback(new Error("仅支持整数!"))
        } else {
            callback();
        }
    }
};
export default {
    good_price: {
        required: true,
        trigger: "blur",
        validator: validatePrice,
    },
    nake_fee: {
        required: true,
        validator: validatePrice,

        trigger: "blur",
    },
    supplierNo: {
        type: "array",
        required: true,
        message: "采购供应商不能为空",
        trigger: "change",

    },
    num: {
        required: true,
        validator: validateWeight,
        trigger: "blur",
    },
    expecttime: {
        required: true,
        message: "预计入库时间不能为空",
        trigger: 'blur',
    },
    weight: {
        required: true,
        validator: validateWeight,
        trigger: "blur",
    },
    now_god_price: {
        required: true,
        validator: validatePrice,
        trigger: "blur",
    },
    teach_fee: {
        required: true,
        validator: validatePrice,
        trigger: "blur",
    },
    pakge_fee: {
        required: true,
        validator: validatePrice,
        trigger: "blur",
    },
    mark_fee: {
        required: true,
        validator: validatePrice,
        trigger: "blur",
    },
    cert_fee: {
        required: true,
        validator: validatePrice,
        trigger: "blur",
    },
    delivery_fee: {
        required: true,
        validator: validatePrice,
        trigger: "blur",
    },
    open_fee: {
        required: true,
        validator: validatePrice,
        trigger: "blur",
    },
    purchase_num: {
        required: true,
        validator: validateWeight,
        trigger: "blur",
    },
    diff_weight: {
        required: true,
        validator: validateWeight,
        trigger: "blur",
    },
    diff_fee: {
        required: true,
        validator: validatePrice,
        trigger: "blur",
    },
    remark: {
        required: true,
        message: "请填写备注",
        trigger: "blur",
    }
}