From e1bed3fc67baa849a82886d472bf124fa9146385 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E7=BD=97=E6=96=8C=E6=9D=B0?= <>
Date: Wed, 27 Nov 2024 12:42:25 +0800
Subject: [PATCH] ui
---
package.json | 3 +-
.../order_statistics/orderStatistics.vue | 38 ++++++++++++++++++-
2 files changed, 39 insertions(+), 2 deletions(-)
diff --git a/package.json b/package.json
index ab1aecb..2763c48 100644
--- a/package.json
+++ b/package.json
@@ -21,7 +21,8 @@
"vue": "^3.4.21",
"vue-router": "^4.3.0",
"vue3-print-nb": "^0.1.4",
- "vuex": "^4.1.0"
+ "vuex": "^4.1.0",
+ "xlsx": "^0.18.5"
},
"devDependencies": {
"@vitejs/plugin-vue": "^5.0.4",
diff --git a/src/components/order_statistics/orderStatistics.vue b/src/components/order_statistics/orderStatistics.vue
index e96b106..9d543a0 100644
--- a/src/components/order_statistics/orderStatistics.vue
+++ b/src/components/order_statistics/orderStatistics.vue
@@ -52,6 +52,9 @@
+
+ 导出Excel
+
@@ -85,7 +88,8 @@ import { reactive, ref, getCurrentInstance, computed, onMounted, watch, nextTick
import { ElTable, ElMessage, ElMessageBox } from 'element-plus'
import { Plus, Operation, Message, MoreFilled, Search, Setting, Edit, Delete } from '@element-plus/icons-vue'
import { useStore } from 'vuex'
-
+import { saveAs } from 'file-saver';
+import * as XLSX from 'xlsx';
// 项目封装的脚手架
import { abcfun } from 'abcfun'
@@ -166,6 +170,38 @@ const disabledWeeks = (rowIndex: number, weekId: number) => {
const menuSelect = (key: string, keyPath: string[]) => {
console.log(key, keyPath)
}
+const exportToExcel=()=>{
+ var wb = XLSX.utils.table_to_book(document.querySelector('#tableId'),{ raw: true });//关联dom节点
+ var wbout = XLSX.write(wb, {
+ bookType: 'xlsx',
+ bookSST: true,
+ type: 'array'
+ })
+ let fileName = formatDate(new Date())
+ try {
+ saveAs(new Blob([wbout], {
+ type: 'text/plain;charset=utf-8'
+ }), fileName+'.xlsx')//自定义文件名
+ } catch (e) {
+ if (typeof console !== 'undefined') console.log(e, wbout);
+ }
+ return wbout
+}
+const formatDate=(date)=> {
+ let year = date.getFullYear();
+// year = year.toString().slice(2, 4); // 获取年份的后两位
+
+ let month = date.getMonth() + 1; // 月份是从0开始的,所以需要+1
+ month = month < 10 ? '0' + month : month; // 月份小于10前面补0
+
+ let day = date.getDate();
+ day = day < 10 ? '0' + day : day; // 日期小于10前面补0
+ let h = date.getHours(); //获取时
+ let m = date.getMinutes(); //获取分
+ let s = date.getSeconds(); //获取秒
+
+ return `${year}${month}${day}${h}${m}${s}`;
+}
// 菜单--高级查询
const btnQuery = () => {
axios.post(appConfig, '/api/app/AppointPatientRegister/GetAppointPatientRegisterList', {