Browse Source

OA新版本

zhuliu 1 month ago
parent
commit
e2924161e6

+ 22 - 0
src/api/newApi/AI.js

@@ -26,4 +26,26 @@ export default {
     generateInstruction(data) {
         return axios.post("/xiaoshi/dify/generateInstruction", data);
     },
+
+
+    /**
+     * 保存会话记录
+     */
+    saveChatRecord(data) {
+        return axios.post("/chatRecord/saveChatRecord", data);
+    },
+    /**
+     * 查询会话记录
+     */
+    queryChatRecord(data) {
+        return axios.post("/chatRecord/queryChatRecord", data);
+    },
+    /**
+     * 导出
+     */
+    exportResultFiles(data) {
+        return axios.post("/chatRecord/exportResultFiles", data);
+    },
+
+    
 }

File diff suppressed because it is too large
+ 897 - 123
src/views/AITools/OADefense/OADefense.vue


File diff suppressed because it is too large
+ 928 - 429
src/views/AITools/OADefense/OADefense1.vue


File diff suppressed because it is too large
+ 1255 - 0
src/views/AITools/OADefense/OADefense2.vue


+ 72 - 75
src/views/AITools/OADefense/dialog/errorTip.vue

@@ -12,22 +12,21 @@
             <div>
                 <myUpload :file-list="patent_fileUrls" @on-change="onchangeFile" @on-remove="onRemove" style="height: 180px;" :autoUpload="true"></myUpload>
             </div> -->
-            <div style="overflow-y: auto;overflow-x:hidden">
-                <template v-if="relevant_file.app_file">
-                    <div>
-                        <p class="file_title">本申请文件</p>
-                        <div class="upload_file">
-                            <div v-if="relevant_file.app_file.guid" class="file_show">
-                                <myTooltip :content="relevant_file.app_file.name ? relevant_file.app_file.name : relevant_file.app_file.originalName">
-                                    <div class="noWrap file_name">
-                                        <i class="el-icon-document" style="margin-right: 10px"></i>
-                                        <span class="name">{{relevant_file.app_file.name ? relevant_file.app_file.name : relevant_file.app_file.originalName}}</span>
-                                    </div>
-                                </myTooltip>
-                                <div class="type">{{ relevant_file.app_file.guid ? "已上传" : "待上传" }}</div>
-                                <div class="icon" @click="relevant_file.app_file = {}">
-                                    <i class="el-icon-close"></i>
+            <div style="overflow-y: auto;overflow-x:hidden;margin-top:10px">
+                <div class="upload-group">
+                    <div class="upload-group-title">
+                        <div>上传文件(可拖动上传)</div>
+                    </div>
+                    <div class="upload-box-container">
+                        <!-- 本申请文件 -->
+                        <div v-if="relevant_file.app_file">
+                            <div v-if="relevant_file.app_file.showPercentage || relevant_file.app_file.guid" class="upload-box">
+                                <div class="upload-placeholder">本申请文件</div>
+                                <div class="file-info"><span v-if="!relevant_file.app_file.showPercentage">已上传:</span><span class="file-name">{{relevant_file.app_file.name ? relevant_file.app_file.name : relevant_file.app_file.originalName}}</span></div>
+                                <div v-if="relevant_file.app_file.showPercentage" class="progressShow">
+                                    <el-progress :percentage="relevant_file.app_file.percentage"></el-progress>
                                 </div>
+                                <span class="clear-btn" @click="relevant_file.app_file = {}">× 清除</span>
                             </div>
                             <el-upload
                                 v-else
@@ -36,34 +35,27 @@
                                 drag
                                 action="#"
                                 :auto-upload="false"
+                                :show-file-list='false'
                                 :limit="1"
                                 :on-change="(file)=>onChange(file,'relevant_file.app_file')"
                                 style="width: 100%"
                             >
-                                <i class="el-icon-upload"></i>
                                 <div class="el-upload__text">
-                                    <div><em>点击上传</em></div>
-                                    <div>或将文件拖到此处上传</div>
+                                    <div class="upload-placeholder">本申请文件</div>
+                                    <div class="upload-placeholder">点击或拖拽上传</div>
+                                    <div class="red file-info margin-top_0">注:本申请未被公开则需要上传</div>
                                 </div>
                             </el-upload>
                         </div>
