import{d as b,T as m,j as e,z as u,F as d,aS as a,M as o,C as x,B as f}from"./index.394decd7.js";import{C as r}from"./index.24fb4ee4.js";import"./index.b91a923c.js";import{I as l}from"./index.ae2dd816.js";import{R as j,a as p}from"./index.4ef31a7f.js";import{S as g}from"./index.3bbf4ddb.js";import{c as n,a as h}from"./checkbox_default.944f238b.js";import{C as k}from"./index.e164926c.js";const _="_subjects_1t5fp_1",v="_subjectContainer_1t5fp_6",y="_subjectMaxLength_1t5fp_9",B="_title_1t5fp_19",C="_topBg_1t5fp_53",S="_checkbox_1t5fp_61",L="_name_1t5fp_66";var s={subjects:_,subjectContainer:v,subjectMaxLength:y,title:B,"subject-list":"_subject-list_1t5fp_37","subject-item":"_subject-item_1t5fp_43",topBg:C,checkbox:S,name:L},E=b({name:"SubjectList",props:{onChoice:{type:Function,default:t=>{}},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(t,c){this.checkBox=[...t]}},methods:{onSelect(t){this.selectType==="Checkbox"?(this.max===this.checkBox.length&&!this.checkBox.includes(t)&&m(`\u4E50\u5668\u6700\u591A\u9009\u62E9${this.max}\u4E2A`),this.checkboxRefs[t].toggle()):this.selectType==="Radio"&&(this.radio=t)}},render(){return e("div",{class:s.subjects},[e("div",{class:s.subjectContainer},[this.subjectList.length?this.selectType==="Checkbox"?e(k,{modelValue:this.checkBox,"onUpdate:modelValue":t=>this.checkBox=t,max:this.max},{default:()=>[e("div",{class:s.subjectMaxLength},[u("\u6700\u591A\u53EF\u9009\u62E9"),this.max,u("\u4E2A\u4E50\u5668")]),!this.single&&this.subjectList.map(t=>t.subjects&&t.subjects.length>0?e(d,null,[e("div",{class:s.title},[t.name]),e("div",{class:s["subject-list"]},[t.subjects&&t.subjects.map(c=>e("div",{class:s["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:s.topBg},[e(r,{name:c.id,class:s.checkbox,disabled:!0,ref:i=>this.checkboxRefs[c.id]=i},{icon:i=>e(o,{name:i.checked?n:h,size:"20"},null)}),e("p",{class:s.name},[c.name])])]))])]):null),this.single?e("div",{class:s["subject-list"]},[this.subjectList.map(t=>e("div",{class:s["subject-item"],onClick:()=>this.onSelect(t.id)},[e(l,{src:t.img||"xxx",width:"100%",height:"100%",fit:"cover"},{loading:()=>e(a,{type:"spinner",size:20},null)}),e("div",{class:s.topBg},[e(r,{name:t.id,class:s.checkbox,disabled:!0,ref:c=>this.checkboxRefs[t.id]=c},{icon:c=>e(o,{name:c.checked?n:h,size:"20"},null)}),e("p",{class:s.name},[t.name])])]))]):null]}):e(j,{modelValue:this.radio,"onUpdate:modelValue":t=>this.radio=t},{default:()=>[!this.single&&this.subjectList.map(t=>t.subjects&&t.subjects.length>0?e(d,null,[e("div",{class:s.title},[t.name]),e("div",{class:s["subject-list"]},[t.subjects&&t.subjects.map(c=>e("div",{class:s["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:s.topBg},[e(p,{name:c.id,class:s.checkbox},{icon:i=>e(o,{name:i.checked?n:h,size:"20"},null)}),e("p",{class:s.name},[c.name])])]))])]):null),this.single?e("div",{class:s["subject-list"]},[this.subjectList.map(t=>e("div",{class:s["subject-item"],onClick:()=>this.onSelect(t.id)},[e(l,{src:t.img||"xxx",width:"100%",height:"100%",fit:"cover"},{loading:()=>e(a,{type:"spinner",size:20},null)}),e("div",{class:s.topBg},[e(p,{name:t.id,class:s.checkbox},{icon:c=>e(o,{name:c.checked?n:h,size:"20"},null)}),e("p",{class:s.name},[t.name])])]))]):null]}):e(x,{tips:"\u6682\u65E0\u58F0\u90E8\u6570\u636E",btnStatus:!1},null)]),this.subjectList.length>0&&e(g,{offsetBottom:0,position:"bottom"},{default:()=>[e("div",{class:"btnGroup"},[e(f,{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\u5B9A")]})])]})])}});export{E as S};