import Rmb2101Check from "../../rmb2101/model/check";
import Rmb2103Check from "../../rmb2103/model/check";
import Rmb2106Check from "../../rmb2106/model/check";
import Rmb2107Check from "../../rmb2107/model/check";
import Rmb2108Check from "../../rmb2108/model/check";
import Rmb2111Check from "../../rmb2111/model/check";
import Rmb2112Check from "../../rmb2112/model/check";
import Rmb2122Check from "../../rmb2122/model/check";
import Rmb2123Check from "../../rmb2123/model/check";

export default class RmbbopCheck {
    constructor(_this) {
        this.check = {
            ...(_this.model.rmbbop.aloneflg === "2" ? {} : new Rmb2101Check(_this).check),
            ...(_this.model.rmbbop.aloneflg === "2" ? {} : new Rmb2103Check(_this).check),
            ...(_this.model.rmbbop.aloneflg === "2" ? {} : new Rmb2106Check(_this).check),
            ...(_this.model.rmbbop.aloneflg === "2" ? {} : new Rmb2107Check(_this).check),
            ...(_this.model.rmbbop.aloneflg === "2" ? {} : new Rmb2108Check(_this).check),
            ...(_this.model.rmbbop.aloneflg === "2" ? {} : new Rmb2111Check(_this).check),
            ...(_this.model.rmbbop.aloneflg === "2" ? {} : new Rmb2112Check(_this).check),
            ...(_this.model.rmbbop.aloneflg === "2" ? {} : new Rmb2122Check(_this).check),
            ...(_this.model.rmbbop.aloneflg === "2" ? {} : new Rmb2123Check(_this).check),
            "rmbbop.rmb2101.rmbflg": [
                {required: true, message: "必输项", trigger: 'blur'}
            ],
            "rmbbop.rmb2112.rmbflg": [
                {required: true, message: "必输项"}
            ],
            "rmbbop.rmb2111.rmbflg": [
                {required: true, message: "必输项", trigger: 'blur'}
            ],
            "rmbbop.rmb2107.rmbflg": [
                {required: true, message: "必输项", trigger: 'blur'}
            ],
            "rmbbop.rmb2103.rmbflg": [
                {required: true, message: "必输项", trigger: 'blur'}
            ],
            "rmbbop.rmb2106.rmbflg": [
                {required: true, message: "必输项", trigger: 'blur'}
            ],
            "rmbbop.rmb2108.rmbflg": [
                {required: true, message: "必输项"}
            ],
            "rmbbop.rmb2122.rmbflg": [
                {required: true, message: "必输项"}
            ],
            "rmbbop.rmb2123.rmbflg": [
                {required: true, message: "必输项"}
            ],
            "rmbbop.aloneflg": [
                {
                    validator: (rule, value, callback) => {
                        const rmbbop = _this.model.rmbbop;
                        const hasRmbbop = Object.values(rmbbop).find(value => value.rmbflg === '1');
                        if (hasRmbbop && !value) {
                            callback(new Error('必输项'));
                        }
                        callback();
                    }
                }
            ],
        }
    }
}