浏览代码

智能助手-修改

lzw 3 月之前
父节点
当前提交
e42581d0db
共有 1 个文件被更改,包括 511 次插入66 次删除
  1. 511 66
      src/components/pages/test/smarter.vue

+ 511 - 66
src/components/pages/test/smarter.vue

@@ -16,7 +16,7 @@
                         )
                         ">表单管理</span>
                     <!-- v-show="oid == '4c686762-1d0a-11ed-8c78-005056b86db5'" -->
-                    <span class="subClick"  @click="
+                    <span class="subClick" @click="
                         goTo(
                             '/trainCourse?userid=' +
                             userid +
@@ -42,7 +42,7 @@
                         ">数据看板</span>
                     <span class="sub_head">智能助手</span>
                 </div>
-                <div class="pb_head_t_right">
+                <!-- <div class="pb_head_t_right">
                     <el-tooltip class="item" effect="dark" content="预览" placement="bottom">
                         <span class="preview_icon"></span>
                     </el-tooltip>
@@ -52,58 +52,155 @@
                     <el-tooltip class="item" effect="dark" content="问题" placement="bottom">
                         <span class="problem_icon"></span>
                     </el-tooltip>
-                </div>
+                </div> -->
             </div>
         </div>
         <div class="cc_bottom">
-            <smartMenu></smartMenu>
-            <div class="cc_b_middle">
-                <div  style="width:100%;height: 100%;">
-                    <aiLeader :courseId="aiBoxRightCid" :worksArray="courseInfoList" ref="aiChat"
-                        @pushFileData="pushFileData" @clearFileData="clearFileData"></aiLeader>
+            <div class="cc_b_left">
+                <div class="menu_container">
+                    <div :class="['cc_b_l_menu', { active: activeMenu === 1 }]" @click="activeMenu = 1">
+                        <span :class="['session_icon', { active: activeMenu === 1 }]"></span>
+                        <div style="margin-left: 10px;margin-top: 1px;font-size: 15px;">当前会话</div>
+                    </div>
+                    <div :class="['cc_b_l_menu', { active: activeMenu === 2 }]" @click="activeMenu = 2">
+                        <span :class="['history_icon', { active: activeMenu === 2 }]"></span>
+                        <div style="margin-left: 10px;margin-top: 1px;font-size: 15px;">历史会话</div>
+                    </div>
+                    <!--<div :class="['cc_b_l_menu', { active: activeMenu === 3 }]" @click="activeMenu = 3">
+                            <span :class="['mysql_icon', { active: activeMenu === 3 }]"></span>
+                            <div style="margin-left: 10px;margin-top: 1px;font-size: 15px;">数据库管理</div>
+                        </div> -->
+                </div>
+                <div class="fold_btn">
+                    <span class="more_icon"></span>
                 </div>
             </div>
-            <div class="cc_b_right">
-                <div v-if="showFileUrl">
-                    <div class="cc_b_r_menu">
-                        <div v-for="(item, index) in menuList" @click="changeMenuIndex(index)" :key="index"
-                            :class="{ 'cc_b_r_menu_active': menuIndex == index }">
-                            <el-tooltip class="item" effect="dark" :content="item.name" placement="top">
-                                <span>{{ item.name }}</span>
-                            </el-tooltip>
-                            <!-- <div class="cc_b_r_btn"> -->
-                                <span class="close_icon" :class="{ active: menuIndex == index }" @click="deleteMenuItem(index)"></span>
-                            <!-- </div> -->
+            <div v-if="activeMenu == 1" style="width:100%;display: flex;">
+                <div class="cc_b_middle">
+                    <div style="width:100%;height: 100%;">
+                        <aiLeader :courseId="aiBoxRightCid" :worksArray="courseInfoList" ref="aiChat"
+                            @pushFileData="pushFileData" @clearFileData="clearFileData"></aiLeader>
+                    </div>
+                </div>
+                <div class="cc_b_right">
+                    <div v-if="showFileUrl">
+                        <div style="display: flex;">
+                            <div :class="['preview_file', { active: fileMenu === 1 }]" @click="fileMenu = 1">文档预览</div>
+                            <div :class="['bianji_file', { active: fileMenu === 2 }]" @click="fileMenu = 2">文档编辑</div>
+                        </div>
+                        <div v-if="fileMenu == 1" style="margin:10px;">
+                            <div class="cc_b_r_menu">
+                                <div v-for="(item, index) in menuList" @click="changeMenuIndex(index)" :key="index"
+                                    :class="{ 'cc_b_r_menu_active': menuIndex == index }">
+                                    <el-tooltip class="item" effect="dark" :content="item.name" placement="top">
+                                        <span>{{ item.name }}</span>
+                                    </el-tooltip>
+                                    <!-- <div class="cc_b_r_btn"> -->
+                                    <span class="close_icon" :class="{ active: menuIndex == index }"
+                                        @click="deleteMenuItem(index)"></span>
+                                    <!-- </div> -->
+                                </div>
+                            </div>
+                            <div class="cc_b_r_content" style="max-height: 700px; overflow-y: auto;">
+                                <csvTableView v-if="showFileUrl" :url="showFileUrl" />
+                            </div>
                         </div>
+                        <div v-if="fileMenu == 2">
+                            <div class="bianji_area">
+                                <span></span>
+                            </div>
+
+                        </div>
+
                     </div>
-                    <div class="cc_b_r_content">
-                        <csvTableView v-if="showFileUrl" :url="showFileUrl" />
+                    <div v-else style="margin: 40px 0px 0px 20px">
+                        <div>--官方能力演示--</div>
+                        <div class="b_r_menu">
+                            <div class="b_r_menu_content">
+                                <div class="m_c_title">数据处理</div>
+                                <div class="m_c_item">缺失值处理</div>
+                                <div class="m_c_item">无效样本处理</div>
+                                <div class="m_c_item">数据降维</div>
+                            </div>
+                            <div class="b_r_menu_content">
+                                <div class="m_c_title">数据分析</div>
+                                <div class="m_c_item">线性回归</div>
+                                <div class="m_c_item">相关性分析</div>
+                                <div class="m_c_item">关联分心</div>
+                            </div>
+                            <div class="b_r_menu_content">
+                                <div class="m_c_title">图标生成</div>
+                                <div class="m_c_item">箱线图</div>
+                                <div class="m_c_item">雷达图</div>
+                            </div>
+                        </div>
                     </div>
                 </div>
-                <div v-else  style="margin: 40px 0px 0px 20px">
-                    <div>--官方能力演示--</div>
-                    <div class="b_r_menu">
-                        <div class="b_r_menu_content">
-                            <div class="m_c_title">数据处理</div>
-                            <div class="m_c_item">缺失值处理</div>
-                            <div class="m_c_item">无效样本处理</div>
-                            <div class="m_c_item">数据降维</div>
-                        </div>
-                        <div class="b_r_menu_content">
-                            <div class="m_c_title">数据分析</div>
-                            <div class="m_c_item">线性回归</div>
-                            <div class="m_c_item">相关性分析</div>
-                            <div class="m_c_item">关联分心</div>
+            </div>
+            <div v-if="activeMenu == 2" style="width:100%;">
+                <div class="history_talk">
+                    <div class="h_t_head">
+                        <div class="t_h_left">
+                            <span style="font-weight: bold;font-size: 18px;">历史回溯</span>
+                            <span>共计{{ tableData.length }}个会话</span>
                         </div>
-                        <div class="b_r_menu_content">
-                            <div class="m_c_title">图标生成</div>
-                            <div class="m_c_item">箱线图</div>
-                            <div class="m_c_item">雷达图</div>
+                        <div class="t_h_right">
+                            <div style="margin-right: 10px;position: relative;">
+                                <el-input v-model="talkName" class="student_input" placeholder="检索会话名称"></el-input>
+                                <span class="serach_icon" @click="historyTalk()"></span>
+                            </div>
                         </div>
                     </div>
+                    <div class="h_t_table">
+                        <el-table :data="tableData" style="width: 100%">
+                            <el-table-column prop="name" label="会话名称" width="180">
+                            </el-table-column>
+                            <el-table-column prop="create_at" label="创建时间" width="180">
+                            </el-table-column>
+                            <el-table-column prop="update_at" label="更新时间">
+                            </el-table-column>
+                            <el-table-column prop="control" label="操作">
+                                <template slot-scope="scope">
+                                    <div style="display: flex;">
+                                        <div class="bianji">
+                                            <i class="el-icon-edit"></i>
+                                            <span @click="openUpdate(scope.row.name, scope.row.id)">重命名</span>
+                                        </div>
+                                        <div class="bianji">
+                                            <i class="el-icon-delete"></i>
+                                            <span @click="delete_talk(scope.row.id)">删除</span>
+                                        </div>
+                                    </div>
+                                </template>
+                            </el-table-column>
+                        </el-table>
+                    </div>
+                    <div class="h_t_bottom">
+                        <span>共{{ tableData.length }}条</span>
+                        <el-pagination background layout="prev, pager, next" :page-size="pageSize" :current-page="page"
+                            :total="total" @current-change="handleCurrentChange"></el-pagination>
+                        <!-- <el-select v-model="value" placeholder="请选择页数" size="mini" class="el_select">
+                            <el-option v-for="item in options" :key="item.value" :label="item.label"
+                                :value="item.value">
+                            </el-option>
+                        </el-select> -->
+                    </div>
+
                 </div>
             </div>
         </div>
+        <el-dialog title="修改会话名称" :visible.sync="dialogVisibleUpdate" :append-to-body="true" :before-close="handleClose"
+            class="dialog_diy">
+            <el-form>
+                <el-form-item label="会话名称" :label-width="formLabelWidth">
+                    <el-input v-model="talkName1" auto-complete="off" placeholder="请输入会话名称..."></el-input>
+                </el-form-item>
+            </el-form>
+            <span class="rename_btn">
+                <el-button @click="dialogVisibleUpdate = false">取 消</el-button>
+                <el-button type="primary" @click="UpdateTalkName()">确 定</el-button>
+            </span>
+        </el-dialog>
     </div>
 </template>
 
@@ -119,7 +216,7 @@ import radarTeacher from "./dataCom/radarTeacher.vue";
 import aiLeader from "./checkAi/aiLeader.vue";
 import txtView from "./choseCheck/txtView.vue";
 import Cascader from "./dataCom/cascader.vue";
-import smartMenu from "./smartBox/smartMenu.vue";
+// import smartMenu from "./smartBox/smartMenu.vue";
 import csvTableView from "./choseCheck/csvTableView.vue";
 
 
@@ -127,7 +224,7 @@ export default {
     name: 'smarter',
     components: {
         radarZong, radarTeacher, Cascader,
-        aiLeader, txtView, smartMenu, csvTableView
+        aiLeader, txtView, csvTableView
     },
     data() {
         return {
@@ -140,12 +237,97 @@ export default {
             menuList: [],
             menuIndex: 0,
             courseInfoList: [],
+            page: 1,
+            total: 0,
+            talkName: '',
+            talkName1: '',
+            chatId: '',
+            formLabelWidth: "100px",
+            pageSize: 9,
             loading: true,
             activeMenu: 1, // 默认激活第一个
-            examineData:[]
+            fileMenu: 1,
+            cutNumber: 1,
+            dialogVisibleUpdate: false,
+            examineData: [],
+            tableData: [],
+            options: [{
+                value: '1',
+                label: '20条/页'
+            }, {
+                value: '2',
+                label: '双皮奶'
+            }],
+            value: '1'
+
         };
     },
     methods: {
+        openUpdate(name, id) {
+            this.talkName1 = name;
+            this.chatId = id;
+            this.dialogVisibleUpdate = true;
+        },
+        UpdateTalkName() {
+            let params = [{
+                id: this.chatId,
+                name: this.talkName1,
+            }];
+            this.ajax
+                .post(this.$store.state.api + "updateChat", params)
+                .then(res => {
+                    if (this.talkName1 == '') {
+                        this.$message({
+                            message: "不能为空",
+                            type: "error",
+                        });
+                    } else {
+                        this.$message({
+                            message: "修改成功",
+                            type: "success",
+                        });
+                        this.dialogVisibleUpdate = false;
+                        this.historyTalk();
+                        this.talkName1 = '';
+                    }
+                })
+                .catch((err) => {
+                    console.error(err);
+                })
+        },
+        delete_talk(id) {
+            let params = [{
+                id: id
+            }]
+            this.$confirm("确定删除此会话吗?", "提示", {
+                confirmButtonText: "确定",
+                cancelButtonText: "取消",
+                type: "warning",
+            })
+                .then(() => {
+                    this.ajax
+                        .post(this.$store.state.api + "deleteChat", params)
+                        .then((res) => {
+                            this.$message({
+                                message: "删除成功",
+                                type: "success",
+                            });
+                            this.historyTalk();
+                        })
+                        .catch((err) => {
+                            this.$message.error("删除失败");
+                            console.error(err);
+                        });
+                })
+                .catch(() => { });
+        },
+        handleCurrentChange(newPage) {
+            this.page = newPage;
+            this.historyTalk();
+        },
+        handleClose(done) {
+            done();
+        },
         // 获取基础页面数据
         getPageBase() {
             let params = {
@@ -157,11 +339,11 @@ export default {
             this.ajax
                 .get(this.$store.state.api + "selectTestExamineBase", params)
                 .then(res => {
-                    console.log('selectTestExamineBase',res.data[0]);
-                    this.examineData=res.data[0]
+                    console.log('selectTestExamineBase', res.data[0]);
+                    this.examineData = res.data[0]
                 })
                 .catch(error => {
-                console.log(error);
+                    console.log(error);
                 });
         },
         deleteMenuItem(index) {
@@ -169,13 +351,36 @@ export default {
             this.menuIndex = 0
             this.$refs.aiChat.delFileList(index)
             this.$forceUpdate()
-            console.log('menuList',this.menuList);
-            
+            console.log('menuList', this.menuList);
+
+        },
+
+        historyTalk() {
+            let params = {
+                uid: this.userid,
+                n: this.talkName,
+                page: this.page,
+                num: this.pageSize
+            };
+            this.ajax
+                .get(this.$store.state.api + "getChatHistory", params)
+                .then((res) => {
+                    this.tableData = res.data[0]
+                    console.log("tableData", this.tableData);
+                    this.total = res.data[0].length > 0 ? res.data[0][0].num : 0;
+                    console.log("111111", this.total);
+
+
+                })
+                .catch((err) => {
+                    console.error(err);
+                });
         },
         pushFileData(data) {
             this.menuList.push(data)
             console.log("menuList", this.menuList);
 
+
         },
         clearFileData() {
             this.menuList = []
@@ -195,10 +400,13 @@ export default {
                     promiseList.push(this.getCourseData(el))
                 })
                 Promise.all(promiseList).then(res => {
-                    console.log("courseInfoList", this.courseInfoList)
                     this.courseInfoList = res
+                    console.log("courseInfoList", this.courseInfoList)
                     this.loading = false
-                })
+                }).catch(err => {
+                    console.error("Error occurred:", err);
+                    this.loading = false;  // 如果有错误,也要停止loading
+                });
             }
         },
         getCourseData(courseId) {
@@ -294,6 +502,7 @@ export default {
                     });
             })
         },
