|
|
@@ -130,7 +130,8 @@
|
|
|
:chat_id="dialogId"
|
|
|
:chat_type="type"
|
|
|
:agentId="agentId"
|
|
|
- :special_refference="item.fullRefference"
|
|
|
+ :special_4_refference="item.fullRefference"
|
|
|
+ :special_4_image="item.fullImageUrls"
|
|
|
/>
|
|
|
</p>
|
|
|
</div>
|
|
|
@@ -144,7 +145,8 @@
|
|
|
:chat_id="dialogId"
|
|
|
:chat_type="type"
|
|
|
:agentId="agentId"
|
|
|
- :special_refference="item.fullRefference"
|
|
|
+ :special_4_refference="item.fullRefference"
|
|
|
+ :special_4_image="item.fullImageUrls"
|
|
|
/>
|
|
|
</div>
|
|
|
|
|
|
@@ -323,6 +325,14 @@ export default defineComponent({
|
|
|
|
|
|
// 完整的引用数据: pdf文档引用效果需要使用此数据
|
|
|
fullRefference: item.reference,
|
|
|
+ // 合法可用的图片地址
|
|
|
+ fullImageUrls: (() => {
|
|
|
+ if(item.images){
|
|
|
+ return item.images;
|
|
|
+ }else{
|
|
|
+ return [];
|
|
|
+ }
|
|
|
+ })(),
|
|
|
|
|
|
// 如果有文件处理完拿第一个,后续有变动再改
|
|
|
file: (item.files && item.files.length > 0) ? item.files.map(item => {
|
|
|
@@ -456,9 +466,14 @@ export default defineComponent({
|
|
|
const isLoaded = ref(false);
|
|
|
const answerData = ref("");
|
|
|
const answerReference = ref([]);
|
|
|
+
|
|
|
const fullRefference = reactive({
|
|
|
full_ref: {}
|
|
|
});
|
|
|
+ const fullImageUrls = reactive({
|
|
|
+ url: []
|
|
|
+ });
|
|
|
+
|
|
|
const imageUrl = ref(undefined);
|
|
|
const answerFile = ref(undefined);
|
|
|
const answerCode = ref(undefined);
|
|
|
@@ -471,7 +486,10 @@ export default defineComponent({
|
|
|
const addAnswer = (data) => {
|
|
|
data.answer = answerData.value;
|
|
|
data.reference = answerReference.value;
|
|
|
+
|
|
|
data.fullRefference = fullRefference.full_ref; // 完整的引用数据
|
|
|
+ data.fullImageUrls = fullImageUrls.url; // 图片地址数据
|
|
|
+
|
|
|
data.image_url = imageUrl.value;
|
|
|
data.code = answerCode.value;
|
|
|
data.file = answerFile.value;
|
|
|
@@ -513,16 +531,18 @@ export default defineComponent({
|
|
|
|
|
|
function createSocket() {
|
|
|
const token = helper.read("token");
|
|
|
+ const p_type = props.type;
|
|
|
+
|
|
|
// 如果是智能数据,则拿缓存里的数据开启对话
|
|
|
if (helper.read("sendData") && helper.read("sendData").agent_id == 'basic_excel_talk') {
|
|
|
const data = helper.read("sendData");
|
|
|
|
|
|
- helper.webSocket = ajax.message.create(token, data.agent_id, data.chat_id, props.type);
|
|
|
+ helper.webSocket = ajax.message.create(token, data.agent_id, data.chat_id, p_type);
|
|
|
|
|
|
// 创建对话之后清空缓存
|
|
|
helper.write('sendData', {});
|
|
|
} else {
|
|
|
- helper.webSocket = ajax.message.create(token, props.agentId, props.dialogId, props.type);
|
|
|
+ helper.webSocket = ajax.message.create(token, props.agentId, props.dialogId, p_type);
|
|
|
}
|
|
|
|
|
|
// 监听socket开启事件
|
|
|
@@ -579,12 +599,14 @@ export default defineComponent({
|
|
|
}
|
|
|
|
|
|
const { type, reference, step_message, files } = res_data;
|
|
|
+ const msg_type = type; // 返回的消息类型
|
|
|
+ const chat_type = props.type; // 对话的类型
|
|
|
|
|
|
let { message } = res_data;
|
|
|
|
|
|
if (!loadingData.value) return;
|
|
|
|
|
|
- if (type === "stream") {
|
|
|
+ if (msg_type === "stream") {
|
|
|
// 没解析完就一直loading
|
|
|
if (step_message == '文件上传完成,开始解析') {
|
|
|
emit("changeParse", true);
|
|
|
@@ -607,7 +629,7 @@ export default defineComponent({
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- if (type === "message") {
|
|
|
+ if (msg_type === "message") {
|
|
|
// 获取此时的聊天临时聊天记录中的序号
|
|
|
const cur_index = tempHistory.getChatIndex(cur_chat_id);
|
|
|
|
|
|
@@ -630,7 +652,7 @@ export default defineComponent({
|
|
|
}
|
|
|
|
|
|
// 智能数据
|
|
|
- if (props.type == 'smartData') {
|
|
|
+ if (chat_type == 'smartData') {
|
|
|
answerData.value = '正在处理中...'
|
|
|
// 以下是智能数据对话的变量
|
|
|
const { image_url, excel_url, excel_name, code, sql } = JSON.parse(evt_dt);
|
|
|
@@ -655,8 +677,9 @@ export default defineComponent({
|
|
|
|
|
|
if (sql) answerSql.value = getHTML(sql);
|
|
|
}
|
|
|
+
|
|
|
// 出题
|
|
|
- if (props.type == 'question') {
|
|
|
+ if (chat_type == 'question') {
|
|
|
const { file_url, file_name } = JSON.parse(evt_dt);
|
|
|
const port = window.location.port ? `:${window.location.port}` : '';
|
|
|
|
|
|
@@ -677,7 +700,7 @@ export default defineComponent({
|
|
|
addAnswer(loadingData.value);
|
|
|
}
|
|
|
|
|
|
- if (type === "close") {
|
|
|
+ if (msg_type === "close") {
|
|
|
if (!answerData.value) {
|
|
|
answerLoaded();
|
|
|
answerData.value = getHTML(message);
|
|
|
@@ -686,6 +709,39 @@ export default defineComponent({
|
|
|
stopWriting();
|
|
|
answerData.value = "";
|
|
|
isLoaded.value = false;
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 在小数绘图对话结束时
|
|
|
+ * 存在一个字段数据
|
|
|
+ */
|
|
|
+ if(chat_type === 'huitu'){
|
|
|
+ // 获取此时的聊天临时聊天记录中的序号
|
|
|
+ const cur_index = tempHistory.getChatIndex(cur_chat_id);
|
|
|
+
|
|
|
+ message = replaceCode(message, cur_index);
|
|
|
+ answerData.value = getHTML(message);
|
|
|
+
|
|
|
+ // 小数绘图
|
|
|
+ if(res_data.message_files){
|
|
|
+ console.log(11);
|
|
|
+ const arr = [];
|
|
|
+
|
|
|
+ if(Array.isArray(res_data.message_files)){
|
|
|
+ console.log(12);
|
|
|
+
|
|
|
+ res_data.message_files.forEach((item, index) => {
|
|
|
+ console.log(13, index);
|
|
|
+ arr.push(item.url);
|
|
|
+ });
|
|
|
+
|
|
|
+ console.log(arr, 'arr');
|
|
|
+
|
|
|
+ fullImageUrls.url = arr;
|
|
|
+ }else{
|
|
|
+ fullImageUrls.url = arr;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
// // 获取所有的临时历史记录
|
|
|
@@ -717,22 +773,37 @@ export default defineComponent({
|
|
|
*/
|
|
|
helper.$bus.on("send-message", (value) => {
|
|
|
dialogConfig.value = helper.dialogConfig;
|
|
|
- const question = props.type === "report" ? value.inputs.report_name : value;
|
|
|
+
|
|
|
+ const chat_type = props.type; // 对话的类型
|
|
|
+
|
|
|
+ const question = chat_type === "report" ? value.inputs.report_name : value;
|
|
|
const data = addQuestion(question);
|
|
|
loadingData.value = addLoading(data);
|
|
|
- let sendData =
|
|
|
- props.type === "report" || props.type === "excel"
|
|
|
- ? value
|
|
|
- : {
|
|
|
- message: value
|
|
|
- };
|
|
|
|
|
|
- if (props.type === 'doc') {
|
|
|
+ let sendData = {
|
|
|
+ message: value
|
|
|
+ }
|
|
|
+
|
|
|
+ if(chat_type === "report"){
|
|
|
+ sendData = value;
|
|
|
+ }
|
|
|
+
|
|
|
+ if(chat_type === "excel"){
|
|
|
+ sendData = value;
|
|
|
+ }
|
|
|
+
|
|
|
+ // chat_type === "report" || chat_type === "excel"
|
|
|
+ // ? value
|
|
|
+ // : {
|
|
|
+ // message: value
|
|
|
+ // };
|
|
|
+
|
|
|
+ if (chat_type === 'doc') {
|
|
|
sendData.doc_ids = [helper.read('docId')];
|
|
|
}
|
|
|
|
|
|
// 小数绘图
|
|
|
- if(props.type === 'huitu'){
|
|
|
+ if(chat_type === 'huitu'){
|
|
|
const img_file = helper.read('sendData');
|
|
|
if(img_file){
|
|
|
const upload_file_id = img_file.upload_file_id;
|