import{M as V,K as F,q as A,a0 as j,L as N}from"./index.17037962789732.js";import"./index.170379627897333.js";import"./index.170379627897336.js";import"./index.170379627897329.js";import"./index.170379627897315.js";import"./index.170379627897330.js";import{F as S}from"./system.1703796278973.js";import{L as T,T as E,o as C}from"./comm.1703796278973.js";import{d as M}from"./utils.1703796278973.js";import{f as O,g as I}from"./cardManagement.1703796278973.js";import{d as K,k as u,r as $,o as d,x as k,b as l,a as c,u as n,t as U,z as i,c as b,A as B,B as D,F as J}from"./vue.1703796278973.js";const R={style:{"margin-left":"20px"}},X={key:0,style:{"margin-top":"20px"}},q={style:{color:"red"}},ae=K({__name:"UploadFile",props:{modelValue:{type:Array,default:()=>[]},product:{type:String,default:""},file:{type:String,default:"xlsx"}},emits:["update:modelValue"],setup(p,{emit:z}){const o=p,x=u(!1),m=u(!1),_=u(0),g=u(""),v=async a=>{const e=await O(a);if(e){const t=new Blob([e],{type:a}),s=URL.createObjectURL(t);M(s,"物联卡导入模板",a)}},h=a=>{const e=(o==null?void 0:o.file)==="csv"?"csv":"xlsx",t=a.type==="text/csv",s=a.type==="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet";return!t&&e!=="xlsx"&&C("请上传.csv格式文件","warning"),!s&&e!=="csv"&&C("请上传.xlsx格式文件","warning"),t&&e!=="xlsx"||s&&e!=="csv"},w=async a=>{if(x.value=!0,a.file.status==="done"){const e=a.file.response||{result:""};m.value=!0,I(o.product,{fileUrl:e.result}).then(t=>{var s;_.value=((s=t.result)==null?void 0:s.total)||0,V.success("导入成功")}).catch(t=>{var s,r;g.value=((r=(s=t==null?void 0:t.response)==null?void 0:s.data)==null?void 0:r.message)||"导入失败"}).finally(()=>{m.value=!1})}};return(a,e)=>{const t=$("AIcon"),s=F,r=A,y=j,L=N;return d(),k(J,null,[l(y,{align:"end"},{default:c(()=>[l(r,{fileList:p.modelValue.upload,"onUpdate:fileList":e[0]||(e[0]=f=>p.modelValue.upload=f),name:"file",action:n(S),headers:{"X-Access-Token":n(T).get(n(E))},maxCount:1,showUploadList:!1,onChange:w,accept:o!=null&&o.file?`.${o==null?void 0:o.file}`:".xlsx","before-upload":h},{default:c(()=>[l(s,null,{icon:c(()=>[l(t,{type:"UploadOutlined"})]),default:c(()=>[U(" 文件上传 ")]),_:1})]),_:1},8,["fileList","action","headers","accept"]),i("div",R,[l(y,null,{default:c(()=>[U(" 下载模板 "),i("a",{onClick:e[1]||(e[1]=f=>v("xlsx"))},".xlsx"),i("a",{onClick:e[2]||(e[2]=f=>v("csv"))},".csv")]),_:1})])]),_:1}),n(x)?(d(),k("div",X,[n(m)?(d(),b(L,{key:0,status:"processing",text:"进行中"})):(d(),b(L,{key:1,status:"success",text:"已完成"})),i("span",null,"总数量："+B(n(_)),1),i("p",q,B(n(g)),1)])):D("",!0)],64)}}});export{ae as _};
