提交 01fa8e11 authored 作者: 邓文彬's avatar 邓文彬

fix(机房巡检): 加载时间优化

上级 5bcd8979
......@@ -66,7 +66,10 @@ export default {
uni.setStorageSync("now_user", this.$store.state.now_user);
uni.setStorageSync("last_time", this.$store.state.now_user.LastSynchronizationTime);
// 清除store 数据
this.$store.commit("SET_DARF_DATA", {});
this.$store.commit("SET_LOG_LIST", []);
this.$store.commit("SET_ALL_DATA", []);
},
onUnload() {
},
......
......@@ -84,7 +84,7 @@ export default {
{
defaultIcon: "iconfont icon-Inspection",
isActive: false,
text: "杭州内网机房巡检",
text: "巡检管理",
},
{
defaultIcon: "iconfont icon-a-ActivityConfiguration",
......@@ -137,6 +137,9 @@ export default {
"last_time",
this.$store.state.now_user.LastSynchronizationTime || ""
);
},
});
},
......
......@@ -63,7 +63,12 @@ export default {
},
created() {},
onShow() {},
mounted() {},
mounted() {
this.$store.commit("SET_DARF_DATA", {});
this.$store.commit("SET_LOG_LIST", []);
this.$store.commit("SET_ALL_DATA", []);
},
// 定义返回退出
onBackPress(options) {
this.backButtonPress++;
......
......@@ -14,6 +14,13 @@ import lodash from "lodash";
*/
export const getAllInspections = () => {
return new Promise((resolve, reject) => {
if(store.state.all_data.length){
const tempRes = lodash.orderBy(store.state.all_data, "creatTime", ['desc']);
const result = lodash.orderBy(tempRes, "synchronization", ['asc']);
resolve(result)
return;
}
readInspectionData()
.then((res) => {
const tempRes = lodash.orderBy(res, "creatTime", ['desc']);
......@@ -34,6 +41,13 @@ export const getAllInspections = () => {
*/
export const getLogList = () => {
return new Promise((resolve, reject) => {
if(store.state.log_list.length){
const tempRes = lodash.orderBy(store.state.log_list, "time", "desc");
resolve(tempRes)
return;
}
readLogData()
.then((res) => {
const tempRes = lodash.orderBy(res, "time", "desc");
......
......@@ -58,6 +58,10 @@ export const addLog = (content) => {
const fileContent = Base64.encode(JSON.stringify(temp)); // 方便验证
// store 更新日志
store.commit("SET_LOG_LIST", content);
createFileWithPlusIO(
`${SYNCHRONIZE_DATA_PAD}/日志文件/${now_user.user}`,
fileName,
......@@ -147,15 +151,14 @@ export const readDarfData = () => {
*/
export const writeInspectionData = (content, userName) => {
return new Promise((resolve, reject) => {
// const now_user = store.state.now_user;
let timeStr = moment().format("yyyy-MM-DD");
// let fileName = `${timeStr}.txt`;
let fileName = `list.txt`;
const fileContent = Base64.encode(JSON.stringify(content));
// store 更新 巡检数据
store.commit("SET_ALL_DATA", content);
const fileContent = Base64.encode(JSON.stringify(content));
createFileWithPlusIO(
`${SYNCHRONIZE_DATA_PAD}/巡检数据/${userName}`,
......@@ -385,9 +388,6 @@ export function deleteAllFilesInDirectory(directoryPath) {
});
}
// // 使用示例
// const directoryPath = '_doc/exampleDirectory';
// deleteAllFilesInDirectory(directoryPath);
// 初始化 -- 读取数据文件
export const readDirectoryData = () => {
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论