select-tag.12a89705.js 2.6 KB

1
  1. import{d as C,i as e,A as c,s as T,e as B,U as b,a3 as S,a8 as j,T as x,B as v}from"./index.6b776f4b.js";import{b as E}from"./index.46520b6f.js";import{T as h}from"./index.beb9a25a.js";import{C as y}from"./index.7b4b6592.js";import"./index.bebc33d1.js";import{c as f}from"./index.926ca9c5.js";import{C as A}from"./index.6b2308b1.js";const N="_select_ku3kj_1",V="_title_ku3kj_17",F="_tit_ku3kj_17",q="_childContent_ku3kj_31",w="_item_ku3kj_36",U="_radio_ku3kj_46",z="_btn_ku3kj_73";var t={select:N,title:V,tit:F,childContent:q,item:w,"radio-group":"_radio-group_ku3kj_46",radio:U,btn:z},D=C({name:"SelectTagChild",props:{child:{type:Array,default:()=>[]},onSelect:{type:Function,default:()=>{}},rowSingle:{type:Boolean,default:!1},needAllButton:{type:Boolean,default:!0}},setup({child:m,onSelect:n,needAllButton:d,rowSingle:i},{attrs:p}){return()=>{const u=p.selected;return e(A,{class:f(t.childContent,t["radio-group"]),modelValue:u,"onUpdate:modelValue":a=>{n(a)}},{default:()=>[d&&e(y,{name:0,class:t.radio,onClick:()=>n([])},{default:()=>[e(h,{class:f(t.item,"van-ellipsis"),type:"primary",plain:u.length!==0,round:!0,size:"large"},{default:()=>[c("\u5168\u90E8")]})]}),m.map(a=>e(y,{key:a.id,name:a.id,class:t.radio,onClick:()=>{i&&n([a.id])}},{default:()=>[e(h,{class:f(t.item,"van-ellipsis"),plain:!u.includes(a.id),type:"primary",round:!0,size:"large"},{default:()=>[a.name]})]}))]})}}}),J=C({name:"SelectTag",props:{defaultValue:{type:String,default:""},rowSingle:{type:Boolean,default:!1},exquisiteFlag:{type:Boolean,default:!1},needAllButton:{type:Boolean,default:!0}},emits:["cancel","confirm"],setup({exquisiteFlag:m,defaultValue:n,...d},{emit:i,expose:p}){const u=T.platformType==="STUDENT"?"/api-student":"/api-teacher",{isLoading:a,state:l}=E(B(u+"/MusicTag/tree"),null),_=()=>{s.value=[],i("cancel")};(n||"").split(",").map(o=>Number(o));const s=b([]),g={};return S(l,()=>{if(l.value){const o=l.value&&l.value.data||[];for(const r of o)g[r.id]=r.name}}),p({resetTags:_}),()=>{const o=l.value&&l.value.data||[];return e("div",{class:t.select},[e("h4",{class:t.title},[c("\u5168\u90E8\u6807\u7B7E")]),e("div",{class:t.content},[o.length>0&&e("div",{class:t.list},[e(D,j({selected:s.value||[],child:o||[],onSelect:r=>{if(s.value.length>=3){x("\u6700\u591A\u53EA\u80FD\u90093\u4E2A\u6807\u7B7E");return}setTimeout(()=>{r.forEach(k=>{s.value.includes(k)||s.value.push(k)})},100)}},d),null)])]),e("footer",{class:"van-safe-area-bottom van-hairline--top"},[e(v,{class:t.btn,round:!0,onClick:_},{default:()=>[c("\u91CD\u7F6E")]}),e(v,{class:t.btn,type:"primary",round:!0,onClick:()=>i("confirm",s.value,g)},{default:()=>[c("\u786E\u8BA4")]})])])}}});export{J as S};