Browse Source

OA接口调试

zhuliu 4 weeks ago
parent
commit
0a725a9ed5

+ 9 - 3
src/api/newApi/AI.js

@@ -29,22 +29,28 @@ export default {
 
 
     /**
+     * 请求OA结果
+     */
+    sendOADefense2(data) {
+        return axios.post("/xiaoshi/dify/sendOADefense2", data);
+    },
+    /**
      * 保存会话记录
      */
     saveChatRecord(data) {
-        return axios.post("/chatRecord/saveChatRecord", data);
+        return axios.post("/xiaoshi/dify/oaChatRecord/add", data);
     },
     /**
      * 查询会话记录
      */
     queryChatRecord(data) {
-        return axios.post("/chatRecord/queryChatRecord", data);
+        return axios.post("/xiaoshi/dify/oaChatRecord/query", data);
     },
     /**
      * 导出
      */
     exportResultFiles(data) {
-        return axios.post("/chatRecord/exportResultFiles", data);
+        return axios.post("/xiaoshi/dify/oa/generateResult", data);
     },
 
     

+ 64 - 33
src/views/AITools/OADefense/OADefense1.vue

@@ -13,7 +13,7 @@
                     </div>
                     <div style="font-weight:600">OA答辩</div>
                     <el-button size="mini" class="margin-left_10" type="primary" @click="addConversation">添加新OA答辩</el-button>
-                    <el-button v-if="notice_file.guid && !loading" class="margin-left_10" type="primary" size="mini" @click="regenerate">重新生成</el-button>
+                    <!-- <el-button v-if="notice_file.guid && !loading" class="margin-left_10" type="primary" size="mini" @click="regenerate">重新生成</el-button> -->
                 </div>
                 <div class="head_right">
                     <el-select v-model="current_guid" size="mini" placeholder="请选择">
@@ -21,13 +21,16 @@
                         <el-option v-if="app_file.guid" :label="`申请文件-${app_file.appNo}`" :value="app_file.guid" @click.native="handleOptionClick(app_file,2)"></el-option>
                         <el-option v-if="modify_file.guid" :label="`修改对照页`" :value="modify_file.guid" @click.native="handleOptionClick(modify_file,4)"></el-option>
                         <template v-if="contrast_file && contrast_file.length>0">
-                            <el-option
-                                v-for="(item,index) in contrast_file"
-                                :key="index"
-                                :label="`D${item.index}-${item.publicNo}`"
-                                :value="item.guid"
-                                @click.native="handleOptionClick(item,3)">
-                            </el-option>
+                            <template v-for="(item,index) in contrast_file" >
+                                <el-option
+                                    :key="index"
+                                    v-if="item.guid"
+                                    :label="`D${item.index}-${item.publicNo}`"
+                                    :value="item.guid"
+                                    @click.native="handleOptionClick(item,3)">
+                                </el-option>
+                            </template>
+                            
                         </template>
                         
                     </el-select>
@@ -203,9 +206,9 @@
                                 </span>
                             </p>
                             <div v-if="changeClaim.changeClaim == 1">
-                                <p class="file_title">修改后完整的权利要求</p>
+                                <p class="file_title">修改建议或者修改后的权利要求</p>
                                 <div>
-                                    <el-input type="textarea" v-model="changeClaim.claim" :rows="6" placeholder="请输入修改后完整的权利要求"></el-input>
+                                    <el-input type="textarea" v-model="changeClaim.claimChangeSuggestion" :rows="6" placeholder="请输入修改建议或者修改后的权利要求"></el-input>
                                 </div>
                             </div>
                         </div>
@@ -303,6 +306,12 @@
                                                     <el-button type="primary" size="small" @click="openErrorTip(message.answer)">点击上传</el-button>
                                                 </div>
                                             </div>
+                                            <div v-else-if="message.answer.code == 1002">
+                                                <div style="font-size:16px" v-html="message.answer.data.replace('\n','<br>')"></div>  
+                                                <div class="btn_box" v-if="index == messageList.length-1">
+                                                    <el-button type="primary" size="small" @click="openErrorTip(message.answer)">点击上传</el-button>
+                                                </div>
+                                            </div>
                                             <div v-else>
                                                 您好,以下是本次OA涉及的文件:
                                                 <div>
@@ -676,38 +685,46 @@ export default {
             let params = {
                 confessionSessionId:this.currentConversation.id
             }
+            var message =  this.$message({
+                message: '文档生成中',
+                type: 'warning',
+                duration:0
+            });
             this.$api.exportResultFiles(params).then(async response=>{
                 if(response.code == 200){
+                    message.close()
                     await this.getConversionDetails()
                     if(this.currentConversation.resultFiles && this.currentConversation.resultFiles.length){
                         this.changeResultFile(this.currentConversation.resultFiles[0])
                     }
                 }
+            }).catch(error=>{
+                message.close()
             })
         },
         //用户修改
         editMessage(message){
-            let operation=message.operation
+            let operation=message.operation + ''
             let currentEditData = {
                 show:true,
                 operation:operation
             }
             switch(operation){
-                case 2://修改是否修改权利要求以及最接近的现有技术
-                case 7:
+                case '2'://修改是否修改权利要求以及最接近的现有技术
+                case '7':
                     currentEditData.near_index = message.answer.nearIndex
                     currentEditData.nearNo = message.answer.nearNo
                     currentEditData.changeClaim = message.answer.changeClaim + ''
                     break;
-                case 3://输入权要修改意见
-                case 4://输入权要修改意见
+                case '3'://输入权要修改意见
+                case '4'://输入权要修改意见
                     currentEditData.claimChangeSuggestion = ''
                     break
-                case 5://修改答辩点
-                case 8:
+                case '5'://修改答辩点
+                case '8':
                     currentEditData.main_claim_reason = message.answer
                     break
-                case 6://答复意见
+                case '6'://答复意见
                     currentEditData.replyOpinion = ''
                     break
             }
@@ -720,11 +737,11 @@ export default {
                 ...this.currentEditData
             }
             this.currentEditData.btnLoading = true
-            let operation = this.currentEditData.operation
+            let operation = this.currentEditData.operation + ''
             var question = '我已提交修改'
             switch(operation){
-                case 2:
-                case 7:
+                case '2':
+                case '7':
                     if(this.currentEditData.near_index){
                         this.changeClaim.near_index = this.currentEditData.near_index
                         let obj = this.contrast_file.find(item=>{
@@ -738,24 +755,24 @@ export default {
                     if(this.currentEditData.changeClaim){
                         this.changeClaim.changeClaim = this.currentEditData.changeClaim
                     }
-                    operation = 7
+                    operation = '7'
                     break
-                case 3:
-                case 4:
+                case '3':
+                case '4':
                     if(this.currentEditData.claimChangeSuggestion){
                         this.changeClaim.claimChangeSuggestion = this.currentEditData.claimChangeSuggestion
                     }
                     question = this.currentEditData.claimChangeSuggestion
-                    operation = 4
+                    operation = '4'
                     break;
-                case 5:
-                case 8:
+                case '5':
+                case '8':
                     this.main_claim_reason = this.currentEditData.main_claim_reason
-                    operation = 8
+                    operation = '8'
                     break
-                case 6://答复意见
+                case '6'://答复意见
                     this.difyQuery = this.currentEditData.replyOpinion
-                    question = this.currentEditData.replyOpinion
+                    question = this.currentEditData.replyOpinion || '重新生成'
                     break;
             }
             if(operation != 6){
@@ -815,7 +832,15 @@ export default {
         },
         get_file_obj(data){
             if(data.notice_file){
-                this.$set(this,'notice_file',data.notice_file)
+                if(this.current_guid == this.notice_file.guid){
+                    this.$set(this,'current_guid',data.notice_file.guid)
+                    this.$set(this,'notice_file',data.notice_file)
+                    this.handleOptionClick(data.notice_file,1)
+                }else{
+                    this.$set(this,'notice_file',data.notice_file)
+                }
+                
+                
             }
             if(data.app_file){
                 this.$set(this.relevant_file,'app_file',data.app_file)
@@ -858,6 +883,7 @@ export default {
             let content = this.currentConversation.content
             var params = {
                 confessionSessionId:this.currentConversation.id,
+                guid:this.notice_file.guid
             }
             if(!content){
                 params.content = JSON.stringify(
@@ -1083,8 +1109,13 @@ export default {
         handleOptionClick(obj,type){
             switch(type){
                 case 1:
-                    this.confession = obj
-                    this.getOption()
+                    if(obj.type){
+                        this.confession = obj
+                        this.getOption()
+                    }else{
+                        this.getFileByGuid(obj)
+                    }
+                    break
                 case 2:
                 case 3:
                 case 4:

+ 59 - 17
src/views/AITools/OADefense/dialog/errorTip.vue

@@ -18,6 +18,34 @@
                         <div>上传文件(可拖动上传)</div>
                     </div>
                     <div class="upload-box-container">
+                        <!-- 审查意见通知书 -->
+                        <div v-if="relevant_file.notice_file">
+                            <div v-if="relevant_file.notice_file.showPercentage || relevant_file.notice_file.guid" class="upload-box upload">
+                                <div class="upload-placeholder"><i class="el-icon-star-on red"></i>审查意见通知书</div>
+                                <div class="file-info"><span v-if="!relevant_file.notice_file.showPercentage">已上传:</span><span class="file-name">{{relevant_file.notice_file.name ? relevant_file.notice_file.name : relevant_file.notice_file.originalName}}</span></div>
+                                <div v-if="relevant_file.notice_file.showPercentage" class="progressShow">
+                                    <el-progress :percentage="relevant_file.notice_file.percentage"></el-progress>
+                                </div>
+                                <span class="clear-btn" @click="relevant_file.notice_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,'relevant_file.notice_file')"
+                                style="width: 100%"
+                            >
+                                <div class="el-upload__text">
+                                    <div><i class="el-icon-star-on red"></i>审查意见通知书</div>
+                                    <div>点击或拖到上传</div>
+                                </div>
+                            </el-upload>
+                        </div>
                         <!-- 本申请文件 -->
                         <div v-if="relevant_file.app_file">
                             <div v-if="relevant_file.app_file.showPercentage || relevant_file.app_file.guid" class="upload-box">
@@ -149,24 +177,29 @@ import batchFileDialog from './batchFile.vue';
             this.tip = tip.data.replace('\n','<br>')
             let non_existent_files = tip.non_existent_files
             this.$set(this,'relevant_file',{})
-            if(non_existent_files.appNo){
-                this.$set(this.relevant_file,'app_file',{})
-            }
-            if(non_existent_files.modify){
-                this.$set(this.relevant_file,'modify_file',{})
-            }
-            if(non_existent_files.publicNos && non_existent_files.publicNos.length){
-                this.$set(this.relevant_file,'contrast_file',[])
-                non_existent_files.publicNos.forEach(item=>{
-                    this.relevant_file.contrast_file.push(
-                        {
-                            order:item.index,
-                            publicNo:item.publicNo,
-                            file:{}
-                        }
-                    )
-                })
+            if(non_existent_files){
+                if(non_existent_files.appNo){
+                    this.$set(this.relevant_file,'app_file',{})
+                }
+                if(non_existent_files.modify){
+                    this.$set(this.relevant_file,'modify_file',{})
+                }
+                if(non_existent_files.publicNos && non_existent_files.publicNos.length){
+                    this.$set(this.relevant_file,'contrast_file',[])
+                    non_existent_files.publicNos.forEach(item=>{
+                        this.relevant_file.contrast_file.push(
+                            {
+                                order:item.index,
+                                publicNo:item.publicNo,
+                                file:{}
+                            }
+                        )
+                    })
+                }
+            }else{
+                this.$set(this.relevant_file,'notice_file',{})
             }
+            
             this.$set(this,'patent_fileUrls',[])
             this.visible = true
         },
@@ -222,6 +255,9 @@ import batchFileDialog from './batchFile.vue';
             this.$refs.batchFile.open()
         },
         get_file_obj(data){
+            if(data.notice_file){
+                this.$set(this.relevant_file,'notice_file',data.notice_file)
+            }
             if(data.app_file){
                 this.$set(this.relevant_file,'app_file',data.app_file)
             }
@@ -280,6 +316,12 @@ import batchFileDialog from './batchFile.vue';
             //     return
             // }
             // this.$emit('submit',this.patent_fileUrls)
+            if(this.relevant_file.notice_file){
+                if(!this.relevant_file.notice_file.guid){
+                    this.$message.warning('请上传缺少的相关文件后再运行!')
+                    return
+                }
+            }
             if(this.relevant_file.app_file){
                 if(!this.relevant_file.app_file.guid){
                     this.$message.warning('请上传缺少的相关文件后再运行!')

+ 63 - 55
src/views/AITools/OADefense/mixins/index1.js

@@ -55,11 +55,12 @@ export default {
             var chatRecord = {}
             await this.$api.saveChatRecord(params).then(response=>{
                 if(response.code == 200){
-                    let id = response.data
-                    chatRecord = {
-                        id:id,
-                        ...params
-                    }
+                    // let id = response.data
+                    // chatRecord = {
+                    //     id:id,
+                    //     ...params
+                    // }
+                    chatRecord = response.data
                 }
             })
             return chatRecord
@@ -75,46 +76,44 @@ export default {
                     }
                 })
             }
-            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,
-                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;
-            //     }
+            // 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,
+            //     near_index:this.changeClaim.near_index,
+            //     main_claim_reason:JSON.stringify(this.main_claim_reason),
+            //     claimChangeSuggestion:this.changeClaim.claimChangeSuggestion,
+            //     operation:operation+''
+            // }
+            // var params = {
+            //     inputs:inputs,
+            //     query:this.difyQuery || 'OA答辩',
+            //     conversation_id:this.currentConversation.conversationId,
+            //     response_mode:'streaming',
+            //     user:this.userinfo.id
             // }
-            
-
             var params = {
-                inputs:inputs,
+                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.trim(),
+                nearIndex:this.changeClaim.near_index,
+                mainClaimReason:JSON.stringify(this.main_claim_reason),
+                claimChangeSuggestion:this.changeClaim.claimChangeSuggestion.trim(),
+                operation:operation+'',
+                messageId:message.id,
                 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.result = null
-            const response = await fetch('https://ai.xsip.cn/v1/chat-messages', {
+            const response = await fetch('/api/xiaoshi/dify/sendOADefense2', {
               method: 'POST',
               headers: {
                 'Content-Type': 'application/json',
@@ -129,6 +128,7 @@ export default {
             const decoder = new TextDecoder('utf-8');
             let noFinishMessage = ''
             message.answer = ''
+            let answer_code = ''
             while (true) {
                 const { done, value } = await reader.read();
                 if (done){
@@ -140,19 +140,25 @@ export default {
                     let params  = {
                         ...message
                     }
-                    if(typeof (params.answer) != "string"){
-                        params.answer = JSON.stringify(params.answer)
-                    }else{
-                        params.answer =  params.answer.replace('undefined','')
+                    // if(typeof (params.answer) != "string"){
+                    //     params.answer = JSON.stringify(params.answer)
+                    // }else{
+                    //     params.answer =  params.answer.replace('undefined','')
+                    // }
+                    // this.addChatRecord(params)
+                    if(params.operation == 1){
+                        if(answer_code == 203){
+                            this.sendMessage(null,2)
+                        }
                     }
-                    this.addChatRecord(params)
+
                     if(params.operation == 3){
                         this.changeClaim.claimChangeSuggestion = params.answer
-                        this.updateContent()
+                        // this.updateContent()
                     }
                     if(params.operation == 4){
                         this.changeClaim.claim = params.answer
-                        this.updateContent()
+                        // this.updateContent()
                     }
                     break;
                 } 
@@ -169,7 +175,7 @@ export default {
                         if(json.event == 'message'){
                             if(!this.currentConversation.conversationId){
                                 this.currentConversation.conversationId = json.conversation_id
-                                this.saveConversationId(json.conversation_id)
+                                // this.saveConversationId(json.conversation_id)
                             }
                             if(message.loading){
                                 this.$set(message,'loading',false)
@@ -183,6 +189,7 @@ export default {
                                 }
                                 
                                 if(operation == 1){
+                                    answer_code = answer_json.code
                                     if(answer_json.code == 1001){//缺少专利文件
                                         this.$refs.errorTip.open(answer_json)
                                     }else if(answer_json.code == 203){//文件输出
@@ -194,20 +201,20 @@ export default {
                                             modify_file:this.modify_file,
                                             contrast_file:this.contrast_file
                                         }
-                                        this.updateContent()
-                                        this.sendMessage(null,2)
+                                        // this.updateContent()
+                                        
                                     }
                                 }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()
+                                    // this.updateContent()
                                 }else if(operation == 5){
                                     this.main_claim_reason = answer_json
-                                    this.updateContent()
+                                    // this.updateContent()
                                 }else if(operation == 6){
-                                    this.updateContent(operation,answer_json)
+                                    // this.updateContent(operation,answer_json)
                                 }
                                 
                             }catch(e){
@@ -244,6 +251,7 @@ export default {
                                                this.$set(message,'answer',answer_json) 
                                             }
                                             if(operation == 1){
+                                                answer_code = answer_json.code
                                                 if(answer_json.code == 1001){//缺少专利文件
                                                     this.$refs.errorTip.open(answer_json)
                                                 }else if(answer_json.code == 203){//文件输出
@@ -255,7 +263,7 @@ export default {
                                                         modify_file:this.modify_file,
                                                         contrast_file:this.contrast_file
                                                     }
-                                                    this.updateContent()
+                                                    // this.updateContent()
                                                     this.sendMessage(null,2)
                                                 }
                                             }else if(operation == 2){
@@ -263,12 +271,12 @@ export default {
                                                 this.changeClaim.nearNo = answer_json.nearNo
                                                 this.changeClaim.changeClaim = answer_json.changeClaim
                                                 this.changeClaim.novelty_innovative = answer_json.novelty_innovative
-                                                this.updateContent()
+                                                // this.updateContent()
                                             }else if(operation == 5){
                                                 this.main_claim_reason = answer_json
-                                                this.updateContent()
+                                                // this.updateContent()
                                             }else if(operation == 6){
-                                                this.updateContent(operation,answer_json)
+                                                // this.updateContent(operation,answer_json)
                                             }
                                         }catch(e){
                                             message.answer += answer.replace(/\n|\\n|\\\n|\\\\n/g,'<br>');
@@ -315,7 +323,7 @@ export default {
             }
             this.$api.updateConfessionSession(params).then(response=>{
                 if(response.code == 200){
-                    this.queryConfessionSession(true)
+                    // this.queryConfessionSession(true)
                 }
             }).catch(error=>{