<template>
    <div class="eContainer">
        <c-page title="进口保函开立">
            <el-form :model="model" :rules="rules" :validate-on-rule-change="false" label-position="right" label-width="120px"
                     ref="modelForm" size="small">
                <c-tabs @tab-click="curTabClick" ref="elment" type="card" v-model="tabVal">
                    <el-tab-pane :label="$t('commonModels.修改信息')" name="ovwpq">
                        <c-content>
                            <m-ovwpq :codes="codes" :model="model"/>
                        </c-content>
                    </el-tab-pane>
                    <el-tab-pane :label="$t('commonModels.开立信息')" name="opnInfo">
                        <c-content>
                            <m-opnInfo :codes="codes" :model="model"/>
                        </c-content>
                    </el-tab-pane>

                    <el-tab-pane :label="$t('commonModels.保函文本')" name="gidtxtp">
                        <m-gidtxtp :codes="codes" :model="model"/>
                    </el-tab-pane>

                    <el-tab-pane :label="$t('commonModels.授信/表外')" name="liacombo">
                        <c-content>
                            <div class="eibs-tab">
                                <c-collapse ref="liacombo" style="margin-bottom: 5px;" v-model="activeNames">
                                    <el-collapse-item :title="$t('commonCollapse.保证金')" name="ccvpan">
                                        <m-ccvpan :codes="codes" :model="model"/>
                                    </el-collapse-item>

                                    <el-collapse-item :title="$t('commonCollapse.统一授信')" name="limitbody">
                                        <m-limitbody :codes="codes" :model="model"/>
                                    </el-collapse-item>

                                    <el-collapse-item :title="$t('commonCollapse.表外信息')" name="engp">
                                        <m-engp :codes="codes" :model="model"/>
                                    </el-collapse-item>
                                </c-collapse>
                            </div>
                        </c-content>
                    </el-tab-pane>

                    <!--PD000027 -->
                    <el-tab-pane :label="$t('commonModels.费用/账务')" name="setpan">
                        <c-content>
                            <m-setmod :codes="codes" :model="model"/>
                        </c-content>
                    </el-tab-pane>

                    <!--PD000510 -->
                    <el-tab-pane :label="$t('commonModels.备查表')" name="addbcb">
                        <c-content>
                            <m-addbcb :codes="codes" :model="model"/>
                        </c-content>
                    </el-tab-pane>

                    <el-tab-pane :label="$t('commonModels.对外担保')" name="cfagit">
                        <c-content>
                            <m-cfagit
                                    :cfagitConfig="{
									conp: {
										isShow: model.cfagit.basflg == 'X' && model.gidgrp.rec.fingua =='Y',
										disabled: true
									},
									dclpp: {
										isShow: model.cfagit.dclflg == 'X' && model.cfagit.cfatyp == 'M' && model.gidgrp.rec.fingua =='Y',
										disabled: true
									},
								}"
                                    :codes="codes"
                                    :model="model"
                            >
                                <el-collapse-item :title="$t('commonCollapse.是否对外担保')" name="isFingua">
                                    <m-isFingua :codes="codes" :model="model"/>
                                </el-collapse-item>
                                <el-collapse-item :title="$t('commonCollapse.对外担保数据采集')" name="cfap"
                                                  v-if="model.gidgrp.rec.fingua == 'Y' && this.model.cfagit.recgrp != null && this.model.cfagit.recgrp.bas.exguarancode != null && this.model.cfagit.recgrp.bas.exguarancode != ''">
                                    <m-cfap :codes="codes" :model="model"/>
                                </el-collapse-item>
                            </m-cfagit>
                        </c-content>
                    </el-tab-pane>

                    <el-tab-pane :label="$t('commonModels.跨境人民币')" name="rmbbop">
                        <c-content>
                            <m-rmbbop :codes="codes" :model="model" ref="rmbbop"></m-rmbbop>
                        </c-content>
                    </el-tab-pane>

                    <el-tab-pane :label="$t('commonModels.统一名单')" name="usrmd">
                        <c-content>
                            <m-usrmd :codes="codes" :model="model"/>
                        </c-content>
                    </el-tab-pane>
                    <el-tab-pane :label="$t('commonModels.报文/面函')" name="docpan">
                        <c-content>
                            <m-docpan :codes="codes" :model="model"/>
                        </c-content>
                    </el-tab-pane>
                </c-tabs>
            </el-form>
            <c-function-btn :handleCheck="handleCheck" :handleStash="handleStash" :handleSubmit="handleSubmit">
            </c-function-btn>
        </c-page>
    </div>
