This commit is contained in:
BianLzhaoMin 2026-01-26 14:13:22 +08:00
parent dca44ad839
commit 0d286b2b41
2 changed files with 30 additions and 27 deletions

View File

@ -28,6 +28,7 @@
:table-columns="initTableColumns" :table-columns="initTableColumns"
:action-columns="actionColumns" :action-columns="actionColumns"
:defaultQueryParams="{ dayPlanType: tableType }" :defaultQueryParams="{ dayPlanType: tableType }"
:default-form-data="defaultFormData"
> >
<template #proposedLongTimeCar="{ row }"> <template #proposedLongTimeCar="{ row }">
<span v-if="row.proposedLongTimeCar && row.proposedTemporaryCar"> <span v-if="row.proposedLongTimeCar && row.proposedTemporaryCar">
@ -107,6 +108,14 @@ const comTableRef = ref(null)
const addFormRef = ref(null) const addFormRef = ref(null)
const tableType = ref(route.query.dayPlanType || '0') 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(() => { onMounted(() => {
if (route.query.dayPlanType) { if (route.query.dayPlanType) {
tableType.value = route.query.dayPlanType tableType.value = route.query.dayPlanType
@ -290,12 +299,17 @@ const onHandleEdit = () => {
// //
const onDownloadStatistic = () => { 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( proxy.download(
'/download/dayPlanStatistics', '/download/dayPlanStatistics',
{ {
dayPlanType: tableType.value, dayPlanType: tableType.value,
startDate: dayjs().startOf('month').format('YYYY-MM-DD'), startDate,
endDate: dayjs().endOf('month').format('YYYY-MM-DD'), endDate,
}, },
`日计划统计表.xlsx`, `日计划统计表.xlsx`,
) )

View File

@ -11,22 +11,24 @@
:action-columns="actionColumns" :action-columns="actionColumns"
> >
<!-- 工具栏插槽 --> <!-- 工具栏插槽 -->
<template #toolbar> <template #toolbar="{ formData }">
<ComButton <ComButton
type="primary" type="primary"
v-hasPermi="['settlement:add']" v-hasPermi="['settlement:add']"
icon="Plus" icon="Plus"
@click="onHandleAdd" @click="onHandleAdd"
>新建</ComButton
> >
新建
</ComButton>
<ComButton <ComButton
plain plain
type="info" type="info"
icon="Download" icon="Download"
@click="onDownloadStatistic" @click="onDownloadStatistic(formData)"
v-hasPermi="['settlement:download']" v-hasPermi="['settlement:download']"
>下载统计表</ComButton
> >
下载统计表
</ComButton>
</template> </template>
<!-- 合同状态列插槽 --> <!-- 合同状态列插槽 -->
@ -144,27 +146,14 @@ const onHandleAdd = () => {
} }
// //
const onDownloadStatistic = async () => { const onDownloadStatistic = async (query) => {
try { proxy.download(
const formData = comTableRef.value?.getFormData() || {} '/settlement/downloadSettlement',
const response = await downloadSettlementStatisticAPI(formData) {
// ...query,
const blob = new Blob([response], { },
type: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet', `结算统计表.xlsx`,
}) )
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('下载失败')
}
} }
// //