Files
geMoldInsight/static/assets/MoldInsightView-DkAbjiJg.js
T
2026-07-31 16:55:52 +08:00

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