修改 膳食改为 每次取回来数据在本地缓存,然后再取出来使用
This commit is contained in:
@@ -154,39 +154,79 @@ export default {
|
||||
'X-Sign': signMd5Utils.getSign(requestUrl, params),
|
||||
'X-TIMESTAMP': signMd5Utils.getDateTimeToString(requestUrl, params),
|
||||
}).then((res) => {
|
||||
_this.dataConfig.list = [];
|
||||
if (res.success && res.result) {
|
||||
_this.dataConfig.dinnerType = res.result.dinnerType ? res.result.dinnerType : "-";
|
||||
_this.dataConfig.userNum = res.result.userNum ? res.result.userNum : "-";
|
||||
// _this.dataConfig.startDay = res.result.startDay ? _this.formatDateString(res.result.startDay) : "-";
|
||||
_this.dataConfig.startDay = "2025年5月7日";
|
||||
_this.getSessionStorageData(res);
|
||||
|
||||
_this.dataConfig.personnelType = _this.rankingConfig.personnelType;
|
||||
let dataKey = _this.dataConfig.personnelType === "staff" ? 'nutritionRankingsVos' : 'departRankingsVos';
|
||||
let list = res.result[dataKey];
|
||||
// if (res.success && res.result) {
|
||||
// _this.dataConfig.dinnerType = res.result.dinnerType ? res.result.dinnerType : "-";
|
||||
// _this.dataConfig.userNum = res.result.userNum ? res.result.userNum : "-";
|
||||
// _this.dataConfig.startDay = "2025年5月7日";
|
||||
//
|
||||
// _this.dataConfig.personnelType = _this.rankingConfig.personnelType;
|
||||
// let dataKey = _this.dataConfig.personnelType === "staff" ? 'nutritionRankingsVos' : 'departRankingsVos';
|
||||
// let list = res.result[dataKey];
|
||||
//
|
||||
// if (list && list.length) {
|
||||
// list.map(item => {
|
||||
// if(item.departName === "行政事务管理处") {
|
||||
// item.departName = "公共事务中心";
|
||||
// }
|
||||
// })
|
||||
// _this.dataConfig.list = list;
|
||||
//
|
||||
// _this.$nextTick(() => {
|
||||
// _this.startOneTimeScroll();
|
||||
// });
|
||||
// } else {
|
||||
// _this.startBannerLoop();
|
||||
// }
|
||||
// } else {
|
||||
// _this.startBannerLoop();
|
||||
// }
|
||||
}).catch((error) => {
|
||||
console.error("请求失败:", error);
|
||||
_this.getSessionStorageData(null);
|
||||
});
|
||||
},
|
||||
|
||||
if (list && list.length) {
|
||||
list.map(item => {
|
||||
if(item.departName === "行政事务管理处") {
|
||||
item.departName = "公共事务中心";
|
||||
}
|
||||
})
|
||||
_this.dataConfig.list = list;
|
||||
getSessionStorageData(res) {
|
||||
let _this = this;
|
||||
_this.dataConfig.list = [];
|
||||
_this.dataConfig.personnelType = _this.rankingConfig.personnelType;
|
||||
let dataKey = _this.dataConfig.personnelType === "staff" ? 'nutritionRankingsVos' : 'departRankingsVos';
|
||||
if (res && res.success && res.result) {
|
||||
console.log('有新数据,并且写入了。');
|
||||
|
||||
_this.$nextTick(() => {
|
||||
_this.startOneTimeScroll();
|
||||
});
|
||||
} else {
|
||||
_this.startBannerLoop();
|
||||
}
|
||||
if (res.result[dataKey] && res.result[dataKey].length) {
|
||||
res.result[dataKey].map(item => {
|
||||
if(item.departName === "行政事务管理处") {
|
||||
item.departName = "公共事务中心";
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
sessionStorage.setItem(dataKey, JSON.stringify(res.result));
|
||||
}
|
||||
|
||||
let data = sessionStorage.getItem(dataKey) || null;
|
||||
if(data) {
|
||||
let data_ = JSON.parse(data);
|
||||
|
||||
_this.dataConfig.dinnerType = data_.dinnerType ? data_.dinnerType : "-";
|
||||
_this.dataConfig.userNum = data_.userNum ? data_.userNum : "-";
|
||||
_this.dataConfig.startDay = "2025年5月7日";
|
||||
|
||||
if (data_[dataKey] && data_[dataKey].length) {
|
||||
_this.dataConfig.list = data_[dataKey];
|
||||
|
||||
_this.$nextTick(() => {
|
||||
_this.startOneTimeScroll();
|
||||
});
|
||||
} else {
|
||||
_this.startBannerLoop();
|
||||
}
|
||||
}).catch((error) => {
|
||||
console.error("请求失败:", error);
|
||||
_this.dataConfig.list = [];
|
||||
} else {
|
||||
_this.startBannerLoop();
|
||||
});
|
||||
}
|
||||
},
|
||||
|
||||
startOneTimeScroll() {
|
||||
|
||||
Reference in New Issue
Block a user