From 1a213b60555c36b9d828d24720b71fdf6fb6e569 Mon Sep 17 00:00:00 2001 From: 18571350067 Date: Fri, 26 Nov 2021 18:02:30 +0800 Subject: [PATCH 1/4] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E5=AD=97=E5=85=B8?= =?UTF-8?q?=E9=9B=86=E5=90=88=E8=BD=AC=E6=A0=91=E5=B0=81=E8=A3=85=20?= =?UTF-8?q?=E4=BF=AE=E6=94=B9=E7=B3=BB=E7=BB=9F=E8=AF=BE=E7=A8=8B=E6=96=B0?= =?UTF-8?q?=E5=A2=9E=E4=B8=AD=E7=9A=84=E8=AF=BE=E7=A8=8B=E7=B1=BB=E5=88=AB?= =?UTF-8?q?=E4=B8=BA=E6=A0=91=E5=BD=A2=E9=80=89=E6=8B=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/utils/util.js | 24 ++++++++++++ src/views/course/CourseAdd.vue | 69 +++++++++++++--------------------- 2 files changed, 51 insertions(+), 42 deletions(-) diff --git a/src/utils/util.js b/src/utils/util.js index 6ec26e0..eaf6311 100644 --- a/src/utils/util.js +++ b/src/utils/util.js @@ -86,6 +86,30 @@ export function listToTree(list, tree, parentId) { return tree } +// 词典集合转树 +export function dictToTree(list, tree, parentId) { + list.forEach(item => { + if (item.parentid === parentId) { + let item_ = {}; + item_.title = item.name; + item_.value = item.value; + item_.key = item.id; + const child = { ...item_, children: [] }; + + dictToTree(list, child.children, item.value); + + if (child.children.length <= 0) { + delete child.children + }else{ + child.selectable = false; + } + + tree.push(child) + } + }) + return tree +} + //列表转🌲 // export function list2Tree(list, parentId) { // let obj = [] diff --git a/src/views/course/CourseAdd.vue b/src/views/course/CourseAdd.vue index 0e65736..373aa25 100644 --- a/src/views/course/CourseAdd.vue +++ b/src/views/course/CourseAdd.vue @@ -9,35 +9,27 @@ - + - + + + - + {{ dataValue }}分钟 @@ -91,14 +83,7 @@ - +
上传
@@ -114,7 +99,7 @@ - + {{ item.name }} @@ -132,6 +117,7 @@ import { courseAdd, getCourseDetails } from '@/api/course/course' import storage from 'store' import { ACCESS_TOKEN } from '@/store/mutation-types' import { dictionaryDropDown } from '@/api/sys/dictionaryItem' +import { dictToTree } from '@/utils/util' export default { name: 'step1', @@ -140,17 +126,17 @@ export default { dataValue: 1, form: { coverPath: '', - tags:[], - courseTags:[] + tags: [], + courseTags: [], }, url: '', previewVisible: false, fileList: [], previewImage: [], dictPerson: [], - dictCourseType: [], + dictCourseType: [], // 课程类别 industry: [], - dictCourseTag:[], + dictCourseTag: [], } }, components: { @@ -161,21 +147,20 @@ export default { this.dictionaryDropDown() if (this.$route.query.id) { getCourseDetails({ id: this.$route.query.id }).then((res) => { - this.form = res.data; - this.form.isRequired = this.form.isRequired + ''; + this.form = res.data + this.form.isRequired = this.form.isRequired + '' - this.form.tags = []; - this.form.courseTags.forEach((item,index) => { - this.form.tags.push(item.dictValue.toString()); - }); + this.form.tags = [] + this.form.courseTags.forEach((item, index) => { + this.form.tags.push(item.dictValue.toString()) + }) }) } }, methods: { //显示页面上的数字 - onChange(dataValue) { - }, + onChange(dataValue) {}, save() { courseAdd(this.form).then((res) => { if (res.code == 200) { @@ -194,17 +179,18 @@ export default { }) // 课程类别 dictionaryDropDown({ dictionaryCode: '0006' }).then((res) => { - this.dictCourseType = res.data + // 词典转树结构 + this.dictCourseType = dictToTree(res.data, [], 0) }) // 人员类型 dictionaryDropDown({ dictionaryCode: '0005' }).then((res) => { this.dictPerson = res.data }) // 标签项 默认选中的多选框 - dictionaryDropDown({dictionaryCode: '0008'}).then((res) => { + dictionaryDropDown({ dictionaryCode: '0008' }).then((res) => { const tagList = res.data - for ( let i = 0; i < tagList.length; i++) { - tagList[i].value = tagList[i].value.toString() + for (let i = 0; i < tagList.length; i++) { + tagList[i].value = tagList[i].value.toString() } this.dictCourseTag = tagList }) @@ -225,8 +211,7 @@ export default { hreader[ACCESS_TOKEN] = storage.get(ACCESS_TOKEN) return hreader }, - onSuccess(file) { - }, + onSuccess(file) {}, handleCancel() { this.previewVisible = false }, @@ -246,7 +231,7 @@ export default { //标签选择器 handleTagChange(value) { - this.form.tags = value; + this.form.tags = value }, }, } From 4af0bfb0661ee115c3e4a3a2f5f5cf68b916f9b1 Mon Sep 17 00:00:00 2001 From: 18571350067 Date: Fri, 26 Nov 2021 18:18:01 +0800 Subject: [PATCH 2/4] =?UTF-8?q?=E6=90=9C=E7=B4=A2=E5=8C=BA=E5=B0=81?= =?UTF-8?q?=E8=A3=85=20select=20select-dictionary=20select-dictionary-tree?= =?UTF-8?q?=20=E6=94=AF=E6=8C=81=E5=8D=95=E9=80=89=E5=A4=9A=E9=80=89?= =?UTF-8?q?=E9=85=8D=E7=BD=AE=20=E8=AF=BE=E7=A8=8B=E5=88=97=E8=A1=A8?= =?UTF-8?q?=E7=95=8C=E9=9D=A2=E6=96=B0=E5=A2=9E=E8=AF=BE=E7=A8=8B=E7=B1=BB?= =?UTF-8?q?=E5=88=AB=E6=90=9C=E7=B4=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/SearchCom/index.vue | 7 +++++-- src/views/course/CourseList.vue | 15 +++++++++------ 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/src/components/SearchCom/index.vue b/src/components/SearchCom/index.vue index 39d5e84..e168b82 100644 --- a/src/components/SearchCom/index.vue +++ b/src/components/SearchCom/index.vue @@ -7,15 +7,18 @@ - + {{ j.name }} - + {{ j.name }} + + + diff --git a/src/views/course/CourseList.vue b/src/views/course/CourseList.vue index fdd5323..ce41fdb 100644 --- a/src/views/course/CourseList.vue +++ b/src/views/course/CourseList.vue @@ -32,6 +32,7 @@ import { STable, SearchCom } from '@/components' import { getCourseList, deleteCourse } from '@/api/course/course' import { dictionaryDropDown } from '@/api/sys/dictionaryItem' +import { dictToTree } from '@/utils/util' export default { components: { @@ -44,7 +45,8 @@ export default { queryParam: { courseName: this.$route.query.courseName || '' }, queryOptions: [ { type: 'input', placeholder: '课程名称', key: 'courseName' }, - { type: 'select', placeholder: '请选择标签', key: 'tag', options: [] }, + { type: 'select-dic-tree', placeholder: '请选择课程类别', key: 'courseType' , options: [] }, + { type: 'select-dic', placeholder: '请选择标签', key: 'tag', mode: 'multiple', options: [] }, ], loadData: (parameter) => { return getCourseList(Object.assign(parameter, this.queryParam)).then((res) => { @@ -68,13 +70,14 @@ export default { dictionaryDropDown() { this.formLoading = false + //课程类别 + dictionaryDropDown({ dictionaryCode: '0006' }).then((res) => { + this.queryOptions[1].options = dictToTree(res.data, [], 0); + }) + //课程标签字典 dictionaryDropDown({ dictionaryCode: '0008' }).then((res) => { - const tagList = res.data - for (let i = 0; i < tagList.length; i++) { - tagList[i].id = tagList[i].value.toString() - } - this.queryOptions[1].options = tagList + this.queryOptions[2].options = res.data }) }, handleRefresh() { From 75c74adca224ad09070ba9b6fa7097f96030fdec Mon Sep 17 00:00:00 2001 From: 18571350067 Date: Fri, 26 Nov 2021 18:22:12 +0800 Subject: [PATCH 3/4] =?UTF-8?q?=E6=90=9C=E7=B4=A2=E5=8C=BA=E7=BB=84?= =?UTF-8?q?=E4=BB=B6=20select-dictionary-tree=20=E6=94=AF=E6=8C=81?= =?UTF-8?q?=E6=B8=85=E9=99=A4=E6=8C=89=E9=92=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/SearchCom/index.vue | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/SearchCom/index.vue b/src/components/SearchCom/index.vue index e168b82..23ae735 100644 --- a/src/components/SearchCom/index.vue +++ b/src/components/SearchCom/index.vue @@ -17,7 +17,7 @@ - + From 8cc943a78485c52ffe99ced4043e689346ce1623 Mon Sep 17 00:00:00 2001 From: 18571350067 Date: Fri, 26 Nov 2021 19:06:08 +0800 Subject: [PATCH 4/4] =?UTF-8?q?=E9=87=8D=E7=BD=AE=E6=96=B9=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/api/course/course.js | 1 + src/views/course/CourseList.vue | 5 ++++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/api/course/course.js b/src/api/course/course.js index 9433ed2..5665890 100644 --- a/src/api/course/course.js +++ b/src/api/course/course.js @@ -44,6 +44,7 @@ export function deleteCourse (params) { // 查询课程列表 export function getCourseList (params) { + if(params.tag) params.tag = params.tag.toString(); return request({ url: courseApi.list, method: 'get', diff --git a/src/views/course/CourseList.vue b/src/views/course/CourseList.vue index ce41fdb..a2fddfb 100644 --- a/src/views/course/CourseList.vue +++ b/src/views/course/CourseList.vue @@ -42,7 +42,7 @@ export default { data() { return { dictCourseTag: [], - queryParam: { courseName: this.$route.query.courseName || '' }, + queryParam: { courseName: this.$route.query.courseName || '', tag: [] }, queryOptions: [ { type: 'input', placeholder: '课程名称', key: 'courseName' }, { type: 'select-dic-tree', placeholder: '请选择课程类别', key: 'courseType' , options: [] }, @@ -56,6 +56,7 @@ export default { columns: [ { title: '课程编号', width: '160px', align: 'center', dataIndex: 'courseCode', key: 'courseCode' }, { title: '课程名称', width: 'auto', align: 'center', dataIndex: 'courseName', key: 'courseName' }, + { title: '课程类别', width: 'auto', align: 'center', dataIndex: 'courseType', key: 'courseType' }, { title: '课时/分', width: '160px', align: 'center', dataIndex: 'hour', key: 'hour' }, { title: '数量', width: '160px', align: 'center', dataIndex: 'questionCount', key: 'questionCount' }, { title: '操作', key: 'operation', width: '300px', align: 'center', scopedSlots: { customRender: 'action' } }, @@ -78,6 +79,8 @@ export default { //课程标签字典 dictionaryDropDown({ dictionaryCode: '0008' }).then((res) => { this.queryOptions[2].options = res.data + + }) }, handleRefresh() {