树形结构

This commit is contained in:
18571350067 2022-03-18 18:01:25 +08:00
parent 99fe4e2ed3
commit 3e3ba58448
2 changed files with 33 additions and 4 deletions

View File

@ -16,7 +16,7 @@
<!-- 课程类别 --> <!-- 课程类别 -->
<a-col :span="9" :offset="3"> <a-col :span="9" :offset="3">
<a-form-model-item label="课程类别" :label-col="{ span: 8 }" :wrapper-col="{ span: 12 }"> <a-form-model-item label="课程类别" :label-col="{ span: 8 }" :wrapper-col="{ span: 12 }">
<a-tree-select v-model="form.courseType" :tree-data="dictCourseType" placeholder="请选择课程类别"></a-tree-select> <a-tree-select v-model="form.courseType" :replaceFields="replaceFields" :tree-data="dictCourseType" placeholder="请选择课程类别"></a-tree-select>
<!-- <a-select v-model="form.courseType" placeholder="--请选择--"> <!-- <a-select v-model="form.courseType" placeholder="--请选择--">
<a-select-option v-for="(item, index) in dictCourseType" :key="index" :value="item.value"> <a-select-option v-for="(item, index) in dictCourseType" :key="index" :value="item.value">
@ -104,6 +104,7 @@
<script> <script>
import { coursewareClassList } from '@/api/course/courseware'
import { courseAdd, getCourseDetails } from '@/api/course/course' import { courseAdd, getCourseDetails } from '@/api/course/course'
import storage from 'store' import storage from 'store'
import { ACCESS_TOKEN } from '@/store/mutation-types' import { ACCESS_TOKEN } from '@/store/mutation-types'
@ -115,6 +116,7 @@ export default {
name: 'step1', name: 'step1',
data() { data() {
return { return {
replaceFields:{children:'children', title:'name', key:'id', value: 'value' },
pageName: this.$route.query.id ? '课程编辑' : '课程新增', pageName: this.$route.query.id ? '课程编辑' : '课程新增',
dataValue: 1, dataValue: 1,
form: { form: {
@ -132,6 +134,7 @@ export default {
dictCourseType: [], // dictCourseType: [], //
industry: [], industry: [],
dictCourseTag: [], dictCourseTag: [],
treeDataOne:[]
} }
}, },
components: { components: {
@ -140,6 +143,7 @@ export default {
getCourseDetails, getCourseDetails,
}, },
created() { created() {
this.getCourseTreeData(0) //
this.dictionaryDropDown() this.dictionaryDropDown()
if(this.$route.query.id) this.loadData(); if(this.$route.query.id) this.loadData();
}, },
@ -147,6 +151,7 @@ export default {
methods: { methods: {
// //
loadData() { loadData() {
this.getCourseTreeData(0)
if (this.$route.query.id) { if (this.$route.query.id) {
getCourseDetails({ id: this.$route.query.id }).then((res) => { getCourseDetails({ id: this.$route.query.id }).then((res) => {
this.form = res.data this.form = res.data
@ -179,10 +184,10 @@ export default {
this.industry = res.data this.industry = res.data
}) })
// //
dictionaryDropDown({ dictionaryCode: '0006' }).then((res) => { // dictionaryDropDown({ dictionaryCode: '0006' }).then((res) => {
// //
this.dictCourseType = dictToTree(res.data, [], 0) // this.dictCourseType = dictToTree(res.data, [], 0)
}) // })
// //
dictionaryDropDown({ dictionaryCode: '0005' }).then((res) => { dictionaryDropDown({ dictionaryCode: '0005' }).then((res) => {
this.dictPerson = res.data this.dictPerson = res.data
@ -209,6 +214,29 @@ export default {
}) })
}, },
//
getCourseTreeData(type) {
coursewareClassList({ type: type }).then((res) => {
//list🌲
const list2tree1 = (list, parentId) => {
return list.filter((item) => {
//
if (!this.treeDataOne) this.treeDataOne.push(item.value)
if (item.parentId === parentId) {
item.children = list2tree1(list, item.id)
return true
}
return false
})
}
this.dictCourseType = list2tree1(res.data, 0)
console.log("dict",this.dictCourseType);
})
},
// //
handleTagChange(value) { handleTagChange(value) {
this.form.tags = value this.form.tags = value

View File

@ -76,6 +76,7 @@
</a-button>&nbsp;&nbsp;&nbsp; </a-button>&nbsp;&nbsp;&nbsp;
</a-upload> </a-upload>
</div> </div>
<a-progress :percent="schedule" v-if="schedule > 0" />
</a-card> </a-card>
</div> </div>
</a-tab-pane> </a-tab-pane>