import{U as c,_ as m,c as g,o as u,h as o,n as p,t as r,v as w}from"./index-D7n5ZNak.js";import{g as k,a as d,W as v}from"./document-Doy44Wja.js";import{g as f,a as b}from"./applyTemplate-CXUrzqQY.js";function P(i,t){var e=i.getResponseHeader("Content-Disposition"),n="";if(e){var s=pGetParamName(e,"filename=");s?n=decodeURIComponent(s):n="petro"+Date.getTime()}else n=t.substring(t.lastIndexOf("/")+1),n=n.split("?")[0];return n}function T(i,t,e,n){i=i.indexOf("?")>-1?i+"&newTime="+new Date().getTime():i+"?newTime="+new Date().getTime();var s=new XMLHttpRequest;s.onreadystatechange=function(){if(this.readyState==4&&this.status==200){e=e||P(s,i);var a=wps.Env.GetTempPath()+"/"+e,l=new FileReader;l.onload=function(){if(wps.FileSystem.Remove(a),wps.FileSystem.Exists(a)){alert("已有相同名称的文档打开了");return}wps.FileSystem.writeAsBinaryString(a,l.result),t(a)},l.readAsBinaryString(s.response)}},s.open("GET",i),s.responseType="blob",s.send()}function y(i,t){switch(typeof window.Application.Enum!="object"&&(window.Application.Enum=c.WPS_Enum),i){case"dockLeft":{let e=window.Application.PluginStorage.getItem("taskpane_id");if(e){let n=window.Application.GetTaskPane(e);n.DockPosition=window.Application.Enum.msoCTPDockPositionLeft}break}case"dockRight":{let e=window.Application.PluginStorage.getItem("taskpane_id");if(e){let n=window.Application.GetTaskPane(e);n.DockPosition=window.Application.Enum.msoCTPDockPositionRight}break}case"hideTaskPane":{let e=window.Application.PluginStorage.getItem("taskpane_id");if(e){let n=window.Application.GetTaskPane(e);n.Visible=!1}break}case"addString":{let e=window.Application.ActiveDocument;if(e){e.Range(0,0).Text=`Hello,
 wps加载项!
`;let n=window.Application.Selection.Range;n&&n.Select()}break}case"getDocName":{let e=window.Application.ActiveDocument;return e?e.Name:"当前没有打开任何文档"}}}const A={onbuttonclick:y},D={name:"TaskPane",data(){return{DemoSpan:"",docName:"",parContent:[]}},methods:{onbuttonclick(i){return A.onbuttonclick(i)},onDocNameClick(){let i=window.Application.ActiveDocument;this.docName=i.Name},onOpenWeb(){},test(){const t=window.Application.ActiveDocument.Content;console.log("range",t);const e="";t.InsertParagraphAfter(),t.Collapse(wps.Enum.wpCollapseEnd);const n=d();console.log("wpsParagraphs",n);const s=n.pop();console.log("lastParagraph",s),s.Range.InsertXML(e)},testPar(){d().forEach((t,e)=>{console.log(t),this.parContent.push(t.Range.Text)})},testTemp(){Application.Documents.Item(this.docName).CopyStylesFromTemplate("D:\\work\\work data\\admin\\请示1类公文模板(2025-09-19T10-15-04).docx")},async YongTest(){const i=k();T("http://221.226.175.250:9000/jvs-public/assistant/test.docx",async t=>{console.log(t);const e=v(t),n=await f(i,e);console.log(n),await b(i,e),e.Close(),wps.FileSystem.Remove(t)})}}};w(()=>{});const C={class:"global"},S={class:"divItem"},x={class:"divItem"},I={class:"divItem"},R={class:"divItem"};function E(i,t,e,n,s,a){return u(),g("div",C,[t[12]||(t[12]=o("div",{class:"divItem"},[p(" 这是一个网页，按 "),o("span",{style:{"font-weight":"bolder"}},'"F12"'),p(" 可以打开调试器。 ")],-1)),o("div",S,[t[9]||(t[9]=p(" 这个示例展示了wps加载项的相关基础能力，与B/S业务系统的交互，请用浏览器打开： ")),o("span",{style:{"font-weight":"bolder",color:"slateblue",cursor:"pointer"},onClick:t[0]||(t[0]=l=>a.onOpenWeb())},r(s.DemoSpan),1)]),t[13]||(t[13]=o("div",{class:"divItem"},[p(" 开发文档: "),o("span",{style:{"font-weight":"bolder",color:"slateblue"}},"https://open.wps.cn/docs/office")],-1)),t[14]||(t[14]=o("hr",null,null,-1)),o("div",x,[o("button",{style:{margin:"3px"},onClick:t[1]||(t[1]=l=>a.onbuttonclick("dockLeft"))},"停靠左边"),o("button",{style:{margin:"3px"},onClick:t[2]||(t[2]=l=>a.onbuttonclick("dockRight"))},"停靠右边"),o("button",{style:{margin:"3px"},onClick:t[3]||(t[3]=l=>a.onbuttonclick("hideTaskPane"))},"隐藏TaskPane"),o("button",{style:{margin:"3px"},onClick:t[4]||(t[4]=l=>a.onbuttonclick("addString"))},"文档开头添加字符串"),o("button",{style:{margin:"3px"},onClick:t[5]||(t[5]=l=>a.onDocNameClick())},"取文件名"),o("button",{style:{margin:"3px"},onClick:t[6]||(t[6]=l=>a.testPar())},"获取段落"),o("button",{style:{margin:"3px"},onClick:t[7]||(t[7]=l=>a.testTemp())},"模板应用"),o("button",{style:{margin:"3px"},onClick:t[8]||(t[8]=l=>a.YongTest())},"勇哥测试专用")]),t[15]||(t[15]=o("hr",null,null,-1)),o("div",I,[t[10]||(t[10]=p(" 文档文件名为： ")),o("span",null,r(s.docName),1)]),o("div",R,[t[11]||(t[11]=p(" 文档内容为： ")),o("span",null,r(s.parContent),1)])])}const W=m(D,[["render",E],["__scopeId","data-v-20423f08"]]);export{W as default};
