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