<template>
    <div class="eContainer">
      <c-page :title="title">
        <el-form
          ref="modelForm"
          label-width="120px"
          size="small"
          label-position="right"
          :model="model"
          :rules="rules"
          :validate-on-rule-change="false"
          :disabled="isDisabled"
        >
          <c-tabs v-model="tabVal" ref="elment" type="card">
            <el-tab-pane label="交易服务详情" name="trn">
              <c-content v-show="this.type=='info'">
                <m-trn-info :trnModel="trnModel" :model1="model1" />
              </c-content>
            </el-tab-pane>
          </c-tabs>
        </el-form>
        <div style="text-align: center">
          <c-button
            type="primary"
            style="margin-right: 10px"
            @click="commitEdit"
            v-if="type === 'edit'"
            >提 交</c-button
          >
          <c-button type="primary" @click="goBack">返 回</c-button>
        </div>
      </c-page>
    </div>
  </template>
  
  <script>
  import Utils from "~/utils";
  import Trn, { Pattern } from "./Trn.js";
  import Wfe from "./Wfe.js";
  
  import TrnInfo from "./TrnInfo.vue";
  
  import { queryById} from "~/service/manage/trn.js";
  
  export default {
    name: "StaticsDbitrn",
    components: {
      "m-trn-info": TrnInfo,
    },
    provide() {
      return {
        root: this,
      };
    },
    props: {
          type: {
              type: String,
              default: "info"
          },
          title: {
              type: String,
              default: "dbitrn"
          }
      },
    data() {
      return {
        model: new Trn().data,
        tabVal: "trn",
        rules: Pattern,
        model1:{
            inr: '',
            inidattim: '',
            ownref: '',
            relflg: '',
            inifrm: '',
            reloricur: '',
            reloriamt: '',
            iniusr:'',
            ininam:'',
            relcur:'',
            relamt:'',
            usg:'',
            usr:'',
            exedat:'',
            relreq:'',
            relres:'',
            inflev:'',
            inftxt:'',
            rprusr:'',
            ssninr:'',
            cpldattim:'',
        },
        trnModel:[],
        WfeModel:{
          inr:"",
          srv:"",
          sta:"",
          wfsinr:"",
          wfssub:"",
          rtycnt:"",
          tardattim:"",
          dattim:"",
          ssninr:"",
          txt:"",
          descripe:"",
          pageNum: 1,
          pageSize:PageSize,
          total: 0,
        },
      };
    },
    computed: {
      isDisabled() {
        return this.type === "info" || this.type === "delete";
      },
    },
    created() {
      if (this.type !== "add") {
        this.model1.inr = this.$route.params.inr
        queryById(this.model1).then((res) => {
        if (res.data.inr) {
          this.model1 = res.data;
        } else {
          this.$notify.error("信息不存在")
        }
        });
      }
    },
    methods: {
      commitEdit() {
        this.$refs.modelForm.validate((validated) => {
          if (validated) {
            edit(this.model)
              .then((res) => {
                this.$notify.success("保存成功!");
                this.goBack(true)
              })
              .catch((err) => {
                this.$notify.error("保存失败!");
              });
          } else {
            Utils.formValidateTips(this.$refs.modelForm.fields)
          }
        });
      },
      /**
       * update 是否更新inftrn的查询列表
       */
      goBack(update) {
        //this.$store.go(-1);
        this.$store.commit('delTagsArry', this.$route.path);
        this.$router.history.push('/business/dbltrn')
        // this.$store.dispatch("TagsView/delView", this.$route);
        // this.$router.push({ name: "StaticsDbltrn", params: { update } });
      },
  
    },
  };
  </script>
  
  <style>
  </style>