import{_ as B,d as N,u as T,k as v,c as U,g as o,w as l,b as k,o as b,i as d,t as u,f as V,h as w,e as O}from"./app-Bei_nIK3.js";import{a as P}from"./apiAdmin-DKbjyhIh.js";import{a as F,U as I}from"./UploadFile-VVfMhFHM.js";import{P as M}from"./PdfDownload-Bl_a57u_.js";import{C as L}from"./CloudDownloadOutlined-Cl_zT9aY.js";import{B as E}from"./useFlexGapSupport-I9-A4OAO.js";import{M as q}from"./index-BV9s-9gS.js";import{P as A}from"./Paragraph-CJFej98T.js";import"./index-C53-ipA5.js";import{F as R,_ as j}from"./index-CvmHj1Ev.js";import{C as z}from"./index-Cjf_Tk6m.js";import{_ as G,a as H}from"./index-DxFi17QQ.js";import{_ as J}from"./index-BdzfonJJ.js";const K=N({props:{pageTitle:String,sampleFileUrl:String,importUrl:String,checkVisible:{type:Boolean,default:!1},buttonType:{type:Boolean,default:!1},url:{type:String,default:""},fileName:{type:String,default:"file"}},emits:["onUploadSuccess"],components:{CloudDownloadOutlined:L,UploadFile:I,UploadOutlined:F,PdfDownload:M},setup(e,{emit:t}){const{addEditFileRequestAdmin:y,loading:c,rules:C}=P(),{t:h}=T(),a=v([]),n=v(!1),i=v(!1),_=s=>(a.value=[...a.value,s],!1),p=()=>{const s={};a&&a.value&&a.value[0]!=null&&(s.file=a.value[0]),e.checkVisible&&(s.override=i.value),c.value=!0,y({url:e.importUrl,data:s,successMessage:h("messages.imported_successfully"),success:g=>{f(),t("onUploadSuccess")}})},m=()=>{n.value=!0},f=s=>{a.value=[],n.value=!1,i.value=!1};return{fileList:a,rules:C,loading:c,visible:n,showModal:m,handleCancel:f,importItems:p,beforeUpload:_,overrideData:i}}}),Q={key:0};function W(e,t,y,c,C,h){const a=k("CloudDownloadOutlined"),n=E,i=k("PdfDownload"),_=A,p=H,m=G,f=k("UploadOutlined"),s=J,g=j,D=z,S=R,$=q;return b(),U("div",null,[o(n,{type:"primary",onClick:e.showModal},{default:l(()=>[o(a),d(" "+u(e.pageTitle),1)]),_:1},8,["onClick"]),o($,{open:e.visible,"onUpdate:open":t[2]||(t[2]=r=>e.visible=r),title:e.pageTitle},{footer:l(()=>[o(n,{type:"primary",loading:e.loading,onClick:e.importItems},{default:l(()=>[d(u(e.$t("common.import")),1)]),_:1},8,["loading","onClick"]),o(n,{key:"back",onClick:e.handleCancel},{default:l(()=>[d(u(e.$t("common.cancel")),1)]),_:1},8,["onClick"])]),default:l(()=>[o(m,{gutter:16,class:"mb-10"},{default:l(()=>[o(p,{xs:24,sm:24,md:24,lg:24},{default:l(()=>[o(_,null,{default:l(()=>[V("ul",null,[e.buttonType?(b(),U("li",Q,[o(i,{buttonType:!0,title:e.$t("messages.click_here_to_download_sample_file"),url:e.url,fileName:e.fileName,payload:{type:"csv"}},null,8,["title","url","fileName"])])):w("",!0)])]),_:1})]),_:1})]),_:1}),o(m,{gutter:16},{default:l(()=>[o(p,{xs:24,sm:24,md:24,lg:24},{default:l(()=>[o(S,{layout:"vertical"},{default:l(()=>[o(g,{label:e.$t("common.file"),name:"file",help:e.rules.file?e.rules.file.message:null,validateStatus:e.rules.file?"error":null},{default:l(()=>[o(s,{accept:".xlsx,.csv","file-list":e.fileList,"onUpdate:fileList":t[0]||(t[0]=r=>e.fileList=r),name:"file","before-upload":e.beforeUpload,maxCount:1},{default:l(()=>[o(n,{loading:e.loading},{icon:l(()=>[o(f)]),default:l(()=>[d(" "+u(e.$t("common.upload")),1)]),_:1},8,["loading"])]),_:1},8,["file-list","before-upload"])]),_:1},8,["label","help","validateStatus"]),e.checkVisible?(b(),O(g,{key:0},{default:l(()=>[o(D,{checked:e.overrideData,"onUpdate:checked":t[1]||(t[1]=r=>e.overrideData=r)},{default:l(()=>[d(u(e.$t("leave.attendance_overwrite")),1)]),_:1},8,["checked"])]),_:1})):w("",!0)]),_:1})]),_:1})]),_:1})]),_:1},8,["open","title"])])}const de=B(K,[["render",W]]);export{de as I};
