check.js 11.3 KB
import moment from "moment";
import BigNumber from "bignumber.js";

export default {
    data() {
        return {
            rules: {
                //====当事人描述========================================

                // applicant
                "ledgrp.apl.pts.ref": [
                    {required: false, message: "This field is mandatory"},
                    {max: 16, message: "长度不能超过16"}
                ],
                "ledgrp.apl.pts.extkey": [
                    {required: true, message: "This field is mandatory"},
                    {max: 16, message: "长度不能超过16"}
                ],

                // beneficary
                "ledgrp.ben.pts.ref": [
                    {required: false, message: "This field is mandatory"},
                    {max: 16, message: "长度不能超过16"}
                ],
                "ledgrp.ben.pts.extkey": [
                    {required: true, message: "This field is mandatory"},
                    {max: 16, message: "长度不能超过16"}
                ],

                // issuing bank
                "ledgrp.iss.pts.ref": [
                    {required: true, message: "This field is mandatory"},
                    {max: 16, message: "长度不能超过16"}
                ],
                "ledgrp.iss.pts.extkey": [
                    {required: true, message: "This field is mandatory"},
                    {max: 16, message: "长度不能超过16"}
                ],

                // Available with, 选择下拉列表
                "ledgrp.rec.avbwth": [
                    {required: true, message: "This field is mandatory"},
                ],

                // Available by,信用证兑付方式
                "ledgrp.rec.avbby": [
                    {required: true, message: "This field is mandatory"},
                ],


                "letamep.lcrgodamep.lcrgod":[
                    {
                        validator: (rule, value, callback) => {
                            if (/[^\x00-\xff]+/g.test(value)) {
                                return callback(new Error('此栏位不能输入中文、中文符号以及全角字符'));
                            }
                            if(value.includes('*')){
                                return callback(new Error('The block contains character \' *\'.\nPlease delete the character or replace it with a valid text.'));
                            }
                            callback();
                        },
                        trigger: ['blur', 'change']
                    }
                ],
                "letamep.lcrdocamep.lcrdoc":[
                    {
                        validator: (rule, value, callback) => {
                            if (/[^\x00-\xff]+/g.test(value)) {
                                return callback(new Error('此栏位不能输入中文、中文符号以及全角字符'));
                            }
                            if(value.includes('*')){
                                return callback(new Error('The block contains character \' *\'.\nPlease delete the character or replace it with a valid text.'));
                            }
                            callback();
                        },
                        trigger: ['blur', 'change']
                    }
                ],
                "letamep.adlcndamep.adlcnd":[
                    {
                        validator: (rule, value, callback) => {
                            if (/[^\x00-\xff]+/g.test(value)) {
                                return callback(new Error('此栏位不能输入中文、中文符号以及全角字符'));
                            }
                            if(value.includes('*')){
                                return callback(new Error('The block contains character \' *\'.\nPlease delete the character or replace it with a valid text.'));
                            }
                            callback();
                        },
                        trigger: ['blur', 'change']
                    }
                ],
                "letamep.spcbenamep.spcben":[
                    {
                        validator: (rule, value, callback) => {
                            if (/[^\x00-\xff]+/g.test(value)) {
                                return callback(new Error('此栏位不能输入中文、中文符号以及全角字符'));
                            }
                            if(value.includes('*')){
                                return callback(new Error('The block contains character \' *\'.\nPlease delete the character or replace it with a valid text.'));
                            }
                            callback();
                        },
                        trigger: ['blur', 'change']
                    }
                ],
                "letamep.spcrcbamep.spcrcb":[
                    {
                        validator: (rule, value, callback) => {
                            if (/[^\x00-\xff]+/g.test(value)) {
                                return callback(new Error('此栏位不能输入中文、中文符号以及全角字符'));
                            }
                            if(value.includes('*')){
                                return callback(new Error('The block contains character \' *\'.\nPlease delete the character or replace it with a valid text.'));
                            }
                            callback();
                        },
                        trigger: ["blur", "change"],
                    },
                ],
                "ledgrp.blk.lcrdoc":[{ max: 52000, message: "长度不能超过52000" }],
                "ledgrp.blk.lcrgod":[{ max: 52000, message: "长度不能超过52000" }],
                "ledgrp.blk.adlcnd":[{ max: 52000, message: "长度不能超过52000" }],
                "ledgrp.blk.spcben":[{ max: 52000, message: "长度不能超过52000" }],
                "ledgrp.blk.spcrcb":[{ max: 52000, message: "长度不能超过52000" }],


                "swiadd.amedat": [
                    {
                        validator: (rule, value, callback) => {

                            // 修改日期 amedat 不能小于 开证日期 opndat
                            if (value != '' && value != null) {

                                if (this.model.ledgrp.rec.opndat != '' && this.model.ledgrp.rec.opndat != null) {

                                    if (!(moment(this.model.ledgrp.rec.opndat).diff(moment(value), 'days') <= 0)) {

                                        return callback(new Error('The amendment date can not be before the issuance date'));
                                    }
                                }

                            }
                            callback();

                        }, trigger: ['blur', 'change']
                    }
                ],

                "ledgrp.rec.shpfro":[

                    {
                        validator: (rule, value, callback) => {

                            if (value != '' && value != null) {
                                if(value.length>140){
                                    return callback(new Error('Cannot split message >140. Too many message'));
                                }

                            }
                            callback();

                        }, trigger: ['blur', 'change']
                    }
                ],
                "ledgrp.rec.porloa":[

                    {
                        validator: (rule, value, callback) => {

                            if (value != '' && value != null) {
                                if(value.length>140){
                                    return callback(new Error('Cannot split message >140. Too many message'));
                                }

                            }
                            callback();

                        }, trigger: ['blur', 'change']
                    }
                ],
                "ledgrp.rec.pordis":[

                    {
                        validator: (rule, value, callback) => {

                            if (value != '' && value != null) {
                                if(value.length>140){
                                    return callback(new Error('Cannot split message >140. Too many message'));
                                }

                            }
                            callback();

                        }, trigger: ['blur', 'change']
                    }
                ],
                "ledgrp.rec.shpto":[

                    {
                        validator: (rule, value, callback) => {

                            if (value != '' && value != null) {
                                if(value.length>140){
                                    return callback(new Error('Cannot split message >140. Too many message'));
                                }

                            }
                            callback();

                        }, trigger: ['blur', 'change']
                    }
                ],

                "swiadd.newamt": [
                    {
                        validator: (rule, value, callback) => {

                                if( value!=null || value!='' ){
                                    if(new BigNumber(value).comparedTo(new BigNumber(0))< 0){
                                        return callback(new Error('A negative amount is not allowed'));
                                    }
                                }

                            callback();

                        }, trigger: ['blur', 'change']
                    }
                ],

                "swiadd.newnomtop":[
                    {
                        validator: (rule, value, callback) => {

                            if (value != '' && value != null) {
                                if(new BigNumber(value).comparedTo(new BigNumber(0))<0){
                                    return callback(new Error('The amount tolerance has to be positive'));
                                }
                            }
                            callback();

                        }, trigger: ['blur', 'change']
                    }

                ],
                "swiadd.newnomton":[
                    {
                        validator: (rule, value, callback) => {

                            if (value != '' && value != null) {
                                if(new BigNumber(value).comparedTo(new BigNumber(0))<0){
                                    return callback(new Error('Please enter this amount tolerance without a sign'));
                                }

                            }
                            callback();

                        }, trigger: ['blur', 'change']
                    }

                ],

                "swiadd.amenbr":[
                    {
                        validator: (rule, value, callback) => {

                            if (value != '' && value != null) {
                                if(new BigNumber(value).comparedTo(new BigNumber(0))<0){
                                    return callback(new Error('Please enter this amenbr without a sign'));
                                }

                            }
                            callback();

                        }, trigger: ['blur', 'change']
                    }

                ],



            }

        }
    }
}