提交 0b54e7bf authored 作者: caodi\cd's avatar caodi\cd

fix:打包

上级 de073eec
......@@ -21,7 +21,7 @@
</view>
</view>
<view class="img">
<image v-if="details.synchronization == 1" class="bg-img" src="../../static/img/add-img/default.png"></image>
<!-- <image v-if="details.synchronization == 1" class="bg-img" src="../../static/img/add-img/default.png"></image> -->
<!-- <image v-else class="bg-img" src="../../static/img/add-img/active.png"></image> -->
</view>
</view>
......
......@@ -112,14 +112,26 @@ export default {
// 生成签字图片
uni.canvasToTempFilePath({
canvasId: "signatureCanvas",
success: (res) => {
success: async (res) => {
const tempFilePath = res.tempFilePath;
// 存储照片到本地
uni.saveImageToPhotosAlbum({
filePath: tempFilePath,
success: function () {
console.log("图片已成功保存到相册");
},
fail: function (err) {
console.error("保存图片到相册失败:", err);
},
});
const base64 = await this.convertFileToBase64(tempFilePath);
// console.log("base64",base64)
// 这里可以将 tempFilePath 上传到服务器或进行其他处理
uni.showToast({
title: "签字已保存",
icon: "success",
});
this.$emit("confirm", tempFilePath);
this.$emit("confirm", base64);
this.close();
},
fail: (err) => {
......@@ -127,6 +139,32 @@ export default {
},
});
},
// 转化为base64
convertFileToBase64(filePath) {
return new Promise((resolve, reject) => {
plus.io.resolveLocalFileSystemURL(
filePath,
function (entry) {
entry.file(
function (file) {
const reader = new plus.io.FileReader();
reader.onloadend = function (evt) {
const base64 = evt.target.result; // 获取 Base64 数据
resolve(base64); // 返回 Base64 数据
};
reader.readAsDataURL(file); // 读取文件并转换为 Base64
},
function (error) {
reject("获取文件对象失败:" + error.message);
}
);
},
function (error) {
reject("解析文件路径失败:" + error.message);
}
);
});
},
open() {
this.isOpen = true;
},
......
......@@ -89,7 +89,7 @@ export default {
// 父组件传递的数据
defaultData: {
type: Object,
default: {},
default: () => ({}),
},
},
data() {
......@@ -156,11 +156,14 @@ export default {
return this.$store.state.now_user || {};
},
},
mounted() {
watch: {
defaultData(newVal) {
// 在这里处理数据变化
if (Object.keys(this.defaultData).length !== 0) {
this.itemData = this.defaultData;
}
},
},
methods: {
// 拍照
takePhoto(index) {
......@@ -228,7 +231,7 @@ export default {
// 处理】数据
getFromData() {
console.log(111, this.itemData);
const isValid = this.areAllObjectsValid(this.itemData.detail,2); //false不通过 true通过
const isValid = this.areAllObjectsValid(this.itemData.detail, 2); //false不通过 true通过
// const isAllOne = this.areAllInspectionResultsOne(this.itemData.detail);
this.itemData.isValid = isValid;
this.itemData.inspectionItem = this.inspectionItem;
......
......@@ -95,7 +95,7 @@ export default {
// 父组件传递的数据
defaultData: {
type: Object,
default: {},
default: () => ({}),
},
},
data() {
......@@ -153,10 +153,13 @@ export default {
return this.$store.state.now_user || {};
},
},
mounted() {
watch: {
defaultData(newVal) {
// 在这里处理数据变化
if (Object.keys(this.defaultData).length !== 0) {
this.itemData = this.defaultData;
}
}
},
methods: {
// 拍照
......
......@@ -77,9 +77,16 @@ export default {
default: "",
},
// 父组件传递的数据
itemData: {
defaultData: {
type: Object,
default: () => ({
default: () => ({}),
},
},
data() {
return {
currentIndex: 0, // 当前操作的索引
photos: [],
itemData: {
isValid: false, // false是校验未通过 true是校验通过
// status: 0, 0是未巡检 1是已巡检 2巡检异常 statusLabel: "未巡检",
inspectionItem: "", //巡检事项
......@@ -109,13 +116,7 @@ export default {
photos: [],
},
],
}),
},
},
data() {
return {
currentIndex: 0, // 当前操作的索引
photos: [],
};
},
computed: {
......@@ -123,7 +124,14 @@ export default {
return this.$store.state.now_user || {};
},
},
mounted() {},
watch: {
defaultData(newVal) {
// 在这里处理数据变化
if (Object.keys(this.defaultData).length !== 0) {
this.itemData = this.defaultData;
}
},
},
methods: {
// 拍照
takePhoto(index) {
......
......@@ -89,7 +89,7 @@ export default {
// 父组件传递的数据
defaultData: {
type: Object,
default: {},
default: () => ({}),
},
},
data() {
......@@ -134,10 +134,13 @@ export default {
return this.$store.state.now_user || {};
},
},
mounted() {
watch: {
defaultData(newVal) {
// 在这里处理数据变化
if (Object.keys(this.defaultData).length !== 0) {
this.itemData = this.defaultData;
}
}
},
methods: {
// 拍照
......
......@@ -58,9 +58,17 @@ export default {
default: "",
},
// 父组件传递的数据
itemData: {
defaultData: {
type: Object,
default: () => ({
default: () => ({}),
},
},
data() {
return {
currentIndex: 0, // 当前操作的索引
photos: [],
// 父组件传递的数据
itemData: {
isValid: true, // true是不校验
// status: 0, 0是未巡检 1是已巡检 2巡检异常 statusLabel: "未巡检",
inspectionItem: "", //巡检事项
......@@ -74,13 +82,7 @@ export default {
photos: [],
},
],
}),
},
},
data() {
return {
currentIndex: 0, // 当前操作的索引
photos: [],
};
},
computed: {
......@@ -88,6 +90,14 @@ export default {
return this.$store.state.now_user || {};
},
},
watch: {
defaultData(newVal) {
// 在这里处理数据变化
if (Object.keys(this.defaultData).length !== 0) {
this.itemData = this.defaultData;
}
}
},
mounted() {},
methods: {
// 拍照
......
......@@ -43,7 +43,9 @@
type="number"
placeholder="请输入"
maxlength="2"
/> <text class="fg"></text><input
/>
<text class="fg"></text
><input
class="input"
v-model="item.UpositonE"
type="number"
......@@ -115,7 +117,7 @@ export default {
// 父组件传递的数据
defaultData: {
type: Object,
default: {},
default: () => ({}),
},
},
data() {
......@@ -149,11 +151,14 @@ export default {
return this.$store.state.now_user || {};
},
},
mounted() {
watch: {
defaultData(newVal) {
// 在这里处理数据变化
if (Object.keys(this.defaultData).length !== 0) {
this.itemData = this.defaultData;
}
},
},
methods: {
// 拍照
takePhoto(index) {
......
......@@ -77,9 +77,16 @@ export default {
default: "",
},
// 父组件传递的数据
itemData: {
defaultData: {
type: Object,
default: () => ({
default: () => ({}),
},
},
data() {
return {
currentIndex: 0, // 当前操作的索引
photos: [],
itemData: {
isValid: false, // false是校验未通过 true是校验通过
// status: 0, 0是未巡检 1是已巡检 2巡检异常 statusLabel: "未巡检",
inspectionItem: "", //巡检事项
......@@ -115,13 +122,7 @@ export default {
photos: [],
},
],
}),
},
},
data() {
return {
currentIndex: 0, // 当前操作的索引
photos: [],
};
},
computed: {
......@@ -129,7 +130,20 @@ export default {
return this.$store.state.now_user || {};
},
},
mounted() {},
watch: {
defaultData(newVal) {
// 在这里处理数据变化
if (Object.keys(this.defaultData).length !== 0) {
this.itemData = this.defaultData;
}
}
},
async mounted() {
console.log("sdsadasd", this.itemData);
// if (Object.keys(this.defaultData).length !== 0) {
// this.itemData = this.defaultData;
// }
},
methods: {
// 拍照
takePhoto(index) {
......@@ -207,7 +221,7 @@ export default {
// this.itemData.status = 2; //1表示已经巡检过有异常
// this.itemData.statusLabel = "巡检异常";
// }
// console.log(this.itemData);
console.log("查看数据", this.itemData);
return this.itemData;
},
// 数据校验方法 true说明有未填项
......
......@@ -89,7 +89,7 @@ export default {
// 父组件传递的数据
defaultData: {
type: Object,
default: {},
default: () => ({}),
},
},
data() {
......@@ -138,10 +138,13 @@ export default {
return this.$store.state.now_user || {};
},
},
mounted() {
watch: {
defaultData(newVal) {
// 在这里处理数据变化
if (Object.keys(this.defaultData).length !== 0) {
this.itemData = this.defaultData;
}
}
},
methods: {
// 拍照
......
......@@ -77,9 +77,16 @@ export default {
default: "",
},
// 父组件传递的数据
itemData: {
defaultData: {
type: Object,
default: () => ({
default: () => ({}),
},
},
data() {
return {
currentIndex: 0, // 当前操作的索引
photos: [],
itemData: {
isValid: false, // false是校验未通过 true是校验通过
// status: 0, 0是未巡检 1是已巡检 2巡检异常 statusLabel: "未巡检",
inspectionItem: "", //巡检事项
......@@ -109,13 +116,7 @@ export default {
photos: [],
},
],
}),
},
},
data() {
return {
currentIndex: 0, // 当前操作的索引
photos: [],
};
},
computed: {
......@@ -123,6 +124,14 @@ export default {
return this.$store.state.now_user || {};
},
},
watch: {
defaultData(newVal) {
// 在这里处理数据变化
if (Object.keys(this.defaultData).length !== 0) {
this.itemData = this.defaultData;
}
}
},
mounted() {},
methods: {
// 拍照
......
......@@ -33,7 +33,7 @@
>
</view>
</view>
<view v-if="isSubmit" class="profile-right">
<view v-if="inspectionNumber >1" class="profile-right">
<button v-if="!isSign" class="record-button" @click="toSign">
巡检人签字
</button>
......@@ -91,13 +91,18 @@
</view>
</view></view
>
<signDialog ref="signDialog" @confirm="handlePopupConfirm"></signDialog>
</view>
</template>
<script>
import moment from "moment";
import { pad_all_inspection_position } from "@/utils/dict.js";
import { getInspectionDetails } from "@/request/index.js";
import signDialog from "@/components/signDialog.vue";
export default {
components: {
signDialog,
},
data() {
return {
inspectionCode: "",
......
......@@ -58,7 +58,7 @@
v-show="checkValueInArray(tabs, 'wlhj', activeTab)"
ref="wlhj"
:inspectionItem="tabs[activeTab].label"
:defaultData="list.wlhj || {}"
:defaultData="list.wlhj"
></wlhj>
<!-- 安防系统 -->
<afxt
......@@ -268,14 +268,9 @@ export default {
.then((res) => {
const detailsInfo = res;
console.log("getDetails", res);
let list = detailsInfo.originData[this.value - 1].details;
console.log("list", list);
// 未巡检需要处理默认数据结构
if (list && list.length) {
this.list = list;
}
this.list = detailsInfo.originData[this.value - 1].details;
console.log("list", this.list);
// this.inspectionResult = list[0].inspectionResult;
console.log("let list", list);
this.detailsInfo = detailsInfo;
console.log("detailsInfo", detailsInfo);
......@@ -305,6 +300,7 @@ export default {
if (this.uid) {
let posItem = this.detailsInfo.originData[this.value - 1];
let paramsObj = this.getAllChildFormData(); //获取所有数据
console.log("获取数据",paramsObj)
posItem.details = paramsObj;
posItem.isSubmit = isSubmit;
if (!this.checkInspectionResult(paramsObj)) {
......@@ -314,10 +310,17 @@ export default {
posItem.status = 2; //1表示已经巡检过有异常
posItem.statusLable = "巡检异常";
}
// 使用 filter 方法筛选出 status 为 1 或 2 的对象
const inspectedItems = this.detailsInfo.originData.filter(
(item) => item.status === 1 || item.status === 2
);
// 获取已经巡检过的数量
this.detailsInfo.inspectionNumber = inspectedItems.length;
// let { notZeroCount, equalTwoCount } = this.count(
// this.detailsInfo.originData
// );
// this.detailsInfo.inspectionNumber = notZeroCount; //巡检总数
// this.detailsInfo.status = notZeroCount; //巡检总数
// this.detailsInfo.isException = equalTwoCount; //异常数量
console.log("this.detailsInfo", this.detailsInfo);
this.detailsInfo.submitTime = moment().format("yyyy-MM-DD"); // 记录提交时间
......@@ -339,7 +342,7 @@ export default {
};
});
let tabList = JSON.parse(JSON.stringify(dataObj));
let posItem = tabList[this.value];
let posItem = tabList[this.value-1];
posItem.details = paramsObj;
if (!this.checkInspectionResult(paramsObj)) {
posItem.status = 1; //1表示已经巡检过没有异常
......@@ -421,6 +424,7 @@ export default {
return false;
}
const params = this.getParams(isSubmit); //数据获取
console.log("提交时获取一次",params)
const all_data = this.$store.state.all_data; //获取全部数据
let logContent = "";
console.log("all_data", all_data);
......
......@@ -77,31 +77,43 @@ export default {
};
},
mounted() {
watch: {
list(newVal) {
console.log("newVal",newVal);
this.init()
},
},
// async mounted() {
// const temp = [];
// this.list.forEach((item) => {
// temp.push(...(item.list || []));
// });
// console.log("this.list", this.list);
// console.log("temp", temp);
// this.notSynchronizationList = temp.filter(
// (item) => item.synchronization == 0 && item.isSign === true
// );
// getAllInspections().then((res) => {
// this.allList = res;
// });
// },
methods: {
init() {
const temp = [];
this.list.forEach((item) => {
temp.push(...(item.list || []));
});
console.log("this.list", this.list);
console.log("temp", temp);
this.notSynchronizationList = temp.filter(
(item) => item.synchronization == 0
(item) => item.synchronization == 0 && item.isSign === true
);
getAllInspections().then((res) => {
this.allList = res;
});
},
watch: {
list(newData) {
const temp = [];
newData.forEach((item) => {
temp.push(...(item.list || []));
});
this.notSynchronizationList = temp.filter(
(item) => item.synchronization == 0
);
},
},
methods: {
close() {
this.$emit("close");
},
......@@ -113,18 +125,16 @@ export default {
* 读取上一次打包的文件, 复制到 [ history ] 文件夹中
*/
clickHandle() {
if(this.loading) return;
if (this.loading) return;
const directoryPath = `${SYNCHRONIZE_DATA_PAD}/发送数据`;
const targetDirectoryPath = `${SYNCHRONIZE_DATA_PAD}/history`;
checkAndCreateDirectory(directoryPath).then(() => {
copyDirectory(directoryPath, targetDirectoryPath)
.then(() => {
return deleteAllFilesInDirectory(directoryPath);
})
.then(() => {
this.coverData();
})
.catch((error) => {
......@@ -141,25 +151,26 @@ export default {
const userName = this.$store.state.now_user.user;
const notSynchronizationList = this.notSynchronizationList;
const allList = this.allList;
console.log("窗口allList", allList);
console.log(
"窗口this.notSynchronizationList",
this.notSynchronizationList
);
let timeStr = moment().format("yyyy_MM_DD_hh_mm_ss");
const JFXJ_DATA = notSynchronizationList
.filter((item) => item.inspectionType == 1)
.map((item) => {
return {
...item,
originData: [],
};
return item;
}); // 机房数据类型是 1
const JDXJ_DATA = notSynchronizationList
.filter((item) => item.inspectionType == 2)
.map((item) => {
return item[item.inspectionCode];
return item;
}); // 井道数据类型是 2
console.log(5151, JFXJ_DATA, JDXJ_DATA);
this.loading = true;
const tmepList = [];
......@@ -174,6 +185,8 @@ export default {
tmepList.push(this.packedData(item, JDXJ_DATA_FILE_NAME));
});
console.log("同步窗口");
console.log("同步窗口", tmepList);
Promise.all(tmepList)
.then(() => {
// 更新巡检数据状态
......@@ -223,8 +236,7 @@ export default {
const log_list = this.$store.state.log_list;
log_list.push(logContent);
this.$store.commit("SET_LOG_LIST", log_list);
addLog(log_list).then((res) => {
});
addLog(log_list).then((res) => {});
// 更新同步时间
this.updateSysTime();
......@@ -290,12 +302,13 @@ export default {
console.log("APP.vue 存储数据失败", error);
},
});
createFileWithPlusIO(SYNCHRONIZE_DATA_PAD, USER_FILE_NAME, fileContent).then(() => {
console.log("---用户数据更新成功")
}).catch(error => {
console.log("---用户数据更新失败", error)
createFileWithPlusIO(SYNCHRONIZE_DATA_PAD, USER_FILE_NAME, fileContent)
.then(() => {
console.log("---用户数据更新成功");
})
.catch((error) => {
console.log("---用户数据更新失败", error);
});
});
},
},
......
......@@ -59,7 +59,7 @@
><!-- 打包弹窗 -->
<Dialog
v-show="isDialog && list.length"
:list="list"
:listArr="list"
@close="openDialog(false)"
></Dialog>
</view>
......@@ -168,7 +168,6 @@ export default {
}
});
const keys = Object.keys(tempAllData);
// 第二步: 根据搜索条件过滤
const list = keys.map((key) => {
return {
......
......@@ -35,6 +35,7 @@
>
</view>
</view>
<!-- {{ isSubmit }} {{ isSign }} -->
<view v-if="isSubmit" class="profile-right">
<button v-if="!isSign" class="record-button" @click="toSign">
巡检人签字
......@@ -283,13 +284,13 @@ export default {
let params = this.detailsInfo;
params.signImg = value;
console.log("all_data", all_data);
console.log("all_data", all_data);
const index = all_data.findIndex((element) => element.uid == this.uid);
console.log("签字获取数据",params)
all_data[index] = params;
const logContent = getLogContent(LOG_TYPE_ENUM.sys, "数据同步", "同步");
const logContent = getLogContent(LOG_TYPE_ENUM.sign, "签字", "机房巡检");
// 更新巡检list
console.log("all_data存储", all_data);
console.log("all_data一个", all_data[index]);
this.$store.commit("SET_ALL_DATA", all_data);
const inspectList = all_data.filter(
(item) => item.createByName == userInfo.user
......
......@@ -533,7 +533,7 @@ export default {
});
// 清空基础缓存信息
this.$store.commit("SET_TEMP_DATA", {}); // 缓存[巡检信息]
// this.$store.commit("SET_TEMP_DATA", {}); // 缓存[巡检信息]
uni.showToast({
title: isSubmit ? "提交成功" : "保存草稿成功",
icon: "success",
......
......@@ -25,6 +25,7 @@ export const LOG_TYPE_ENUM = {
add: "新增成功",
photo: "拍照",
edit: "编辑成功",
sign: "签字",
darf: "草稿",
delete: "删除",
sys: "同步",
......
......@@ -120,6 +120,7 @@ export function checkAndCreateDirectory(directoryPath) {
);
resolve(dirEntry);
return
},
function (error) {
// 目录不存在,创建目录
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论