import{d as p,T as j,j as e,B as u,F as h,aU as a,O as o,C as m,E as x}from"./ResizeObserver.es.62ab429c.js";import{C as r}from"./index.2745b15c.js";import"./index.9a52dc9a.js";import{I as l}from"./index.021584f9.js";import{R as g,a as b}from"./index.4e7a82cc.js";import{S as k}from"./index.b0c6821a.js";import{c as n,a as d}from"./checkbox_default.69f49af8.js";import{C as f}from"./index.5d843ffa.js";const _="_subjects_1djd7_1",B="_subjectContainer_1djd7_6",v="_subjectMaxLength_1djd7_9",y="_title_1djd7_19",C="_topBg_1djd7_53",S="_checkbox_1djd7_61",L="_name_1djd7_66",R="_subjectBtnGroup_1djd7_89";var t={subjects:_,subjectContainer:B,subjectMaxLength:v,title:y,"subject-list":"_subject-list_1djd7_37","subject-item":"_subject-item_1djd7_43",topBg:C,checkbox:S,name:L,subjectBtnGroup:R},M=p({name:"SubjectList",props:{onChoice:{type:Function,default:s=>{}},choiceSubjectIds:{type:Array,default:[]},subjectList:{type:Array,default:[]},max:{type:Number,default:5},selectType:{type:String,default:"Checkbox"},single:{type:Boolean,default:!1}},data(){return{checkBox:[],checkboxRefs:[],radio:null}},async mounted(){this.selectType==="Radio"?this.radio=this.choiceSubjectIds[0]:this.checkBox=this.choiceSubjectIds},watch:{choiceSubjectIds(s,c){this.checkBox=[...s]}},methods:{onSelect(s){this.selectType==="Checkbox"?(this.max===this.checkBox.length&&!this.checkBox.includes(s)&&j(`\u4E50\u5668\u6700\u591A\u9009\u62E9${this.max}\u4E2A`),this.checkboxRefs[s].toggle()):this.selectType==="Radio"&&(this.radio=s)}},render(){return e("div",{class:t.subjects},[e("div",{class:t.subjectContainer},[this.subjectList.length?this.selectType==="Checkbox"?e(f,{modelValue:this.checkBox,"onUpdate:modelValue":s=>this.checkBox=s,max:this.max},{default:()=>[e("div",{class:t.subjectMaxLength},[u("\u6700\u591A\u53EF\u9009\u62E9"),this.max,u("\u4E2A\u4E50\u5668")]),!this.single&&this.subjectList.map(s=>s.subjects&&s.subjects.length>0?e(h,null,[e("div",{class:t.title},[s.name]),e("div",{class:t["subject-list"]},[s.subjects&&s.subjects.map(c=>e("div",{class:t["subject-item"],onClick:()=>this.onSelect(c.id)},[e(l,{src:c.img||"xxx",width:"100%",height:"100%",fit:"cover"},{loading:()=>e(a,{type:"spinner",size:20},null)}),e("div",{class:t.topBg},[e(r,{name:c.id,class:t.checkbox,disabled:!0,ref:i=>this.checkboxRefs[c.id]=i},{icon:i=>e(o,{name:i.checked?n:d,size:"20"},null)}),e("p",{class:t.name},[c.name])])]))])]):null),this.single?e("div",{class:t["subject-list"]},[this.subjectList.map(s=>e("div",{class:t["subject-item"],onClick:()=>this.onSelect(s.id)},[e(l,{src:s.img||"xxx",width:"100%",height:"100%",fit:"cover"},{loading:()=>e(a,{type:"spinner",size:20},null)}),e("div",{class:t.topBg},[e(r,{name:s.id,class:t.checkbox,disabled:!0,ref:c=>this.checkboxRefs[s.id]=c},{icon:c=>e(o,{name:c.checked?n:d,size:"20"},null)}),e("p",{class:t.name},[s.name])])]))]):null]}):e(g,{modelValue:this.radio,"onUpdate:modelValue":s=>this.radio=s},{default:()=>[!this.single&&this.subjectList.map(s=>s.subjects&&s.subjects.length>0?e(h,null,[e("div",{class:t.title},[s.name]),e("div",{class:t["subject-list"]},[s.subjects&&s.subjects.map(c=>e("div",{class:t["subject-item"],onClick:()=>this.onSelect(c.id)},[e(l,{src:c.img||"xxx",width:"100%",height:"100%",fit:"cover"},{loading:()=>e(a,{type:"spinner",size:20},null)}),e("div",{class:t.topBg},[e(b,{name:c.id,class:t.checkbox},{icon:i=>e(o,{name:i.checked?n:d,size:"20"},null)}),e("p",{class:t.name},[c.name])])]))])]):null),this.single?e("div",{class:t["subject-list"]},[this.subjectList.map(s=>e("div",{class:t["subject-item"],onClick:()=>this.onSelect(s.id)},[e(l,{src:s.img||"xxx",width:"100%",height:"100%",fit:"cover"},{loading:()=>e(a,{type:"spinner",size:20},null)}),e("div",{class:t.topBg},[e(b,{name:s.id,class:t.checkbox},{icon:c=>e(o,{name:c.checked?n:d,size:"20"},null)}),e("p",{class:t.name},[s.name])])]))]):null]}):e(m,{tips:"\u6682\u65E0\u58F0\u90E8\u6570\u636E",btnStatus:!1},null)]),this.subjectList.length>0&&e(k,{offsetBottom:0,position:"bottom"},{default:()=>[e("div",{class:["btnGroup",t.subjectBtnGroup]},[e(x,{round:!0,block:!0,type:"primary",style:{width:"96%",margin:"0 auto"},onClick:()=>this.onChoice(this.selectType==="Checkbox"?this.checkBox:this.radio)},{default:()=>[u("\u786E\u8BA4")]})])]})])}});export{M as S};
