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

fix(pad): 功能走查,用户信息更新bug解决

上级 198631c3
...@@ -114,10 +114,11 @@ export default { ...@@ -114,10 +114,11 @@ export default {
this.person.user == this.personList[key].user && this.person.user == this.personList[key].user &&
this.person.pd == this.personList[key].passWord this.person.pd == this.personList[key].passWord
) { ) {
console.log("-userInfo---",userInfo)
const userInfo = this.personList[key]; const userInfo = this.personList[key];
this.$store.commit("SET_USER", userInfo); this.$store.commit("SET_USER", userInfo);
uni.setStorageSync("now_user", userInfo); uni.setStorageSync("now_user", userInfo);
uni.setStorageSync("last_time", userInfo.LastSynchronizationTime || "");
uni.navigateTo({ uni.navigateTo({
url: "/pages/home/home", url: "/pages/home/home",
......
...@@ -57,6 +57,7 @@ import { ...@@ -57,6 +57,7 @@ import {
} from "@/utils/IoReadingAndWriting.js"; } from "@/utils/IoReadingAndWriting.js";
import moment from "moment"; import moment from "moment";
import { getAllInspections } from "@/request/index.js"; import { getAllInspections } from "@/request/index.js";
import { Base64 } from "js-base64";
export default { export default {
props: { props: {
...@@ -87,9 +88,19 @@ export default { ...@@ -87,9 +88,19 @@ export default {
getAllInspections().then((res) => { getAllInspections().then((res) => {
this.allList = res; this.allList = res;
console.log("_--", this.list);
}); });
}, },
watch: {
list(newData) {
const temp = [];
newData.forEach((item) => {
temp.push(...(item.list || []));
});
this.notSynchronizationList = temp.filter(
(item) => item.synchronization == 0
);
},
},
methods: { methods: {
close() { close() {
this.$emit("close"); this.$emit("close");
...@@ -106,16 +117,11 @@ export default { ...@@ -106,16 +117,11 @@ export default {
const targetDirectoryPath = `${SYNCHRONIZE_DATA_PAD}/history`; const targetDirectoryPath = `${SYNCHRONIZE_DATA_PAD}/history`;
checkAndCreateDirectory(directoryPath).then(() => { checkAndCreateDirectory(directoryPath).then(() => {
console.log("---sss");
copyDirectory(directoryPath, targetDirectoryPath) copyDirectory(directoryPath, targetDirectoryPath)
.then(() => { .then(() => {
console.log("---文件复制完成");
return deleteAllFilesInDirectory(directoryPath); return deleteAllFilesInDirectory(directoryPath);
}) })
.then(() => { .then(() => {
console.log("---文件删除成功----");
console.log("coverData----", this.$store.state.now_user.user);
this.coverData(); this.coverData();
}) })
.catch((error) => { .catch((error) => {
...@@ -223,7 +229,7 @@ export default { ...@@ -223,7 +229,7 @@ export default {
log_list.push(logContent); log_list.push(logContent);
this.$store.commit("SET_LOG_LIST", log_list); this.$store.commit("SET_LOG_LIST", log_list);
addLog(log_list).then((res) => { addLog(log_list).then((res) => {
console.log("日志文件写入成功"); // console.log("日志文件写入成功");
}); });
// 更新同步时间 // 更新同步时间
...@@ -254,7 +260,7 @@ export default { ...@@ -254,7 +260,7 @@ export default {
// 打包文件 // 打包文件
packedData(content, fileName) { packedData(content, fileName) {
console.log("--------发送数据内容----", fileName, content); // console.log("--------发送数据内容----", fileName, content);
const fileContent = setSm2(content); const fileContent = setSm2(content);
return createFileWithPlusIO( return createFileWithPlusIO(
...@@ -271,13 +277,13 @@ export default { ...@@ -271,13 +277,13 @@ export default {
const key = personList.findIndex( const key = personList.findIndex(
(item) => item.userId == now_user.userId (item) => item.userId == now_user.userId
); );
console.log("--updateSysTime-", key);
// 更新用户同步时间 // 更新用户同步时间
const userInfo = personList[key]; const userInfo = personList[key];
const LastSynchronizationTime = moment().format("yyyy-MM-DD HH:mm"); const LastSynchronizationTime = moment().format("yyyy-MM-DD HH:mm");
personList[key].LastSynchronizationTime = LastSynchronizationTime; personList[key].LastSynchronizationTime = LastSynchronizationTime;
userInfo.LastSynchronizationTime = LastSynchronizationTime; userInfo.LastSynchronizationTime = LastSynchronizationTime;
console.log("---更新最近一次同步时间--", userInfo); // console.log("---更新最近一次同步时间--", userInfo);
this.$store.commit("SET_USER", userInfo); this.$store.commit("SET_USER", userInfo);
uni.setStorageSync("last_time", userInfo.LastSynchronizationTime || ""); uni.setStorageSync("last_time", userInfo.LastSynchronizationTime || "");
...@@ -293,7 +299,12 @@ export default { ...@@ -293,7 +299,12 @@ export default {
console.log("APP.vue 存储数据失败", error); console.log("APP.vue 存储数据失败", error);
}, },
}); });
createFileWithPlusIO(SYNCHRONIZE_DATA_PAD, USER_FILE_NAME, fileContent); createFileWithPlusIO(SYNCHRONIZE_DATA_PAD, USER_FILE_NAME, fileContent).then(() => {
console.log("---用户数据更新成功")
}).catch(error => {
console.log("---用户数据更新失败", error)
})
}); });
}, },
}, },
......
...@@ -44,7 +44,7 @@ ...@@ -44,7 +44,7 @@
> >
<!-- 打包弹窗 --> <!-- 打包弹窗 -->
<Dialog v-if="isDialog && list.length" :list="list" @close="openDialog(false)"></Dialog> <Dialog v-show="isDialog && list.length" :list="list" @close="openDialog(false)"></Dialog>
</view> </view>
</template> </template>
...@@ -112,7 +112,7 @@ export default { ...@@ -112,7 +112,7 @@ export default {
const all_data = this.all_data || []; const all_data = this.all_data || [];
this.isPackedDataBtn = this.isPackedDataBtn =
all_data.filter((item) => item.synchronization == 0).length > 0; all_data.filter((item) => item.synchronization == 0).length > 0;
console.log("all_data", all_data); // console.log("all_data", all_data);
const tempAllData = {}; const tempAllData = {};
all_data.forEach((item) => { all_data.forEach((item) => {
...@@ -150,7 +150,7 @@ export default { ...@@ -150,7 +150,7 @@ export default {
}; };
}); });
console.log("list 数据----", list); // console.log("list 数据----", list);
this.countNum = 0; this.countNum = 0;
list.forEach((item) => { list.forEach((item) => {
this.countNum += item.list.length; this.countNum += item.list.length;
......
...@@ -65,7 +65,7 @@ export const addLog = (content) => { ...@@ -65,7 +65,7 @@ export const addLog = (content) => {
fileName, fileName,
fileContent fileContent
).then((res) => { ).then((res) => {
console.log("--日志文件-写入成功", content); // console.log("--日志文件-写入成功", content);
resolve(); resolve();
}); });
...@@ -159,7 +159,9 @@ export const writeInspectionData = (content, userName) => { ...@@ -159,7 +159,9 @@ export const writeInspectionData = (content, userName) => {
// const now_user = store.state.now_user; // const now_user = store.state.now_user;
let timeStr = moment().format("yyyy-MM-DD"); let timeStr = moment().format("yyyy-MM-DD");
let fileName = `${timeStr}.txt`; // let fileName = `${timeStr}.txt`;
let fileName = `list.txt`;
// console.log("写入-巡检数据--", content); // console.log("写入-巡检数据--", content);
// console.log( // console.log(
...@@ -189,7 +191,7 @@ export const readInspectionData = () => { ...@@ -189,7 +191,7 @@ export const readInspectionData = () => {
? `${SYNCHRONIZE_DATA_PAD}/巡检数据` ? `${SYNCHRONIZE_DATA_PAD}/巡检数据`
: `${SYNCHRONIZE_DATA_PAD}/巡检数据/${now_user.user}`; : `${SYNCHRONIZE_DATA_PAD}/巡检数据/${now_user.user}`;
console.log("---directoryPath", directoryPath); // console.log("---directoryPath", directoryPath);
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
readFilesInDirectory(directoryPath) readFilesInDirectory(directoryPath)
...@@ -231,7 +233,6 @@ export function copyDirectory(sourceDirectoryPath, targetDirectoryPath) { ...@@ -231,7 +233,6 @@ export function copyDirectory(sourceDirectoryPath, targetDirectoryPath) {
// 读取源目录中的所有文件和子目录 // 读取源目录中的所有文件和子目录
directoryReader.readEntries( directoryReader.readEntries(
function (entries) { function (entries) {
console.log("------entries.length-----", entries.length);
// 目标文件夹没有内容,直接返回 // 目标文件夹没有内容,直接返回
if (!entries.length) { if (!entries.length) {
return resolve(); return resolve();
...@@ -249,9 +250,8 @@ export function copyDirectory(sourceDirectoryPath, targetDirectoryPath) { ...@@ -249,9 +250,8 @@ export function copyDirectory(sourceDirectoryPath, targetDirectoryPath) {
entry.name, entry.name,
function () { function () {
++copyNum; ++copyNum;
console.log("文件复制成功:", entry.name);
if (copyNum == entries.length) { if (copyNum == entries.length) {
console.log("-copyNum--", copyNum); // console.log("-copyNum--", copyNum);
resolve(); resolve();
} }
}, },
...@@ -358,7 +358,6 @@ export function deleteAllFilesInDirectory(directoryPath) { ...@@ -358,7 +358,6 @@ export function deleteAllFilesInDirectory(directoryPath) {
entry.remove( entry.remove(
function () { function () {
++copyNum; ++copyNum;
console.log("文件删除成功:", entry.name);
if (copyNum == entries.length) { if (copyNum == entries.length) {
resolve(); resolve();
} }
......
// 时间倒序排列
export const sortTimeDesc = (a, b) => {
return a.creatTime < b.creatTime ? 1 : -1;
};
\ No newline at end of file
...@@ -354,10 +354,10 @@ export function createFileWithPlusIO(directoryPath, fileName, fileContent) { ...@@ -354,10 +354,10 @@ export function createFileWithPlusIO(directoryPath, fileName, fileContent) {
fileEntry.createWriter( fileEntry.createWriter(
function (fileWriter) { function (fileWriter) {
fileWriter.onwriteend = function () { fileWriter.onwriteend = function () {
console.log( // console.log(
"createFileWithPlusIO_文件创建并写入成功: " + // "createFileWithPlusIO_文件创建并写入成功: " +
fileEntry.fullPath // fileEntry.fullPath
); // );
resolve(fileContent); resolve(fileContent);
}; };
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论