execl-upload.cc28de33.js 1.5 KB

1
  1. import{_ as C,d as F,w as _,o as p,G as U,C as R,a as i,c as b,u as N,bA as S,bB as A,aW as D}from"./index.0bc83371.js";import{r as L,u as c}from"./xlsx.ed122d16.js";const M={key:0,class:"el-upload__text"},j=F({__name:"execl-upload",emits:["onSuccess"],setup(K,{expose:f,emit:m}){const x=_(null),n=_(null),v=e=>{const o=e.raw;!o||g(o)},g=e=>{u(e)&&h(e)},h=async e=>{const o=A.service({lock:!0,text:"Loading",background:"rgba(0, 0, 0, 0.7)"});return new Promise(s=>{const a=new FileReader;a.onload=l=>{const t=l.target.result,r=L(t,{type:"array"}),B=r.SheetNames[0],d=r.Sheets[B],E=k(d),w=c.sheet_to_json(d,{defval:""});m("onSuccess",{header:E,results:w}),o.close(),s({isok:!0})},a.readAsArrayBuffer(e)})},k=e=>{const o=[],s=c.decode_range(e["!ref"]);let a;const l=s.s.r;for(a=s.s.c;a<=s.e.c;++a){const t=e[c.encode_cell({c:a,r:l})];let r="UNKNOWN "+a;t&&t.t&&(r=c.format_cell(t)),o.push(r)}return o},u=async e=>e.size/1024<500?!0:(D.warning("\u8BF7\u4E0D\u8981\u4E0A\u4F20\u5927\u4E8E500KB\u7684\u6587\u4EF6"),!1),y=()=>n.value=null;return f({onDisplay:()=>n.value=null}),(e,o)=>(p(),U(N(S),{ref_key:"uploadRef",ref:x,action:"#",accept:".xls,.xlsx",drag:"","auto-upload":!1,onChange:v,onRemove:y,onBeforeUpload:u,multiple:""},{default:R(()=>[i(' class="execl-uploader" '),n.value?i("v-if",!0):(p(),b("div",M,"\u70B9\u51FB\u6B64\u5904,\u4E0A\u4F20\u6587\u4EF6"))]),_:1},512))}});var G=C(j,[["__scopeId","data-v-dec4647e"],["__file","C:/Users/63107/Desktop/projects/accout-vue3-ui/src/components/execlUpload/src/execl-upload.vue"]]);export{G as e};