</template>
<script>
    import CodeTable from "~/config/CodeTable";
    import Gitame from "../model";
    import commonDepend from "~/mixin/commonDepend";
    import operationFunc from "~/mixin/operationFunc";

    import event from "../event";
    import Check from "../model/check";
    import Default from "../model/default";
    import buildFn from "../event/buildCommons.js";

    // import Cnyp1 from "./Cnyp1";
    import Rmbbop from "~/components/business/rmb/rmbbop/views";
    import Cfagit from "~/components/business/Cfagit/views";
    import IsFingua from "./IsFingua";
    import Cfap from "./Cfap";

    import Ovwpq from "./Ovwpq";
    import OpnInfo from "./OpnInfo";

    import Addbcb from "./Addbcb";
    import Gidtxtp from "./Gidtxtp";
    import Gidtxtpc from "./Gidtxtpc";

    import Engp from "~/components/business/engp/views";
    import Ccvpan from "~/components/business/ccvpan/views";
    import Setmod from "~/components/business/setmod/views";
    import Docpan from "~/components/business/docpan/views";
    import Doctre from "~/components/business/doctre/views";
    import Limitbody from "~/components/business/limitbody/views";
    import Usrmd from "~/components/business/Usrmd/views";

    export default {
        name: "Gitame",
        components: {
            "m-ovwpq": Ovwpq,
            "m-opnInfo": OpnInfo,
            "m-addbcb": Addbcb,
            "m-gidtxtp": Gidtxtp,
            "m-gidtxtpc": Gidtxtpc,
            // "m-cnyp1": Cnyp1,
            "m-rmbbop": Rmbbop,
            "m-cfagit": Cfagit,
            "m-isFingua": IsFingua,
            "m-cfap": Cfap,

            "m-engp": Engp,
            "m-ccvpan": Ccvpan,
            "m-setmod": Setmod,
            "m-docpan": Docpan,
            "m-doctre": Doctre,
            "m-limitbody": Limitbody,
            "m-usrmd": Usrmd
        },
        provide() {
            return {
                root: this
            };
        },
        mixins: [operationFunc, event, commonDepend, Default, buildFn],
        data() {
            return {
                tabVal: "ovwpq",
                activeNames: ["ccvpan", "limitbody", "engp"],
                trnName: "gitame",
                trnType: "",
                model: new Gitame().data,
                codes: {
                    ...CodeTable
                },
                flag: false,
                atxinrList: [],
                atxinrcList: [],
                rules: {},
            };
        },
        computed: {
            rawRules() {
                return Check.apply(this);
            },
        },
        methods: {
            curTabClick(tab) {
                if (!this.isInDisplay) {
                    this.templateToText(tab.name)
                }
                this.tabClick(tab)
            },
            changeTxt(tabName) {
                this.templateToText(tabName)
            },
            // 保函模板转文本
            templateToText(tabName) {
                if (tabName === 'gidtxtp' || tabName === 'docpan') {
                    if (!this.model.gidgrp.rec.gidtxtmodflg) {
                        //发生修改则不再计算
                        let atxinr = this.model.gidgrp.rec.atxinr;
                        let textTempData = this.model.textTempData;
                        this.formatTxtp(this.model.gidgrp.blk.gtxgidtxt, atxinr, 'atx', textTempData, 'gidgrp')
                    }
                }
                if (tabName === 'gidtxtp' || tabName === 'docpan') {
                    if (!this.model.gidgrp.rec.gidtxtmodflgc) {
                        //发生修改则不再计算
                        let gtxinrc = this.model.gidgrp.rec.gtxinrc;
                        let textTempData = this.model.textTempData;
                        this.formatTxtp(this.model.gidgrp.blk.gtxgidtxtc, gtxinrc, 'atx', textTempData, 'gidgrp', true)
                    }
                }
            },
        },
        created() {
            console.log("进入gitame交易");
            this.rules = this.rawRules;
            let params = {
                transName: this.trnName,
                gidgrp: {
                    rec: {
                        inr: this.$route.query.inr || ""
                    }
                }
            };
            this.init(params);
        }
    };
</script>
<style>
</style>