Your Name
2022-08-11 988558aaa309068fd393cc654be537434b0a15ea
src/views/goalManagement/Goalsummary/index.vue
@@ -24,10 +24,10 @@
         <div class="btns">
            <p>汇总日期:2022-07-04 23:00:07</p>
            <div>
               <el-button type="primary" size="default" :icon="Download">导出</el-button>
               <el-button type="primary" size="default" :icon="Download" @click="exportExcel('tab1', '会员明细.xlsx')">导出</el-button>
            </div>
         </div>
         <el-table :data="tableData" style="width: 100%">
         <el-table :data="tableData" style="width: 100%" id="tab1">
            <el-table-column label="责任部门" align="center">
               <template #default="scope">{{ scope.row.departmentId }}</template>
            </el-table-column>
@@ -68,6 +68,9 @@
import { ElMessageBox, ElMessage, ElButton, ElInput, TabsPaneContext, FormInstance } from 'element-plus';
import { Plus, Delete, Upload, Download, Refresh, View } from '@element-plus/icons-vue';
import { goalManagementApi } from '/@/api/goalManagement';
// import * as XLSX from 'xlsx';
export default defineComponent({
   components: { ElButton, ElInput },
   setup() {
@@ -162,6 +165,16 @@
            ],
         },
      ];
      const exportExcel = (id:string,name:string) => {
         let workbook = XLSX.utils.table_to_book(document.getElementById(id)); //需要在table上定义一个id
         try {
            XLSX.writeFile(workbook, name);
            console.log('导出成功!');
         } catch (e) {
            console.log('导出失败!');
         }
      }
      return {
         ruleForm,
         tableData,
@@ -179,6 +192,7 @@
         Download,
         Refresh,
         View,
         exportExcel
      };
   },
});
@@ -210,4 +224,4 @@
   display: flex;
   justify-content: right;
}
</style>
</style>