Files
HJGL_DS/HJGL_DS/FineUIPro.Web/HJGL/JoinMarking/assets/main-D6A4EeIi.js
T
2026-08-07 17:26:21 +08:00

2 lines
55 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import{_ as e,A as t,r as l,w as a,a as n,c as o,o as i,b as s,d as u,t as r,e as d,v as p,f as c,g as v,h as f,n as g,F as x,i as y,j as m,k as b,l as h,s as w,m as k,p as S,q as z,P as C,u as A,x as F,y as P,z as V,B as D,C as N,D as I}from"./styles-Df5KliA-.js";import"./pdfjs-DXqArq6h.js";import"./pdf-lib-AfLQbX6n.js";const U={key:0,class:"annotation-detail-panel"},R={class:"panel-header"},$={class:"detail-content"},E={class:"detail-row"},M={class:"label-preview"},j={class:"detail-row"},L={class:"detail-row",style:{"align-items":"center"}},O={style:{display:"flex","align-items":"center",gap:"6px",cursor:"pointer",color:"#334155","font-size":"12px"}},B={class:"detail-row"},_={class:"detail-row"},T={class:"detail-row"},J={class:"detail-row"},X={key:0,class:"detail-row"},Y={key:1,class:"detail-row"},W={class:"detail-row"},G={class:"detail-row readonly"},q={class:"detail-row readonly"},Z={style:{"margin-top":"16px","padding-top":"12px","border-top":"1px solid #e5e7eb"}},H={style:{display:"flex","flex-direction":"column",gap:"8px"}},K={style:{display:"flex","flex-direction":"column",gap:"6px"}},Q={key:0,style:{"margin-top":"12px","border-top":"1px solid #e5e7eb","padding-top":"10px"}},ee={style:{"font-size":"12px","font-weight":"600",color:"#0369a1","margin-bottom":"6px"}},te=["onClick"],le={style:{"font-size":"12px","font-weight":"600",color:"#0369a1"}},ae={style:{display:"flex","align-items":"center",gap:"6px"}},ne={style:{"font-size":"11px",color:"#64748b"}},oe={style:{"font-size":"10px",color:"#94a3b8"}},ie=["onClick"],se={key:0,style:{padding:"6px 8px","max-height":"160px","overflow-y":"auto"}},ue={style:{border:"1px solid #bae6fd","border-radius":"6px",padding:"10px 10px 8px",background:"#f0f9ff"}},re={style:{display:"flex","flex-direction":"column",gap:"6px"}},de={width:"28",height:"28",viewBox:"0 0 28 28",style:{"flex-shrink":"0"}},pe={width:"28",height:"28",viewBox:"0 0 28 28",style:{"flex-shrink":"0"}},ce={width:"28",height:"28",viewBox:"0 0 28 28",style:{"flex-shrink":"0"}},ve={style:{background:"#f8fafc",border:"1px solid #e2e8f0","border-radius":"8px",padding:"10px 12px","margin-bottom":"12px"}},fe={style:{display:"grid","grid-template-columns":"max-content 1fr","align-items":"center",gap:"6px 10px"}},ge={style:{display:"flex",gap:"12px"}},xe={style:{display:"flex","align-items":"center",gap:"4px","font-size":"12px",color:"#334155",cursor:"pointer"}},ye={style:{display:"flex","align-items":"center",gap:"4px","font-size":"12px",color:"#334155",cursor:"pointer"}},me={style:{display:"flex","align-items":"center",gap:"6px","font-size":"12px",color:"#334155",cursor:"pointer"}},be={style:{display:"flex","flex-direction":"column",gap:"4px"}},he={style:{display:"flex","align-items":"center",gap:"4px","font-size":"12px",color:"#334155",cursor:"pointer"}},we={style:{display:"flex","align-items":"center",gap:"4px","font-size":"12px",color:"#334155",cursor:"pointer"}},ke={style:{display:"flex","align-items":"center",gap:"4px","font-size":"12px",color:"#334155",cursor:"pointer"}},Se={style:{display:"grid","grid-template-columns":"repeat(3,28px)","grid-template-rows":"repeat(3,28px)",gap:"4px"}},ze=["onClick","title"],Ce={key:0,style:{width:"6px",height:"6px","border-radius":"50%",background:"#94a3b8",display:"block"}},Ae={key:1,style:{color:"#0ea5e9","font-weight":"bold","font-size":"14px"}},Fe={style:{display:"none","flex-direction":"column","margin-top":"24px","padding-top":"16px","border-top":"1px solid #e5e7eb"}},Pe={style:{"margin-bottom":"12px"}},Ve={style:{"margin-bottom":"12px"}},De=e({__name:"LeftPanel",props:{autoAnnotating:{type:Boolean,default:!1},selectedAnnotation:{type:Object,default:null},selectedAnnotationPage:{type:Number,default:null},selectedAnnotationIndex:{type:Number,default:null},annotationsJson:{type:String,default:"{}"},initialCsvData:{type:String,default:""},groups:{type:Array,default:()=>[]},groupMode:{type:Boolean,default:!1},lineRenumberMode:{type:Boolean,default:!1},startNumber:{default:null}},emits:["file-selected","open-pdf","save-pdf-editable","saveas-pdf-editable","export-pdf-embedded","save-pdf-final","export-csv","export-json","import-annotations","import-csv","import-image","undo-annotation","clear-page-annotations","delete-selected-annotation","apply-settings","update-annotation","delete-annotation","deselect-annotation","load-pdf-url","renumber-page-annotations","auto-annotate-page","toggle-group-mode","toggle-line-renumber-mode","delete-group"],setup(e,{emit:w}){const k=[t.find(e=>"top-left"===e.value),t.find(e=>"top"===e.value),t.find(e=>"top-right"===e.value),t.find(e=>"left"===e.value),{value:"center",label:""},t.find(e=>"right"===e.value),t.find(e=>"bottom-left"===e.value),t.find(e=>"bottom"===e.value),t.find(e=>"bottom-right"===e.value)],S=e,z=w,C=l(0),A=l(""),F=l(""),P=l(10),V=l(!1),D=l(""),N=l(""),I=l(""),De=l(!1);function Ne(){if(!S.selectedAnnotation)return;const e={...S.selectedAnnotation,displayValue:C.value,settings:{...S.selectedAnnotation.settings,prefix:A.value,suffix:F.value,fontSize:P.value},completed:V.value,completedTime:V.value?D.value:"",completedBy:V.value?N.value:"",note:I.value};z("update-annotation",{annotation:e,autoRenumberFollowing:De.value})}function Ie(){confirm("确定要删除这个标注吗?")&&z("delete-annotation")}a(()=>S.selectedAnnotation,e=>{e&&(C.value=e.displayValue||0,A.value=e.settings?.prefix??"",F.value=e.settings?.suffix??"",P.value=e.settings?.fontSize??10,V.value=e.completed||!1,D.value=e.completedTime||"",N.value=e.completedBy||"",I.value=e.note||"",De.value=!1)},{immediate:!0,deep:!0});const Ue=l(null),Re=l(null),$e=l(null),Ee=l(null),Me=n(new Set);const je=l(1),Le=l(1),Oe=l(""),Be=l(""),_e=l("hexagon"),Te=l(10),Je=l("none"),Xe=l("circle-outline"),Ye=l(!0),We=l("top-right"),Ge=l(!0),qe=l(80),Ze=l("测试数据A,测试数据B,测试数据C,测试数据D,测试数据E\n13213213,13213213,13213213,13213213,13213213\n312321312,312321312,312321312,312321312,312321312\n611429411,611429411,611429411,611429411,611429411\n910537510,910537510,910537510,910537510,910537510\n1209645609,1209645609,1209645609,1209645609,1209645609\n1508753708,1508753708,1508753708,1508753708,1508753708\n1807861807,1807861807,1807861807,1807861807,1807861807\n2106969906,2106969906,2106969906,2106969906,2106969906\n2406078005,2406078005,2406078005,2406078005,2406078005\n2705186104,2705186104,2705186104,2705186104,2705186104\n3004294203,3004294203,3004294203,3004294203,3004294203\n3303402302,3303402302,3303402302,3303402302,3303402302\n3602510401,3602510401,3602510401,3602510401,3602510401\n3901618500,3901618500,3901618500,3901618500,3901618500\n4200726599,4200726599,4200726599,4200726599,4200726599\n4499834698,4499834698,4499834698,4499834698,4499834698\n4798942797,4798942797,4798942797,4798942797,4798942797\n5098050896,5098050896,5098050896,5098050896,5098050896\n5397158995,5397158995,5397158995,5397158995,5397158995\n5696267094,5696267094,5696267094,5696267094,5696267094\n5995375193,5995375193,5995375193,5995375193,5995375193\n6294483292,6294483292,6294483292,6294483292,6294483292\n6593591391,6593591391,6593591391,6593591391,6593591391"),He=l(""),Ke=l("{}"),Qe=l(!1),et=l(""),tt=l("");a(()=>S.annotationsJson,e=>{e&&(Ke.value=e)},{immediate:!0}),a(()=>S.initialCsvData,e=>{e&&e.trim()&&(Ze.value=e,console.log("CSV table data updated from props:",e.substring(0,100)+"..."))},{immediate:!0}),a(()=>S.startNumber,e=>{null!=e&&e!==je.value&&(je.value=e)}),a(Ke,e=>{try{const t=document.getElementById("hdworkRecord");t&&(t.value=e||"{}",console.log("Synced JSON data to workRecord-inputEl:",e?.substring(0,100)+"..."))}catch(t){console.warn("Error syncing to workRecord-inputEl:",t)}},{immediate:!0});let lt=null;function at(e){const t=e.target.files&&e.target.files[0];t&&z("file-selected",t)}function nt(){Ue.value&&(Ue.value.value="",Ue.value.click()),z("open-pdf")}async function ot(){if(He.value&&Ke.value.trim()){Qe.value=!0,et.value="";try{let t;try{t=JSON.parse(Ke.value)}catch(e){throw new Error("JSON 格式错误: "+e.message)}const l=await async function(e,t){try{const l=await fetch("http://localhost:8000/api/pdf/process",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({data:e,pdfPath:t,timestamp:(new Date).toISOString()})});if(!l.ok)throw new Error(`API Error: ${l.status} ${l.statusText}`);return await l.json()}catch(l){throw console.error("API call failed:",l),l}}(t,He.value);et.value="提交成功!",tt.value="success",console.log("API Response:",l)}catch(t){et.value="错误: "+(t.message||"网络请求失败"),tt.value="error",console.error("Submit failed:",t)}finally{Qe.value=!1}}}function it(){confirm("确定要清除本页所有标注吗?此操作不可撤销。")&&z("clear-page-annotations")}function st(e){const t=e.target.files&&e.target.files[0];t&&z("import-annotations",t)}function ut(e){const t=e.target.files&&e.target.files[0];t&&z("import-csv",t)}function rt(e){const t=e.target.files&&e.target.files[0];t&&z("import-image",{file:t,size:qe.value})}return a(He,(e,t)=>{lt&&clearTimeout(lt),e&&e.trim()&&(lt=setTimeout(()=>{const t=e.trim();(t.startsWith("http://")||t.startsWith("https://"))&&z("load-pdf-url",t)},500))},{immediate:!0}),a([je,Le,Oe,Be,Te,Je,Xe,Ye,We],()=>{z("apply-settings",{startNumber:je.value,increment:Le.value,prefix:Oe.value,suffix:Be.value,fontSize:Te.value,borderStyle:Je.value,annotationStyle:Xe.value,highDpi:!!Ge.value,singleClickMode:Ye.value,defaultAngle:We.value})}),(t,l)=>(i(),o("div",null,[e.selectedAnnotation?(i(),o("div",U,[u("div",R,[l[35]||(l[35]=u("h3",{style:{margin:"0","font-size":"14px"}},"标注详情",-1)),u("div",{class:"btn close-btn",onClick:l[0]||(l[0]=e=>z("deselect-annotation")),title:"关闭"},"×")]),u("div",$,[u("div",E,[l[36]||(l[36]=u("label",null,"标签内容:",-1)),u("div",M,r(A.value)+r(C.value)+r(F.value),1)]),u("div",j,[l[37]||(l[37]=u("label",null,"编号:",-1)),d(u("input",{"onUpdate:modelValue":l[1]||(l[1]=e=>C.value=e),type:"number",min:"0",class:"detail-input"},null,512),[[p,C.value,void 0,{number:!0}]])]),u("div",L,[l[39]||(l[39]=u("label",{style:{margin:"0"}},"自动修改:",-1)),u("label",O,[d(u("input",{"onUpdate:modelValue":l[2]||(l[2]=e=>De.value=e),type:"checkbox",style:{"accent-color":"#0ea5e9"}},null,512),[[v,De.value]]),l[38]||(l[38]=c(" 修改后续焊口编号 ",-1))])]),u("div",B,[l[40]||(l[40]=u("label",null,"前缀:",-1)),d(u("input",{"onUpdate:modelValue":l[3]||(l[3]=e=>A.value=e),type:"text",class:"detail-input"},null,512),[[p,A.value]])]),u("div",_,[l[41]||(l[41]=u("label",null,"后缀:",-1)),d(u("input",{"onUpdate:modelValue":l[4]||(l[4]=e=>F.value=e),type:"text",class:"detail-input"},null,512),[[p,F.value]])]),u("div",T,[l[42]||(l[42]=u("label",null,"字体大小:",-1)),d(u("input",{"onUpdate:modelValue":l[5]||(l[5]=e=>P.value=e),type:"number",min:"6",max:"72",class:"detail-input"},null,512),[[p,P.value,void 0,{number:!0}]])]),l[50]||(l[50]=u("div",{class:"detail-divider"},null,-1)),u("div",J,[l[44]||(l[44]=u("label",null,"状态:",-1)),d(u("select",{"onUpdate:modelValue":l[6]||(l[6]=e=>V.value=e),class:"detail-input"},[...l[43]||(l[43]=[u("option",{value:!1},"未完成",-1),u("option",{value:!0},"已完成",-1)])],512),[[f,V.value]])]),V.value?(i(),o("div",X,[l[45]||(l[45]=u("label",null,"完成时间:",-1)),d(u("input",{"onUpdate:modelValue":l[7]||(l[7]=e=>D.value=e),type:"datetime-local",class:"detail-input"},null,512),[[p,D.value]])])):s("",!0),V.value?(i(),o("div",Y,[l[46]||(l[46]=u("label",null,"完成人:",-1)),d(u("input",{"onUpdate:modelValue":l[8]||(l[8]=e=>N.value=e),type:"text",placeholder:"输入完成人姓名",class:"detail-input"},null,512),[[p,N.value]])])):s("",!0),u("div",W,[l[47]||(l[47]=u("label",null,"备注:",-1)),d(u("textarea",{"onUpdate:modelValue":l[9]||(l[9]=e=>I.value=e),placeholder:"添加备注...",class:"detail-textarea"},null,512),[[p,I.value]])]),u("div",G,[l[48]||(l[48]=u("label",null,"页码:",-1)),u("span",null,"第 "+r(e.selectedAnnotationPage)+" 页",1)]),u("div",q,[l[49]||(l[49]=u("label",null,"位置:",-1)),u("span",null,"X: "+r(Math.round(e.selectedAnnotation.x))+", Y: "+r(Math.round(e.selectedAnnotation.y)),1)]),u("div",{class:"detail-actions"},[u("div",{class:"btn btn-primary",onClick:Ne},"保存修改"),u("div",{class:"btn btn-danger",onClick:Ie},"删除标注")])])])):s("",!0),u("div",Z,[l[59]||(l[59]=u("h3",{style:{margin:"0 0 12px 0"}},"设置",-1)),u("div",H,[u("input",{ref_key:"fileInput",ref:Ue,type:"file",accept:"application/pdf",onChange:at,style:{display:"none"}},null,544),u("input",{ref_key:"jsonInput",ref:Re,type:"file",accept:"application/json,.json",onChange:st,style:{display:"none"}},null,544),u("input",{ref_key:"csvInput",ref:$e,type:"file",accept:"text/csv,.csv",onChange:ut,style:{display:"none"}},null,544),u("input",{ref_key:"imageInput",ref:Ee,type:"file",accept:"image/*",onChange:rt,style:{display:"none"}},null,544),u("div",K,[u("div",{class:"btn btn-primary",onClick:nt,style:{width:"100%",display:"none"}},"打开PDF"),u("div",{class:"btn btn-primary",onClick:l[10]||(l[10]=e=>z("export-pdf-embedded")),style:{width:"100%",display:"none"}},"导出带焊口数据的PDF"),u("div",{class:"btn btn-primary",onClick:l[11]||(l[11]=e=>z("save-pdf-final")),style:{width:"100%",display:"none"}},"导出PDF(测试用)"),u("div",{class:"btn btn-primary",onClick:l[12]||(l[12]=e=>z("export-csv")),style:{width:"100%",display:"none"}},"导出Excel"),u("div",{class:"btn btn-primary",onClick:l[13]||(l[13]=e=>z("export-json")),style:{width:"100%",display:"none"}},"导出JSON"),u("div",{class:"btn btn-primary",onClick:l[14]||(l[14]=e=>z("undo-annotation")),style:{width:"100%"}},"撤销上一标注"),u("div",{class:"btn btn-primary",onClick:l[15]||(l[15]=e=>z("toggle-group-mode")),style:g({width:"100%",background:S.groupMode?"#0369a1":"",outline:S.groupMode?"2px solid #0c4a6e":"none"})},r(S.groupMode?"分组模式:开(拖动框选)":"焊口分组标注"),5),u("div",{class:"btn btn-primary",onClick:l[16]||(l[16]=e=>z("toggle-line-renumber-mode")),title:"拖动鼠标画一条线,穿过的焊口会按线上的先后顺序重新编号",style:g({width:"100%",background:S.lineRenumberMode?"#b45309":"",outline:S.lineRenumberMode?"2px solid #92400e":"none"})},r(S.lineRenumberMode?"画线重新编号:开(拖动画线)":"画线重新编号"),5)]),S.groups&&S.groups.length>0?(i(),o("div",Q,[u("div",ee,"焊口分组("+r(S.groups.length)+")",1),(i(!0),o(x,null,y(S.groups,e=>(i(),o("div",{key:e.id,style:{"margin-bottom":"6px",border:"1px solid #bae6fd","border-radius":"6px",overflow:"hidden",background:"#f0f9ff"}},[u("div",{style:{display:"flex","align-items":"center","justify-content":"space-between",padding:"6px 8px",cursor:"pointer",background:"#e0f2fe"},onClick:t=>{return l=e.id,void(Me.has(l)?Me.delete(l):Me.add(l));var l}},[u("span",le,r(e.name),1),u("div",ae,[u("span",ne,"第"+r(e.page)+"页 · "+r(e.weldList?.length||0)+"个",1),u("span",oe,r(Me.has(e.id)?"▲":"▼"),1),u("span",{style:{"font-size":"11px",color:"#ef4444",cursor:"pointer",padding:"0 2px"},onClick:m(t=>z("delete-group",e.id),["stop"])},"×",8,ie)])],8,te),Me.has(e.id)?(i(),o("div",se,[(i(!0),o(x,null,y(e.weldList,(e,t)=>(i(),o("div",{key:t,style:{"font-size":"11px",color:"#334155",padding:"2px 0","border-bottom":"1px solid #e0f2fe"}},r(e.label),1))),128))])):s("",!0)]))),128))])):s("",!0),u("div",ue,[l[57]||(l[57]=u("div",{style:{"font-size":"13px","font-weight":"600",color:"#0369a1","margin-bottom":"8px"}},"焊缝自动标注",-1)),u("div",{class:"btn",onClick:l[17]||(l[17]=e=>!S.autoAnnotating&&z("auto-annotate-page",_e.value)),style:g({width:"100%",background:S.autoAnnotating?"#7dd3fc":"#0ea5e9",color:"#fff",marginBottom:"10px",cursor:S.autoAnnotating?"not-allowed":"pointer",opacity:S.autoAnnotating?.8:1,border:"none",borderRadius:"4px",padding:"8px"})},r(S.autoAnnotating?"検测中…":"自动标注本页"),5),l[58]||(l[58]=u("div",{style:{"font-size":"12px",color:"#6b7280","margin-bottom":"6px"}},"焊口样式:",-1)),u("div",re,[u("label",{style:g([{display:"flex","align-items":"center",gap:"8px",cursor:"pointer",padding:"4px 6px","border-radius":"4px"},"hexagon"===_e.value?"background:#e0f2fe;border:1px solid #0ea5e9":"border:1px solid transparent"])},[d(u("input",{type:"radio",value:"hexagon","onUpdate:modelValue":l[18]||(l[18]=e=>_e.value=e),style:{margin:"0"}},null,512),[[b,_e.value]]),(i(),o("svg",de,[...l[51]||(l[51]=[u("polygon",{points:"14,2 25,8 25,20 14,26 3,20 3,8",fill:"#334155",stroke:"#334155","stroke-width":"1"},null,-1),u("text",{x:"14",y:"18","text-anchor":"middle",fill:"#fff","font-size":"10","font-weight":"bold"},"1",-1)])])),l[52]||(l[52]=u("span",{style:{"font-size":"13px"}},"6边型",-1))],4),u("label",{style:g([{display:"flex","align-items":"center",gap:"8px",cursor:"pointer",padding:"4px 6px","border-radius":"4px"},"hexagon-outline"===_e.value?"background:#e0f2fe;border:1px solid #0ea5e9":"border:1px solid transparent"])},[d(u("input",{type:"radio",value:"hexagon-outline","onUpdate:modelValue":l[19]||(l[19]=e=>_e.value=e),style:{margin:"0"}},null,512),[[b,_e.value]]),(i(),o("svg",pe,[...l[53]||(l[53]=[u("polygon",{points:"14,2 25,8 25,20 14,26 3,20 3,8",fill:"#fff",stroke:"#334155","stroke-width":"2"},null,-1),u("text",{x:"14",y:"18","text-anchor":"middle",fill:"#334155","font-size":"10","font-weight":"bold"},"1",-1)])])),l[54]||(l[54]=u("span",{style:{"font-size":"13px"}},"空心6边型",-1))],4),u("label",{style:g([{display:"flex","align-items":"center",gap:"8px",cursor:"pointer",padding:"4px 6px","border-radius":"4px"},"circle"===_e.value?"background:#e0f2fe;border:1px solid #0ea5e9":"border:1px solid transparent"])},[d(u("input",{type:"radio",value:"circle","onUpdate:modelValue":l[20]||(l[20]=e=>_e.value=e),style:{margin:"0"}},null,512),[[b,_e.value]]),(i(),o("svg",ce,[...l[55]||(l[55]=[u("circle",{cx:"14",cy:"14",r:"12",fill:"#334155",stroke:"#334155","stroke-width":"1"},null,-1),u("text",{x:"14",y:"18","text-anchor":"middle",fill:"#fff","font-size":"10","font-weight":"bold"},"1",-1)])])),l[56]||(l[56]=u("span",{style:{"font-size":"13px"}},"圆形",-1))],4)])]),u("div",{class:"btn btn-primary",onClick:l[21]||(l[21]=e=>z("renumber-page-annotations")),style:{width:"100%"}},"按设置重新标注"),u("div",{class:"btn btn-primary",onClick:it,style:{width:"100%"}},"清除本页标注")])]),u("div",ve,[l[75]||(l[75]=u("div",{style:{"font-size":"11px","font-weight":"600",color:"#94a3b8","letter-spacing":"0.06em","text-transform":"uppercase","margin-bottom":"10px"}},"标注设置",-1)),u("div",fe,[l[66]||(l[66]=u("span",{style:{"font-size":"12px",color:"#475569","white-space":"nowrap"}},"起始编号",-1)),d(u("input",{"onUpdate:modelValue":l[22]||(l[22]=e=>je.value=e),type:"number",min:"0",style:{width:"100%","box-sizing":"border-box",padding:"4px 6px",border:"1px solid #cbd5e1","border-radius":"4px","font-size":"12px"}},null,512),[[p,je.value,void 0,{number:!0}]]),l[67]||(l[67]=u("span",{style:{"font-size":"12px",color:"#475569","white-space":"nowrap"}},"增量",-1)),d(u("input",{"onUpdate:modelValue":l[23]||(l[23]=e=>Le.value=e),type:"number",min:"1",style:{width:"100%","box-sizing":"border-box",padding:"4px 6px",border:"1px solid #cbd5e1","border-radius":"4px","font-size":"12px"}},null,512),[[p,Le.value,void 0,{number:!0}]]),l[68]||(l[68]=u("span",{style:{"font-size":"12px",color:"#475569","white-space":"nowrap"}},"前缀",-1)),d(u("input",{"onUpdate:modelValue":l[24]||(l[24]=e=>Oe.value=e),type:"text",style:{width:"100%","box-sizing":"border-box",padding:"4px 6px",border:"1px solid #cbd5e1","border-radius":"4px","font-size":"12px"}},null,512),[[p,Oe.value]]),l[69]||(l[69]=u("span",{style:{"font-size":"12px",color:"#475569","white-space":"nowrap"}},"后缀",-1)),d(u("input",{"onUpdate:modelValue":l[25]||(l[25]=e=>Be.value=e),type:"text",style:{width:"100%","box-sizing":"border-box",padding:"4px 6px",border:"1px solid #cbd5e1","border-radius":"4px","font-size":"12px"}},null,512),[[p,Be.value]]),l[70]||(l[70]=u("span",{style:{"font-size":"12px",color:"#475569","white-space":"nowrap"}},"字体大小",-1)),d(u("input",{"onUpdate:modelValue":l[26]||(l[26]=e=>Te.value=e),type:"number",min:"6",max:"72",step:"1",style:{width:"100%","box-sizing":"border-box",padding:"4px 6px",border:"1px solid #cbd5e1","border-radius":"4px","font-size":"12px"}},null,512),[[p,Te.value,void 0,{number:!0}]]),l[71]||(l[71]=u("span",{style:{"font-size":"12px",color:"#475569","white-space":"nowrap"}},"边框样式",-1)),u("div",ge,[u("label",xe,[d(u("input",{type:"radio",value:"none","onUpdate:modelValue":l[27]||(l[27]=e=>Je.value=e),style:{"accent-color":"#0ea5e9"}},null,512),[[b,Je.value]]),l[60]||(l[60]=c(" 无 ",-1))]),u("label",ye,[d(u("input",{type:"radio",value:"rect","onUpdate:modelValue":l[28]||(l[28]=e=>Je.value=e),style:{"accent-color":"#0ea5e9"}},null,512),[[b,Je.value]]),l[61]||(l[61]=c(" 矩形 ",-1))])]),l[72]||(l[72]=u("span",{style:{"font-size":"12px",color:"#475569","white-space":"nowrap","align-self":"start","padding-top":"2px"}},"点击模式",-1)),u("label",me,[d(u("input",{type:"checkbox","onUpdate:modelValue":l[29]||(l[29]=e=>Ye.value=e),style:{"accent-color":"#0ea5e9",width:"14px",height:"14px"}},null,512),[[v,Ye.value]]),l[62]||(l[62]=c(" 单击模式 ",-1))]),l[73]||(l[73]=u("span",{style:{"font-size":"12px",color:"#475569","white-space":"nowrap","align-self":"start","padding-top":"2px"}},"标注样式",-1)),u("div",be,[u("label",he,[d(u("input",{type:"radio",value:"circle-outline","onUpdate:modelValue":l[30]||(l[30]=e=>Xe.value=e),style:{"accent-color":"#0ea5e9"}},null,512),[[b,Xe.value]]),l[63]||(l[63]=c(" 圆圈 ",-1))]),u("label",we,[d(u("input",{type:"radio",value:"arrow","onUpdate:modelValue":l[31]||(l[31]=e=>Xe.value=e),style:{"accent-color":"#0ea5e9"}},null,512),[[b,Xe.value]]),l[64]||(l[64]=c(" 箭头 ",-1))]),u("label",ke,[d(u("input",{type:"radio",value:"dot","onUpdate:modelValue":l[32]||(l[32]=e=>Xe.value=e),style:{"accent-color":"#0ea5e9"}},null,512),[[b,Xe.value]]),l[65]||(l[65]=c(" 圆点 ",-1))])]),l[74]||(l[74]=u("span",{style:{"font-size":"12px",color:"#475569","white-space":"nowrap","align-self":"start","padding-top":"2px"}},"默认标注角度",-1)),u("div",Se,[(i(),o(x,null,y(k,e=>u("div",{key:e.value,onClick:t=>"center"!==e.value&&(We.value=e.value),title:e.label,style:g({width:"28px",height:"28px",boxSizing:"border-box",display:"flex",alignItems:"center",justifyContent:"center",borderRadius:"4px",border:"center"===e.value?"none":We.value===e.value?"1px solid #0ea5e9":"1px solid #cbd5e1",background:"center"===e.value?"transparent":We.value===e.value?"#e0f2fe":"#fff",cursor:"center"===e.value?"default":"pointer"})},["center"===e.value?(i(),o("span",Ce)):We.value===e.value?(i(),o("span",Ae,"✓")):s("",!0)],12,ze)),64))])])]),u("div",Fe,[l[78]||(l[78]=u("h4",{style:{margin:"0 0 12px 0"}},"网络接口",-1)),u("div",Pe,[l[76]||(l[76]=u("label",{style:{display:"block","font-size":"12px","margin-bottom":"4px",color:"#6b7280"}},"PDF 目录路径",-1)),d(u("input",{"onUpdate:modelValue":l[33]||(l[33]=e=>He.value=e),type:"text",placeholder:"/path/to/pdf",style:{width:"100%",padding:"6px",border:"1px solid #d1d5db","border-radius":"4px","font-size":"12px"}},null,512),[[p,He.value]])]),u("div",Ve,[l[77]||(l[77]=u("label",{style:{display:"block","font-size":"12px","margin-bottom":"4px",color:"#6b7280"}},"数据 (JSON)",-1)),d(u("textarea",{"onUpdate:modelValue":l[34]||(l[34]=e=>Ke.value=e),placeholder:'{"key":"value"}',style:{width:"100%",height:"100px",padding:"6px",border:"1px solid #d1d5db","border-radius":"4px","font-size":"12px","font-family":"monospace",resize:"vertical"}},null,512),[[p,Ke.value]])]),u("div",{class:h(["btn",{disabled:!He.value||!Ke.value}]),onClick:ot,style:{width:"100%",padding:"8px",background:"#3b82f6",color:"white",border:"none","border-radius":"4px",cursor:"pointer","font-size":"14px"}},r(Qe.value?"提交中...":"提交数据"),3),et.value?(i(),o("div",{key:0,style:g({marginTop:"8px",padding:"8px",borderRadius:"4px",fontSize:"12px",color:"success"===tt.value?"#10b981":"#ef4444",background:"success"===tt.value?"#d1fae5":"#fee2e2"})},r(et.value),5)):s("",!0)])]))}},[["__scopeId","data-v-99d9d8cd"]]),Ne={class:"weld-table-panel"},Ie={style:{display:"flex","align-items":"center",gap:"8px"}},Ue={style:{"font-weight":"400",opacity:"0.8"}},Re={style:{"font-size":"10px"}},$e={key:0,class:"weld-table-body"},Ee={key:0,class:"weld-table-empty"},Me={key:1,style:{"overflow-x":"auto"}},je={class:"weld-table"},Le=["onClick"],Oe={style:{color:"#94a3b8"}},Be=["value","onInput"],_e=["value","onInput"],Te=["value","onInput"],Je=["value","onInput"],Xe={style:{"text-align":"center"}},Ye=["checked","onChange"],We=["value","onInput"],Ge={style:{"white-space":"nowrap",color:"#64748b"}},qe=["onClick"],Ze=e({__name:"WeldTable",props:{annotations:{type:Array,default:()=>[]},page:{type:Number,default:1},selectedIndex:{type:Number,default:null},closable:{type:Boolean,default:!1}},emits:["update","delete","select","close"],setup(e,{emit:t}){const a=t,n=l(!0);function d(e){const t=Number(e);return Number.isFinite(t)?t:0}function p(e,t,l,n){const o={...t};"prefix"===l||"suffix"===l||"fontSize"===l?o.settings={...t.settings,[l]:n}:"completed"===l?(o.completed=n,o.completedTime=n?t.completedTime||(new Date).toISOString().slice(0,16):"",n||(o.completedBy="")):o[l]=n,a("update",e,o)}return(t,l)=>(i(),o("div",Ne,[u("div",{class:"weld-table-header",onClick:l[1]||(l[1]=e=>n.value=!n.value)},[u("span",null,"本页焊口一览("+r(e.annotations.length)+")",1),u("span",Ie,[u("span",Ue,"第 "+r(e.page)+" 页",1),u("span",Re,r(n.value?"▲":"▼"),1),e.closable?(i(),o("span",{key:0,class:"header-close",title:"关闭",onClick:l[0]||(l[0]=m(e=>a("close"),["stop"]))},"×")):s("",!0)])]),n.value?(i(),o("div",$e,[0===e.annotations.length?(i(),o("div",Ee,"本页暂无焊口标注")):(i(),o("div",Me,[u("table",je,[l[8]||(l[8]=u("thead",null,[u("tr",null,[u("th",null,"#"),u("th",null,"编号"),u("th",null,"前缀"),u("th",null,"后缀"),u("th",null,"字号"),u("th",null,"完成"),u("th",null,"备注"),u("th",null,"焊口位置"),u("th")])],-1)),u("tbody",null,[(i(!0),o(x,null,y(e.annotations,(t,n)=>(i(),o("tr",{key:n,class:h({"row-selected":n===e.selectedIndex}),onClick:e=>a("select",n)},[u("td",Oe,r(n+1),1),u("td",null,[u("input",{type:"number",class:"cell-input",style:{width:"52px"},value:t.displayValue,min:"0",onClick:l[2]||(l[2]=m(()=>{},["stop"])),onInput:e=>p(n,t,"displayValue",d(e.target.value))},null,40,Be)]),u("td",null,[u("input",{type:"text",class:"cell-input",style:{width:"56px"},value:t.settings?.prefix??"",onClick:l[3]||(l[3]=m(()=>{},["stop"])),onInput:e=>p(n,t,"prefix",e.target.value)},null,40,_e)]),u("td",null,[u("input",{type:"text",class:"cell-input",style:{width:"56px"},value:t.settings?.suffix??"",onClick:l[4]||(l[4]=m(()=>{},["stop"])),onInput:e=>p(n,t,"suffix",e.target.value)},null,40,Te)]),u("td",null,[u("input",{type:"number",class:"cell-input",style:{width:"44px"},value:t.settings?.fontSize??10,min:"6",max:"72",onClick:l[5]||(l[5]=m(()=>{},["stop"])),onInput:e=>p(n,t,"fontSize",d(e.target.value))},null,40,Je)]),u("td",Xe,[u("input",{type:"checkbox",checked:!!t.completed,style:{"accent-color":"#0ea5e9",width:"14px",height:"14px",cursor:"pointer"},onClick:l[6]||(l[6]=m(()=>{},["stop"])),onChange:e=>p(n,t,"completed",e.target.checked)},null,40,Ye)]),u("td",null,[u("input",{type:"text",class:"cell-input",style:{width:"100px"},value:t.note??"",placeholder:"备注...",onClick:l[7]||(l[7]=m(()=>{},["stop"])),onInput:e=>p(n,t,"note",e.target.value)},null,40,We)]),u("td",Ge,r(Math.round(t.x2??t.x))+", "+r(Math.round(t.y2??t.y)),1),u("td",null,[u("span",{class:"row-delete",title:"删除该焊口",onClick:m(e=>function(e){confirm("确定要删除这个焊口标注吗?")&&a("delete",e)}(n),["stop"])},"×",8,qe)])],10,Le))),128))])])]))])):s("",!0)]))}},[["__scopeId","data-v-3f4d92b8"]]);function He(e){const t=[];let l="",a=!1;for(let n=0;n<e.length;n++){const o=e[n],i=e[n+1];'"'===o?a&&'"'===i?(l+='"',n++):a=!a:","!==o||a?l+=o:(t.push(l.trim()),l="")}return t.push(l.trim()),t}const Ke={class:"container"},Qe={class:"left"},et={class:"right"},tt={class:"controls"},lt=["disabled"],at={style:{"min-width":"38px","text-align":"center","font-size":"13px"}},nt=["max"],ot={style:{"margin-left":"4px","font-size":"13px","white-space":"nowrap"}},it={key:0,style:{display:"flex","align-items":"center",gap:"8px","margin-left":"4px","font-size":"13px",color:"#6b7280","white-space":"nowrap",overflow:"hidden"}},st={style:{overflow:"hidden","text-overflow":"ellipsis","white-space":"nowrap","max-width":"200px"}},ut={style:{"white-space":"nowrap"}},rt={class:"viewer"},dt={key:0,class:"bookmark-panel"},pt={class:"bookmark-panel-header"},ct={class:"bookmark-panel-body"},vt={key:0,class:"bookmark-empty"},ft={class:"bookmark-group-header"},gt={style:{color:"#94a3b8","font-weight":"400"}},xt=["onClick"],yt=["title","onClick"],mt={class:"bookmark-thumb-page"},bt=["src","alt"],ht={key:1,class:"weld-table-drawer"},wt="http://localhost:8000/api/weld";I({__name:"App",setup(e){const t=l(null),n=w(null),v=l(0),f=l(1),m=l(1),b=l(!1),I=l(null),U=l(""),R=l(""),$=l({}),E=l("{}"),M=l(""),j=l(null),L=l(null),O=l(null),B=l([]),_=l(!1),T=l(!1),J=l([]),X=l(!1),Y=l(!1);function W(){n.value?(T.value=!T.value,T.value&&(b.value=!1,Ae.value=!1,Fe.value=!1,le("请拖动鼠标框选书签区域"))):le("请先打开PDF文件","error")}async function G({page:e,rect:t}){if(T.value=!1,!n.value||Y.value)return;const l=t.x2-t.x1,a=t.y2-t.y1;if(!(l<=0||a<=0)){Y.value=!0,le("正在生成书签…");try{const o=480/l,i=[];for(let e=1;e<=v.value;e++){const s=await n.value.getPage(e),u=s.getViewport({scale:o,offsetX:-t.x1*o,offsetY:-t.y1*o}),r=document.createElement("canvas");r.width=Math.max(1,Math.round(l*o)),r.height=Math.max(1,Math.round(a*o)),await s.render({canvasContext:r.getContext("2d"),viewport:u}).promise,i.push({page:e,dataUrl:r.toDataURL("image/png")})}J.value.push({id:`bm_${Date.now()}`,sourcePage:e,rect:t,thumbs:i}),X.value=!0,le(`书签已生成(${i.length} 页)`)}catch(o){console.error("生成书签失败:",o),le("生成书签失败: "+o.message,"error")}finally{Y.value=!1}}}function q(e){e?(j.value={...e.annotation},L.value=e.page,O.value=e.index):(j.value=null,L.value=null,O.value=null),de()}function Z(e){if(!I.value||null===L.value||null===O.value)return;const t=e?.annotation||e,l=!!e?.autoRenumberFollowing,a=L.value,n=O.value,o=Number(j.value?.displayValue),i=Number(t?.displayValue);if(I.value.updateAnnotation(a,n,t),l&&Number.isFinite(o)&&Number.isFinite(i)&&i!==o){const e=Number.isFinite(Number(Ve.value))?Number(Ve.value):1;(I.value.getAnnotations()[a]||[]).map((e,t)=>({ann:e,idx:t,value:Number(e.displayValue)})).filter(({idx:e,value:t})=>e!==n&&Number.isFinite(t)&&t>o).sort((e,t)=>e.value-t.value||e.idx-t.idx).forEach(({ann:t,idx:l},n)=>{const o=i+e*(n+1),s=t.settings?.prefix??Ne.value,u=t.settings?.suffix??Ie.value;I.value.updateAnnotation(a,l,{...t,displayValue:o,text:`${s}${o}${u}`})}),le("标注已更新,并按增量自动修改后续焊口编号")}else le("标注已更新");j.value={...t},de()}function H(){I.value&&null!==L.value&&null!==O.value&&(I.value.deleteAnnotation(L.value,O.value),j.value=null,L.value=null,O.value=null,le("标注已删除"),de())}function K(e){I.value&&I.value.selectAnnotation(e)}function Q(){j.value=null,L.value=null,O.value=null,I.value&&I.value.clearSelection()}const ee=l({show:!1,message:"",type:"success"});let te=null;function le(e,t="success"){ee.value={show:!0,message:e,type:t},clearTimeout(te),te=setTimeout(()=>{ee.value.show=!1},2500)}let ae=null;const ne=l(null),oe=l(null),ie=l(100),se=l(1),ue=k(()=>{const e=null!==oe.value?oe.value:se.value;return Math.round(100*e)}),re=k(()=>{if(!I.value)return 0;const e=I.value.getAnnotations();let t=0;for(const l in e)t+=e[l].length;return t});function de(){if(!I.value||!U.value)return E.value="{}",void(B.value=[]);try{const e=I.value.getAnnotations();B.value=[...e[f.value]||[]],E.value=function(e,t,l,a=[]){const n={version:"1.0",exportDate:(new Date).toISOString(),sourceFile:l,globalSettings:t,annotations:{}};for(const o in e){const l=e[o];Array.isArray(l)&&l.length>0&&(n.annotations[o]=l.map(e=>{const l=e.settings?.prefix??t.prefix??"",a=e.settings?.suffix??t.suffix??"",n=l+e.displayValue+a;return{x:e.x,y:e.y,x2:e.x2,y2:e.y2,displayValue:e.displayValue,label:n,style:e.style,annotationStyle:e.annotationStyle}}))}return a&&a.length>0&&(n.groups=a.map(e=>({id:e.id,name:e.name,page:e.page,weldList:e.weldList}))),JSON.stringify(n,null,2)}(e,{startNumber:Pe.value,increment:Ve.value,prefix:Ne.value,suffix:Ie.value,fontSize:Ue.value,borderStyle:we.value,annotationStyle:ke.value},U.value,Ce.value)}catch(e){console.error("Failed to generate annotations JSON:",e)}}function pe(){Ae.value=!Ae.value,Ae.value?(b.value=!1,Fe.value=!1,le("分组模式已开启,拖动鼠标框选焊口")):le("分组模式已关闭")}function ce(){Fe.value=!Fe.value,Fe.value?(b.value=!1,Ae.value=!1,le("画线重新编号已开启,拖动鼠标画一条线经过焊口")):le("画线重新编号已关闭")}function ve({count:e,nextStartNumber:t}){e?(void 0!==t&&(Pe.value=t),de(),le(`已按顺序重新编号 ${e} 个焊口`)):le("该线附近没有找到焊口","error")}function fe(e){if(!e.weldList||0===e.weldList.length)return void le("框选区域内没有焊口","error");const t=(U.value||"XXXXXX").replace(/\.[^.]+$/,"").slice(-6).toUpperCase(),l=Ce.value.filter(t=>t.page===e.page),a=String(l.length+1).padStart(3,"0"),n=`${t}-${e.page}-${a}`;Ce.value.push({id:`grp_${Date.now()}`,name:n,page:e.page,weldList:e.weldList,rect:e.rect}),de(),le(`已创建分组: ${n}(${e.weldList.length}个焊口)`)}function ge(e){Ce.value=Ce.value.filter(t=>t.id!==e),de(),le("分组已删除")}function xe(e){t.value=e,U.value=e.name,f.value=1,m.value=1,oe.value=1,ie.value=100,ne.value=null;const l=new FileReader;l.onload=async e=>{ae=e.target.result;const t=await D(ae);t&&(ne.value=t,n.value&&I.value&&N(()=>me()))},l.readAsArrayBuffer(e),async function(e){Le.value="vector";try{const t=new FormData;t.append("pdf",e);const l=await fetch(`${wt}/pdf-type`,{method:"POST",body:t});if(l.ok){const e=await l.json();Le.value=e.type||"vector"}}catch(t){console.warn("PDF类型检测失败,使用默认矢量模式:",t)}}(e)}function ye(e){n.value=e.pdf,v.value=e.numPages,f.value=1,m.value=1,T.value=!1,J.value=[],ne.value&&N(()=>me());const t=document.getElementById("annotionData");if(t&&"string"==typeof t.value&&t.value.trim())try{const e=JSON.parse(t.value.trim());if(e&&e.annotations&&I.value){I.value.setAnnotations(e.annotations);const t=e.globalSettings||e.settings;t&&(Pe.value=t.startNumber||1,Ve.value=t.increment||1,Ne.value=t.prefix||"",Ie.value=t.suffix||"",Ue.value=t.fontSize||10,we.value=t.borderStyle||"none",ke.value=t.annotationStyle||"circle-outline"),Array.isArray(e.groups)&&(Ce.value=e.groups),de()}}catch(l){console.warn("annotionData 解析失败:",l)}}function me(){const e=ne.value;e&&I.value&&(ne.value=null,I.value.setAnnotations(e.annotations),e.settings&&(Pe.value=e.settings.startNumber||1,Ve.value=e.settings.increment||1,Ne.value=e.settings.prefix||"",Ie.value=e.settings.suffix||"",Ue.value=e.settings.fontSize||10,we.value=e.settings.borderStyle||"none",ke.value=e.settings.annotationStyle||"circle-outline"),e.groups&&e.groups.length>0&&(Ce.value=e.groups),de(),le("已自动恢复PDF中的标注数据"))}function be(e){se.value=e}function he(e){oe.value=e,ie.value=Math.round(100*e)}const we=l("none"),ke=l("circle-outline"),Se=l(!0),ze=l("top-right"),Ce=l([]),Ae=l(!1),Fe=l(!1),Pe=l(1),Ve=l(1),Ne=l(""),Ie=l(""),Ue=l(10);function Re(e){we.value=e.borderStyle,ke.value=e.annotationStyle,Se.value=e.singleClickMode??!0,ze.value=e.defaultAngle??"top-right",Pe.value=e.startNumber,Ve.value=e.increment,Ne.value=e.prefix,Ie.value=e.suffix,Ue.value=e.fontSize,le("设置已应用")}function $e(){oe.value=+ie.value/100}function Ee(){I.value&&(I.value.clearCurrentPageAnnotations(),de())}function Me(){I.value&&(I.value.renumberCurrentPageAnnotations(Pe.value,Ve.value,Ne.value,Ie.value,Ue.value),de(),le("本页焊口编号已重新标注"))}const je=l(!1),Le=l("vector");async function Oe(e){if(t.value){je.value=!0;try{let l;l="hexagon"===e?"vector"===Le.value?"detect-vector-hexagon-2":"detect-solid-hexagon":"hexagon-outline"===e?"detect-vector":"circle"===e?"detect-vector-circle":"detect-vector-hexagon-2";const a=new FormData;a.append("pdf",t.value),a.append("page",String(f.value)),"detect"===l&&(a.append("sensitivity","70"),a.append("min_size","20"),a.append("dpi","100"));const n=await fetch(`${wt}/${l}`,{method:"POST",body:a});if(!n.ok){const e=await n.json().catch(()=>({detail:n.statusText}));throw new Error(e.detail||n.statusText)}const{welds:o}=await n.json();if(!o||0===o.length)return void le("未检测到焊口","error");let i=Pe.value-Ve.value,s=null,u=[];if(I.value){const e=I.value.getAnnotations();u=e[f.value]||[];for(const t of u)t.displayValue>i&&(i=t.displayValue),"auto"!==t.source&&(null===s||(t.displayValue||0)>(s.displayValue||0))&&(s=t)}const r=12,d=o.filter(e=>!u.some(t=>{const l=t.x2??t.x,a=t.y2??t.y;if(void 0===l||void 0===a)return!1;return Math.hypot((e.x??0)-l,(e.y??0)-a)<=r}));if(0===d.length)return void le("自动检测焊口与已有标注重合,未新增标注");let p=[...d];if(s){const e=s.x2??s.x??0,t=s.y2??s.y??0,l=p.every(e=>(e.y??0)>t),a=p.every(t=>(t.x??0)>e);l?p=p.sort((e,t)=>(e.y??0)-(t.y??0)||(e.x??0)-(t.x??0)):a&&(p=p.sort((e,t)=>(e.x??0)-(t.x??0)||(e.y??0)-(t.y??0)))}const c=Math.max(i,s?.displayValue||i),v=p.map((e,t)=>{const l=e.r||8,a=Math.max(2*l,20),{dx:n,dy:o}=V(ze.value,a),i=c+(t+1)*Ve.value;return{x:e.x+n,y:e.y+o,x2:e.x,y2:e.y,displayValue:i,text:Ne.value+i+Ie.value,style:we.value,annotationStyle:ke.value,source:"auto",settings:{prefix:Ne.value,suffix:Ie.value,startNumber:Pe.value,increment:Ve.value,fontSize:Ue.value}}});if(I.value){I.value.addAnnotationsToPage(f.value,v),de();const e=o.length-d.length;le(e>0?`已自动标注 ${d.length} 个焊口(跳过 ${e} 个重合)`:`已自动标注 ${d.length} 个焊口`)}}catch(l){console.error("自动标注失败:",l),le("自动标注失败: "+l.message,"error")}finally{je.value=!1}}else le("请先打开PDF文件","error")}function Be(){I.value&&(I.value.undoLastAnnotation(),de())}async function _e(){if(ae&&I.value)try{const e=I.value.getAnnotations(),t=I.value.getPageRotations(),l=await A(ae,e,$.value,{startNumber:Pe.value,increment:Ve.value,prefix:Ne.value,suffix:Ie.value,fontSize:Ue.value,borderStyle:we.value,annotationStyle:ke.value},t);F(l,`annotated_${U.value||Date.now()}.pdf`),le("PDF已生成并下载")}catch(e){console.error("Failed to generate PDF:",e),le("生成PDF失败: "+e.message,"error")}else le("请先打开PDF文件","error")}async function Te(){if(ae&&I.value)try{const e=I.value.getAnnotations(),t=await P(ae,e,{startNumber:Pe.value,increment:Ve.value,prefix:Ne.value,suffix:Ie.value,fontSize:Ue.value,borderStyle:we.value,annotationStyle:ke.value},Ce.value);F(t,`weld_data_${U.value||Date.now()}.pdf`),le("已导出带焊口数据的PDF(无可视标注)")}catch(e){console.error("Failed to export embedded PDF:",e),le("导出失败: "+e.message,"error")}else le("请先打开PDF文件","error")}async function Je(){if(ae&&I.value)try{const e=I.value.getAnnotations(),t=I.value.getPageRotations(),l=await A(ae,e,$.value,{startNumber:Pe.value,increment:Ve.value,prefix:Ne.value,suffix:Ie.value,fontSize:Ue.value,borderStyle:we.value,annotationStyle:ke.value},t);F(l,`final_${U.value||Date.now()}.pdf`),le("PDF已生成并下载")}catch(e){console.error("Failed to generate PDF:",e),le("生成PDF失败: "+e.message,"error")}else le("请先打开PDF文件","error")}function Xe(){if(I.value&&U.value)try{!function(e,t,l,a=[]){const{startNumber:n,increment:o,prefix:i,suffix:s}=t,u=[];u.push(["页码","标签","显示值","标签X坐标","标签Y坐标","指向X坐标","指向Y坐标","边框样式","标注样式","字体大小","前缀","后缀","起始值","增量"]);for(const v in e){const t=e[v];Array.isArray(t)&&t.forEach(e=>{const t=e.settings?.prefix??i,l=e.settings?.suffix??s,a=e.settings?.startNumber??n,r=e.settings?.increment??o,d=e.settings?.fontSize??10,p=t+e.displayValue+l;u.push([v,p,e.displayValue,Math.round(1e3*e.x)/1e3,Math.round(1e3*e.y)/1e3,void 0!==e.x2?Math.round(1e3*e.x2)/1e3:"",void 0!==e.y2?Math.round(1e3*e.y2)/1e3:"",e.style||"none",e.annotationStyle||"arrow",d,t,l,a,r])})}a&&a.length>0&&(u.push([]),u.push(["=== 焊口分组 ==="]),u.push(["分组名称","页码","焊口数量","焊口标签列表"]),a.forEach(e=>{const t=(e.weldList||[]).map(e=>e.label).join(" | ");u.push([e.name,e.page,e.weldList?.length||0,t])}));const r=u.map(e=>e.map(e=>{const t=String(e);return t.includes(",")||t.includes('"')||t.includes("\n")?`"${t.replace(/"/g,'""')}"`:t}).join(",")).join("\n"),d=new Blob(["\ufeff"+r],{type:"text/csv;charset=utf-8;"}),p=document.createElement("a"),c=URL.createObjectURL(d);p.href=c,p.download=`${l.replace(/\.[^.]+$/,"")}_annotations.csv`,document.body.appendChild(p),p.click(),document.body.removeChild(p),URL.revokeObjectURL(c)}(I.value.getAnnotations(),{startNumber:Pe.value,increment:Ve.value,prefix:Ne.value,suffix:Ie.value},U.value,Ce.value),le("CSV数据已导出")}catch(e){le("导出CSV失败: "+e.message,"error")}else le("请先打开PDF文件","error")}function Ye(){if(I.value&&U.value)try{!function(e,t,l,a=[]){const n={version:"1.0",exportDate:(new Date).toISOString(),sourceFile:l,globalSettings:t,annotations:{}};for(const r in e){const l=e[r];Array.isArray(l)&&l.length>0&&(n.annotations[r]=l.map(e=>{const l=e.settings?.prefix??t.prefix??"",a=e.settings?.suffix??t.suffix??"",n=l+e.displayValue+a;return{x:e.x,y:e.y,x2:e.x2,y2:e.y2,displayValue:e.displayValue,label:n,style:e.style,annotationStyle:e.annotationStyle}}))}a&&a.length>0&&(n.groups=a.map(e=>({id:e.id,name:e.name,page:e.page,weldList:e.weldList})));const o=JSON.stringify(n,null,2),i=new Blob([o],{type:"application/json;charset=utf-8;"}),s=document.createElement("a"),u=URL.createObjectURL(i);s.href=u,s.download=`${l.replace(/\.[^.]+$/,"")}_annotations.json`,document.body.appendChild(s),s.click(),document.body.removeChild(s),URL.revokeObjectURL(u)}(I.value.getAnnotations(),{startNumber:Pe.value,increment:Ve.value,prefix:Ne.value,suffix:Ie.value,fontSize:Ue.value,borderStyle:we.value,annotationStyle:ke.value},U.value,Ce.value),le("JSON数据已导出(可用于还原标注)")}catch(e){le("导出JSON失败: "+e.message,"error")}else le("请先打开PDF文件","error")}async function We(e){if(e)try{const t=await async function(e){return new Promise((t,l)=>{const a=new FileReader;a.onload=e=>{try{const l=JSON.parse(e.target.result);if(!l.annotations||!l.globalSettings)throw new Error("无效的标注数据格式");t({annotations:l.annotations,settings:l.globalSettings,sourceFile:l.sourceFile,version:l.version})}catch(a){l(new Error("解析JSON文件失败: "+a.message))}},a.onerror=()=>{l(new Error("读取文件失败"))},a.readAsText(e)})}(e);if(!window.confirm(`确定要导入标注数据吗?\n来源文件: ${t.sourceFile||"未知"}\n版本: ${t.version||"未知"}\n当前标注将被覆盖。`))return;I.value&&(I.value.setAnnotations(t.annotations),t.settings&&(Pe.value=t.settings.startNumber||1,Ve.value=t.settings.increment||1,Ne.value=t.settings.prefix||"",Ie.value=t.settings.suffix||"",Ue.value=t.settings.fontSize||10,we.value=t.settings.borderStyle||"none",ke.value=t.settings.annotationStyle||"circle-outline"),le("标注数据导入成功"),de())}catch(t){le("导入失败: "+t.message,"error")}}async function Ge(e){if(e)try{const t=await async function(e){return new Promise((t,l)=>{const a=new FileReader;a.onload=a=>{try{const l=a.target.result.trim().split("\n");if(l.length<2)throw new Error("CSV文件内容不足,至少需要标题行和数据行");const n=He(l[0]),o=["页码","标签X坐标","标签Y坐标"];for(const e of o)if(!n.includes(e))throw new Error(`缺少必要的列: ${e}`);const i={};let s={startNumber:1,increment:1,prefix:"",suffix:"",fontSize:10,borderStyle:"none",annotationStyle:"arrow"};for(let e=1;e<l.length;e++){const t=He(l[e]);if(0===t.length||t.every(e=>!e))continue;const a={};for(let e=0;e<n.length;e++)a[n[e]]=t[e]||"";const o=a["页码"]?.trim();if(!o)continue;const u=parseFloat(a["标签X坐标"]),r=parseFloat(a["标签Y坐标"]),d=a["指向X坐标"]?parseFloat(a["指向X坐标"]):void 0,p=a["指向Y坐标"]?parseFloat(a["指向Y坐标"]):void 0;if(isNaN(u)||isNaN(r))throw new Error(`第${e+1}行: 坐标格式错误`);const c=a["显示值"]?parseInt(a["显示值"]):0,v=a["边框样式"]?.trim()||"none",f=a["标注样式"]?.trim()||"arrow",g=a["字体大小"]?parseInt(a["字体大小"]):10,x=a["前缀"]?.trim()||"",y=a["后缀"]?.trim()||"",m=a["起始值"]?parseInt(a["起始值"]):1,b=a["增量"]?parseInt(a["增量"]):1;1===e&&(s={startNumber:m,increment:b,prefix:x,suffix:y,fontSize:g,borderStyle:v,annotationStyle:f});const h={x:u,y:r,displayValue:c,style:v,annotationStyle:f,settings:{prefix:x,suffix:y,fontSize:g,startNumber:m,increment:b}};void 0===d||void 0===p||isNaN(d)||isNaN(p)||(h.x2=d,h.y2=p),i[o]||(i[o]=[]),i[o].push(h)}if(0===Object.keys(i).length)throw new Error("CSV文件中没有有效的标注数据");t({annotations:i,settings:s,sourceFile:e.name,version:"1.0"})}catch(n){l(new Error("解析CSV文件失败: "+n.message))}},a.onerror=()=>{l(new Error("读取文件失败"))},a.readAsText(e,"utf-8")})}(e);if(!window.confirm(`确定要导入CSV标注数据吗?\n来源文件: ${t.sourceFile||"未知"}\n当前标注将被覆盖。`))return;I.value&&(I.value.setAnnotations(t.annotations),t.settings&&(Pe.value=t.settings.startNumber||1,Ve.value=t.settings.increment||1,Ne.value=t.settings.prefix||"",Ie.value=t.settings.suffix||"",Ue.value=t.settings.fontSize||10,we.value=t.settings.borderStyle||"none",ke.value=t.settings.annotationStyle||"circle-outline"),le("CSV标注数据导入成功"),de())}catch(t){le("导入CSV失败: "+t.message,"error")}}function qe(e){const t=f.value;$.value[t]||($.value[t]=[]),$.value[t].push(e),I.value&&I.value.setImages($.value),le("图片已放置")}function kt(){le("已取消图片放置")}function St(e){$.value[e.page]=e.images,le("图片已删除")}async function zt(e){const t=e?.file,l=e?.size||80,a=e?.imageData;try{if(a)return I.value?(I.value.setTemporaryImage(a,l),void le("点击PDF上要放置表格的位置,按ESC取消")):void le("请先加载PDF","error");if(!t)return void le("请先选择图片文件","error");const e=new FileReader;e.onload=e=>{I.value?(I.value.setTemporaryImage(e.target.result,l),le("点击PDF上要放置图片的位置,按ESC取消")):le("请先加载PDF","error")},e.readAsDataURL(t)}catch(n){le("导入图片失败: "+n.message,"error")}}function Ct(){let e=R.value;if(!e){const t=document.getElementById("hdpdfurl");t&&t.value&&(e=t.value.trim())}if(!e&&t.value&&(e=URL.createObjectURL(t.value)),e){let t=`/viewer.html?url=${encodeURIComponent(e)}`;const l=document.getElementById("imgurl1"),a=document.getElementById("imgurl2");l?.value?.trim()&&(t+=`&imgurl1=${encodeURIComponent(l.value.trim())}`),a?.value?.trim()&&(t+=`&imgurl2=${encodeURIComponent(a.value.trim())}`),window.open(t,"_blank")}else le("未找到PDF地址","error")}async function At(e){if(e){R.value=e,le("正在加载在线PDF...");try{const a=await fetch(e);if(!a.ok)throw new Error(`加载失败: ${a.status} ${a.statusText}`);const n=await a.arrayBuffer(),o=new Blob([n],{type:"application/pdf"});let i="online.pdf";try{const t=new URL(e).pathname.split("/"),l=t[t.length-1];l&&l.includes(".pdf")&&(i=decodeURIComponent(l))}catch(l){}const s=new File([o],i,{type:"application/pdf"});ae=n,t.value=s,U.value=i,f.value=1,m.value=1,oe.value=1,ie.value=100,le("PDF加载成功")}catch(a){le("加载PDF失败: "+a.message,"error")}}}return S(()=>{try{const e=document.getElementById("hdpdfurl");if(e&&"string"==typeof e.value&&e.value.trim()){const t=e.value.trim();R.value=t,At(t)}const t=document.getElementById("hdjoinInfo");t&&"string"==typeof t.value&&t.value.trim()&&(M.value=t.value.trim())}catch(e){console.warn("Error checking for elements:",e)}}),a(f,()=>{I.value?B.value=[...I.value.getAnnotations()[f.value]||[]]:B.value=[]}),(e,l)=>(i(),o("div",Ke,[ee.value.show?(i(),o("div",{key:0,style:g({position:"fixed",top:"20px",right:"20px",padding:"12px 16px",background:"success"===ee.value.type?"#d1fae5":"#fee2e2",color:"success"===ee.value.type?"#065f46":"#991b1b",borderRadius:"4px",boxShadow:"0 4px 12px rgba(0,0,0,0.15)",zIndex:9999,animation:"slideIn 0.3s ease-out",fontSize:"14px",fontWeight:"500"})},r(ee.value.message),5)):s("",!0),u("div",Qe,[z(De,{"selected-annotation":j.value,"selected-annotation-page":L.value,"selected-annotation-index":O.value,"annotations-json":E.value,"initial-csv-data":M.value,"auto-annotating":je.value,groups:Ce.value,"group-mode":Ae.value,"line-renumber-mode":Fe.value,"start-number":Pe.value,onFileSelected:xe,onApplySettings:Re,onClearPageAnnotations:Ee,onRenumberPageAnnotations:Me,onAutoAnnotatePage:Oe,onUndoAnnotation:Be,onSavePdfEditable:_e,onExportPdfEmbedded:Te,onSavePdfFinal:Je,onExportCsv:Xe,onExportJson:Ye,onImportAnnotations:We,onImportCsv:Ge,onImportImage:zt,onUpdateAnnotation:Z,onDeleteAnnotation:H,onDeselectAnnotation:Q,onLoadPdfUrl:At,onToggleGroupMode:pe,onToggleLineRenumberMode:ce,onDeleteGroup:ge},null,8,["selected-annotation","selected-annotation-page","selected-annotation-index","annotations-json","initial-csv-data","auto-annotating","groups","group-mode","line-renumber-mode","start-number"])]),u("div",et,[u("div",tt,[u("div",{onClick:l[0]||(l[0]=e=>{b.value=!b.value,b.value&&(Ae.value=!1,Fe.value=!1)}),style:g({background:b.value?"#334155":"#e2e8f0",color:b.value?"white":"#475569",padding:"4px 8px",borderRadius:"4px",cursor:"pointer",userSelect:"none",fontSize:"11px",whiteSpace:"nowrap"})},"标注模式"+r(b.value?":开":":关"),5),l[16]||(l[16]=u("div",{style:{width:"1px",background:"#e5e7eb",height:"26px",margin:"0 6px"}},null,-1)),u("div",{class:h(["btn",{disabled:!n.value||f.value<=1}]),onClick:l[1]||(l[1]=e=>!(!n.value||f.value<=1)&&void(f.value>1&&(f.value--,m.value=f.value,Ae.value=!1))),style:{"font-size":"13px",padding:"6px 10px"}},"上一页",2),u("div",{class:h(["btn",{disabled:!n.value||f.value>=v.value}]),onClick:l[2]||(l[2]=e=>!(!n.value||f.value>=v.value)&&void(f.value<v.value&&(f.value++,m.value=f.value,Ae.value=!1))),style:{"font-size":"13px",padding:"6px 10px"}},"下一页",2),l[17]||(l[17]=u("div",{style:{width:"1px",background:"#e5e7eb",height:"26px",margin:"0 6px"}},null,-1)),u("div",{class:h(["btn",{disabled:!n.value}]),onClick:l[3]||(l[3]=e=>!n.value||(null===oe.value&&(oe.value=se.value),oe.value=Math.max(.5,+(oe.value/1.2).toFixed(2)),void(ie.value=Math.round(100*oe.value)))),style:{"font-size":"13px",padding:"6px 8px"}},"-",2),u("div",{class:h(["btn",{disabled:!n.value}]),onClick:l[4]||(l[4]=e=>!n.value||(null===oe.value&&(oe.value=se.value),oe.value=Math.min(3,+(1.2*oe.value).toFixed(2)),void(ie.value=Math.round(100*oe.value)))),style:{"font-size":"13px",padding:"6px 8px"}},"+",2),d(u("input",{"onUpdate:modelValue":l[5]||(l[5]=e=>ie.value=e),onInput:$e,type:"range",min:"50",max:"300",style:{width:"90px"},disabled:!n.value},null,40,lt),[[p,ie.value,void 0,{number:!0}]]),u("div",at,r(ue.value)+"%",1),l[18]||(l[18]=u("div",{style:{width:"1px",background:"#e5e7eb",height:"26px",margin:"0 6px"}},null,-1)),l[19]||(l[19]=u("div",{style:{"margin-left":"4px","font-size":"13px"}},"第",-1)),d(u("input",{type:"number","onUpdate:modelValue":l[6]||(l[6]=e=>m.value=e),min:1,max:v.value,style:{width:"50px","margin-left":"4px","font-size":"13px",padding:"2px 4px"}},null,8,nt),[[p,m.value,void 0,{number:!0}]]),u("div",{class:h(["btn",{disabled:!n.value}]),onClick:l[7]||(l[7]=e=>!n.value||void(m.value>=1&&m.value<=v.value&&(f.value=m.value,Ae.value=!1))),style:{"font-size":"13px",padding:"6px 10px"}},"跳转",2),u("div",ot,"/ "+r(v.value||0)+" 页",1),l[20]||(l[20]=u("div",{style:{width:"1px",background:"#e5e7eb",height:"26px",margin:"0 6px"}},null,-1)),U.value?(i(),o("div",it,[u("div",st,[l[14]||(l[14]=u("strong",null,"文件:",-1)),c(" "+r(U.value),1)]),u("div",ut,[l[15]||(l[15]=u("strong",null,"标签:",-1)),c(" "+r(re.value),1)])])):s("",!0),l[21]||(l[21]=u("div",{style:{flex:"1"}},null,-1)),u("div",{class:"btn",onClick:W,title:"框选一个区域,把每页相同位置的图像作为书签",style:g({fontSize:"13px",padding:"6px 10px",whiteSpace:"nowrap",background:T.value?"#7e22ce":"",color:T.value?"#fff":""})},r(T.value?"框选书签区域…":"添加书签"),5),u("div",{class:"btn",onClick:l[8]||(l[8]=e=>X.value=!X.value),title:"显示/隐藏书签面板",style:g({fontSize:"13px",padding:"6px 10px",whiteSpace:"nowrap",background:X.value?"#334155":"",color:X.value?"#fff":""})}," 书签"+r(J.value.length?`(${J.value.length})`:""),5),u("div",{class:"btn",onClick:l[9]||(l[9]=e=>_.value=!_.value),title:"查看/编辑本页焊口数据",style:g({fontSize:"13px",padding:"6px 10px",whiteSpace:"nowrap",background:_.value?"#334155":"",color:_.value?"#fff":""})},"焊口一览",4),u("div",{class:"btn",onClick:Ct,title:"在新窗口中打开纯PDF预览",style:{"font-size":"13px",padding:"6px 10px","white-space":"nowrap"}},"PDF预览")]),u("div",rt,[z(C,{file:t.value,page:f.value,scale:oe.value,"annotation-mode":b.value,"border-style":we.value,"annotation-style":ke.value,"single-click-mode":Se.value,"default-angle":ze.value,"start-number":Pe.value,increment:Ve.value,prefix:Ne.value,suffix:Ie.value,"font-size":Ue.value,"group-mode":Ae.value,groups:Ce.value,"line-renumber-mode":Fe.value,"bookmark-mode":T.value,ref_key:"pdfViewerRef",ref:I,onLoaded:ye,onScaleChanged:be,onWheelZoom:he,onPlaceImage:qe,onAnnotationSelected:q,onImagePlacingCancelled:kt,onImageDeleted:St,onAnnotationChanged:de,onGroupCreated:fe,onLineRenumberApplied:ve,onBookmarkRegionSelected:G},null,8,["file","page","scale","annotation-mode","border-style","annotation-style","single-click-mode","default-angle","start-number","increment","prefix","suffix","font-size","group-mode","groups","line-renumber-mode","bookmark-mode"])]),X.value?(i(),o("div",dt,[u("div",pt,[l[22]||(l[22]=u("span",null,"书签",-1)),u("span",{class:"bookmark-panel-close",title:"关闭",onClick:l[10]||(l[10]=e=>X.value=!1)},"×")]),u("div",ct,[0===J.value.length?(i(),o("div",vt,[...l[23]||(l[23]=[c(" 暂无书签",-1),u("br",null,null,-1),c("点击「添加书签」框选区域 ",-1)])])):s("",!0),(i(!0),o(x,null,y(J.value,(e,t)=>(i(),o("div",{key:e.id,class:"bookmark-group"},[u("div",ft,[u("span",null,[c("书签 "+r(t+1)+" ",1),u("span",gt,"· 取自第"+r(e.sourcePage)+"页",1)]),u("span",{class:"bookmark-group-delete",title:"删除此书签",onClick:t=>{return l=e.id,J.value=J.value.filter(e=>e.id!==l),void le("书签已删除");var l}},"×",8,xt)]),(i(!0),o(x,null,y(e.thumbs,e=>(i(),o("div",{key:e.page,class:h(["bookmark-thumb",{active:e.page===f.value}]),title:`跳转到第 ${e.page} 页`,onClick:t=>{var l;(l=e.page)>=1&&l<=v.value&&(f.value=l,m.value=l,Ae.value=!1)}},[u("div",mt,"第 "+r(e.page)+" 页",1),u("img",{src:e.dataUrl,alt:`第${e.page}页`},null,8,bt)],10,yt))),128))]))),128))])])):s("",!0),_.value?(i(),o("div",ht,[z(Ze,{annotations:B.value,page:f.value,"selected-index":L.value===f.value?O.value:null,closable:!0,onClose:l[11]||(l[11]=e=>_.value=!1),onUpdate:l[12]||(l[12]=(e,t)=>function({page:e,index:t,annotation:l}){I.value&&(I.value.updateAnnotation(e,t,l),L.value===e&&O.value===t&&(j.value={...l}),de())}({page:f.value,index:e,annotation:t})),onDelete:l[13]||(l[13]=e=>function({page:e,index:t}){I.value&&(I.value.deleteAnnotation(e,t),L.value===e&&null!==O.value&&(O.value===t?(j.value=null,L.value=null,O.value=null):O.value>t&&O.value--),le("标注已删除"),de())}({page:f.value,index:e})),onSelect:K},null,8,["annotations","page","selected-index"])])):s("",!0)])]))}}).mount("#app");