check.js 6.3 KB
Newer Older
fukai committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193
import BigNumber from "bignumber.js";
import moment from 'moment';

export default {
	data() {
		return {
			rules: {
				"gcdgrp.rec.ownref": [
					{ type: "string", required: true, message: "必输项" },
					{ max: 16, message: "长度不能超过16" }
				],
				"gcdgrp.rec.nam": [
					{ type: "string", required: false, message: "必输项" },
					{ max: 40, message: "长度不能超过40" }
				],
				"gcdgrp.rec.clmdat": [
					{ type: "string", required: true, message: "输入正确的日期" },
					{
						validator: (rule, value, callback) => {
							let businessType = this.$route.query.businessType;
							if (businessType) {
								callback();
							}
							// if (this.model.gidgrp.rec.expdat && moment(value).diff(moment(this.model.gidgrp.rec.expdat), 'days') > 0) {
							//   return callback(new Error('The Date of Claim should be earlier than expire date'));
							// }
							if (moment(value).diff(moment(new Date().Format("yyyy-MM-dd")), 'days') > 0) {
								return callback(new Error('The Date of Claim may not be in the future'));
							} else if (moment(value).diff(moment(this.model.gidgrp.rec.opndat), 'days') < 0) {
								return callback(new Error('The Date of Claim cannot be earlier than the opening date'));
							} else {
								//校验通过
								callback();
							}
						}, trigger: ['blur', 'change']
					}
				],
				"gcdgrp.rec.payrol": [
					{ type: "string", required: true, message: "必输项" },
				],
				"gcdgrp.rec.docprbrol": [
					{ type: "string", required: true, message: "必输项" },
				],
				"gcdgrp.blk.addamtinf": [
					{ type: "string", required: false, message: "必输项" },
					{ max: 780, message: "长度不能超过780" }
				],
				"gcdgrp.blk.presentdet": [
					{ type: "string", required: false, message: "必输项" },
					{ max: 700, message: "长度不能超过700" }
				],
				"gcdgrp.cbs.max.cur": [
					{ type: "string", required: false, message: "必输项" },
					{ max: 3, message: "长度不能超过3" }
				],
				"gcdgrp.cbs.max.amt": [
					{ required: true, message: "必输项" },
					{
						validator: (rule, value, callback) => {
							if (value && Number(value) <= Number('0')) {
								return callback(new Error('索赔金额必须大于0'));
							}
							if (new BigNumber(value).comparedTo(new BigNumber(this.model.gidgrp.cbs.opn1.amt)) > 0) {
								return callback(new Error('索赔金额不能大于保函余额'));
							}
							//校验通过
							callback();
						}, trigger: ['blur', 'change']
					}
				],
				"gcdgrp.cbs.opn1.cur": [
					{ type: "string", required: false, message: "必输项" },
					{ max: 3, message: "长度不能超过3" }
				],
				"gcdgrp.cbs.opn1.amt": [
					{ type: "string", required: false, message: "必输项" },
					{ max: 17, message: "整数位不能超过14位" },
					// {pattern: /(^\d+$)|(^\.\d{1,3}$)|(^\d+\.\d{1,3}$)/, message: "小数位不能超过3位" }
				],
				"gcdgrp.cbs.max2.amt": [
					{
						validator: (rule, value, callback) => {
							if (value && Number(value) < Number('0')) {
								return callback(new Error('索赔附加金额必须大于等于0'));
							}
							if (new BigNumber(value).comparedTo(new BigNumber(this.model.gidgrp.cbs.opn2.amt)) > 0) {
								return callback(new Error('索赔附加金额不能大于保函附加金额余额'));
							}
							//校验通过
							callback();
						}, trigger: ['blur', 'change']
					}
				],
				"gcdgrp.apl.pts.ref": [
					{ type: "string", required: false, message: "必输项" },
					{ max: 16, message: "长度不能超过16" }
				],

				"gcdgrp.apl.pts.nam": [
					{ type: "string", required: false, message: "必输项" },
					{ max: 40, message: "长度不能超过40" }
				],
				"gcdgrp.ben.pts.ref": [
					{ type: "string", required: false, message: "必输项" },
					{ max: 16, message: "长度不能超过16" }
				],

				"gcdgrp.ben.pts.nam": [
					{ type: "string", required: false, message: "必输项" },
					{ max: 40, message: "长度不能超过40" }
				],

				"gcdgrp.prb.pts.ref": [
					{ type: "string", required: false, message: "必输项" },
					{ max: 16, message: "长度不能超过16" }
				],

				"gcdgrp.prb.pts.extkey": [
					{ type: "string", required: true, message: "必输项" },
					{ max: 16, message: "长度不能超过16" }
				],
				"gcdgrp.prb.pts.adrblk": [
					{ type: "string", required: false, message: "必输项" },
					{ max: 140, message: "长度不能超过140" }
				],

				"gcdgrp.oth.pts.ref": [
					{ type: "string", required: false, message: "必输项" },
					{ max: 16, message: "长度不能超过16" }
				],
				"gcdgrp.oth.pts.extkey": [
					{ type: "string", required: true, message: "必输项" },
					{ max: 16, message: "长度不能超过16" }
				],

				"gcdgrp.oth.pts.adrblk": [
					{ type: "string", required: false, message: "必输项" },
					{ max: 140, message: "长度不能超过140" }
				],
				"gcdgrp.int.pts.extkey": [
					{ type: "string", required: false, message: "必输项" },
					{ max: 16, message: "长度不能超过16" }
				],
				"gcdgrp.awi.pts.extkey": [
					{ type: "string", required: false, message: "必输项" },
					{ max: 16, message: "长度不能超过16" }
				],
				"payday": [
					{ required: true, message: "请输入正确的数字" },
					{
						validator: (rule, value, callback) => {
							if (value < 1 || value > 99) {
								callback(new Error('请输入1-99范围内的数字'));
							} else {
								callback();
							}
						}, trigger: ['blur', 'change']
					},
				],
				"clmtxts20": [
					{ type: "string", required: false, message: "必输项" },
					{ max: 3250, message: "长度不能超过65" }
				],
				"szflg": [
					{ type: "string", required: true, message: "必输项" },
				],
				"gcdgrp.rec.expludat": [
					{
						validator: (rule, value, callback) => {
							const date1 = moment(value);
							const date2 = moment(this.model.gcdgrp.rec.newexpdat);
							const date3 = moment(this.model.gidgrp.rec.expdat);
							if (date2.isValid()) {
								if (date1.isAfter(date2)) {
									callback(new Error('不能大于延期效期'));
								}
							} else {
								if (date1.isAfter(date3)) {
									callback(new Error('不能大于保函效期'));
								}
							}
							//校验通过
							callback();
						}, trigger: ['blur', 'change']
					}
				],
			}
		}
	}
}