提交 d8641917 authored 作者: JaxBBLL's avatar JaxBBLL

fix

上级 6909d900
...@@ -38,40 +38,32 @@ ...@@ -38,40 +38,32 @@
</template> </template>
<script> <script>
import { import {
SYNCHRONIZE_DATA_PAD, SYNCHRONIZE_DATA_PAD,
checkAndCreateDirectory, checkAndCreateDirectory,
createFileWithPlusIO, createFileWithPlusIO,
setSm2, setSm2,
USER_FILE_NAME, USER_FILE_NAME,
getUserList, getUserList,
zipCompress zipCompress,
} from "@/utils/systemCofig"; } from "@/utils/systemCofig";
import { import { findPhotosUrls } from "@/utils/index.js";
findPhotosUrls import { copySelectedFiles } from "@/utils/plus.js";
} from "@/utils/index.js";
import { import {
copySelectedFiles
} from "@/utils/plus.js";
import {
writeInspectionData, writeInspectionData,
copyDirectory, copyDirectory,
deleteAllFilesInDirectory, deleteAllFilesInDirectory,
addLog, addLog,
getLogContent, getLogContent,
LOG_TYPE_ENUM, LOG_TYPE_ENUM,
} from "@/utils/IoReadingAndWriting.js"; } from "@/utils/IoReadingAndWriting.js";
import moment from "moment"; import moment from "moment";
import { import { getAllInspections } from "@/request/index.js";
getAllInspections import { Base64 } from "js-base64";
} from "@/request/index.js"; import inspectApi from "@/api/inspect";
import { import inspect from "@/api/inspect";
Base64 export default {
} from "js-base64";
import inspectApi from "@/api/inspect";
import inspect from "@/api/inspect";
export default {
props: { props: {
list: { list: {
type: Array, type: Array,
...@@ -155,9 +147,11 @@ ...@@ -155,9 +147,11 @@
// }); // });
}, },
copyPhotos() { copyPhotos() {
this.list.forEach(e => { this.list.forEach((e) => {
e.inspectionData = JSON.parse(e.inspectionData) || '{}' if (typeof e.inspectionData === "string") {
}) e.inspectionData = JSON.parse(e.inspectionData) || "{}";
}
});
const urls = findPhotosUrls(this.list).map((url) => url.split("/").pop()); const urls = findPhotosUrls(this.list).map((url) => url.split("/").pop());
console.log("urls", urls); console.log("urls", urls);
return copySelectedFiles( return copySelectedFiles(
...@@ -200,10 +194,10 @@ ...@@ -200,10 +194,10 @@
tmepList.push(this.packedData(JFXJ_DATA, JFXJ_DATA_FILE_NAME)); tmepList.push(this.packedData(JFXJ_DATA, JFXJ_DATA_FILE_NAME));
} }
JDXJ_DATA.forEach((item, index) => { if (JDXJ_DATA.length) {
let JDXJ_DATA_FILE_NAME = `${userName}_JDXJ_${timeStr}_${index}.txt`; let JDXJ_DATA_FILE_NAME = `${userName}_JDXJ_${timeStr}.txt`;
tmepList.push(this.packedData(item, JDXJ_DATA_FILE_NAME)); tmepList.push(this.packedData(JDXJ_DATA, JDXJ_DATA_FILE_NAME));
}); }
console.log("同步窗口"); console.log("同步窗口");
console.log("同步窗口", tmepList); console.log("同步窗口", tmepList);
...@@ -246,7 +240,8 @@ ...@@ -246,7 +240,8 @@
let ids = this.list.map((e) => e.id); let ids = this.list.map((e) => e.id);
// 复制照片 // 复制照片
await this.copyPhotos(); await this.copyPhotos();
zipCompress(`${SYNCHRONIZE_DATA_PAD}/发送数据`, zipCompress(
`${SYNCHRONIZE_DATA_PAD}/发送数据`,
`${SYNCHRONIZE_DATA_PAD}/fssj/${userName}_JFXJ_${timeStr}.zip` `${SYNCHRONIZE_DATA_PAD}/fssj/${userName}_JFXJ_${timeStr}.zip`
); );
// zip // zip
...@@ -267,8 +262,6 @@ ...@@ -267,8 +262,6 @@
// 更新同步时间 // 更新同步时间
this.updateSysTime(); this.updateSysTime();
}, 2 * 1000); }, 2 * 1000);
}) })
.catch((error) => { .catch((error) => {
...@@ -293,7 +286,6 @@ ...@@ -293,7 +286,6 @@
}); });
}, },
// 使用示例 // 使用示例
// 打包文件 // 打包文件
packedData(content, fileName) { packedData(content, fileName) {
...@@ -345,10 +337,10 @@ ...@@ -345,10 +337,10 @@
}); });
}, },
}, },
}; };
</script> </script>
<style scoped lang="less"> <style scoped lang="less">
.synchronous-dialog { .synchronous-dialog {
position: fixed; position: fixed;
z-index: 999; z-index: 999;
top: 0; top: 0;
...@@ -365,11 +357,13 @@ ...@@ -365,11 +357,13 @@
width: 400px; width: 400px;
height: 60%; height: 60%;
box-sizing: border-box; box-sizing: border-box;
background-image: linear-gradient(-6deg, background-image: linear-gradient(
-6deg,
#f9ffe7 0%, #f9ffe7 0%,
#ffffff 12%, #ffffff 12%,
#fcfeff 73%, #fcfeff 73%,
#ccf1ff 100%); #ccf1ff 100%
);
border: 0.4px solid rgba(224, 224, 224, 1); border: 0.4px solid rgba(224, 224, 224, 1);
border-radius: 12px; border-radius: 12px;
position: relative; position: relative;
...@@ -454,5 +448,5 @@ ...@@ -454,5 +448,5 @@
} }
} }
} }
} }
</style> </style>
...@@ -113,18 +113,16 @@ export default { ...@@ -113,18 +113,16 @@ export default {
* 读取上一次打包的文件, 复制到 [ history ] 文件夹中 * 读取上一次打包的文件, 复制到 [ history ] 文件夹中
*/ */
clickHandle() { clickHandle() {
if(this.loading) return; if (this.loading) return;
const directoryPath = `${SYNCHRONIZE_DATA_PAD}/发送数据`; const directoryPath = `${SYNCHRONIZE_DATA_PAD}/发送数据`;
const targetDirectoryPath = `${SYNCHRONIZE_DATA_PAD}/history`; const targetDirectoryPath = `${SYNCHRONIZE_DATA_PAD}/history`;
checkAndCreateDirectory(directoryPath).then(() => { checkAndCreateDirectory(directoryPath).then(() => {
copyDirectory(directoryPath, targetDirectoryPath) copyDirectory(directoryPath, targetDirectoryPath)
.then(() => { .then(() => {
return deleteAllFilesInDirectory(directoryPath); return deleteAllFilesInDirectory(directoryPath);
}) })
.then(() => { .then(() => {
this.coverData(); this.coverData();
}) })
.catch((error) => { .catch((error) => {
...@@ -142,7 +140,6 @@ export default { ...@@ -142,7 +140,6 @@ export default {
const notSynchronizationList = this.notSynchronizationList; const notSynchronizationList = this.notSynchronizationList;
const allList = this.allList; const allList = this.allList;
let timeStr = moment().format("yyyy_MM_DD_hh_mm_ss"); let timeStr = moment().format("yyyy_MM_DD_hh_mm_ss");
const JFXJ_DATA = notSynchronizationList const JFXJ_DATA = notSynchronizationList
...@@ -160,19 +157,17 @@ export default { ...@@ -160,19 +157,17 @@ export default {
return item[item.inspectionCode]; return item[item.inspectionCode];
}); // 井道数据类型是 2 }); // 井道数据类型是 2
this.loading = true; this.loading = true;
const tmepList = []; const tmepList = [];
if (JFXJ_DATA.length) { if (JFXJ_DATA.length) {
let JFXJ_DATA_FILE_NAME = `${userName}_JFXJ_${timeStr}.txt`; let JFXJ_DATA_FILE_NAME = `${userName}_JFXJ_${timeStr}.txt`;
tmepList.push(this.packedData(JFXJ_DATA, JFXJ_DATA_FILE_NAME)); tmepList.push(this.packedData(JDXJ_DATA, JFXJ_DATA_FILE_NAME));
}
if (JDXJ_DATA.length) {
let JDXJ_DATA_FILE_NAME = `${userName}_JDXJ_${timeStr}.txt`;
tmepList.push(this.packedData(JDXJ_DATA, JDXJ_DATA_FILE_NAME));
} }
JDXJ_DATA.forEach((item, index) => {
let JDXJ_DATA_FILE_NAME = `${userName}_JDXJ_${timeStr}_${index}.txt`;
tmepList.push(this.packedData(item, JDXJ_DATA_FILE_NAME));
});
Promise.all(tmepList) Promise.all(tmepList)
.then(() => { .then(() => {
...@@ -223,8 +218,7 @@ export default { ...@@ -223,8 +218,7 @@ export default {
const log_list = this.$store.state.log_list; const log_list = this.$store.state.log_list;
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) => {});
});
// 更新同步时间 // 更新同步时间
this.updateSysTime(); this.updateSysTime();
...@@ -290,12 +284,13 @@ export default { ...@@ -290,12 +284,13 @@ export default {
console.log("APP.vue 存储数据失败", error); console.log("APP.vue 存储数据失败", error);
}, },
}); });
createFileWithPlusIO(SYNCHRONIZE_DATA_PAD, USER_FILE_NAME, fileContent).then(() => { createFileWithPlusIO(SYNCHRONIZE_DATA_PAD, USER_FILE_NAME, fileContent)
console.log("---用户数据更新成功") .then(() => {
}).catch(error => { console.log("---用户数据更新成功");
console.log("---用户数据更新失败", error)
}) })
.catch((error) => {
console.log("---用户数据更新失败", error);
});
}); });
}, },
}, },
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论