+
     },
     computed: {
         showFileUrl() {
@@ -311,15 +520,27 @@ export default {
                 _cidList.sort((a, b) => parseInt(b) - parseInt(a));
                 _result = _cidList.join(',');
             }
+            console.log("我是cid", _result);
 
             return _result
         }
     },
     mounted() {
         this.getData();
-        this.getPageBase()
+        this.getPageBase();
+        this.historyTalk();
+
+    },
+    watch: {
+        activeMenu(newValue) {
+            if (newValue === 2) {
+                console.log("HelloWorld");
+                this.historyTalk();
+            }
+        },
     }
 
+
 };
 </script>
 
@@ -531,6 +752,31 @@ export default {
     -moz-osx-font-smoothing: grayscale;
 }
 
+.dialog_diy>>>.el-dialog__header {
+    background: #3d67bc !important;
+    padding: 15px 20px;
+}
+
+.dialog_diy>>>.el-dialog__title {
+    color: #fff;
+}
+
+.student_table>>>.el-table--border td {
+    border-right: 0px !important;
+}
+
+.dialog_diy>>>.el-dialog__headerbtn {
+    top: 19px;
+}
+
+.dialog_diy>>>.el-dialog__headerbtn .el-dialog__close {
+    color: #fff;
+}
+
+.dialog_diy>>>.el-dialog__headerbtn .el-dialog__close:hover {
+    color: #fff;
+}
+
 .cc_bottom {
     width: 100%;
     height: calc(100% - 66px - 10px);
@@ -551,12 +797,125 @@ export default {
     height: 100%;
 }
 
+.cc_b_left {
+    border-right: 1px solid #E4E7ED;
+    display: flex;
+    flex-direction: column;
+    justify-content: space-between;
+    height: 100%;
+    width: 13%;
+}
+
+.menu_container {
+    flex: 1;
+    /* 占据除折叠按钮外的所有空间 */
+}
+
+.cc_b_l_menu {
+    padding: 10px;
+    margin: 17px;
+    border-radius: 7px;
+    color: #828282;
+    cursor: pointer;
+    display: flex;
+}
+
+.cc_b_l_menu.active {
+    background-color: #3681fc;
+    color: #fff;
+
+}
+
+.session_icon {
+    background: url('../../../assets/icon/test/test_session.png') no-repeat;
+    width: 18px;
+    height: 18px;
+    display: inline-block;
+    background-size: contain;
+}
+
+.session_icon.active {
+    background: url('../../../assets/icon/test/test_session_active.png') no-repeat;
+    width: 18px;
+    height: 18px;
+    display: inline-block;
+    background-size: contain;
+}
+
+.history_icon {
+    background: url('../../../assets/icon/test/test_history.png') no-repeat;
+    width: 18px;
+    height: 18px;
+    display: inline-block;
+    background-size: contain;
+}
+
+.history_icon.active {
+    background: url('../../../assets/icon/test/test_history_active.png') no-repeat;
+    width: 18px;
+    height: 18px;
+    display: inline-block;
+    background-size: contain;
+}
+
+/* .mysql_icon{
+    background:url('../../../../assets/icon/test/test_mysql.png') no-repeat;
+    width: 18px;
+    height: 18px;
+    display: inline-block;
+    background-size: contain;
+}
+.mysql_icon.active{
+    background:url('../../../../assets/icon/test/test_mysql_active.png') no-repeat;
+    width: 18px;
+    height: 18px;
+    display: inline-block;
+    background-size: contain;
+} */
+.fold_btn {
+    padding: 27px 20px;
+    cursor: pointer;
+    border-top: 1px solid #E4E7ED;
+    margin-top: auto;
+    /* 确保折叠按钮在底部 */
+}
+
+.more_icon {
+    background: url('../../../assets/icon/test/test_more.png') no-repeat;
+    width: 14px;
+    height: 14px;
+    display: inline-block;
+    background-size: contain;
+    cursor: pointer;
+}
+
 .cc_b_right {
     width: 50%;
     height: 100%;
     box-sizing: border-box;
 }
 
+.preview_file,
+.bianji_file {
+    margin: 10px;
+    width: 65px;
+    cursor: pointer;
+}
+
+.preview_file.active {
+    border-bottom: 2px solid blue;
+}
+
+.bianji_file.active {
+    border-bottom: 2px solid blue;
+}
+
+.bianji_area {
+    background-color: #e5e4e4;
+    height: 600px;
+    margin: 10px;
+}
+
 .cc_b_r_menu {
     width: 100%;
     height: 50px;
@@ -569,15 +928,15 @@ export default {
 
 .cc_b_r_menu>div {
     height: 100%;
-	max-width: 100px;
-	padding: 0 15px;
-	display: flex;
-	text-align: center;
-	/* justify-content: center; */
-	align-items: center;
-	cursor: pointer;
-	transition: all 0.3s;
-	/* text-overflow: ellipsis;
+    max-width: 100px;
+    padding: 0 15px;
+    display: flex;
+    text-align: center;
+    /* justify-content: center; */
+    align-items: center;
+    cursor: pointer;
+    transition: all 0.3s;
+    /* text-overflow: ellipsis;
 	overflow: hidden;
 	white-space: nowrap; */
 }
@@ -602,18 +961,21 @@ export default {
     width: 100%;
     height: calc(100% - 50px);
 }
-.cc_b_r_btn{
+
+.cc_b_r_btn {
     display: flex;
     align-items: center;
 }
-.close_icon{
+
+.close_icon {
     width: 0 !important;
     height: 22px;
     display: inline-block;
     background-size: contain;
     cursor: pointer;
 }
-.close_icon.active{
+
+.close_icon.active {
     background: url('../../../assets/icon/test/test_close_active.png') no-repeat;
     width: 40px !important;
     height: 22px;
@@ -621,11 +983,13 @@ export default {
     background-size: contain;
     cursor: pointer;
 }
-.b_r_menu{
+
+.b_r_menu {
     display: flex;
     justify-content: space-around;
 }
-.b_r_menu_content{
+
+.b_r_menu_content {
     display: flex;
     flex-direction: column;
     background: linear-gradient(to bottom, #dfeaff, #ffffff, #f6f9ff);
@@ -634,15 +998,96 @@ export default {
     width: 50%;
     margin-right: 14px
 }
-.m_c_title{
+
+.m_c_title {
     margin: 10px 7px 7px 21px;
     font-size: 16px;
     font-weight: bold;
 }
-.m_c_item{
+
+.m_c_item {
     border-radius: 5px;
     padding: 8px 8px 8px 13px;
     margin: 7px;
     border: 1px solid #E4E7ED;
 }
+
+.history_talk {
+    background: linear-gradient(to bottom, #dfeaff, #ffffff, #f6f9ff);
+    margin: 10px;
+    padding: 10px;
+}
+
+.h_t_head {
+    display: flex;
+    justify-content: space-between;
+}
+
+.t_h_left {
+    margin-left: 13px;
+    font-size: 13px;
+}
+
+.h_t_table {
+    margin: 10px;
+    box-shadow: 0px 0px 12px rgb(190 193 199);
+}
+
+.bianji {
+    display: flex;
+    align-items: center;
+    margin-right: 10px;
+}
+
+.bianji:hover {
+    color: rgb(14, 173, 236);
+    cursor: pointer;
+}
+
+.rename_btn {
+    display: flex;
+    justify-content: flex-end;
+}
+
+.h_t_bottom {
+    display: flex;
+    justify-content: flex-end;
+    align-items: center;
+    margin-right: 9px;
+}
+
+.el_select {
+    width: 89px;
+}
+
+
+.table_title {
+    background-color: gray;
+}
+
+.student_input>>>.el-input__inner {
+    height: 30px;
+    width: 179px;
+    font-size: 13px;
+    padding: 0 10px;
+}
+
+.serach_icon {
+    position: absolute;
+    right: 12px;
+    top: 50%;
+    transform: translateY(-50%);
+    width: 13px;
+    height: 13px;
+    background: url("../../../assets/icon/test/test_search.png") no-repeat;
+    background-size: 100% 100%;
+    cursor: pointer;
+}
+
+.el-input {
+    position: relative;
+    font-size: 14px;
+    display: inline-block;
+    width: 100%;
+}
 </style>