-                    </div>
-                </template>
-                <template v-if="relevant_file.modify_file">
-                    <div>
-                        <p class="file_title">上一次OA的修改对照页</p>
-                        <div class="upload_file">
-                            <div v-if="relevant_file.modify_file.guid" class="file_show">
-                                <myTooltip :content="relevant_file.modify_file.name ? relevant_file.modify_file.name : relevant_file.modify_file.originalName">
-                                    <div class="noWrap file_name">
-                                        <i class="el-icon-document" style="margin-right: 10px"></i>
-                                        <span class="name">{{relevant_file.modify_file.name ? relevant_file.modify_file.name : relevant_file.modify_file.originalName}}</span>
-                                    </div>
-                                </myTooltip>
-                                <div class="type">{{ relevant_file.modify_file.guid ? "已上传" : "待上传" }}</div>
-                                <div class="icon" @click="relevant_file.modify_file = {}">
-                                    <i class="el-icon-close"></i>
+                        <!-- 修改对照页 -->
+                        <div v-if="relevant_file.modify_file">
+                            <div v-if="relevant_file.modify_file.showPercentage || relevant_file.modify_file.guid" class="upload-box">
+                                <div class="upload-placeholder">上一次OA修改对照页</div>
+                                <div class="file-info"><span v-if="!relevant_file.modify_file.showPercentage">已上传:</span><span class="file-name">{{relevant_file.modify_file.name ? relevant_file.modify_file.name : relevant_file.modify_file.originalName}}</span></div>
+                                <div v-if="relevant_file.modify_file.showPercentage" class="progressShow">
+                                    <el-progress :percentage="relevant_file.modify_file.percentage"></el-progress>
                                 </div>
+                                <span class="clear-btn" @click="relevant_file.modify_file = {}">× 清除</span>
                             </div>
                             <el-upload
                                 v-else
@@ -72,59 +64,54 @@
                                 drag
                                 action="#"
                                 :auto-upload="false"
+                                :show-file-list='false'
                                 :limit="1"
                                 :on-change="(file)=>onChange(file,'relevant_file.modify_file')"
                                 style="width: 100%"
                             >
-                                <i class="el-icon-upload"></i>
                                 <div class="el-upload__text">
-                                    <div><em>点击上传</em></div>
-                                    <div>或将文件拖到此处上传</div>
+                                    <div class="upload-placeholder">上一次OA修改对照页</div>
+                                    <div class="upload-placeholder">点击或拖拽上传</div>
+                                    <div class="red file-info margin-top_0">
+                                        注:不是第一次OA并且想在上一次OA基础上答辩则需要上传
+                                    </div>
                                 </div>
                             </el-upload>
                         </div>
-                    </div>
-                </template>
-                    
-                    <template v-if="relevant_file.contrast_file">
-                        <div>
+                        <!-- 对比文件 -->
+                        <template v-if="relevant_file.contrast_file">
                             <div v-for="contrast_file in relevant_file.contrast_file" :key="'D'+contrast_file.order">
-                                <p class="file_title">对比文件D{{ contrast_file.order }}</p>
-                                <div class="upload_file">
-                                    <div v-if="contrast_file.file.guid" class="file_show">
-                                        <myTooltip :content="contrast_file.file.name ? contrast_file.file.name : contrast_file.file.originalName">
-                                            <div class="noWrap file_name">
-                                                <i class="el-icon-document" style="margin-right: 10px"></i>
-                                                <span class="name">{{contrast_file.file.name ? contrast_file.file.name : contrast_file.file.originalName}}</span>
-                                            </div>
-                                        </myTooltip>
-                                        <div class="type">{{ contrast_file.file.guid ? "已上传" : "待上传" }}</div>
-                                        <div class="icon" @click="contrast_file.file = {}">
-                                            <i class="el-icon-close"></i>
-                                        </div>
+                                <div v-if="contrast_file.file.showPercentage || contrast_file.file.guid" class="upload-box">
+                                    <div class="upload-placeholder">对比文件{{contrast_file.order}}</div>
+                                    <div class="file-info"><span v-if="!contrast_file.file.showPercentage">已上传:</span><span class="file-name">{{contrast_file.file.name ? contrast_file.file.name : contrast_file.file.originalName}}</span></div>
+                                    <div v-if="contrast_file.file.showPercentage" class="progressShow">
+                                        <el-progress :percentage="contrast_file.file.percentage"></el-progress>
                                     </div>
-                                    <el-upload
-                                        v-else
-                                        ref="upload_file"
-                                        class="upload-demo"
-                                        drag
-                                        action="#"
-                                        :auto-upload="false"
-                                        :limit="1"
-                                        :on-change="(file)=>onChange(file,'file',contrast_file)"
-                                        style="width: 100%"
-                                    >
-                                        <i class="el-icon-upload"></i>
-                                        <div class="el-upload__text">
-                                            <div><em>点击上传</em></div>
-                                            <div>或将文件拖到此处上传</div>
-                                        </div>
-                                    </el-upload>
+                                    <span class="clear-btn" @click="contrast_file.file = {}">× 清除</span>
                                 </div>
+                                <el-upload
+                                    v-else
+                                    ref="upload_file"
+                                    class="upload-demo"
+                                    drag
+                                    action="#"
+                                    :auto-upload="false"
+                                    :show-file-list='false'
+                                    :limit="1"
+                                    :on-change="(file)=>onChange(file,'file',contrast_file)"
+                                    style="width: 100%"
+                                >
+                                    <div class="el-upload__text">
+                                        <div class="upload-placeholder">对比文件{{contrast_file.order}}</div>
+                                        <div class="upload-placeholder">点击或拖拽上传</div>
+                                        <div class="red file-info margin-top_0">注:非专利文献需要上传</div>
+                                    </div>
+                                </el-upload>
                             </div>
