<template>
  <c-page title="汇出汇款">
    <div class="eContainer">
      <el-form
        :model="model"
        :rules="rules"
        ref="modelForm"
        label-width="200px"
        size="small"
        :validate-on-rule-change="false"
      >
        <el-tabs ref="elment" type="card" @tab-click="tabClick">
          <el-tab-pane label="Overview">
            <!--PD000020 -->
            <m-opnp1 :model="model" :codes="codes" />
          </el-tab-pane>

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

          <el-tab-pane label="Bookings">
            <!--PD000001 -->
            <m-glepan :model="model" :codes="codes" ref="glepan"/>
          </el-tab-pane>

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

          <el-tab-pane label="Messages">
            <!--PD000529 -->
            <m-docpan :model="model" :codes="codes" />
          </el-tab-pane>

          <el-tab-pane label="Attachments">
            <!--PD000546 -->
            <m-doctre :model="model" :codes="codes" />
          </el-tab-pane>

          <el-tab-pane label="Finance">
            <!--PD000218 -->
            <m-finp :model="model" :codes="codes" />
          </el-tab-pane>

          <el-tab-pane label="外管信息">
            <!--PD000009 -->
            <m-wg :model="model" :codes="codes"/>
          </el-tab-pane>
          
          <el-tab-pane label="境内汇款申请书-基础信息" v-if="model.bopmod.szflg === '2' && model.bopmod.basflg">
            <m-dbe :model="model" :codes="codes"></m-dbe>
          </el-tab-pane>
          <el-tab-pane label="境外汇款申请书-基础信息" v-if="model.bopmod.szflg === '1' && model.bopmod.basflg">
            <m-dbb :model="model" :codes="codes"></m-dbb>
          </el-tab-pane>

          <el-tab-pane label="跨境人民币申报">
            <!--PD000002 -->
            <m-cnyp :model="model" :codes="codes"/>
          </el-tab-pane>
          <el-tab-pane label="2111跨境支出信息" v-if="model.cnybop.outflg==='1'">
            <m-outp :model="model" :codes="codes"></m-outp>
        </el-tab-pane>
        </el-tabs>
        
      </el-form>
    </div>
  </c-page>
</template>
<script>
import Api from "~/service/Api";
import Utils from "~/utils/index"
import CodeTable from "~/config/CodeTable";
import Cptopn from "~/model/Cptopn";
import CommonProcess from "~/mixin/CommonProcess";
import Pattern from "~/model/Cptopn/Pattern";
import Default from "~/model/Cptopn/Default";
import Check from "~/model/Cptopn/Check";
import Opnp1 from "./Opnp1";
import Setpan from "./Setpan";
import Glepan from "./Glepan";
import Coninfp from "./Coninfp";
import Docpan from "./Docpan";
import Doctre from "./Doctre";
import Finp from "./Finp";
import Wg from "./Wg";
import Cnyp from "./Cnyp";
import Dbe from "./Dbe.vue"
import Dbb from "./Dbb.vue"
import Outp from "./Outp.vue"

export default {
  components: {
    "m-opnp1": Opnp1,
    "m-setpan": Setpan,
    "m-glepan": Glepan,
    "m-coninfp": Coninfp,
    "m-docpan": Docpan,
    "m-doctre": Doctre,
    "m-finp": Finp,
    "m-wg": Wg,
    "m-cnyp": Cnyp,
    "m-dbe": Dbe,
    "m-dbb": Dbb,
    "m-outp": Outp
  },
    provide() {
        return {
            root: this
        }
    },
  mixins: [CommonProcess], // 里面包含了Default、Check等的公共处理
  data() {
    return {
      trnName:"cptopn",
      model: new Cptopn().data,
      checkRules: Check,
      defaultRules: Default,
      pattern: Pattern,
      rules:null,
      codes: {...CodeTable},
    };
  },
   methods:{
        tabClick(vm){
            if(this.isInDisplay){
                return
            }
            const label = vm.label
           
            if (label === "Settlement") {
                this.executeRule("setmod.setpan").then(res => {
                    if (res.respCode == "AAAAAA"){
                        const data = res.data;
                        Utils.copyValueFromVO(this.model, data)
                    }
                })
            }
             if (label === "Bookings") {
                this.executeRule("setmod.glemod.glepan").then(res => {
                    const data = res.data;
                    this.$refs.glepan.stmData.data = res.data.setmod_glemod_gleshwstm.rows;
                })
            }
        }
    },
  created: async function () {
    console.log("进入cptopn交易");
    let rtnmsg = await Api.post("cptopn/init", { params: {} });
    if (rtnmsg.respCode == SUCCESS) {
      Utils.copyValueFromVO(this.model,rtnmsg.data)
    } else {
      this.$notify.error({ title: "错误", message: "服务请求失败！" });
    }
  },
};
</script>
<style>
</style>
