Browse Source

Merge remote-tracking branch 'origin/master'

da-xian 3 months ago
parent
commit
c5aa97ff86

+ 1 - 1
vue/src/components/basic/es-result/doc-view.vue

@@ -14,7 +14,7 @@
           <span>
             上传时间:<span class="key-tag">{{ it.date }}</span>
           </span><br>
-          <filePreview :fileName="it.storage_path" :filePath="it.storage_path"></filePreview>
+          <filePreview :fileName="it.file_name" :filePath="it.storage_path"></filePreview>
         </div>
       </div>
     </div>

+ 22 - 2
vue/src/components/basic/es-result/list-view.vue

@@ -6,7 +6,7 @@
                :pagination="false" @resizeColumn="handleResizeColumn" :rowClassName = "rowClassName"
                bordered>
         <template #bodyCell="{ column, record }">
-            <div v-html="record[column.key]"></div>
+            <div v-html="defaultIfNull(record[column.key])"></div>
         </template>
       </a-table>
     </div>
@@ -46,8 +46,28 @@ export default defineComponent({
       console.log(record);
       return index % 2 === 0 ? 'even' : 'odd';
     }
+    const isoDateRegex = /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(?:\.\d{3})?Z$/;;
+
+    function convertIsoDateToYMD(isoString: string): string {
+      const date = new Date(isoString);
+      const year = date.getUTCFullYear();
+      const month = String(date.getUTCMonth() + 1).padStart(2, '0'); // Months are zero-indexed
+      const day = String(date.getUTCDate()).padStart(2, '0');
+
+      return `${year}-${month}-${day}`;
+    }
+
+    const defaultIfNull = (value) => {
+      if (value == null || value == "") {
+        return "/";
+      }
+      if (isoDateRegex.test(value)) {
+        return convertIsoDateToYMD(value);
+      }
+      return value;
+    }
     return {
-      columns, data, title,rowClassName,
+      columns, data, title,rowClassName,defaultIfNull,
       handleResizeColumn: (w, col) => {
         col.width = w;
       }

+ 22 - 8
vue/src/components/basic/es-result/table-view.vue

@@ -3,7 +3,7 @@
     <div class="search-title">{{ title }}</div>
     <div class="search-view">
       <template v-for="it in fieldData">
-        <span>{{ it.fieldName }}:<span class="key-tag" v-html="data[it.fieldCode]"/></span>
+        <span>{{ it.fieldName }}: <span class="key-tag" v-html="defaultIfNull(data[it.fieldCode])"/></span>
       </template>
     </div>
   </div>
@@ -26,14 +26,28 @@ export default defineComponent({
     const fieldData = props.indexSetting?.fieldList.filter(it => it.dataType != "NESTED");
     const data = props.data;
 
-    /*if (data != null && data.highlight != null) {
-      const highlights= data.highlight as [];
-      highlights.forEach(it=>{
-        it.
-      })
-    }*/
+    const isoDateRegex = /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(?:\.\d{3})?Z$/;
+
+    function convertIsoDateToYMD(isoString: string): string {
+      const date = new Date(isoString);
+      const year = date.getUTCFullYear();
+      const month = String(date.getUTCMonth() + 1).padStart(2, '0'); // Months are zero-indexed
+      const day = String(date.getUTCDate()).padStart(2, '0');
+
+      return `${year}-${month}-${day}`;
+    }
+
+    const defaultIfNull = (value) => {
+      if (value == null || value == "") {
+        return "/";
+      }
+      if (isoDateRegex.test(value)) {
+        return convertIsoDateToYMD(value);
+      }
+      return value;
+    }
     return {
-      fieldData, data, title
+      fieldData, data, title, defaultIfNull
     };
   }
 });

+ 13 - 4
vue/src/components/basic/file-preview/index.vue

@@ -47,18 +47,23 @@ export default defineComponent({
     const visible = ref<boolean>(false);
     const spinning = ref<boolean>(false);
     const previewUrl = ref<Blob>();
-    const fileSuffix = props.fileName?.substring(props.fileName?.lastIndexOf('.') + 1).toLowerCase();
+    const fileSuffix = ref("");
 
     function loadFile() {
-      if (props.accept?.indexOf(fileSuffix) < 0) {
+      let fileName = stripHtmlTags(props.fileName);
+      let filePath = stripHtmlTags(props.filePath);
+      fileSuffix.value = fileName?.substring(fileName?.lastIndexOf('.') + 1).toLowerCase();
+
+      debugger
+      if (props.accept?.indexOf(fileSuffix.value) < 0) {
         $message.error("不支持预览的文件格式!");
         return;
       }
       spinning.value = true;
       handleloadByGet("/api/wellInfo/downFile", {
         isShow: 1,
-        fileName: props.fileName,
-        filePath: props.filePath
+        fileName: fileName,
+        filePath: filePath
       }, "获取文件失败!").then(res => {
         previewUrl.value = res.data;
         if (previewUrl.value == undefined) {
@@ -69,6 +74,10 @@ export default defineComponent({
       })
     }
 
+    function stripHtmlTags(htmlString: string): string {
+      return htmlString.replace(/<[^>]+>/g, '');
+    }
+
     function rendered() {
       console.log("渲染完成");
       spinning.value = false;