Files
SGGL_SHJ/SGGL/FineUIPro.Web/HJGL/JoinMarking/assets/viewer-DS99NKTs.js
T

2 lines
13 KiB
JavaScript
Raw Normal View History

import{_ as e,r as t,m as a,p as l,B as n,c as o,o as i,b as r,d as s,l as u,t as c,e as v,n as d,v as f,i as p,q as m,P as y,s as g,u as h,z as b,A as x}from"./styles-YQqUhjjA.js";import"./pdfjs-DXqArq6h.js";import"./pdf-lib-AfLQbX6n.js";const w={class:"viewer-container"},S={class:"viewer-main"},k={class:"controls"},T=["disabled"],D={style:{"min-width":"54px","text-align":"center"}},J=["max"],P={style:{"margin-left":"4px"}},_={key:0,style:{display:"flex","align-items":"center",gap:"12px","margin-left":"8px","font-size":"12px",color:"#6b7280"}},F={class:"viewer"};x(e({__name:"ViewerApp",setup(e){const x=t(null),I=t(null),C=t(0),O=t(1),R=t(1),E=t(null),A=t(""),N=t({}),z=t(!1);let L=null;const B=t({startNumber:1,increment:1,prefix:"",suffix:"",fontSize:10,borderStyle:"none",annotationStyle:"arrow"});let H=null;const M=t({show:!1,message:"",type:"success"});let U=null;function W(e,t="success"){M.value={show:!0,message:e,type:t},clearTimeout(U),U=setTimeout(()=>{M.value.show=!1},2500)}const j=t(null),V=t(100),$=t(1),Y=a(()=>{const e=null!==j.value?j.value:$.value;return Math.round(100*e)});function Z(e){I.value=e.pdf,C.value=e.numPages,O.value=1,R.value=1,ie&&E.value&&b(()=>{E.value.setAnnotations(ie),b(()=>{E.value&&E.value.renderPage&&E.value.renderPage(O.value)}),W("标注数据已加载"),ie=null})}function q(e){$.value=e}function G(e){j.value=e,V.value=Math.round(100*e)}function K(){j.value=+V.value/100}async function Q(e){if(e&&e.trim())try{const t=await fetch(e);if(!t.ok)throw new Error(`获取失败: ${t.status}`);const a=await t.blob(),l=new FileReader;l.onload=e=>{const t=e.target.result;E.value?(E.value.setTemporaryImage(t,400),W("点击PDF上要放置图片的位置, 按ESC取消")):W("请先加载PDF","error")},l.onerror=()=>{W("读取图片数据失败","error")},l.readAsDataURL(a)}catch(t){console.error("导入图片错误:",t),W("导入图片失败: "+t.message,"error")}else W("图片URL为空","error")}async function X(){const e=document.getElementById("imgurl1"),t=e?.value?.trim();t?await Q(t):W("未找到图片地址1","error")}async function ee(){const e=document.getElementById("imgurl2"),t=e?.value?.trim();t?await Q(t):W("未找到图片地址2","error")}function te(){if(!E.value||!I.value)return void W("请先加载PDF","error");const e=document.getElementById("annotionData");if(!e||!e.value||!e.value.trim())return void W("未找到焊口数据","error");let t;try{const a=JSON.parse(e.value);t=Array.isArray(a)?a:null}catch(a){return void W("焊口数据格式错误","error")}if(t&&0!==t.length)try{const e=function(e){const t=document.createElement("canvas"),a=t.getContext("2d"),l=[{key:"index",label:"序号",width:50},{key:"JOT_JointNo",label:"焊口编号",width:100},{key:"WED_Code",label:"焊工代号",width:90},{key:"JOT_Location",label:"焊接位置",width:80},{key:"JOT_WeldDate",label:"焊接日期",width:100},{key:"DetectionTypeCode",label:"检测类型",width:80},{key:"IsRepair",label:"是否返修",width:70},{key:"IsHotProcess",label:"是否热处理",width:80},{key:"JOT_JointStatus",label:"焊口状态",width:80}],n=32,o=36,i=l.reduce((e,t)=>e+t.width,0)+16,r=o+n*e.length+16;t.width=2*i,t.height=2*r,t.style.width=i+"px",t.style.height=r+"px",a.scale(2,2),a.fillStyle="#ffffff",a.fillRect(0,0,i,r);const s=i-16;a.fillStyle="#e8edf2",a.fillRect(8,8,s,o),a.fillStyle="#1e3a5f",a.font='bold 14px "Microsoft YaHei", "SimHei", sans-serif',a.textAlign="center",a.textBaseline="middle";let u=8;for(const c of l)a.fillText(c.label,u+c.width/2,26),u+=c.width;a.font='13px "Microsoft YaHei", "SimHei", sans-serif';for(let c=0;c<e.length;c++){const t=e[c],o=44+c*n;c%2==1&&(a.fillStyle="#f5f7fa",a.fillRect(8,o,s,n)),a.fillStyle="#333333",a.textAlign="center",u=8;for(const e of l){let l="";l="index"===e.key?String(c+1):null!=t[e.key]?String(t[e.key]):"/";const n=e.width-8;let i=l;for(;a.measureText(i).width>n&&i.length>1;)i=i.slice(0,-1);i!==l&&(i+="…"),a.fillText(i,u+e.width/2,o+16),u+=e.width}}a.strokeStyle="#c0c8d4",a.lineWidth=1,a.strokeRect(8,8,s,o+n*e.length);for(let c=0;c<=e.length;c++){const e=44+c*n;a.be