Browse Source

优化csv导出

lighter 1 year ago
parent
commit
51a738910e

+ 5 - 5
src/utils/ExportCVS.js

@@ -1,7 +1,7 @@
 import {ElMessage} from "element-plus";
 import {encode} from 'iconv-lite'
 
-export function exportCSV(data, field, fileName) {
+export function exportCSV(data, field, fileName, separator) {
     if (!data || data.length === 0) {
         ElMessage({
             message: '没有可以导出的数据!',
@@ -13,10 +13,10 @@ export function exportCSV(data, field, fileName) {
     let csvContent = ''
     let jsonColumns = []
     for (let key in field) {
-        csvContent += field[key] + ','
+        csvContent += field[key] + separator
         jsonColumns.push(key)
     }
-    csvContent = trim(csvContent, ',') + '\n'
+    csvContent = trim(csvContent, separator) + '\n'
 
     for (let i = 0; i < data.length; i++) {
         let row = ''
@@ -25,9 +25,9 @@ export function exportCSV(data, field, fileName) {
             if (val === null || val === undefined) {
                 val = ''
             }
-            row += `${val},`
+            row += `${val}${separator}`
         }
-        csvContent += trim(row, ',') + '\n'
+        csvContent += trim(row, separator) + '\n'
     }
 
     const arrBuffer = new Int8Array(encode(csvContent, 'GBK'))

+ 3 - 3
src/views/hospitalization/case-front-sheet/FrontSheetExport.vue

@@ -14,7 +14,7 @@
           <template #default="props">
             <div style="display: flex">
               <div style="width: 40%">
-                <div style="width: 100%; padding: 4px; background: gray; font-weight: bold; color: white">
+                <div style="width: 100%; padding: 4px; background: rgb(128,128,128); font-weight: bold; color: white">
                   出院诊断
                 </div>
                 <div style="display: flex; font-size: 13px; font-weight: bold; padding: 4px 0">
@@ -31,7 +31,7 @@
                 </div>
               </div>
               <div v-show="props.row.surgeryList.length > 0" style="width: 55%; margin-left: 30px">
-                <div style="width: 100%; padding: 4px; background: gray; font-weight: bold; color: white">
+                <div style="width: 100%; padding: 4px; background: rgb(128,128,128); font-weight: bold; color: white">
                   手术记录
                 </div>
                 <div style="display: flex; font-size: 13px; font-weight: bold; padding: 4px 0">
@@ -316,7 +316,7 @@ const exportExcel = () => {
 
     const yearMonth = month.split('-')
     const fileName = `430000150806_长沙泰和医院_${yearMonth[0]}_${yearMonth[1]}.csv`
-    exportCSV(sheets, title, fileName)
+    exportCSV(sheets, title, fileName, ',')
   }
 }
 </script>