import{_ as $,x as I,b as O,r as U,e as b,o as B,g as D,c as o,w as l,i as p,t as u,j as k,B as F,aI as L,aH as S,n as T,v as M,aG as N,a1 as V,a8 as E,al as j}from"./app-DGDivIsO.js";import{a as q}from"./apiAdmin-D4J8O5cP.js";import{U as A,a as G}from"./UploadFile-BWxMf9-v.js";import{C as H}from"./CloudDownloadOutlined-BbYr1R9k.js";const P=I({props:["pageTitle","sampleFileUrl","importUrl"],emits:["onUploadSuccess"],components:{CloudDownloadOutlined:H,UploadFile:A,UploadOutlined:G},setup(e,{emit:s}){const{addEditFileRequestAdmin:f,loading:d,rules:g}=q(),{t:v}=O(),a=U([]),n=U(!1),m=t=>(a.value=[...a.value,t],!1),c=()=>{const t={};a&&a.value&&a.value[0]!=null&&(t.file=a.value[0]),d.value=!0,f({url:e.importUrl,data:t,successMessage:v("messages.imported_successfully"),success:C=>{i(),s("onUploadSuccess")}})},r=()=>{n.value=!0},i=t=>{a.value=[],n.value=!1};return{fileList:a,rules:g,loading:d,visible:n,showModal:r,handleCancel:i,importItems:c,beforeUpload:m}}});function R(e,s,f,d,g,v){const a=b("CloudDownloadOutlined"),n=F,m=L,c=S,r=T,i=M,t=b("UploadOutlined"),C=N,y=V,h=E,w=j;return B(),D("div",null,[o(n,{type:"primary",onClick:e.showModal},{default:l(()=>[o(a),p(" "+u(e.pageTitle),1)]),_:1},8,["onClick"]),o(w,{open:e.visible,"onUpdate:open":s[1]||(s[1]=_=>e.visible=_),title:e.pageTitle},{footer:l(()=>[o(n,{type:"primary",loading:e.loading,onClick:e.importItems},{default:l(()=>[p(u(e.$t("common.import")),1)]),_:1},8,["loading","onClick"]),o(n,{key:"back",onClick:e.handleCancel},{default:l(()=>[p(u(e.$t("common.cancel")),1)]),_:1},8,["onClick"])]),default:l(()=>[o(i,{gutter:16,class:"mb-10"},{default:l(()=>[o(r,{xs:24,sm:24,md:24,lg:24},{default:l(()=>[o(c,null,{default:l(()=>[k("ul",null,[k("li",null,[o(m,{href:e.sampleFileUrl,target:"_blank"},{default:l(()=>[p(u(e.$t("messages.click_here_to_download_sample_file")),1)]),_:1},8,["href"])])])]),_:1})]),_:1})]),_:1}),o(i,{gutter:16},{default:l(()=>[o(r,{xs:24,sm:24,md:24,lg:24},{default:l(()=>[o(h,{layout:"vertical"},{default:l(()=>[o(y,{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(C,{accept:".xlsx,.csv","file-list":e.fileList,"onUpdate:fileList":s[0]||(s[0]=_=>e.fileList=_),name:"file","before-upload":e.beforeUpload,maxCount:1},{default:l(()=>[o(n,{loading:e.loading},{icon:l(()=>[o(t)]),default:l(()=>[p(" "+u(e.$t("common.upload")),1)]),_:1},8,["loading"])]),_:1},8,["file-list","before-upload"])]),_:1},8,["label","help","validateStatus"])]),_:1})]),_:1})]),_:1})]),_:1},8,["open","title"])])}const W=$(P,[["render",R]]);export{W as I};
