import BassCheck from '../../../common/check/BassCheck'
import VrfsCheck from '../../../common/check/VrfsCheck'
import * as BopTools from '../../../common/utils/BopTools'
import moment from "moment";
import {checkRuleOfDBJ,checkRuleOfDBV} from "JSHRules"

export default function () {
    let checksDBJ = checkRuleOfDBJ().call({module:"DBJAME"}).call(this,this,moment)
    let checksDBV = checkRuleOfDBV().call({module:"DBVAME"}).call(this,this,moment)
    let rules = {...checksDBJ,...checksDBV}
    rules = BopTools.filterRule.call(this,rules,'mtabut.')
    return rules
    //动态收集当前交易的校验
    // if (this.model.mtabut.basflg) {
    //     Object.assign(rules, BassCheck.apply(this))
    // }
    // if (this.model.mtabut.vrfflg) {
    //     Object.assign(rules, VrfsCheck.apply(this))
    // }
    //这里仅仅是一个定义,如有相同,一定要做prop规则合并
    //交易下自定义规则
    // let transRules = {
    //     "recgrp.bas.exrate": [
    //
    //         {
    //             validator: (rule, value, callback) => {
    //                 if ((value === '' || value == null || value === 0) && this.model.recgrp.bas.actiontype !== 'D') {
    //                     return callback(new Error('必输项'))
    //                 } else {
    //                     if (value < 0) {
    //                         callback(new Error('利率必须大于等于0'));
    //                     }
    //                     callback()
    //                 }
    //             },
    //             trigger: ['blur', 'change']
    //         },
    //         {
    //             pattern: /^-?[1-9]\d{0,4}(\.\d{1,8})?$|^0(\.\d{1,8})?$/,
    //             message: "整数位不能超过5位,小数位不能超过8位",
    //         },
    //
    //     ],
    //     "recgrp.bas.fcyacc": [
    //
    //         {
    //             validator: (rule, value, callback) => {
    //                 if (this.model.recgrp.bas.actiontype !== 'D' && (value === '' || value == null)) {
    //                     return callback(new Error('必输项'))
    //                 } else {
    //                     callback()
    //                 }
    //             }
    //         }
    //     ],
    //     "recgrp.bas.fcyamt": [
    //         {
    //             validator: (rule, value, callback) => {
    //                 if ((value === '' || value == null || value === 0) && this.model.recgrp.bas.actiontype !== 'D') {
    //                     return callback(new Error('必输项'))
    //                 }
    //                 if (value < 0 && this.model.recgrp.bas.actiontype !== 'D') {
    //                     return callback(new Error('金额不能小于0'))
    //                 }
    //                 callback()
    //
    //             },
    //             trigger: ['blur', 'change']
    //         },
    //     ],
    //     "recgrp.bas.fcyccy": [
    //
    //         {
    //             validator: (rule, value, callback) => {
    //                 if ((value === '' || value == null) && this.model.recgrp.bas.actiontype !== 'D') {
    //                     return callback(new Error('必输项'))
    //                 } else {
    //                     callback()
    //                 }
    //             },
    //             trigger: ['blur', 'change']
    //         },
    //     ],
    //     "recgrp.bas.oppuser": [
    //         {type: "string", required: true, message: "必输项"},
    //     ],
    //     "recgrp.vrf.txcode": [
    //
    //         {
    //             validator: (rule, value, callback) => {
    //                 if (this.model.recgrp.vrf.actiontype !== 'D' && (value === '' || value == null)) {
    //                     return callback(new Error('必输项'))
    //                 }
    //                 if (this.model.recgrp.vrf.txcode && this.model.mtabut.zbxmszh === 'Y') {
    //                     if (this.model.recgrp.vrf.txcode === "226000") {
    //                         callback()
    //                     }
    //                     if (this.model.recgrp.vrf.txcode === "921030" || this.model.recgrp.vrf.txcode === "922010" || this.model.recgrp.vrf.txcode === "922090" ||
    //                         this.model.recgrp.vrf.txcode === "925010" || this.model.recgrp.vrf.txcode === "925020" || this.model.recgrp.vrf.txcode === "929080") {
    //                         return callback(new Error('交易编码不是资本项目相关'))
    //                     }
    //                     var s = this.model.recgrp.vrf.txcode.substring(0, 1);
    //                     if (("-5-6-7-8-9-".indexOf(s) <= 0)) {
    //                         return callback(new Error('交易编码不是资本项目相关'))
    //                     }
    //                 }
    //                 callback()
    //
    //             }
    //         }
    //     ],
    //
    //     "mtabut.paydat": [
    //         {type: "string", required: true, message: "必输项"},
    //         {
    //             validator: (rule, value, callback) => {
    //
    //                 if (new Date(this.model.mtabut.paydat).getTime() > new Date().getTime()) {
    //                     return callback(new Error('收付汇日期不得晚于系统日期!'))
    //                 }
    //
    //                 callback()
    //             }
    //         }
    //     ],
    //     "recgrp.bas.lcyacc": [
    //         {type: "string", required: true, message: "必输项"}
    //     ],
    //     "recgrp.bas.oppbank": [
    //         {
    //             validator: (rule, value, callback) => {
    //                 if (this.model.recgrp.bas.actiontype !== 'D') {
    //                     if (value === '' || value == null) {
    //                         return callback(new Error('必输项'))
    //                     }
    //                 }
    //                 callback()
    //             }
    //         }
    //     ],
    //     "recgrp.vrf.usetype": [
    //         {
    //             validator: (rule, value, callback) => {
    //                 if (this.model.recgrp.vrf.txcode) {
    //                     if (this.model.recgrp.vrf.txcode === "226000") {
    //                         return callback(new Error("当交易编码为资本类型时必输"))
    //                     }
    //                     if (this.model.recgrp.vrf.txcode === "921030" || this.model.recgrp.vrf.txcode === "922010" || this.model.recgrp.vrf.txcode === "922090" ||
    //                         this.model.recgrp.vrf.txcode === "925010" || this.model.recgrp.vrf.txcode === "925020" || this.model.recgrp.vrf.txcode === "929080") {
    //                         callback()
    //                     }
    //                     var s = this.model.recgrp.vrf.txcode.substring(0, 1);
    //                     if (("-5-6-7-8-9-".indexOf(s) > 0)) {
    //                         if (value === '' || value == null) {
    //                             return callback(new Error("当交易编码为资本类型时必输"))
    //                         }
    //                     }
    //                 }
    //                 callback()
    //             }
    //         }
    //     ],
    //     "recgrp.vrf.usedetail": [
    //
    //         {
    //             validator: (rule, value, callback) => {
    //                 if (this.model.mtabut.vrfflg === 'X') {
    //                     if (this.model.recgrp.vrf.usetype === '005' || this.model.recgrp.vrf.usetype === '006' || this.model.recgrp.vrf.usetype === '009') {
    //                         if (value === '' || value == null) {
    //                             return callback(new Error('必输项'))
    //                         }
    //
    //                     }
    //                     if (this.model.mtabut.zbxmszh === 'Y') {
    //                         if (value.indexOf("CADS") !== 0) {
    //                             return callback(new Error('无资本项目数字化标识,请添加CADS前缀'))
    //                         }
    //                     }
    //                 }
    //                 callback()
    //             }
    //         }
    //     ],
    //     "mtabut.zbxmszh": [
    //         {type: "string", required: true, message: "必输项"}
    //     ]
    // };
    // return BopTools.mergeRules(rules, transRules)
}