index.js 9.33 KB
import Api from '~/service/Api';
import Utils from '~/utils';
import commonFunctions from '~/mixin/commonFunctions.js';
import buildFn from './buildCommons.js';
import setmod from '~/components/business/setmod/event';
import glentry from '~/components/business/glentry/event';
import engp from '~/components/business/engp/event';
import docpan from '~/components/business/docpan/event';
import ccvpan from '~/components/business/ccvpan/event';
import limitbody from '~/components/business/limitbody/event';
import doctre from '~/components/business/doctre/event';

export default {
    mixins: [commonFunctions],
    methods: {
        ...setmod,
        ...glentry,
        ...engp,
        ...docpan,
        ...ccvpan,
        ...limitbody,
        ...doctre,
        async init() {
            const params = {
                spt: JSON.parse(localStorage.getItem('row_' + this.trnName)),
                trnmod: {
                    trn: JSON.parse(localStorage.getItem('review_' + this.trnName))
                }
            }
            if (typeof (this.$route.query.inr) == 'string') {
                params.spt = null
                params.trnmod.trn = null
            }
            const loading = this.loading();
            const res = await Api.post('/service/letnot/init', {
                ...params,
                transName: this.trnName,
                userId: window.sessionStorage.userId || 'ZL',
                ledgrp: {
                    rec: {
                        inr: this.$route.query.inr
                    }
                }
            });
            loading.close();
            if (!res.data) {
                return
            }
            this.copyValueFromVoData(this.model, res.data)
            this.copyValueFromVoData(this.model.setmod.setfeg, res.data.setfeg)
            this.copyValueFromVoData(this.model.setmod.setfog, res.data.setfog)
            this.copyValueFromVoData(this.model.setmod.setglg, res.data.setglg)
        },
        // 兼容处理在前端model中定义了字段,后端返回的数据中不存在字段的问题
        copyValueFromVoData(model, data) {
            let keysList = Object.keys(model)
            keysList.map((key) => {
                if (data[key]) {
                    if (Utils.typeOf(model[key]) === 'Object') {
                        this.copyValueFromVoData(model[key], data[key])
                    } else {
                        this.$set(model, key, data[key])
                    }
                }
            })
        },
        async tabClick(tab) {
            if (this.isInDisplay) {
                return;
            }
            let name = tab.name;
            switch (name) {
                case 'ccvpan':
                    let ccvpanRequest = buildFn.buildCcvpan(this.model, this.trnName);
                    this.processLiaccv(ccvpanRequest);
                    break;
                case 'engp':
                    let engpRequest = buildFn.buildEngp(this.model, this.trnName);
                    this.processLiaall(engpRequest);
                    break;
                case 'setmod':
                    let setfegRequest = buildFn.buildSetfeg(this.model, this.trnName);
                    // 此处利用回调是为了等setfeg的接口调用完成后才去获取setglg参数,由于setglg参数依赖于setfeg函数的返回值
                    this.processSetpan(setfegRequest, () => {
                        return buildFn.buildSetglg(this.model, this.trnName);
                    });
                    break;
                case 'docpan':
                    let docpanRequest = buildFn.buildDocpan(this.model, this.trnName);
                    this.processTrndoc(docpanRequest);
                    break;
                case 'glentry':
                    let glentryRequest = buildFn.buildGlentry(this.model, this.trnName);
                    this.processGlentry(glentryRequest);
                    break;
                case 'limitbody':
                    let limitbodyRequest = buildFn.buildLimitbody(
                        this.model,
                        this.trnName
                    );
                    this.processLimitbody(limitbodyRequest);
                    break;
                case 'doctre':
                    let doctreRequest = buildFn.buildDoctre(this.model, this.trnName);
                    this.processDoctre(doctreRequest);
                    break;
                default:
                    return;
            }
        },
        // 获取弹框表格数据
        async queryGridEtyPromptDialogData(type, ptytyp) {
            let params = {
                userId: window.sessionStorage.userId || 'ZL',
                ptytyp: ptytyp,
                extkey: this.model.ledgrp[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;
            }
        },
        // 选中letnot弹框表格的行数据
        async selectGridEtyPromptData(row) {
            let params = {
                ...row,
            };
            let res = await Api.post('/service/ptspta/fetch', params);
            if (res.respCode == SUCCESS) {
                this.$set(this.model.ledgrp, row.role.toLowerCase(), res.data);
            }
        },

 //获取信用证编号
    async onLitpButgetref() {
        let params = {
          ptainr: this.model.ledgrp.ben.pts.ptainr,
          businessType: 'AD',
          tbl: 'AD',
        };
        const loading = this.loading();
        let res = await Api.post('/service/letnot/getOwnRef', params);
        if (res.respCode == SUCCESS) {
          loading.close();
          this.model.ledgrp.rec.ownref = res.data;
        }
      },
        // //获取信用证编号
        // async onLitpButgetref() {
        //   let params = {
        //     ptainr: this.model.ledgrp.apl.pts.ptainr,
        //     businessType: 'LG',
        //     tbl: 'LG',
        //   };
        //   const loading = this.loading();
        //   let res = await Api.post('/service/letnot/getOwnRef', params);
        //   if (res.respCode == SUCCESS) {
        //     loading.close();
        //     this.model.ledgrp.rec.ownref = res.data;
        //   }
        // },
        // // 初始化开立类型码表下拉列表
        // async queryHndtypCodeTableList(trnName) {
        //   let params = {
        //     letp: {
        //       swiftflg: this.model.letp.swiftflg,
        //     },
        //     ledgrp: {
        //       rec: {
        //         purpos: this.model.ledgrp.rec.purpos,
        //       },
        //     },
        //     transName: trnName.toUpperCase(),
        //   };
        //   // let res = await Api.post('/service/litopn/initHndtyp', params);
        //   // if (res.respCode == SUCCESS) {
        //   //   this.$set(this.codes, 'voHndtyp', res.data);
        //   // }
        // },
        // 是否SWIFT格式修改--联动保函开立类型
        // handleChangeSwiftflg() {
        //   this.queryHndtypCodeTableList(this.root.trnName);
        // },
        // 支出目的修改--联动保函开立类型
        // handleChangePurpos() {
        //   this.queryHndtypCodeTableList(this.root.trnName);
        // },
        apprulChange(v) {
            if (v !== 'OTHR') {
                this.model.ledgrp.rec.apprultxt = ''
            }
        },

        async avbwthFlg() {
            let ptsList = []
            ptsList.push(this.model.ledgrp.adv)
            ptsList.push(this.model.ledgrp.a2b)
            ptsList.push(this.model.ledgrp.iss)
            let params = {
                avbwth: this.model.ledgrp.rec.avbwth,
                ptsList
            };
            let res = await Api.post('/service/letnot/avbwthflg', params);
            if (res.respCode == SUCCESS) {
                this.model.ledgrp.avb.pts.extkey=res.data.pts.extkey;
                this.model.ledgrp.avb.pts.adrblk=res.data.pts.adrblk;
            }
        },

        openAddAmount(val) {
            if (val === '' && !(this.model.ledgrp.cbs.max2.amt == '0.000' && this.model.ledgrp.blk.addamtcov === '')) {
                this.$confirm('是否确定要删除此合同的附加金额?', '提示', {
                    confirmButtonText: '是',
                    cancelButtonText: '否',
                    type: 'warning',
                    showClose: false
                }).then(() => {//yes的执行在这里写
                    this.executeRule('letp.aamp.aammod.addamtflg').then(res => {
                        if (res.respCode == SUCCESS) {
                            this.updateModel(res.data)
                        }
                    })
                    // this.model.ledgrp.cbs.max2.amt ='0.000';
                    // this.model.ledgrp.blk.addamtcov = '';
                    // this.$message({
                    //       type: 'success',
                    //       message: '删除成功!'
                    // });
                }).catch(() => {//No的功能在这里写
                    this.model.letp.aamp.aammod.addamtflg = 'X'
                    // this.$message({
                    //   type: 'info',
                    //   message: '已取消'
                    // });
                });
            }
        },

    },
};