lighter 2 years ago
parent
commit
7c88088140
2 changed files with 9 additions and 32 deletions
  1. 1 31
      src/utils/ExportCVS.js
  2. 8 1
      src/views/clinic/interactive/Comments.vue

+ 1 - 31
src/utils/ExportCVS.js

@@ -1,6 +1,5 @@
 import {ElMessage} from "element-plus";
-// const iconv = require('iconv-lite')
-import {decode,encode} from 'iconv-lite'
+import {encode} from 'iconv-lite'
 
 export function exportCSV(data, field, fileName) {
     if (!data || data.length === 0) {
@@ -49,33 +48,4 @@ function trim(str, char) {
         str = str.replace(new RegExp('^\\' + char + '+|\\' + char + '+$', 'g'), '')
     }
     return str.replace(/^\s + |\s + $/g, '')
-}
-
-
-function utf8ToUnicode(utf8) {
-    // 将UTF-8格式的字节转成Unicode字符串
-    var unicode = "";
-    var i = 0;
-    while (i < utf8.length) {
-        var c = utf8.charCodeAt(i);
-        if (c < 128) {
-            unicode += String.fromCharCode(c);
-            i++;
-        } else if ((c > 191) && (c < 224)) {
-            unicode += String.fromCharCode(((c & 0x1f) << 6) | (utf8.charCodeAt(i + 1) & 0x3f));
-            i += 2;
-        } else {
-            unicode += String.fromCharCode(((c & 0x0f) << 12) | ((utf8.charCodeAt(i + 1) & 0x3f) << 6) | (utf8.charCodeAt(i + 2) & 0x3f));
-            i += 3;
-        }
-    }
-    return unicode;
-}
-
-function unicodeToGbk(str){
-    var arr = [];
-    for(var i=0; i<str.length; i++){
-        arr.push('\\u' + str.charCodeAt(i).toString(16));
-    }
-    return unescape(arr.join('').replace(/\\/g, '%'));
 }

+ 8 - 1
src/views/clinic/interactive/Comments.vue

@@ -104,6 +104,7 @@ const inquiry = reactive({
   pageNum: 1,
   pageSize: 15,
   onlyValidComments: false,
+  isForExport: false
 })
 
 const comments = reactive({
@@ -169,7 +170,13 @@ const exportExcel = () => {
     patientName: '患者姓名',
     patPhoneNo: '患者电话',
   }
-  Export(comments.list, fields, '服务号患者评价')
+  inquiry.isForExport = true
+  getComments(inquiry).then(res => {
+    inquiry.isForExport = false
+    Export(res.list, fields, '服务号患者评价')
+  }).catch(() => {
+    inquiry.isForExport = false
+  })
 }
 
 </script>