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

1 line
7.4 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,E as n,F as r,I as i,L as a,N as o,O as s,P as c,R as l,S as u,T as d,_ as f,a as p,c as m,g as h,i as g,j as _,k as v,m as y,n as b,p as x,r as S,s as C,u as w,v as T,x as E,y as D}from"./index-Dngmm__P.js";import{i as O}from"./utils-COFIQvWo.js";var ee={class:`page-container`},k={class:`page-header`},A={key:0,class:`upload-layout`},j={class:`upload-main-card`},M={key:0,class:`batch-file-list`},N={class:`batch-file-header`},P={class:`file-name`},F={class:`file-size`},I={key:1,class:`error-message`},L={class:`upload-side-card`},R={class:`material-panel compact-panel`},z={key:1,class:`inline-note`},B={key:1,class:`batch-dashboard`},V={class:`batch-progress-header`},H={class:`batch-progress-info`},U={class:`progress-bar`,style:{"margin-bottom":`var(--space-4)`}},W={class:`table-container`},G={key:0,class:`progress-bar`,style:{width:`100px`,display:`inline-block`}},K={key:1},q={key:1,style:{color:`var(--danger-color)`}},J={key:2,style:{color:`var(--text-secondary)`}},Y=b(e({__name:`BatchView`,setup(e){let b=w(),Y=m(),X=c(null),Z=null,Q=o({selectedFiles:[],selectedMaterial:`ABS`,dragOver:!1,uploading:!1,error:``,batchId:null,batchData:null}),te=e=>{let t=e.target;$(Array.from(t.files||[]))},ne=e=>{e.preventDefault(),Q.dragOver=!1,$(Array.from(e.dataTransfer?.files||[]))},$=e=>{let t=e.filter(e=>{let t=e.name.toLowerCase();return t.endsWith(`.stp`)||t.endsWith(`.step`)});t.length<e.length&&(Q.error=`部分文件格式不支持,已自动过滤非 STP/STEP 文件`);let n=[...Q.selectedFiles,...t];n.length>20?(Q.error=`单次批量上传最多 20 个文件`,Q.selectedFiles=n.slice(0,20)):Q.selectedFiles=n},re=e=>{Q.selectedFiles.splice(e,1)},ie=e=>({processing:`处理中`,completed:`已完成`,failed:`失败`,unknown:`未知`,rejected:`已拒绝`})[e]||e,ae=async()=>{if(!Y.token){Q.error=`请先登录后再上传文件`,b.push(`/login`);return}if(!Q.selectedFiles.length)return;Q.uploading=!0,Q.error=``;let e=new FormData;for(let t of Q.selectedFiles)e.append(`files`,t);e.append(`material`,Q.selectedMaterial),e.append(`draft_angle`,`2.0`),e.append(`shrinkage_rate`,`0.5`),e.append(`parting_precision`,`0.1`),e.append(`cavity_match`,`95`);try{let t=await fetch(`/api/batch-upload`,{method:`POST`,headers:{Authorization:`Bearer ${Y.token}`},body:e});if(t.status===401){p(),b.push(`/login`);return}if(!t.ok)throw Error(`上传失败: ${t.status}`);let n=await t.json();Q.batchId=n.batch_id,S(`已创建批量任务:${n.accepted} 个文件已接受`,`success`),oe(n.batch_id)}catch(e){Q.error=g(e,`批量上传`)}finally{Q.uploading=!1}},oe=e=>{let t=async()=>{try{let n=await C(`/api/batch/${e}`);if(Q.batchData=n,n.processing===0){S(`批量任务完成:${n.completed} 个成功,${n.failed} 个失败`,n.failed>0?`warning`:`success`);return}Z=setTimeout(t,3e3)}catch(e){g(e,`查询批量状态`)}};t()};return d(()=>{if(!Y.user){b.push(`/login`);return}}),n(()=>{Z&&clearTimeout(Z)}),(e,n)=>{let o=v(`t-button`),c=v(`t-option`),d=v(`t-select`),p=v(`t-form-item`),m=v(`t-tag`),g=v(`t-table-column`),S=v(`t-table`);return t(),D(`div`,ee,[h(`div`,k,[u(o,{variant:`text`,onClick:n[0]||=e=>r(b).back()},{default:_(()=>[...n[7]||=[h(`svg`,{width:`16`,height:`16`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,"stroke-width":`2.2`,"stroke-linecap":`round`,"stroke-linejoin":`round`},[h(`path`,{d:`M19 12H5M12 19l-7-7 7-7`})],-1),E(` 返回 `,-1)]]),_:1}),n[8]||=h(`h1`,null,`批量分析`,-1),n[9]||=h(`p`,null,`同时上传多个 STP 文件,并行分析、统一查看进度`,-1)]),Q.batchId?(t(),D(`div`,B,[h(`div`,V,[h(`div`,H,[h(`h2`,null,`批量任务:`+l(Q.batchId.slice(0,8))+`...`,1),h(`p`,null,[E(` 共 `+l(Q.batchData?.total)+` 个任务, `,1),u(m,{type:`success`,variant:`light`},{default:_(()=>[E(`完成 `+l(Q.batchData?.completed),1)]),_:1}),Q.batchData?.failed?(t(),f(m,{key:0,type:`danger`,variant:`light`},{default:_(()=>[E(`失败 `+l(Q.batchData?.failed),1)]),_:1})):T(``,!0),Q.batchData?.processing?(t(),f(m,{key:1,type:`warning`,variant:`light`},{default:_(()=>[E(`进行中 `+l(Q.batchData?.processing),1)]),_:1})):T(``,!0)])]),u(o,{variant:`outline`,size:`small`,onClick:n[6]||=e=>{Q.batchId=``,Q.batchData=null}},{default:_(()=>[...n[16]||=[E(` 新建批量 `,-1)]]),_:1})]),h(`div`,U,[h(`div`,{class:`progress-fill`,style:a({width:(Q.batchData?.progress_percent||0)+`%`})},null,4)]),h(`div`,W,[u(S,{data:Q.batchData?.tasks||[],"row-key":`task_id`,stripe:``},{default:_(()=>[u(g,{title:`文件名`,colKey:`filename`}),u(g,{title:`状态`},{default:_(({row:e})=>[u(m,{type:e.status===`completed`?`success`:e.status===`failed`?`danger`:`warning`,variant:`light`},{default:_(()=>[E(l(ie(e.status)),1)]),_:2},1032,[`type`])]),_:1}),u(g,{title:`进度`},{default:_(({row:e})=>[e.status===`processing`?(t(),D(`div`,G,[h(`div`,{class:`progress-fill`,style:a({width:(e.progress||0)+`%`})},null,4)])):(t(),D(`span`,K,l(e.progress||0)+`%`,1))]),_:1}),u(g,{title:`错误信息`,colKey:`error`}),u(g,{title:`操作`},{default:_(({row:e})=>[e.status===`completed`?(t(),f(o,{key:0,theme:`primary`,size:`small`,onClick:t=>r(b).push(`/moldinsight/result/${e.task_id}`)},{default:_(()=>[...n[17]||=[E(` 查看结果 `,-1)]]),_:1},8,[`onClick`])):e.status===`failed`?(t(),D(`span`,q,l(e.error||`分析失败`),1)):(t(),D(`span`,J,`处理中...`))]),_:1})]),_:1},8,[`data`])])])):(t(),D(`div`,A,[h(`div`,j,[n[14]||=h(`h2`,{class:`section-title`},`1. 选择多个 STP 文件`,-1),h(`div`,{class:i([`upload-zone`,{"drag-over":Q.dragOver}]),onDragover:n[1]||=x(e=>Q.dragOver=!0,[`prevent`]),onDragleave:n[2]||=x(e=>Q.dragOver=!1,[`prevent`]),onDrop:ne,onClick:n[3]||=e=>X.value?.click()},[h(`input`,{ref_key:`fileInput`,ref:X,type:`file`,accept:`.stp,.step`,multiple:``,onChange:te,hidden:``},null,544),n[10]||=h(`div`,{class:`upload-icon`},`📁`,-1),n[11]||=h(`div`,{class:`upload-text`},[h(`span`,{class:`upload-title`},`点击选择或拖拽多个 STP/STEP 文件`),h(`span`,{class:`upload-hint`},`支持批量上传,单次最多 20 个文件`)],-1)],34),Q.selectedFiles.length?(t(),D(`div`,M,[h(`div`,N,[h(`span`,null,`已选择 `+l(Q.selectedFiles.length)+` 个文件`,1),u(o,{variant:`text`,size:`small`,onClick:n[4]||=e=>Q.selectedFiles=[]},{default:_(()=>[...n[12]||=[E(`清空`,-1)]]),_:1})]),(t(!0),D(y,null,s(Q.selectedFiles,(e,i)=>(t(),D(`div`,{key:i,class:`batch-file-item`},[h(`span`,P,l(e.name),1),h(`span`,F,l(r(O)(e.size)),1),u(o,{variant:`text`,size:`small`,onClick:e=>re(i)},{default:_(()=>[...n[13]||=[E(`×`,-1)]]),_:1},8,[`onClick`])]))),128))])):T(``,!0),Q.error?(t(),D(`div`,I,l(Q.error),1)):T(``,!0)]),h(`div`,L,[n[15]||=h(`h2`,{class:`section-title`},`2. 注塑模参数`,-1),h(`div`,R,[u(p,{label:`产品材料`},{default:_(()=>[u(d,{modelValue:Q.selectedMaterial,"onUpdate:modelValue":n[5]||=e=>Q.selectedMaterial=e},{default:_(()=>[u(c,{value:`ABS`,label:`ABS (1.05 g/cm³)`}),u(c,{value:`PP`,label:`PP (0.90 g/cm³)`}),u(c,{value:`PE`,label:`PE (0.95 g/cm³)`}),u(c,{value:`PC`,label:`PC (1.20 g/cm³)`}),u(c,{value:`PA`,label:`PA (1.14 g/cm³)`}),u(c,{value:`POM`,label:`POM (1.41 g/cm³)`}),u(c,{value:`PMMA`,label:`PMMA (1.18 g/cm³)`}),u(c,{value:`PBT`,label:`PBT (1.31 g/cm³)`})]),_:1},8,[`modelValue`])]),_:1})]),Q.selectedFiles.length?(t(),f(o,{key:0,theme:`primary`,class:`upload-submit-btn`,onClick:ae,disabled:Q.uploading},{default:_(()=>[E(l(Q.uploading?`上传中...`:`3. 开始批量分析`),1)]),_:1},8,[`disabled`])):(t(),D(`div`,z,`先选择 STP 文件,再填写材料并开始批量分析。`))])]))])}}}),[[`__scopeId`,`data-v-167d79eb`]]);export{Y as default};