<template>
  <div class="eContainer">
    <el-form :model="model" :rules="rules" ref="modelForm" label-width="200px" size="small" :validate-on-rule-change="false">
       <c-tabs v-model="activeName" ref="elment" type="card" @tab-click="tabClick" >
        
            <!--PD000001 -->
           <el-tab-pane label="内容" name="ovwp">
                <m-ovwp :model="model" :codes="codes"/>
           </el-tab-pane>
 
            <!--PD000275 -->
           <el-tab-pane label="明细" name="detp">
                <m-detp :model="model" :codes="codes"/>
           </el-tab-pane>
 
            <!--PD000342 -->
           <el-tab-pane label="条款" name="tk">
                <m-tk :model="model" :codes="codes"/>
           </el-tab-pane>

           <!--PD000027 -->
           <el-tab-pane label="或有" name="engp" v-if="model.lidgrp.cbs.nom1.amt!=''">
                <m-engp :model="model" :codes="codes"/>
           </el-tab-pane>

           <!--PD000000 -->
           <el-tab-pane label="结算" name="setpan">
                <m-setpan :model="model" :codes="codes"/>
           </el-tab-pane>

           <el-tab-pane label="分录" name="glepan">
           </el-tab-pane>

           <!--PD000000 -->
           <el-tab-pane label="附言" name="coninfp">
                <m-coninfp :model="model" :codes="codes"/>
           </el-tab-pane>

           <!--PD000529 -->
           <el-tab-pane label="面函" name="docpan">
                <m-docpan :model="model" :codes="codes" ref="docpan"/>
           </el-tab-pane>

           <el-tab-pane label="附件信息" name="doctre">
                <m-doctre :model="model" :codes="codes"/>
           </el-tab-pane>

            <!--PD000361 -->
           <el-tab-pane label="Mt799" name="mt799">
                <m-mt799 :model="model" :codes="codes"/>
           </el-tab-pane>

           <el-tab-pane label="账户概况" name="actlst">
                <m-actlst :model="model" :codes="codes"/>
           </el-tab-pane>
 
            <!--PD000065 -->
           <!-- <el-tab-pane label="PD000065" name="rbip">
                <m-rbip :model="model" :codes="codes"/>
           </el-tab-pane> -->
 
            <!--PD000077 -->
           <!-- <el-tab-pane label="PD000077" name="detp">
                <m-detp :model="model" :codes="codes"/>
           </el-tab-pane> -->
 
            <!--PD000361 -->
           <!-- <el-tab-pane label="PD000361" name="mt799">
                <m-mt799 :model="model" :codes="codes"/>
           </el-tab-pane>
  -->
            <!--PD000019 -->
           <!-- <el-tab-pane label="PD000019" name="litbenl1">
                <m-litbenl1 :model="model" :codes="codes"/>
           </el-tab-pane> -->
 
            <!--PD000021 -->
           <!-- <el-tab-pane label="PD000021" name="litapll1">
                <m-litapll1 :model="model" :codes="codes"/>
           </el-tab-pane> -->
 
            <!--PD000020 -->
           <!-- <el-tab-pane label="PD000020" name="litrmbl1">
                <m-litrmbl1 :model="model" :codes="codes"/>
           </el-tab-pane> -->
 
 
            <!--PD000510 -->
           <!-- <el-tab-pane label="PD000510" name="addbcb">
                <m-addbcb :model="model" :codes="codes"/>
           </el-tab-pane> -->
 
            
 
            <!--PD000001 -->
           <!-- <el-tab-pane label="PD000001" name="ccvpan">
                <m-ccvpan :model="model" :codes="codes"/>
           </el-tab-pane> -->
       </c-tabs>
        <c-bus-button :$pntvm="this"></c-bus-button>
    </el-form>
    <c-grid-ety-prompt-dialog ref="etyDialog" :promptData="promptData" v-on:select-ety="selectEty"></c-grid-ety-prompt-dialog>
  </div>
