<!--
 * @Author: zqm
 * @Date: 2021-06-22 11:23:35
 * @LastEditTime: 2021-07-12 13:47:21
 * @LastEditors: Please set LastEditors
 * @Description: 云代账入口
 * @FilePath: \taxFormToolFramework\src\pages\view\cloudAccount.vue
-->

<template>
  <el-container>
    <el-header class="header_ydz">
      <buttonArea ref="buttonArea"></buttonArea>
    </el-header>
    <el-container>
      <el-main>
        <div ref="taxForm" id="taxForm" class="taxForm"></div>
      </el-main>
      <el-aside class="bar">
        <informationBar ref="infoBar"></informationBar>
      </el-aside>
    </el-container>
  </el-container>
</template>

<script>
import buttonArea from "../../components/buttonArea";
import informationBar from "../../components/informationBar.vue";

export default {
  name: "",
  components: {
    buttonArea, informationBar
  },
  data: function () {
    return {
      engines: ''
    };
  },
  methods: {
    //查询初始化数据
    initSbbInfo() {
      var openData = this.$store.state.data.openData
      var _self = this;
      var getUrl = config.selectSbbInfo; //涉税 正常开表
      this.ajax.post(getUrl, openData, function (returnData) {
        _self.createEngine(returnData.content);
      }, "json", true);
    },
    createEngine(data) {
      var header = data.data[0].header
      var tbrq = data.openTableData.openTableDate
      var nsrmc = data.init.jbxx[0].nsrmc
      var sbdm = header.bbDm.split("_")[1];
      var url = "../../static/engineJson/" + header.bblxDm + "/" + sbdm + "/" + header.bbDm + '_' + header.versionNumber + ".json";
      var template = {}
      var _self = this
      this.ajax.get(url, function (res) {
        if (res.template) {
          template = res.template;
        } else {
          template = res;
        }
        _self.loading = true;
        _self.engines = new engine({
          el: "#taxForm",
          data: {
            pzzlDm: header.bblxDm,
            bbDm: sbdm,
            bbVersion: header.versionNumber,
            sksssjq: header.sksssjq,
            sksssjz: header.sksssjz,
            tbrq: tbrq,
            nsrmc: nsrmc,
            readOnly: false,
            bgColor: true,
            uniquePositioning: true,
            thousandCharacterSwitch: true,
            areaPaste: true,
            verificationSwich: true,
            initData: {},
            tableData: {},
            template: template
          },
          userCellOperation: function (e) {
            _self.$store.commit("saveStatus", false);
          },
          tableConfigData: function (s) {
            _self.$store.commit("configData", s);
            _self.dealConfigData(s)
          },
        });
      }, "json");
      this.loading = false;
      // var addtLProp = {}
      // addtLProp.bbDm = item.bbDm;
      // _self.engines.addtLProp = addtLProp;
      this.$store.commit("engines", _self.engines);
      this.showOpenModal()
    },
    showOpenModal() {
      var openAlter = this.$store.state.data.openAlter
      if (openAlter.length > 0) {
        this.$alert(openAlter[0].message, '提示', { type: openAlter[0].mesType });
      }
      var openConfirm = this.$store.state.data.openConfirm
      if (openConfirm.length > 0) {
        this.$confirm(openConfirm[0].message, '提示', {
          confirmButtonText: '确定',
          cancelButtonText: '取消',
          type: openConfirm[0].mesType
        }).then(() => {
        }).catch(() => {
        });
      }
    }
  },
  mounted: function () {
    var height = document.documentElement.clientHeight;
    this.$refs.taxForm.style.height = height - 80 + "px";
    this.initSbbInfo()
  }
};
</script>

<style scoped>
.header_ydz {
  padding: 0 20px;
  height: 50px !important;
  line-height: 50px !important;
  background-color: #f8f8f8;
  border-bottom: none;
  margin-left: -10px;
}
</style>


