import{aj as z,S as E,as as _,r as L,F as N}from"./index.CL7yl-Wb.js";import{a as k,i as R,r as p,aj as v,at as $,c as b,o as y,S as o,K as t,E as D,L as K,u as i,b as n,P as d}from"./vue.D1BjjNmv.js";const O={style:{display:"inline-block"}},P={class:"dialog-footer"},q=k({name:"importExcel"}),J=k({...q,props:{upload:{type:Object,default(){return{open:!0,title:"",isUploading:!1,updateSupport:0,headers:{Authorization:"JWT "+E.get("token")},url:z()+"api/system/file/"}}},api:{type:String,default(){}}},setup(w){const C=R("refreshView");let a=w,s=p(!1);const f=p(),r=p(!1),m=p(!1),S=function(){r.value=!0},V=function(){_({url:a.api+"import_data/",params:{},method:"get"})},F=function(){_({url:a.api+"update_template/",params:{},method:"get"})},B=function(u,e,l){m.value=!0},T=function(u,e,l){return m.value=!1,s.value=!0,f.value.clearFiles(),L({url:a.api+"import_data/",method:"post",data:{url:u.data.url}}).then(g=>{s.value=!1,N.alert("导入成功","导入完成",{confirmButtonText:"OK",callback:x=>{C()}})}).catch(()=>{s.value=!1})},U=function(){f.value.submit()};return(u,e)=>{const l=v("el-button"),g=v("el-upload"),x=v("el-dialog"),j=$("loading");return y(),b("div",O,[o(l,{size:"default",type:"success",onClick:e[0]||(e[0]=c=>S())},{default:t(()=>[D(u.$slots,"default",{},()=>[e[3]||(e[3]=d("导入"))])]),_:3}),o(x,{title:i(a).upload.title,modelValue:r.value,"onUpdate:modelValue":e[2]||(e[2]=c=>r.value=c),width:"400px","append-to-body":""},{footer:t(()=>[n("div",P,[o(l,{type:"primary",disabled:i(s),onClick:U},{default:t(()=>e[9]||(e[9]=[d("确 定")])),_:1},8,["disabled"]),o(l,{disabled:i(s),onClick:e[1]||(e[1]=c=>r.value=!1)},{default:t(()=>e[10]||(e[10]=[d("取 消")])),_:1},8,["disabled"])])]),default:t(()=>[K((y(),b("div",null,[o(g,{ref_key:"uploadRef",ref:f,limit:1,accept:".xlsx, .xls",headers:i(a).upload.headers,action:i(a).upload.url,disabled:m.value,"on-progress":B,"on-success":T,"auto-upload":!1,drag:""},{tip:t(()=>e[4]||(e[4]=[n("div",{class:"el-upload__tip",style:{color:"red"}},"提示：仅允许导入“xls”或“xlsx”格式文件！",-1)])),default:t(()=>[e[5]||(e[5]=n("i",{class:"el-icon-upload"},null,-1)),e[6]||(e[6]=n("div",{class:"el-upload__text"},[d(" 将文件拖到此处，或 "),n("em",null,"点击上传")],-1))]),_:1},8,["headers","action","disabled"]),n("div",null,[o(l,{type:"warning",style:{"font-size":"14px","margin-top":"20px"},onClick:V},{default:t(()=>e[7]||(e[7]=[d("下载导入模板")])),_:1}),o(l,{type:"warning",style:{"font-size":"14px","margin-top":"20px"},onClick:F},{default:t(()=>e[8]||(e[8]=[d("批量更新模板")])),_:1})])])),[[j,i(s)]])]),_:1},8,["title","modelValue"])])}}});export{J as _};
