This commit is contained in:
2025-09-26 17:51:07 +08:00
parent 9654a1cbbd
commit b73e0f8385
20 changed files with 1844 additions and 403 deletions

View File

@@ -1,6 +1,6 @@
<template>
<div class="calendar" style="min-width: 1000px;overflow-x: auto;min-height: 100%;">
<div v-if="allMonthData.length>0" @click="handleExportAll()" style="position: absolute; left: 360px;top:30px;cursor: pointer;color: #006699;font-size: 14px;"><i class="el-icon-download"></i>下载 {{year}} 年全部VIP报表</div>
<div v-if="allMonthData.length>0" @click="handleExportAll()" style="position: absolute; left: 360px;top:30px;cursor: pointer;color: #006699;font-size: 14px;"><i class="el-icon-download"></i>下载 {{selectYear}} 年全部VIP报表</div>
<el-card class="box-card" v-for="(month, mIndex) in allMonthData"
:key="mIndex" >
@@ -8,13 +8,13 @@
<div style="color: #888;font-weight: 700;text-align: center;position: relative;font-size: 20px;">{{ month.month}} <el-button @click="handleExport(Number(month.month))" style="float: right; padding: 3px 0;position: absolute;right: 0px;top: -2px;" type="text"><i class="el-icon-download"></i>下载报表</el-button>
</div>
</div>
<div class="days" style="margin-bottom: 15px;">
<div class="days" >
<!-- <div v-for="d in weekDays" :key="d" class="day header">{{ d }}</div> -->
<!-- <div v-for="blank in month.startWeek" :key="'b'+blank" class="day"></div> -->
<div v-for="d in list" :key="d" class="day header" style="margin-bottom: 10px;">{{ d.title }}</div>
<div v-for="d in list" class="day header" style="margin-bottom: 10px;">{{ d.title }}</div>
<div v-for="d in list" :key="d" class="day" :style="`${d.val=='currentTanxiao'?'background-color:#11cdba30;color:#d00':''}`">{{
<div v-for="d in list" class="day" :style="`${d.val=='currentTanxiao'?'background-color:#11cdba30;color:#d00':''}`">{{
month.total[d.val]
}}</div>
@@ -42,7 +42,7 @@
const currentMonth = now.getMonth() + 1; // 月份从0开始
// 如果是今年只取到当前月否则取12个月
const endMonth = year == currentYear ? currentMonth - 1 : 12;
const endMonth = year == currentYear ? currentMonth : 12;
let months = [];
for (let i = 1; i <= endMonth; i++) {
@@ -55,7 +55,7 @@
export default {
name: "FullYearCalendar",
props: {
year: {
selectYear: {
type: Number,
default: new Date().getFullYear()
},
@@ -90,32 +90,12 @@
};
},
computed: {
// months() {
// let months = [];
// for (let m = 0; m < 12; m++) {
// let firstDay = new Date(this.year, m, 1);
// let lastDay = new Date(this.year, m + 1, 0);
// let daysInMonth = lastDay.getDate();
// let startWeek1 = (firstDay.getDay() + 6) % 7; // 转换为 Mon=0
// let startWeek = (firstDay.getDay() + 6) % 7; // 转换为 Mon=0
// let days = [];
// for (let d = 1; d <= daysInMonth; d++) {
// let dateStr = `${this.year}-${String(m+1).padStart(2,"0")}-${String(d).padStart(2,"0")}`;
// days.push({
// number: d,
// date: dateStr,
// color: this.marks[dateStr] || ""
// });
// }
// months.push({ startWeek, days });
// }
// return months;
// }
},
async created() {
await this.getMonthsByYear(this.year)
await this.getMonthsByYear(this.selectYear)
await this.fetchAllMonthData()
},
methods: {
@@ -134,10 +114,10 @@
return this.$http({
url: this.$http.adornUrl(this.urlList.export),
method: "post",
data: this.$http.adornData({ date: `${this.year}-${m}` }),
data: this.$http.adornData({ date: this.$commonJS.getDate(this.selectYear,m) }),
responseType: "blob"
}).then(res => {
const filename = `VIP报表_${this.year}${m}月下载文件.xlsx`
const filename = `VIP报表_${this.selectYear}${m}月下载文件.xlsx`
const blob = new Blob([res.data], {
type: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"
})
@@ -175,7 +155,7 @@
async handleExport(mIndex) {
console.log('mIndex at line 120:', mIndex)
var filename = `VIP报表_${this.year}${this.pad(mIndex)}月下载文件.xlsx`;
var filename = `VIP报表_${this.selectYear}${this.pad(mIndex)}月下载文件.xlsx`;
this.$message({
message: "请耐心等待...",
type: "info",
@@ -189,7 +169,7 @@
),
method: "post",
data: this.$http.adornData({
date: `${this.year}-${this.pad(mIndex)}`
date: this.$commonJS.getDate(this.selectYear,this.pad(mIndex))
}),
responseType: "blob" // ⚡⚡⚡一定要加上
}).then(res => {
@@ -235,7 +215,7 @@
async init(){
this.showCurrentMonth = ''
this.showCurrentMonthDate = ''
await this.getMonthsByYear(this.year)
await this.getMonthsByYear(this.selectYear)
await this.fetchAllMonthData()
},
getMonthsByYear(year) {
@@ -254,7 +234,7 @@
spinner: "el-icon-loading",
background: "rgba(0, 0, 0, 0.7)"
});
const year = this.year
const year = this.selectYear
const months = getMonths(year)
console.log('months', months)
// 构造请求数组
@@ -263,7 +243,7 @@
return this.$http({
url: this.$http.adornUrl(this.urlList.list),
method: "post",
data: this.$http.adornData({ date: `${year}-${m}` })
data: this.$http.adornData({ date: this.$commonJS.getDate(year,m) })
}).then(res => {
if (res.data && res.data.code === 0) {
return { month: monthNum, total: res.data.total }
@@ -290,7 +270,7 @@
showClose: true
});
}
if (this.year == new Date().getFullYear()) {
if (this.selectYear == new Date().getFullYear()) {
const now = new Date()
const year = now.getFullYear()
const month = this.pad(now.getMonth() + 1)
@@ -332,7 +312,7 @@
.days {
display: grid;
grid-template-columns: repeat(4, 1fr);
font-size: 16px;
font-size: 17px;
}
.day {
text-align: center;
@@ -349,8 +329,11 @@
.day.blue { background: #ddeeff; color: #004; }
.day.yellow { background: #fff6cc; color: #665500; }
/deep/ .el-card .el-card__header{
padding: 8px 20px !important;
padding: 4px 20px !important;
}
/deep/ .el-card .el-card__body {
padding: 15px !important;
overflow-x: auto !important;
}
</style>