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