<template>
  <c-page title="汇入汇款">
    <div class="eContainer">
      <!-- <c-bus-button :$pntvm="this"></c-bus-button> -->
      <c-function-btn
        :handleSubmit="handleSubmit"
        :handleCheck="handleCheck"
        :handleStash="handleStash"
      >
        <el-button size="small">备忘录</el-button>
        <el-button size="small">影像信息</el-button>
        <!-- <el-button size="small">保存模板</el-button> -->
        <!-- <el-button size="small">使用模板</el-button> -->
        <el-button size="small">制裁信息</el-button>
        <!-- <el-button size="small">拆分报文</el-button> -->
        <el-button size="small">智能提示</el-button>
      </c-function-btn>
      <el-form
        :model="model"
        :rules="rules"
        ref="modelForm"
        label-width="150px"
        size="small"
        :validate-on-rule-change="false"
      >
        <c-tabs ref="elment" :value="tabVal" type="card" @tab-click="mimeTabClick">
          <el-tab-pane label="基本信息" name="opnp1">
            <!--PD000020 -->
            <c-content>
            <m-opnp1 :model="model" :codes="codes" />
            </c-content>
          </el-tab-pane>
           <el-tab-pane label="费用及账务" name="setpan">
            <!--PD000006 -->
            <c-content>
            <m-setpan :model="model" :codes="codes" />
            </c-content>
          </el-tab-pane>
           <el-tab-pane label="分录" name="glepan">
            <m-glepan :model="model" :codes="codes" ref="glepan" />
          </el-tab-pane>
          <el-tab-pane label="附言" name="coninfp">
            <!--PD000000 -->
            <m-coninfp :model="model" :codes="codes" />
          </el-tab-pane>
          
          <el-tab-pane label="附件" name="doctre">
            <!--PD000529 -->
            <m-doctre :model="model" :codes="codes" />
          </el-tab-pane>
          <el-tab-pane label="收账通知" name="docpan2">
            <!--PD000001 -->
            <m-docpan2 :model="model" :codes="codes" />
          </el-tab-pane>
          <el-tab-pane label="申报信息" name="sbxx">
            <!--PD000546 -->
            <m-sbxx :model="model" :codes="codes" />
          </el-tab-pane>
           <el-tab-pane label="2101跨境收入信息" name="incp" v-if="model.cnybop.cnyflg === '1'">
            <c-content>
            <m-incp :model="model" :codes="codes"></m-incp>
            </c-content>
          </el-tab-pane>
          <el-tab-pane label="报文及面函" name="docpan">
            <!--PD000000 -->
            <m-docpan :model="model" :codes="codes" />
          </el-tab-pane>
        </c-tabs>
      </el-form>
    </div>
     <c-grid-ety-prompt-dialog ref="etyDialog" :promptData="promptData" v-on:select-ety="selectEty"></c-grid-ety-prompt-dialog>
  </c-page>
</template>
<script>
import Api from "~/service/Api";
import Utils from "~/utils/index";
import CodeTable from "~/config/CodeTable";
import Cptadv from "~/model/Cptadv";
import commonProcess from "~/mixin/commonProcess";
import commonFuncs from "~/mixin/commonFuncs";
import Opnp1 from "./Opnp1";
import Docpan2 from "./Docpan2";
import Pattern from "~/model/Cptadv/Pattern";
import Default from "~/model/Cptadv/Default";
import Check from "~/model/Cptadv/Check";
// import Setpan from "./Setpan";
// import Coninfp from "./Coninfp";
// import Docpan from "./Docpan";
import Sbxx from "./Sbxx";
import Incp from "./Incp";

import Doctre from "~/views/Public/Doctre";
import Setpan from "~/views/Public/Setpan";
import Glepan from "~/views/Public/Glepan";
import Coninfp from "~/views/Public/Coninfp";
import Docpan from "~/views/Public/Docpan";
import Ptap from "~/views/Public/Ptap";

export default {
  name: "Cptadv",
  components: {
    "m-opnp1": Opnp1,
    "m-sbxx": Sbxx,
    "m-setpan": Setpan,
    "m-glepan": Glepan,
    "m-coninfp": Coninfp,
    "m-docpan": Docpan,
    "m-doctre": Doctre,
    "m-ptap": Ptap,
    "m-docpan2" : Docpan2,
    "m-incp" : Incp
  },
  provide() {
    return {
      root: this,
    };
  },
  mixins: [commonProcess,commonFuncs], // 里面包含了Default、Check等的公共处理
  computed: {},
  data() {
    return {
      tabVal: "opnp1",
      trnName: "cptadv",
      model: new Cptadv().data,
      // defaultRule:Default,
      // rules:this.mergeRules(Pattern,Check),
      checkRules: Check,
      defaultRules: Default,
      pattern: Pattern,
      rules: null,
      codes: { ...CodeTable },
    };
  },
  methods: {
    mimeTabClick(tab) {
      this.tabClick(tab)
      const name = tab.name
      let rulePath;
      if (name === "docpan2") {
        rulePath = "lendoc.docpan";
      }
      if (name === "sbxx") {
        rulePath = "bopmod.wg,cnybop.cnyp";
      }
      if (name === "incp") {
        rulePath = "cnybop.incp";
      }
      if (!!rulePath) {
        this.executeRule(rulePath).then(res => {
          if (res.respCode == SUCCESS) {
            this.updateModel(res.data)
          }
        })
      }
    }
  },
  created: async function () {
    console.log("进入cptadv交易");
    // let rtnmsg = await Api.post("cptadv/init",{params:{}});
    let rtnmsg = await this.init(this.$route.query);
    if (rtnmsg.respCode == SUCCESS) {
      //TODO 处理数据逻辑
      Utils.copyValueFromVO(this.model, rtnmsg.data);
      if (this.isInDisplay) {
        this.restoreDisplay();
      }
    } else {
      this.$notify.error({ title: "错误", message: "服务请求失败！" });
    }
  },
};
</script>
<style>
.el-col .el-divider--horizontal {
    margin-top: 0;
}
.messageLabel .el-form-item__label {
    text-align: left;
    font-weight: bold;
    font-size: 12px;
}
</style>
