提交 78d515f5 authored 作者: caodi\cd's avatar caodi\cd

提交

上级 a8e03645
...@@ -24,7 +24,7 @@ ...@@ -24,7 +24,7 @@
<!-- 关闭按钮 --> <!-- 关闭按钮 -->
<div class="close-button"> <div class="close-button">
<text class="iconfont icon-a-bianzu16beifen" @click="close"></text> <text class="iconfont icon-shibai1" @click="close"></text>
</div> </div>
</view> </view>
</view> </view>
......
<template>
<view v-if="isOpen" class="synchronous-dialog">
<view class="synchronous-content">
<view class="title">巡检指引</view>
<view class="operating-instructions">
<view
v-for="(item, index) in startDialogData.text"
:key="index"
class="text"
>{{ item }}</view
>
</view><view class="row-item bottom-row">
<view v-if="!startDialogData.isList" class="button btn" @click="clearSignature">返回巡检列表</view>
<view class="button" @click="confirmSignature">我已到达</view>
</view>
<!-- 关闭按钮 -->
<div class="close-button">
<text class="iconfont icon-shibai1" @click="close"></text>
</div>
</view>
</view>
</template>
<script>
export default {
components: {},
props: {
startDialogData: {
type: Object,
default: "",
},
},
data() {
return {
isOpen: false,
};
},
mounted() {},
methods: {
confirmSignature() {
this.$emit("confirm", "");
},
open() {
this.isOpen = true;
},
// 关闭弹窗
close() {
this.isOpen = false;
},
},
};
</script>
<style scoped lang="less">
.synchronous-dialog {
position: fixed;
top: 0;
left: 0;
width: 100%;
height: 100%;
background: rgba(0, 0, 0, 0.5);
display: flex;
align-items: center;
justify-content: center;
text-align: center;
.synchronous-content {
padding: 25.6px 19.2px;
width: 420px;
height: 214px;
box-sizing: border-box;
background-image: linear-gradient(
-6deg,
#f9ffe7 0%,
#ffffff 12%,
#fcfeff 73%,
#ccf1ff 100%
);
border: 0.4px solid rgba(224, 224, 224, 1);
border-radius: 12px;
position: relative;
.row-item {
display: flex;
align-items: center;
justify-content: center;
}
.title {
font-size: 18px;
color: #000000;
line-height: 26px;
font-weight: 500;
margin-bottom: 12px;
}
.operating-instructions {
.text {
font-size: 16px;
color: #000000;
text-align: center;
line-height: 24px;
font-weight: 400;
}
margin-bottom: 24px;
}
// 打包按钮
.bottom-row {
position: absolute;
bottom: 25.6px;
left: 50%;
transform: translateX(-50%);
.button {
display: flex;
align-items: center;
justify-content: center;
background-image: linear-gradient(180deg, #3773f6 0%, #2c57f6 99%);
box-shadow: 0px 10px 24px 0px rgba(51, 104, 246, 0.24);
border-radius: 27px;
width: 160px;
height: 32px;
color: #fff;
margin: 0 5px;
&.btn {
background: #ffffff;
color: #000000;
}
}
}
// 关闭按钮
.close-button {
position: absolute;
bottom: -40px;
left: 50%;
transform: translateX(-50%);
.iconfont {
color: #fff;
font-size: 24px;
}
}
}
}
</style>
...@@ -64,7 +64,7 @@ ...@@ -64,7 +64,7 @@
class="card-wrapper" class="card-wrapper"
v-for="(card, cardIndex) in row" v-for="(card, cardIndex) in row"
:key="cardIndex" :key="cardIndex"
@click="toShaftInspection(card.name, card.jfType, card.value)" @click="startDialog(card.name, card.jfType, card.value, false)"
> >
<view <view
class="card" class="card"
...@@ -159,7 +159,16 @@ ...@@ -159,7 +159,16 @@
</view> </view>
<detail ref="detail" :jfType="jfType" :detailsItem="detailsItem"></detail <detail ref="detail" :jfType="jfType" :detailsItem="detailsItem"></detail
></view> ></view>
<view class="submit-module">
<view class="action-btn" @click="startDialogBtn()">开始巡检</view>
</view>
<signDialog ref="signDialog" @confirm="handlePopupConfirm"></signDialog> <signDialog ref="signDialog" @confirm="handlePopupConfirm"></signDialog>
<!-- 巡检弹窗 -->
<startDialog
ref="startDialog"
:startDialogData="startDialogData"
@confirm="handleStartDialog"
></startDialog>
</view> </view>
</template> </template>
<script> <script>
...@@ -174,10 +183,12 @@ import { ...@@ -174,10 +183,12 @@ import {
import { getInspectionDetails } from "@/request/index.js"; import { getInspectionDetails } from "@/request/index.js";
import signDialog from "@/components/signDialog.vue"; import signDialog from "@/components/signDialog.vue";
import detail from "./components/detail.vue"; import detail from "./components/detail.vue";
import startDialog from "./components/dialog.vue";
export default { export default {
components: { components: {
signDialog, signDialog,
detail, detail,
startDialog,
}, },
data() { data() {
return { return {
...@@ -196,7 +207,15 @@ export default { ...@@ -196,7 +207,15 @@ export default {
all_data: [], //所有数据 all_data: [], //所有数据
jfType: "0", //机房类型 jfType: "0", //机房类型
allIsSubmitOne: false, allIsSubmitOne: false,
activeName: "F座3楼-内环屏蔽机房", startDialogData: {
text: [],
isList: true,
isLast: false,
}, //弹窗文案
name: "F座3楼-内环屏蔽机房",
jfType: "0",
value: "1",
listData: [],
}; };
}, },
computed: { computed: {
...@@ -217,6 +236,11 @@ export default { ...@@ -217,6 +236,11 @@ export default {
} else { } else {
this.init(); this.init();
} }
// this.startDialogData.text = [
// `请到“${this.name}”后;`,
// "点击“我已到达”开始巡检",
// ];
console.log("this.startDialogData", this.startDialogData);
this.all_data = this.$store.state.all_data; this.all_data = this.$store.state.all_data;
console.log("onShow", this.all_data); console.log("onShow", this.all_data);
}, },
...@@ -233,8 +257,10 @@ export default { ...@@ -233,8 +257,10 @@ export default {
statusLable: item.statusLable, statusLable: item.statusLable,
}; };
}); });
this.listData = this.deepClone(list);
console.log("查看this.listData", this.listData);
const group1 = list.slice(0, 5); const group1 = list.slice(0, 5);
const group2 = list.slice(5, 10); const group2 = list.slice(5, 10).reverse();
const group3 = list.slice(10); const group3 = list.slice(10);
this.rows = [group1, group2, group3]; this.rows = [group1, group2, group3];
this.inspectionCode = `JFXJ${moment().format("yyyyMMDDHHmmss")}${ this.inspectionCode = `JFXJ${moment().format("yyyyMMDDHHmmss")}${
...@@ -256,6 +282,28 @@ export default { ...@@ -256,6 +282,28 @@ export default {
resolve(); resolve();
}); });
}, },
deepClone(target) {
if (typeof target !== "object" || target === null) {
return target;
}
let clone;
if (Array.isArray(target)) {
clone = [];
for (let i = 0; i < target.length; i++) {
clone[i] = this.deepClone(target[i]);
}
} else {
clone = {};
for (const key in target) {
if (target.hasOwnProperty(key)) {
clone[key] = this.deepClone(target[key]);
}
}
}
return clone;
},
// 回显数据 // 回显数据
getDetails(uid) { getDetails(uid) {
uni.showLoading(); uni.showLoading();
...@@ -263,6 +311,8 @@ export default { ...@@ -263,6 +311,8 @@ export default {
.then((res) => { .then((res) => {
const detailsInfo = res; const detailsInfo = res;
console.log("detailsInfo", detailsInfo); console.log("detailsInfo", detailsInfo);
this.listData = this.deepClone(detailsInfo.originData);
console.log("详情this.listData", this.listData);
this.detailsInfo = detailsInfo; this.detailsInfo = detailsInfo;
this.inspectionNumber = detailsInfo.inspectionNumber; this.inspectionNumber = detailsInfo.inspectionNumber;
...@@ -283,8 +333,8 @@ export default { ...@@ -283,8 +333,8 @@ export default {
let group1 = this.cardsInfo.slice(0, 5); let group1 = this.cardsInfo.slice(0, 5);
let group2 = this.cardsInfo.slice(5, 10); let group2 = this.cardsInfo.slice(5, 10);
let group3 = this.cardsInfo.slice(10); let group3 = this.cardsInfo.slice(10);
if(this.isSign) { if (!this.isSign) {
group2 = group2.reverse() group2 = group2.reverse();
} }
this.rows = [group1, group2, group3]; this.rows = [group1, group2, group3];
console.log("this.cardsInfo", this.cardsInfo); console.log("this.cardsInfo", this.cardsInfo);
...@@ -311,10 +361,47 @@ export default { ...@@ -311,10 +361,47 @@ export default {
} }
console.log("this.detailsItem", this.detailsItem); console.log("this.detailsItem", this.detailsItem);
}, },
startDialogBtn(name = "F座3楼-内环屏蔽机房", jfType = "0", value = "1") {
let item = this.findTargetObject(this.listData);
console.log("即将操作的机房", item);
this.name = this.uid ? item.name : name;
this.jfType = this.uid ? item.jfType : jfType;
this.value = this.uid ? item.value : value;
this.startDialogData.text = [
`请到“${name}”后;`,
"点击“我已到达”开始巡检",
];
this.name = name;
this.jfType = jfType;
this.value = value;
this.$refs.startDialog.open();
},
startDialog(name = "F座3楼-内环屏蔽机房", jfType = "0", value = "1") {
this.name = name;
this.jfType = jfType;
this.value = value;
if (!this.uid && value != "1") {
this.startDialogData.text = [
`当前线路非常用巡检线路,`,
`是否需要从“${this.name}”开始巡检`,
];
} else {
this.startDialogData.text = [
`请到“${this.name}”后;`,
"点击“我已到达”开始巡检",
];
}
this.$refs.startDialog.open();
},
// 处理弹窗确认
handleStartDialog(summary) {
this.toShaftInspection(this.name, this.jfType, this.value);
},
// 跳转到具体的机房 // 跳转到具体的机房
toShaftInspection(location, jfType, value) { toShaftInspection(name, jfType, value) {
uni.navigateTo({ uni.navigateTo({
url: `/pages/inspectionContent/inspectionContentNew?value=${value}&inspectionCode=${this.inspectionCode}&jfType=${jfType}&location=${location}&uid=${this.uid}&backValue=${this.backValue}`, url: `/pages/inspectionContent/inspectionContentNew?value=${value}&inspectionCode=${this.inspectionCode}&jfType=${jfType}&location=${name}&uid=${this.uid}&backValue=${this.backValue}`,
}); });
}, },
lookTable() { lookTable() {
...@@ -325,6 +412,40 @@ export default { ...@@ -325,6 +412,40 @@ export default {
toSign() { toSign() {
this.$refs.signDialog.open(); this.$refs.signDialog.open();
}, },
findTargetObject(rows) {
if (!rows || rows.length === 0) return null;
let lastNonZeroIndex = -1;
// 首先检查所有对象,记录最后一个 status 不为 0 的索引
for (let i = 0; i < rows.length; i++) {
if (rows[i].status !== 0) {
lastNonZeroIndex = i;
}
}
// 如果没有找到任何 status 不为 0 的对象,返回 null
if (lastNonZeroIndex === -1) return null;
// 计算目标对象的索引
let targetIndex = lastNonZeroIndex + 1;
// 如果最后一个非零对象是数组的最后一个元素,则从第一个对象开始检查
if (lastNonZeroIndex === rows.length - 1) {
for (let i = 0; i < rows.length; i++) {
if (rows[i].status !== 0) {
targetIndex = i + 1;
break; // 找到第一个就停止
}
}
// 如果 targetIndex 超出数组范围,则返回 null
return targetIndex < rows.length ? rows[targetIndex] : null;
}
// 正常情况:返回最后一个非零对象的下一个对象
return rows[targetIndex];
},
// 处理弹窗确认 // 处理弹窗确认
handlePopupConfirm(summary) { handlePopupConfirm(summary) {
this.detailsInfo.isSign = this.isSign = true; // 回显到文字显示区域 this.detailsInfo.isSign = this.isSign = true; // 回显到文字显示区域
...@@ -675,4 +796,32 @@ export default { ...@@ -675,4 +796,32 @@ export default {
} }
} }
} }
.submit-module {
display: flex;
justify-content: center;
position: fixed;
gap: 16px;
left: 50%;
transform: translateX(-50%);
bottom: 25.6px;
.action-btn {
width: 145.6px;
height: 38.4px;
line-height: 38.4px;
background: #ffffff;
border: 0.8px solid rgba(224, 224, 224, 1);
box-shadow: 0px 8px 19.2px 0px rgba(185, 185, 185, 0.24);
border-radius: 21.6px 19.2px 19.2px 21.6px;
font-size: 16px;
color: #000000;
text-align: center;
font-weight: 400;
&.complete-btn {
background-image: linear-gradient(180deg, #3773f6 0%, #2c57f6 99%);
color: #ffffff;
}
}
}
</style> </style>
...@@ -128,16 +128,25 @@ ...@@ -128,16 +128,25 @@
> >
完成巡检 完成巡检
</view> --> </view> -->
<view v-if="tabs[activeTab].value !=='qt'" class="action-btn complete-btn" @click="nextTab"> 下一项 </view> <view
v-if="tabs[activeTab].value !== 'qt'"
class="action-btn complete-btn"
@click="nextTab"
>
下一项
</view>
</view> </view>
<startDialog
ref="startDialog"
:startDialogData="startDialogData"
@confirm="handleStartDialog"
></startDialog>
</view> </view>
</template> </template>
<script> <script>
import { import {
pad_2_1_inspection_items,
pad_all_inspection_position, pad_all_inspection_position,
pad_2_1_floor,
tabsInfo1, tabsInfo1,
tabsInfo2, tabsInfo2,
} from "@/utils/dict.js"; //巡检位置,A座到F座 楼层2楼4楼到26楼 } from "@/utils/dict.js"; //巡检位置,A座到F座 楼层2楼4楼到26楼
...@@ -160,6 +169,7 @@ import dlxt from "./components/dlxt.vue"; //电力系统 ...@@ -160,6 +169,7 @@ import dlxt from "./components/dlxt.vue"; //电力系统
import xfxt from "./components/xfxt.vue"; //消防系统 import xfxt from "./components/xfxt.vue"; //消防系统
import xlqk from "./components/xlqk.vue"; //线路情况 import xlqk from "./components/xlqk.vue"; //线路情况
import qt from "./components/qt.vue"; //其它 import qt from "./components/qt.vue"; //其它
import startDialog from "./components/dialog.vue";
export default { export default {
components: { components: {
...@@ -172,6 +182,7 @@ export default { ...@@ -172,6 +182,7 @@ export default {
xfxt, xfxt,
xlqk, xlqk,
qt, qt,
startDialog,
}, },
data() { data() {
return { return {
...@@ -185,7 +196,7 @@ export default { ...@@ -185,7 +196,7 @@ export default {
randomDescription: "这是一段随机说明文字。", // 随机说明文字 randomDescription: "这是一段随机说明文字。", // 随机说明文字
tabs: [], tabs: [],
activeTab: 0, // 当前选中的 Tab activeTab: 0, // 当前选中的 Tab
inspectionResult: 0, // Switch 值(0: 正常, 1: 异常) inspectionResult: "", // Switch 值(0: 正常, 1: 异常)
conclusion: "", // 情况摘要 conclusion: "", // 情况摘要
photos: [], // 现场照片 photos: [], // 现场照片
historyData: null, // 历史数据 historyData: null, // 历史数据
...@@ -195,6 +206,15 @@ export default { ...@@ -195,6 +206,15 @@ export default {
list: [], //巡检信息 list: [], //巡检信息
itemDetail: {}, itemDetail: {},
backValue: "", //路由来源 backValue: "", //路由来源
startDialogData: {
text: [],
isList: false,
isLast: false,
}, //弹窗文案
listData: [],
name: "",
jfType: "0",
value: "1",
}; };
}, },
computed: { computed: {
...@@ -221,7 +241,7 @@ export default { ...@@ -221,7 +241,7 @@ export default {
this.backValue = options.backValue || ""; this.backValue = options.backValue || "";
this.tabs = this.tabs =
this.jfType === "2" || this.jfType === "3" ? tabsInfo2 : tabsInfo1; this.jfType === "2" || this.jfType === "3" ? tabsInfo2 : tabsInfo1;
console.log("机房查看options", options);
if (options.uid) { if (options.uid) {
this.getDetails(options.uid); this.getDetails(options.uid);
} else { } else {
...@@ -266,7 +286,7 @@ export default { ...@@ -266,7 +286,7 @@ export default {
.then((res) => { .then((res) => {
const detailsInfo = res; const detailsInfo = res;
this.list = detailsInfo.originData[this.value - 1].details; this.list = detailsInfo.originData[this.value - 1].details;
console.log("list", this.list); console.log("查看list", this.list);
// this.inspectionResult = list[0].inspectionResult; // this.inspectionResult = list[0].inspectionResult;
this.detailsInfo = detailsInfo; this.detailsInfo = detailsInfo;
console.log("detailsInfo", detailsInfo); console.log("detailsInfo", detailsInfo);
...@@ -296,6 +316,7 @@ export default { ...@@ -296,6 +316,7 @@ export default {
getParams(isSubmit) { getParams(isSubmit) {
if (this.uid) { if (this.uid) {
let posItem = this.detailsInfo.originData[this.value - 1]; let posItem = this.detailsInfo.originData[this.value - 1];
this.listData = this.detailsInfo.originData;
let paramsObj = this.getAllChildFormData(); //获取所有数据 let paramsObj = this.getAllChildFormData(); //获取所有数据
console.log("获取数据", paramsObj); console.log("获取数据", paramsObj);
posItem.details = paramsObj; posItem.details = paramsObj;
...@@ -331,13 +352,14 @@ export default { ...@@ -331,13 +352,14 @@ export default {
value: item.dictValue, value: item.dictValue,
jfType: item.jfType, jfType: item.jfType,
isVaild: false, // 校验通过 isVaild: false, // 校验通过
details: {}, details: paramsObj,
status: item.status, status: item.status,
refName: `TabContentItem_${index}`, refName: `TabContentItem_${index}`,
statusLable: item.statusLable, statusLable: item.statusLable,
}; };
}); });
let tabList = this.deepClone(dataObj); let tabList = this.deepClone(dataObj);
this.listData = this.deepClone(tabList);
let posItem = tabList[this.value - 1]; let posItem = tabList[this.value - 1];
posItem.details = paramsObj; posItem.details = paramsObj;
posItem.isSubmit = isSubmit; posItem.isSubmit = isSubmit;
...@@ -457,7 +479,7 @@ export default { ...@@ -457,7 +479,7 @@ export default {
"巡检模块" "巡检模块"
); );
} else { } else {
params.uid = new Date().getTime(); // 唯一标识 pad 端使用 this.uid = params.uid = new Date().getTime(); // 唯一标识 pad 端使用
all_data.push(params); all_data.push(params);
logContent = getLogContent( logContent = getLogContent(
LOG_TYPE_ENUM.add, LOG_TYPE_ENUM.add,
...@@ -487,14 +509,86 @@ export default { ...@@ -487,14 +509,86 @@ export default {
// 清空基础缓存信息 // 清空基础缓存信息
// this.$store.commit("SET_TEMP_DATA", {}); // 缓存[巡检信息] // this.$store.commit("SET_TEMP_DATA", {}); // 缓存[巡检信息]
uni.showToast({ // uni.showToast({
title: isSubmit ? "提交成功" : "保存草稿成功", // title: isSubmit ? "提交成功" : "保存草稿成功",
icon: "success", // icon: "success",
}); // });
if (isSubmit) {
this.startDialog();
} else {
uni.showToast({
title: "暂存成功",
icon: "none",
});
// uni.navigateTo({
// url: `/pages/inspectionContent/inspectionContentList?uid=${params.uid}&backValue=${this.backValue}`,
// });
}
uni.navigateTo({ uni.navigateTo({
url: `/pages/inspectionContent/inspectionContentList?uid=${params.uid}&backValue=${this.backValue}`, url: `/pages/inspectionContent/inspectionContentList?uid=${params.uid}&backValue=${this.backValue}`,
}); });
}, },
startDialog() {
let item = this.findTargetObject(this.listData);
console.log("即将操作的机房", item);
this.name = item && item.name ? item.name : "";
this.jfType = item && item.name ? item.jfType : "";
this.value = item && item.name ? item.value : "";
if (item && item.name) {
this.startDialogData.text = [
`当前机房已巡检完毕,`,
`请到“${this.name}”`,
];
} else {
this.startDialogData.text = [
`本次巡检任务已全部完成,`,
"请“返回巡检列表”进行签名及数据同步",
];
}
this.$refs.startDialog.open();
},
// 处理弹窗确认
handleStartDialog() {
console.log("跳转前",this.uid)
uni.navigateTo({
url: `/pages/inspectionContent/inspectionContentNew?value=${this.value}&inspectionCode=${this.inspectionCode}&jfType=${this.jfType}&location=${this.name}&uid=${this.uid}&backValue=${this.backValue}`,
});
},
findTargetObject(rows) {
if (!rows || rows.length === 0) return null;
let lastNonZeroIndex = -1;
// 首先检查所有对象,记录最后一个 status 不为 0 的索引
for (let i = 0; i < rows.length; i++) {
if (rows[i].status !== 0) {
lastNonZeroIndex = i;
}
}
// 如果没有找到任何 status 不为 0 的对象,返回 null
if (lastNonZeroIndex === -1) return null;
// 计算目标对象的索引
let targetIndex = lastNonZeroIndex + 1;
// 如果最后一个非零对象是数组的最后一个元素,则从第一个对象开始检查
if (lastNonZeroIndex === rows.length - 1) {
for (let i = 0; i < rows.length; i++) {
if (rows[i].status !== 0) {
targetIndex = i + 1;
break; // 找到第一个就停止
}
}
// 如果 targetIndex 超出数组范围,则返回 null
return targetIndex < rows.length ? rows[targetIndex] : null;
}
// 正常情况:返回最后一个非零对象的下一个对象
return rows[targetIndex];
},
// 获取子组件数据 // 获取子组件数据
getAllChildFormData() { getAllChildFormData() {
// 获取所有子组件实例 // 获取所有子组件实例
...@@ -576,6 +670,7 @@ export default { ...@@ -576,6 +670,7 @@ export default {
} }
}, // 设置巡检结论 }, // 设置巡检结论
setInspectionResult(value) { setInspectionResult(value) {
console.log("设置巡检结论",value)
this.inspectionResult = value; this.inspectionResult = value;
this.list[this.activeTab].inspectionResult = value; // 更新当前 Tab 的数据 this.list[this.activeTab].inspectionResult = value; // 更新当前 Tab 的数据
}, },
......
<template>
<view class="synchronous-dialog">
<view class="synchronous-content">
<view class="row-item">
<text class="title">待打包数据</text>
</view>
<view class="row-item count-num">
<text class="num">{{ notSynchronizationList.length }}</text>
<text></text>
</view>
<view class="operating-instructions">
<view class="title">操作说明:</view>
<view class="instructions-item">
1、在PAD端,点击“数据打包”,做好同步准备。
</view>
<view class="instructions-item">
2、完成打包后,将PAD直联PC机,等待PC机自动导入需同步记录。
</view>
<view class="instructions-item">
3、PC端自动导入完成后,请点击“同步数据”,同步成功后,列表自动刷新展示同步数据;且PAD同步的数据不支持修改。
</view>
</view>
<view class="row-item bottom-row">
<button class="button" :loading="loading" @click="clickHandle">
数据打包
</button>
</view>
<!-- 关闭按钮 -->
<div class="close-button">
<text class="iconfont icon-shibai1" @click="close"></text>
</div>
</view>
</view>
</template>
<script>
import {
SYNCHRONIZE_DATA_PAD,
checkAndCreateDirectory,
createFileWithPlusIO,
setSm2,
USER_FILE_NAME,
getUserList,
} from "@/utils/systemCofig";
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";
export default {
props: {
list: {
type: Array,
default: () => {
return [];
},
},
},
components: {},
data() {
return {
loading: false,
notSynchronizationList: [], // 未同步数据
allList: [], // 所有数据
};
},
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.isSign === true
);
getAllInspections().then((res) => {
this.allList = res;
});
},
close() {
this.$emit("close");
},
/**
* 1.生成两个文件. 机房文件 和 井道文件
* 2. 更新巡检数据状态 synchronization 置为 1
* 3. 写入数据
* 读取上一次打包的文件, 复制到 [ history ] 文件夹中
*/
clickHandle() {
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) => {
uni.showToast({
title: error,
icon: "none",
duration: 1000,
});
});
});
},
// 处理数据
coverData() {
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;
}); // 机房数据类型是 1
const JDXJ_DATA = notSynchronizationList
.filter((item) => item.inspectionType == 2)
.map((item) => {
return item;
}); // 井道数据类型是 2
console.log(5151, JFXJ_DATA, JDXJ_DATA);
this.loading = true;
const tmepList = [];
if (JFXJ_DATA.length) {
let JFXJ_DATA_FILE_NAME = `${userName}_JFXJ_${timeStr}.txt`;
tmepList.push(this.packedData(JFXJ_DATA, JFXJ_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));
});
console.log("同步窗口");
console.log("同步窗口", tmepList);
Promise.all(tmepList)
.then(() => {
// 更新巡检数据状态
const synchronizationUids = notSynchronizationList.map((item) => {
item.synchronization = 1;
return item.uid;
});
const userData = {};
allList.forEach((item) => {
if (synchronizationUids.includes(item.uid)) {
item.synchronization = 1;
}
if (userData[item.createByName]) {
userData[item.createByName].push(item);
} else {
userData[item.createByName] = [item];
}
});
this.$store.commit("SET_ALL_DATA", allList);
const keys = Object.keys(userData);
const promiseArr = keys.map((key) => {
const val = userData[key];
return writeInspectionData(val, key);
});
Promise.all(promiseArr)
.then(() => {
setTimeout(() => {
uni.showToast({
title: "打包成功",
icon: "none",
duration: 2000,
});
this.close();
this.loading = false;
// 生成日志
const logContent = getLogContent(
LOG_TYPE_ENUM.sys,
"",
"同步模块"
);
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) => {});
// 更新同步时间
this.updateSysTime();
}, 2 * 1000);
})
.catch((error) => {
this.loading = false;
uni.showToast({
title: error,
icon: "none",
duration: 2000,
});
});
})
.catch(() => {
setTimeout(() => {
uni.showToast({
title: "打包失败",
icon: "none",
duration: 2000,
});
this.loading = false;
}, 2 * 1000);
});
},
// 打包文件
packedData(content, fileName) {
const fileContent = setSm2(content);
return createFileWithPlusIO(
`${SYNCHRONIZE_DATA_PAD}/发送数据`,
fileName,
fileContent
);
},
// 更新最近一次同步时间
updateSysTime() {
getUserList().then((personList) => {
const now_user = this.$store.state.now_user;
const key = personList.findIndex(
(item) => item.userId == now_user.userId
);
// 更新用户同步时间
const userInfo = personList[key];
const LastSynchronizationTime = moment().format("yyyy-MM-DD HH:mm");
personList[key].LastSynchronizationTime = LastSynchronizationTime;
userInfo.LastSynchronizationTime = LastSynchronizationTime;
this.$store.commit("SET_USER", userInfo);
uni.setStorageSync("last_time", userInfo.LastSynchronizationTime || "");
// 更新用户数据
const fileContent = JSON.stringify(
Base64.encode(JSON.stringify(personList))
);
uni.setStorage({
key: "user_data",
data: JSON.stringify(personList),
fail: (error) => {
console.log("APP.vue 存储数据失败", error);
},
});
createFileWithPlusIO(SYNCHRONIZE_DATA_PAD, USER_FILE_NAME, fileContent)
.then(() => {
console.log("---用户数据更新成功");
})
.catch((error) => {
console.log("---用户数据更新失败", error);
});
});
},
},
};
</script>
<style scoped lang="less">
.synchronous-dialog {
position: fixed;
z-index: 999;
top: 0;
left: 0;
width: 100%;
height: 100%;
background: rgba(0, 0, 0, 0.5);
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,
#f9ffe7 0%,
#ffffff 12%,
#fcfeff 73%,
#ccf1ff 100%
);
border: 0.4px solid rgba(224, 224, 224, 1);
border-radius: 12px;
position: relative;
.row-item {
display: flex;
align-items: center;
justify-content: center;
}
.title {
font-family: PingFangSC-Medium;
font-size: 18px;
color: #000000;
text-align: center;
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;
font-size: 50px;
color: #3774f6;
line-height: 44px;
font-weight: 500;
}
}
.operating-instructions {
margin-bottom: 8%;
.title {
font-size: 13px;
color: #4a4a4a;
line-height: 24px;
font-weight: 600;
text-align: left;
}
.instructions-item {
font-size: 12px;
color: #7c7c7c;
line-height: 22px;
font-weight: 400;
}
}
// 打包按钮
.bottom-row {
position: absolute;
bottom: 24px;
left: 50%;
transform: translateX(-50%);
.button {
display: flex;
align-items: center;
justify-content: center;
background-image: linear-gradient(180deg, #3773f6 0%, #2c57f6 99%);
box-shadow: 0px 10px 24px 0px rgba(51, 104, 246, 0.24);
border-radius: 27px;
width: 160px;
height: 40px;
color: #fff;
}
}
// 关闭按钮
.close-button {
position: absolute;
bottom: -40px;
left: 50%;
transform: translateX(-50%);
.iconfont {
font-size: 24px;
}
}
}
}
</style>
...@@ -69,7 +69,7 @@ ...@@ -69,7 +69,7 @@
import SearchCom from "@/components/searchCom/index.vue"; import SearchCom from "@/components/searchCom/index.vue";
import InspectionItem from "@/components/inspectionItem/index.vue"; import InspectionItem from "@/components/inspectionItem/index.vue";
import { getDarft } from "@/request/index.js"; import { getDarft } from "@/request/index.js";
import Dialog from "./dialog.vue"; import Dialog from "../inspectionContent/components/dialog.vue";
import { getAllInspections } from "@/request/index.js"; import { getAllInspections } from "@/request/index.js";
import Empty from "@/components/empty/index.vue"; import Empty from "@/components/empty/index.vue";
......
...@@ -34,10 +34,10 @@ ...@@ -34,10 +34,10 @@
</block> </block>
<block slot="right" class="nav-right"> <block slot="right" class="nav-right">
<view class="header-right"> <view class="header-right">
<text <!-- <text
class="iconfont icon-quanxuan" class="iconfont icon-quanxuan"
@click.stop="toggleSelectAll" @click.stop="toggleSelectAll"
></text> ></text> -->
<text class="iconfont icon-shanchu" @click.stop="deletePhotos" <text class="iconfont icon-shanchu" @click.stop="deletePhotos"
>删除</text >删除</text
> >
...@@ -80,10 +80,10 @@ ...@@ -80,10 +80,10 @@
> >
<text v-if="photo.selected"></text> <text v-if="photo.selected"></text>
</view> </view>
<text <!-- <text
class="delete-icon iconfont icon-shanchu" class="delete-icon iconfont icon-shanchu"
@click.stop="deletePhoto(photo)" @click.stop="deletePhoto(photo)"
></text> ></text> -->
<view class="type">{{ <view class="type">{{
photo.synchronization ? "已同步" : "待同步" photo.synchronization ? "已同步" : "待同步"
}}</view> }}</view>
......
...@@ -7,8 +7,8 @@ ...@@ -7,8 +7,8 @@
rightWidth="300" rightWidth="300"
> >
<block slot="left"> <block slot="left">
<view class="uni-nav-bar-text" @click="back"> <view class="" @click="back">
<text class="iconfont icon-Arrow-Left"></text <text class="iconfont icon-fanhui"></text
></view> ></view>
</block> </block>
</uni-nav-bar> </uni-nav-bar>
......
...@@ -31,7 +31,7 @@ ...@@ -31,7 +31,7 @@
<!-- 关闭按钮 --> <!-- 关闭按钮 -->
<div class="close-button"> <div class="close-button">
<text class="iconfont icon-a-bianzu16beifen" @click="close"></text> <text class="iconfont icon-shibai1" @click="close"></text>
</div> </div>
</view> </view>
</view> </view>
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论