-                        </div>
-                    </template>
+                        </template>
                     </div>
+                </div>
+            </div>
           </div>
         <span slot="footer" class="dialog-footer">
           <el-button size="mini" @click="handleClose">取 消</el-button>
@@ -212,10 +199,17 @@ import batchFileDialog from './batchFile.vue';
                 type: 'warning',
                 duration:0
             });
-            this.$api.uploadFile(formData).then(response=>{
+            this.$api.uploadFile(formData,(percent)=>{
+                if(!notice_file.showPercentage){
+                    notice_file.showPercentage = true
+                }
+                notice_file.percentage = percent
+                this.setData(row,field,notice_file)
+            }).then(response=>{
                 if(response.code == 200){
                     let guid = response.data[0]
                     notice_file.guid = guid
+                    notice_file.showPercentage = false
                     // this.$set(this,field,notice_file)
                     this.setData(row,field,notice_file)
                     message.close()
@@ -313,4 +307,7 @@ import batchFileDialog from './batchFile.vue';
   };
   </script>
   <style lang="scss" scoped>
+  .red{
+        color:red !important;
+    }
   </style>

+ 231 - 39
src/views/AITools/OADefense/mixins/index.js

@@ -1,8 +1,10 @@
-
+const api_key = 'app-NRQwVZmqF8a1yuhzgB96Ndj1'
+const url = 'http://192.168.2.24/v1'
 export default {
     data() {
         return {
-            controller:null
+            controller:null,
+            hasFiles:null
         }
     },
     computed:{
@@ -12,35 +14,89 @@ export default {
     },
     methods: {
         async getResult(){
-            if(!this.confession.guid){
+            if(!this.notice_file.guid){
                 this.$message.warning('请先上传审查意见书')
                 return
             }
-            if(this.loading){
-                this.$message.warning('请等当前执行完成')
-                return
+            
+            this.cancelRun()
+
+            this.controller = new AbortController();
+            let patent_fileUrls = {}
+            // if(this.patent_fileUrls && this.patent_fileUrls.length){
+            //     this.patent_fileUrls.forEach(item=>{
+            //         patent_fileUrls[item.name] = item.guid
+            //     })
+            // }
+            if(this.relevant_file.contrast_file && this.relevant_file.contrast_file.length){
+                this.relevant_file.contrast_file.forEach(item=>{
+                    if(item.file && item.file.guid){
+                        patent_fileUrls['D' + item.order + '-' + item.file.name] = item.file.guid
+                    }
+                })
+            }
+            // var params = {
+            //     inputs:{
+            //         fileUrl:'http://192.168.2.24:8803/fileManager/downloadFile?fileId='+this.notice_file.guid,
+            //         patent_fileUrls:JSON.stringify(patent_fileUrls),
+            //         patent_files:[],
+            //         changeClaim:this.changeClaim.changeClaim + '',
+            //         claim:this.changeClaim.claim,
+            //         near_index:this.changeClaim.near_index,
+            //         main_claim_reason:JSON.stringify(this.main_claim_reason)
+            //     },
+            //     query:'OA答辩',
+            //     response_mode:'streaming',
+            //     user:this.userinfo.id
+            // }
+            // this.loading = true
+            // this.loading_text = ''
+            // var loading_text = ''
+            // this.result = null
+            // const response = await fetch('https://ai.xsip.cn/v1/chat-messages', {
+            //   method: 'POST',
+            //   headers: {
+            //     'Content-Type': 'application/json',
+            //     // 'Accept': 'text/event-stream',
+            //     'Authorization': `Bearer ${api_key}`,
+            //   },
+            //   body:JSON.stringify(params),
+            //   signal: this.controller.signal
+            // });
+            var params = {
+                confessionSessionId:this.currentConversation.id,
+                patentFileUrls:JSON.stringify(patent_fileUrls),
+                appFileGuid:this.relevant_file.app_file.guid,
+                modifyFileGuid:this.relevant_file.modify_file.guid,
+                changeClaim:this.changeClaim.changeClaim + '',
+                claim:this.changeClaim.claim,
+                nearIndex:this.changeClaim.near_index,
+                mainClaimReason:JSON.stringify(this.main_claim_reason)
             }
             this.loading = true
+            this.loading_text = ''
+            var loading_text = ''
             this.result = null
-            this.controller = new AbortController();
-            const response = await fetch('/api/xiaoshi/dify/sendOADefense?confessionSessionId='+this.currentConversation.id, {
-              method: 'GET',
-              headers: {
-                'Content-Type': 'application/json',
-                'Accept': 'text/event-stream',
-              },
-              signal: this.controller.signal
-            });
+            const response = await fetch('/api/xiaoshi/dify/sendOADefense', {
+                method: 'POST',
+                headers: {
+                  'Content-Type': 'application/json',
+                  'Accept': 'text/event-stream',
+                },
+                body:JSON.stringify(params),
+                signal: this.controller.signal
+              });
             if (!response.ok) throw new Error('AI API 调用失败');
-            this.finish = false
             const reader = response.body.getReader();
             const decoder = new TextDecoder('utf-8');
             let noFinishMessage = ''
             while (true) {
                 const { done, value } = await reader.read();
                 if (done){
-                    this.finish = true
                     this.loading = false
+                    if(this.hasFiles){
+                        this.saveAllFiles(this.hasFiles)
+                    }
                     break;
                 } 
                 const chunk = decoder.decode(value);
@@ -54,19 +110,45 @@ export default {
                     try {
                         const json = JSON.parse(jsonStr);
                         if(json.event == 'message'){
-                            this.result += json.answer;
-                        }else if(json.event == 'message_replace'){
-                            this.result = json.answer
-                        }else if(json.event == 'text_chunk'){
-                            if(json.data){
-                               this.result += json.data.text; 
+                            let answer = json.answer
+                            try{
+                                let answer_json = JSON.parse(answer)
+                                if(answer_json.code == 1001){//缺少专利文件
+                                    this.result = answer_json
+                                    this.$refs.errorTip.open(answer_json)
+                                }else if(answer_json.code == 200){
+                                    this.queryConfessionSession(false,false,true) 
+                                }else if(answer_json.code == 1003){//中间过程
+                                    this.loading_text = answer_json.data
+                                    loading_text = answer_json.data
+                                }else if(answer_json.code == 1002){//请求超时
+                                    this.result = answer_json
+                                }else if(answer_json.code == 201){//修改后的权利要求输出
+                                    this.result = answer_json
+                                    this.$set(this.changeClaim,'claim',answer_json.data)
+                                    if(this.app_file && this.app_file.guid){
+                                        this.handleOptionClick(this.app_file,2)
+                                    }
+                                }else if(answer_json.code == 202){//区别技术特征
+                                    this.result = answer_json
+                                    this.$set(this,'main_claim_reason',answer_json.data)
+                                }else if(answer_json.code == 203){//文件输出
+                                    this.hasFiles = answer_json.data
+                                    this.app_file = answer_json.data.app_file || {}
+                                    this.modify_file = answer_json.data.modify_file || {}
+                                    this.contrast_file = answer_json.data.contrast_file || []
+                                }
+                            }catch(e){
+                                if(loading_text!=''){
+                                    loading_text = ''
+                                    this.loading_text = ''
+                                }
+                                this.result += answer.replace(/\n|\\n|\\\n|\\\\n/g,'<br>');
                             }
                             
-                        }else if(json.event == 'workflow_finished'){
-                            if(json.data){
-                                this.result = json.data.outputs.output; 
-                            }
-                            this.queryConfessionSession(false,false,true) 
+                        }else if(json.event == 'message_replace'){
+                            this.result = json.answer
+                        }else  if(json.event == 'message_end'){
                         }
                         
                     } catch (e) {
@@ -78,18 +160,44 @@ export default {
                                 try{
                                     const json = JSON.parse(noFinishMessage);
                                     if(json.event == 'message'){
-                                        this.result += json.answer;
+                                        let answer = json.answer
+                                        try{
+                                            let answer_json = JSON.parse(answer)
+                                            if(answer_json.code == 1001){//缺少专利文件
+                                                this.result = answer_json
+                                                this.$refs.errorTip.open(answer_json)
+                                            }else if(answer_json.code == 1002){//请求超时
+                                                this.result = answer_json
+                                            }else if(answer_json.code == 200){
+                                                this.queryConfessionSession(false,false,true)
+                                            }else if(answer_json.code == 1003){//中间过程
+                                                this.loading_text = answer_json.data
+                                                loading_text = answer_json.data
+                                            }else if(answer_json.code == 201){//修改后的权利要求输出
+                                                this.result = answer_json
+                                                this.$set(this.changeClaim,'claim',answer_json.data)
+                                                if(this.app_file && this.app_file.guid){
+                                                    this.handleOptionClick(this.app_file,2)
+                                                }
+                                            }else if(answer_json.code == 202){//区别技术特征
+                                                this.result = answer_json
+                                                this.$set(this,'main_claim_reason',answer_json.data)
+                                            }else if(answer_json.code == 203){//文件输出
+                                                this.hasFiles = answer_json.data
+                                                this.app_file = answer_json.data.app_file || {}
+                                                this.modify_file = answer_json.data.modify_file || {}
+                                                this.contrast_file = answer_json.data.contrast_file || []
+                                            }
+                                        }catch(e){
+                                            if(loading_text!=''){
+                                                loading_text = ''
+                                                this.loading_text = ''
+                                            }
+                                            this.result += answer.replace(/\n|\\n|\\\n|\\\\n/g,'<br>');
+                                        }
                                     }else if(json.event == 'message_replace'){
                                         this.result = json.answer
-                                    }else if(json.event == 'text_chunk'){
-                                        if(json.data){
-                                            this.result += json.data.text; 
-                                         }
-                                    }else if(json.event == 'workflow_finished'){
-                                        if(json.data){
-                                            this.result = json.data.outputs.output; 
-                                        }
-                                        this.queryConfessionSession(false,false,true) 
+                                    }else if(json.event == 'message_end'){
                                     }
                                 }
                                 catch(e){
@@ -104,6 +212,47 @@ export default {
                 }
             }
         },
+
+        //保存文件
+        async saveAllFiles(files){
+            await this.getConversionDetails()
+            let content = this.currentConversation.content
+            var params = {
+                confessionSessionId:this.currentConversation.id,
+            }
+            if(!content){
+                params.content = JSON.stringify(
+                    {
+                        relevant_file:files
+                    }
+                )
+            }else{
+                try{
+                    let data1 = JSON.parse(content)
+                    if(data1.data && data1.data.code == 1001){
+                        data1.data = {}
+                    }
+                    data1.relevant_file = files
+                    params.content = JSON.stringify(data1)
+                    
+                }catch(e){
+                    params.content = JSON.stringify(
+                        {
+                            relevant_file:files
+                        }
+                    ) 
+                }
+            }
+            this.$api.updateConfessionSession(params).then(response=>{
+                if(response.code == 200){
+                    this.queryConfessionSession(true)
+                    this.hasFiles = null
+                }
+            }).catch(error=>{
+                
+            })
+        },
+
         cancelRun(){
             if (this.controller) {
                 this.controller.abort();
@@ -112,7 +261,20 @@ export default {
         },
         //格式化AI答复
         formateAIAnswer(chat){
-            let answer = chat.replace('null','')
+            let answer = chat.replace('null','').replace(/<br>/gi, '</p><p>').replace(/^<p>|<\/p>$/gi, '')
+
+            // let regx1 = /<think>[\s\S]*<\/think>/g
+            // let regx2 = /<details style="color:gray;background-color: #f8f8f8;padding: 8px;border-radius: 4px;" open> <summary> Thinking... <\/summary>[\s\S]*<\/details>/g
+            // // let regx1 = new RegExp("<think>.*</think>", "g")
+            // // let regx2 = new RegExp('<details style="color:gray;background-color: #f8f8f8;padding: 8px;border-radius: 4px;" open> <summary> Thinking... </summary>.*</details>', "g")
+            // let text = answer.replace(regx1,'').replace(regx2,'')
+            // return [
+            //     {
+            //         type:'text',
+            //         content:text.trim()
+            //     }
+            // ]
+
             let len = answer.length
 
             let signs = [
@@ -225,5 +387,35 @@ export default {
             }
             document.body.removeChild(textArea);
         },
+
+        /**
+         * 上传文件处理
+         *  */
+        // 上传的文件监听
+        onchangeFile(file, fileList) {
+            if(!this.patent_fileUrls){
+                this.$set(this,'patent_fileUrls',[])
+            }
+            if (file.guid) {
+                let index = this.patent_fileUrls.findIndex(item => {
+                    return item.uid == file.uid
+                })
+                if (index != -1) {
+                    this.patent_fileUrls.splice(index, 1, file)
+                }
+            } else {
+                this.patent_fileUrls.push(file.raw)
+            }
+    
+        },
+        // 删除上传的文件
+        onRemove(file, fileList) {
+            let index = this.patent_fileUrls.findIndex(item => {
+                return item.uid == file.uid
+            })
+            if (index != -1) {
+                this.patent_fileUrls.splice(index, 1)
+            }
+        },
     },
 }

+ 229 - 145
src/views/AITools/OADefense/mixins/index1.js

@@ -1,3 +1,5 @@
+import chart from "@/store/modules/chart"
+
 const api_key = 'app-NRQwVZmqF8a1yuhzgB96Ndj1'
 const url = 'http://192.168.2.24/v1'
 export default {
@@ -13,21 +15,59 @@ export default {
         }
     },
     methods: {
-        async getResult(){
-            if(!this.notice_file.guid){
-                this.$message.warning('请先上传审查意见书')
-                return
+        async sendMessage(message,operation=1,question){
+            if(!question){
+                switch(operation){
+                    case 1:
+                        question = ''
+                        break;
+                    case 2:
+                        question = ''
+                        break;
+                    case 3:
+                        question = '请分析并给出修改意见'
+                        break
+                    case 4:
+                        question = '生成修改方案'
+                        break;
+                    case 5:
+                        question = '我接受这些修改,请获取答辩点'
+                        break;
+                    case 6:
+                        question = '请生成答复意见'
+                        break;
+                }
             }
-            
-            this.cancelRun()
+            // 添加对话记录
+            var params = {
+                confessionSessionId:this.currentConversation.id,
+                question:question,
+                operation:operation,
+                answer:''
+            }
+            let chatRecord = await this.addChatRecord(params)
+            this.messageList.push(chatRecord)
+            this.sendMessage1(message,chatRecord,operation)
+
+        },
+
+        async addChatRecord(params){
+            var chatRecord = {}
+            await this.$api.saveChatRecord(params).then(response=>{
+                if(response.code == 200){
+                    let id = response.data
+                    chatRecord = {
+                        id:id,
+                        ...params
+                    }
+                }
+            })
+            return chatRecord
+        },
+
 
-            this.controller = new AbortController();
+        async sendMessage1(lastMessage,message,operation=1){
             let patent_fileUrls = {}
-            // if(this.patent_fileUrls && this.patent_fileUrls.length){
-            //     this.patent_fileUrls.forEach(item=>{
-            //         patent_fileUrls[item.name] = item.guid
-            //     })
-            // }
             if(this.relevant_file.contrast_file && this.relevant_file.contrast_file.length){
                 this.relevant_file.contrast_file.forEach(item=>{
                     if(item.file && item.file.guid){
@@ -35,67 +75,84 @@ export default {
                     }
                 })
             }
-            // var params = {
-            //     inputs:{
-            //         fileUrl:'http://192.168.2.24:8803/fileManager/downloadFile?fileId='+this.notice_file.guid,
-            //         patent_fileUrls:JSON.stringify(patent_fileUrls),
-            //         patent_files:[],
-            //         changeClaim:this.changeClaim.changeClaim + '',
-            //         claim:this.changeClaim.claim,
-            //         near_index:this.changeClaim.near_index,
-            //         main_claim_reason:JSON.stringify(this.main_claim_reason)
-            //     },
-            //     query:'OA答辩',
-            //     response_mode:'streaming',
-            //     user:this.userinfo.id
-            // }
-            // this.loading = true
-            // this.loading_text = ''
-            // var loading_text = ''
-            // this.result = null
-            // const response = await fetch('https://ai.xsip.cn/v1/chat-messages', {
-            //   method: 'POST',
-            //   headers: {
-            //     'Content-Type': 'application/json',
-            //     // 'Accept': 'text/event-stream',
-            //     'Authorization': `Bearer ${api_key}`,
-            //   },
-            //   body:JSON.stringify(params),
-            //   signal: this.controller.signal
-            // });
-            var params = {
-                confessionSessionId:this.currentConversation.id,
-                patentFileUrls:JSON.stringify(patent_fileUrls),
-                appFileGuid:this.relevant_file.app_file.guid,
-                modifyFileGuid:this.relevant_file.modify_file.guid,
+            let inputs = {
+                fileUrl:'http://192.168.2.24:8803/fileManager/downloadFile?fileId='+this.notice_file.guid,
+                patent_fileUrls:JSON.stringify(patent_fileUrls),
+                app_file_guid:this.relevant_file.app_file.guid,
+                modify_file_guid:this.relevant_file.modify_file.guid,
                 changeClaim:this.changeClaim.changeClaim + '',
                 claim:this.changeClaim.claim,
-                nearIndex:this.changeClaim.near_index,
-                mainClaimReason:JSON.stringify(this.main_claim_reason)
+                near_index:this.changeClaim.near_index,
+                main_claim_reason:JSON.stringify(this.main_claim_reason),
+                claimChangeSuggestion:this.changeClaim.claimChangeSuggestion,
+                operation:operation+'',
+                query:this.difyQuery
             }
+            // if(lastMessage){
+            //     switch(operation){
+            //         case 4:
+            //             inputs.claimChangeSuggestion = lastMessage.answer
+            //             break;
+            //         case 5:
+            //             inputs.claim = lastMessage.answer
+            //             break;
+            //         case 6:
+            //             inputs.main_claim_reason = JSON.stringify(lastMessage.answer)
+            //             break;
+            //     }
+            // }
+            
+
+            var params = {
+                inputs:inputs,
+                query:this.difyQuery || 'OA答辩',
+                conversation_id:this.currentConversation.conversationId,
+                response_mode:'streaming',
+                user:this.userinfo.id
+            }
+            this.difyQuery = ''
+            this.$set(message,'loading',true)
             this.loading = true
-            this.loading_text = ''
-            var loading_text = ''
             this.result = null
-            const response = await fetch('/api/xiaoshi/dify/sendOADefense', {
-                method: 'POST',
-                headers: {
-                  'Content-Type': 'application/json',
-                  'Accept': 'text/event-stream',
-                },
-                body:JSON.stringify(params),
-                signal: this.controller.signal
-              });
+            const response = await fetch('https://ai.xsip.cn/v1/chat-messages', {
+              method: 'POST',
+              headers: {
+                'Content-Type': 'application/json',
+                // 'Accept': 'text/event-stream',
+                'Authorization': `Bearer app-UTUV4s0TkGMBqHBEF3oqAbVp`,
+              },
+              body:JSON.stringify(params)
+            });
+            
             if (!response.ok) throw new Error('AI API 调用失败');
             const reader = response.body.getReader();
             const decoder = new TextDecoder('utf-8');
             let noFinishMessage = ''
+            message.answer = ''
             while (true) {
                 const { done, value } = await reader.read();
                 if (done){
                     this.loading = false
-                    if(this.hasFiles){
-                        this.saveAllFiles(this.hasFiles)
+                    if(message.loading){
+                        this.$set(message,'loading',false)
+                        this.$forceUpdate()
+                    }
+                    let params  = {
+                        ...message
+                    }
+                    if(typeof (params.answer) != "string"){
+                        params.answer = JSON.stringify(params.answer)
+                    }else{
+                        params.answer =  params.answer.replace('undefined','')
+                    }
+                    this.addChatRecord(params)
+                    if(params.operation == 3){
+                        this.changeClaim.claimChangeSuggestion = params.answer
+                        this.updateContent()
+                    }
+                    if(params.operation == 4){
+                        this.changeClaim.claim = params.answer
+                        this.updateContent()
                     }
                     break;
                 } 
@@ -110,45 +167,62 @@ export default {
                     try {
                         const json = JSON.parse(jsonStr);
                         if(json.event == 'message'){
+                            if(!this.currentConversation.conversationId){
+                                this.currentConversation.conversationId = json.conversation_id
+                                this.saveConversationId(json.conversation_id)
+                            }
+                            if(message.loading){
+                                this.$set(message,'loading',false)
+                                this.$forceUpdate()
+                            }
                             let answer = json.answer
                             try{
                                 let answer_json = JSON.parse(answer)
-                                if(answer_json.code == 1001){//缺少专利文件
-                                    this.result = answer_json
-                                    this.$refs.errorTip.open(answer_json)
-                                }else if(answer_json.code == 200){
-                                    this.queryConfessionSession(false,false,true) 
-                                }else if(answer_json.code == 1003){//中间过程
-                                    this.loading_text = answer_json.data
-                                    loading_text = answer_json.data
-                                }else if(answer_json.code == 1002){//请求超时
-                                    this.result = answer_json
-                                }else if(answer_json.code == 201){//修改后的权利要求输出
-                                    this.result = answer_json
-                                    this.$set(this.changeClaim,'claim',answer_json.data)
-                                    if(this.app_file && this.app_file.guid){
-                                        this.handleOptionClick(this.app_file,2)
+                                if(operation != 6){
+                                  this.$set(message,'answer',answer_json)  
+                                }
+                                
+                                if(operation == 1){
+                                    if(answer_json.code == 1001){//缺少专利文件
+                                        this.$refs.errorTip.open(answer_json)
+                                    }else if(answer_json.code == 203){//文件输出
+                                        this.app_file = answer_json.data.app_file || {}
+                                        this.modify_file = answer_json.data.modify_file || {}
+                                        this.contrast_file = answer_json.data.contrast_file || []
+                                        this.relevant_file = {
+                                            app_file:this.app_file,
+                                            modify_file:this.modify_file,
+                                            contrast_file:this.contrast_file
+                                        }
+                                        this.updateContent()
+                                        this.sendMessage(null,2)
                                     }
-                                }else if(answer_json.code == 202){//区别技术特征
-                                    this.result = answer_json
-                                    this.$set(this,'main_claim_reason',answer_json.data)
-                                }else if(answer_json.code == 203){//文件输出
-                                    this.hasFiles = answer_json.data
-                                    this.app_file = answer_json.data.app_file || {}
-                                    this.modify_file = answer_json.data.modify_file || {}
-                                    this.contrast_file = answer_json.data.contrast_file || []
+                                }else if(operation == 2){
+                                    this.changeClaim.near_index = answer_json.nearIndex
+                                    this.changeClaim.nearNo = answer_json.nearNo
+                                    this.changeClaim.changeClaim = answer_json.changeClaim
+                                    this.changeClaim.novelty_innovative = answer_json.novelty_innovative
+                                    this.updateContent()
+                                }else if(operation == 5){
+                                    this.main_claim_reason = answer_json
+                                    this.updateContent()
+                                }else if(operation == 6){
+                                    this.updateContent(operation,answer_json)
                                 }
+                                
                             }catch(e){
-                                if(loading_text!=''){
-                                    loading_text = ''
-                                    this.loading_text = ''
-                                }
-                                this.result += answer.replace(/\n|\\n|\\\n|\\\\n/g,'<br>');
+                                message.answer += answer.replace(/\n|\\n|\\\n|\\\\n/g,'<br>');
                             }
                             
                         }else if(json.event == 'message_replace'){
-                            this.result = json.answer
+                            this.$set(message,'answer',json.answer)
+                            if(message.loading){
+                                this.$set(message,'loading',false)
+                            }
                         }else  if(json.event == 'message_end'){
+                            if(message.loading){
+                                this.$set(message,'loading',false)
+                            }
                         }
                         
                     } catch (e) {
@@ -160,44 +234,54 @@ export default {
                                 try{
                                     const json = JSON.parse(noFinishMessage);
                                     if(json.event == 'message'){
+                                        if(message.loading){
+                                            this.$set(message,'loading',false)
+                                        }
                                         let answer = json.answer
                                         try{
                                             let answer_json = JSON.parse(answer)
-                                            if(answer_json.code == 1001){//缺少专利文件
-                                                this.result = answer_json
-                                                this.$refs.errorTip.open(answer_json)
-                                            }else if(answer_json.code == 1002){//请求超时
-                                                this.result = answer_json
-                                            }else if(answer_json.code == 200){
-                                                this.queryConfessionSession(false,false,true)
-                                            }else if(answer_json.code == 1003){//中间过程
-                                                this.loading_text = answer_json.data
-                                                loading_text = answer_json.data
-                                            }else if(answer_json.code == 201){//修改后的权利要求输出
-                                                this.result = answer_json
-                                                this.$set(this.changeClaim,'claim',answer_json.data)
-                                                if(this.app_file && this.app_file.guid){
-                                                    this.handleOptionClick(this.app_file,2)
+                                            if(operation != 6){
+                                               this.$set(message,'answer',answer_json) 
+                                            }
+                                            if(operation == 1){
+                                                if(answer_json.code == 1001){//缺少专利文件
+                                                    this.$refs.errorTip.open(answer_json)
+                                                }else if(answer_json.code == 203){//文件输出
+                                                    this.app_file = answer_json.data.app_file || {}
+                                                    this.modify_file = answer_json.data.modify_file || {}
+                                                    this.contrast_file = answer_json.data.contrast_file || []
+                                                    this.relevant_file = {
+                                                        app_file:this.app_file,
+                                                        modify_file:this.modify_file,
+                                                        contrast_file:this.contrast_file
+                                                    }
+                                                    this.updateContent()
+                                                    this.sendMessage(null,2)
                                                 }
-                                            }else if(answer_json.code == 202){//区别技术特征
-                                                this.result = answer_json
-                                                this.$set(this,'main_claim_reason',answer_json.data)
-                                            }else if(answer_json.code == 203){//文件输出
-                                                this.hasFiles = answer_json.data
-                                                this.app_file = answer_json.data.app_file || {}
-                                                this.modify_file = answer_json.data.modify_file || {}
-                                                this.contrast_file = answer_json.data.contrast_file || []
+                                            }else if(operation == 2){
+                                                this.changeClaim.near_index = answer_json.nearIndex
+                                                this.changeClaim.nearNo = answer_json.nearNo
+                                                this.changeClaim.changeClaim = answer_json.changeClaim
+                                                this.changeClaim.novelty_innovative = answer_json.novelty_innovative
+                                                this.updateContent()
+                                            }else if(operation == 5){
+                                                this.main_claim_reason = answer_json
+                                                this.updateContent()
+                                            }else if(operation == 6){
+                                                this.updateContent(operation,answer_json)
                                             }
                                         }catch(e){
-                                            if(loading_text!=''){
-                                                loading_text = ''
-                                                this.loading_text = ''
-                                            }
-                                            this.result += answer.replace(/\n|\\n|\\\n|\\\\n/g,'<br>');
+                                            message.answer += answer.replace(/\n|\\n|\\\n|\\\\n/g,'<br>');
                                         }
                                     }else if(json.event == 'message_replace'){
-                                        this.result = json.answer
+                                         this.$set(message,'answer',json.answer)
+                                        if(message.loading){
+                                            this.$set(message,'loading',false)
+                                        }
                                     }else if(json.event == 'message_end'){
+                                        if(message.loading){
+                                             this.$set(message,'loading',false)
+                                        }
                                     }
                                 }
                                 catch(e){
@@ -213,40 +297,40 @@ export default {
             }
         },
 
-        //保存文件
-        async saveAllFiles(files){
-            await this.getConversionDetails()
-            let content = this.currentConversation.content
+        //更新会话的content
+        async updateContent(operation,data){
+            let content = {
+                query:{
+                    relevant_file:this.relevant_file,
+                    claimChange:this.changeClaim,
+                    main_claim_reason:this.main_claim_reason
+                }
+            }
+            if(operation == 6){
+                content.data = data
+            }
             var params = {
                 confessionSessionId:this.currentConversation.id,
+                content:JSON.stringify(content)
             }
-            if(!content){
-                params.content = JSON.stringify(
-                    {
-                        relevant_file:files
-                    }
-                )
-            }else{
-                try{
-                    let data1 = JSON.parse(content)
-                    if(data1.data && data1.data.code == 1001){
-                        data1.data = {}
-                    }
-                    data1.relevant_file = files
-                    params.content = JSON.stringify(data1)
-                    
-                }catch(e){
-                    params.content = JSON.stringify(
-                        {
-                            relevant_file:files
-                        }
-                    ) 
+            this.$api.updateConfessionSession(params).then(response=>{
+                if(response.code == 200){
+                    this.queryConfessionSession(true)
                 }
+            }).catch(error=>{
+                
+            })
+        },
+        //更新会话的dify会话id
+        saveConversationId(id){
+            var params = {
+                confessionSessionId:this.currentConversation.id,
+                conversationId:id
             }
             this.$api.updateConfessionSession(params).then(response=>{
                 if(response.code == 200){
-                    this.queryConfessionSession(true)
-                    this.hasFiles = null
+                    // this.queryConfessionSession(true)
+                    this.currentConversation.conversationId = id
                 }
             }).catch(error=>{