2.4 组件结构调整,调整会员权限判断
This commit is contained in:
@@ -20,8 +20,10 @@ const _sfc_main = {
|
||||
//结束日期
|
||||
selectYear: "",
|
||||
Month: "",
|
||||
calendarApiData: []
|
||||
calendarApiData: [],
|
||||
// 新增:存储接口返回的日历数据
|
||||
selectedDateKey: ""
|
||||
// 新增:选中日期的唯一标识(格式:YYYY-MM-DD)
|
||||
};
|
||||
},
|
||||
created() {
|
||||
@@ -70,8 +72,8 @@ const _sfc_main = {
|
||||
};
|
||||
},
|
||||
/**
|
||||
* 获取当天的item数据(合并接口数据)
|
||||
*/
|
||||
* 获取当天的item数据(合并接口数据)
|
||||
*/
|
||||
getTodayItem(year, month, day) {
|
||||
const targetDate = `${year}-${month > 9 ? month : "0" + month}-${day > 9 ? day : "0" + day}`;
|
||||
const currentMonthList = this.monthDateList[this.selectMonthIndex] || [];
|
||||
@@ -88,30 +90,9 @@ const _sfc_main = {
|
||||
// 示例:炸板率
|
||||
};
|
||||
},
|
||||
/**
|
||||
* 触发日期变更事件(传递包含接口数据的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 }) {
|
||||
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", {
|
||||
@@ -215,22 +196,14 @@ const _sfc_main = {
|
||||
this.calendarApiData = res.data;
|
||||
if (this.selectDateStr) {
|
||||
const [year, month, day] = this.selectDateStr.split("-").map(Number);
|
||||
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:330", "日历接口返回数据格式异常", res);
|
||||
common_vendor.index.__f__("warn", "at components/LCCalendar/LCCalendar.vue:316", "日历接口返回数据格式异常", res);
|
||||
}
|
||||
} catch (error) {
|
||||
this.calendarApiData = [];
|
||||
common_vendor.index.__f__("error", "at components/LCCalendar/LCCalendar.vue:334", "获取日历数据失败", error);
|
||||
common_vendor.index.__f__("error", "at components/LCCalendar/LCCalendar.vue:320", "获取日历数据失败", error);
|
||||
}
|
||||
},
|
||||
/**
|
||||
@@ -328,6 +301,7 @@ const _sfc_main = {
|
||||
*/
|
||||
clickPreMonth() {
|
||||
if (this.selectMonthIndex > 0) {
|
||||
this.selectedDateKey = "";
|
||||
this.selectMonthIndex--;
|
||||
let monthList = this.monthDateList[this.selectMonthIndex];
|
||||
let year = "";
|
||||
@@ -351,8 +325,9 @@ const _sfc_main = {
|
||||
this.endDateStr = year + "-" + (month > 9 ? month : "0" + month) + "-" + lastDay;
|
||||
this.selectYear = year;
|
||||
this.Month = month;
|
||||
this.selectDateStr = this.startDateStr;
|
||||
this.getCalendarCombinedData();
|
||||
common_vendor.index.__f__("log", "at components/LCCalendar/LCCalendar.vue:469", "点击上个月");
|
||||
common_vendor.index.__f__("log", "at components/LCCalendar/LCCalendar.vue:457", "点击上个月");
|
||||
}
|
||||
},
|
||||
/**
|
||||
@@ -360,6 +335,7 @@ const _sfc_main = {
|
||||
*/
|
||||
clickNextMonth() {
|
||||
if (this.selectMonthIndex < this.monthDateList.length - 1) {
|
||||
this.selectedDateKey = "";
|
||||
this.selectMonthIndex++;
|
||||
let monthList = this.monthDateList[this.selectMonthIndex];
|
||||
let year = "";
|
||||
@@ -381,12 +357,21 @@ 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:498", "点击下个月");
|
||||
common_vendor.index.__f__("log", "at components/LCCalendar/LCCalendar.vue:489", "点击下个月");
|
||||
this.selectYear = year;
|
||||
this.Month = month;
|
||||
this.selectDateStr = this.startDateStr;
|
||||
this.getCalendarCombinedData();
|
||||
}
|
||||
},
|
||||
/**
|
||||
* 通用补零函数:确保数字为两位数,不足则前面补0
|
||||
* @param {number|string} num - 需要补零的数字
|
||||
* @returns {string} 补零后的字符串
|
||||
*/
|
||||
padZero(num) {
|
||||
return String(num).padStart(2, "0");
|
||||
},
|
||||
monthChange(e) {
|
||||
let currentDate = /* @__PURE__ */ new Date();
|
||||
let currentYear = currentDate.getFullYear();
|
||||
@@ -411,6 +396,7 @@ const _sfc_main = {
|
||||
if (!item.isCurrentMonth)
|
||||
return;
|
||||
if (this.selectDateStr != item.date) {
|
||||
this.selectedDateKey = item.date;
|
||||
this.selectDateStr = item.date;
|
||||
const apiData = this.getCalendarItemByDate(item.date) || {};
|
||||
const mergedItem = {
|
||||
@@ -451,36 +437,21 @@ const _sfc_main = {
|
||||
this.chgStockData = mergedItem;
|
||||
const [year, month, day] = item.date.split("-").map(Number);
|
||||
this.emitDateChange(year, month, day, mergedItem, prevMergedItem);
|
||||
common_vendor.index.__f__("log", "at components/LCCalendar/LCCalendar.vue:580", "点击某天(含接口数据)", { current: mergedItem, prev: prevMergedItem });
|
||||
common_vendor.index.__f__("log", "at components/LCCalendar/LCCalendar.vue:583", "点击某天(含接口数据)", {
|
||||
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) {
|
||||
return {
|
||||
a: common_assets._imports_0$1,
|
||||
b: common_vendor.o(($event) => $options.clickPreMonth()),
|
||||
c: common_assets._imports_1$16,
|
||||
c: common_assets._imports_1$18,
|
||||
d: common_vendor.t($data.selectDateStr),
|
||||
e: common_assets._imports_1$2,
|
||||
e: common_assets._imports_2$3,
|
||||
f: common_vendor.o(($event) => $options.clickNextMonth()),
|
||||
g: common_vendor.f($data.weekList, (item, index, i0) => {
|
||||
return {
|
||||
@@ -503,25 +474,27 @@ function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
|
||||
g: common_vendor.t(((_e = $options.getCalendarItemByDate(item.date)) == null ? void 0 : _e.top_sector) || "-"),
|
||||
h: $options.getZtCountTextColor((_f = $options.getCalendarItemByDate(item.date)) == null ? void 0 : _f.zt_count)
|
||||
} : {}), {
|
||||
i: common_vendor.n($options.getZtCountBgClass((_g = $options.getCalendarItemByDate(item.date)) == null ? void 0 : _g.zt_count))
|
||||
i: common_vendor.n($options.getZtCountBgClass((_g = $options.getCalendarItemByDate(item.date)) == null ? void 0 : _g.zt_count)),
|
||||
j: common_vendor.n($data.selectedDateKey === item.date ? "selected-border" : "")
|
||||
}) : common_vendor.e({
|
||||
j: !item.isCurrentMonth
|
||||
k: !item.isCurrentMonth
|
||||
}, !item.isCurrentMonth ? {} : common_vendor.e({
|
||||
k: common_vendor.t(item.day),
|
||||
l: index % 7 == 0 || index % 7 == 6 ? "#999999" : "#2A2A2A",
|
||||
m: index % 7 == 0 || index % 7 == 6
|
||||
l: common_vendor.t(item.day),
|
||||
m: index % 7 == 0 || index % 7 == 6 ? "#999999" : "#2A2A2A",
|
||||
n: index % 7 == 0 || index % 7 == 6
|
||||
}, index % 7 == 0 || index % 7 == 6 ? {} : common_vendor.e({
|
||||
n: ((_h = $options.getCalendarItemByDate(item.date)) == null ? void 0 : _h.zt_count) > 0
|
||||
o: ((_h = $options.getCalendarItemByDate(item.date)) == null ? void 0 : _h.zt_count) > 0
|
||||
}, ((_i = $options.getCalendarItemByDate(item.date)) == null ? void 0 : _i.zt_count) > 0 ? {
|
||||
o: common_vendor.t((_j = $options.getCalendarItemByDate(item.date)) == null ? void 0 : _j.zt_count),
|
||||
p: $options.getZtCountTextColor((_k = $options.getCalendarItemByDate(item.date)) == null ? void 0 : _k.zt_count),
|
||||
q: common_vendor.t(((_l = $options.getCalendarItemByDate(item.date)) == null ? void 0 : _l.top_sector) || "-"),
|
||||
r: $options.getZtCountTextColor((_m = $options.getCalendarItemByDate(item.date)) == null ? void 0 : _m.zt_count)
|
||||
p: common_vendor.t((_j = $options.getCalendarItemByDate(item.date)) == null ? void 0 : _j.zt_count),
|
||||
q: $options.getZtCountTextColor((_k = $options.getCalendarItemByDate(item.date)) == null ? void 0 : _k.zt_count),
|
||||
r: common_vendor.t(((_l = $options.getCalendarItemByDate(item.date)) == null ? void 0 : _l.top_sector) || "-"),
|
||||
s: $options.getZtCountTextColor((_m = $options.getCalendarItemByDate(item.date)) == null ? void 0 : _m.zt_count)
|
||||
} : {}), {
|
||||
s: common_vendor.n($options.getZtCountBgClass((_n = $options.getCalendarItemByDate(item.date)) == null ? void 0 : _n.zt_count))
|
||||
t: common_vendor.n($options.getZtCountBgClass((_n = $options.getCalendarItemByDate(item.date)) == null ? void 0 : _n.zt_count)),
|
||||
v: common_vendor.n($data.selectedDateKey === item.date ? "selected-border" : "")
|
||||
})), {
|
||||
t: index,
|
||||
v: common_vendor.o(($event) => $options.clickSelectDate(item), index)
|
||||
w: index,
|
||||
x: common_vendor.o(($event) => $options.clickSelectDate(item, index), index)
|
||||
});
|
||||
})
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user