import{S as T,g as z,d as h,r as j}from"./index.ad3efb29.js";import{j as L}from"./elementPlus.4833989a.js";import{d as N,B as O,r as p,ai as _,aq as R,o as x,c as y,U as a,O as e,H as $,S as n,a as d,u as i,P as q}from"./vue.adf17aba.js";const D={style:{display:"inline-block"}},E=d("i",{class:"el-icon-upload"},null,-1),P=d("div",{class:"el-upload__text"},[n(" 将文件拖到此处，或 "),d("em",null,"点击上传")],-1),A=d("div",{class:"el-upload__tip",style:{color:"red"}},"提示：仅允许导入“xls”或“xlsx”格式文件！",-1),H={class:"dialog-footer"},M=N({__name:"index",props:{upload:{type:Object,default(){return{open:!0,title:"",isUploading:!1,updateSupport:0,headers:{Authorization:"JWT "+T.get("token")},url:z()+"api/system/file/"}}},api:{type:String,default(){}}},setup(b){const k=O("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"})},S=function(){h({url:o.api+"update_template/",params:{},method:"get"})},V=function(u,t,l){f.value=!0},B=function(u,t,l){return f.value=!1,s.value=!0,c.value.clearFiles(),j({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"),U=R("loading");return x(),y("div",D,[a(l,{size:"default",type:"success",onClick:t[0]||(t[0]=m=>w())},{default:e(()=>[$(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",H,[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":V,"on-success":B,"auto-upload":!1,drag:""},{tip:e(()=>[A]),default:e(()=>[E,P]),_: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:S},{default:e(()=>[n("批量更新模板")]),_:1})])])),[[U,i(s)]])]),_:1},8,["title","modelValue"])])}}});export{M as _};
