Эх сурвалжийг харах

处理公式函数及内外部知识库区分

yangg 9 сар өмнө
parent
commit
28c92815dc
50 өөрчлөгдсөн 397 нэмэгдсэн , 149 устгасан
  1. 0 0
      dist/index.html
  2. 0 0
      dist/static/css/app.2d6ec3ea.css
  3. 0 1
      dist/static/css/chunk-2b49eda5.b34e6023.css
  4. 0 0
      dist/static/css/chunk-4269f43b.ce959b8e.css
  5. 0 0
      dist/static/css/chunk-7c02fbbc.775a21e3.css
  6. 1 0
      dist/static/css/chunk-b4ab3520.ac5c2bcf.css
  7. 0 0
      dist/static/css/chunk-db25e5ec.68741a84.css
  8. 0 0
      dist/static/js/app.73878e5f.js
  9. 0 0
      dist/static/js/app.79eb093a.js
  10. 0 0
      dist/static/js/chunk-09c6c984.176e2c2d.js
  11. 0 0
      dist/static/js/chunk-0a97e1f4.c2abdbf7.js
  12. 0 0
      dist/static/js/chunk-0aff232d.6044a099.js
  13. 0 0
      dist/static/js/chunk-227fce26.d4e347ce.js
  14. 0 0
      dist/static/js/chunk-2b49eda5.b8742509.js
  15. 0 0
      dist/static/js/chunk-35464144.b9272b84.js
  16. 0 0
      dist/static/js/chunk-359e4600.57f077a0.js
  17. 0 0
      dist/static/js/chunk-3d9675b3.9145f9c8.js
  18. 0 0
      dist/static/js/chunk-4139ed56.8ff819b3.js
  19. 0 0
      dist/static/js/chunk-4269f43b.20f5f920.js
  20. 0 0
      dist/static/js/chunk-44eee83d.147179cf.js
  21. 0 0
      dist/static/js/chunk-47fa645a.bd1c9bc1.js
  22. 0 0
      dist/static/js/chunk-52f685c2.03405328.js
  23. 0 0
      dist/static/js/chunk-5a3bdf57.e8961240.js
  24. 0 0
      dist/static/js/chunk-5b1b00c6.fe5a6f00.js
  25. 0 0
      dist/static/js/chunk-6155c71d.d19aca08.js
  26. 0 0
      dist/static/js/chunk-6a80e4ca.fd0df70b.js
  27. 0 0
      dist/static/js/chunk-6b49e032.57baf1f6.js
  28. 0 0
      dist/static/js/chunk-6ddf6871.81f0be53.js
  29. 0 0
      dist/static/js/chunk-76756389.d763329d.js
  30. 0 0
      dist/static/js/chunk-7a88741c.d6509271.js
  31. 1 1
      dist/static/js/chunk-7c02fbbc.72d5e308.js
  32. 0 0
      dist/static/js/chunk-aeb9b426.f1ece2e3.js
  33. 0 0
      dist/static/js/chunk-b4ab3520.3cb31a11.js
  34. 0 0
      dist/static/js/chunk-c5d7799a.ccce2b22.js
  35. 0 0
      dist/static/js/chunk-cde19f0e.9ea08112.js
  36. 0 0
      dist/static/js/chunk-d649fd9a.42f44f7c.js
  37. 0 0
      dist/static/js/chunk-db25e5ec.b675e383.js
  38. 0 0
      dist/static/js/chunk-e6bc7406.afb795a7.js
  39. 0 0
      dist/static/js/chunk-f23301fc.6b884ccb.js
  40. 0 0
      dist/static/js/chunk-libs.1e1db6b8.js
  41. 0 0
      dist/static/js/chunk-libs.fe317445.js
  42. 1 1
      package.json
  43. 174 0
      src/components/FilePreview/index.vue
  44. 45 6
      src/components/webAi/css/ChatBox.css
  45. 39 4
      src/components/webAi/js/ChatBox.js
  46. 76 39
      src/views/document/com/components/TextArea/index.vue
  47. 1 75
      src/views/document/com/components/sourceAi/index.vue
  48. 9 3
      src/views/document/com/menus.vue
  49. 28 12
      src/views/document/com/view.vue
  50. 22 7
      src/views/knowledgeMenu/category/infoList.vue

Файлын зөрүү хэтэрхий том тул дарагдсан байна
+ 0 - 0
dist/index.html


Файлын зөрүү хэтэрхий том тул дарагдсан байна
+ 0 - 0
dist/static/css/app.2d6ec3ea.css


+ 0 - 1
dist/static/css/chunk-2b49eda5.b34e6023.css

