|
@@ -213,16 +213,42 @@ export default {
|
|
|
const day = String(date.getDate()).padStart(2, "0");
|
|
|
return `${year}${month}${day}`;
|
|
|
},
|
|
|
+ //根据日期获取第几周
|
|
|
+ getWeek(dateTime) {
|
|
|
+ var time,
|
|
|
+ week,
|
|
|
+ checkDate = new Date(dateTime);
|
|
|
+ checkDate.setDate(checkDate.getDate() + 4 - (checkDate.getDay() || 7));
|
|
|
+ time = checkDate.getTime();
|
|
|
+ checkDate.setMonth(0);
|
|
|
+ checkDate.setDate(1);
|
|
|
+ week = Math.floor(Math.round((time - checkDate) / 86400000) / 7) + 1;
|
|
|
+ return week;
|
|
|
+ },
|
|
|
+ formatDateToYYYYMMDD(dateStr) {
|
|
|
+ // 检查输入字符串是否为8位数字,即yyyymmdd格式
|
|
|
+ if (!/^\d{8}$/.test(dateStr)) {
|
|
|
+ throw new Error('Invalid date format. Expected yyyymmdd.');
|
|
|
+ }
|
|
|
+ // 提取年月日部分
|
|
|
+ const year = dateStr.substring(0, 4);
|
|
|
+ const month = dateStr.substring(4, 6);
|
|
|
+ const day = dateStr.substring(6, 8);
|
|
|
+
|
|
|
+ // 格式化并返回yyyy-mm-dd格式的字符串
|
|
|
+ return `${year}-${month.padStart(2, '0')}-${day.padStart(2, '0')}`;
|
|
|
+ },
|
|
|
async onExport() {
|
|
|
const res = await weekExport(
|
|
|
this.queryParams.startDate,
|
|
|
this.queryParams.endDate
|
|
|
);
|
|
|
+ const weekNum=this.getWeek(this.formatDateToYYYYMMDD(this.queryParams.startDate));
|
|
|
if (res) {
|
|
|
const elink = document.createElement("a");
|
|
|
- elink.download = `周报-${this.queryParams.startDate}_${this.queryParams.endDate}.xls`;
|
|
|
+ elink.download = `配电专业生产周例会汇报材料(第`+weekNum+`周).doc`;
|
|
|
elink.style.display = "none";
|
|
|
- const blob = new Blob([res], { type: "application/x-msdownload" });
|
|
|
+ const blob = new Blob([res], { type: "application/msword;charset=UTF-8" });
|
|
|
elink.href = URL.createObjectURL(blob);
|
|
|
document.body.appendChild(elink);
|
|
|
elink.click();
|