index.js 7.36 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
import Api from '~/service/Api';
import commonFunctions from '~/mixin/commonFunctions.js';
import moment from 'moment';
import { cloneDeep } from "lodash";
import Pts from '~/components/business/commonModel/Pts.js';

export default {
	mixins: [commonFunctions],
	methods: {
		// 获取弹框表格数据
		async queryGridEtyPromptDialogData(type, ptytyp) {
			let params = {
			  userId: window.sessionStorage.userId || "ZL",
			  ptytyp: ptytyp,
			  extkey: this.model.lidgrp[type.toLowerCase()].pts.extkey,
			};
			let res = await Api.post("/service/ptspta/list", params);
			if (res.respCode == SUCCESS) {
			  this.root.$refs["etyDialog"].show = true;
			  this.root.promptData.data = res.data.ptaInfos;
			  this.root.promptData.type = type;
			}
		  },
		
		//获取信用证编号
		async onLttpButgetref() {
			let params = {
			businessType: "LC",
			littyp: "LC",
			ptainr: this.model.ltdgrp.be1.pts.ptainr,
			ownref: this.model.ltdgrp.rec.ownref,
			};
			const loading = this.loading();
			let res = await Api.post("/Lc/ref/ltd", params);
			loading.close();
			if (res.respCode == SUCCESS) {
			  this.model.ltdgrp.rec.ownref = res.data;
			} else {
        this.$message.error(res.respMsg);
      }
		},


		avtdatDefault() {
			if (this.model.ltdgrp.rmt.pts.adrblk != null && this.model.ltdgrp.rmt.pts.adrblk != ""){
			  this.model.ltdgrp.rec.autdat = moment(new Date()).format('YYYY-MM-DD');
			}
		},

		// 获取码表
		async getdbCode(codeType, uil, codeNam) {
			let params = {
			  codeType: codeType,
			  uil: uil ? uil : "EN",
			};
			let rtnmsg = await Api.post("/manager/dic/listDicInfo", params);
			if (rtnmsg.respCode === SUCCESS) {
			  let curList = rtnmsg.data.map((item) => ({
				value: item.codeValue,
				label: item.codeName,
			  }));
			  this.dbCodes[codeNam] = curList;
			}
		  },

		preperDefault() {
			if (this.model.ledgrp.rec.shpdat != this.model.ltdgrp.rec.shpdat || this.model.ledgrp.rec.expdat != this.model.ltdgrp.rec.shpdat){
			  let days = "21";
			  if (this.model.ltdgrp.rec.shpdat != null && this.model.ltdgrp.rec.shpdat != "" && this.model.ltdgrp.rec.expdat != null && this.model.ltdgrp.rec.expdat !=""){
				days = moment(this.model.ltdgrp.rec.expdat).diff(moment(this.model.ltdgrp.rec.shpdat), 'days');
			  }
			  this.model.ltdgrp.blk.preper = "Documents to be presented within " + days + " days after date of shipment.";
			}

			let modifyList = this.model.ltdgrp.rec.modifySet;
			if (!(modifyList && modifyList.includes("prepers18")) )
			{
				if (this.model.ltdgrp.rec.shpdat == null || this.model.ltdgrp.rec.shpdat == "" || this.model.ltdgrp.rec.expdat == null || this.model.ltdgrp.rec.expdat ==""){
					this.model.ltdgrp.rec.prepers18 = "21"
				}
				else
				{	
					this.model.ltdgrp.rec.prepers18 = moment(this.model.ltdgrp.rec.expdat).diff(moment(this.model.ltdgrp.rec.shpdat), 'days');
				}
			}
		},

		avbbyDefault() {
			switch (this.model.ltdgrp.rec.avbby)
			{
				case "P":
					this.model.ltdgrp.rec.tenmaxday = "0";
					this.model.ltdgrp.blk.mixdet = "";
					this.model.ltdgrp.blk.defdet = "";
					break;
				case "M":
					this.model.ltdgrp.blk.dftat = "";
          this.model.ltdgrp.blk.defdet = "";
          this.model.ltdgrp.drw.pts = new Pts().data;
          this.model.ltdgrp.drw.ptytyp = "";
					break;
				case "N":
          this.model.ltdgrp.blk.mixdet = "";
					break;
				case "D":
					this.model.ltdgrp.blk.mixdet = "";
          this.model.ltdgrp.blk.dftat = "";
          this.model.ltdgrp.drw.pts = new Pts().data;
          this.model.ltdgrp.drw.ptytyp = "";
					break;
				case "A":
					this.model.ltdgrp.blk.mixdet = "";
					this.model.ltdgrp.blk.defdet = "";
					break;
      }
      if(this.model.ltdgrp.rec.avbby != 'A' && this.model.ltdgrp.rec.avbby != 'N' && this.model.ltdgrp.rec.avbby != 'P'){
        this.drwdisabled = true
      }else{
        if(this.model.ltdgrp.drw.pts.extkey ==''){
          this.drwdisabled = false
        }
      }
		},

		async stactyDefault() {
			let modifyList = this.model.ltdgrp.rec.modifySet;
			if (!(modifyList && modifyList.includes("stacty")) )
			{
				let params = {
					ptainr: this.model.ltdgrp.adt.pts.ptainr,
				};
				const loading = this.loading();
				let res = await Api.post("/Lc/lttopn/stacty", params);
				if (res.respCode == SUCCESS) {
					loading.close();
					this.model.ltdgrp.rec.stacty = res.data;
				} else {
					loading.close();
				}
			}
			if (!this.model.ltdgrp.adt.pts.adrblk)
			{
				this.model.ltdgrp.rec.cnfins = "";
			}

			//avt的賦值
			if(this.model.ltdgrp.rec.avbwth === 'A' && (this.model.ltdgrp.avt.pts.adrblk === null || this.model.ltdgrp.avt.pts.adrblk === '')){
				this.model.ltdgrp.avt = cloneDeep(this.model.ltdgrp.adt);
				this.model.ltdgrp.avt.pts.rol = "AVT";
			}
		},

		cnfinsDefault() {
			if (!this.model.ltdgrp.adt.pts.adrblk)
			{
				// let modifyList = this.model.ltdgrp.rec.modifySet;
				// if (!(modifyList && modifyList.includes("cnfins")) )
				// {
					if (this.model.ledgrp.rec.cnfsta == "Y")
					{
						this.model.ltdgrp.rec.cnfins = "W";
					}else{
						this.model.ltdgrp.rec.cnfins = "";
					}
				// }
			} 
    },

    getCodeTableValue(value, codenam) {
      const codeobj = this.dbCodes[codenam].find((obj) => obj.value === value);
      return codeobj ? codeobj.label : value;
    },
    
    onAvbwthChange() {
      // 2.填充字段
      // 先将原有数据清空
      this.model.ltdgrp.avt.pts = new Pts().data;
      this.model.ltdgrp.avt.ptainr = "";
      this.model.ltdgrp.avt.ptyinr = "";
      this.model.ltdgrp.avt.adrblk = "";
      this.model.ltdgrp.avt.nam = "";
      this.model.ltdgrp.avt.extkey = "";
      this.model.ltdgrp.avt.ptytyp = "";
      this.model.ltdgrp.avt.cnnam = "";
      this.model.ltdgrp.avt.cnadr = "";
      this.model.ltdgrp.avt.ennam = "";
      this.model.ltdgrp.avt.enadr = "";
      this.model.ltdgrp.avt.ref = "";
      this.model.ltdgrp.avt.cnnamadr = "";
      this.model.ltdgrp.avt.ennamadr = "";
      let ptsList = [];
			ptsList.push(this.model.ltdgrp.adt);
			ptsList.push(this.model.ltdgrp.con);
			ptsList.push(this.model.ltdgrp.rmt);
			ptsList.push(this.model.lttp.own);
      let rol = "";
      if ("A" == this.model.ltdgrp.rec.avbwth) {
        rol = "ADT";
      } else if ("C" == this.model.ltdgrp.rec.avbwth) {
        rol = "OWN";
      } else if ("R" == this.model.ltdgrp.rec.avbwth) {
        rol = "RMT";
      } else if ("I" == this.model.ltdgrp.rec.avbwth) {
        rol = "OWN";
      }
      let res = ptsList.find((item) => item.pts.rol == rol);
      if (res != null && res != "") {
        let newRes = cloneDeep(res);
        this.model.ltdgrp.avt = newRes;
        this.model.ltdgrp.avt.pts.rol = "AVT";
      }
      // 1.控制是否可输入
      let val = this.model.ltdgrp.rec.avbwth;
      //Issuing Bank
      if ((val == "I" || val == "C") && this.model.ltdgrp.avt.pts.extkey !='' ) {
        this.avbDisabled = true;
        // this.disabledExtkey = false;
      } else if (val == "A" && this.model.ltdgrp.avt.pts.extkey !='' ) {
        //Advising Bank
        //Confirming Bank
        this.avbDisabled = true;
        // this.disabledExtkey = true;
      } else if (val == "O" && (this.model.ltdgrp.blk.avbwthtxt == null || this.model.ltdgrp.blk.avbwthtxt == "")){
          let value = this.getCodeTableValue("O", "avbwth");
          this.model.ltdgrp.blk.avbwthtxt = value;
      }else{
        this.avbDisabled = false;
        // this.disabledExtkey = false;
      }
    },
	}
}