img-upload.23218332.js 1.4 KB

1
  1. import{_ as b,d as h,E as r,bh as F,aC as j,x as i,o as B,N as C,K as p,y as E,W as x,b as U,aS as c,bi as y,bj as I}from"./index.1417328f.js";const k=x("\u4E0A\u4F20\u56FE\u7247"),w=U("div",{class:"el-upload__tip"},"\u8BF7\u4E0A\u4F20jpg.png.bmp.jpeg\u7C7B\u578B\u56FE\u7247",-1),D=h({__name:"img-upload",emits:["change"],setup(N,{emit:l}){const d=["image/png","image/jpg","image/bmp","image/jpeg"],t=r([]),o=r([]),m=F(),_=j(),g=({type:a,size:e})=>{if(!d.includes(a))return c.error("\u8BF7\u4E0A\u4F20jpg.png.bmp.jpeg\u7C7B\u578B\u56FE\u7247"),!1;if(e/1024/1024>1)return c.error("\u56FE\u7247\u5927\u5C0F\u8D85\u8FC71M"),!1},f=async({file:a})=>{const e=new FormData;e.append("img",a),e.append("token",m.token);const{message:s,code:n,data:u}=await y(e);_({message:s,code:n,handler:()=>{o.value.push(I+"/"+u[0].url),l("change",o.value.join(","))}})},v=a=>{const e=t.value.findIndex(({uid:s})=>s===a.uid);return o.value.splice(e,1),l("change",o.value.join(",")),!0};return(a,e)=>{const s=i("el-button"),n=i("el-upload");return B(),C(n,{"file-list":t.value,"onUpdate:file-list":e[0]||(e[0]=u=>t.value=u),"before-upload":g,"http-request":f,"before-remove":v,multiple:""},{tip:p(()=>[w]),default:p(()=>[E(s,{type:"primary"},{default:p(()=>[k]),_:1})]),_:1},8,["file-list"])}}});var S=b(D,[["__file","/Users/apple/Desktop/Company Projects/accout-vue3-ui/src/views/InvoiceSales/refund/components/approval-process/img-upload.vue"]]);export{S as default};