1 line
10 KiB
JavaScript
1 line
10 KiB
JavaScript
import{A as e,D as t,E as n,F as r,I as ee,L as i,M as te,N as a,O as o,P as s,S as c,_ as l,a as u,b as d,c as f,f as p,g as m,h,i as g,m as _,p as v,r as y,s as b,u as x,v as S,w as ne,x as C,y as w}from"./index-CpL0XiXx.js";import{a as T,i as E,r as D}from"./utils-COFIQvWo.js";var re={class:`page-container`},ie={class:`upload-layout`},ae={class:`upload-main-card`},oe={key:0,class:`file-info`},se={class:`file-name`},O={class:`file-size`},k={key:1,class:`error-message`},A={key:2,class:`progress-bar`},j={class:`upload-side-card`},M={class:`material-panel compact-panel`},N={class:`advanced-params`},P={class:`advanced-params-body`},F={class:`advanced-param-grid`},I={class:`param-meta-row`},L={class:`range-value`},R={class:`range-value`},z={class:`param-hint`},B={key:1,class:`inline-note`},V={key:0,class:`history-collapsible section`},H={class:`history-summary`},ce={class:`table-container`},U={class:`action-buttons`},W={class:`history-dropdown`},G={key:1,class:`inline-note`},K=c({__name:`MoldInsightView`,setup(c){let K=x(),q=f(),J=a(null),Y=te({selectedFile:null,selectedMaterial:`ABS`,moldParams:{draftAngle:2,shrinkageRate:.5,partingPrecision:.1,cavityMatch:95},uploading:!1,error:``,currentTask:null,task:null,polling:!1,dragOver:!1,progress:0,history:null,expandedFiles:{}}),le=_(()=>Object.keys(Y.expandedFiles).filter(e=>Y.expandedFiles[e]!==null)),X=e=>e===`completed`?`success`:e===`failed`?`danger`:`warning`,ue=async e=>{},Z=async()=>{try{Y.history=await b(`/api/history`)}catch(e){console.error(`加载历史记录失败:`,e)}},de=async e=>{if(Y.expandedFiles[e])Y.expandedFiles[e]=null;else try{let t=await b(`/api/history/${encodeURIComponent(e)}`);Y.expandedFiles[e]=t}catch(e){g(e,`加载文件历史`)}},Q=e=>{K.push(`/moldinsight/result/${e.task_id}`)},fe=e=>{let t=e.target.files?.[0];t&&$(t)},$=e=>{let t=e.name.toLowerCase();if(!t.endsWith(`.stp`)&&!t.endsWith(`.step`)){Y.error=`请选择 STP 或 STEP 格式文件`,Y.selectedFile=null;return}if(e.size>100*1024*1024){Y.error=`文件大小不能超过 100MB`,Y.selectedFile=null;return}Y.error=``,Y.selectedFile=e,y(`已选择文件: ${e.name}`,`success`)},pe=e=>{e.preventDefault(),Y.dragOver=!1;let t=e.dataTransfer?.files;t&&t.length>0&&$(t[0])},me=async()=>{if(!Y.selectedFile)return;if(!q.token){Y.error=`请先登录后再上传文件`,y(`请先登录`,`warning`),K.push(`/login`);return}if(q.token===`demo`){Y.error=`演示模式不支持文件上传,请使用完整账户登录`,y(`演示模式不支持上传`,`warning`);return}Y.uploading=!0,Y.error=``,Y.progress=0;let e=new FormData;e.append(`file`,Y.selectedFile),e.append(`material`,Y.selectedMaterial),e.append(`draft_angle`,String(Y.moldParams.draftAngle)),e.append(`shrinkage_rate`,String(Y.moldParams.shrinkageRate)),e.append(`parting_precision`,String(Y.moldParams.partingPrecision)),e.append(`cavity_match`,String(Y.moldParams.cavityMatch));try{let t=await fetch(`/api/upload`,{method:`POST`,headers:{Authorization:`Bearer ${q.token}`},body:e});if(t.status===401){u(),Y.error=`登录已过期,请重新登录`,y(`登录已过期,请重新登录`,`warning`),K.push(`/login`);return}if(!t.ok)throw Error(`上传失败: ${t.status}`);let n=await t.json();Y.currentTask={task_id:n.task_id,status:`processing`,filename:n.file_info?.filename},y(`文件上传成功,开始分析...`,`success`),he(n.task_id)}catch(e){Y.error=g(e,`文件上传`)}finally{Y.uploading=!1}},he=async e=>{Y.polling=!0,Y.progress=10;let t=0,n=async()=>{try{t++,Y.progress=Math.min(90,10+t*.5);let r=await b(`/api/status/${e}`,{method:`POST`});if(Y.currentTask=r,Y.task=r,r.status===`completed`){Y.polling=!1,Y.progress=100,y(`分析完成`,`success`),Z(),K.push(`/moldinsight/result/${e}`);return}if(r.status===`failed`){Y.polling=!1,Y.error=r.error||`分析失败`,y(`分析失败`,`error`);return}t<300&&setTimeout(n,2e3)}catch(e){Y.polling=!1,Y.error=g(e,`轮询状态`)}};n()},ge=[{key:`draftAngle`,label:`拔模角`,unit:`°`,min:1,max:10,step:.5,defaultValue:2,hint:`常规注塑件建议从 1.5° 到 3° 起步`},{key:`shrinkageRate`,label:`收缩率`,unit:`%`,min:.5,max:3,step:.1,defaultValue:.5,hint:`按材料牌号校核,默认值用于首轮方案评估`},{key:`partingPrecision`,label:`分型精度`,unit:`mm`,min:.01,max:1,step:.01,defaultValue:.1,hint:`用于控制分型面拟合与边界容差`},{key:`cavityMatch`,label:`型腔匹配度`,unit:`%`,min:80,max:100,step:1,defaultValue:95,hint:`数值越高越偏向紧配合与严格封合`}];return ne(()=>{if(!q.user){K.push(`/login`);return}Z()}),(te,a)=>{let c=o(`t-option`),u=o(`t-select`),f=o(`t-form-item`),g=o(`t-input-number`),_=o(`t-button`),y=o(`t-table-column`),b=o(`t-tag`),x=o(`t-table`);return n(),S(`div`,re,[a[13]||=w(`<div class="page-header"><h1>注塑模 STP 分析</h1><p>上传 STEP/STP 产品件,完成自动分模、工程建议与导出</p></div><div class="moldinsight-intro-grid"><div class="intro-card"><div class="intro-card-title">输入</div><div class="intro-card-text">STEP/STP 产品件,面向注塑模主流程</div></div><div class="intro-card"><div class="intro-card-title">输出</div><div class="intro-card-text">分模方案、DFM 风险、注塑模系统摘要与 CAD 导出</div></div><div class="intro-card"><div class="intro-card-title">目标</div><div class="intro-card-text">先确认推荐方案,再进入导出与 CAM 准备</div></div></div>`,2),h(`div`,ie,[h(`div`,ae,[a[7]||=h(`h2`,{class:`section-title`},`1. 上传产品件`,-1),h(`div`,{class:r([`upload-zone`,{"drag-over":Y.dragOver}]),onDragover:a[0]||=p(e=>Y.dragOver=!0,[`prevent`]),onDragleave:a[1]||=p(e=>Y.dragOver=!1,[`prevent`]),onDrop:pe,onClick:a[2]||=e=>J.value?.click()},[h(`input`,{ref_key:`fileInput`,ref:J,type:`file`,accept:`.stp,.step`,onChange:fe,hidden:``},null,544),a[5]||=h(`div`,{class:`upload-icon`},`📁`,-1),a[6]||=h(`div`,{class:`upload-text`},[h(`span`,{class:`upload-title`},`点击选择或拖拽 STP/STEP 文件`),h(`span`,{class:`upload-hint`},`支持注塑模产品件分析,最大 100MB`)],-1)],34),Y.selectedFile?(n(),S(`div`,oe,[h(`span`,se,i(Y.selectedFile.name),1),h(`span`,O,i(s(E)(Y.selectedFile.size)),1),h(`button`,{class:`btn-clear`,onClick:a[3]||=e=>Y.selectedFile=null,title:`清除文件`},`×`)])):l(``,!0),Y.error?(n(),S(`div`,k,i(Y.error),1)):l(``,!0),Y.polling?(n(),S(`div`,A,[h(`div`,{class:`progress-fill`,style:ee({width:Y.progress+`%`})},null,4)])):l(``,!0)]),h(`div`,j,[a[10]||=h(`h2`,{class:`section-title`},`2. 注塑模参数`,-1),h(`div`,M,[C(f,{label:`产品材料`},{default:e(()=>[C(u,{modelValue:Y.selectedMaterial,"onUpdate:modelValue":a[4]||=e=>Y.selectedMaterial=e},{default:e(()=>[C(c,{value:`ABS`,label:`ABS (1.05 g/cm³)`}),C(c,{value:`PP`,label:`PP (0.90 g/cm³)`}),C(c,{value:`PE`,label:`PE (0.95 g/cm³)`}),C(c,{value:`PC`,label:`PC (1.20 g/cm³)`}),C(c,{value:`PA`,label:`PA (1.14 g/cm³)`}),C(c,{value:`POM`,label:`POM (1.41 g/cm³)`}),C(c,{value:`PMMA`,label:`PMMA (1.18 g/cm³)`}),C(c,{value:`PBT`,label:`PBT (1.31 g/cm³)`})]),_:1},8,[`modelValue`])]),_:1}),h(`details`,N,[a[9]||=h(`summary`,null,`高级工艺参数`,-1),h(`div`,P,[a[8]||=h(`div`,{class:`inline-note`},`默认值适用于多数注塑件;仅在已知工艺约束时再调整。`,-1),h(`div`,F,[(n(),S(v,null,t(ge,t=>h(`div`,{class:`param-input-card`,key:t.key},[C(f,{label:t.label},{default:e(()=>[C(g,{modelValue:Y.moldParams[t.key],"onUpdate:modelValue":e=>Y.moldParams[t.key]=e,modelModifiers:{number:!0},min:t.min,max:t.max,step:t.step,suffix:t.unit},null,8,[`modelValue`,`onUpdate:modelValue`,`min`,`max`,`step`,`suffix`]),h(`div`,I,[h(`span`,L,`默认 `+i(t.defaultValue)+i(t.unit),1),h(`span`,R,`范围 `+i(t.min)+` - `+i(t.max)+i(t.unit),1)]),h(`div`,z,i(t.hint),1)]),_:2},1032,[`label`])])),64))])])])]),Y.selectedFile?(n(),m(_,{key:0,theme:`primary`,class:`upload-submit-btn`,onClick:me,disabled:Y.uploading||Y.polling},{default:e(()=>[d(i(Y.uploading?`上传中...`:Y.polling?`分析中...`:`3. 开始注塑模分析`),1)]),_:1},8,[`disabled`])):(n(),S(`div`,B,`先选择 STP 文件,再填写材料并开始分析。`))])]),Y.history?.files?.length?(n(),S(`details`,V,[h(`summary`,H,`分析历史(`+i(Y.history.files.length)+` 个文件)`,1),h(`div`,ce,[C(x,{"row-key":`filename`,data:Y.history.files,"expanded-row-keys":le.value,onExpandChange:ue},{expandedRow:e(({row:t})=>[h(`div`,W,[Y.expandedFiles[t.filename]?(n(),m(x,{key:0,"row-key":`id`,data:Y.expandedFiles[t.filename]},{default:e(()=>[C(y,{key:`upload_time`,title:`上传时间`},{cell:e(({row:e})=>[d(i(s(D)(e.upload_time)),1)]),_:1}),C(y,{key:`file_size`,title:`文件大小`},{cell:e(({row:e})=>[d(i(s(E)(e.file_size)),1)]),_:1}),C(y,{key:`status`,title:`状态`},{cell:e(({row:t})=>[C(b,{theme:X(t.status),variant:`light`},{default:e(()=>[d(i(t.status),1)]),_:2},1032,[`theme`])]),_:1}),C(y,{key:`volume`,title:`体积 (mm³)`},{cell:e(({row:e})=>[d(i(e.volume?s(T)(e.volume):`-`),1)]),_:1}),C(y,{key:`surface_area`,title:`表面积 (mm²)`},{cell:e(({row:e})=>[d(i(e.surface_area?s(T)(e.surface_area):`-`),1)]),_:1}),C(y,{key:`product_weight`,title:`重量 (g)`},{cell:e(({row:e})=>[d(i(e.product_weight?e.product_weight.toFixed(2):`-`),1)]),_:1}),C(y,{key:`detail_actions`,title:`操作`},{cell:e(({row:t})=>[t.has_analysis?(n(),m(_,{key:0,theme:`primary`,size:`small`,onClick:e=>Q(t)},{default:e(()=>[...a[12]||=[d(` 查看详情 `,-1)]]),_:1},8,[`onClick`])):l(``,!0)]),_:1})]),_:1},8,[`data`])):(n(),S(`div`,G,`加载中...`))])]),default:e(()=>[C(y,{key:`filename`,title:`文件名`},{cell:e(({row:e})=>[d(i(e.filename),1)]),_:1}),C(y,{key:`upload_count`,title:`上传次数`},{cell:e(({row:t})=>[C(b,{theme:`primary`,variant:`light`},{default:e(()=>[d(i(t.upload_count)+` 次`,1)]),_:2},1024)]),_:1}),C(y,{key:`file_size`,title:`文件大小`},{cell:e(({row:e})=>[d(i(s(E)(e.file_size)),1)]),_:1}),C(y,{key:`latest_status`,title:`最新状态`},{cell:e(({row:t})=>[C(b,{theme:X(t.latest_status),variant:`light`},{default:e(()=>[d(i(t.latest_status),1)]),_:2},1032,[`theme`])]),_:1}),C(y,{key:`latest_upload_time`,title:`最新分析时间`},{cell:e(({row:e})=>[d(i(s(D)(e.latest_upload_time)),1)]),_:1}),C(y,{key:`actions`,title:`操作`},{cell:e(({row:t})=>[h(`div`,U,[t.latest_status===`completed`?(n(),m(_,{key:0,theme:`primary`,size:`small`,onClick:e=>Q({task_id:t.latest_task_id})},{default:e(()=>[...a[11]||=[d(` 查看最新 `,-1)]]),_:1},8,[`onClick`])):l(``,!0),C(_,{variant:`text`,size:`small`,onClick:e=>de(t.filename),title:Y.expandedFiles[t.filename]?`收起`:`展开历史记录`},{icon:e(()=>[h(`span`,{class:r([`dropdown-icon`,{expanded:Y.expandedFiles[t.filename]}])},`▼`,2)]),_:2},1032,[`onClick`,`title`])])]),_:1})]),_:1},8,[`data`,`expanded-row-keys`])])])):l(``,!0)])}}});export{K as default}; |