|
@@ -1,10 +1,9 @@
|
|
|
-import { Button, Checkbox, Icon, Image } from "vant";
|
|
|
+import { Button, Checkbox, CheckboxGroup, Icon, Image, Loading } from "vant";
|
|
|
import { defineComponent } from "vue";
|
|
|
import styles from './subject-model.module.less';
|
|
|
|
|
|
import checkBoxActive from '../images/checkbox_active.png';
|
|
|
import checkBoxDefault from '../images/checkbox_default.png';
|
|
|
-import request from "@/helpers/request";
|
|
|
import ColResult from "@/components/col-result";
|
|
|
|
|
|
export default defineComponent({
|
|
@@ -13,48 +12,64 @@ export default defineComponent({
|
|
|
onChoice: {
|
|
|
type: Function,
|
|
|
default: (item: any) => { }
|
|
|
+ },
|
|
|
+ choiceSubjectIds: {
|
|
|
+ type: Array,
|
|
|
+ default: []
|
|
|
+ },
|
|
|
+ subjectList: {
|
|
|
+ type: Array,
|
|
|
+ default: []
|
|
|
+ },
|
|
|
+ max: {// 最多可选数量
|
|
|
+ type: Number,
|
|
|
+ default: 5
|
|
|
}
|
|
|
},
|
|
|
data() {
|
|
|
return {
|
|
|
- subjectList: [],
|
|
|
- checkBox: []
|
|
|
+ checkBox: [],
|
|
|
+ checkboxRefs: [] as any,
|
|
|
}
|
|
|
},
|
|
|
async mounted() {
|
|
|
- try {
|
|
|
- const res = await request.get('/api-teacher/subject/queryPage', {
|
|
|
- params: {
|
|
|
- rows: 100,
|
|
|
- page: 1
|
|
|
- }
|
|
|
- })
|
|
|
- console.log(res)
|
|
|
- } catch {
|
|
|
- //
|
|
|
+ this.checkBox = this.choiceSubjectIds as never[]
|
|
|
+ },
|
|
|
+ methods: {
|
|
|
+ onSelect(id: number) {
|
|
|
+ this.checkboxRefs[id].toggle();
|
|
|
}
|
|
|
},
|
|
|
render() {
|
|
|
return (
|
|
|
<div class={styles.subjects}>
|
|
|
- <div class={styles['subject-list']}>
|
|
|
- { this.subjectList.length ? [1, 2, 3, 4, 5].map((item: any) => (
|
|
|
- <div class={styles['subject-item']}>
|
|
|
- <Image src="https://daya.ks3-cn-beijing.ksyun.com/202110/Sn76BUQ.png" width="100%" height="100%" fit="cover" />
|
|
|
- <div class={styles.topBg}>
|
|
|
- <Checkbox v-model={this.checkBox} name={1} class={styles.checkbox} v-slots={{
|
|
|
- icon: (props: any) => (
|
|
|
- <Icon name={props.checked ? checkBoxActive : checkBoxDefault} size="22" />
|
|
|
- )
|
|
|
- }} />
|
|
|
- <p class={styles.name}>长笛</p>
|
|
|
- </div>
|
|
|
- </div>
|
|
|
- )) : <ColResult tips="暂无声部数据" btnStatus={false} /> }
|
|
|
- </div>
|
|
|
+ {this.subjectList.length ? <CheckboxGroup v-model={this.checkBox} max={this.max}>
|
|
|
+ {this.subjectList.map((item: any) => (
|
|
|
+ <>
|
|
|
+ <div class={styles.title}>{item.name}</div>
|
|
|
+ <div class={styles['subject-list']}>
|
|
|
+ {item.subjects && item.subjects.map((sub: any) => (
|
|
|
+ <div class={styles['subject-item']} onClick={() => this.onSelect(sub.id)}>
|
|
|
+ <Image src={sub.img} width="100%" height="100%" fit="cover" v-slots={{
|
|
|
+ loading: () => <Loading type="spinner" size={20} />
|
|
|
+ }} />
|
|
|
+ <div class={styles.topBg}>
|
|
|
+ <Checkbox name={sub.id} class={styles.checkbox} ref={(el: any) => this.checkboxRefs[sub.id] = el} v-slots={{
|
|
|
+ icon: (props: any) => (
|
|
|
+ <Icon name={props.checked ? checkBoxActive : checkBoxDefault} size="22" />
|
|
|
+ )
|
|
|
+ }} />
|
|
|
+ <p class={styles.name}>{sub.name}</p>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ ))}
|
|
|
+ </div>
|
|
|
+ </>
|
|
|
+ ))}
|
|
|
+ </CheckboxGroup> : <ColResult tips="暂无声部数据" btnStatus={false} />}
|
|
|
|
|
|
<div class={styles["btn-group"]}>
|
|
|
- <Button round block type="primary" onClick={() => this.onChoice(true)}>确定</Button>
|
|
|
+ <Button round block type="primary" onClick={() => this.onChoice(this.checkBox)}>确定</Button>
|
|
|
</div>
|
|
|
</div>
|
|
|
)
|