SanHQin 11 mesiacov pred
rodič
commit
f7fdbb55ff

+ 1 - 1
src/common/axios.config.js

@@ -28,7 +28,7 @@ axios.interceptors.request.use((config) => {
     // }
     if (config.url === 'https://gpt.cocorobo.cn/search_image' || config.url === 'https://gpt.cocorobo.cn/chat' || config.url === 'https://gpt4.cocorobo.cn/create_free_assistants' || config.url === 'https://gpt4.cocorobo.cn/assistants_completion_response') {
         config.data = config.data//序列化post 参数
-    } else if (config.url.indexOf('https://gpt4.cocorobo.cn/') != -1 || config.url.indexOf('https://claude3.cocorobo.cn/') != -1 || config.url.indexOf('https://llm.cocorobo.cn/') != -1) {
+    } else if (config.url.indexOf('https://gpt4.cocorobo.cn/') != -1 || config.url.indexOf('https://claude3.cocorobo.cn/') != -1 || config.url.indexOf('https://llm.cocorobo.cn/') != -1 || config.url.indexOf('http://gpt4.cocorobo.cn/') != -1) {
         config.headers = {
             'Content-Type': 'application/json',
         }

+ 1 - 1
src/components/pages/test/add/edit/check/index.vue

@@ -14,7 +14,7 @@
             <evaV :tindex="index" :cJson.sync="item.json" v-if="item.type == 7"></evaV>
             <timeV :tindex="index" :cJson.sync="item.json" v-if="item.type == 8"></timeV>
             <courseV2 :tindex="index" :cJson.sync="item.json" v-if="item.type == 11"></courseV2>
-            <span v-else>暂未设置题目</span>
+            <!-- <span v-else>暂未设置题目</span> -->
           </div>
           <div v-for="(item2, index2) in item.array" :key="`${index}-${index2}`" class="check_box_xia">
             <div class="title" v-if="item2.ttype != 1 || (!item2.json && item2.ttype == 1)" :style="{fontSize:item2.ttype == 1 && '16px'}">{{ selectType(item2, index2) }}</div>

+ 146 - 71
src/components/pages/test/check/aiBoxRight.vue

@@ -207,7 +207,13 @@
         :disabled="isVoice"
         ref="textareaRef"
         v-model.trim="courseText"
-        :placeholder="isVoice ? isTalk?'':'点击按钮开始录音' : '在此输入您想了解的内容'"
+        :placeholder="
+          isVoice
+            ? isTalk
+              ? ''
+              : '点击按钮开始录音'
+            : '在此输入您想了解的内容'
+        "
       ></textarea>
 
       <span
@@ -322,7 +328,7 @@
         终止
       </div>
     </div>
-		<iframe
+    <iframe
       allow="camera *; microphone *;display-capture;midi;encrypted-media;"
       src="https://beta.cloud.cocorobo.cn/browser/public/index.html"
       ref="iiframe"
@@ -480,10 +486,11 @@ export default {
         8: "日期",
         9: "单选题",
         10: "多选题",
-        11: "课程",
+        11: "课程"
       },
       answerArray: [],
-      fileId: []
+      fileId: [],
+      fileList: []
     };
   },
   watch: {
@@ -501,18 +508,19 @@ export default {
         }
       }
     },
