import{ad as _,d as w,h as f,Y as B,r,o as z,f as I,w as a,b as u,k as j,a2 as R,l as g,E as m}from"./index.e3896b23.js";import{c as $}from"./constant.71632d98.js";const K=n=>_.get("/data-integrate/file/"+n),M=n=>n.id?_.put("/data-integrate/file",n):_.post("/data-integrate/file",n),N=g("\u9009\u62E9\u6587\u4EF6"),S=g("\u53D6\u6D88"),q=g("\u786E\u5B9A"),O=w({__name:"add-or-update",emits:["refreshDataList"],setup(n,{expose:C,emit:v}){const c=f(),i=f(!1),p=f(),t=B({name:"",fileCategoryId:"",path:"",type:"",fileUrl:"",size:"",description:"",projectId:""}),b=(l,e,d,s)=>{i.value=!0,t.id="",c.value&&c.value.clearFiles(),p.value&&p.value.resetFields(),l&&D(l),t.fileCategoryId=e,t.path=d,t.projectId=s},D=l=>{K(l).then(e=>{Object.assign(t,e.data),t.fileUrl="",t.name=""})},V=f({name:[{required:!0,message:"\u5FC5\u586B\u9879\u4E0D\u80FD\u4E3A\u7A7A",trigger:"blur"}]}),y=l=>l.size/1024/1024/1024/1024>1?(m.error("\u6587\u4EF6\u5927\u5C0F\u4E0D\u80FD\u8D85\u8FC7100M"),!1):!0,A=(l,e)=>{e.length>1&&e.splice(0,1)},h=(l,e)=>{if(l.code!==0)return m.error("\u4E0A\u4F20\u5931\u8D25\uFF1A"+l.message),!1;console.log(l.data),t.name=l.data.name,t.type=l.data.suffix,t.fileUrl=l.data.url,t.size=l.data.size},E=()=>{p.value.validate(l=>{if(!l)return!1;if(!t.fileUrl){m.warning({message:"\u8BF7\u9009\u62E9\u6587\u4EF6\u4E0A\u4F20\u540E\u518D\u63D0\u4EA4\uFF01"});return}M(t).then(()=>{m.success({message:"\u64CD\u4F5C\u6210\u529F",duration:500,onClose:()=>{i.value=!1,v("refreshDataList")}})})})};return C({init:b}),(l,e)=>{const d=r("el-input"),s=r("el-form-item"),F=r("el-button"),U=r("el-upload"),k=r("el-form"),x=r("el-dialog");return z(),I(x,{modelValue:i.value,"onUpdate:modelValue":e[6]||(e[6]=o=>i.value=o),title:t.id?"\u4FEE\u6539":"\u65B0\u589E","close-on-click-modal":!1},{footer:a(()=>[u(F,{onClick:e[4]||(e[4]=o=>i.value=!1)},{default:a(()=>[S]),_:1}),u(F,{type:"primary",onClick:e[5]||(e[5]=o=>E())},{default:a(()=>[q]),_:1})]),default:a(()=>[u(k,{ref_key:"dataFormRef",ref:p,model:t,rules:V.value,"label-width":"100px",onKeyup:e[3]||(e[3]=R(o=>E(),["enter"]))},{default:a(()=>[u(s,{label:"\u540D\u79F0",prop:"name"},{default:a(()=>[u(d,{disabled:"",modelValue:t.name,"onUpdate:modelValue":e[0]||(e[0]=o=>t.name=o)},null,8,["modelValue"])]),_:1}),u(s,{label:"\u4E0A\u4F20\u6587\u4EF6"},{default:a(()=>[u(U,{ref_key:"upload",ref:c,class:"upload-demo",action:j($).uploadUrl,"before-upload":y,"on-success":h,multiple:"","on-change":A},{trigger:a(()=>[u(F,{type:"primary"},{default:a(()=>[N]),_:1})]),_:1},8,["action"])]),_:1}),u(s,{label:"\u6240\u5C5E\u5206\u7EC4",prop:"path"},{default:a(()=>[u(d,{disabled:"",modelValue:t.path,"onUpdate:modelValue":e[1]||(e[1]=o=>t.path=o),placeholder:"\u6240\u5C5E\u5206\u7EC4"},null,8,["modelValue"])]),_:1}),u(s,{label:"\u63CF\u8FF0",prop:"description"},{default:a(()=>[u(d,{rows:2,type:"textarea",modelValue:t.description,"onUpdate:modelValue":e[2]||(e[2]=o=>t.description=o),placeholder:"\u63CF\u8FF0"},null,8,["modelValue"])]),_:1})]),_:1},8,["model","rules"])]),_:1},8,["modelValue","title"])}}});export{O as _};
