|
- <!DOCTYPE html>
- <html lang="en">
-
- <head>
- <title>导入模板</title>
- <meta charset="UTF-8">
- <script type="text/javascript" src='js/main.js'></script>
- <script type="text/javascript" src="otherslib/lib/vue.min.js"></script>
- <style type="text/css">
- * {
- box-sizing: border-box;
- }
-
-
- .clear:after {
- content: "";
- display: block;
- clear: both;
- }
-
- html,
- body,
- #template {
- margin: 0;
- padding: 0;
- width: 100%;
- height: 100%;
- }
-
- .row {
- width: 100%;
- border-top: 2px solid #e7e7e7;
- }
-
- .row>div {
- height: 100%;
- }
-
- #file_select {
- width: 100%;
- padding-left: 5%;
- }
-
- .def_control {
- height: 55%;
- width: 100%;
- font-size: 18px;
- }
-
- .btn_box {
- width: 16%;
- float: right;
- line-height: 4.5em;
- margin-right: 3%;
- }
- </style>
- </head>
-
- <body>
-
- <div id="template">
- <div class="row" style="height:50%;padding-top: 3%;">
- <div id="file_select">
- <span>文件名:</span>
- <select class="def_control" style="width: 80%;" v-model="templateItem">
- <option value="-1">请选择模板</option>
- <option v-for="(item,key) in templates" :value="item.tempId" :key="key">{{item.tempName}}</option>
- </select>
- </div>
- </div>
- <div class="row" style="height: 50%;">
- <div class="btn_box">
- <button class="def_control" type="button" @click="cancel()">取消</button>
- </div>
- <div class="btn_box">
- <button class="def_control" type="button" @click="OnImportTemplate()">导入</button>
- </div>
- </div>
- </div>
-
- </body>
-
- </html>
- <script>
-
-
-
- function importTemlateFile(templateURL) {
- var wpsApp = wps.WpsApplication();
- var activeDoc = wpsApp.ActiveDocument;
- if (!activeDoc) {
- alert("文档不存在");
- return;
- }
- var selection = wpsApp.ActiveWindow.Selection;
- selection.WholeStory();
- selection.Delete();
- selection.InsertFile(templateURL);
- if (activeDoc.Revisions.Count > 0) {
- activeDoc.AcceptAllRevisions();
- }
- }
-
-
- function OnImportTemplate() {
- var templateId = vm.templateItem;
- console.log(vm);
- if (templateId == -1) {
- alert('请选中模板!!');
- return;
- }
-
-
-
-
- var templateURL = getHtmlURL("template/模板.docx");
- importTemlateFile(templateURL);
- window.opener = null;
- window.open('', '_self', '');
- window.close();
- wps.OAAssist.ShellExecute("ksowebstartupwps://");
- }
-
-
- function cancel() {
- window.close();
- wps.OAAssist.ShellExecute("ksowebstartupwps://");
- }
-
- var vm = new Vue({
- el: "#template",
- data: {
- templateItem: -1,
- templates: {}
- },
- methods: {
- getAllTemplate: function () {
- var _this = this
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- this.templates=[{
- tempName:'模板',
- tempId:1
- }]
- }
- },
- mounted: function () {
- this.getAllTemplate();
- }
- });
-
-
- </script>
|