index-CRFMH-eq.js 5.3 KB

1
  1. import{v as S,ae as X,ag as M,aL as F,N as D,af as Y,ah as q,ai as s,aj as u,ak as C,J as R,d as g,b as L,k as E,n as N,aM as I,y as K,D as Q,al as W,am as d,an as l,at as m,ap as r,aN as ee,az as P,aO as ae,aP as te,ao as k,aC as b,aE as le,aG as A,au as c,as as se,a as oe}from"./index-D68iA7pN.js";import{M as ne}from"./index-AOcxwHT9.js";const ie=S.sendStringToExecute.bind(S),de={class:"px-3"},ue={class:"d-flex algin-center mt-2 w-75"},re={class:""},me={class:""},pe={class:""},fe={class:""},ve=X({__name:"index",setup(ge){const U=M([]),o=M(""),_=(t=o.value)=>{t&&(U.value=Array.from(new Set([...U.value,o.value])))},T=()=>{const t=document.createElement("input");t.type="file",t.style.display="none",t.accept="image/*",document.body.appendChild(t);const e=oe();t.click(),h(!0),window.addEventListener("focus",()=>{setTimeout(()=>{e&&ie("MxFullscreen")},100)},{once:!0}),t.onchange=()=>{t.files&&t.files[0]&&(o.value=URL.createObjectURL(t.files[0]),B(o.value),setTimeout(()=>{URL.revokeObjectURL(o.value)},5e3))},t.remove()},n=F({width:0,height:0}),B=(t=o.value)=>{const e=L.getCurrentMxCAD();try{e.loadImage(t,a=>{if(!a){console.log("loadImage failed"),o.value="",R().error(g("加载图片失败"));return}n.width=a.width,n.height=a.height,_(t)})}catch(a){console.log("loadImage failed",a),o.value="",R().error(g("加载图片失败"))}},i=F({x:0,y:0}),p=D(!1,"Mx_AttachPictureDialog_isGetPt"),V=D(!1,"Mx_AttachPictureDialog_isGetZoomRatio"),v=D(!1,"Mx_AttachPictureDialog_isGetRotationAngle"),w=M(1),y=M(0),j=async()=>{if(o.value==="")return R().warning(g("请先选择图片"));h(!1);const t=L.getCurrentMxCAD();if(p.value){const e=new E;e.setMessage(g("指定插入点"));const a=await e.go();if(!a)return;i.x=a.x,i.y=a.y}if(V.value){const e=new E,a=new N(i.x,i.y);e.setBasePt(a),e.setMessage(g("指定缩放比例")),e.setUserDraw((O,Z)=>{const G=O.distanceTo(a)/n.width,$=n.width*G,H=n.height*G,J=new THREE.Vector3(a.x+$,a.y+H);Z.drawRect(a.toVector3(),J)});const f=await e.go();if(!f)return;w.value=I(f.distanceTo(a)/n.width,3)}if(v.value){const e=new K;e.setMessage(g("指定旋转角度"));const a=new N(i.x,i.y);e.setBasePt(a);const f=await e.go();if(!f)return;e.getDetailedResult()===Q.kCoordIn?y.value=I(f,3):y.value=I(f/(Math.PI/180),3)}t.drawImage(i.x,i.y,n.width*w.value,n.height*w.value,y.value,o.value)},{isShow:x,showDialog:h}=Y(!1,"_InsertImage",()=>{x.value||T()}),z=[{name:"确定",fun:j,primary:!0},{name:"关闭",fun:()=>h(!1)}];return(t,e)=>(W(),q(ne,{title:t.t("539"),modelValue:u(x),"onUpdate:modelValue":e[11]||(e[11]=a=>C(x)?x.value=a:null),"max-width":"600",footerBtnList:z},{default:s(()=>[d("div",de,[d("div",ue,[l(ee,{class:"mt-1 mr-2",items:U.value,modelValue:o.value,"onUpdate:modelValue":e[0]||(e[0]=a=>o.value=a),onChange:e[1]||(e[1]=a=>B())},{prepend:s(()=>[d("span",re,[m(r(t.t("138"))+"(",1),e[12]||(e[12]=d("span",{class:"text-decoration-underline"},"N",-1)),e[13]||(e[13]=m(") "))])]),_:1},8,["items","modelValue"]),l(te,{onClick:T},{default:s(()=>[l(P,{"key-name":"B"},{default:s(()=>[m(r(t.t("139")),1)]),_:1}),e[14]||(e[14]=m()),l(ae,{icon:"class:iconfont more"})]),_:1})]),l(se,{"align-stretch":"",class:"mt-2"},{default:s(()=>[l(k,{cols:4,"align-self":"auto"},{default:s(()=>[l(b,{title:t.t("540"),class:"h-100"},{default:s(()=>[l(le,{src:o.value,cover:"",crossorigin:"anonymous"},null,8,["src"])]),_:1},8,["title"])]),_:1}),l(k,{cols:4},{default:s(()=>[l(b,{title:t.t("541")},{default:s(()=>[l(A,{modelValue:u(p),"onUpdate:modelValue":e[2]||(e[2]=a=>C(p)?p.value=a:null)},{label:s(()=>[l(P,{"key-name":"S"},{default:s(()=>[m(r(t.t("144")),1)]),_:1})]),_:1},8,["modelValue"]),l(c,{class:"mt-1",modelValue:i.x,"onUpdate:modelValue":e[3]||(e[3]=a=>i.x=a),disabled:u(p)},{prepend:s(()=>e[15]||(e[15]=[d("span",{class:""}," X:",-1)])),_:1},8,["modelValue","disabled"]),l(c,{class:"mt-1",modelValue:i.y,"onUpdate:modelValue":e[4]||(e[4]=a=>i.y=a),disabled:u(p)},{prepend:s(()=>e[16]||(e[16]=[d("span",{class:""}," Y:",-1)])),_:1},8,["modelValue","disabled"])]),_:1},8,["title"]),l(b,{title:t.t("44")},{default:s(()=>[l(A,{modelValue:u(V),"onUpdate:modelValue":e[5]||(e[5]=a=>C(V)?V.value=a:null)},{label:s(()=>[l(P,{"key-name":"S"},{default:s(()=>[m(r(t.t("144")),1)]),_:1})]),_:1},8,["modelValue"]),l(c,{class:"mt-1 ml-1",type:"number",disabled:u(V),modelValue:w.value,"onUpdate:modelValue":e[6]||(e[6]=a=>w.value=a)},null,8,["disabled","modelValue"])]),_:1},8,["title"])]),_:1}),l(k,{cols:4,"align-self":"auto"},{default:s(()=>[l(b,{title:t.t("542"),class:"h-50"},{default:s(()=>[l(c,{class:"mt-1",type:"number",modelValue:n.width,"onUpdate:modelValue":e[7]||(e[7]=a=>n.width=a)},{prepend:s(()=>[d("span",me,r(t.t("543"))+":",1)]),_:1},8,["modelValue"]),l(c,{class:"mt-1",type:"number",modelValue:n.height,"onUpdate:modelValue":e[8]||(e[8]=a=>n.height=a)},{prepend:s(()=>[d("span",pe,r(t.t("544"))+":",1)]),_:1},8,["modelValue"])]),_:1},8,["title"]),l(b,{title:t.t("545"),class:"h-50"},{default:s(()=>[l(A,{class:"",modelValue:u(v),"onUpdate:modelValue":e[9]||(e[9]=a=>C(v)?v.value=a:null)},{label:s(()=>[l(P,{"key-name":"S"},{default:s(()=>[m(r(t.t("144")),1)]),_:1})]),_:1},8,["modelValue"]),l(c,{class:"mt-1",type:"number",modelValue:y.value,"onUpdate:modelValue":e[10]||(e[10]=a=>y.value=a),disabled:u(v)},{prepend:s(()=>[d("span",fe,r(t.t("235"))+":",1)]),_:1},8,["modelValue","disabled"])]),_:1},8,["title"])]),_:1})]),_:1})])]),_:1},8,["title","modelValue"]))}});export{ve as default};