execl-upload.2ed330c3.js 1.5 KB

1
  1. import{_ as F,d as U,E as p,o as _,N as C,K as N,a as i,c as R,u as S,b1 as b,b2 as A,aS as D}from"./index.1417328f.js";import{r as L,u as c}from"./xlsx.ed122d16.js";const K={key:0,class:"el-upload__text"},M=U({__name:"execl-upload",emits:["onSuccess"],setup(j,{expose:f,emit:m}){const x=p(null),n=p(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"}),E=r.SheetNames[0],d=r.Sheets[E],B=k(d),w=c.sheet_to_json(d,{defval:""});m("onSuccess",{header:B,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)=>(_(),C(S(b),{ref_key:"uploadRef",ref:x,action:"#",accept:".xls,.xlsx",drag:"","auto-upload":!1,onChange:v,onRemove:y,onBeforeUpload:u,multiple:""},{default:N(()=>[i(' class="execl-uploader" '),n.value?i("v-if",!0):(_(),R("div",K,"\u70B9\u51FB\u6B64\u5904,\u4E0A\u4F20\u6587\u4EF6"))]),_:1},512))}});var H=F(M,[["__scopeId","data-v-dec4647e"],["__file","/Users/apple/Desktop/Company Projects/accout-vue3-ui/src/components/execlUpload/src/execl-upload.vue"]]);export{H as e};