sparkles: ✨ 导出excel
This commit is contained in:
parent
994fd58bb0
commit
a2d24b9492
@ -11,6 +11,7 @@
|
||||
enter-button
|
||||
@search="loadData()"
|
||||
></a-input-search>
|
||||
<a-button type="primary" @click="downloadData()">导出</a-button>
|
||||
</a-col>
|
||||
</a-row>
|
||||
</template>
|
||||
@ -38,6 +39,7 @@
|
||||
<script setup lang="ts">
|
||||
import api from '@/api'
|
||||
import { IPage } from '@/api/api'
|
||||
import { http } from '@/settings/http'
|
||||
|
||||
const searchKey = ref('')
|
||||
const pagedata = ref<IPage<material.ApplyDTO>>()
|
||||
@ -64,6 +66,12 @@
|
||||
//初始加载
|
||||
loadData()
|
||||
|
||||
//导出数据
|
||||
const downloadData = () => {
|
||||
// 调用后端接口下载excel文件
|
||||
const url = `${http.prefix}/apply/download-excel?applyType=1&type=${searchKey.value}&code=${searchKey.value}&name=${searchKey.value}`
|
||||
window.open(url)
|
||||
}
|
||||
//表格列
|
||||
const columns = [
|
||||
{
|
||||
|
@ -11,6 +11,7 @@
|
||||
enter-button
|
||||
@search="loadData()"
|
||||
></a-input-search>
|
||||
<a-button type="primary" @click="downloadData()">导出</a-button>
|
||||
</a-col>
|
||||
</a-row>
|
||||
</template>
|
||||
@ -78,6 +79,7 @@
|
||||
import api from '@/api'
|
||||
import { IPage } from '@/api/api'
|
||||
import { useUserStore } from '@/stores/user'
|
||||
import { http } from '@/settings/http'
|
||||
|
||||
const searchKey = ref('')
|
||||
const pagedata = ref<IPage<material.ApplyDTO>>()
|
||||
@ -105,6 +107,13 @@
|
||||
//初始加载
|
||||
loadData()
|
||||
|
||||
//导出数据
|
||||
const downloadData = () => {
|
||||
// 调用后端接口下载excel文件
|
||||
const url = `${http.prefix}/apply/download-excel?applyType=3&type=${searchKey.value}&code=${searchKey.value}&name=${searchKey.value}`
|
||||
window.open(url)
|
||||
}
|
||||
|
||||
//表格列
|
||||
const columns = [
|
||||
{
|
||||
|
@ -3,7 +3,7 @@
|
||||
<!-- 页面操作栏 -->
|
||||
<template #ops>
|
||||
<a-row>
|
||||
<a-col :span="6" style="width: 180px">
|
||||
<a-col :span="6" style="width: 280px">
|
||||
<a-date-picker
|
||||
v-model:value="startDate"
|
||||
:format="'YYYY-MM-DD HH:mm:ss'"
|
||||
@ -33,10 +33,11 @@
|
||||
<a-select-option value="MANUAL">人工盘点</a-select-option>
|
||||
</a-select>
|
||||
</a-col>
|
||||
<a-col :span="6">
|
||||
<a-col :span="6" style="width: 180px">
|
||||
<a-input-search v-model:value="taker" :placeholder="`盘点人`" allow-clear enter-button @search="loadData()" />
|
||||
</a-col>
|
||||
</a-row>
|
||||
<a-button type="primary" @click="downloadData()">导出</a-button>
|
||||
</template>
|
||||
<!-- 页面表格内容 -->
|
||||
<div style="min-height: calc(100vh - 305px)">
|
||||
@ -125,6 +126,7 @@
|
||||
import { IPage } from '@/api/api'
|
||||
import resultForm from '../stocktaking/result-form.vue'
|
||||
import { Dayjs } from 'dayjs'
|
||||
import { http } from '@/settings/http'
|
||||
|
||||
const applyIdRef = ref()
|
||||
const auditPage = ref<IPage<material.ApplyForm>>()
|
||||
@ -162,6 +164,36 @@
|
||||
//初始加载
|
||||
loadData()
|
||||
|
||||
//导出数据
|
||||
const downloadData = () => {
|
||||
// 创建 URLSearchParams 对象
|
||||
const params = new URLSearchParams()
|
||||
|
||||
// 动态添加参数
|
||||
if (auditType.value) {
|
||||
params.append('auditType', auditType.value)
|
||||
}
|
||||
if (startDate.value) {
|
||||
// 格式化日期并移除 'Z' 和毫秒部分
|
||||
const formattedDate = startDate.value.toISOString().replace('Z', '').slice(0, -4)
|
||||
params.append('createDate', formattedDate)
|
||||
}
|
||||
if (taker.value) {
|
||||
params.append('taker', taker.value)
|
||||
}
|
||||
if (status.value && status.value.length > 0) {
|
||||
// 为数组中的每个值单独添加参数
|
||||
status.value.forEach((value) => {
|
||||
params.append('reviewResults', value)
|
||||
})
|
||||
}
|
||||
|
||||
// 构建完整的 URL
|
||||
const url = `${http.prefix}/apply/audit/download-excel?${params.toString()}`
|
||||
|
||||
// 打开下载链接
|
||||
window.open(url)
|
||||
}
|
||||
//表格列
|
||||
const columns = [
|
||||
{
|
||||
|
Loading…
x
Reference in New Issue
Block a user