From 49c052b10687fa8734470bea9eb68e952ec88d30 Mon Sep 17 00:00:00 2001
From: guoyuji <guoyujie@ng.com>
Date: 星期三, 29 五月 2024 15:25:42 +0800
Subject: [PATCH] 提交 1.差异尺寸设置默认值0.4, 2.报表框选导出excel

---
 north-glass-erp/northglass-erp/src/components/BasicTable.vue |   47 ++++++++++++++++++++++++++++++++++++++++++++++-
 1 files changed, 46 insertions(+), 1 deletions(-)

diff --git a/north-glass-erp/northglass-erp/src/components/BasicTable.vue b/north-glass-erp/northglass-erp/src/components/BasicTable.vue
index 9f881a3..0f72e3e 100644
--- a/north-glass-erp/northglass-erp/src/components/BasicTable.vue
+++ b/north-glass-erp/northglass-erp/src/components/BasicTable.vue
@@ -4,8 +4,10 @@
 import {changeFilterEvent} from "@/hook"
 import request from "@/utils/request"
 import exportExcel  from "@/hook/exportExcel"
+import {addListener,exportData} from "@/hook/mouseMove"
 import deepClone from "@/utils/deepClone";
 import {ElMessage} from "element-plus";
+import * as XLSX from "xlsx";
 const xGrid = ref()
 let filterData = ref({})
 const gridOptions = reactive({
@@ -37,8 +39,17 @@
     mode: 'row',
     showStatus: true
   },//琛ㄥご鍙傛暟
-  columns:[
+  menuConfig: {
+    body: {
+      options: [
+        [
 
+          { code: 'exportExcelChecked', name: '瀵煎嚭閫変腑', prefixIcon: 'vxe-icon-download', visible: true }
+        ]
+      ]
+    }
+  },
+  columns:[
 
   ],//琛ㄥご鎸夐挳
   toolbarConfig: {
@@ -69,6 +80,26 @@
   }
 
 })
+const gridEvents = {
+  menuClick ({ menu, row, column }) {
+    const $grid = xGrid.value
+    if ($grid) {
+      switch (menu.code) {
+        case 'exportExcelChecked': {
+          let result = exportData()
+          if(result){
+            // 灏嗘暟鎹浆鎹负 worksheet 瀵硅薄
+            const worksheet = XLSX.utils.aoa_to_sheet(result);
+            const workbook = XLSX.utils.book_new();
+            XLSX.utils.book_append_sheet(workbook, worksheet, 'Sheet1');
+            XLSX.writeFile(workbook, 'data.xlsx');
+          }
+          break
+        }
+      }
+    }
+  }
+}
 
 
 const props = defineProps({
@@ -101,6 +132,7 @@
 onMounted(() => {
   gridOptions.columns = props.childrenData.columns
   getReportData()
+  addListener(xGrid.value,gridOptions)
 
 
 })
@@ -174,6 +206,7 @@
           class="mytable-scrollbar"
           ref="xGrid"
           v-bind="gridOptions"
+          v-on="gridEvents"
       >
         <!--      涓嬫媺鏄剧ず鎵�鏈変俊鎭彃妲�-->
         <template #content="{ row }">
@@ -242,4 +275,16 @@
   height:  calc(100% - 30px);
 
 }
+
+.vxe-grid {
+  /* 绂佺敤娴忚鍣ㄩ粯璁ら�変腑 */
+  -webkit-user-select: none;
+  -moz-user-select: none;
+  -ms-user-select: none;
+  user-select: none;
+}
+:deep(#product .el-dialog__body){
+  height: 90%;
+  width: 100%;
+}
 </style>
\ No newline at end of file

--
Gitblit v1.8.0