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

edit

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