mirror of
https://github.com/crmeb/CRMEB.git
synced 2026-11-09 11:21:13 +00:00
2 lines
1.5 KiB
JavaScript
2 lines
1.5 KiB
JavaScript
import{f as m,y as n,z as l,j as f,C as _,a2 as g,a0 as I,A as y,W as b,l as x}from"./element-plus-C_ZDq0cz.js";import{d as h}from"./vuedraggable.umd-fTw9SVdO.js";import{_ as k}from"./index-DHL7RTL2.js";const L={class:"list"},w=["src"],C=["onClick"],D=Object.assign({name:"userLabel"},{__name:"useLabel",props:{activeId:{type:Array,default:()=>{}},listData:{type:Array,default:()=>{}}},emits:["activeData","update:activeId"],setup(r,{emit:u}){const d=u,s=r,i=x([]);m(()=>s.activeId,(t,o)=>{t!=o&&t.length&&(i.value=[],t.forEach(e=>{s.listData.forEach(a=>{e==a.id&&i.value.push(a)})}))},{deep:!0,immediate:!0});async function p(t){const{newIndex:o,oldIndex:e}=t,a=s.activeId[e],c=[...s.activeId];c.splice(e,1),c.splice(o,0,a),d("update:activeId",c)}function v(t){let o=i.value.indexOf(t);i.value.splice(o,1);let e=s.activeId.findIndex(c=>c==t.id);s.activeId.splice(e,1),d("activeData",JSON.parse(JSON.stringify(i.value)));const a=[...s.activeId];d("update:activeId",a)}return(t,o)=>(n(),l("div",L,[f(b(h),{class:"flex",group:"label",disabled:i.value.length<2,list:i.value,"item-key":"id",handle:".label",onEnd:p,animation:"300"},{item:_(({element:e,index:a})=>[(n(),l("div",{class:"label",key:a},[e.image?(n(),l("img",{key:1,src:e.image,class:"img-tag"},null,8,w)):(n(),l("div",{key:0,class:"label-item",style:g({backgroundColor:e.bg_color,color:e.font_color,border:e.border_color?"1px solid "+e.border_color:"none"})},I(e.name),5)),y("i",{class:"el-icon-error",onClick:c=>v(e)},null,8,C)]))]),_:1},8,["disabled","list"])]))}}),O=k(D,[["__scopeId","data-v-026e0e3b"]]);export{O as u};
|