import moment from 'moment';

export default {
	data(){
		return {
			rules:{
				"cfagit.paydat":[{
					required: true,
          message:'请输入发生日期'
				},{
					validator:(rule,value,callback)=>{
						if(moment(value).diff(moment(new Date()), 'days') > 0){
							return callback(new Error('收付汇日期不得晚于系统日期'))
						}
						callback()
					}
				}
			],
				"cfagit.ownextkey":[{
					required: true,
					message:'必输项'
				}],
				"cfagit.recgrp.bas.guarantorcode":[{
					validator:(rule,value,callback)=>{
						if(this.model.cfagit.recgrp.bas.acp == 'X' && this.model.cfagit.recgrp.bas.guarantype != 'D' && !value){
							return callback(new Error('必输项'))
						}
						callback()
					}
				}],
				"cfagit.recgrp.bas.guarancurr":[{
					validator:(rule,value,callback)=>{
						if(this.model.cfagit.recgrp.bas.acp == 'X' && this.model.cfagit.recgrp.bas.guarantype != 'D' && !value){
							return callback(new Error('必输项'))
						}
						callback()
					}
				}],
				"cfagit.recgrp.bas.guaranamount":[{
					validator:(rule,value,callback)=>{
						if(this.model.cfagit.recgrp.bas.acp == 'X' && this.model.cfagit.recgrp.bas.guarantype != 'D'){
							if(!value){
								return callback('必输项')
							}else if(value < 0){
								return callback('保函金额不能小于0')
							}
						}
						callback()
					}
				}],
				"cfagit.recgrp.bas.guarantype":[{
					validator:(rule,value,callback)=>{
						if(this.model.cfagit.recgrp.bas.acp == 'X' && this.model.cfagit.recgrp.bas.guarantype != 'D' && !value){
							return callback(new Error('必输项'))
						}
						callback()
					}
				}],
				"cfagit.recgrp.bas.maindebtcurr":[{
					validator:(rule,value,callback)=>{
						if(this.model.cfagit.recgrp.bas.acp == 'X' && this.model.cfagit.recgrp.bas.guarantype != 'D' && this.model.cfagit.recgrp.bas.guarantype == '1105' && !value){
							return callback(new Error('必输项'))
						}
						callback()
					}
				}],
				"cfagit.recgrp.bas.maindebtamount":[{
					validator:(rule,value,callback)=>{
						if(this.model.cfagit.recgrp.bas.acp == 'X' && this.model.cfagit.recgrp.bas.guarantype != 'D' && this.model.cfagit.recgrp.bas.guarantype == '1105' && value < 0){
							return callback(new Error('主债务金额不能小于0'))
						}
						callback()
					}
				}],
				"cfagit.recgrp.bas.bentype":[{
					validator:(rule,value,callback)=>{
						if(this.model.cfagit.recgrp.bas.acp == 'X' && this.model.cfagit.recgrp.bas.guarantype != 'D' && !value){
							return callback(new Error('必输项'))
						}
						callback()
					}
				}],
				"cfagit.recgrp.bas.bencode":[{
					validator:(rule,value,callback)=>{
						if(this.model.cfagit.recgrp.bas.acp == 'X' && this.model.cfagit.recgrp.bas.guarantype != 'D'){
							if(this.model.cfagit.recgrp.bas.guarantype != '1105' || this.cfagit.recgrp.bas.maindebtmanner != '1'){
								if(this.model.cfagit.recgrp.bas.bentype == '20001403'){
									if(value.length != 12){
										return callback(new Error('受益人代码栏位应填写12位金融机构标识码'))
									}
								}
							}
						}
						callback()
					}
				}],
				"cfagit.recgrp.bas.bename": [{
					validator: (rule,value,callback) => {
						if(this.model.cfagit.recgrp.bas.acp == 'X' && this.model.cfagit.recgrp.bas.guarantype != 'D')
						if (!value && !this.model.cfagit.recgrp.bas.benamen) {
							return callback(new Error('受益人中文名称和英文名称至少填写一个!'));
						}
						if (this.model.cfagit.recgrp.bas.guarantype == '1105' || this.model.cfagit.recgrp.bas.maindebtmanner == '1'){
							if(value != '资本市场'){
								return callback(new Error("当担保类型为'为境外发债担保'且发行方式为'公开发行'时,填报为'资本市场'"))
							}
						}
						callback();
					},
				}],
				"cfagit.recgrp.bas.guedtype":[{
					required: true,
					message:'必输项'
				}],
				"cfagit.recgrp.bas.guedindustrycode":[{
					validator:(rule,value,callback)=>{
						if(this.model.cfagit.recgrp.bas.acp == 'X' && this.model.cfagit.recgrp.bas.guarantype != 'D'){
							if(!value){
								return callback(new Error('必输项'))
							}
						}
						callback()
					}
				}],
				"cfagit.recgrp.bas.guedcouncode":[{
					required: true,
					message:'必输项'
				}],
				"cfagit.recgrp.bas.guedname": [{
					validator: (rule, value, callback) => {
						if(this.model.cfagit.recgrp.bas.acp == 'X' && this.model.cfagit.recgrp.bas.guarantype != 'D'){
							if(!value && !this.model.cfagit.recgrp.bas.guednamen) {
										return callback(new Error('被担保人中文名称和英文名称至少填写一个!'));
							} 
						}
						
						callback()
					},
				}],
				"cfagit.recgrp.bas.guappname": [{
					validator: (rule, value, callback) => {
						if(this.model.cfagit.recgrp.bas.acp == 'X' && this.model.cfagit.recgrp.bas.guarantype != 'D'){
							if(!value && !this.model.cfagit.recgrp.bas.guappnamen) {
										return callback(new Error('担保申请人中文名称和英文名称至少填写一个!'));
							} 
						}
						callback()
					},
				}],
				"cfagit.recgrp.bas.actiondesc": [{
					validator: (rule, value, callback) => {
						if (this.model.cfagit.recgrp.bas.acp == 'X' && this.model.cfagit.recgrp.bas.actiontype == 'D' && !value) {
							return callback(new Error('必输项'));
						} 
						callback()
					},
				}],
				"cfagit.recgrp.bas.contractdate": [{
					validator: (rule, value, callback) => {
						if (this.model.cfagit.recgrp.bas.acp == 'X' && this.model.cfagit.recgrp.bas.actiontype != 'D' && !value) {
							return callback(new Error('必输项'));
						} 
						callback()
					},
				}],
				"cfagit.recgrp.bas.maturity": [{
					validator: (rule, value, callback) => {
						if (this.model.cfagit.recgrp.bas.acp == 'X' && this.model.cfagit.recgrp.bas.actiontype != 'D' && !value) {
							return callback(new Error('必输项'));
						} 
						callback()
					},
				}],
				"cfagit.recgrp.bas.maindebtmanner": [{
					validator: (rule, value, callback) => {
						if (this.model.cfagit.recgrp.bas.acp == 'X' && this.model.cfagit.recgrp.bas.actiontype != 'D') {
							if(this.model.cfagit.recgrp.bas.guarantype == '1105' && !value){
								return callback(new Error('必输项'));
							}
						} 
						callback()
					},
				}],
				"cfagit.recgrp.bas.bencountrycode":[{
					validator: (rule, value, callback) => {
						if (this.model.cfagit.recgrp.bas.acp == 'X' && this.model.cfagit.recgrp.bas.actiontype != 'D') {
							if(!value){
								return callback(new Error('必输项'));
							}
						} 
						callback()
					},
				}],
				"cfagit.recgrp.bas.maindebtcondate": [{
					validator: (rule, value, callback) => {
						if (this.model.cfagit.recgrp.bas.acp == 'X' && this.model.cfagit.recgrp.bas.actiontype != 'D' ) {
							if(this.model.cfagit.recgrp.bas.guarantype == '1105' && !value){
								return callback(new Error('必输项'));
							}
						} 
						callback()
					},
				}],
				"cfagit.recgrp.bas.maindebtmaturity": [{
					validator: (rule, value, callback) => {
						if (this.model.cfagit.recgrp.bas.acp == 'X' && this.model.cfagit.recgrp.bas.actiontype != 'D' ) {
							if(this.model.cfagit.recgrp.bas.guarantype == '1105' && !value){
								return callback(new Error('必输项'));
							}
						} 
						callback()
					},
				}],
				"cfagit.recgrp.bas.intrat": [{
					validator: (rule, value, callback) => {
						if ( this.model.cfagit.recgrp.bas.acp == 'X' && this.model.cfagit.recgrp.bas.actiontype != 'D' ) {
							if(this.model.cfagit.recgrp.bas.guarantype == '1105' && !value){
								return callback(new Error('必输项'));
							}
						} 
						callback()
					},
				}],
				"cfagit.recgrp.bas.maindebtmaturity": [{
					validator: (rule, value, callback) => {
						if (this.model.cfagit.recgrp.bas.acp == 'X' && this.model.cfagit.recgrp.bas.actiontype != 'D' ) {
							if(this.model.cfagit.recgrp.bas.guarantype == '1105' && !value){
								return callback(new Error('必输项'));
							}
						} 
						callback()
					},
				}],
				"cfagit.recgrp.bas.founds1": [{
					validator: (rule, value, callback) => {
						let founds1 = this.model.cfagit.recgrp.bas.founds1
						let founds2 = this.model.cfagit.recgrp.bas.founds2
						let founds3 = this.model.cfagit.recgrp.bas.founds3
						let founds4 = this.model.cfagit.recgrp.bas.founds4
						let founds5 = this.model.cfagit.recgrp.bas.founds5
						let founds6 = this.model.cfagit.recgrp.bas.founds6
						let founds7 = this.model.cfagit.recgrp.bas.founds7
						let founds8 = this.model.cfagit.recgrp.bas.founds8
						if (this.model.cfagit.recgrp.bas.acp == 'X' && this.model.cfagit.recgrp.bas.actiontype != 'D' ) {
							if(this.model.cfagit.recgrp.bas.guarantype == '1105' && !founds1 && !founds2 && !founds3 && !founds4 && !founds5 && !founds6 && !founds7 && !founds8){
								return callback(new Error('当担保类型选择为"为境外发债担保"时,必填项,可多选'));
							}
						} 
						callback()
					},
				}],
				"cfagit.recgrp.bas.founds2": [{
					validator: (rule, value, callback) => {
						let founds1 = this.model.cfagit.recgrp.bas.founds1
						let founds2 = this.model.cfagit.recgrp.bas.founds2
						let founds3 = this.model.cfagit.recgrp.bas.founds3
						let founds4 = this.model.cfagit.recgrp.bas.founds4
						let founds5 = this.model.cfagit.recgrp.bas.founds5
						let founds6 = this.model.cfagit.recgrp.bas.founds6
						let founds7 = this.model.cfagit.recgrp.bas.founds7
						let founds8 = this.model.cfagit.recgrp.bas.founds8
						if (this.model.cfagit.recgrp.bas.acp == 'X' && this.model.cfagit.recgrp.bas.actiontype != 'D' ) {
							if(this.model.cfagit.recgrp.bas.guarantype == '1105' && !founds1 && !founds2 && !founds3 && !founds4 && !founds5 && !founds6 && !founds7 && !founds8){
								return callback(new Error('当担保类型选择为"为境外发债担保"时,必填项,可多选'));
							}
						} 
						callback()
					},
				}],
				"cfagit.recgrp.bas.founds3": [{
					validator: (rule, value, callback) => {
						let founds1 = this.model.cfagit.recgrp.bas.founds1
						let founds2 = this.model.cfagit.recgrp.bas.founds2
						let founds3 = this.model.cfagit.recgrp.bas.founds3
						let founds4 = this.model.cfagit.recgrp.bas.founds4
						let founds5 = this.model.cfagit.recgrp.bas.founds5
						let founds6 = this.model.cfagit.recgrp.bas.founds6
						let founds7 = this.model.cfagit.recgrp.bas.founds7
						let founds8 = this.model.cfagit.recgrp.bas.founds8
						if (this.model.cfagit.recgrp.bas.acp == 'X' && this.model.cfagit.recgrp.bas.actiontype != 'D' ) {
							if(this.model.cfagit.recgrp.bas.guarantype == '1105' && !founds1 && !founds2 && !founds3 && !founds4 && !founds5 && !founds6 && !founds7 && !founds8){
								return callback(new Error('当担保类型选择为"为境外发债担保"时,必填项,可多选'));
							}
						} 
						callback()
					},
				}],
				"cfagit.recgrp.bas.founds4": [{
					validator: (rule, value, callback) => {
						let founds1 = this.model.cfagit.recgrp.bas.founds1
						let founds2 = this.model.cfagit.recgrp.bas.founds2
						let founds3 = this.model.cfagit.recgrp.bas.founds3
						let founds4 = this.model.cfagit.recgrp.bas.founds4
						let founds5 = this.model.cfagit.recgrp.bas.founds5
						let founds6 = this.model.cfagit.recgrp.bas.founds6
						let founds7 = this.model.cfagit.recgrp.bas.founds7
						let founds8 = this.model.cfagit.recgrp.bas.founds8
						if (this.model.cfagit.recgrp.bas.acp == 'X' && this.model.cfagit.recgrp.bas.actiontype != 'D' ) {
							if(this.model.cfagit.recgrp.bas.guarantype == '1105' && !founds1 && !founds2 && !founds3 && !founds4 && !founds5 && !founds6 && !founds7 && !founds8){
								return callback(new Error('当担保类型选择为"为境外发债担保"时,必填项,可多选'));
							}
						} 
						callback()
					},
				}],
				"cfagit.recgrp.bas.founds5": [{
					validator: (rule, value, callback) => {
						let founds1 = this.model.cfagit.recgrp.bas.founds1
						let founds2 = this.model.cfagit.recgrp.bas.founds2
						let founds3 = this.model.cfagit.recgrp.bas.founds3
						let founds4 = this.model.cfagit.recgrp.bas.founds4
						let founds5 = this.model.cfagit.recgrp.bas.founds5
						let founds6 = this.model.cfagit.recgrp.bas.founds6
						let founds7 = this.model.cfagit.recgrp.bas.founds7
						let founds8 = this.model.cfagit.recgrp.bas.founds8
						if (this.model.cfagit.recgrp.bas.acp == 'X' && this.model.cfagit.recgrp.bas.actiontype != 'D' ) {
							if(this.model.cfagit.recgrp.bas.guarantype == '1105' && !founds1 && !founds2 && !founds3 && !founds4 && !founds5 && !founds6 && !founds7 && !founds8){
								return callback(new Error('当担保类型选择为"为境外发债担保"时,必填项,可多选'));
							}
						} 
						callback()
					},
				}],
				"cfagit.recgrp.bas.founds6": [{
					validator: (rule, value, callback) => {
						let founds1 = this.model.cfagit.recgrp.bas.founds1
						let founds2 = this.model.cfagit.recgrp.bas.founds2
						let founds3 = this.model.cfagit.recgrp.bas.founds3
						let founds4 = this.model.cfagit.recgrp.bas.founds4
						let founds5 = this.model.cfagit.recgrp.bas.founds5
						let founds6 = this.model.cfagit.recgrp.bas.founds6
						let founds7 = this.model.cfagit.recgrp.bas.founds7
						let founds8 = this.model.cfagit.recgrp.bas.founds8
						if (this.model.cfagit.recgrp.bas.acp == 'X' && this.model.cfagit.recgrp.bas.actiontype != 'D' ) {
							if(this.model.cfagit.recgrp.bas.guarantype == '1105' && !founds1 && !founds2 && !founds3 && !founds4 && !founds5 && !founds6 && !founds7 && !founds8){
								return callback(new Error('当担保类型选择为"为境外发债担保"时,必填项,可多选'));
							}
						} 
						callback()
					},
				}],
				"cfagit.recgrp.bas.founds7": [{
					validator: (rule, value, callback) => {
						let founds1 = this.model.cfagit.recgrp.bas.founds1
						let founds2 = this.model.cfagit.recgrp.bas.founds2
						let founds3 = this.model.cfagit.recgrp.bas.founds3
						let founds4 = this.model.cfagit.recgrp.bas.founds4
						let founds5 = this.model.cfagit.recgrp.bas.founds5
						let founds6 = this.model.cfagit.recgrp.bas.founds6
						let founds7 = this.model.cfagit.recgrp.bas.founds7
						let founds8 = this.model.cfagit.recgrp.bas.founds8
						if (this.model.cfagit.recgrp.bas.acp == 'X' && this.model.cfagit.recgrp.bas.actiontype != 'D' ) {
							if(this.model.cfagit.recgrp.bas.guarantype == '1105' && !founds1 && !founds2 && !founds3 && !founds4 && !founds5 && !founds6 && !founds7 && !founds8){
								return callback(new Error('当担保类型选择为"为境外发债担保"时,必填项,可多选'));
							}
						} 
						callback()
					},
				}],
				"cfagit.recgrp.bas.founds8": [{
					validator: (rule, value, callback) => {
						let founds1 = this.model.cfagit.recgrp.bas.founds1
						let founds2 = this.model.cfagit.recgrp.bas.founds2
						let founds3 = this.model.cfagit.recgrp.bas.founds3
						let founds4 = this.model.cfagit.recgrp.bas.founds4
						let founds5 = this.model.cfagit.recgrp.bas.founds5
						let founds6 = this.model.cfagit.recgrp.bas.founds6
						let founds7 = this.model.cfagit.recgrp.bas.founds7
						let founds8 = this.model.cfagit.recgrp.bas.founds8
						if (this.model.cfagit.recgrp.bas.acp == 'X' && this.model.cfagit.recgrp.bas.actiontype != 'D' ) {
							if(this.model.cfagit.recgrp.bas.guarantype == '1105' && !founds1 && !founds2 && !founds3 && !founds4 && !founds5 && !founds6 && !founds7 && !founds8){
								return callback(new Error('当担保类型选择为"为境外发债担保"时,必填项,可多选'));
							}
						} 
						callback()
					},
				}],
				"cfagit.recgrp.bas.guedparecompname": [{
					validator: (rule, value, callback) => {
						if(this.model.cfagit.recgrp.bas.acp == 'X' && this.model.cfagit.recgrp.bas.actiontype != 'D'){
							if(this.model.cfagit.recgrp.bas.guarantype == '1105'){
								if (!value && !this.model.cfagit.recgrp.bas.guedparecompnamen) {
									return callback(new Error('被担保人境内母公司中文名称和英文名称至少填写一个!'));
								} 
							}
						}
						callback()
					},
				}],
				"cfagit.recgrp.bas.guedparecompcode": [{
					validator: (rule, value, callback) => {
						if(this.model.cfagit.recgrp.bas.acp == 'X' && this.model.cfagit.recgrp.bas.actiontype != 'D'){
							if(this.model.cfagit.recgrp.bas.guarantype == '1105'){
								if (!value) {
									return callback(new Error('必输项'));
								} 
							}
						}
						callback()
					},
				}],
				"cfagit.recgrp.bas.cgyn": [{
					validator: (rule, value, callback) => {
							if(this.model.cfagit.recgrp.bas.acp == 'X' && this.model.cfagit.recgrp.bas.actiontype != 'D'){
								if (!value) {
									return callback(new Error('必输项'));
								} 
							}
						callback()
					},
				}],
				"cfagit.recgrp.bas.cgcouncode": [{
					validator: (rule, value, callback) => {
							if(this.model.cfagit.recgrp.bas.acp == 'X' && this.model.cfagit.recgrp.bas.actiontype != 'D'){
								if(this.model.cfagit.recgrp.bas.cgyn == '1'){
									if (!value) {
									return callback(new Error('必输项'));
									} 
								}	
							}
						callback()
					},
				}],
				"cfagit.recgrp.bas.cgcode": [{
					validator: (rule, value, callback) => {
							if( this.model.cfagit.recgrp.bas.acp == 'X' && this.model.cfagit.recgrp.bas.actiontype != 'D'){
								if(this.model.cfagit.recgrp.bas.cgyn == '1'){
									if (!value) {
									return callback(new Error('必输项'));
									} 
								}	
							}
						callback()
					},
				}],
				"cfagit.recgrp.bas.cgname": [{
					validator: (rule, value, callback) => {
							if(this.model.cfagit.recgrp.bas.acp == 'X' && this.model.cfagit.recgrp.bas.actiontype != 'D'){
								if(this.model.cfagit.recgrp.bas.cgyn == '1'){
									if (!value && !this.model.cfagit.recgrp.bas.cgnamen) {
									return callback(new Error('当"是否有反担保人"为"是"时,反担保人中文名称和英文名称至少填写一个 '));
									} 
								}	
							}
						callback()
					},
				}],
				"cfagit.recgrp.bas.thyn": [{
					validator: (rule, value, callback) => {
							if(this.model.cfagit.recgrp.bas.acp == 'X' && this.model.cfagit.recgrp.bas.actiontype != 'D'){
								if (!value) {
									return callback(new Error('必输项'));
								} 
							}
						callback()
					},
				}],
				"cfagit.recgrp.bas.thje": [{
					validator: (rule, value, callback) => {
							if(this.model.cfagit.recgrp.bas.acp == 'X' && this.model.cfagit.recgrp.bas.actiontype != 'D'){
								if (this.model.cfagit.recgrp.bas.thyn == '1' && value < 0) {
									return callback(new Error('当是否调回境内选择"是"时,必填项,金额大于等于0'));
								} 
							}
						callback()
					},
				}],
				"cfagit.recgrp.bas.jwyn": [{
					validator: (rule, value, callback) => {
							if(this.model.cfagit.recgrp.bas.acp == 'X' && this.model.cfagit.recgrp.bas.actiontype != 'D'){
								if (!value) {
									return callback(new Error('必输项'));
								} 
							}
						callback()
					},
				}],
				// "cfagit.recgrp.bas.issuecountrycode":[{
				// 	validator: (rule, value, callback) => {
				// 		if(this.model.cfagit.recgrp.bas.acp == 'X' && this.model.cfagit.recgrp.bas.actiontype != 'D'){
				// 			if (!value) {
				// 				return callback(new Error('必输项'));
				// 			}
				// 		}
				// 	callback()
				// },
				// }]
			}
		}
	}
}