lsc 7 місяців тому
батько
коміт
7a2c397e89

+ 11 - 3
src/components/pages/aiAddCourse/addCourse.vue

@@ -2827,8 +2827,8 @@
                       <div @click="allEvaCan(), addCourseBehavior('courseBehavior', `点击学历案-一键生成所有评价按钮`)"
                         v-if="panTool() > 0">{{panTaskElist() == 0 && panEvaCont() == 0 ? '一键生成所有评价' : '重新生成所有评价'}}
                       </div>
-                      <div @click="exportTaskEA(), addCourseBehavior('courseBehavior', `点击学历案-导出评价和学历案按钮`)">导出评价和学历案
-                      </div>
+                      <!-- <div @click="exportTaskEA(), addCourseBehavior('courseBehavior', `点击学历案-导出评价和学历案按钮`)">导出评价和学历案
+                      </div> -->
                     </div>
                   </button>
                   <!-- <button class="c_pub_button_confirm3" style="margin: 0 0 0 10px;" @click="openAiDialog2(2, 'aiTask3','all', ''), addCourseBehavior('courseBehavior', `点击学历案-重新生成所有任务按钮`)">重新生成所有任务</button> -->
@@ -10121,7 +10121,15 @@ ${_this.unitJson[0].chapterInfo[0].taskJson[index].taskDetail3.replaceAll('#',''
             console.log(data.message);
             let _task = _this.unitJson[0].chapterInfo[0].taskJson[index]
             let name = _task.task+'-学历案'
-            let _html =  md.render(data.message)
+            let _html =  md.render(data.message).replace(/[\r\n]+/g, '').replace(/<hr>/g, '').replace(/<ol[^>]*>/g, '').replace(/<\/ol>/g, '').replace(/<li[^>]*>(.*?)<\/li>/g, (match, content) => {
+              // 去除内容为空的<li>标签
+              if (!content.trim()) {
+                return '';  // 如果<li>标签内容为空,删除该标签
+              }
+              // 去掉<li>中的标签,保留纯文本内容
+              return `<li>${content.replace(/<[^>]+>/g, '')}</li>`;
+            }); // 去掉 <ol> 和 </ol> 标签
+            console.log(_html)
             await _this.generate(name, _html, index, ()=>{
               _this.taskAnLoading[index] = false
               _this.taskAnCancelToken[index] = null

+ 3 - 3
src/components/pages/aiEasy/addCourse.vue

@@ -589,10 +589,10 @@
                         <button class="c_pub_button_add pub_btn_add_img" @click="openSource(0)">
                           资源
                         </button>
-                        <!-- <button class="c_pub_button_add pub_btn_add_img" @click="openAiCreate(0)">
+                        <button class="c_pub_button_add pub_btn_add_img" @click="openAiCreate(0)">
                           AI生成PPT
                         </button>
-                        <button class="c_pub_button_add pub_btn_add_img" @click="createTeacherAn(0)">
+                        <!-- <button class="c_pub_button_add pub_btn_add_img" @click="createTeacherAn(0)">
                           AI生成教案
                         </button>
                         <button class="c_pub_button_add pub_btn_add_img" @click="openAiCreateVideo(0)">
@@ -29862,7 +29862,7 @@ ol {
 }
 
 .chapter_upload_check {
-  width: 15px;
+  min-width: 15px;
   height: 15px;
   cursor: pointer;
   background-image: url('../../../assets/icon/check.png');

+ 35 - 21
src/components/pages/aiEasy/aiCreateDialog.vue

@@ -41,7 +41,8 @@
             </span>
         </el-dialog>
         <div v-if="tanDialog" @click="dialogVisibleAiCreate2 = true" class="tanDialog">
-            <span>任务{{ lineCount + 1 }}的生成ppt </span><button class="c_pub_button_confirm">打开</button>
+            <!-- 任务{{ lineCount + 1 }}的 -->
+            <span>生成ppt </span><button class="c_pub_button_confirm">打开</button>
         </div>
     </div>
 </template>
@@ -50,6 +51,7 @@
 import Pptxgen from "pptxgenjs";
 import wOffice from "../components/wOffice.vue";
 import { v4 as uuidv4 } from "uuid";
+import { file } from 'jszip';
 var OpenCC = require("opencc-js");
 
 let converter2 = OpenCC.Converter({
@@ -927,16 +929,16 @@ export default {
                 return;
             }
             let _this = this;
-
+            let infoData = this.unitJson[0].chapterInfo[0].taskJson[this.lineCount].chapterData
             let fileid = [];
-            if (_this.infoData.length) {
-                for (var i = 0; i < _this.infoData.length; i++) {
-                    if (_this.infoData[i].fileid) {
-                        fileid.push(_this.infoData[i].fileid);
+            if (infoData.length) {
+                for (var i = 0; i < infoData.length; i++) {
+                    if (infoData[i].fileid) {
+                        fileid.push(infoData[i].fileid);
                     } else {
-                        let _fileid = await _this.createFileid(_this.infoData[i].url);
+                        let _fileid = await _this.createFileid(infoData[i].url);
                         if (_fileid) {
-                            _this.infoData[i].fileid = _fileid;
+                            infoData[i].fileid = _fileid;
                             _this.$forceUpdate();
                             fileid.push(_fileid);
                         }
@@ -944,6 +946,11 @@ export default {
                 }
             }
             console.log("fileid=========", fileid);
+            if(!fileid.length){
+                this.closeAiPpt();
+                this.$message.error("请上传教案后再生成ppt");
+                return;
+            }
 
             let mclass = [];
             if (_this.courseTypeId.length) {
@@ -1052,15 +1059,16 @@ ${_this.outline.replaceAll('#', '').replaceAll('*', '').replaceAll('-', '').repl
             }
             let _this = this;
 
+            let infoData = this.unitJson[0].chapterInfo[0].taskJson[this.lineCount].chapterData
             let fileid = [];
-            if (_this.infoData.length) {
-                for (var i = 0; i < _this.infoData.length; i++) {
-                    if (_this.infoData[i].fileid) {
-                        fileid.push(_this.infoData[i].fileid);
+            if (infoData.length) {
+                for (var i = 0; i < infoData.length; i++) {
+                    if (infoData[i].fileid) {
+                        fileid.push(infoData[i].fileid);
                     } else {
-                        let _fileid = await _this.createFileid(_this.infoData[i].url);
+                        let _fileid = await _this.createFileid(infoData[i].url);
                         if (_fileid) {
-                            _this.infoData[i].fileid = _fileid;
+                            infoData[i].fileid = _fileid;
                             _this.$forceUpdate();
                             fileid.push(_fileid);
                         }
@@ -1068,6 +1076,11 @@ ${_this.outline.replaceAll('#', '').replaceAll('*', '').replaceAll('-', '').repl
                 }
             }
             console.log("fileid=========", fileid);
+            if(!fileid.length){
+                this.closeAiPpt();
+                this.$message.error("请上传教案后再生成ppt");
+                return;
+            }
 
             let mclass = [];
             if (_this.courseTypeId.length) {
@@ -1091,7 +1104,8 @@ ${_this.outline.replaceAll('#', '').replaceAll('*', '').replaceAll('-', '').repl
             }
             let message = "";
             if (this.courseState == 4) {
-                message = `NOTICE Language: ${this.getLang()}
+                message = `
+                NOTICE Language: ${this.getLang()}
 
 # 任务
 请根据参考资料,生成关于${this.courseName},为教师生成这节课的教学ppt的大纲,大纲的主要内容课程知识点的讲解与相关练习和测试。你的输出应该符合#输出格式
@@ -1106,14 +1120,14 @@ ${mclass.length ? "#参考资料\n面向年级:" + mclass.join(",") : ""}
 # 限制
 - 你不能输出错误的知识,如果你实在不清楚,输出“对不起,我不确定”
 - 你不能输出违反伦理的内容`;
-            } else if (this.courseState == 5) {
-                message = `NOTICE Language: ${this.getLang()}
+            } else if (this.courseState == 6) {
+                message = `Role: 你是ppt内容设计大师,能力是从用户提供的文件资料中提取最重要的学科概念作为生成ppt的大纲,最后根据任务要求的流程要求输出ppt的大纲。
+NOTICE Language: ${this.getLang()}
 
 # 任务
-请根据<任务教案>,为教师生成本的教学ppt的大纲,大纲包含各环节的步骤,学科知识点。
+请根据上传的文件教案,为教师生成本的教学ppt的大纲,大纲包含各环节的步骤,学科知识点。
 
 # 参考资料
-任务教案:${_this.unitJson[0].chapterInfo[0].taskJson[_this.lineCount].taskDetail3.replaceAll('#', '').replaceAll('*', '').replaceAll('-', '').replaceAll('\n', '')}
 ${mclass.length ? "面向年级:" + mclass.join(",") : ""}
 
 # 输出格式
@@ -1243,8 +1257,8 @@ ${mclass.length ? "面向年级:" + mclass.join(",") : ""}
             const _slideTou = pres.addSlide();
             _slideTou.background = { path: this.templateList[this.templateIndex].img1.img }
             let title = ''
-            if (this.courseState == 4) {
-                title = this.courseName
+            if (this.courseState == 6) {
+                title = this.courseName ? this.courseName : 'ai生成ppt'
             } else if (this.courseState == 5) {
                 title = this.unitJson[0].chapterInfo[0].taskJson[this.lineCount].task
             }

+ 35 - 69
src/components/pages/knowledge/fileBox.vue

@@ -2,55 +2,33 @@
     <div class="f_box">
         <div class="f_box_top">
             <div class="f_box_top_left">
-                <div class="btn" @click="addImg($event)" v-if="type == '1'">
-                    上传本地文件
-                    <input type="file" accept="*" style="display: none" multiple="multiple"
-                        @change="beforeUpload($event)" />
+                <div class="f_box_top_title">
+                    所有文件
                 </div>
-                <div class="btn" @click="addFileToTest()" :style="{opacity: checkArray.length ? 1 : .5}" v-if="type == '2'">
-                    添加至表单
+            </div>
+            <div class="f_box_top_right">
+                <div class="btn">
+                    上传文件
+                </div>
+                <div class="btn delBtn">
+                    删除
                 </div>
-                <div class="btn2" v-if="checkArray.length && type == '1'" @click="openMoveBox">移动到</div>
-                <div class="btn2" v-if="checkArray.length && type == '1'" @click="downPan">下载</div>
-                <div class="delBtn" v-if="checkArray.length && type == '1'" @click="deleteFile"></div>
+            </div>
+        </div>
+        <div class="f_box_top">
+            <div class="f_box_top_left">
+                
             </div>
             <div class="f_box_top_right">
                 <div class="input">
                     <input type="text" v-model="fileName" placeholder="请输入你需要搜索的文件名字" @keyup.enter="serchFile">
                     <div class="serch" @click="serchFile"></div>
                 </div>
-                <div class="tab">
-                    <div class="list" :class="{ active: stype == '2' }" @click="stype = '2'"></div>
-                    <div class="table" :class="{ active: stype == '1' }" @click="stype = '1'"></div>
-                </div>
             </div>
         </div>
         <div class="none_box" v-if="fileArray.length == 0">
             暂无上传文件
         </div>
-        <div class="f_box_file_square" v-if="stype == '1' && fileArray.length" v-loading.body="isLoading">
-            <div class="f_box_file_allCheck" @click="checkAll" v-if="fileArray.length">
-                <img :src="checkImg" alt="" v-if="checkArray.length != fileArray.length">
-                <img :src="checkIsImg" alt="" v-else>
-                <span>全部文件</span>
-            </div>
-            <div class="f_box_file" v-for="(item, index) in fileArray" :key="index"
-                :class="{ check: checkArray.indexOf(item.id) != -1 }" @click.stop="selectFile(item)">
-                <img :src="officeImg" alt="" v-if="item.type == 1">
-                <img :src="pdfImg" alt="" v-if="item.type == 4">
-                <img :src="videoImg" alt="" v-if="item.type == 2">
-                <img :src="otherImg" alt="" v-if="item.type == 5">
-                <img :src="item.file" alt="" v-if="item.type == 3">
-                <el-tooltip :content="item.name" placement="top" effect="dark">
-                    <!-- content to trigger tooltip here -->
-                    <div class="name">{{ item.name }}</div>
-                </el-tooltip>
-                <div class="check" @click.stop="checkFile(item.id)">
-                    <img :src="checkImg" alt="" v-if="checkArray.indexOf(item.id) == -1">
-                    <img :src="checkIsImg" alt="" v-else>
-                </div>
-            </div>
-        </div>
         <div class="f_box_file_list" v-else-if="stype == '2' && fileArray.length" v-loading.body="isLoading">
             <div class="list_file_box">
                 <div class="list_top">
@@ -102,19 +80,6 @@
                 <div class="lbox">
                     <img src="../../../assets/loading.gif" />上传中,请稍后
                 </div>
-                <!-- <div style="margin-bottom: 10px">
-                                <span>{{
-                                    isFinishSize
-                                }}M</span>
-                                /
-                                <span>{{
-                                    isAllSize
-                                }}M</span>
-                            </div> -->
-                <!-- <el-progress :text-inside="true" :stroke-width="20" :percentage="progress
-                                ? progress
-                                : 0
-                                " style="width: 80%"></el-progress> -->
             </div>
         </div>
         <wpdf :dialogVisiblePdf.sync="dialogVisiblePdf" :url="wurl"></wpdf>
@@ -242,7 +207,7 @@ export default {
         return {
             isLoading: false,
             proVisible: false,
-            stype: 1,
+            stype: 2,
             fileArray: [],
             officeImg: officeImg,
             pdfImg: pdfImg,
@@ -280,7 +245,7 @@ export default {
     },
     methods: {
         getData() {
-            let type = this.pid.split('-')
+            let type = this.pid.split('/')
             let id = ''
             if (type.length == 1) {
                 if (type[0] == 'wu') {
@@ -301,7 +266,7 @@ export default {
                 .get(this.$store.state.api + "getSourceFile", params)
                 .then((res) => {
                     this.isLoading = false;
-                    this.fileArray = res.data[0];
+                    // this.fileArray = res.data[0];
                 })
                 .catch((err) => {
                     this.isLoading = false;
@@ -523,7 +488,7 @@ export default {
         },
         addSource(file, ctype) {
             let _ctype = ctype
-            let type = this.pid.split('-')
+            let type = this.pid.split('/')
             let id = ''
             if (type.length == 1) {
                 if (type[0] == 'wu') {
@@ -672,7 +637,7 @@ export default {
                 this.$message.error("请添加分类再移动");
                 return
             }
-            let type = this.pid.split('-')
+            let type = this.pid.split('/')
             let id = ''
             if (type.length == 1) {
                 if (type[0] == 'wu') {
@@ -816,7 +781,7 @@ export default {
 <style scoped>
 .f_box {
     width: 100%;
-    height: 100%;
+    /* height: 100%; */
     position: relative;
 }
 
@@ -833,7 +798,12 @@ export default {
     align-items: center;
 }
 
-.f_box_top_left .btn {
+.f_box_top_title{
+    font-size: 16px;
+    /* font-weight: bold; */
+}
+
+.f_box_top .btn {
     display: flex;
     cursor: pointer;
     align-items: center;
@@ -847,7 +817,7 @@ export default {
     align-items: center;
 }
 
-.f_box_top_left .btn2 {
+.f_box_top .btn2 {
     display: flex;
     cursor: pointer;
     align-items: center;
@@ -862,18 +832,14 @@ export default {
     align-items: center;
 }
 
-.f_box_top_left .delBtn {
-    cursor: pointer;
-    width: 24px;
-    height: 24px;
-    display: block;
-    background-image: url('../../../assets/icon/sourceFile/delete.png');
-    background-size: 100% 100%;
+.f_box_top .delBtn {
+    background: rgb(255, 0, 13);
 }
 
-.f_box_top_left .btn+.btn2,
-.f_box_top_left .btn2+.btn2,
-.f_box_top_left .btn2+.delBtn {
+.f_box_top .btn+.btn2,
+.f_box_top .btn+.btn,
+.f_box_top .btn2+.btn2,
+.f_box_top .btn2+.delBtn {
     margin-left: 15px;
 }
 
@@ -1096,8 +1062,8 @@ export default {
 }
 
 .f_box_file_list {
-    height: calc(100% - 55px);
-    overflow: auto;
+    /* height: calc(100% - 55px); */
+    /* overflow: auto; */
     width: 100%;
     padding: 10px;
     box-sizing: border-box;

+ 779 - 0
src/components/pages/knowledge/folder.vue

@@ -0,0 +1,779 @@
+<template>
+    <div class="f_box">
+        <div class="f_box_top">
+            <div class="f_box_top_left">
+                <div class="f_box_top_title">
+                    所有文件夹
+                </div>
+            </div>
+            <div class="f_box_top_right">
+                <div class="btn" @click="openAdd">
+                    新建文件夹
+                </div>
+                <div class="btn delBtn" @click="deleteFolder">
+                    删除
+                </div>
+            </div>
+        </div>
+        <div class="f_box_top">
+            <div class="f_box_top_left">
+                
+            </div>
+            <div class="f_box_top_right">
+                <div class="input">
+                    <input type="text" v-model="fileName" placeholder="请输入你需要搜索的文件夹名字" @keyup.enter="serchFile">
+                    <div class="serch" @click="serchFile"></div>
+                </div>
+            </div>
+        </div>
+        <div class="none_box" v-if="fileArray.length == 0">
+            暂无文件夹
+        </div>
+        <div class="f_box_file_list" v-else-if="stype == '2' && fileArray.length" v-loading.body="isLoading">
+            <div class="list_file_box">
+                <el-table :data="fileArray" border stripe style="width: 100%" @selection-change="handleSelectionChange" :row-key="row => row.id">
+                    <el-table-column type="selection" width="50px"></el-table-column>
+                    <el-table-column prop="name" label="文件夹名字" show-overflow-tooltip min-width="15"></el-table-column>
+                    <el-table-column prop="detail" label="描述" show-overflow-tooltip min-width="20"></el-table-column>
+                    <el-table-column prop="fileCount" label="文件数" width="80px"></el-table-column>
+                    <el-table-column prop="username" label="拥有者" show-overflow-tooltip min-width="10"></el-table-column>
+                    <el-table-column label="标签" show-overflow-tooltip min-width="10">
+                        <template slot-scope="scope">
+                            {{ getTag(scope.row)}}
+                        </template>
+                    </el-table-column>
+                    <el-table-column label="公开权限" width="80px">
+                        <template slot-scope="scope">
+                            {{ getJuri(scope.row.juri)}}
+                        </template>
+                    </el-table-column>
+                    <el-table-column prop="time" label="编辑时间" min-width="15"></el-table-column>
+                    <el-table-column label="操作" width="200px">
+                        <template slot-scope="scope">
+                            <div>
+                                <el-button @click="editFile(scope.row.id)" type="primary" size="small">查看</el-button>
+                                <el-button @click="deleteFile(scope.row.id)" type="danger" size="small">删除</el-button>
+                            </div>
+                        </template>
+                    </el-table-column>
+                </el-table>
+            </div>
+            <el-pagination
+                style="margin-top: 10px;"
+                background
+                layout="prev, pager, next"
+                :page-size="10"
+                :total="total"
+                @current-change="handleCurrentChange"
+                >
+            </el-pagination>
+        </div>
+        <el-dialog title="新建文件夹" :visible.sync="moveBox" width="550px" @close="moveBox = false" class="dialog">
+            <div>
+                <el-input v-model="folderName" placeholder="请输入知识库名称"></el-input>
+                <el-input v-model="folderDescription" type="textarea" rows="4" resize="none" placeholder="请输入知识库描述" style="margin-top: 10px;"></el-input>
+            </div>
+            <span slot="footer">
+                <el-button @click="moveBox = false">取 消</el-button>
+                <el-button type="primary" @click="createFolder">确 定</el-button>
+            </span>
+        </el-dialog>
+
+    </div>
+</template>
+
+<script>
+import officeImg from '../../../assets/icon/sourceFile/office.png'
+import pdfImg from '../../../assets/icon/sourceFile/pdf.png'
+import videoImg from '../../../assets/icon/sourceFile/video.png'
+import otherImg from '../../../assets/icon/sourceFile/other.png'
+import checkImg from '../../../assets/icon/sourceFile/check.png'
+import checkIsImg from '../../../assets/icon/sourceFile/check_is.png'
+
+
+import wVideo from "../test/file/wVideo.vue";
+import wpdf from "../test/file/wPdf2.vue";
+import wOffice from "../test/file/wOffice.vue";
+
+import JSZip from "jszip";
+import FileSaver from "file-saver";
+
+const getFile = (url) => {
+    return new Promise((resolve, reject) => {
+        var credentials = {
+            accessKeyId: "AKIATLPEDU37QV5CHLMH",
+            secretAccessKey: "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",
+        }; //秘钥形式的登录上传
+        window.AWS.config.update(credentials);
+        window.AWS.config.region = "cn-northwest-1"; //设置区域
+        let url2 = url;
+        let _url2 = "";
+        if (
+            url2.indexOf("https://view.officeapps.live.com/op/view.aspx?src=") != -1
+        ) {
+            _url2 = url2.split(
+                "https://view.officeapps.live.com/op/view.aspx?src="
+            )[1];
+        } else {
+            _url2 = url2;
+        }
+        var s3 = new window.AWS.S3({ params: { Bucket: "ccrb" } });
+        let name = decodeURIComponent(_url2.split("https://ccrb.s3.cn-northwest-1.amazonaws.com.cn/")[1].replace(/\+/g, ' '))
+        var params = {
+            Bucket: "ccrb",
+            Key: name
+        };
+        s3.getObject(params, function (err, data) {
+            if (err) {
+                console.log(err, err.stack)
+                resolve({ data: 1 });
+            } else {
+                resolve({ data: data.Body });
+                console.log(data);
+            }          // sxuccessful response
+
+        });
+        // axios({
+    });
+};
+export default {
+    components: {
+        wVideo,
+        wpdf,
+        wOffice,
+    },
+    props: {
+        userid: {
+            type: String,
+        },
+        typeArray: {
+            type: Array,
+        },
+        pid: {
+            type: String,
+        },
+        type: {
+            type: String
+        }
+    },
+    watch: {
+        pid: {
+            immediate: true,
+            deep: true,
+            handler(newValue, oldValue) {
+                this.fileArray = []
+                this.checkArray = []
+                this.fileName = ''
+                this.page = 1
+                this.getData()
+            },
+        },
+    },
+    data() {
+        return {
+            isLoading: false,
+            proVisible: false,
+            stype: 2,
+            fileArray: [],
+            officeImg: officeImg,
+            pdfImg: pdfImg,
+            videoImg: videoImg,
+            otherImg: otherImg,
+            checkImg: checkImg,
+            checkIsImg: checkIsImg,
+            checkArray: [],
+            dialogVisiblePdf: false,
+            dialogVisibleVideo: false,
+            dialogVisibleOffice: false,
+            wurl: '',
+            moveBox: false,
+            checkTypeArray: [],
+            moveChild: '',
+            fileName: '',
+            folderName: "",
+            folderDescription: "",
+            page: 1,
+            total: 0,
+        }
+    },
+    computed: {
+        retrunType() {
+            return function (item) {
+                if (item.type == 1) {
+                    return 'OFFICE文件'
+                } else if (item.type == 2) {
+                    return '视频文件'
+                } else if (item.type == 3) {
+                    return '图片'
+                } else if (item.type == 4) {
+                    return 'PDF文件'
+                } else if (item.type == 5) {
+                    return '其他文件'
+                }
+            };
+        },
+        getJuri() {
+            return function (juri) {
+                if (juri == 1) {
+                    return '私有'
+                } else if (juri == 2) {
+                    return '组织内'
+                } else if (juri == 3) {
+                    return '全部'
+                }
+            };
+        },
+        getTag() {
+            return function (row) {
+                const tags = [row.classTagName, row.subTagName, row.tag]
+                    .filter(tag => tag) // 过滤掉空值
+                    .flatMap(tag => tag.split(",")); // 展开并分割
+                return tags.length ? tags.join(",") : '-';
+            };
+        },
+    },
+    methods: {
+        handleCurrentChange(val) {
+            this.page = val;
+            this.getData();
+        },
+        getData() {
+            let type = this.pid.split("/")
+            let id = ''
+            if (type[0] == '0') {
+                id = this.userid
+            }
+            this.isLoading = true;
+            let params = {
+                uid: id,
+                page: this.page,
+                num: 10
+            };
+            this.ajax
+                .post(this.$store.state.api + "getFolderPage", [params])
+                .then((res) => {
+                    this.isLoading = false;
+                    this.total = res.data[0][0].num;
+                    this.fileArray = res.data[0];
+                    this.$parent.getData();
+                })
+                .catch((err) => {
+                    this.isLoading = false;
+                    console.error(err);
+                });
+        },
+        serchFile() {
+            this.getData();
+        },
+        handleSelectionChange(selectedRows) {
+            this.checkArray = selectedRows.map(row => row.id);
+        },
+        checkFile(id) {
+            if (this.checkArray.indexOf(id) == -1) {
+                this.checkArray.push(id)
+            } else {
+                this.checkArray.splice(this.checkArray.indexOf(id), 1)
+            }
+        },
+        checkAll() {
+            if (this.checkArray.length === this.fileArray.length) {
+                this.checkArray = []
+            } else {
+                this.checkArray = []
+                this.fileArray.forEach(item => {
+                    this.checkArray.push(item.id)
+                });
+            }
+        },
+        deleteFile(id) {
+            this.$confirm("确定删除文件夹吗?", "提示", {
+                confirmButtonText: "确定",
+                cancelButtonText: "取消",
+                type: "warning",
+            })
+            .then(() => {
+                let params = [
+                    { ids: id }
+                ]
+                this.ajax
+                    .post(this.$store.state.api + "deleteFolder", params)
+                    .then((res) => {
+                        this.$message({
+                            message: "删除成功",
+                            type: "success",
+                        });
+                        this.checkArray = []
+                        this.getData();
+                    })
+                    .catch((err) => {
+                        this.$message.error("删除失败");
+                        console.error(err);
+                    });
+            })
+            .catch(() => { });
+        },
+        deleteFolder(){
+            if(!this.checkArray.length){
+                this.$message.warning("请选择要删除的文件夹")
+                return;
+            }
+            this.deleteFile(this.checkArray.join(","))
+        },
+        checkMoveChild(item) {
+            this.moveChild = item
+        },
+        openAdd(){
+            this.moveBox = true
+        },
+        createFolder(){
+            if (!this.folderName) {
+                this.$message.error("文件夹名字必填");
+                return;
+            }
+            let params = [
+                { 
+                    n: this.folderName,
+                    fd: this.folderDescription,
+                    uid: this.userid,
+                }
+            ]
+            this.ajax
+                .post(this.$store.state.api + "addFolder", params)
+                .then((res) => {
+                    this.$message({
+                        message: "创建成功",
+                        type: "success",
+                    });
+                    this.moveBox = false;
+                    this.getData();
+                })
+                .catch((err) => {
+                    this.$message.error("删除失败");
+                    console.error(err);
+                });
+        },
+        editFile(id){
+            console.log(id);
+            
+            let array = [this.pid.split("/")[0], id];
+            this.$emit('checkType', array.join('/'));
+        }
+    },
+    mounted() {
+        this.getData();
+    },
+}
+</script>
+
+<style scoped>
+.f_box {
+    width: 100%;
+    /* height: 100%; */
+    position: relative;
+}
+
+.f_box_top {
+    display: flex;
+    align-items: center;
+    padding: 10px;
+    width: 100%;
+    box-sizing: border-box;
+}
+
+.f_box_top_left {
+    display: flex;
+    align-items: center;
+}
+
+.f_box_top_title{
+    font-size: 16px;
+    /* font-weight: bold; */
+}
+
+.f_box_top .btn {
+    display: flex;
+    cursor: pointer;
+    align-items: center;
+    height: 30px;
+    padding: 0 8px;
+    background: rgb(0, 97, 255);
+    color: #fff;
+    box-sizing: border-box;
+    border-radius: 4px;
+    font-size: 14px;
+    align-items: center;
+}
+
+.f_box_top .btn2 {
+    display: flex;
+    cursor: pointer;
+    align-items: center;
+    height: 30px;
+    padding: 0 8px;
+    background: #fff;
+    color: rgb(0, 97, 255);
+    border: 1px solid rgb(0, 97, 255);
+    box-sizing: border-box;
+    border-radius: 4px;
+    font-size: 14px;
+    align-items: center;
+}
+
+.f_box_top .delBtn {
+    background: rgb(255, 0, 13);
+}
+
+.f_box_top .btn+.btn2,
+.f_box_top .btn+.btn,
+.f_box_top .btn2+.btn2,
+.f_box_top .btn2+.delBtn {
+    margin-left: 15px;
+}
+
+.f_box_top_right {
+    margin-left: auto;
+    max-width: calc(100% - 280px);
+    overflow: hidden;
+    display: flex;
+    align-items: center;
+}
+
+.f_box_top_right>.input {
+    position: relative;
+    width: 250px;
+    height: 35px;
+}
+
+.f_box_top_right>.input>input {
+    width: 100%;
+    height: 100%;
+    border: 1px solid #D9D9D9;
+    border-radius: 5px;
+    padding: 0 45px 0 10px;
+    box-sizing: border-box;
+    font-size: 12px;
+    outline: none;
+}
+
+.f_box_top_right>.input>.serch {
+    content: '';
+    display: block;
+    width: 20px;
+    height: 20px;
+    background-image: url('../../../assets/icon/sourceFile/search.png');
+    background-size: 100% 100%;
+    position: absolute;
+    right: 13px;
+    top: 50%;
+    transform: translateY(-50%);
+    cursor: pointer;
+}
+
+.f_box_top_right>.tab {
+    height: 30px;
+    width: 80px;
+    margin-left: 15px;
+    background: #e7e7e7;
+    border: 2px solid #D9D9D9;
+    border-radius: 5px;
+    box-sizing: border-box;
+    overflow: hidden;
+    display: flex;
+    align-items: center;
+}
+
+.f_box_top_right>.tab>.table,
+.f_box_top_right>.tab>.list {
+    width: 50%;
+    height: 100%;
+    display: flex;
+    align-items: center;
+    justify-content: center;
+    cursor: pointer;
+}
+
+.f_box_top_right>.tab>.list::before {
+    content: '';
+    display: block;
+    width: 20px;
+    height: 20px;
+    background-image: url('../../../assets/icon/sourceFile/list.png');
+    background-size: 100% 100%;
+}
+
+.f_box_top_right>.tab>.list.active,
+.f_box_top_right>.tab>.table.active {
+    background: #fff;
+}
+
+.f_box_top_right>.tab>.table::before {
+    content: '';
+    display: block;
+    width: 20px;
+    height: 20px;
+    background-image: url('../../../assets/icon/sourceFile/table.png');
+    background-size: 100% 100%;
+}
+
+.mask {
+    background-color: rgb(0 0 0 / 30%);
+    /* position: fixed; */
+    position: absolute;
+    top: 0;
+    left: 0;
+    width: 100%;
+    height: 100%;
+    z-index: 90;
+    display: flex;
+    align-items: center;
+    justify-content: center;
+}
+
+.progressBox {
+    width: 300px;
+    height: 150px;
+    background: #fff;
+    border-radius: 10px;
+    box-shadow: 0 0 6px 1px #bfbfbf;
+    display: flex;
+    align-items: center;
+    justify-content: center;
+    flex-direction: column;
+    position: relative;
+    color: #6c6c6c;
+}
+
+.progressBox>>>.el-progress-bar__outer {
+    background-color: #d1dfff !important;
+}
+
+.progressBox .lbox {
+    height: 50px;
+    font-size: 19px;
+    display: flex;
+    align-items: center;
+    color: #747474;
+}
+
+.progressBox .lbox img {
+    width: 40px;
+    margin-right: 20px;
+}
+
+.closeCss {
+    position: absolute;
+    top: 8px;
+    right: 8px;
+    cursor: pointer;
+    width: 20px;
+    height: 20px;
+}
+
+.closeCss>img {
+    width: 100%;
+    height: 100%;
+}
+
+
+.f_box_file_square {
+    height: calc(100% - 55px);
+    overflow: auto;
+    width: 100%;
+    padding: 55px;
+    box-sizing: border-box;
+    display: flex;
+    flex-wrap: wrap;
+    align-content: flex-start;
+    position: relative;
+}
+
+.f_box_file_square>.f_box_file {
+    display: flex;
+    flex-direction: column;
+    align-items: center;
+    justify-content: center;
+    width: 160px;
+    height: 160px;
+    cursor: pointer;
+    margin: 0 36px 36px 0;
+    border-radius: 20px;
+    position: relative;
+}
+
+.f_box_file_square>.f_box_file:hover {
+    background: #F0F2F5;
+}
+
+.f_box_file_square>.f_box_file:hover>.check {
+    display: block;
+}
+
+.f_box_file_square>.f_box_file.check {
+    background: #E0EAFB;
+}
+
+.f_box_file_square>.f_box_file.check>.check {
+    display: block;
+}
+
+.f_box_file_square>.f_box_file>.check {
+    position: absolute;
+    left: 15px;
+    top: 15px;
+    width: 16px;
+    height: 16px;
+    background-size: 100%;
+    display: none;
+}
+
+.f_box_file_square>.f_box_file>.check>img {
+    width: 100%;
+    height: 100%;
+    object-fit: cover;
+}
+
+.f_box_file_square>.f_box_file>img {
+    width: 90px;
+    height: 90px;
+    object-fit: cover;
+}
+
+.f_box_file_square>.f_box_file>.name {
+    white-space: nowrap;
+    font-size: 14px;
+    max-width: 80%;
+    overflow: hidden;
+    margin: 4px auto 0;
+    text-overflow: ellipsis;
+    text-align: center;
+}
+
+.f_box_file_list {
+    /* height: calc(100% - 55px); */
+    /* overflow: auto; */
+    width: 100%;
+    padding: 10px;
+    box-sizing: border-box;
+}
+
+.f_box_file_list>.f_box_file {}
+
+
+.f_box_file_allCheck {
+    display: flex;
+    align-items: center;
+    position: absolute;
+    font-size: 14px;
+    top: 20px;
+    left: 10px;
+    cursor: pointer;
+}
+
+.f_box_file_allCheck>img {
+    width: 16px;
+    height: 16px;
+    object-fit: cover;
+    margin-right: 5px;
+}
+
+.dialog>>>.el-dialog__body {
+    padding: 10px 20px;
+}
+
+.type_nav_box {}
+
+.type_nav_box>.nav {
+    height: 40px;
+    border-radius: 5px;
+    cursor: pointer;
+    display: flex;
+    align-items: center;
+    width: 100%;
+    padding: 0 10px;
+    box-sizing: border-box;
+    margin-bottom: 10px;
+    font-size: 16px;
+    color: #000;
+}
+
+.type_nav_box>.nav>.down {
+    min-width: 14px;
+    height: 14px;
+    background-image: url('../../../assets/icon/sourceFile/icon_arrow.png');
+    background-size: 100% 100%;
+    margin-right: 10px;
+    transition: all 0.3s;
+    transform: rotate(-90deg);
+}
+
+.type_nav_box>.nav.active>.down {
+    transform: rotate(0deg);
+}
+
+.type_nav_box>.nav>.file {
+    min-width: 18px;
+    height: 18px;
+    background-image: url('../../../assets/icon/sourceFile/file.png');
+    background-size: 100% 100%;
+    margin-right: 10px;
+}
+
+.type_nav_box>.nav>.name {
+    max-width: 100%;
+    overflow: hidden;
+    text-overflow: ellipsis;
+    white-space: nowrap;
+}
+
+.type_nav_box>.child {}
+
+.type_nav_box>.child>.nav {
+    height: 40px;
+    border-radius: 5px;
+    cursor: pointer;
+    display: flex;
+    align-items: center;
+    width: 100%;
+    padding: 0 10px 0 50px;
+    box-sizing: border-box;
+    margin-bottom: 10px;
+    font-size: 16px;
+    color: #000;
+}
+
+.type_nav_box>.child>.nav.active {
+    background: #e0eafb;
+}
+
+.type_nav_box>.child>.nav>.file {
+    min-width: 18px;
+    height: 18px;
+    background-image: url('../../../assets/icon/sourceFile/file.png');
+    background-size: 100% 100%;
+    margin-right: 10px;
+}
+
+.type_nav_box>.child>.nav>.name {
+    max-width: 100%;
+    overflow: hidden;
+    text-overflow: ellipsis;
+    white-space: nowrap;
+}
+
+.none_box {
+    height: calc(100% - 55px);
+    overflow: auto;
+    width: 100%;
+    padding: 10px;
+    box-sizing: border-box;
+    display: flex;
+    align-items: center;
+    justify-content: center;
+}
+
+
+.list_file_box {
+    width: 100%;
+}
+
+</style>

+ 566 - 0
src/components/pages/knowledge/folderDetail.vue

@@ -0,0 +1,566 @@
+<template>
+  <div class="f_box">
+    <div class="f_box_top" v-loading="isLoading">
+      <div class="title">
+        <div class="t_title">{{ data.name }}</div>
+        <div class="t_btn">
+          <!-- <div class="btn">复制文件夹</div> -->
+          <div
+            class="btn"
+            @click="deleteFile(pid.split('/')[1])"
+            v-if="userid == data.userid"
+          >
+            删除文件夹
+          </div>
+        </div>
+      </div>
+      <div class="detail">
+        <textarea
+          v-autoHeight="68"
+          rows="2"
+          class="binfo_input binfo_textarea"
+          cols
+          v-model="data.detail"
+          placeholder="输入文件夹描述"
+          v-if="canEdit"
+        ></textarea>
+        <div
+          class="detail_box"
+          v-html="data.detail ? data.detail : '暂无描述'"
+          v-else
+        ></div>
+        <div class="editbox" v-if="userid == data.userid">
+          <div class="edit_btn" @click="editConfirm">
+            {{ canEdit ? "确定" : "编辑" }}
+          </div>
+        </div>
+      </div>
+      <div class="tag_box" v-if="data.userid == userid">
+        <div class="tag">
+          <div class="tag_title">标签:</div>
+          <div class="tag_check">
+            <el-select
+              v-loading="tagLoading1"
+              v-model="check1"
+              placeholder="前选择学科标签"
+              clearable
+              filterable
+              multiple
+              collapse-tags
+              style="width: calc(100% / 2 - 10px / 2); margin-right: 10px;"
+              @change="updateFolder()"
+            >
+              <el-option
+                v-for="(item, index) in tagData1"
+                :key="index"
+                :label="item.name"
+                :value="item.id"
+              ></el-option>
+            </el-select>
+            <el-select
+              v-loading="tagLoading2"
+              v-model="check2"
+              placeholder="前选择年级标签"
+              clearable
+              filterable
+              multiple
+              collapse-tags
+              style="width: calc(100% / 2 - 10px / 2);"
+              @change="updateFolder()"
+            >
+              <el-option
+                v-for="(item, index) in tagData2"
+                :key="index"
+                :label="item.name"
+                :value="item.id"
+              ></el-option>
+            </el-select>
+            <el-select
+              v-loading="tagLoading3"
+              v-model="check3"
+              placeholder="自定义标签"
+              clearable
+              filterable
+              multiple
+              collapse-tags
+              allow-create
+              style="width: 100%; margin-top: 10px;"
+              @change="handleTagChange"
+            >
+              <el-option
+                v-for="(item, index) in tagData3"
+                :key="index"
+                :label="item.name"
+                :value="item.name"
+              >
+                <div class="selectBox">
+                  <span>{{ item.name }}</span>
+                  <div class="controlsBox">
+                    <span
+                      class="delSelect"
+                      @click.stop="deleteTag(item.id, item.name)"
+                    ></span>
+                  </div>
+                </div>
+              </el-option>
+            </el-select>
+          </div>
+        </div>
+        <div class="tag">
+          <div class="tag_title">权限管理:</div>
+          <div class="tag_check">
+            <el-radio-group v-model="data.juri" @change="updateFolder()">
+              <el-radio label="1">私有</el-radio>
+              <el-radio label="2">组织内</el-radio>
+              <el-radio label="3">全部</el-radio>
+            </el-radio-group>
+          </div>
+        </div>
+      </div>
+      <div class="tag_box" v-else>
+        <div class="tag_check">
+          <div class="tag_check_box" v-if="this.check1.length">
+            <span>学科:</span>
+            <span>{{ getTagName(1) }}</span>
+          </div>
+          <div class="tag_check_box" v-if="this.check2.length">
+            <span>年级:</span>
+            <span>{{ getTagName(2) }}</span>
+          </div>
+          <div class="tag_check_box" v-if="this.check3.length">
+            <span>自定义:</span>
+            <span>{{ getTagName(3) }}</span>
+          </div>
+        </div>
+      </div>
+    </div>
+  </div>
+</template>
+
+<script>
+export default {
+  props: {
+    pid: {
+      type: String
+    },
+    userid: {
+      type: String
+    }
+  },
+  data() {
+    return {
+      data: {},
+      isLoading: false,
+      canEdit: false,
+      tagLoading1: false,
+      tagLoading2: false,
+      tagLoading3: false,
+      tagData1: [],
+      tagData2: [],
+      tagData3: [],
+      check1: [],
+      check2: [],
+      check3: []
+    };
+  },
+  watch: {
+    pid(newValue, oldValue) {
+      this.data = {};
+      this.getData();
+      this.getTag(1); // 获取标签
+      this.getTag(2); // 获取标签
+      this.getTag(3); // 获取标签
+    }
+  },
+  computed: {
+    getTagName() {
+      return function(type) {
+        const tagDataMap = {
+          1: { data: this.tagData1, check: this.check1, key: "id" },
+          2: { data: this.tagData2, check: this.check2, key: "id" },
+          3: { data: this.tagData3, check: this.check3, key: "name" }
+        };
+        const { data, check, key } = tagDataMap[type] || {};
+        return data
+          ? data
+              .filter(item => check.includes(item[key]))
+              .map(item => item.name)
+              .join(",")
+          : "";
+      };
+    }
+  },
+  directives: {
+    autoHeight: {
+      update(el, binding) {
+        const { value } = binding;
+        if (value && typeof value === "number") {
+          el.style.height = `${value}px`;
+        } else {
+          el.style.height = "auto";
+        }
+      },
+      componentUpdated(el) {
+        el.style.height = `${el.scrollHeight + 10}px`;
+      }
+    }
+  },
+  mounted() {
+    this.getTag(1); // 获取标签
+    this.getTag(2); // 获取标签
+    this.getTag(3); // 获取标签
+    this.getData();
+  },
+  methods: {
+    getData() {
+      this.isLoading = true;
+      let type = this.pid.split("/");
+      let params = {
+        id: type[1]
+      };
+      this.ajax
+        .post(this.$store.state.api + "getKnowledgeDetail", [params])
+        .then(res => {
+          this.isLoading = false;
+          this.data = res.data[0][0];
+          this.check1 = res.data[0][0].sub_tag
+            ? res.data[0][0].sub_tag.split(",")
+            : [];
+          this.check2 = res.data[0][0].class_tag
+            ? res.data[0][0].class_tag.split(",")
+            : [];
+          this.check3 = res.data[0][0].tag ? res.data[0][0].tag.split(",") : [];
+        })
+        .catch(err => {
+          this.isLoading = false;
+          console.error(err);
+        });
+    },
+    getTag(type) {
+      const tagLoadings = [
+        this.tagLoading1,
+        this.tagLoading2,
+        this.tagLoading3
+      ];
+      tagLoadings[type - 1] = true;
+
+      let params = {
+        type: type,
+        uid: this.userid
+      };
+      this.ajax
+        .post(this.$store.state.api + "getKnowledgeTag", [params])
+        .then(res => {
+          tagLoadings[type - 1] = false;
+          this[`tagData${type}`] = res.data[0];
+
+          const checkKey = `check${type}`;
+          if (type == 3) {
+            this[checkKey] = this[checkKey].filter(tag =>
+              this[`tagData${type}`].some(item => item.name === tag)
+            );
+          } else {
+            this[checkKey] = this[checkKey].filter(tag =>
+              this[`tagData${type}`].some(item => item.id === tag)
+            );
+          }
+        })
+        .catch(err => {
+          tagLoadings[type - 1] = false;
+          console.error(err);
+        });
+    },
+    deleteFile(id) {
+      this.$confirm("确定删除文件夹吗?", "提示", {
+        confirmButtonText: "确定",
+        cancelButtonText: "取消",
+        type: "warning"
+      })
+        .then(() => {
+          let params = [{ ids: id }];
+          this.ajax
+            .post(this.$store.state.api + "deleteFolder", params)
+            .then(res => {
+              this.$message({
+                message: "删除成功",
+                type: "success"
+              });
+              this.$emit("checkType", this.pid.split("/")[0]);
+            })
+            .catch(err => {
+              this.$message.error("删除失败");
+              console.error(err);
+            });
+        })
+        .catch(() => {});
+    },
+    editConfirm() {
+      if (!this.canEdit) {
+        this.canEdit = true;
+        this.data.detail += "*1*/123/";
+        this.$nextTick(() => {
+          this.data.detail = this.data.detail.replace("*1*/123/", "");
+          this.$refs.binfo_textarea.focus();
+        });
+      } else {
+        this.canEdit = false;
+        this.updateFolder();
+      }
+    },
+    updateFolder() {
+      let type = this.pid.split("/");
+      let params = {
+        id: type[1],
+        d: this.data.detail,
+        st: this.check1.join(","),
+        ct: this.check2.join(","),
+        t: this.check3.join(","),
+        j: this.data.juri
+      };
+      this.ajax
+        .post(this.$store.state.api + "updateFolder", [params])
+        .then(res => {
+          this.$message.success("修改成功");
+          this.getData();
+        })
+        .catch(err => {
+          console.error(err);
+        });
+    },
+    handleTagChange(value) {
+      const tagArray = this.tagData3;
+      const missingTags = value.filter(
+        selectedTag => !tagArray.some(tag => tag.name === selectedTag)
+      );
+
+      console.log("Selected tags:", value);
+      console.log("Missing tags:", missingTags);
+
+      missingTags.forEach(tag => this.addTag(tag));
+      this.updateFolder();
+    },
+    addTag(name) {
+      let params = {
+        n: name,
+        uid: this.userid,
+        type: 3,
+        j: 3
+      };
+      this.ajax
+        .post(this.$store.state.api + "addTag", [params])
+        .then(res => {
+          this.getTag(3);
+        })
+        .catch(err => {
+          console.error(err);
+        });
+    },
+    deleteTag(id, n) {
+      this.$confirm("确定删除这个标签吗?", "提示", {
+        confirmButtonText: "确定",
+        cancelButtonText: "取消",
+        type: "warning"
+      })
+        .then(() => {
+          this.check3 = this.check3.filter(t => t != n);
+          this.updateFolder();
+          let params = {
+            id: id
+          };
+          this.ajax
+            .post(this.$store.state.api + "deleteTag", [params])
+            .then(res => {
+              this.$message.success("删除成功");
+              this.getTag(3);
+            })
+            .catch(err => {
+              console.error(err);
+            });
+        })
+        .catch(() => {});
+    }
+  }
+};
+</script>
+
+<style scoped>
+.f_box {
+  width: 100%;
+  /* height: 100%; */
+  position: relative;
+}
+
+.f_box_top {
+  padding: 10px;
+  width: 100%;
+  box-sizing: border-box;
+}
+
+.f_box_top .btn {
+  display: flex;
+  cursor: pointer;
+  align-items: center;
+  height: 30px;
+  padding: 0 8px;
+  background: rgb(0, 97, 255);
+  color: #fff;
+  box-sizing: border-box;
+  border-radius: 4px;
+  font-size: 14px;
+  align-items: center;
+}
+
+.f_box_top .btn + .btn {
+  margin-left: 10px;
+}
+
+.f_box_top > .title {
+  width: 100%;
+  display: flex;
+  align-items: center;
+}
+
+.f_box_top > .title > .t_title {
+  font-size: 22px;
+  font-weight: bold;
+}
+
+.f_box_top > .title > .t_btn {
+  margin-left: auto;
+  display: flex;
+  align-items: center;
+}
+
+.binfo_input {
+  width: 100%;
+  margin: 0;
+  padding: 12px 14px;
+  display: block;
+  min-width: 0;
+  outline: none;
+  box-sizing: border-box;
+  background: none;
+  border: none;
+  border-radius: 4px;
+  background: #fff;
+  font-size: 16px;
+  resize: none;
+  font-family: "Microsoft YaHei";
+  min-height: 48px;
+  /* border: 1px solid #3682fc00; */
+  border: 1.5px solid #cad1dc;
+}
+
+.binfo_textarea {
+  border: 1.5px solid #cad1dc;
+  font-size: 16px;
+  resize: none;
+  /* background: #f6f6f6; */
+  font-family: "Microsoft YaHei";
+}
+
+.binfo_input:focus-visible {
+  border: 1.5px solid #3681fc !important;
+}
+
+.f_box_top > .detail {
+  width: 100%;
+  margin-top: 10px;
+  color: #6d6d6d;
+}
+
+.f_box_top > .detail > .detail_box {
+  width: 100%;
+  white-space: break-spaces;
+  word-break: break-all;
+}
+
+.f_box_top > .detail > .editbox {
+  display: flex;
+  align-items: center;
+  justify-content: flex-end;
+}
+
+.f_box_top > .detail > .editbox > .edit_btn {
+  color: #3681fc;
+  cursor: pointer;
+  margin-top: 5px;
+}
+
+.tag_box {
+  margin: 10px 0 0 0;
+  display: flex;
+  align-items: flex-start;
+  width: 100%;
+}
+.tag_box > .tag {
+  width: calc(100% / 2 - 20px / 2);
+  display: flex;
+  align-items: flex-start;
+  line-height: 40px;
+}
+
+.tag_box > .tag + .tag {
+  margin-left: 20px;
+}
+
+.tag_box > .tag > .tag_title {
+  min-width: fit-content;
+}
+.tag_box > .tag > .tag_check {
+  display: flex;
+  flex-wrap: wrap;
+}
+
+.tag_box > .tag > .tag_check >>> .el-radio-button__inner,
+.el-radio-group,
+.tag_box > .tag > .tag_check >>> .el-radio__input,
+.tag_box > .tag > .tag_check >>> .el-radio__label,
+.tag_box > .tag > .tag_check >>> .el-radio {
+  display: flex;
+  align-items: center;
+  height: 40px;
+}
+
+.selectBox {
+  width: 100%;
+  height: 100%;
+  display: flex;
+  align-items: center;
+  justify-content: space-between;
+}
+
+.controlsBox {
+  display: flex;
+  align-items: center;
+  width: auto;
+  height: 100%;
+  display: flex;
+}
+
+.delSelect {
+  width: 16px;
+  height: 16px;
+  /* display: none; */
+  align-items: center;
+  justify-content: center;
+  background: url("../../../assets/icon/classroomObservation/del.svg") no-repeat;
+  background-size: 100% 100%;
+  box-sizing: border-box;
+  /* transform: translateY(7px); */
+}
+
+.tag_check_box {
+  width: 100%;
+  display: flex;
+  margin: 0 0 10px;
+  flex-wrap: nowrap;
+}
+.tag_check_box > span:nth-child(1) {
+  min-width: 65px;
+  text-align-last: justify;
+}
+.tag_check_box > span:nth-child(2) {
+  word-break: break-all;
+}
+</style>

+ 105 - 320
src/components/pages/knowledge/index.vue

@@ -2,75 +2,51 @@
   <div class="l_box">
     <div class="l_type_box" v-loading="isLoading">
       <div class="header">
-        <span class="title">我的资源库</span>
-        <span class="add" @click="addClick" ref="divToHide3">添加分类</span>
+        <span class="title">知识库</span>
       </div>
       <div class="nav">
-        <div class="nav_b">
-          <div class="nav_box" :class="{ active1: pid == 'wu' }" @click="checkType('wu')"><span
-              class="icon no"></span><span class="name">未分类</span>
-          </div>
-        </div>
         <div class="nav_b" v-for="(item, index) in typeArray" :key="index">
-          <div class="nav_box" :class="{ open: item.open, active2: pid.split('-')[0] == index }"
-            @click="checkType(index + '')"><span class="icon" :class="{ haveL: item.child.length }"
-              @click.stop="typeOpen(index)"></span>
-            <input class="renameInput" v-model="renameInput" v-if="renameType == (index + '')" ref="renameInput"
-              @change="rename" @keyup.enter="rename">
-            <el-tooltip :content="item.name" placement="top" effect="dark" v-else>
+          <div class="nav_box" :class="{ open: item.open, active2: pid.split('/')[0] == item.id }" @click="checkType(item.id)">
+            <span class="icon" :class="{ haveL: item.child.length }" @click.stop="typeOpen(index)"></span>
+            <el-tooltip :content="item.name" placement="top" effect="dark">
               <span class="name">{{ item.name }}</span>
             </el-tooltip>
-            <span ref="divToHide5" class="icon more" @click.stop="showActions($event, index + '')"></span>
           </div>
           <div class="nav_child_box" v-if="item.open && item.child.length">
-            <div class="nav_box" :class="{ active: pid == index + '-' + index2 }" v-for="(item2, index2) in item.child"
-              :key="index + '-' + index2" @click="checkType(index + '-' + index2)">
+            <div class="nav_box" :class="{ active: pid == item.id + '/' + item2.id }" v-for="(item2, index2) in item.child"
+              :key="index + '-' + index2" @click="checkType(item.id + '/' + item2.id)">
               <span class="icon"></span>
-              <input class="renameInput" v-model="renameInput" v-if="renameType == (index + '-' + index2)"
-                ref="renameInput" @change="rename" @keyup.enter="rename">
-              <el-tooltip :content="item2.name" placement="top" effect="dark" v-else>
+              <el-tooltip :content="item2.name" placement="top" effect="dark">
                 <span class="name">{{ item2.name }}</span>
               </el-tooltip>
-              <span ref="divToHide5" class="icon more" @click.stop="showActions($event, index + '-' + index2)"></span>
-            </div>
-          </div>
-          <div class="add_box" v-if="addVisbile2 === index" ref="divToHide2">
-            <input type="text" v-model="addInput" @change="addType" @keyup.enter="addType">
-          </div>
-        </div>
-        <div class="add_box" v-if="addVisbile" ref="divToHide">
-          <input type="text" v-model="addInput" @change="addType" @keyup.enter="addType">
-        </div>
-      </div>
-      <div v-if="showActionDiv" ref="actionDiv" :style="actionDivStyle" class="action-div">
-        <div @click="actionDelete">删除</div>
-        <div @click="actionRename">重命名</div>
-        <div @click="actionAdd" v-if="actionType.split('-').length == 1" ref="addTypeAction">添加分类</div>
-        <div class="move" v-if="pidArray.length">
-          <span>移动</span>
-          <div class="pid_box">
-            <div v-for="(item, index) in pidArray" :key="index" @click="actionMove(item)">
-              <!-- <el-tooltip :content="item.name" placement="right" effect="dark"> -->
-              <span>{{ item.name }}</span>
-              <!-- </el-tooltip> -->
             </div>
           </div>
         </div>
       </div>
     </div>
     <div class="l_file_box">
-      <div class="l_none" v-if="pid != 'wu' && pid.split('-').length == 1">请添加二级分类</div>
-      <fileBox :userid="userid" :typeArray="typeArray" :pid="pid" :type='type' @addFile="addFile" ref="fileBox" v-else>
+      <div class="bread_box">
+        <span class="bread" :class="{is: getPid(item.name) == pid}" v-for="(item, index) in getBread()" :key="index" @click="checkType2(getPid(item.name) == pid, getPid(item.name))">{{ item.name }}</span>
+        </div>
+      <folder :userid="userid" :typeArray="typeArray" :pid="pid" @checkType="checkType" v-if="pid.split('/').length == 1"></folder>
+      <fileBox :userid="userid" :typeArray="typeArray" :pid="pid" :type='type' ref="fileBox" v-if="pid.split('/').length == 1">
       </fileBox>
+      <folderDetail :userid="userid" :pid="pid"  v-if="pid.split('/').length > 1" @checkType="checkType"></folderDetail>
+
     </div>
   </div>
 </template>
 
 <script>
 import fileBox from './fileBox.vue';
+import folder from './folder.vue';
+import folderDetail from './folderDetail.vue';
+
 export default {
   components: {
     fileBox,
+    folder,
+    folderDetail
   },
   props: {
     type: {
@@ -81,23 +57,58 @@ export default {
   data() {
     return {
       userid: this.$route.query.userid,
-      pid: 'wu',
+      pid: '0',
       addInput: '',
       addVisbile: false,
       addVisbile2: '',
       isLoading: false,
-      typeArray: [],
-      showActionDiv: false,
-      actionDivStyle: {
-        top: '0px',
-        left: '0px'
-      },
+      typeArray: [
+        { name: '我的知识库',child: [], id: '0' }
+      ],
       actionType: '',
       renameType: '',
       renameInput: '',
       pidArray: [],
     }
   },
+  computed: {
+    getBread(){
+      return function () {
+        const _pid = this.pid.split('/');
+        let array = [];
+        let index = this.typeArray.findIndex(item => item.id === _pid[0]);
+        
+        if (index !== -1) {
+            array.push({ name: this.typeArray[index].name, id: this.typeArray[index].id });
+        }
+
+        for (let i = 1; i < _pid.length; i++) {
+            const childIndex = this.typeArray[index].child.findIndex(child => child.id === _pid[i]);
+            if (childIndex !== -1) {
+                array.push({ name: this.typeArray[index].child[childIndex].name, id: this.typeArray[index].child[childIndex].id });
+            }
+        }
+        console.log(array);
+        
+        return array;
+      };
+    },
+    getPid(){
+      return function (item) {
+        let array = this.getBread()
+        let pid = []
+        for(var i = 0; i < array.length; i++){
+          if(array[i].name == item){
+            pid.push(array[i].id)
+            break;
+          }else{
+            pid.push(array[i].id)
+          }
+        }
+        return pid.join('/');
+      };
+    }
+  },
   methods: {
     getData() {
       this.isLoading = true;
@@ -105,299 +116,46 @@ export default {
         uid: this.userid,
       };
       this.ajax
-        .get(this.$store.state.api + "getSourceFileType", params)
+        .post(this.$store.state.api + "getFolder", [params])
         .then((res) => {
           this.isLoading = false;
-          let pid = res.data[0];
-          let child = res.data[1];
-          for (var i = 0; i < pid.length; i++) {
-            let pidChild = []
-            pid[i].open = (this.typeArray.length && this.typeArray[i]) ? this.typeArray[i].open : false
-            for (var j = 0; j < child.length; j++) {
-              if (pid[i].id == child[j].pid) {
-                pidChild.push(child[j])
-              }
-            }
-            pid[i].child = pidChild
-          }
-          this.typeArray = pid
-          this.$forceUpdate()
-
-          let _pid = this.pid.split('-')
-          if (_pid.length === 1 && this.pid != 'wu') {
-            if (pid[_pid[0]]) {
-              pid[_pid[0]].open = true
-              this.pid = this.pid + '-0'
-            } else {
-              this.pid = 'wu'
-            };
-            this.checkType(this.pid);
-          } else if (_pid.length > 1) {
-            if (this.typeArray[_pid[0]].child.length > 0 && (parseInt(_pid[1]) + 1) > this.typeArray[_pid[0]].child.length) {
-              this.pid = _pid[0] + '-0';
-              this.checkType(this.pid);
-            } else if ((parseInt(_pid[1]) + 1) > this.typeArray[_pid[0]].child.length) {
-              this.checkType(_pid[0]);
-            }
-          }
-          this.$refs['fileBox'].getData()
-          console.log(this.$refs['fileBox']);
+          let data = res.data[0]
+          this.typeArray[0].child = data
+          // this.$refs['fileBox'].getData()
+          // console.log(this.$refs['fileBox']);
         })
         .catch((err) => {
           this.isLoading = false;
           console.error(err);
         });
     },
-    addClick() {
-      // if (this.pid == 'wu') {
-      this.addVisbile = true;
-      this.addInput = '一级分类标签'
-      setTimeout(() => {
-        this.$refs.divToHide.children[0].select()
-      }, 500);
-      // } else {
-      //   let check = this.pid.split('-')
-      //   this.addVisbile2 = parseInt(check[0]);
-      //   this.addInput = '二级分类标签'
-      //   setTimeout(() => {
-      //     this.$refs.divToHide2[0].children[0].select()
-      //   }, 500);
-      // }
-
-    },
-    addType() {
-      let pid = ''
-      if (!this.addInput) {
-        this.$message.error('请输入分类名字');
-        return
-      }
-      if (this.addVisbile) {
-        pid = '0'
-      } else if (this.addVisbile2 === 0 || this.addVisbile2) {
-        let check = this.pid.split('-')
-        pid = this.typeArray[check[0]].id
-      }
-      let params = [{
-        pid: pid,
-        name: this.addInput,
-        uid: this.userid
-      }];
-      this.ajax
-        .post(this.$store.state.api + "addSourceFileType", params)
-        .then((res) => {
-          this.$message.success('添加成功');
-          this.addVisbile = false
-          this.addVisbile2 = ''
-          this.getData()
-        })
-        .catch((err) => {
-          console.error(err);
-        });
-    },
     typeOpen(index) {
       if (this.typeArray[index].child.length > 0) {
         this.typeArray[index].open = !this.typeArray[index].open
+        this.$forceUpdate();
       }
     },
     checkType(pid) {
       if (this.pid == pid) {
         return
       }
-      let _pid = pid.split('-')
-      if (_pid.length === 1 && pid != 'wu') {
-        if (this.typeArray[_pid[0]].child.length > 0) {
-          this.pid = pid + '-0';
-          this.typeArray[_pid[0]].open = true;
-        } else {
-          this.pid = pid;
-        }
-      } else {
-        this.pid = pid;
+      const [id] = pid.split('/');
+      const index = this.typeArray.findIndex(item => item.id === id);
+      if (index !== -1) {
+        this.typeArray[index].open = true;
       }
+      this.pid = pid;
+      this.$forceUpdate()
     },
-    handleClickOutside(event) {
-      const target = event.target;
-      const divToHide = this.$refs.divToHide; // 获取需要隐藏的 div 的引用
-      const divToHide2 = this.$refs.divToHide2; // 获取需要隐藏的 div 的引用
-      const addTypeAction = this.$refs.addTypeAction
-      const divToHide3 = this.$refs.divToHide3; // 获取需要隐藏的 div 的引用
-      const divToHide4 = this.$refs.actionDiv; // 获取需要隐藏的 div 的引用
-      const divToHide5 = this.$refs.divToHide5; // 获取需要隐藏的 div 的引用
-      const renameInput = this.$refs.renameInput; // 获取需要隐藏的 div 的引用
-      console.log('1')
-      if (divToHide && !divToHide.contains(target) && divToHide3 && !divToHide3.contains(target)) {
-        // 点击的不是需要隐藏的 div,则隐藏它
-        this.addVisbile = false
-      }
-      // if (divToHide2 && divToHide2[0] && !divToHide2[0].contains(target) && divToHide3 && !divToHide3.contains(target)) {
-      //   // 点击的不是需要隐藏的 div,则隐藏它
-      //   this.addVisbile2 = ''
-      // }
-      if (divToHide2 && divToHide2[0] && !divToHide2[0].contains(target) && addTypeAction && !addTypeAction.contains(target)) {
-        // 点击的不是需要隐藏的 div,则隐藏它
-        this.addVisbile2 = ''
+    checkType2(is, pid) {
+      if(!is){  
+        this.checkType(pid)
       }
-
-      if (divToHide4 && !divToHide4.contains(target) && divToHide5 && !divToHide5[0].contains(target)) {
-        // 点击的不是需要隐藏的 div,则隐藏它
-        this.showActionDiv = false;
-      }
-
-      if (renameInput && renameInput[0] && !renameInput[0].contains(target) && (!divToHide4 || (divToHide4 && !divToHide4.contains(target)))) {
-        // 点击的不是需要隐藏的 div,则隐藏它
-        this.renameType = ''
-      }
-    },
-    showActions(event, type) {
-      this.showActionDiv = true;
-      const buttonRect = event.target.getBoundingClientRect();
-      this.actionDivStyle.top = `${buttonRect.bottom - 30}px`;
-      this.actionDivStyle.left = `${buttonRect.left + 25}px`;
-      this.pidArray = []
-      let _type = type.split('-')
-      if (_type.length > 1) {
-        let pid = this.typeArray[_type[0]].child[_type[1]].pid
-        this.typeArray.forEach(item => {
-          item.id != pid && this.pidArray.push(item)
-        })
-      }
-      this.actionType = type;
-      this.$forceUpdate();
-    },
-    actionMove(pid) {
-      let type = this.actionType.split('-')
-      let id = this.typeArray[type[0]].child[type[1]].id
-      this
-        .$confirm('确定移动到' + pid.name + '吗?并且此分类的底下的文件也会跟随!', "提示", {
-          confirmButtonText: "确定",
-          cancelButtonText: "取消",
-          type: "warning",
-        })
-        .then(() => {
-          let params = [{
-            id: id,
-            pid: pid.id
-          }];
-          this.ajax
-            .post(this.$store.state.api + "updateSourceFileTypePid", params)
-            .then((res) => {
-              this.$message.success('移动成功');
-              this.showActionDiv = false
-              this.getData()
-            })
-            .catch((err) => {
-              console.error(err);
-            });
-        })
-        .catch(() => {
-        });
-    },
-    actionRename() {
-      let type = this.actionType.split('-')
-      if (type.length == 1) {
-        this.renameInput = this.typeArray[type[0]].name
-      } else {
-        this.renameInput = this.typeArray[type[0]].child[type[1]].name
-      }
-      this.renameType = this.actionType
-      if (this.pid != this.renameType) {
-        this.checkType(this.renameType)
-      }
-      console.log(this.renameType);
-      setTimeout(() => {
-        this.$refs.renameInput[0].select();
-        this.showActionDiv = false
-      }, 500);
-    },
-    actionAdd() {
-      let type = this.actionType.split('-')
-      if (type.length > 1) {
-        return
-      }
-      let check = type
-      this.checkType(this.actionType)
-      this.addVisbile2 = parseInt(check[0]);
-      this.addInput = '二级分类标签'
-      this.showActionDiv = false
-      setTimeout(() => {
-        this.$refs.divToHide2[0].children[0].select()
-      }, 500);
-    },
-    rename() {
-      if (!this.renameInput) {
-        this.$message.error('请输入分类名字');
-        return
-      }
-      let type = this.renameType.split('-')
-      let id = ''
-      if (type.length == 1) {
-        id = this.typeArray[type[0]].id
-      } else {
-        id = this.typeArray[type[0]].child[type[1]].id
-      }
-      let params = [{
-        id: id,
-        name: this.renameInput
-      }];
-      this.ajax
-        .post(this.$store.state.api + "updateSourceFileName", params)
-        .then((res) => {
-          this.$message.success('修改成功');
-          this.renameType = ''
-          this.getData()
-        })
-        .catch((err) => {
-          console.error(err);
-        });
-    },
-    actionDelete() {
-      let type = this.actionType.split('-')
-      let id = ''
-      let msg = ''
-      if (type.length == 1) {
-        if (this.typeArray[type[0]].child.length) {
-          msg = '删除此分类后,该分类下的所有子分类将全部删除,确定删除此分类吗?'
-        } else {
-          msg = '确定删除此分类吗?'
-        }
-        id = this.typeArray[type[0]].id
-      } else {
-        msg = '确定删除此分类吗?'
-        id = this.typeArray[type[0]].child[type[1]].id
-      }
-      this
-        .$confirm(msg, "提示", {
-          confirmButtonText: "确定",
-          cancelButtonText: "取消",
-          type: "warning",
-        })
-        .then(() => {
-          let params = [{
-            id: id,
-          }];
-          this.ajax
-            .post(this.$store.state.api + "deleteSoureFileType", params)
-            .then((res) => {
-              this.$message.success('删除成功');
-              this.showActionDiv = false
-              this.getData()
-            })
-            .catch((err) => {
-              console.error(err);
-            });
-        })
-        .catch(() => {
-        });
-    },
-    addFile(file) {
-      this.$emit('addFile', file)
     }
   },
   beforeDestroy() {
-    document.removeEventListener('click', this.handleClickOutside);
   },
   mounted() {
-    document.addEventListener('click', this.handleClickOutside);
     this.getData();
   },
 }
@@ -467,7 +225,7 @@ export default {
   overflow: auto;
 }
 
-.l_type_box>.nav>.nav_b {
+.l_type_box>.nav>.nav_b + .nav_b {
   margin-top: 10px;
 }
 
@@ -737,7 +495,9 @@ export default {
   background: #fff;
   height: 100%;
   border-radius: 5px;
-  overflow: hidden;
+  overflow: auto;
+  padding: 10px;
+  box-sizing: border-box;
 }
 
 .l_none {
@@ -748,4 +508,29 @@ export default {
   align-items: center;
   justify-content: center;
 }
+
+.bread_box{
+  padding: 15px 10px 0px;
+  width: 100%;
+  display: flex;
+  align-items: center;
+  box-sizing: border-box;
+}
+
+.bread_box > .bread{
+  font-size: 18px;
+  cursor: pointer;
+  color: #a1a1a1;
+}
+
+.bread_box > .bread.is{
+  color: #000;
+  cursor: default;
+}
+
+.bread_box > .bread + .bread::before{
+  content: '>';
+  font-size: 14px;
+  margin: 0 8px;
+}
 </style>