@@ -1 +0,0 @@
-.project-search[data-v-659a1004]{display:-webkit-box;display:-ms-flexbox;display:flex;padding:10px;font-size:12px}.listClass[data-v-659a1004]{display:-webkit-box;display:-ms-flexbox;display:flex;-webkit-box-align:center;-ms-flex-align:center;align-items:center;-webkit-box-pack:justify;-ms-flex-pack:justify;justify-content:space-between}.excel-table[data-v-659a1004]{width:100%;overflow-y:auto}.excel-table table[data-v-659a1004]{border-collapse:collapse;width:100%;margin-bottom:20px}.excel-table td[data-v-659a1004],.excel-table th[data-v-659a1004]{border:1px solid #ddd;padding:8px;text-align:left;white-space:nowrap}.excel-table th[data-v-659a1004]{background-color:#f2f2f2;font-weight:700;position:sticky;top:0;z-index:1}.excel-table tr[data-v-659a1004]:nth-child(2n){background-color:#f9f9f9}.no-data[data-v-659a1004]{font-size:18px;color:#909399;text-align:center;margin-top:50px}

+ 0 - 0
dist/static/css/chunk-76756389.ce959b8e.css → dist/static/css/chunk-4269f43b.ce959b8e.css


+ 0 - 0
dist/static/css/chunk-0a651140.775a21e3.css → dist/static/css/chunk-7c02fbbc.775a21e3.css


+ 1 - 0
dist/static/css/chunk-b4ab3520.ac5c2bcf.css

@@ -0,0 +1 @@
+.project-search[data-v-05222c55]{display:-webkit-box;display:-ms-flexbox;display:flex;padding:10px;font-size:12px}.listClass[data-v-05222c55]{display:-webkit-box;display:-ms-flexbox;display:flex;-webkit-box-align:center;-ms-flex-align:center;align-items:center;-webkit-box-pack:justify;-ms-flex-pack:justify;justify-content:space-between}.excel-table[data-v-05222c55]{width:100%;overflow-y:auto}.excel-table table[data-v-05222c55]{border-collapse:collapse;width:100%;margin-bottom:20px}.excel-table td[data-v-05222c55],.excel-table th[data-v-05222c55]{border:1px solid #ddd;padding:8px;text-align:left;white-space:nowrap}.excel-table th[data-v-05222c55]{background-color:#f2f2f2;font-weight:700;position:sticky;top:0;z-index:1}.excel-table tr[data-v-05222c55]:nth-child(2n){background-color:#f9f9f9}.no-data[data-v-05222c55]{font-size:18px;color:#909399;text-align:center;margin-top:50px}

+ 0 - 0
dist/static/css/chunk-09c6c984.68741a84.css → dist/static/css/chunk-db25e5ec.68741a84.css


Файлын зөрүү хэтэрхий том тул дарагдсан байна
+ 0 - 0
dist/static/js/app.73878e5f.js


Файлын зөрүү хэтэрхий том тул дарагдсан байна
+ 0 - 0
dist/static/js/app.79eb093a.js


Файлын зөрүү хэтэрхий том тул дарагдсан байна
+ 0 - 0
dist/static/js/chunk-09c6c984.176e2c2d.js


+ 0 - 0
dist/static/js/chunk-0a97e1f4.317fc6ba.js → dist/static/js/chunk-0a97e1f4.c2abdbf7.js


Файлын зөрүү хэтэрхий том тул дарагдсан байна
+ 0 - 0
dist/static/js/chunk-0aff232d.6044a099.js


+ 0 - 0
dist/static/js/chunk-227fce26.758d66d8.js → dist/static/js/chunk-227fce26.d4e347ce.js


Файлын зөрүү хэтэрхий том тул дарагдсан байна
+ 0 - 0
dist/static/js/chunk-2b49eda5.b8742509.js


+ 0 - 0
dist/static/js/chunk-35464144.e795ead5.js → dist/static/js/chunk-35464144.b9272b84.js


+ 0 - 0
dist/static/js/chunk-359e4600.e7311a4f.js → dist/static/js/chunk-359e4600.57f077a0.js


+ 0 - 0
dist/static/js/chunk-3d9675b3.f01c0ed2.js → dist/static/js/chunk-3d9675b3.9145f9c8.js


+ 0 - 0
dist/static/js/chunk-4139ed56.683be18b.js → dist/static/js/chunk-4139ed56.8ff819b3.js


Файлын зөрүү хэтэрхий том тул дарагдсан байна
+ 0 - 0
dist/static/js/chunk-4269f43b.20f5f920.js


+ 0 - 0
dist/static/js/chunk-44eee83d.f5067198.js → dist/static/js/chunk-44eee83d.147179cf.js


+ 0 - 0
dist/static/js/chunk-47fa645a.9abdc039.js → dist/static/js/chunk-47fa645a.bd1c9bc1.js


+ 0 - 0
dist/static/js/chunk-52f685c2.6e0d1263.js → dist/static/js/chunk-52f685c2.03405328.js


+ 0 - 0
dist/static/js/chunk-5a3bdf57.6b643fb2.js → dist/static/js/chunk-5a3bdf57.e8961240.js


+ 0 - 0
dist/static/js/chunk-5b1b00c6.64a30a77.js → dist/static/js/chunk-5b1b00c6.fe5a6f00.js


+ 0 - 0
dist/static/js/chunk-6155c71d.e659c4af.js → dist/static/js/chunk-6155c71d.d19aca08.js


+ 0 - 0
dist/static/js/chunk-6a80e4ca.18a7894d.js → dist/static/js/chunk-6a80e4ca.fd0df70b.js


+ 0 - 0
dist/static/js/chunk-6b49e032.905555a0.js → dist/static/js/chunk-6b49e032.57baf1f6.js


+ 0 - 0
dist/static/js/chunk-6ddf6871.007db15a.js → dist/static/js/chunk-6ddf6871.81f0be53.js


Файлын зөрүү хэтэрхий том тул дарагдсан байна
+ 0 - 0
dist/static/js/chunk-76756389.d763329d.js


+ 0 - 0
dist/static/js/chunk-7a88741c.ee63f65f.js → dist/static/js/chunk-7a88741c.d6509271.js


Файлын зөрүү хэтэрхий том тул дарагдсан байна
+ 1 - 1
dist/static/js/chunk-7c02fbbc.72d5e308.js


+ 0 - 0
dist/static/js/chunk-aeb9b426.51ca49bb.js → dist/static/js/chunk-aeb9b426.f1ece2e3.js


Файлын зөрүү хэтэрхий том тул дарагдсан байна
+ 0 - 0
dist/static/js/chunk-b4ab3520.3cb31a11.js


+ 0 - 0
dist/static/js/chunk-c5d7799a.194677e9.js → dist/static/js/chunk-c5d7799a.ccce2b22.js


Файлын зөрүү хэтэрхий том тул дарагдсан байна
+ 0 - 0
dist/static/js/chunk-cde19f0e.9ea08112.js


+ 0 - 0
dist/static/js/chunk-d649fd9a.04a273aa.js → dist/static/js/chunk-d649fd9a.42f44f7c.js


Файлын зөрүү хэтэрхий том тул дарагдсан байна
+ 0 - 0
dist/static/js/chunk-db25e5ec.b675e383.js


+ 0 - 0
dist/static/js/chunk-e6bc7406.0356416c.js → dist/static/js/chunk-e6bc7406.afb795a7.js


+ 0 - 0
dist/static/js/chunk-f23301fc.0846967e.js → dist/static/js/chunk-f23301fc.6b884ccb.js


Файлын зөрүү хэтэрхий том тул дарагдсан байна
+ 0 - 0
dist/static/js/chunk-libs.1e1db6b8.js


Файлын зөрүү хэтэрхий том тул дарагдсан байна
+ 0 - 0
dist/static/js/chunk-libs.fe317445.js


+ 1 - 1
package.json

@@ -47,7 +47,7 @@
     "jszip-utils": "^0.1.0",
     "luckyexcel": "^1.0.1",
     "luckysheet": "^2.1.13",
-    "mammoth": "^1.6.0",
+    "mammoth": "^1.8.0",
     "markdown-it": "^13.0.2",
     "normalize.css": "7.0.0",
     "nprogress": "^0.2.0",

+ 174 - 0
src/components/FilePreview/index.vue

@@ -0,0 +1,174 @@
+<template>
+  <div class="file-preview">
+    <div v-if="isSupported">
+      <!-- PDF 预览 -->
+      <iframe
+        v-if="fileType === 'pdf'"
+        :src="fileUrl"
+        width="100%"
+        height="822px"
+      ></iframe>
+
+      <!-- 图片预览 -->
+      <img
+        v-else-if="isImage"
+        :src="fileUrl"
+        alt="图片预览"
+        style="max-width: 100%; max-height: 822px"
+      />
+
+      <!-- Word 文档预览 -->
+      <div v-if="isWord && wordLoaded" v-html="wordContent" class="word-preview"></div>
+      <div v-else-if="isWord && !wordLoaded" class="loading-word">
+        {{ wordLoadingError ? '加载失败,请重试' : '加载中...' }}
+      </div>
+
+      <!-- 其他 Office 文档预览 -->
+      <iframe
+        v-else-if="isOffice"
+        :src="officePreviewUrl"
+        width="100%"
+        height="822px"
+      ></iframe>
+
+      <!-- 文本文件预览 -->
+      <pre
+        v-else-if="fileType === 'txt'"
+        style="max-height: 822px; overflow: auto"
+        >{{ textContent }}</pre
+      >
+    </div>
+    <div v-else class="unsupported-file">
+      不支持预览该文件类型,<a :href="fileUrl" download>点击下载</a>
+    </div>
+  </div>
+</template>
+  
+  <script>
+import mammoth from "mammoth";
+export default {
+  props: {
+    fileUrl: {
+      type: String,
+      required: true,
+    },
+    fileType: {
+      type: String,
+      required: true,
+    },
+  },
+  data() {
+    return {
+      textContent: "",
+      wordContent: "",
+      supportedTypes: [
+        "pdf",
+        "doc",
+        "docx",
+        "xls",
+        "xlsx",
+        "ppt",
+        "pptx",
+        "txt",
+        "jpg",
+        "jpeg",
+        "png",
+        "gif",
+      ],
+      wordLoaded: false,
+      wordLoadingError: false,
+    };
+  },
+  watch: {
+    fileUrl: {
+      immediate: true,
+      handler() {
+        if (this.isWord) {
+          this.loadWordContent();
+        }
+      },
+    },
+  },
+  computed: {
+    isSupported() {
+      return this.supportedTypes.includes(this.fileType);
+    },
+    isImage() {
+      return ["jpg", "jpeg", "png", "gif"].includes(this.fileType);
+    },
+    isWord() {
+      return ["doc", "docx"].includes(this.fileType);
+    },
+    isOffice() {
+      return ["xls", "xlsx", "ppt", "pptx"].includes(this.fileType);
+    },
+  },
+  mounted() {
+    if (this.fileType === "txt") {
+      this.loadTextContent();
+    } else if (this.isWord) {
+      this.loadWordContent();
+    }
+  },
+  methods: {
+    async loadWordContent() {
+      this.wordLoaded = false;
+      this.wordLoadingError = false;
+
+      try {
+        const response = await fetch(this.fileUrl);
+        if (!response.ok) {
+          throw new Error(`HTTP error! status: ${response.status}`);
+        }
+        const blob = await response.blob();
+        const arrayBuffer = await this.blobToArrayBuffer(blob);
+        const result = await mammoth.convertToHtml({ arrayBuffer });
+        this.wordContent = result.value;
+        this.wordLoaded = true;
+      } catch (error) {
+        console.error("加载Word文档内容时出错:", error);
+        this.wordContent = "无法加载Word文档内容";
+        this.wordLoadingError = true;
+      } finally {
+        this.wordLoaded = true;
+      }
+    },
+    blobToArrayBuffer(blob) {
+      return new Promise((resolve, reject) => {
+        const reader = new FileReader();
+        reader.onload = () => resolve(reader.result);
+        reader.onerror = reject;
+        reader.readAsArrayBuffer(blob);
+      });
+    },
+  },
+};
+</script>
+  
+  <style scoped>
+.file-preview {
+  width: 100%;
+  height: 822px;
+  overflow: auto;
+}
+.unsupported-file {
+  display: flex;
+  justify-content: center;
+  align-items: center;
+  height: 100%;
+  font-size: 18px;
+  color: #909399;
+}
+.word-preview {
+  padding: 20px;
+  background-color: white;
+}
+.loading-word {
+  display: flex;
+  justify-content: center;
+  align-items: center;
+  height: 100%;
+  font-size: 18px;
+  color: #909399;
+}
+</style>

+ 45 - 6
src/components/webAi/css/ChatBox.css

@@ -15,6 +15,15 @@
     padding: 10px; /* 或你希望的内边距大小 */
     margin-bottom: 120px;
 }
+/* 针对手机端的媒体查询 */
+@media screen and (max-width: 768px) {
+    .messages {
+        width: 100%;
+        max-width: 100%;
+        margin: 0;
+        margin-bottom: 120px;
+    }
+}
 
 .messages li {
     display: flex;
@@ -33,6 +42,7 @@
 
 
 .user-avatar {
+
     background-image: url('../assets/用户.png') ;
     background-position: center;
     background-repeat: no-repeat;
@@ -41,12 +51,20 @@
 }
 
 .bot-avatar {
+  
     background-image: url('../assets/机器人.png');
     background-position: center;
     background-repeat: no-repeat;
     background-size: cover;
     /* background-color: green; */ /* AI头像颜色 */
 }
+/* 针对手机端的媒体查询 */
+@media screen and (max-width: 768px) {
+    .user-avatar, .bot-avatar {
+        width: 30px;  /* 或其他更小的尺寸 */
+        height: 30px;
+    }
+}
 
 .message-content {
     background-color: #f0f0f0; /* 消息背景 */
@@ -54,7 +72,7 @@
     padding-right: 20px; /* 上下左右的内边距 */
     padding-top: 10px; /* 上下左右的内边距 */
     padding-bottom: 0px; /* 上下左右的内边距 */
-    max-width: calc(82% - 10px); /* 计算头像和间距 */
+    max-width: calc(90% - 10px); /* 计算头像和间距 */
     border-radius: 15px; /* 边框圆角 */
     margin-bottom: 10px; /* 和下一条消息之间的间距 */
     /* 消息内容样式 */
@@ -68,8 +86,16 @@
     margin: 0;
     white-space: normal; /* 确保文本会换行 */
     word-wrap: break-word; /* 长单词或 URL 会被断开以适应容器宽度 */
-}
 
+}
+.message-text ::v-deep p {
+    font-size: 14px !important;
+    margin: 5px 0 10px;
+    padding: 0;
+    font-size: inherit;
+    line-height: inherit;
+    font-weight: inherit;
+  }
 .input-container {
     position: absolute; /* 改为绝对定位 */
     bottom: 10px; /* 距离底部的距离 */
@@ -105,7 +131,7 @@ textarea {
 }
 
 .input-container button {
-    min-width: 100px; /* 例如,按钮的最小宽度为 100px */
+    min-width: 80px; /* 例如,按钮的最小宽度为 100px */
     white-space: nowrap; /* 防止文字折行 */
     padding: 10px 20px;
     cursor: pointer;
@@ -117,13 +143,26 @@ textarea {
 .sender-name {
     font-weight: bold;
     color: #333;
-    margin-bottom: 5px;
+    
 }
 
-.btn{
+.btn {
     font-size: 16px;
     color: #ffffff;
     border-radius: 5px;
-    border: #3cbade;
+    border: none;
     background-color: #3cbade;
+    padding: 10px 20px;  /* 添加内边距 */
+    width: auto;  /* 让宽度自适应内容 */
+}
+
+/* 针对手机端的媒体查询 */
+@media screen and (max-width: 768px) {
+    .btn {
+        font-size: 14px;  /* 稍微减小字体大小 */
+        padding: 8px 16px;  /* 减小内边距 */
+        
+        max-width: 80px;  /* 限制最大宽度 */
+        margin: 0 auto;  /* 居中显示 */
+    }
 }

+ 39 - 4
src/components/webAi/js/ChatBox.js

@@ -17,11 +17,46 @@ export default {
       generating: false,
       userInput: "",
       websocket: null,
+      wsUrl:'http://58.246.234.210:7860/api/v1/run/951e3ba4-c66a-496c-9497-7dbddc2647f8?stream=false',
+      tweaks:{}
     };
   },
   created() {
     this.connectWebSocket();
   },
+  mounted() {
+    if(this.$route.name=='ai'){
+      /* 外部知识库 */
+      this.wsUrl='http://58.246.234.210:7860/api/v1/run/951e3ba4-c66a-496c-9497-7dbddc2647f8?stream=false'
+      this.tweaks={
+              "ChatInput-dDbhW": {},
+              "Prompt-1stgH": {},
+              "ChatOutput-b1zWw": {},
+              "OllamaModel-5n7vc": {},
+              "Milvus-1X7fT": {},
+              "OllamaEmbeddings-V29wK": {},
+              "Memory-GrHZr": {},
+              "ParseData-0dk9n": {}
+            }
+    }else{
+      /* 内部知识库 */
+      this.wsUrl='https://ai.raycos.net/api/v1/run/9263c538-2cd2-4c1b-8c9a-3bb986920d6d?stream=false'
+      this.tweaks={
+              "ChatInput-NYqTq": { },
+              "Prompt-oVfSC": {},
+              "ChatOutput-sA5Uc": {},
+              "SplitText-GvztW": {},
+              "File-rHitZ": {},
+              "OllamaEmbeddings-bQe5H": {},
+              "Milvus-QVby8": {},
+              "OllamaModel-UxNZ1": {},
+              "Milvus-XiwA4": {},
+              "OllamaEmbeddings-91fPV": {},
+              "Memory-ZBrXL": {},
+              "ParseData-ZmaJQ": {}
+            }
+    }
+  },
   methods: {
     getUuid() {
       return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(
@@ -34,7 +69,7 @@ export default {
       );
     },
     connectWebSocket() {
-      const wsUrl = 'http://58.246.234.210:7860/api/v1/run/951e3ba4-c66a-496c-9497-7dbddc2647f8?stream=false'//process.env.VUE_APP_WS_URL;
+      const wsUrl = this.wsUrl//'http://58.246.234.210:7860/api/v1/run/951e3ba4-c66a-496c-9497-7dbddc2647f8?stream=false'
       // 这里做一个简单的鉴权,只有符合条件的鉴权才能握手成功
       // 移除这里的fetch调用,改用WebSocket
       this.websocket = new WebSocket(wsUrl);
@@ -81,7 +116,7 @@ export default {
     },
     async sendMessage() {
       const chatId = this.getUuid();
-      const wsUrl ='http://58.246.234.210:7860/api/v1/run/951e3ba4-c66a-496c-9497-7dbddc2647f8?stream=false'// process.env.VUE_APP_WS_URL;
+      const wsUrl =this.wsUrl//'http://58.246.234.210:7860/api/v1/run/951e3ba4-c66a-496c-9497-7dbddc2647f8?stream=false'
       let message = this.userInput.trim();
       if (message) {
         // Markdown换行:在每个换行符之前添加两个空格
@@ -109,7 +144,7 @@ export default {
               input_value: message,
               output_type: "chat",
               input_type: "chat",
-              tweaks: {
+              tweaks:this.tweaks/*  {
                 "ChatInput-dDbhW": {},
               "Prompt-1stgH": {},
               "ChatOutput-b1zWw": {},
@@ -118,7 +153,7 @@ export default {
               "OllamaEmbeddings-V29wK": {},
               "Memory-GrHZr": {},
               "ParseData-0dk9n": {}
-              },
+              } */,
             }),
           });
 

+ 76 - 39
src/views/document/com/components/TextArea/index.vue

@@ -150,6 +150,19 @@ export default {
   methods: {
     async replaceData(data) {
       let _this = this;
+      // 定义数学函数和 IF 函数
+      const mathFunctions = {
+        abs: Math.abs,
+        ceil: Math.ceil,
+        floor: Math.floor,
+        max: Math.max,
+        min: Math.min,
+        round: Math.round,
+        sqrt: Math.sqrt,
+        IF: (condition, trueValue, falseValue) =>
+          condition ? trueValue : falseValue,
+        // 添加其他需要的数学函数
+      };
       for (var i = 0; i < _this.com.attrs.length; i++) {
         let attrId = _this.com.attrs[i].id;
         if (_this.com.attrs[i].type == "variable") {
@@ -276,44 +289,63 @@ export default {
             data = data.replace("{{" + item.id + "}}", selectHtml);
           }
         } else if (_this.com.attrs[i].type == "formual") {
-          //// console.log('attrs',_this.com.attrs[i]);
           //处理计算公式 不处理
           let formual = await _this.analysisFormual(_this.com.attrs[i]);
           let point = _this.com.attrs[i].data.point;
           formual = await _this.getRemote(formual);
 
+          /* console.log("处理的公式:", formual); // 添加日志 */
+
+          // 收集公式中使用的变量
+          const variables = {};
+          const variableRegex = /\b[a-zA-Z_][a-zA-Z0-9_]*\b/g;
+          const matches = formual.match(variableRegex);
+          if (matches) {
+            for (const varName of matches) {
+              if (
+                varName !== "IF" &&
+                !Object.keys(mathFunctions).includes(varName)
+              ) {
+                variables[varName] = `${varName}`; // 默认值设为0,您可以根据需要修改
+              }
+            }
+          }
+
+        /*   console.log("识别的变量:", variables); // 添加日志 */
+
           // 定义一个安全的评估函数
-          const safeEval = (formula) => {
-            // 定义允许使用的数学函数和 IF 函数
-            const mathFunctions = {
-              abs: Math.abs,
-              ceil: Math.ceil,
-              floor: Math.floor,
-              max: Math.max,
-              min: Math.min,
-              round: Math.round,
-              sqrt: Math.sqrt,
-              IF: (condition, trueValue, falseValue) =>
-                condition ? trueValue : falseValue,
-              // 添加其他需要的数学函数
-            };
-
-            // 创建一个新的函数,将数学函数作为参数传入
+          const safeEval = (formula, variables) => {
+            // 创建一个新的函数,将数学函数和变量作为参数传入
             const func = new Function(
               ...Object.keys(mathFunctions),
+              ...Object.keys(variables),
               `return ${formula}`
             );
 
-            // 执行函数,传入数学函数作为参数
-            return func(...Object.values(mathFunctions));
+            // 执行函数,传入数学函数和变量作为参数
+            return func(
+              ...Object.values(mathFunctions),
+              ...Object.values(variables)
+            );
           };
 
           try {
-            const result = safeEval(formual);
-            _this.com.attrs[i].content = result.toFixed(point);
+            const result = safeEval(formual, variables);
+           /*  console.log("计算结果:", result); // 添加日志 */
+
+            let formattedResult;
+            if (typeof result === "number" && !isNaN(result)) {
+              formattedResult = result.toFixed(point);
+            } else if (typeof result === "boolean") {
+              formattedResult = result ? "1" : "0";
+            } else {
+              formattedResult = String(result);
+            }
+
+            _this.com.attrs[i].content = formattedResult;
             data = data.replace(
               "{{" + _this.com.attrs[i].id + "}}",
-              result.toFixed(point)
+              formattedResult
             );
           } catch (error) {
             console.error("处理公式时出错:", error);
@@ -531,7 +563,7 @@ export default {
     //分析公式
     async analysisFormual(attrs) {
       let _this = this;
-      console.log("开始分析公式:", attrs.formula);
+     /*  console.log("开始分析公式:", attrs.formula); */
       let formual = attrs.formula;
 
       // 处理 [T][...][...] 引用
@@ -542,29 +574,34 @@ export default {
         async (match, p1, p2) => {
           try {
             let data = await _this.getModuleData(p1, p2);
-            console.log(`获取到的数据: ${match} = ${data}`);
-            if (data === null || data === undefined || isNaN(data)) {
+          /*   console.log(`获取到的数据: ${match} = ${data}`); */
+            if (data === null || data === undefined) {
               console.warn(`获取到的数据无效: ${match}`);
-              return "0";
+              return "''"; // 返回空字符串而不是 0
             } else {
-              return `${parseFloat(data)}`;
+              return typeof data === "string" ? `${data}` : data;
             }
           } catch (error) {
             console.error(`处理 ${match} 时出错:`, error);
-            return "0";
+            return "''";
           }
         }
       );
 
       // 处理嵌套的 IF 语句
-      const ifPattern = /IF\s*\((.*?),(.*?),(.*?)\)/g;
+      const ifPattern = /IF\s*\((.*?),(.*?),(.*?)\)/gi;
       let depth = 0;
       while (formual.match(ifPattern) && depth < 10) {
         formual = formual.replace(
           ifPattern,
           (match, condition, trueValue, falseValue) => {
             // 递归处理嵌套的 IF 语句
-            if (trueValue.includes("IF(") || falseValue.includes("IF(")) {
+            if (
+              trueValue.includes("IF(") ||
+              falseValue.includes("IF(") ||
+              trueValue.includes("if(") ||
+              falseValue.includes("if(")
+            ) {
               return `(${condition} ? (${trueValue}) : (${falseValue}))`;
             }
             return `(${condition} ? ${trueValue} : ${falseValue})`;
@@ -573,7 +610,7 @@ export default {
         depth++;
       }
 
-      console.log("分析后的公式:", formual);
+      /* console.log("分析后的公式:", formual); */
       return formual;
     },
 
@@ -749,23 +786,23 @@ export default {
     //获取本地文档模块数据
     async getModuleData(code, attrName) {
       let _this = this;
-      // console.log(`尝试获取模块数据: code=${code}, attrName=${attrName}`);
-      // console.log("当前 coms:", _this.coms);
+      /* console.log(`尝试获取模块数据: code=${code}, attrName=${attrName}`);
+      console.log("当前 coms:", _this.coms); */
 
       let item = _this.coms.filter((o) => o.name == code);
-      // console.log(`找到的模块:`, item);
+    /*   console.log(`找到的模块:`, item); */
 
       if (item.length > 0) {
         let attr = item[0].attrs.filter((o) => o.name == attrName);
-        // console.log(`找到的属性:`, attr);
+        /* console.log(`找到的属性:`, attr); */
 
         if (attr.length > 0) {
-          // console.log(`返回的值:`, attr[0].content);
-          return parseFloat(attr[0].content);
+          /* console.log(`返回的值:`, attr[0].content); */
+          return attr[0].content; // 返回原始值,不进行转换
         }
       }
-      // console.log("未找到匹配的模块或属性,返回 0");
-      return 0;
+     /*  console.log("未找到匹配的模块或属性,返回空字符串"); */
+      return ""; // 返回空字符串而不是 0
     },
 
     handleChangeProduct(e) {

+ 1 - 75
src/views/document/com/components/sourceAi/index.vue

@@ -10,17 +10,11 @@
           style="width: 100%"
         >
           <el-option label="测试模型" :value="0"></el-option>
-          <!-- <el-option
-                        v-for="(item,index) in tableList"
-                        :key="item.id"
-                        :label="item.name"
-                        :value="index"
-                      /> -->
         </el-select>
       </el-form-item>
       <el-form-item>
         <el-input v-model="dataIntro" v-if="showSearch" @keyup.enter="retrieval"
-          ><!-- v-model="dataForm.intro" -->
+          >
           <el-button
             slot="append"
             icon="el-icon-search"
@@ -42,32 +36,11 @@
         </div>
       </el-form-item>
     </el-form>
-
-    <!-- <el-dialog
-                :visible.sync="showConfirm"
-                title="数据确认"
-                width="500"
-                align-center
-                :append-to-body="true"
-              >
-                <div>当前工作表:{{position.sheet}} </div>
-                <div>当前取值:{{position.value}}</div>
-                <template #footer>
-                  <div class="dialog-footer">
-                    <el-button @click="showConfirm = false">关闭</el-button>
-                    <el-button type="primary" @click="onConfirm">
-                      确认选择
-                    </el-button>
-                  </div>
-                </template>
-              </el-dialog> -->
   </div>
 </template>
   
   <script>
 import { searchSourceData, deleteSourceData } from "@/api/sourceData";
-/* import { search } from "core-js/fn/symbol"; */
-import LuckyExcel from "luckyexcel"; //引入LuckyExcel
 import axios from "axios";
 export default {
   name: "SourceAi",
@@ -156,53 +129,6 @@ export default {
       let _this = this;
       /*      let item = _this.tableList[e]; */
       _this.showSearch = true;
-
-      /*  item.sourceData = JSON.parse(item.source_data);
-
-      _this.position.tb = item.code; */
-      /*      _this.$nextTick(() => {
-        luckysheet.destroy();
-        luckysheet.create({
-          container: "luckysheet", //dom id
-          data: item.sourceData.exportJson.sheets, //excel数据
-          lang: "zh",
-          showinfobar: false, // 是否显示顶部信息栏
-          showstatisticBar: false, // 是否显示底部计数栏
-          sheetBottomConfig: false, // sheet页下方的添加行按钮和回到顶部按钮配置
-          allowEdit: false, // 是否允许前台编辑
-          enableAddRow: false, // 是否允许增加行
-          enableAddCol: false, // 是否允许增加列
-          sheetFormulaBar: false, // 是否显示公式栏
-          enableAddBackTop: false, // 返回头部按钮
-          showsheetbar: true, // 是否显示底部sheet页按钮
-          enableAddRow: false, //允许添加行
-          // 自定义配置底部sheet页按钮
-          showsheetbarConfig: {
-            add: false,
-            menu: false,
-          },
-          hook: {
-            cellMousedown: function (cell, position, sheetFile, ctx) {
-              _this.position.sheet = sheetFile.name;
-
-              _this.position.r = position.r;
-              _this.position.c = position.c;
-
-              if (cell.v) {
-                _this.position.value = cell.v;
-              } else {
-                _this.position.value = "";
-                cell.ct.s.map((res) => {
-                  _this.position.value += res.v;
-                });
-              }
-              _this.showConfirm = true;
-            },
-            cellUpdated: function (r, c, oldValue, newValue, isRefresh) {
-            },
-          },
-        });
-      }); */
     },
     initTableList() {
       let _this = this;

+ 9 - 3
src/views/document/com/menus.vue

@@ -42,6 +42,7 @@
       width="300"
       :close-on-click-modal="false"
       custom-class="prod-verify"
+      top="20px"
       title="选择公式"
     >
       <Formula @onPicked="onPickedFormula" :comList="comArr"></Formula>
@@ -54,6 +55,7 @@
       width="800px"
       :close-on-click-modal="false"
       custom-class="prod-verify"
+      top="20px"
       :title="insertTitle"
     >
       <Variable
@@ -69,6 +71,7 @@
       v-el-drag-dialog
       width="300"
       :close-on-click-modal="false"
+      top="20px"
       custom-class="prod-verify"
       title="选择源数据"
     >
@@ -81,10 +84,12 @@
       v-el-drag-dialog
       width="300"
       :close-on-click-modal="false"
+      top="20px"
       custom-class="prod-verify"
-      title="选择AI"
+      title="AI"
     >
-      <sourceAi @onPicked="onPickedAi"></sourceAi>
+      <!-- <sourceAi @onPicked="onPickedAi"></sourceAi> -->
+      <ChatBox />
     </el-dialog>
 
     <!-- ai -->
@@ -109,7 +114,7 @@ import sourceAi from "./components/sourceAi/index.vue";
 import sourceEs from "./components/sourceEs/index.vue";
 import Variable from "./components/Variable";
 import elDragDialog from "@/directive/el-drag-dialog";
-
+import ChatBox from "@/components/webAi/index.vue";
 export default {
   name: "menus",
   emits: ["onEvents", "onVariable"],
@@ -119,6 +124,7 @@ export default {
     sourceData,
     sourceAi,
     sourceEs,
+    ChatBox
   },
   directives: { elDragDialog },
   props: {

+ 28 - 12
src/views/document/com/view.vue

@@ -538,27 +538,25 @@ export default {
         });
         contentClone.querySelectorAll("table").forEach((table, tableIndex) => {
           table.style.borderCollapse = "separate";
-          //table.style.borderSpacing = "1px"; // 使用间距来模拟边框
           table.style.width = "100%";
           table.style.border = "none";
-          table.style.backgroundColor = "#000000"; // 表格背景色作为边框颜色
 
           table.querySelectorAll("tr").forEach((row, rowIndex) => {
             row.querySelectorAll("td, th").forEach((cell, cellIndex) => {
               cell.style.padding = "5px";
 
-              // 设置右边框和下边框
-              cell.style.borderRight = "0.1pt solid #ffffff";
-              cell.style.borderBottom = "0.1pt solid #ffffff";
+              // 为所有单元格设置右边框和下边框
+              cell.style.borderRight = "0.1px solid #000000";
+              cell.style.borderBottom = "0.1px solid #000000";
 
-              // 为第一行设置上边框
-              if (rowIndex === 0) {
-                cell.style.borderTop = "0.1pt solid #ffffff";
+              // 为所有行的第一个单元格设置左边框
+              if (cellIndex === 0) {
+                cell.style.borderLeft = "0px solid #000000";
               }
 
-              // 为第一列设置左边框
-              if (cellIndex === 0) {
-                cell.style.borderLeft = "0.1pt solid #ffffff";
+              // 为第一行的所有单元格设置上边框
+              if (rowIndex === 0) {
+                cell.style.borderTop = "0px solid #000000";
               }
             });
           });
@@ -604,7 +602,6 @@ export default {
               font-size: 12pt;
               line-height: 1.5;
             }
-           
             .template-textarea {
               page-break-after: always;
             }
@@ -653,6 +650,25 @@ export default {
       }
     },
 
+    // 新增方法来处理所有表格
+    processAllTables(contentClone) {
+      contentClone.querySelectorAll("table").forEach((table) => {
+        table.style.borderCollapse = "separate";
+        table.style.width = "100%";
+        table.style.border = "none";
+        table.style.backgroundColor = "#000000";
+
+        table.querySelectorAll("tr").forEach((row) => {
+          row.querySelectorAll("td, th").forEach((cell) => {
+            cell.style.padding = "5px";
+            cell.style.borderRight = "0.1px solid #ffffff";
+            cell.style.borderBottom = "0.1px solid #ffffff";
+            cell.style.backgroundColor = "#ffffff";
+          });
+        });
+      });
+    },
+
     // 修改 convertImageToBase64 方法
     async convertImageToBase64(img) {
       return new Promise((resolve, reject) => {

+ 22 - 7
src/views/knowledgeMenu/category/infoList.vue

@@ -22,8 +22,12 @@
     >
       暂无解析数据
     </div>
-    <div style="width: 50%">
+    <!-- <div style="width: 50%">
       <iframe :src="documentUrl" width="100%" height="822px"></iframe>
+    </div> -->
+    <div style="width: 50%">
+      <!-- 文件预览组件 -->
+      <file-preview :file-url="documentUrl" :file-type="type" />
     </div>
   </div>
   <div v-else>
@@ -61,8 +65,11 @@
 import { mapGetters } from "vuex";
 import { searchTaskInfo } from "@/api/knowledge";
 import LuckyExcel from "luckyexcel";
+import FilePreview from "@/components/FilePreview/index.vue"; // 新增文件预览组件
 export default {
-  components: {},
+  components: {
+    FilePreview, // 注册文件预览组件
+  },
   computed: {
     ...mapGetters(["roleInfo", "authList"]),
   },
@@ -77,11 +84,14 @@ export default {
       documentUrl: "",
       type: "",
       excelDataList: [],
+      isFileViewable: false,
+      supportedFileTypes: ['pdf', 'doc', 'docx', 'xls', 'xlsx', 'ppt', 'pptx', 'txt', 'jpg', 'jpeg', 'png', 'gif'],
     };
   },
   mounted() {
     this.queryForm.document_id = this.$route.query.id;
     this.type = this.$route.query.type;
+    this.checkFileType();
     this.search();
   },
   methods: {
@@ -95,19 +105,24 @@ export default {
             } */
       return true;
     },
+    checkFileType() {
+      this.isFileViewable = this.supportedFileTypes.includes(this.type);
+    },
+
     search() {
       searchTaskInfo(this.queryForm)
         .then((res) => {
           this.dataList = res.data.tasks;
-          this.documentUrl = res.data.documentUrl;
 
-          if (this.type === "xls" || this.type === "xlsx") {
-            this.excelDataList = this.parseExcelData(res.data.tasks);
+          if (this.isFileViewable) {
+            this.documentUrl = res.data.documentUrl;
+          } else {
+            console.log("文件类型不支持预览");
+            // 可以在这里添加下载按钮的逻辑
           }
         })
         .catch((error) => {
-          console.error("Error fetching data:", error);
-          this.excelDataList = [];
+          console.error("获取数据时出错:", error);
         });
     },
 

Энэ ялгаанд хэт олон файл өөрчлөгдсөн тул зарим файлыг харуулаагүй болно