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>
|
||||
|
||||
@@ -92,6 +92,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>
|
||||
@@ -112,6 +113,7 @@
|
||||
<script setup>
|
||||
import api from './api'
|
||||
import { NButton, NPopconfirm } from 'naive-ui'
|
||||
import * as XLSX from 'xlsx'
|
||||
|
||||
const loading = ref(false)
|
||||
|
||||
@@ -245,12 +247,6 @@ const columns = ref([
|
||||
slot: 'pay_type',
|
||||
render: (row) => h('span', row.pay_type === 1 ? '微信' : '积分'),
|
||||
},
|
||||
{
|
||||
title: '订单总价',
|
||||
align: 'center',
|
||||
slot: 'number',
|
||||
render: (row) => h('span', row.pay_type === 1 ? `${row.price}元` : `${row.exchange}积分`),
|
||||
},
|
||||
{
|
||||
title: '订单状态',
|
||||
align: 'center',
|
||||
@@ -368,6 +364,8 @@ const pagination = ref({
|
||||
page: 1,
|
||||
pageSize: 10,
|
||||
itemCount: 0,
|
||||
showSizePicker: true,
|
||||
pageSizes: [10, 20, 50, 100],
|
||||
onChange: (page) => {
|
||||
pagination.value.page = page
|
||||
getList()
|
||||
@@ -435,6 +433,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></style>
|
||||
|
||||
Reference in New Issue
Block a user