From 1c13bd7a2cd2c8ba69a185da69344c8b59f4e561 Mon Sep 17 00:00:00 2001
From: guoyuji <guoyujie@ng.com>
Date: 星期四, 04 七月 2024 09:29:15 +0800
Subject: [PATCH] 选中求和功能以及还原双击回车才能点击单元格

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

diff --git a/north-glass-erp/northglass-erp/src/components/BasicTable.vue b/north-glass-erp/northglass-erp/src/components/BasicTable.vue
index ad30121..76d5f79 100644
--- a/north-glass-erp/northglass-erp/src/components/BasicTable.vue
+++ b/north-glass-erp/northglass-erp/src/components/BasicTable.vue
@@ -2,9 +2,15 @@
 import {Search} from "@element-plus/icons-vue"
 import {defineEmits, onMounted, reactive, ref, watch} from "vue"
 import {changeFilterEvent} from "@/hook"
-import request from "@/utils/request";
+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";
+import {useI18n} from "vue-i18n";
+
+const { t } = useI18n()
 const xGrid = ref()
 let filterData = ref({})
 const gridOptions = reactive({
@@ -36,12 +42,24 @@
     mode: 'row',
     showStatus: true
   },//琛ㄥご鍙傛暟
-  columns:[
+  menuConfig: {
+    body: {
+      options: [
+        [
 
+          { code: 'exportExcelChecked', name: t('components.exportSelected'), prefixIcon: 'vxe-icon-download', visible: true }
+        ]
+      ]
+    }
+  },
+  columns:[
 
   ],//琛ㄥご鎸夐挳
   toolbarConfig: {
     buttons: [],
+    slots: {
+      tools: 'toolbar_buttons'
+    },
     // import: false,
     // export: true,
     // print: true,
@@ -54,7 +72,7 @@
     return[
       columns.map((column, columnIndex) => {
         if (columnIndex === 0) {
-          return '鍚堣:'
+          return t('basicData.total')
         }
         if (props.childrenData.footList.includes(column.field)) {
           return sumNum(data, column.field)
@@ -65,6 +83,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, `${props.childrenData.exportName}.xlsx`);
+          }
+          break
+        }
+      }
+    }
+  }
+}
 
 
 const props = defineProps({
@@ -97,6 +135,7 @@
 onMounted(() => {
   gridOptions.columns = props.childrenData.columns
   getReportData()
+  addListener(xGrid.value,gridOptions)
 
 
 })
@@ -143,6 +182,8 @@
 }
 
 
+
+
 </script>
 
 <template>
@@ -150,8 +191,8 @@
     <el-date-picker
         v-model="basicProp.selectDate"
         type="daterange"
-        start-placeholder="寮�濮嬫椂闂�"
-        end-placeholder="缁撴潫鏃堕棿"
+        :start-placeholder="$t('basicData.startDate')"
+        :end-placeholder="$t('basicData.endDate')"
         format="YYYY-MM-DD"
         value-format="YYYY-MM-DD"
     />
@@ -160,7 +201,7 @@
         id="searchButton"
         type="primary"
         style="margin-top: -5px"
-        :icon="Search">鏌ヨ</el-button>
+        :icon="Search">{{$t('basicData.search')}}</el-button>
     <div class="order-detail">
       <vxe-grid
           @filter-change="filterChanged"
@@ -168,6 +209,7 @@
           class="mytable-scrollbar"
           ref="xGrid"
           v-bind="gridOptions"
+          v-on="gridEvents"
       >
         <!--      涓嬫媺鏄剧ず鎵�鏈変俊鎭彃妲�-->
         <template #content="{ row }">
@@ -186,6 +228,15 @@
             </div>
           </div>
         </template>
+
+        <template #toolbar_buttons>
+          <vxe-button style="margin-right: 0.5rem"
+                      @click="exportExcel(props.childrenData.exportUrl,
+                                          props.childrenData.exportName,
+                                          basicProp.selectDate)">
+            {{$t('basicData.export')}}</vxe-button>
+        </template>
+
         <template #pager>
           <!--浣跨敤 pager 鎻掓Ы-->
           <!--        'PrevJump','NextJump', -->
@@ -227,4 +278,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