index.js 8.17 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 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242
import Api from '~/service/Api';
import commonFunctions from '~/mixin/commonFunctions.js';
import Utils from "~/utils/index";
import moment from 'moment';
import { cloneDeep } from "lodash";
import Pts from '~/components/business/commonModel/Pts.js';
export default {
	mixins: [commonFunctions],
	methods: {

		paybrolDefault() {
      let ptsList = [];
			ptsList.push(this.model.ledgrp.adv);
			ptsList.push(this.model.ledgrp.avb);
      ptsList.push(this.model.ledgrp.iss);
      ptsList.push(this.model.ledgrp.con);
      let res = ptsList.find((item) => item.pts.rol == this.model.btdgrp.rec.payrol);
      if (res != null && res != "") {
        let newRes = cloneDeep(res);
        this.model.btdgrp.oth = newRes;
        this.model.btdgrp.oth.pts.rol = "OTH";
			}else{
				const objpta = {
					pts : new Pts().data,
				}
				this.model.btdgrp.oth = cloneDeep(objpta);
				this.model.btdgrp.oth.pts.rol = "OTH";

			}
    },
    
    buildPtspta (ptsptaObj) {
      let pts = ptsptaObj.pts;
      let ptspta = {
        rol: pts.rol,
        name: pts.nam,
        ptyinr: pts.ptyinr,
        ptainr: pts.ptainr,
        extkey: pts.extkey,
        dftdsp: pts.dftdsp,
        dftcur: pts.dftcur,
        dftact: pts.dftact,
        dftfeecur: pts.dftfeecur,
        dftactptainr: pts.dftactptainr,
        glggrpflg: pts.glggrpflg,
        adrblk: pts.adrblk,
        pts
      };
      return ptspta;
    },
    docprbrolChange(){
      let ptsptaList = Utils.formatPtspta(this.model.ltdgrp, this.buildPtspta);
      let res = ptsptaList.find((item) => item.pts.rol == this.model.btdgrp.rec.docprbrol);
      if (res != null && res != "") {
        let newRes = cloneDeep(res);
        this.model.btdgrp.prb = newRes;
        this.model.btdgrp.prb.pts.rol = "PRB";
			}else{
				const objpta = {
					pts : new Pts().data,
				}
				this.model.btdgrp.prb = cloneDeep(objpta);
				this.model.btdgrp.prb.pts.rol = "PRB";
			}
    },

		benrefDefault() {
			let blkModifyList = this.model.btdgrp.blk.modifySet;
			if (blkModifyList && blkModifyList.includes("benref")) 
			{
				this.model.btdgrp.be1.pts.ref = this.model.btdgrp.blk.benref;
			}
		},

		// docdisDefault(){
		// 	let blkModifyList = this.model.btdgrp.blk.modifySet;
		// 	if (!(blkModifyList && blkModifyList.includes("docdis") && this.model.btdgrp.blk.docdis != ""))
		// 	{
		// 		let descr = "";
		// 		if (moment(this.model.btdgrp.rec.shpdat).diff(moment(this.model.ledgrp.rec.shpdat), 'days') > 0
		// 			&& this.model.ledgrp.rec.shpdat != "" && this.model.ledgrp.rec.shpdat != null)
		// 		{
		// 			descr = descr + "Late shipment." + " ";
		// 		}
		// 		if (moment(this.model.btdgrp.rec.rcvdatbe1).diff(moment(this.model.ledgrp.rec.expdat), 'days') > 0
		// 			|| moment(this.model.btdgrp.rec.rcvdatbe2).diff(moment(this.model.ledgrp.rec.expdat), 'days') > 0)
		// 		{
		// 			descr = descr + "Documents received after expiry of the LC." + " ";
		// 		}
		// 		let exces = "";
		// 		if (this.model.ledgrp.cbs.opn2.amt < 0)	 
		// 		{
		// 			exces = this.model.btdgrp.cbs.mat.cur + " " + this.model.ledgrp.cbs.opn2.amt;
		// 			descr = descr + "The additional amount is overdrawn by " + exces + " ";
		// 		}
		// 		if (this.model.ledgrp.ref.shppar == "N" && this.model.ledgrp.rec.utlnbr >= 1)
		// 		{
		// 			descr = descr + "Partial shipment effected." + " ";
		// 		}
		// 		if (this.model.btdgrp.rec.doctypcod == "P")
		// 		{
		// 			if (this.model.ledgrp.rec.avbby == "A" || this.model.ledgrp.rec.avbby == "D")
		// 			{
		// 				descr = descr + "Sight draft presented in stead of Usance." + " ";
		// 			}
		// 			if (this.model.ledgrp.rec.avbby == "M")
		// 			{
		// 				descr = descr + "Only Sight draft presented instead of mixed payment." + " ";
		// 			}
		// 		}
		// 		if (this.model.btdgrp.rec.doctypcod == "A" || this.model.btdgrp.rec.doctypcod == "D")
		// 		{
		// 			if (this.model.ledgrp.rec.avbby == "P")
		// 			{
		// 				descr = descr + "Usance draft presented instead of Sight." + " ";
		// 			}
		// 			if (this.model.ledgrp.rec.avbby == "M")
		// 			{
		// 				descr = descr + "Only Usance drafts presented instead of mixed payment." + " ";
		// 			}
		// 		}
		// 		if (this.model.btdgrp.rec.doctypcod == "M")
		// 		{
		// 			if (this.model.ledgrp.rec.avbby == "P")
		// 			{
		// 				descr = descr + "Mixed payment drafts presented instead of sight." + " ";
		// 			}
		// 			if (this.model.ledgrp.rec.avbby == "A" || this.model.ledgrp.rec.avbby == "D")
		// 			{
		// 				descr = descr + "Mixed payment drafts presented instead of usance." + " ";
		// 			}
		// 		}
		// 		this.model.btdgrp.blk.docdis = descr;
		// 	}

		// 	if (this.model.btdgrp.blk.docdisflg == "")
		// 	{
		// 		this.model.btdgrp.blk.docdis = "";
		// 	}
		// },
		docstaDefault() {
			if (this.model.btdgrp.rec.advdat != "" && this.model.btdgrp.rec.advdat != null && this.model.btdgrp.rec.advtyp == "754")
			{
				if (this.model.btdgrp.ref.rcvdatbe2 == null || this.model.btdgrp.ref.rcvdatbe2 == "" || this.model.btdgrp.ref.rcvdatbe1 == null || this.model.btdgrp.ref.rcvdatbe1 == "")
				{
					this.model.btdgrp.ref.docsta = "C";
				}else{
					this.model.btdgrp.ref.docsta = "D";
				}
			}
			if (this.model.btdgrp.rec.disdat != "" && this.model.btdgrp.rec.disdat != null && this.model.btdgrp.rec.advtyp == "750")
			{
				if (this.model.btdgrp.ref.rcvdatbe2 == null || this.model.btdgrp.ref.rcvdatbe2 == "" || this.model.btdgrp.ref.rcvdatbe1 == null || this.model.btdgrp.ref.rcvdatbe1 == "")
				{
					this.model.btdgrp.ref.docsta = "E";
				}else{
					this.model.btdgrp.ref.docsta = "F";
				}
			}
			if ((this.model.btdgrp.rec.advdat == "" || this.model.btdgrp.rec.advdat == null) && (this.model.btdgrp.rec.disdat == "" || this.model.btdgrp.rec.disdat == null))
			{
				if ((this.model.btdgrp.ref.rcvdatbe2 != null && this.model.btdgrp.ref.rcvdatbe2 != "") || (this.model.btdgrp.ref.rcvdatbe1 != null && this.model.btdgrp.ref.rcvdatbe1 != "")
					&& this.model.btdgrp.rec.dscinsflg == "" )
				{
					this.model.btdgrp.ref.docsta = "G";
				}
				if ((this.model.btdgrp.ref.rcvdatbe2 != null && this.model.btdgrp.ref.rcvdatbe2 != "") || (this.model.btdgrp.ref.rcvdatbe1 != null && this.model.btdgrp.ref.rcvdatbe1 != "")
					&& this.model.btdgrp.rec.dscinsflg != "" && this.medel.btdgrp.rec.docdis == "")
				{
					this.model.btdgrp.ref.docsta = "H";
				}
				if ((this.model.btdgrp.ref.rcvdatbe2 != null && this.model.btdgrp.ref.rcvdatbe2 != "") || (this.model.btdgrp.ref.rcvdatbe1 != null && this.model.btdgrp.ref.rcvdatbe1 != "")
					&& this.model.btdgrp.rec.dscinsflg != "" && this.medel.btdgrp.rec.docdis != "")
				{
					this.model.btdgrp.ref.docsta = "I";
				}
			}
			if (this,model.btdgrp.rec.approvcod != "")
			{
				this.model.btdgrp.ref.docsta = "L";
			}
			if (this,model.btdgrp.rec.acpnowflg != "")
			{
				this.model.btdgrp.ref.docsta = "M";
			}
			if (this,model.btdgrp.rec.frepayflg != "")
			{
				this.model.btdgrp.ref.docsta = "N";
			}
		},

		cre752flgDefault(){
			if (this.model.bttp.cre752flg == "")
			{
				this.model.btdgrp.rec.disdat = "";
			}
    },

    // changeRmbclmnow(){
    //   if(!!this.model.rmbclmnow){
    //     if(this.model.rmbclm.modifySet !=null && !this.model.rmbclm.modifySet.includes("rmbrol")){
    //       this.model.rmbclm.rmbrol="RMB"
    //     }
    //     // else{
    //     //   this.model.rmbclm.rmbp.pansta="E"
    //     // }
    //   }
    //   // else{
    //   //   this.model.rmbclm.rmbp.pansta="I"
    //   // }
        
    // },

    changeRmbrol(){
      let ptsList = [];
			ptsList.push(this.model.ledgrp.adv);
			ptsList.push(this.model.ledgrp.avb);
      ptsList.push(this.model.ledgrp.iss);
      ptsList.push(this.model.ledgrp.con);
      ptsList.push(this.model.ledgrp.rmb);
      ptsList.push(this.model.btdgrp.oth);
      let res = ptsList.find((item) => item.pts.rol == this.model.rmbclm.rmbrol);
      if (res != null && res != "") {
        let newRes = cloneDeep(res);
        this.model.rmbclm.rmbrmb = newRes;
        this.model.rmbclm.rmbrmb.pts.rol = "RMBRMB";
      }else{
        const objpta = {
					pts : new Pts().data,
				}
				this.model.rmbclm.rmbrmb = cloneDeep(objpta);
      }
    },

    changeDocdisflg(){
      if (this.model.btdgrp.blk.docdisflg == "") {
        this.model.btdgrp.blk.docdis =  this.model.oldbtdgrp.blk.docdis;
      }
    }
		
	}
}