checkswift.js 2.13 KB
Newer Older
李少勇 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
import CommonCheck from './check.js';
import BigNumber from "bignumber.js";

export default function () {
  return {
    ...CommonCheck.apply(this),
    //清算编号
    "cpdgrp.rec.sysno": [
      { type: "string", required: true, message: "必输项" },
      { max: 21, message: "长度不能超过21" }
    ],
    "cptp.uetr": [
      { type: "string", required: true, message: "必输项" },
      { max: 40, message: "长度不能超过40" }
    ],
    //解付日期
    "cpdgrp.rec.paydat": [
      { type: "string", required: true, message: "输入正确的日期" }
    ],
    //发报行
    "cpdgrp.snd.pts.extkey": [
      { type: "string", required: false, message: "必输项" },
      { max: 16, message: "长度不能超过16" }
    ],
    "cpdgrp.rec.detchgcod": [
      { type: "string", required: true, message: "必输项" },
    ],
    // "cpdgrp.rec.curf33b": [
    //   { type: "string", required: true, message: "必输项" },
    // ],
    "cpdgrp.rec.amtf33b": [
      // { type: "string", required: true, message: "必输项" },
      // { max: 18, message: "整数位不能超过14位" },
      // { pattern: /(^\d+$)|(^\.\d{1,3}$)|(^\d+\.\d{1,3}$)/, message: "小数位不能超过3位" },
      {
        validator: (rule, value, callback) => {
          if(value != '' && this.model.cpdgrp.rec.swftyp=='103'&&
              this.model.cpdgrp.cbs.nom1.cur !='' &&
              this.model.cpdgrp.rec.curf33b !='' &&
              this.model.cpdgrp.rec.cur71f !='' &&
              this.model.cpdgrp.cbs.nom1.cur == this.model.cpdgrp.rec.curf33b &&
              this.model.cpdgrp.rec.curf33b == this.model.cpdgrp.rec.cur71f){
              var preamtf33b  = new BigNumber(this.model.cpdgrp.rec.amt71f).plus(new BigNumber(this.model.cpdgrp.cbs.nom1.amt));
              var amtf33b= new BigNumber(value);
              if(amtf33b.comparedTo(preamtf33b) != 0){
                callback(new Error('币种一致时,33b=71f+32a'));
              }else{
                callback();
              }
          } else {
            //校验通过
            callback();
          }
        },
        trigger: ['blur', 'change']
      }
    ]
  }
}