1.31 财务分析,财务数据模块完善,产业链桑基图展示
This commit is contained in:
@@ -35,12 +35,40 @@ const _sfc_main = {
|
||||
this.endDateStr = this.selectDateStr = `${currentYear}-${currentMonth > 9 ? currentMonth : "0" + currentMonth}-${currentDay > 9 ? currentDay : "0" + currentDay}`;
|
||||
this.getYesterdayDateData();
|
||||
this.generateMonthDateListData();
|
||||
this.emitDateChange(currentYear, currentMonth, currentDay, this.getTodayItem(currentYear, currentMonth, currentDay));
|
||||
this.emitDateChange(
|
||||
currentYear,
|
||||
currentMonth,
|
||||
currentDay,
|
||||
this.getTodayItem(currentYear, currentMonth, currentDay),
|
||||
this.getPrevDayItem(currentYear, currentMonth, currentDay)
|
||||
// 新增上一天数据
|
||||
);
|
||||
},
|
||||
mounted() {
|
||||
this.getCalendarCombinedData();
|
||||
},
|
||||
methods: {
|
||||
// 3. 在日历组件methods中新增getPrevDayItem方法
|
||||
/**
|
||||
* 获取指定日期的上一天数据
|
||||
*/
|
||||
getPrevDayItem(year, month, day) {
|
||||
const currentDate = /* @__PURE__ */ new Date(`${year}-${month}-${day}`);
|
||||
const prevDate = new Date(currentDate.getTime() - 24 * 60 * 60 * 1e3);
|
||||
const prevYear = prevDate.getFullYear();
|
||||
const prevMonth = prevDate.getMonth() + 1;
|
||||
const prevDay = prevDate.getDate();
|
||||
const targetDate = `${prevYear}-${prevMonth > 9 ? prevMonth : "0" + prevMonth}-${prevDay > 9 ? prevDay : "0" + prevDay}`;
|
||||
const currentMonthList = this.monthDateList[this.selectMonthIndex] || [];
|
||||
const localItem = currentMonthList.find((item) => item.date === targetDate) || null;
|
||||
const apiData = this.getCalendarItemByDate(targetDate) || {};
|
||||
return {
|
||||
...localItem,
|
||||
zt_count: apiData.zt_count || 0,
|
||||
top_sector: apiData.top_sector || "-",
|
||||
zaban_rate: apiData.zaban_rate || "0%"
|
||||
};
|
||||
},
|
||||
/**
|
||||
* 获取当天的item数据(合并接口数据)
|
||||
*/
|
||||
@@ -63,14 +91,34 @@ const _sfc_main = {
|
||||
/**
|
||||
* 触发日期变更事件(传递包含接口数据的item)
|
||||
*/
|
||||
emitDateChange(year, month, day, item) {
|
||||
// emitDateChange(year, month, day, item) {
|
||||
// const yearMonth = `${year}-${month > 9 ? month : '0' + month}`;
|
||||
// const fullDate = `${year}-${month > 9 ? month : '0' + month}-${day > 9 ? day : '0' + day}`;
|
||||
// this.$emit('date-change', {
|
||||
// yearMonth,
|
||||
// fullDate,
|
||||
// item: item || { // 兜底:无item时赋值空对象+默认值
|
||||
// date: fullDate,
|
||||
// year,
|
||||
// month,
|
||||
// day,
|
||||
// zt_count: 0,
|
||||
// top_sector: '-',
|
||||
// zaban_rate: '0%'
|
||||
// },
|
||||
// year,
|
||||
// month,
|
||||
// day
|
||||
// });
|
||||
// },
|
||||
emitDateChange(year, month, day, item, prevItem = { zt_count: 0 }) {
|
||||
const yearMonth = `${year}-${month > 9 ? month : "0" + month}`;
|
||||
const fullDate = `${year}-${month > 9 ? month : "0" + month}-${day > 9 ? day : "0" + day}`;
|
||||
this.$emit("date-change", {
|
||||
yearMonth,
|
||||
fullDate,
|
||||
item: item || {
|
||||
// 兜底:无item时赋值空对象+默认值
|
||||
// 兜底:无当前item时赋值空对象+默认值
|
||||
date: fullDate,
|
||||
year,
|
||||
month,
|
||||
@@ -79,6 +127,12 @@ const _sfc_main = {
|
||||
top_sector: "-",
|
||||
zaban_rate: "0%"
|
||||
},
|
||||
prevItem: prevItem || {
|
||||
// 新增:传递上一天数据,兜底默认值
|
||||
zt_count: 0,
|
||||
top_sector: "-",
|
||||
zaban_rate: "0%"
|
||||
},
|
||||
year,
|
||||
month,
|
||||
day
|
||||
@@ -159,18 +213,24 @@ const _sfc_main = {
|
||||
const res = await request_api.calendarCombinedData(param);
|
||||
if (res.success && Array.isArray(res.data)) {
|
||||
this.calendarApiData = res.data;
|
||||
common_vendor.index.__f__("log", "at components/LCCalendar/LCCalendar.vue:258", "日历数据加载成功", this.calendarApiData);
|
||||
if (this.selectDateStr) {
|
||||
const [year, month, day] = this.selectDateStr.split("-").map(Number);
|
||||
this.emitDateChange(year, month, day, this.getTodayItem(year, month, day));
|
||||
this.emitDateChange(
|
||||
year,
|
||||
month,
|
||||
day,
|
||||
this.getTodayItem(year, month, day),
|
||||
this.getPrevDayItem(year, month, day)
|
||||
// 新增上一天数据
|
||||
);
|
||||
}
|
||||
} else {
|
||||
this.calendarApiData = [];
|
||||
common_vendor.index.__f__("warn", "at components/LCCalendar/LCCalendar.vue:266", "日历接口返回数据格式异常", res);
|
||||
common_vendor.index.__f__("warn", "at components/LCCalendar/LCCalendar.vue:330", "日历接口返回数据格式异常", res);
|
||||
}
|
||||
} catch (error) {
|
||||
this.calendarApiData = [];
|
||||
common_vendor.index.__f__("error", "at components/LCCalendar/LCCalendar.vue:270", "获取日历数据失败", error);
|
||||
common_vendor.index.__f__("error", "at components/LCCalendar/LCCalendar.vue:334", "获取日历数据失败", error);
|
||||
}
|
||||
},
|
||||
/**
|
||||
@@ -292,7 +352,7 @@ const _sfc_main = {
|
||||
this.selectYear = year;
|
||||
this.Month = month;
|
||||
this.getCalendarCombinedData();
|
||||
common_vendor.index.__f__("log", "at components/LCCalendar/LCCalendar.vue:405", "点击上个月");
|
||||
common_vendor.index.__f__("log", "at components/LCCalendar/LCCalendar.vue:469", "点击上个月");
|
||||
}
|
||||
},
|
||||
/**
|
||||
@@ -321,7 +381,7 @@ const _sfc_main = {
|
||||
this.selectMonth = year + "年" + month + "月";
|
||||
this.startDateStr = year + "-" + (month > 9 ? month : "0" + month) + "-01";
|
||||
this.endDateStr = year + "-" + (month > 9 ? month : "0" + month) + "-" + lastDay;
|
||||
common_vendor.index.__f__("log", "at components/LCCalendar/LCCalendar.vue:434", "点击下个月");
|
||||
common_vendor.index.__f__("log", "at components/LCCalendar/LCCalendar.vue:498", "点击下个月");
|
||||
this.selectYear = year;
|
||||
this.Month = month;
|
||||
this.getCalendarCombinedData();
|
||||
@@ -338,7 +398,7 @@ const _sfc_main = {
|
||||
this.startDateStr = selectYear + "-" + (selectMonth > 9 ? selectMonth : "0" + selectMonth) + "-01";
|
||||
let lastDayOfMonth = new Date(selectYear, selectMonth, 0);
|
||||
this.endDateStr = selectYear + "-" + (selectMonth > 9 ? selectMonth : "0" + selectMonth) + "-" + lastDayOfMonth.getDate();
|
||||
common_vendor.index.__f__("log", "at components/LCCalendar/LCCalendar.vue:454", "月份变更");
|
||||
common_vendor.index.__f__("log", "at components/LCCalendar/LCCalendar.vue:518", "月份变更");
|
||||
this.selectYear = selectYear;
|
||||
this.Month = selectMonth;
|
||||
this.getCalendarCombinedData();
|
||||
@@ -365,12 +425,53 @@ const _sfc_main = {
|
||||
isWeekend: index % 7 === 0 || index % 7 === 6
|
||||
// 是否周末
|
||||
};
|
||||
const currentDate = new Date(item.date);
|
||||
const prevDate = new Date(currentDate.getTime() - 24 * 60 * 60 * 1e3);
|
||||
const prevYear = prevDate.getFullYear();
|
||||
const prevMonth = prevDate.getMonth() + 1;
|
||||
const prevDay = prevDate.getDate();
|
||||
const prevDateStr = `${prevYear}-${prevMonth > 9 ? prevMonth : "0" + prevMonth}-${prevDay > 9 ? prevDay : "0" + prevDay}`;
|
||||
const prevApiData = this.getCalendarItemByDate(prevDateStr) || {};
|
||||
let prevLocalItem = null;
|
||||
const currentMonthList = this.monthDateList[this.selectMonthIndex] || [];
|
||||
prevLocalItem = currentMonthList.find((i) => i.date === prevDateStr);
|
||||
if (!prevLocalItem) {
|
||||
const prevMonthIndex = this.selectMonthIndex - (prevMonth < item.month ? 1 : 0);
|
||||
const prevMonthList = this.monthDateList[prevMonthIndex] || [];
|
||||
prevLocalItem = prevMonthList.find((i) => i.date === prevDateStr);
|
||||
}
|
||||
const prevMergedItem = {
|
||||
...prevLocalItem || {},
|
||||
zt_count: prevApiData.zt_count || 0,
|
||||
top_sector: prevApiData.top_sector || "-",
|
||||
zaban_rate: prevApiData.zaban_rate || "0%",
|
||||
isWeekend: false
|
||||
// 兜底默认值
|
||||
};
|
||||
this.chgStockData = mergedItem;
|
||||
const [year, month, day] = item.date.split("-").map(Number);
|
||||
this.emitDateChange(year, month, day, mergedItem);
|
||||
common_vendor.index.__f__("log", "at components/LCCalendar/LCCalendar.vue:482", "点击某天(含接口数据)", mergedItem);
|
||||
this.emitDateChange(year, month, day, mergedItem, prevMergedItem);
|
||||
common_vendor.index.__f__("log", "at components/LCCalendar/LCCalendar.vue:580", "点击某天(含接口数据)", { current: mergedItem, prev: prevMergedItem });
|
||||
}
|
||||
}
|
||||
// clickSelectDate(item, index) {
|
||||
// if (!item.isCurrentMonth) return
|
||||
// if (this.selectDateStr != item.date) {
|
||||
// this.selectDateStr = item.date
|
||||
// const apiData = this.getCalendarItemByDate(item.date) || {};
|
||||
// const mergedItem = {
|
||||
// ...item,
|
||||
// zt_count: apiData.zt_count || 0,
|
||||
// top_sector: apiData.top_sector || '-',
|
||||
// zaban_rate: apiData.zaban_rate || '0%',
|
||||
// isWeekend: index % 7 === 0 || index % 7 === 6
|
||||
// };
|
||||
// this.chgStockData = mergedItem;
|
||||
// const [year, month, day] = item.date.split('-').map(Number);
|
||||
// this.emitDateChange(year, month, day, mergedItem);
|
||||
// uni.__f__('log','at components/LCCalendar/LCCalendar.vue:602','点击某天(含接口数据)', mergedItem);
|
||||
// }
|
||||
// }
|
||||
}
|
||||
};
|
||||
function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
|
||||
|
||||
Reference in New Issue
Block a user