|
@@ -0,0 +1,118 @@
|
|
|
+import { defineComponent } from 'vue'
|
|
|
+import styles from './select-subject.module.less'
|
|
|
+import { Tag, Button, Sticky } from 'vant'
|
|
|
+import { state } from '@/state'
|
|
|
+import request from '@/helpers/request'
|
|
|
+
|
|
|
+export default defineComponent({
|
|
|
+ name: 'selectSubject',
|
|
|
+ props: {
|
|
|
+ isReset: {
|
|
|
+ type: Boolean,
|
|
|
+ default: false
|
|
|
+ },
|
|
|
+ onComfirm: {
|
|
|
+ type: Function,
|
|
|
+ default: (item: any) => {}
|
|
|
+ }
|
|
|
+ },
|
|
|
+ data() {
|
|
|
+ return {
|
|
|
+ subject: {
|
|
|
+ name: '',
|
|
|
+ id: ''
|
|
|
+ },
|
|
|
+ subjectList: [] as any,
|
|
|
+ apiSuffix:
|
|
|
+ state.platformType === 'STUDENT' ? '/api-student' : '/api-teacher'
|
|
|
+ }
|
|
|
+ },
|
|
|
+ mounted() {
|
|
|
+ this.getList()
|
|
|
+ },
|
|
|
+ methods: {
|
|
|
+ async getList() {
|
|
|
+ const { data } = await request.get(
|
|
|
+ `${this.apiSuffix}/subject/subjectSelect?type=MUSIC`
|
|
|
+ )
|
|
|
+ if (Array.isArray(data)) {
|
|
|
+ this.subjectList = data
|
|
|
+ }
|
|
|
+ }
|
|
|
+ },
|
|
|
+ render() {
|
|
|
+ return (
|
|
|
+ <>
|
|
|
+ <div class={styles.filterTitle}>全部声部</div>
|
|
|
+ <div
|
|
|
+ class={styles.searchResult}
|
|
|
+ style={{ maxHeight: '45vh', overflowY: 'auto' }}
|
|
|
+ >
|
|
|
+ {this.subjectList.map(
|
|
|
+ (item: any) =>
|
|
|
+ item.subjects &&
|
|
|
+ item.subjects.length > 0 && (
|
|
|
+ <>
|
|
|
+ <div class={styles.searchTitle}>{item.name}</div>
|
|
|
+ <div
|
|
|
+ class={[
|
|
|
+ styles['radio-group'],
|
|
|
+ styles.radio,
|
|
|
+ styles['organ-radio']
|
|
|
+ ]}
|
|
|
+ >
|
|
|
+ {item.subjects.map((subject: any) => {
|
|
|
+ const isActive = subject.id === Number(this.subject.id)
|
|
|
+ const type = isActive ? 'primary' : 'default'
|
|
|
+ return (
|
|
|
+ <Tag
|
|
|
+ size="large"
|
|
|
+ plain={isActive}
|
|
|
+ type={type}
|
|
|
+ round
|
|
|
+ onClick={() => {
|
|
|
+ this.subject = subject
|
|
|
+ }}
|
|
|
+ >
|
|
|
+ {subject.name}
|
|
|
+ </Tag>
|
|
|
+ )
|
|
|
+ })}
|
|
|
+ </div>
|
|
|
+ </>
|
|
|
+ )
|
|
|
+ )}
|
|
|
+ </div>
|
|
|
+ <Sticky position="bottom" offsetBottom={0}>
|
|
|
+ <div class={['btnGroup', this.isReset ? 'btnMore' : '']}>
|
|
|
+ {this.isReset && (
|
|
|
+ <Button
|
|
|
+ type="primary"
|
|
|
+ plain
|
|
|
+ round
|
|
|
+ onClick={() => {
|
|
|
+ this.subject.name = '全部'
|
|
|
+ this.subject.id = ''
|
|
|
+ this.onComfirm({...this.subject})
|
|
|
+ }}
|
|
|
+ >
|
|
|
+ 重 置
|
|
|
+ </Button>
|
|
|
+ )}
|
|
|
+
|
|
|
+ <Button
|
|
|
+ type="primary"
|
|
|
+ round
|
|
|
+ block
|
|
|
+ onClick={() => {
|
|
|
+ this.onComfirm({ ...this.subject })
|
|
|
+ }}
|
|
|
+ >
|
|
|
+ 确 认
|
|
|
+ </Button>
|
|
|
+ </div>
|
|
|
+ </Sticky>
|
|
|
+ </>
|
|
|
+ )
|
|
|
+ }
|
|
|
+})
|