|
|
@@ -165,6 +165,49 @@ export const memoManageMixin = {
|
|
|
},
|
|
|
},
|
|
|
methods: {
|
|
|
+ // 优化后的获取详情方法,不再接收单个item参数
|
|
|
+ async getTasksByDateList() {
|
|
|
+ if (this.memoList.length > 0) {
|
|
|
+ try {
|
|
|
+ // 使用Promise.all并行获取所有备忘录的详情
|
|
|
+ const detailPromises = this.memoList.map(async (memo, index) => {
|
|
|
+ try {
|
|
|
+ const params = {
|
|
|
+ id: memo.id,
|
|
|
+ }
|
|
|
+ const res = await getMemoDetail(params)
|
|
|
+ if (res.code === 200 && res.value) {
|
|
|
+ // 更新原数组中的数据
|
|
|
+ const memoIndex = this.memoList.findIndex(
|
|
|
+ (item) => item.id === memo.id
|
|
|
+ )
|
|
|
+ if (memoIndex !== -1) {
|
|
|
+ this.memoList[memoIndex] = {
|
|
|
+ ...this.memoList[memoIndex],
|
|
|
+ ...res.value,
|
|
|
+ }
|
|
|
+ }
|
|
|
+ // 返回更新后的数据
|
|
|
+ return {
|
|
|
+ ...memo,
|
|
|
+ ...res.value,
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return memo // 如果获取失败,返回原数据
|
|
|
+ } catch (err) {
|
|
|
+ console.error('获取备忘录详情失败:', memo.id, err)
|
|
|
+ return memo // 发生错误时返回原数据
|
|
|
+ }
|
|
|
+ })
|
|
|
+
|
|
|
+ // 等待所有详情请求完成
|
|
|
+ this.memoList = await Promise.all(detailPromises)
|
|
|
+ } catch (error) {
|
|
|
+ console.error('批量获取备忘录详情失败:', error)
|
|
|
+ // 发生错误时返回原始列表
|
|
|
+ }
|
|
|
+ }
|
|
|
+ },
|
|
|
// 根据提醒类型获取对应的颜色
|
|
|
getReminderTypeColor(type) {
|
|
|
const colorMap = {
|
|
|
@@ -214,8 +257,7 @@ export const memoManageMixin = {
|
|
|
// 日历选择日期
|
|
|
handleDateClick(date, data) {
|
|
|
const dateStr = moment(date).format('YYYY-MM-DD')
|
|
|
- const tasks = this.memoList.filter((task) => task.memoDate === dateStr)
|
|
|
-
|
|
|
+ // const tasks = this.memoList.filter((task) => task.memoDate === dateStr)
|
|
|
this.searchParams.memoDate = dateStr
|
|
|
this.handleSearch()
|
|
|
// if (tasks.length > 0) {
|
|
|
@@ -338,19 +380,22 @@ export const memoManageMixin = {
|
|
|
this.selectedDate = moment(this.selectedDate).add(1, 'month').toDate()
|
|
|
},
|
|
|
// 获取备忘录列表
|
|
|
- async handleSearch(num) {
|
|
|
+ async handleSearch() {
|
|
|
try {
|
|
|
let params = {
|
|
|
...this.searchParams,
|
|
|
- pageSize: num || this.searchParams.pageSize,
|
|
|
+ pageSize: this.searchParams.pageSize,
|
|
|
}
|
|
|
const res = await getMemoList(params)
|
|
|
if (res.code == 200) {
|
|
|
this.memoList = res.value.records || []
|
|
|
+ // 只处理day字段,不调用详情接口
|
|
|
this.memoList.forEach((item) => {
|
|
|
const date = new Date(item.memoDate)
|
|
|
item.day = date.getDate()
|
|
|
})
|
|
|
+ // 在列表数据设置完成后,只调用一次详情接口获取所有需要的详情
|
|
|
+ await this.getTasksByDateList()
|
|
|
this.listTotal = res.value.total || 0
|
|
|
}
|
|
|
} catch (error) {
|
|
|
@@ -387,6 +432,8 @@ export const memoManageMixin = {
|
|
|
initCalendarData(num) {
|
|
|
this.selectedDate = new Date()
|
|
|
this.lunarInfo = this.getLunarInfo(this.selectedDate)
|
|
|
+ console.log('初始化日历数据:', this.selectedDate)
|
|
|
+ console.log('初始化日历数据:', this.lunarInfo)
|
|
|
this.handleSearch(num)
|
|
|
},
|
|
|
onTabChange(tab) {
|
|
|
@@ -570,7 +617,7 @@ export const memoManageMixin = {
|
|
|
setCalendarTitle() {
|
|
|
// 可以在这里添加设置日历标题的逻辑
|
|
|
let lunarInfo = this.lunarInfo
|
|
|
- return `${lunarInfo.lYear}年${lunarInfo.lMonth}月 农历${lunarInfo.gzYear}年【${lunarInfo.Animal}】`
|
|
|
+ return `${lunarInfo.cYear}年${lunarInfo.cMonth}月 农历${lunarInfo.gzYear}年【${lunarInfo.Animal}】`
|
|
|
},
|
|
|
},
|
|
|
}
|