index.js 3.58 KB
import Api from '~/service/Api';
import commonFunctions from '~/mixin/commonFunctions.js';
import { cloneDeep } from "lodash";
import Utils from "~/utils/index";
import Pts from '~/components/business/commonModel/Pts.js';
import BigNumber from "bignumber.js";
export default {
	mixins: [commonFunctions],
	methods: {
		advtypDefault() {
			if (this.model.btdgrp.rec.advtyp == "754")
			{
				this.model.btdgrp.rec.disdat = "";
				this.model.btdgrp.rec.dscinsflg = "";
				this.model.btdgrp.blk.docdisflg = "";
				let bttpModifyList = this.model.bttp.modifySet;
				if (!(bttpModifyList && bttpModifyList.includes("setnowflg")) )
				{
					this.model.bttp.setnowflg = "X";
				}
			}else if (this.model.btdgrp.rec.advtyp == "750"){
				this.model.btdgrp.rec.advdat = "";
				let modifyList = this.model.btdgrp.rec.modifySet;
				if (!(modifyList && modifyList.includes("dscinsflg")) )
				{
					this.model.btdgrp.rec.dscinsflg = "X";
				}
				let blkModifyList = this.model.btdgrp.blk.modifySet;
				if (!(blkModifyList && blkModifyList.includes("docdisflg")) )
				{
					this.model.btdgrp.blk.docdisflg = "X";
				}
				this.model.bttp.setnowflg = "";
				this.model.ltdgrp.rmt.pts.extkey = "";
			}else{
				this.model.btdgrp.rec.dscinsflg = "";
				this.model.btdgrp.blk.docdisflg = "";
				this.model.bttp.setnowflg = "";
				this.model.ltdgrp.rmt.pts.extkey = "";
      }
      
      //优化:通知到单默认初始化一些常规的单据信息
      if(this.model.btdgrp.rec.advtyp == "750" && this.model.bttp.docgrdmbe2.docgrd.length == 0 && this.model.bttp.docgrdmbe2.rightdocgrd .length == 0) {
        this.model.bttp.docgrdmbe2.docgrd = [
          {
            docnam: 'Commercial Invoice'
          },
          {
            docnam: 'Bill of Lading Originals'
          },
          {
            docnam: 'Packing List'
          }
        ]
        this.model.bttp.docgrdmbe2.rightdocgrd = [
          {
            docnam: 'Beneficiary\'s Certificate'
          },
          {
            docnam: 'Insurance Policy'
          }
        ]
      }else{
        this.model.bttp.docgrdmbe2.docgrd = []
        this.model.bttp.docgrdmbe2.rightdocgrd = []
      }
		},

		docprbrolDefault() {
			if (this.model.btdgrp.rec.docprbrol == "ADT")
			{
				this.model.btdgrp.prb = cloneDeep(this.model.ltdgrp.adt);
				this.model.btdgrp.prb.pts.rol = "PRB";
				
			}else if (this.model.btdgrp.rec.docprbrol == "BE2")
			{
				this.model.btdgrp.prb = cloneDeep(this.model.btdgrp.be2);
				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";

			}
		},

		defaultBtdgrpBlkDocdisN10(){
			if(this.model.btdgrp.blk.docdisflg === ""){
				this.model.btdgrp.blk.docdis = ""
			}
		},

		docstaDefault() {
			
			if (this.model.btdgrp.rec.disdat != "" && this.model.btdgrp.rec.advtyp == "750")
			{
				if(this.model.btdgrp.rec.rcvdatbe2 == "" || this.model.btdgrp.rec.rcvdatbe1 == "")
				{
					this.model.btdgrp.rec.docsta = "E";
				}else{
					this.model.btdgrp.rec.docsta = "F";
				}
			}
    },
    
    async queryAdvData(ltdinr) {
      let res = await Api.post("/Lc/lttdck/queryAdvData", ltdinr);
      if (res.respCode == SUCCESS) {
        return res.data;
      }
    },

    totamt() {
      if (this.model.btdgrp.blk.chaadd.trim() == "" && this.model.btdgrp.blk.chaded.trim() == ""){
        const maxAmt = this.model.btdgrp.cbs.max.amt;
        const max2Amt = this.model.btdgrp.cbs.max2.amt;
        this.model.btdgrp.rec.totamt =new BigNumber(maxAmt).plus(new BigNumber(max2Amt));
      }
    },
	}
}