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