|  | @@ -75,7 +75,7 @@
 | 
	
		
			
				|  |  |          </el-form-item>
 | 
	
		
			
				|  |  |          <el-form-item label="可用教材" prop="teachingMaterialId"
 | 
	
		
			
				|  |  |            :rules="[{ required: true, message: '请选择可用教材', trigger: 'change' }]">
 | 
	
		
			
				|  |  | -          <el-select
 | 
	
		
			
				|  |  | +          <!-- <el-select
 | 
	
		
			
				|  |  |              v-model.trim="form.teachingMaterialId"
 | 
	
		
			
				|  |  |              :disabled="isDisabled"
 | 
	
		
			
				|  |  |              v-show="!isDisabled"
 | 
	
	
		
			
				|  | @@ -89,7 +89,19 @@
 | 
	
		
			
				|  |  |            >
 | 
	
		
			
				|  |  |              <el-option v-for="(item, index) in teachList" :key="index"
 | 
	
		
			
				|  |  |                :label="item.name" :value="item.id"></el-option>
 | 
	
		
			
				|  |  | -          </el-select>
 | 
	
		
			
				|  |  | +          </el-select> -->
 | 
	
		
			
				|  |  | +          <el-cascader
 | 
	
		
			
				|  |  | +            v-model.trim="form.teachingMaterialId"
 | 
	
		
			
				|  |  | +            :disabled="isDisabled"
 | 
	
		
			
				|  |  | +            v-show="!isDisabled"
 | 
	
		
			
				|  |  | +            style="width: 300px !important"
 | 
	
		
			
				|  |  | +            :options="teachList"
 | 
	
		
			
				|  |  | +            :props="{ multiple: true }"
 | 
	
		
			
				|  |  | +            :show-all-levels="false"
 | 
	
		
			
				|  |  | +            collapse-tags
 | 
	
		
			
				|  |  | +            ref="cascader"
 | 
	
		
			
				|  |  | +            @change="onChange"
 | 
	
		
			
				|  |  | +            clearable></el-cascader>
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |            <el-tag
 | 
	
		
			
				|  |  |              :key="tag.id"
 | 
	
	
		
			
				|  | @@ -121,7 +133,9 @@
 | 
	
		
			
				|  |  |  //         }
 | 
	
		
			
				|  |  |  //     }
 | 
	
		
			
				|  |  |  // }
 | 
	
		
			
				|  |  | -import { getSysMusicScoreList } from '@/views/teachManager/api'
 | 
	
		
			
				|  |  | +// import { getSysMusicScoreList } from '@/views/teachManager/api'
 | 
	
		
			
				|  |  | +import { queryTree } from '../../accompaniment/api'
 | 
	
		
			
				|  |  | +import _ from 'lodash'
 | 
	
		
			
				|  |  |  export default {
 | 
	
		
			
				|  |  |    props: ['type', 'data'],
 | 
	
		
			
				|  |  |    data () {
 | 
	
	
		
			
				|  | @@ -143,9 +157,17 @@ export default {
 | 
	
		
			
				|  |  |      if(this.data) {
 | 
	
		
			
				|  |  |        const { config, teachingMaterialId } = this.data
 | 
	
		
			
				|  |  |        const tmpConfig = config ? JSON.parse(config) : {}
 | 
	
		
			
				|  |  | +      console.log(teachingMaterialId)
 | 
	
		
			
				|  |  | +      let tempIdArr = []
 | 
	
		
			
				|  |  | +      if(teachingMaterialId) {
 | 
	
		
			
				|  |  | +        const tempIds = teachingMaterialId.split(',').map(i => Number(i))
 | 
	
		
			
				|  |  | +        tempIds.forEach(id => {
 | 
	
		
			
				|  |  | +          tempIdArr.push(this.formatParentId(id, this.teachList))
 | 
	
		
			
				|  |  | +        })
 | 
	
		
			
				|  |  | +      }
 | 
	
		
			
				|  |  |        this.form = {
 | 
	
		
			
				|  |  |          ...tmpConfig.member_config,
 | 
	
		
			
				|  |  | -        teachingMaterialId: teachingMaterialId.split(',').map(i => Number(i))
 | 
	
		
			
				|  |  | +        teachingMaterialId: tempIdArr
 | 
	
		
			
				|  |  |        }
 | 
	
		
			
				|  |  |        this.onChange()
 | 
	
		
			
				|  |  |      }
 | 
	
	
		
			
				|  | @@ -158,23 +180,53 @@ export default {
 | 
	
		
			
				|  |  |    methods: {
 | 
	
		
			
				|  |  |      async __init() {
 | 
	
		
			
				|  |  |        try {
 | 
	
		
			
				|  |  | -        const res = await getSysMusicScoreList({ page: 1, rows: 999, enable: 1 })
 | 
	
		
			
				|  |  | -        this.teachList = res.data?.rows || []
 | 
	
		
			
				|  |  | -      } catch(e) {}
 | 
	
		
			
				|  |  | +        const res = await queryTree({ enable: 1 })
 | 
	
		
			
				|  |  | +        const rows = res.data || []
 | 
	
		
			
				|  |  | +        rows.forEach(item => {
 | 
	
		
			
				|  |  | +          let children = []
 | 
	
		
			
				|  |  | +          item.label = item.name
 | 
	
		
			
				|  |  | +          item.value = item.id
 | 
	
		
			
				|  |  | +          let childList = item.sysMusicScoreCategoriesList ? item.sysMusicScoreCategoriesList : []
 | 
	
		
			
				|  |  | +          if(childList.length > 0) {
 | 
	
		
			
				|  |  | +            childList.forEach(child => {
 | 
	
		
			
				|  |  | +              child.label = child.name
 | 
	
		
			
				|  |  | +              child.value = child.id
 | 
	
		
			
				|  |  | +              children.push(child)
 | 
	
		
			
				|  |  | +            })
 | 
	
		
			
				|  |  | +          }
 | 
	
		
			
				|  |  | +          item.children = children.length > 0 ? children : null
 | 
	
		
			
				|  |  | +          this.teachList.push(item)
 | 
	
		
			
				|  |  | +        })
 | 
	
		
			
				|  |  | +      } catch(e) { console.log(e) }
 | 
	
		
			
				|  |  |      },
 | 
	
		
			
				|  |  |      onChange() {
 | 
	
		
			
				|  |  | -      const val = this.form.teachingMaterialId
 | 
	
		
			
				|  |  | +      let childNodes = this.$refs.cascader.getCheckedNodes(true)
 | 
	
		
			
				|  |  |        this.dynamicTags = []
 | 
	
		
			
				|  |  | -      if(val && val.length > 0) {
 | 
	
		
			
				|  |  | -        this.teachList.forEach(item => {
 | 
	
		
			
				|  |  | -          if(val.includes(item.id)) {
 | 
	
		
			
				|  |  | -            this.dynamicTags.push({
 | 
	
		
			
				|  |  | -              name: item.name,
 | 
	
		
			
				|  |  | -              id: item.id
 | 
	
		
			
				|  |  | -            })
 | 
	
		
			
				|  |  | +      childNodes.forEach(node => {
 | 
	
		
			
				|  |  | +        this.dynamicTags.push({
 | 
	
		
			
				|  |  | +          name: node.label,
 | 
	
		
			
				|  |  | +          id: node.value
 | 
	
		
			
				|  |  | +        })
 | 
	
		
			
				|  |  | +      })
 | 
	
		
			
				|  |  | +      console.log(this.getValues())
 | 
	
		
			
				|  |  | +    },
 | 
	
		
			
				|  |  | +    formatParentId(id, list, ids = []) {
 | 
	
		
			
				|  |  | +      for (const item of list) {
 | 
	
		
			
				|  |  | +        if (item.sysMusicScoreCategoriesList) {
 | 
	
		
			
				|  |  | +          const cIds = this.formatParentId(
 | 
	
		
			
				|  |  | +            id,
 | 
	
		
			
				|  |  | +            item.sysMusicScoreCategoriesList,
 | 
	
		
			
				|  |  | +            [...ids, item.id]
 | 
	
		
			
				|  |  | +          );
 | 
	
		
			
				|  |  | +          if (cIds.includes(id)) {
 | 
	
		
			
				|  |  | +            return cIds;
 | 
	
		
			
				|  |  |            }
 | 
	
		
			
				|  |  | -        });
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +        if (item.id === id) {
 | 
	
		
			
				|  |  | +          return [...ids, id];
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  |        }
 | 
	
		
			
				|  |  | +      return ids;
 | 
	
		
			
				|  |  |      },
 | 
	
		
			
				|  |  |      handleClose(tag) {
 | 
	
		
			
				|  |  |  
 | 
	
	
		
			
				|  | @@ -188,9 +240,13 @@ export default {
 | 
	
		
			
				|  |  |      },
 | 
	
		
			
				|  |  |      getValues() {
 | 
	
		
			
				|  |  |        const { teachingMaterialId, ...res } = this.form
 | 
	
		
			
				|  |  | +      let tempArr = []
 | 
	
		
			
				|  |  | +      teachingMaterialId.forEach(ids => {
 | 
	
		
			
				|  |  | +        tempArr.push(_.last(ids))
 | 
	
		
			
				|  |  | +      })
 | 
	
		
			
				|  |  |        return {
 | 
	
		
			
				|  |  |          member_config: { ...res },
 | 
	
		
			
				|  |  | -        teachingMaterialId
 | 
	
		
			
				|  |  | +        teachingMaterialId: tempArr
 | 
	
		
			
				|  |  |        }
 | 
	
		
			
				|  |  |      },
 | 
	
		
			
				|  |  |    },
 |