2025-03-20 10:46:42 +08:00

2 lines
2.0 KiB
JavaScript

import{V as F,k as p,w as h}from"./element-plus.2acb577d.js";import{a as k,h as c,d as b}from"./index.81df6f20.js";import{d as y,Z as f,r as w,o as C,K as A,L as i,a as S,U as z,R as B,u as n}from"./@vue.821a47ec.js";const U=y({__name:"index",props:{formData:{type:Object,require:!0},value:{type:String,default:"annex"}},setup(d){const m=f("doc, docx, xls, xlsx, ppt, pptx, pdf, txt, zip, rar, tar, jpg, png, gif, jpeg, webp, wmv, avi, mpg, mpeg, 3gp, mov, mp4, flv, f4v, rmvb, mkv"),_=k(),v=w(c.baseUrl+c.urlPrefix),l=f([]),a=d;a.formData[a.value]&&a.formData[a.value].forEach(e=>{l.push({name:e.name,uri:e.uri})});const x=e=>{if(e.size>1024e6)return p.error("\u6587\u4EF6\u5927\u5C0F\u4E0D\u80FD\u8D85\u8FC71\u4E2AG"),!1},D=e=>{var t,r;(t=a.formData)[r=a.value]||(t[r]=[]),e.code!=0?a.formData[a.value].push({uri:e.data.uri,name:e.data.name}):p.error(e.msg)},g=e=>{var r,u;const t=document.createElement("a");if(e.uri)t.href=e.uri;else{if(!e.response)return;t.href=(u=(r=e.response)==null?void 0:r.data)==null?void 0:u.uri}t.target="_blank",t.click()},E=e=>{var t,r;if(e.uri){let u=e.uri,o=a.formData[a.value].findIndex(s=>s.uri==u);a.formData[a.value].splice(o,1)}else{if(!e.response)return;let u=(r=(t=e.response)==null?void 0:t.data)==null?void 0:r.uri,o=a.formData[a.value].findIndex(s=>s.uri==u);a.formData[a.value].splice(o,1)}};return(e,t)=>{var o;const r=h,u=F;return C(),A(u,{accept:n(m),"show-file-list":!0,"aria-hidden":"true",headers:{Token:(o=n(_))==null?void 0:o.token},action:v.value+"/upload/file","on-success":D,ref:"upload",limit:100,multiple:"","on-preview":g,"on-remove":E,"before-upload":x,"file-list":n(l)},{tip:i(()=>t[0]||(t[0]=[S("span",{class:"text-primary",style:{"margin-left":"5px","font-size":"11px"}},"\u63D0\u793A:\u6587\u4EF6\u5355\u4E2A\u5927\u5C0F\u4E0D\u80FD\u8D85\u8FC71\u4E2AG",-1)])),default:i(()=>[z(r,{type:"primary"},{default:i(()=>t[1]||(t[1]=[B(" \u4E0A\u4F20 ")])),_:1})]),_:1},8,["accept","headers","action","file-list"])}}});const L=b(U,[["__scopeId","data-v-561d3459"]]);export{L as _};