全栈小学生 eff269ab88 up
2025-09-20 09:12:11 +08:00

2 lines
5.2 KiB
JavaScript

import{d as R,X as B,l as h,al as M,r as Z,as as H,am as _,h as a,c as r,a as i,n as X,aH as v,u as s,e as o,z as w,aO as q,m as E,w as T,t as D,k as F,F as y,T as A,B as L,C as G,aP as J,an as N,_ as K}from"./index-9f163f98.js";/* empty css */import{_ as Q}from"./index.vue_vue_type_style_index_0_lang-eb3f7737.js";import{_ as U}from"./index.vue_vue_type_script_setup_true_lang-b29ac1a4.js";/* empty css */import{S as W}from"./sortable.esm-be94e56d.js";/* empty css *//* empty css *//* empty css */import"./attachment-d1610ab5.js";/* empty css */import"./index.vue_vue_type_script_setup_true_lang-761ba1b4.js";/* empty css */import"./el-form-item-4ed993c7.js";/* empty css *//* empty css *//* empty css *//* empty css *//* empty css *//* empty css *//* empty css *//* empty css */import"./el-tooltip-4ed993c7.js";/* empty css *//* empty css *//* empty css *//* empty css */import"./index.vue_vue_type_script_setup_true_lang-e32ef5b5.js";/* empty css */import"./sys-135535fa.js";const Y={class:"flex flex-wrap"},ee={key:0,class:"w-full h-full relative"},te={class:"w-full h-full flex items-center justify-center"},ie={class:"absolute z-[1] flex items-center justify-center w-full h-full inset-0 bg-black bg-opacity-60 operation"},le={class:"w-full h-full flex items-center justify-center flex-col content-wrap"},ae={class:"leading-none text-xs mt-[10px] text-secondary"},oe={class:"w-full h-full relative"},ne={class:"w-full h-full flex items-center justify-center"},se={class:"absolute z-[1] flex items-center justify-center w-full h-full inset-0 bg-black bg-opacity-60 operation"},re={class:"w-full h-full flex items-center justify-center flex-col content-wrap"},me={class:"leading-none text-xs mt-[10px] text-secondary"},ce=R({__name:"index",props:{type:{type:String,default:"image"},imageFit:{type:String,default:"contain"},modelValue:{type:String,default:""},width:{type:String,default:"100px"},height:{type:String,default:"100px"},imageText:{type:String},limit:{type:Number,default:1}},emits:["update:modelValue","change"],setup(l,{emit:k}){const m=l,c=B({get(){return m.modelValue},set(e){k("update:modelValue",e)}}),t=h({data:[]});let b=h([]);const f=()=>{c.value=N(t.data).toString(),b=N(t.data).map(e=>e.indexOf("data:image")!=-1?e:w(e))};M(()=>c.value,()=>{c.value.indexOf("data:image")!=-1?t.data=[c.value]:t.data=[...c.value.split(",").filter(e=>e)],f()},{immediate:!0});const x=B(()=>({width:m.width,height:m.height})),C=e=>{m.limit==1?(t.data.splice(0,1),e&&t.data.push(e.url)):(e.forEach(n=>{t.data.length<m.limit&&t.data.push(n.url)}),_(()=>{V()})),f(),_(()=>{k("change",c.value)})},z=(e=0)=>{t.data.splice(e,1),f()},u=h({show:!1,index:0}),S=(e=0)=>{u.show=!0,u.index=e},I=Z(null);H(()=>{_(()=>{V()})});const V=()=>{m.limit!=1&&W.create(I.value,{group:"image-wrap",animation:300,onEnd:e=>{const n=t.data[e.oldIndex];t.data.splice(e.oldIndex,1),t.data.splice(e.newIndex,0,n),f()}})};return(e,n)=>{const j=G,d=U,$=Q,O=J;return a(),r(y,null,[i("div",Y,[l.limit==1?(a(),r("div",{key:0,class:X(["rounded cursor-pointer overflow-hidden relative border border-solid border-color image-wrap mr-[10px]",{"rounded-full":l.type=="avatar"}]),style:v(s(x))},[t.data.length?(a(),r("div",ee,[i("div",te,[o(j,{class:"w-full h-full",src:t.data[0].indexOf("data:image")!=-1?t.data[0]:s(w)(t.data[0]),fit:l.imageFit},null,8,["src","fit"])]),i("div",ie,[o(d,{name:"element ZoomIn",color:"#fff",size:"18px",class:"mr-[10px]",onClick:n[0]||(n[0]=p=>S())}),o(d,{name:"element Delete",color:"#fff",size:"18px",onClick:q(z,["stop"])},null,8,["onClick"])])])):(a(),E($,{key:1,limit:l.limit,onConfirm:C},{default:T(()=>[i("div",le,[o(d,{name:"element Plus",size:"20px",color:"var(--el-text-color-secondary)"}),i("div",ae,D(l.imageText||s(F)("upload.root")),1)])]),_:1},8,["limit"]))],6)):(a(),r(y,{key:1},[i("div",{class:"flex flex-wrap",ref_key:"imgListRef",ref:I},[(a(!0),r(y,null,A(t.data,(p,g)=>(a(),r("div",{class:"rounded cursor-pointer overflow-hidden relative border border-solid border-color image-wrap mr-[10px] mb-[10px]",style:v(s(x)),key:p+g},[i("div",oe,[i("div",ne,[o(j,{src:s(w)(p),fit:"contain"},null,8,["src"])]),i("div",se,[o(d,{name:"element ZoomIn",color:"#fff",size:"18px",class:"mr-[10px]",onClick:P=>S(g)},null,8,["onClick"]),o(d,{name:"element Delete",color:"#fff",size:"18px",onClick:P=>z(g)},null,8,["onClick"])])])],4))),128))],512),t.data.length<l.limit?(a(),r("div",{key:0,class:"rounded cursor-pointer overflow-hidden relative border border-dashed border-color",style:v(s(x))},[o($,{limit:l.limit,onConfirm:C},{default:T(()=>[i("div",re,[o(d,{name:"element Plus",size:"20px",color:"var(--el-text-color-secondary)"}),i("div",me,D(l.imageText||s(F)("upload.root")),1)])]),_:1},8,["limit"])],4)):L("",!0)],64))]),u.show?(a(),E(O,{key:0,"url-list":s(b),onClose:n[1]||(n[1]=p=>u.show=!1),"initial-index":u.index,"zoom-rate":1},null,8,["url-list","initial-index"])):L("",!0)],64)}}});const Me=K(ce,[["__scopeId","data-v-8e30190f"]]);export{Me as default};