This commit is contained in:
parent
dca44ad839
commit
0d286b2b41
|
|
@ -28,6 +28,7 @@
|
|||
:table-columns="initTableColumns"
|
||||
:action-columns="actionColumns"
|
||||
:defaultQueryParams="{ dayPlanType: tableType }"
|
||||
:default-form-data="defaultFormData"
|
||||
>
|
||||
<template #proposedLongTimeCar="{ row }">
|
||||
<span v-if="row.proposedLongTimeCar && row.proposedTemporaryCar">
|
||||
|
|
@ -107,6 +108,14 @@ const comTableRef = ref(null)
|
|||
const addFormRef = ref(null)
|
||||
const tableType = ref(route.query.dayPlanType || '0')
|
||||
|
||||
// 默认表单数据:日期区间默认为当月
|
||||
const defaultFormData = computed(() => ({
|
||||
month: [
|
||||
dayjs().startOf('month').format('YYYY-MM-DD'),
|
||||
dayjs().endOf('month').format('YYYY-MM-DD'),
|
||||
],
|
||||
}))
|
||||
|
||||
onMounted(() => {
|
||||
if (route.query.dayPlanType) {
|
||||
tableType.value = route.query.dayPlanType
|
||||
|
|
@ -290,12 +299,17 @@ const onHandleEdit = () => {
|
|||
|
||||
// 下载统计表
|
||||
const onDownloadStatistic = () => {
|
||||
// 获取查询表单的日期数据
|
||||
const formData = comTableRef.value?.searchFormRef?.getFormData() || {}
|
||||
const startDate = formData.startDate || dayjs().startOf('month').format('YYYY-MM-DD')
|
||||
const endDate = formData.endDate || dayjs().endOf('month').format('YYYY-MM-DD')
|
||||
|
||||
proxy.download(
|
||||
'/download/dayPlanStatistics',
|
||||
{
|
||||
dayPlanType: tableType.value,
|
||||
startDate: dayjs().startOf('month').format('YYYY-MM-DD'),
|
||||
endDate: dayjs().endOf('month').format('YYYY-MM-DD'),
|
||||
startDate,
|
||||
endDate,
|
||||
},
|
||||
`日计划统计表.xlsx`,
|
||||
)
|
||||
|
|
|
|||
|
|
@ -11,22 +11,24 @@
|
|||
:action-columns="actionColumns"
|
||||
>
|
||||
<!-- 工具栏插槽 -->
|
||||
<template #toolbar>
|
||||
<template #toolbar="{ formData }">
|
||||
<ComButton
|
||||
type="primary"
|
||||
v-hasPermi="['settlement:add']"
|
||||
icon="Plus"
|
||||
@click="onHandleAdd"
|
||||
>新建</ComButton
|
||||
>
|
||||
新建
|
||||
</ComButton>
|
||||
<ComButton
|
||||
plain
|
||||
type="info"
|
||||
icon="Download"
|
||||
@click="onDownloadStatistic"
|
||||
@click="onDownloadStatistic(formData)"
|
||||
v-hasPermi="['settlement:download']"
|
||||
>下载统计表</ComButton
|
||||
>
|
||||
下载统计表
|
||||
</ComButton>
|
||||
</template>
|
||||
|
||||
<!-- 合同状态列插槽 -->
|
||||
|
|
@ -144,27 +146,14 @@ const onHandleAdd = () => {
|
|||
}
|
||||
|
||||
// 下载统计表
|
||||
const onDownloadStatistic = async () => {
|
||||
try {
|
||||
const formData = comTableRef.value?.getFormData() || {}
|
||||
const response = await downloadSettlementStatisticAPI(formData)
|
||||
// 创建下载链接
|
||||
const blob = new Blob([response], {
|
||||
type: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
|
||||
})
|
||||
const url = window.URL.createObjectURL(blob)
|
||||
const link = document.createElement('a')
|
||||
link.href = url
|
||||
link.download = `结算统计表_${new Date().getTime()}.xlsx`
|
||||
document.body.appendChild(link)
|
||||
link.click()
|
||||
document.body.removeChild(link)
|
||||
window.URL.revokeObjectURL(url)
|
||||
proxy.$modal.msgSuccess('下载成功')
|
||||
} catch (error) {
|
||||
console.error('下载失败:', error)
|
||||
proxy.$modal.msgError('下载失败')
|
||||
}
|
||||
const onDownloadStatistic = async (query) => {
|
||||
proxy.download(
|
||||
'/settlement/downloadSettlement',
|
||||
{
|
||||
...query,
|
||||
},
|
||||
`结算统计表.xlsx`,
|
||||
)
|
||||
}
|
||||
|
||||
// 获取合同列表
|
||||
|
|
|
|||
Loading…
Reference in New Issue