From 1151507eb6628d8442003fb3c0b27b34c49eace9 Mon Sep 17 00:00:00 2001 From: xiezhijun <15270898033@163.com> Date: Tue, 15 Jun 2021 18:48:45 +0800 Subject: [PATCH] =?UTF-8?q?=E8=A7=86=E9=A2=91=E5=88=86=E7=B1=BB=E6=9F=A5?= =?UTF-8?q?=E8=AF=A2=E8=A7=86=E9=A2=91=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../custom/SysNutritionalVideoMapper.xml | 6 +++- .../views/custom/nutritionalVideo/index.vue | 33 ++++++++++++++++--- .../src/views/custom/videoClassify/index.vue | 2 +- 3 files changed, 35 insertions(+), 6 deletions(-) diff --git a/stdiet-custom/src/main/resources/mapper/custom/SysNutritionalVideoMapper.xml b/stdiet-custom/src/main/resources/mapper/custom/SysNutritionalVideoMapper.xml index a468e8714..59d21ec58 100644 --- a/stdiet-custom/src/main/resources/mapper/custom/SysNutritionalVideoMapper.xml +++ b/stdiet-custom/src/main/resources/mapper/custom/SysNutritionalVideoMapper.xml @@ -42,7 +42,11 @@ and snv.show_flag = #{showFlag} </if> <if test="cateId != null"> - and snv.cate_id = #{cateId} + and snv.cate_id in ( + select id from sys_video_classify where del_flag = 0 + and (id = #{cateId} or id in (select s.id from sys_video_classify s where s.parent_id = #{cateId} and s.del_flag = 0) + or id in (select ss.id from sys_video_classify ss where ss.del_flag = 0 and ss.parent_id in (select a.id from sys_video_classify a where a.parent_id = #{cateId} and a.del_flag = 0 ))) + ) </if> <if test="payLevel != null"> and snv.pay_level = #{payLevel} diff --git a/stdiet-ui/src/views/custom/nutritionalVideo/index.vue b/stdiet-ui/src/views/custom/nutritionalVideo/index.vue index ff84e80bf..dea7f8b97 100644 --- a/stdiet-ui/src/views/custom/nutritionalVideo/index.vue +++ b/stdiet-ui/src/views/custom/nutritionalVideo/index.vue @@ -21,14 +21,22 @@ </el-select> </el-form-item> <el-form-item label="视频类别" prop="cateId"> - <el-select v-model="queryParams.cateId" clearable filterable placeholder="请选择类别"> + <!-- <el-select v-model="queryParams.cateId" clearable filterable placeholder="请选择类别"> <el-option v-for="classify in classifyList" :key="classify.id" :label="classify.cateName" :value="classify.id" /> - </el-select> + </el-select>--> + <treeselect + v-model="queryParams.cateId" + :options="classifyList" + :normalizer="normalizer" + :show-count="true" + placeholder="选择分类" + style="width:200px" + /> </el-form-item> <el-form-item label="视频权限" prop="payLevel"> <el-select v-model="queryParams.payLevel" clearable filterable placeholder="请选择权限"> @@ -257,6 +265,9 @@ import UploadFile from "@/components/FileUpload/UploadFile"; import VideoClassify from "../videoClassify"; import AutoHideMessage from "@/components/AutoHideMessage"; + import Treeselect from "@riophae/vue-treeselect"; + import "@riophae/vue-treeselect/dist/vue-treeselect.css"; + import IconSelect from "@/components/IconSelect"; export default { name: "NutritionalVideo", data() { @@ -320,7 +331,7 @@ }); }, components: { - UploadVideo,UploadFile,VideoClassify,AutoHideMessage + UploadVideo,UploadFile,VideoClassify,AutoHideMessage,Treeselect, IconSelect }, methods: { /** 查询营养视频列表 */ @@ -339,7 +350,10 @@ getAllVideoClassify(){ getAllClassify().then(response => { if(response.code == 200){ - this.classifyList = response.data; + this.classifyList = []; + const classify = { id: 0, cateName: '主分类', children: [] }; + classify.children = this.handleTree(response.data, "id"); + this.classifyList.push(classify); } }); }, @@ -413,6 +427,17 @@ } }); }, + /** 转换菜单数据结构 */ + normalizer(node) { + if (node.children && !node.children.length) { + delete node.children; + } + return { + id: node.id, + label: node.cateName, + children: node.children + }; + }, /** 提交按钮 */ submitForm() { this.$refs["form"].validate(valid => { diff --git a/stdiet-ui/src/views/custom/videoClassify/index.vue b/stdiet-ui/src/views/custom/videoClassify/index.vue index ff4e1e6de..1e45c5c1f 100644 --- a/stdiet-ui/src/views/custom/videoClassify/index.vue +++ b/stdiet-ui/src/views/custom/videoClassify/index.vue @@ -353,7 +353,7 @@ }); } }); - console.log(this.threeLevelClassify.length); + //console.log(this.threeLevelClassify.length); this.classifyOptions.push(classify); }); },