<template>
  <div>
    <button @click="openmodel()">测试按钮</button>  <button @click="loadData()">加载数据</button>

    <button @click="printWord()">测试打印word</button>
    <button @click="printExcel()">测试打印excel</button>
    <button @click="printPdf()">测试打印pdf</button>
    <div class="relLayout">
      <gaea-editor ref="editor"></gaea-editor>
    </div>
    <object id="pdfActiveX" name="pdfActiveX" classid="clsid:CA8A9780-280D-11CF-A24D-444553540000" width="0" height="0" border="0"><param name="_Version" value="65539"></object>

  </div>
</template>

<script>
    import eventbus from '../../../../myPlugin/page-ide/lib/service/eventbus';
    export default {
        methods:{
            loadData(){
                eventbus.$emit("showTemplateType",{
                    type:'add'});
            },
            printPdf(){

                try {
                    //  pdfActiveX.SetShowToolbar(false);
                    var pdf_O = document.getElementById("pdfActiveX");
                    pdf_O.src = "http://10.16.11.105/paoyici-city-dev-data/oss_portal/001/licenseManage/2019/db8fe636-b677-4a38-92a4-4e8db0447c5c/1111.pdf";
                    //	document.write(dzswj_ip+dzswj_wsdy+""+cjh+"/"+cgs);
                    pdf_O.PrintAll();
                  //  document.getElementById(id).setAttribute("disabled", true);
                   // msg();
                } catch (e) {
                    alert("未安装adobe reader插件，请联系管理员安装！");
                }
            },
            printWord()
            {
                var obj="http://117.39.29.95:8221/paoyici-city-uat-data/oss_portal/001/uploads/2018/300246d1-7af0-4d80-a15a-9e5d50f271b8/test.docx";
                var wordApp = null;
                try{
                    wordApp = new ActiveXObject('Word.Application');    }catch(e)
                {
                    alert(e+', 原因分析: 浏览器安全级别较高导致不能创建Word对象或者客户端没有安装Word软件');
                    return;
                }
                //var   Doc=wordApp.Documents.Open('http://'+window.location.host+obj.value);
                var   Doc=wordApp.Documents.Open(obj);
                wordApp.Application.Visible = false;
                wordApp.visible = false;
                wordApp.ActiveDocument.printout();
                wordApp.ActiveDocument.close();
                wordApp.Quit();
                wordApp=null;
            },
            printExcel()
            {
                var obj="http://10.16.11.105/paoyici-city-dev-data/oss_portal/001/licenseManage/2019/dc27e024-7cdd-4f87-a5b3-f71035fec76c/test2.xlsx";
                var xlsApp = null;
                try{
                    xlsApp = new ActiveXObject('Excel.Application');    }catch(e)
                {
                    alert(e+', 原因分析: 浏览器安全级别较高导致不能创建Excel对象或者客户端没有安装Excel软件');
                    return;
                }
                //var xlBook = xlsApp.Workbooks.Open('http://'+window.location.host+obj.value);
                var xlBook = xlsApp.Workbooks.Open(obj);
                var xlsheet = xlBook.Worksheets(1);
                xlsApp.Application.Visible = false;
                xlsApp.visible = false;
                xlsheet.Printout;
                xlsApp.Quit();
                xlsApp=null;
            },
            openmodel(){

                this.$store.commit('viewport/deleteDataArr', {});
                let sth=this.$refs.editor.exportData(1);
                console.log(JSON.stringify(sth));
                Bus.$emit("initTemplateInstance",{});
                //let sth=this.$refs.editor.exportData(2);

            }
        },
        created(){
            Bus.$on("initTemplateInstance",function(){
                debugger;
            });
        },mounted(){
            this.$refs.editor.updateHeight("100px");
        }

    };
</script>

<style scoped lang="less">
  .relLayout{

  }
  .iTDNZh {
    position: absolute;
    left: 0px;
    top:40px;
    overflow: hidden !important;
  }
  .hkgySY {
    min-height: 400px !important;
  }
  .attachment-wrap .attachment {
    line-height: 10px !important;
  }
  .attachment-wrap .attachment .title {
    overflow: hidden !important;
  }
</style>
