提交 d191c3fa authored 作者: zs's avatar zs

edit

上级 0892dbfe
...@@ -45,7 +45,7 @@ export default { ...@@ -45,7 +45,7 @@ export default {
,inspectionTime ,inspectionTime
,isException ,isException
,synFlag ,synFlag
,createTime,delFlag ,createTime,delFlag,inspectionData
FROM ${table.inspectionRecordName} FROM ${table.inspectionRecordName}
where 1=1 where 1=1
${data.inspectionType ? `AND inspectionType = '${data.inspectionType}'` : ''} ${data.inspectionType ? `AND inspectionType = '${data.inspectionType}'` : ''}
......
...@@ -13,7 +13,7 @@ export default { ...@@ -13,7 +13,7 @@ export default {
// app初始化 // app初始化
async init() { async init() {
const BASE_PATH = "_documents/data/asmzx/pad"; // 基础路径
// uni.showLoading({ // uni.showLoading({
// title: '正在初始化...', // title: '正在初始化...',
// }) // })
...@@ -25,7 +25,7 @@ export default { ...@@ -25,7 +25,7 @@ export default {
await this.initSqlLite(sqllitedb); // 确保表被创建 await this.initSqlLite(sqllitedb); // 确保表被创建
console.log('Tables created.'); console.log('Tables created.');
await ioUtil.createDir(BASE_PATH, '发送数据')
let isInit = await SqlliteDbUtil.checkIfDataImported(sqllitedb); // 确保表存在后再查询 let isInit = await SqlliteDbUtil.checkIfDataImported(sqllitedb); // 确保表存在后再查询
console.log('Data imported:', isInit); console.log('Data imported:', isInit);
if (!isInit) { if (!isInit) {
...@@ -94,20 +94,14 @@ export default { ...@@ -94,20 +94,14 @@ export default {
// 初始化目录 // 初始化目录
async initDir() { async initDir() {
try { try {
const _www = _Path.getPrivateWWW() const downloadEntry = await ioUtil.getFileEntry()
const _doc = _Path.getPrivateDOC()
const _download = _Path.getDownloads()
const _temp = _Path.getTempPath()
const wwwEntry = await ioUtil.getFileEntry(_www)
const docEntry = await ioUtil.getFileEntry(_doc)
const downloadEntry = await ioUtil.getFileEntry(_download)
if (downloadEntry) { if (downloadEntry) {
await ioUtil.createDir(downloadEntry.fullPath, 'base') await ioUtil.createDir(BASE_PATH, 'base')
await ioUtil.createDir(downloadEntry.fullPath, 'export') await ioUtil.createDir(BASE_PATH, 'export')
await ioUtil.createDir(downloadEntry.fullPath, 'import') await ioUtil.createDir(BASE_PATH, 'import')
await ioUtil.createDir(downloadEntry.fullPath, 'doc') await ioUtil.createDir(BASE_PATH, 'doc')
await ioUtil.createDir(downloadEntry.fullPath, 'error') await ioUtil.createDir(BASE_PATH, 'error')
} }
// 获取设备名称 // 获取设备名称
...@@ -118,7 +112,7 @@ export default { ...@@ -118,7 +112,7 @@ export default {
brand: e.deviceBrand, brand: e.deviceBrand,
deviceModel: e.deviceModel, deviceModel: e.deviceModel,
} }
const deviceFilePath = downloadEntry.fullPath + 'name.txt' const deviceFilePath = BASE_PATH + 'name.txt'
await ioUtil.removeExistFile(deviceFilePath) await ioUtil.removeExistFile(deviceFilePath)
await ioUtil.writeFile('name.txt', downloadEntry, JSON.stringify(deviceData)) await ioUtil.writeFile('name.txt', downloadEntry, JSON.stringify(deviceData))
}, },
......
...@@ -38,30 +38,40 @@ ...@@ -38,30 +38,40 @@
</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,
} from "@/utils/systemCofig"; zipCompress
import { findPhotosUrls } from "@/utils/index.js"; } from "@/utils/systemCofig";
import { copySelectedFiles } from "@/utils/plus.js"; import {
findPhotosUrls
import { } from "@/utils/index.js";
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 { getAllInspections } from "@/request/index.js"; import {
import { Base64 } from "js-base64"; getAllInspections
import inspectApi from "@/api/inspect"; } from "@/request/index.js";
export default { import {
Base64
} from "js-base64";
import inspectApi from "@/api/inspect";
import inspect from "@/api/inspect";
export default {
props: { props: {
list: { list: {
type: Array, type: Array,
...@@ -127,7 +137,7 @@ export default { ...@@ -127,7 +137,7 @@ export default {
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);
...@@ -142,14 +152,17 @@ export default { ...@@ -142,14 +152,17 @@ export default {
duration: 1000, duration: 1000,
}); });
}); });
}); // });
}, },
copyPhotos() { copyPhotos() {
this.list.forEach(e => {
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(
"_documents/data/photos", "_documents/data/photos",
`${SYNCHRONIZE_DATA_PAD}/发送数据/${this.userInfo.user}`, `${SYNCHRONIZE_DATA_PAD}/发送数据`,
urls urls
); );
}, },
...@@ -231,6 +244,12 @@ export default { ...@@ -231,6 +244,12 @@ export default {
duration: 2000, duration: 2000,
}); });
let ids = this.list.map((e) => e.id); let ids = this.list.map((e) => e.id);
// 复制照片
await this.copyPhotos();
await zipCompress(`${SYNCHRONIZE_DATA_PAD}/发送数据`,
`${SYNCHRONIZE_DATA_PAD}/fssj/${userName}_JFXJ_${timeStr}.zip`
);
// zip
await inspectApi.updateSyncData(ids); await inspectApi.updateSyncData(ids);
this.close(); this.close();
this.loading = false; this.loading = false;
...@@ -249,9 +268,7 @@ export default { ...@@ -249,9 +268,7 @@ export default {
// 更新同步时间 // 更新同步时间
this.updateSysTime(); this.updateSysTime();
// 复制照片
await this.copyPhotos();
// zip
}, 2 * 1000); }, 2 * 1000);
}) })
.catch((error) => { .catch((error) => {
...@@ -276,6 +293,8 @@ export default { ...@@ -276,6 +293,8 @@ export default {
}); });
}, },
// 使用示例
// 打包文件 // 打包文件
packedData(content, fileName) { packedData(content, fileName) {
// const fileContent = setSm2(content); // const fileContent = setSm2(content);
...@@ -326,10 +345,10 @@ export default { ...@@ -326,10 +345,10 @@ export default {
}); });
}, },
}, },
}; };
</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;
...@@ -340,18 +359,17 @@ export default { ...@@ -340,18 +359,17 @@ export default {
display: flex; display: flex;
align-items: center; align-items: center;
justify-content: center; justify-content: center;
.synchronous-content { .synchronous-content {
padding: 3% 20px 32px 24px; padding: 3% 20px 32px 24px;
width: 400px; width: 400px;
height: 60%; height: 60%;
box-sizing: border-box; box-sizing: border-box;
background-image: linear-gradient( background-image: linear-gradient(-6deg,
-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;
...@@ -370,9 +388,11 @@ export default { ...@@ -370,9 +388,11 @@ export default {
line-height: 26px; line-height: 26px;
font-weight: 500; font-weight: 500;
} }
.count-num { .count-num {
margin: 5% 0 5% 0; margin: 5% 0 5% 0;
align-items: flex-end; align-items: flex-end;
.num { .num {
display: inline-block; display: inline-block;
font-family: AlibabaPuHuiTi_2_65_Medium; font-family: AlibabaPuHuiTi_2_65_Medium;
...@@ -385,6 +405,7 @@ export default { ...@@ -385,6 +405,7 @@ export default {
.operating-instructions { .operating-instructions {
margin-bottom: 8%; margin-bottom: 8%;
.title { .title {
font-size: 13px; font-size: 13px;
color: #4a4a4a; color: #4a4a4a;
...@@ -392,6 +413,7 @@ export default { ...@@ -392,6 +413,7 @@ export default {
font-weight: 600; font-weight: 600;
text-align: left; text-align: left;
} }
.instructions-item { .instructions-item {
font-size: 12px; font-size: 12px;
color: #7c7c7c; color: #7c7c7c;
...@@ -426,10 +448,11 @@ export default { ...@@ -426,10 +448,11 @@ export default {
bottom: -40px; bottom: -40px;
left: 50%; left: 50%;
transform: translateX(-50%); transform: translateX(-50%);
.iconfont { .iconfont {
font-size: 24px; font-size: 24px;
} }
} }
} }
} }
</style> </style>
\ No newline at end of file
...@@ -471,25 +471,17 @@ export function getUserList() { ...@@ -471,25 +471,17 @@ export function getUserList() {
}); });
} }
export function zipCompress(name) { export function zipCompress(sourceDir, zipPath) {
const BASE_PATH = "_documents/data"; return new Promise((resolve, reject) => {
const targetPath = plus.io.convertLocalFileSystemURL(BASE_PATH + '/photos');
const zipfile = plus.io.convertLocalFileSystemURL(BASE_PATH + `/${name}.zip`);
plus.zip.compress( plus.zip.compress(
targetPath, plus.io.convertLocalFileSystemURL(sourceDir),
zipfile, { plus.io.convertLocalFileSystemURL(zipPath),
{
recursive: true, recursive: true,
overwrite: true overwrite: true,
},
function() {
plus.io.resolveLocalFileSystemURL(zipfile, function(zipEntry) {
zipEntry.file(function(file) {
console.log("ZIP 文件大小: " + file.size + " 字节");
});
});
}, },
function(error) { () => resolve(zipPath),
alert("压缩失败: " + error.message); (error) => reject(`压缩失败: ${error.message}`)
}
); );
});
} }
\ No newline at end of file
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论