import{d as b,V as A,r as E,aw as F,c as y,o as N,w as p,j as f,aH as R,l as o,cq as T,cO as v,fm as w,ds as I,B,p as j,A as D,hK as O,X as U,cZ as k,bR as L,R as V,gI as $}from"./index-9PRMimni.js";import{c as K}from"./componentSetting-DVhNDBTO.js";import{h as M,a as P,u as q}from"./jobPlanDetails-5wu16ZE_.js";import{I as z}from"./helper-CaePX3tj.js";import{p as h}from"./pick-Cg3anC-c.js";import"./_flatRest-DBrd2CHT.js";import"./flatten-DeoUZLdb.js";const Y=b({__name:"index",props:{data:{},isReadonly:{type:Boolean}},setup(_){const l=_,{t:c}=A(),m=k(),r=E([]);function g({name:a,path:t}){const e={...h(l.data,["shipId","serialNumber","productCode","model","jobCode"]),attachmentName:a,fileCode:t};q(e).then(s=>{m.success(c("common.uploadSuccessText")),u()})}function x({file:a,fileList:t,index:e}){const s=o(r)?.[e],i={...h(l.data,["shipId","serialNumber","productCode","model","jobCode"]),attachmentName:s.name,fileCode:s.path};M(i).then(()=>{m.success(c("common.optionsDelSuccessText")),u()})}function C({file:a,event:t}){try{const e=L("("+t.target.response+")"),{infoField:s}=K.upload.apiSetting,{code:i}=e,n=e.msg||e.message||c("common.uploadFailText"),d=e[s];i===V.SUCCESS?g({name:a.name,path:d.name}):m.error(n)}catch(e){console.error(e)}}function S(a){console.warn("File upload error:",a),m.error(c("common.uploadFailText"))}async function u(){try{const a=await P({...l.data}).then(t=>$(t,e=>({name:e.attachmentName,url:e.fileUrl,path:e.fileCode,status:"finished"})));r.value=a}catch(a){console.error("加载数据失败:",a),r.value=[]}}return F(()=>{u()}),(a,t)=>{const e=B,s=R,i=U;return N(),y(i,{class:"w-[50%]"},{default:p(()=>[f(s,{disabled:l.isReadonly,max:3,accept:".pdf,.jpg,.png","file-list":o(r),"onUpdate:fileList":t[0]||(t[0]=n=>I(r)?r.value=n:null),headers:{timestamp:new Date().getTime(),authorization:`${o(v).get(o(w))}`},action:`${o(T)().urlPrefix}${o(z)?"/system":""}/files`,onRemove:t[1]||(t[1]=n=>x({...n})),onError:S,onFinish:t[2]||(t[2]=({file:n,event:d})=>C({file:n,event:d}))},{default:p(()=>[f(e,{class:"mt-[8px]"},{icon:p(()=>[f(o(O))]),default:p(()=>[j(" "+D(o(c)("common.uploadText")),1)]),_:1})]),_:1},8,["disabled","file-list","headers","action"])]),_:1})}}});export{Y as default};