-    worksArray :{
+    worksArray: {
       immediate: true,
       deep: true,
       handler(newValue, oldValue) {
         if (newValue.length) {
-          console.log('newValue',newValue);
-					this.$emit("clearFileData")
-					this.fileId = [];
-					newValue.forEach(el=>{
-						this.setJson(el)
-					})
-					// console.log("👈👉",newValue)
+          console.log("newValue", newValue);
+          this.$emit("clearFileData");
+          this.fileId = [];
+					this.fileList = [];
+          newValue.forEach(el => {
+            this.setJson(el);
+          });
+          // console.log("👈👉",newValue)
           // this.setJson(newValue)
         }
       }
@@ -566,42 +574,51 @@ export default {
     //   // 如果仍需要上传文件,可以保留这行
     //   return this.uploadFile(blob);
     // },
-    setJson(obj){
-			let array = obj.worksArray
-			let name = obj.name
-			console.log(obj)
-			console.log(array)
+    setJson(obj) {
+      let array = obj.worksArray;
+      let name = obj.name;
 
-      const getAnswer = (j) => {
+      const getAnswer = j => {
         if (j.type === 1) {
           return j.json.array
             .filter((_, idx) => j.json.answer2.includes(idx))
             .map(item => `${item.img}${item.option}`)
-            .join(',');
-        } else if (j.type === 3 || j.type === 6 || j.type === 7 || j.type === 8 || j.type === 11) {
+            .join(",");
+        } else if (
+          j.type === 3 ||
+          j.type === 6 ||
+          j.type === 7 ||
+          j.type === 8 ||
+          j.type === 11
+        ) {
           console.log(j.json);
-          return typeof j.json.answer2 === 'string' ? j.json.answer2.replace(/\n/g, ' ') : j.json.answer2;
+          return typeof j.json.answer2 === "string"
+            ? j.json.answer2.replace(/\n/g, " ")
+            : j.json.answer2;
         } else if (j.type === 5) {
           if (!Array.isArray(j.json.file) || j.json.file.length === 0) {
-            return '无附件';
+            return "无附件";
           }
-          return j.json.file.map(file => `${file.name}(${file.url})`).join(',');
+          return j.json.file
+            .map(file => `${file.name}(${file.url})`)
+            .join(",");
         } else {
-          return '';
+          return "";
         }
       };
 
       // 获取所有题目类型和题目
       const questions = array[0].array.map((j, index) => ({
-        "序号": index + 1,
-        "题目类型": this.options2[j.type],
-        "题目": j.json.title
+        序号: index + 1,
+        题目类型: this.options2[j.type],
+        题目: j.json.title
       }));
 
-			console.log(questions)
-
+      console.log(questions);
+			// let csvContent = "data:text/csv;charset=utf-8,"
       // 构建CSV内容
-      let csvContent = "用户名 | 提交时间 | " + questions.map(q => `${q.序号}-${q.题目类型}-${q.题目}`).join(' | ') + "\n";
+      // let csvContent = "用户名 | 提交时间 | " + questions.map(q => `${q.序号}-${q.题目类型}-${q.题目}`).join(' | ') + "\n";
+      let csvContent = "用户名,提交时间,"+ questions.map(q => `${q.序号}-${q.题目类型}-${q.题目}`).join(",") +"\n";
 
       // 添加每个用户的答案
       array.forEach(i => {
@@ -609,18 +626,24 @@ export default {
         i.array.forEach(j => {
           row.push(getAnswer(j));
         });
-        csvContent += row.join(' | ') + "\n";
+        // csvContent += row.join(' | ') + "\n";
+        csvContent += row.join(",") + "\n";
       });
 
       // 创建Blob对象
-      const blob = new Blob([csvContent], { type: "text/plain;charset=utf-8" });
+      // const blob = new Blob([csvContent], { type: "text/plain;charset=utf-8" });
+      // blob.lastModifiedDate = new Date();
+      // blob.name = `${name}_表单数据.txt`;
+
+      // 创建Blob对象
+      const blob = new Blob([csvContent], { type: "text/csv;charset=utf-8" });
       blob.lastModifiedDate = new Date();
-      blob.name = `${name}_表单数据.txt`;
+      blob.name = `${name}_表单数据.csv`;
 
       // 如果仍需要上传文件,可以保留这行
-      return this.uploadFile({file:blob,name:name});
+      return this.uploadFile({ file: blob, name: name });
     },
-    uploadFile({file,name}) {
+    uploadFile({ file, name }) {
       var credentials = {
         accessKeyId: "AKIATLPEDU37QV5CHLMH",
         secretAccessKey: "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"
@@ -670,11 +693,15 @@ export default {
                   let _data = res.data.FunctionResponse;
                   if (_data.result && _data.result.id) {
                     _this.fileId.push(_data.result.id);
-										_this.$emit("pushFileData",{fileId:_data.result.id,name:name,url:data.Location})
+                    _this.fileList.push(data.Location);
+                    _this.$emit("pushFileData", {
+                      fileId: _data.result.id,
+                      name: name,
+                      url: data.Location
+                    });
                   } else {
                     console.error("获取fileId失败");
                   }
-
                 })
                 .catch(e => {
                   console.log(e);
@@ -802,9 +829,33 @@ export default {
               model: "qwen-plus"
             };
 
+            // let params = {
+            //   prompt: _replaceText,
+            //   message: [],
+            //   file: this.fileId ? this.fileId : []
+            // };
+
             this.ajax
               .post("https://gpt4.cocorobo.cn/ai_agent_park_chat_new", params)
+              // .post("http://gpt4.cocorobo.cn/csvaimessage", params)
               .then(res => {
+                // let data = res.FunctionResponse;
+                // const md = new MarkdownIt();
+                // const text = md.render(data);
+                // this.array.find(i => i.uid == _uid).aiContent = text;
+                // this.array.find(i => i.uid == _uid).isalltext = true;
+                // this.array.find(
+                //   i => i.uid == _uid
+                // ).isShowSynchronization = true;
+                // this.array.find(i => i.uid == _uid).loading = false;
+                // this.$nextTick(() => {
+                //   this.$refs.chatDialog.scrollTop = this.$refs.chatDialog.scrollHeight;
+                // });
+                // this.fasource.close();
+                // this.fasource = null;
+                // if (this.courseId) {
+                //   this.insertChat(_uid);
+                // }
                 if (
                   converter(res.data.FunctionResponse.result) ==
                   converter("发送成功")
@@ -890,35 +941,58 @@ export default {
           //     console.log(e);
           //   });
           // this.getAiContent(_uuid);\
+          // let params = {
+          //   assistant_id: "cd72354e-7be5-11ef-a263-12e77c4cb76b",
+          //   userId: this.userid,
+          //   message: `Role: 你是数据检索大师,可以利用file_search的方式完整的去分析文件内容 Language: Please use the same language as the user requirement, if the user speaks Chinese, the specific text of your answer should also be in Chinese.\n${message}`,
+          //   session_name: `${this.courseId}-${this.userid}-test`,
+          //   uid: _uuid,
+          //   file_ids: this.fileId ? this.fileId : [],
+          //   model: "gpt-4o-mini"
+          // };
+
           let params = {
-            assistant_id: 'cd72354e-7be5-11ef-a263-12e77c4cb76b',
-            userId: this.userid,
-            message: `Role: 你是数据检索大师,可以利用file_search的方式完整的去分析文件内容 Language: Please use the same language as the user requirement, if the user speaks Chinese, the specific text of your answer should also be in Chinese.\n${message}`,
-            session_name: `${this.courseId}-${this.userid}-test`,
-            uid: _uuid,
-            file_ids: this.fileId ? this.fileId : [],
-            model: "gpt-4o-mini"
+            prompt: message,
+            messages: [],
+            file: this.fileList ? this.fileList : []
           };
           this.$nextTick(() => {
             this.$refs.chatDialog.scrollTop = this.$refs.chatDialog.scrollHeight;
           });
           this.courseText = "";
           this.ajax
-            .post("https://gpt4.cocorobo.cn/ai_agent_park_chat_new", params)
+            // .post("https://gpt4.cocorobo.cn/ai_agent_park_chat_new", params)
+            .post("http://gpt4.cocorobo.cn/csvaimessage", params)
             .then(res => {
-              if (
-                converter(res.data.FunctionResponse.result) ==
-                converter("发送成功")
-              ) {
-              } else {
-                this.$message.warning(res.data.FunctionResponse.result);
+              // if (
+              //   converter(res.data.FunctionResponse.result) ==
+              //   converter("发送成功")
+              // ) {
+              // } else {
+              //   this.$message.warning(res.data.FunctionResponse.result);
+              // }
+              console.log(res);
+              let data = res.data.FunctionResponse;
+              console.log(data);
+              const md = new MarkdownIt();
+              const text = md.render(data);
+              this.array.find(i => i.uid == _uuid).aiContent = text;
+              this.array.find(i => i.uid == _uuid).isalltext = true;
+              this.array.find(i => i.uid == _uuid).isShowSynchronization = true;
+              this.array.find(i => i.uid == _uuid).loading = false;
+              this.$nextTick(() => {
+                this.$refs.chatDialog.scrollTop = this.$refs.chatDialog.scrollHeight;
+              });
+              if (this.courseId) {
+                this.insertChat(_uuid);
+								this.saveUid = _uuid;
               }
             })
             .catch(err => {
               console.log(err);
             });
-          this.getAtAuContent(_uuid);
-          this.saveUid = _uuid;
+          // this.getAtAuContent(_uuid);
+          // this.saveUid = _uuid;
         }
       }
     },
@@ -1026,7 +1100,10 @@ export default {
     async getUserName() {
       let params = { uid: this.userid };
       try {
-        let res = await this.ajax.get(this.$store.state.api + "getUser", params);
+        let res = await this.ajax.get(
+          this.$store.state.api + "getUser",
+          params
+        );
         this.username = res.data[0][0].name;
       } catch (err) {
         console.error(err);
@@ -1035,10 +1112,10 @@ export default {
     //保存消息
     async insertChat(_uid) {
       let _data = this.array.find(i => i.uid == _uid);
-      this.saveUid = ''
-      this.faloading = false
-      if(!this.username){
-        await this.getUserName()
+      this.saveUid = "";
+      this.faloading = false;
+      if (!this.username) {
+        await this.getUserName();
       }
       if (!_data) return;
       let params = {
@@ -1103,10 +1180,8 @@ export default {
                 content: "",
                 uid: _uid,
                 AI: "AI",
-                aiContent:
-                  "您好,我是您的助手小可",
-                oldContent:
-                  "您好,我是您的助手小可",
+                aiContent: "您好,我是您的助手小可",
+                oldContent: "您好,我是您的助手小可",
                 isShowSynchronization: false,
                 filename: "",
                 index: 0,
@@ -1351,7 +1426,7 @@ export default {
       this.isVoice = flag;
     },
     startVoice() {
-			let iiframe = this.$refs["iiframe"];
+      let iiframe = this.$refs["iiframe"];
       iiframe.contentWindow.window.document.getElementById(
         "languageOptions"
       ).selectedIndex = 2; //普通话
@@ -1363,8 +1438,8 @@ export default {
         if (_msg) this.courseText += _msg;
       };
     },
-		stopVoice(){
-			try {
+    stopVoice() {
+      try {
         if (!this.isTalk) return this.$message.info("请先开始录音");
         let iiframe = this.$refs["iiframe"];
         iiframe.contentWindow.window.document
@@ -1383,7 +1458,7 @@ export default {
           this.addContent();
         }
       }
-		}
+    }
   },
   computed: {
     pan() {
@@ -1432,9 +1507,9 @@ export default {
     //   });
     // });
     // if(this.worksArray.length){
-		// 	this.worksArray.forEach(el=>{
-		// 		this.setJson(el)
-		// 	})
+    // 	this.worksArray.forEach(el=>{
+    // 		this.setJson(el)
+    // 	})
     // }
     this.getRoleList();
     this.getPublicRoleList();
@@ -1446,8 +1521,8 @@ export default {
 .ai_body {
   /* height: calc(100% - 158px - 46px);
   width: 500px; */
-	height: 100%;
-	width: 100%;
+  height: 100%;
+  width: 100%;
   /* margin: 0 auto; */
   display: flex;
   flex-direction: column;

+ 158 - 0
src/components/pages/test/choseCheck/csvTableView.vue

@@ -0,0 +1,158 @@
+<template>
+  <div class="txtView" v-loading="loading">
+		<el-table :data="tableData" border style="width: 100%;height: 100%;" :header-cell-style="{ background: '#f1f1f1', fontSize: '16px' }" :fit="true" >
+			<el-table-column  :fixed="[].includes(index)" :label="item.label" :prop="item.label" v-for="(item,index) in columnList" :key="item"></el-table-column>
+		</el-table>
+		<!-- <div class="tv_content" v-text="content"></div> -->
+	</div>
+</template>
+
+<script>
+import "../../../../common/aws-sdk-2.235.1.min.js";
+
+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]
+    );
+    var params = {
+      Bucket: "ccrb",
+      Key: name
+    };
+    s3.getObject(params, function(err, data) {
+      if (err) {
+        console.log(err, err.stack);
+        resolve({ data: 1 });
+      } else {
+        const fileContent = data.Body.toString("utf-8");
+        resolve({ data: fileContent });
+      } // sxuccessful response
+    });
+    // axios({
+  });
+};
+export default {
+  props: {
+    url: {
+      type: String,
+      default: ""
+    },
+  },
+	data(){
+		return{
+			content:"",
+			loading:true,
+			tableData:[],
+			columnList:[],
+		}
+	},
+	methods: {
+		getTxtContent() {
+			if(!this.url)return;
+			this.loading = true;
+			getFile(this.url).then(res=>{
+				this.loading = false;
+				let tableDataObj = this.formatCSVToTable(res.data);
+				this.tableData = tableDataObj;
+				let column = [];
+				for(let i in tableDataObj[0]){
+				  column.push({
+						label:i,
+						prop:i
+					})
+				}
+				this.columnList = column;
+				this.content = res.data;
+			})
+		},
+		formatCSVToTable(str){
+      const result = [];
+      const jsonObj = str.split("\n");
+      let arrHeader = [];
+      for (const i in jsonObj) {
+        if (typeof jsonObj[i] === 'string' && jsonObj[i].length > 0) {
+          const row = `${jsonObj[i]}`;
+          if (row.trim().length > 0) {
+            const kv = jsonObj[i].split(',');
+            if (i == 0) {
+              // 获取column表头
+              arrHeader = kv;
+            } else {
+              const obj = {};
+              for (let index = 0; index < arrHeader.length; index++) {
+                // 组装表格数据
+                const name = String(arrHeader[index]);
+                if (!arrHeader[index]) continue
+                if (!obj[name]) {
+                  try {
+                    if (kv[index]) {
+                      obj[name] = String(kv[index]);
+                    } else {
+                      obj[name] = '';
+                    }
+                  } catch (err) {
+                    obj[name] = '';
+                  }
+                }
+              }
+              result.push(obj);
+            }
+          }
+        }
+      }
+      return result
+    }
+	},
+	watch:{
+		url(newVal,oldVal){
+			if(newVal!==oldVal){
+				this.getTxtContent();
+			}
+		}
+	},
+	mounted(){
+		this.getTxtContent();
+	}
+};
+</script>
+
+<style scoped>
+.txtView{
+	width: 100%;
+	height: 100%;
+	box-sizing: border-box;
+	background-color: #ececec;
+	padding: 0px 0px;
+}
+
+.tv_content{
+	width: 100%;
+	height: 100%;
+	box-sizing: border-box;
+	background-color: #fff;
+	overflow: auto;
+	word-wrap: break-word;
+	border-radius: 3px;
+	white-space: pre;
+	box-sizing: border-box;
+	padding: 10px;
+}
+</style>

+ 13 - 2
src/components/pages/test/choseCheck/index.vue

@@ -43,7 +43,16 @@
 					
 				</div>
 				<div class="cc_b_r_content">
-					<txtView v-if="showFileUrl" :url="showFileUrl"></txtView>
+					<!-- <iframe
+        ref="viframe"
+        v-if="showFileUrl"
+        style="width: 100%; height: 100%; border: none"
+        :src="showFileUrl"
+      ></iframe> -->
+			<!-- 'https://view.officeapps.live.com/op/view.aspx?src=' +
+			encodeURIComponent(showFileUrl) -->
+					<!-- <txtView v-if="showFileUrl" :url="showFileUrl"></txtView> -->
+					 <csvTableView v-if="showFileUrl" :url="showFileUrl"/>
 				</div>
 			</div>
 		</div>
@@ -53,11 +62,13 @@
 <script>
 import aiBoxRight from '../check/aiBoxRight.vue';
 import txtView from './txtView.vue';
+import csvTableView from './csvTableView.vue';
 export default {
   name: "ChoseCheck",
 	components:{
 		aiBoxRight,
-		txtView
+		txtView,
+		csvTableView
 	},
   data() {
     return {