</template>
<script>
import Api from "~/service/Api"
import Utils from "~/utils/index"
import CodeTable from "~/config/CodeTable"
import Ditopn from "~/model/Ditopn"
import CommonProcess from "~/mixin/CommonProcess"
import Pattern from "~/model/Ditopn/Pattern"
import Default from "~/model/Ditopn/Default";
import Check from "~/model/Ditopn/Check";
import Ovwp from "./Ovwp"
import Revp from "./Revp"
import Tk from "./Tk"
import Rbip from "./Rbip"
import Detp from "./Detp"
import Mt799 from "./Mt799"
import Litbenl1 from "./Litbenl1"
import Litapll1 from "./Litapll1"
import Litrmbl1 from "./Litrmbl1"
import Setpan from "./Setpan"
import Engp from "./Engp"
import Addbcb from "./Addbcb"
import Docpan from "./Docpan"
import Coninfp from "./Coninfp"
import Ccvpan from "./Ccvpan"
import Doctre from "./Doctre.vue"
import Actlst from "./Actlst.vue"


export default {
    components:{
        "m-ovwp" : Ovwp,
        "m-revp" : Revp,
        "m-tk" : Tk,
        "m-rbip" : Rbip,
        "m-detp" : Detp,
        "m-mt799" : Mt799,
        "m-litbenl1" : Litbenl1,
        "m-litapll1" : Litapll1,
        "m-litrmbl1" : Litrmbl1,
        "m-setpan" : Setpan,
        "m-engp" : Engp,
        "m-addbcb" : Addbcb,
        "m-docpan" : Docpan,
        "m-coninfp" : Coninfp,
        "m-ccvpan" : Ccvpan,
        "m-doctre" : Doctre,
        "m-actlst" : Actlst
    },
    provide() {
        return {
            root: this
        }
    },
    mixins: [CommonProcess],    // 里面包含了Default、Check等的公共处理
    data(){
        return {
            activeName: "ovwp",
            trnName:"ditopn",
            model:new Ditopn().data,
            checkRules: Check,
            defaultRules: Default,
            pattern: Pattern,
            rules:null,
            codes:CodeTable
        }
    },
    methods:{
        tabClick(vm){
             if(this.isInDisplay){
                return
            }
            const name = vm.name
            if (name === "engp") {
                this.executeRule("liaall.engp").then(res => {
                    const data = res.data;
                    Utils.copyValueFromVO(this.model, data)
                })
            }
            if (name === "glepan") {
                this.executeRule("setmod.glemod.glepan").then(res => {
                    const data = res.data;
                    this.$refs.glepan.stmData.data = res.data.setmod_glemod_gleshwstm.rows;
                    //Utils.copyValueFromVO(this.model, data)
                })
            }
            if (name === "setpan") {
                this.executeRule("setmod.setpan").then(res => {
                    if (res.respCode == "AAAAAA"){
                        const data = res.data;
                        Utils.copyValueFromVO(this.model, data)
                    }
                })
            }
            if (name === "docpan") {
                this.executeRule("trnmod.trndoc.docpan").then(res => {
                    if (res.respCode == "AAAAAA"){
                        const data = res.data;
                        Utils.copyValueFromVO(this.model, data)
                        var stm = [];
                        let k = 0;
                        for(let i = 0; i < res.data.trnmod_trndoc_doceot.length; i++){
                            if(res.data.trnmod_trndoc_doceot[i].role != ""){
                                stm[k++] = res.data.trnmod_trndoc_doceot[i];
                            }
                        }
                        this.$refs.docpan.stmData.data = stm
                    }
                })
            }

        }
    },
    created:async function(){
        console.log("进入ditopn交易");
        let rtnmsg = await Api.post("ditopn/init",{params:{}})
        if(rtnmsg.respCode == SUCCESS)
        {
           //TODO 处理数据逻辑
          Utils.copyValueFromVO(this.model,rtnmsg.data)
        }
        else
        {
            this.$notify.error({title: '错误',message: '服务请求失败！'});
        }
    }
  }
</script>
<style></style>
