index.cb7569ce.js 4.1 KB

1
  1. import{d as b,T as m,i as e,A as u,F as d,aS as a,N as o,C as x,B as f}from"./index.7994470a.js";import{C as r}from"./index.29eb1675.js";import"./index.c9af17c2.js";import{I as l}from"./index.2fbdc579.js";import{R as j,a as p}from"./index.9dc8689d.js";import{S as g}from"./index.6449f9de.js";import{c as n,a as h}from"./checkbox_default.8d9b037b.js";import{C as k}from"./index.2e766b01.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},M=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{M as S};