This commit is contained in:
@@ -71,6 +71,7 @@
|
||||
<n-col :span="24">
|
||||
<div mt-10>
|
||||
<n-button type="primary" @click="getList">搜索</n-button>
|
||||
<n-button type="primary" ml-10 @click="exportTable">导出表格</n-button>
|
||||
<n-button ml-10 @click="clear">重置</n-button>
|
||||
</div>
|
||||
</n-col>
|
||||
@@ -90,6 +91,7 @@
|
||||
|
||||
<script setup>
|
||||
import api from './api'
|
||||
import * as XLSX from 'xlsx'
|
||||
|
||||
const loading = ref(false)
|
||||
|
||||
@@ -253,6 +255,8 @@ const pagination = ref({
|
||||
page: 1,
|
||||
pageSize: 10,
|
||||
itemCount: 0,
|
||||
showSizePicker: true,
|
||||
pageSizes: [10, 20, 50, 100],
|
||||
onChange: (page) => {
|
||||
pagination.value.page = page
|
||||
getList()
|
||||
@@ -317,6 +321,16 @@ const clear = () => {
|
||||
}
|
||||
getList()
|
||||
}
|
||||
|
||||
const exportTable = () => {
|
||||
// 将数据转换为工作簿
|
||||
const worksheet = XLSX.utils.json_to_sheet(data.value)
|
||||
const workbook = XLSX.utils.book_new()
|
||||
XLSX.utils.book_append_sheet(workbook, worksheet, 'Sheet1')
|
||||
|
||||
// 生成Excel文件并触发下载
|
||||
XLSX.writeFile(workbook, 'table.xlsx')
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
|
||||
Reference in New Issue
Block a user