提交 99d39d48 authored 作者: 邓文彬's avatar 邓文彬

fix(pad): 核心功能完成,开始走查功能

上级 d1b86b97
......@@ -60,6 +60,11 @@
<script>
import getDateTime from "@/common/getdateTime.js";
import { Base64 } from "js-base64";
import {
addLog,
getLogContent,
LOG_TYPE_ENUM,
} from "@/utils/IoReadingAndWriting.js";
import {
SYNCHRONIZE_DATA_PAD,
......@@ -159,17 +164,19 @@ export default {
return item;
});
let timeStr = getDateTime.dateTimeStr("y-m-d h:i");
let operData = {
name: this.$store.state.now_user.name,
level: "秘密",
user: this.$store.state.now_user.user,
module: "其他",
detail: "无",
type: "修改密码",
time: timeStr,
};
this.$store.state.oper_record.unshift(operData);
// let timeStr = getDateTime.dateTimeStr("y-m-d h:i");
// let operData = {
// name: this.$store.state.now_user.name,
// level: "秘密",
// user: this.$store.state.now_user.user,
// module: "其他",
// detail: "无",
// type: "修改密码",
// time: timeStr,
// };
// this.$store.state.oper_record.unshift(operData);
// 重新存储本地用户信息
// let _this = this;
......@@ -235,6 +242,16 @@ export default {
duration: 2000,
});
// 生成日志
const logContent = getLogContent(LOG_TYPE_ENUM.updatePassword);
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) => {
console.log("日志文件写入成功");
});
this.logOut();
});
} else {
......
......@@ -70,11 +70,11 @@
<view class="desc">
<text class="xuxian">......</text>
<text class="bold">{{ item.name }} {{ item.user }}</text>
<text class="bold">{{ item.name || item.user }} </text>
<text class="text">操作</text>
<text class="bold">{{ item.module }}{{ item.type }}</text>
<text class="text">内容</text>
<text class="bold">{{ item.detail }}</text>
<text v-if="item.detail" class="text">内容</text>
<text v-if="item.detail" class="bold">{{ item.detail }}</text>
</view>
</view>
</view>
......
......@@ -48,28 +48,35 @@
<!-- tabls -->
<Tabs class="tabs" ref="tabs" :options="tabList" @change="changeTab" />
<GatherDataCenter v-show="activeTabIndex == 0" ref="GatherDataCenter" />
<GatherDataCenter v-show="activeTabIndex == 0"
:isDisable="isDisable"
ref="GatherDataCenter" />
<ShieldedComputerRoom
ref="ShieldedComputerRoom"
v-show="activeTabIndex == 1"
/>
<BatteryRoom ref="BatteryRoom" v-show="activeTabIndex == 2" />
<BatteryRoom ref="BatteryRoom"
:isDisable="isDisable"
v-show="activeTabIndex == 2" />
<ComputerRoomDuty
ref="ComputerRoomDuty"
:isDisable="isDisable"
v-show="activeTabIndex == 3"
></ComputerRoomDuty>
<DutyHandover
ref="DutyHandover"
:isDisable="isDisable"
v-show="activeTabIndex == 4"
></DutyHandover>
</view>
<view class="fixed-btns">
<view v-if="!isDisable" class="fixed-btns">
<view class="button-group">
<view
v-if="!detailsInfo.uid"
class="btn-draft btn-class"
@tap="draft(activeTabIndex)"
>
......@@ -165,6 +172,7 @@ export default {
// 对应每个tab下的数据 [示例 0: 数据]
},
detailsInfo: {}, // 详情
isDisable: false, // 禁用
};
},
onLoad(options) {
......@@ -179,19 +187,25 @@ export default {
this.tempForm = darf_data.originData.tempForm;
console.log("获取草稿数据---", darf_data);
this.detailsInfo = darf_data;
}
},
mounted() {
if (this.detailsInfo.inspectionType) {
const fillCheck = this.detailsInfo.fillCheck.split(",")
const fillCheck = this.detailsInfo.fillCheck.split(",");
this.tabList.forEach((item, index) => {
item.isVaild = fillCheck.includes(item.value)
item.isVaild = fillCheck.includes(item.value);
this.tempForm[index] && this.setComponentData(index, this.tempForm[index]);
this.tempForm[index] &&
this.setComponentData(index, this.tempForm[index]);
});
} else {
this.baseInfo = this.$store.state.temp_data;
}
},
methods: {
......@@ -208,6 +222,8 @@ export default {
this.baseInfo = detailsInfo.originData.baseInfo;
this.tempForm = detailsInfo.originData.tempForm;
this.detailsInfo = detailsInfo;
this.isDisable = (detailsInfo.synchronization == 1)
},
// 回显组件数据
setComponentData(activeTabIndex, componentData) {
......@@ -249,7 +265,11 @@ export default {
// 更新日志
const log_list = this.$store.state.log_list;
const logContent = getLogContent(LOG_TYPE_ENUM.delete);
const logContent = getLogContent(
LOG_TYPE_ENUM.delete,
`${detailsInfo.recordName}(${detailsInfo.inspectionCode})`,
"巡检模块"
);
log_list.push(logContent);
this.$store.commit("SET_LOG_LIST", log_list);
......@@ -296,7 +316,10 @@ export default {
const tempForm = this.tempForm;
const baseInfo = this.baseInfo;
const fillCheck = tabList.filter(item => item.isVaild). map((item) => item.value).join(",");
const fillCheck = tabList
.filter((item) => item.isVaild)
.map((item) => item.value)
.join(",");
let temp = {
...baseInfo,
isSubmit: 1,
......@@ -373,11 +396,19 @@ export default {
(element) => element.uid == params.uid
);
all_data[index] = params;
logContent = getLogContent(LOG_TYPE_ENUM.edit);
logContent = getLogContent(
LOG_TYPE_ENUM.edit,
`${params.recordName}(${params.inspectionCode})`,
"巡检模块"
);
} else {
params.uid = new Date().getTime(); // 唯一标识 pad 端使用
all_data.push(params);
logContent = getLogContent(LOG_TYPE_ENUM.add);
logContent = getLogContent(
LOG_TYPE_ENUM.add,
`${params.recordName}(${params.inspectionCode})`,
"巡检模块"
);
}
// console.log("--params--",all_data, params)
......@@ -455,20 +486,10 @@ export default {
.setTabVaild(activeTabIndex, vaild, iSwtich)
.then(() => {
this.tempForm[activeTabIndex] = formData;
// console.log("--this.tempForm--", formData);
if (isSave) {
console.log("--保存草稿--");
// 新增日志信息
const logContent = getLogContent(LOG_TYPE_ENUM.darf);
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) => {
console.log("日志文件写入成功");
});
// 写入草稿文件 更新 store 草稿内容
const params = this.getParams();
this.$store.commit("SET_DARF_DATA", params);
......@@ -481,6 +502,19 @@ export default {
title: "保存草稿成功",
});
});
// 新增日志信息
const logContent = getLogContent(
LOG_TYPE_ENUM.darf,
`${params.recordName}(${params.inspectionCode})`,
"巡检模块"
);
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) => {
console.log("日志文件写入成功");
});
}
resolve();
});
......
......@@ -53,7 +53,12 @@
label="情况摘要"
name="notes"
>
<input type="text" v-model="item.notes" placeholder="请输入内容" />
<input
type="text"
:disabled="isDisable"
v-model="item.notes"
placeholder="请输入内容"
/>
</uni-forms-item>
</uni-forms>
</view>
......@@ -69,6 +74,11 @@ import {
* 电池间
*/
export default {
props: {
isDisable: {
type: Boolean,
},
},
data() {
return {
list: [],
......@@ -101,7 +111,7 @@ export default {
methods: {
// tag 点击事件
tagClick(parentIndex, eleIndex, isActive) {
if (isActive) {
if (isActive || this.isDisable) {
return;
}
this.list[parentIndex].resultArr.forEach((element) => {
......@@ -122,6 +132,9 @@ export default {
},
// tag 点击事件
postionChange(parentIndex, eleIndex, isActive) {
if (this.isDisable) {
return;
}
const postionList = this.list[parentIndex].postionList;
const item = postionList[eleIndex];
item.isActive = !isActive;
......
......@@ -19,11 +19,13 @@
v-model="form.roomWatch"
placeholder-style="color:#C7C7C7"
placeholder="请输入需求文字"
:disabled="isDisable"
/>
<view class="quick-input"> 快捷输入 </view>
<view v-if="!isDisable" class="quick-input"> 快捷输入 </view>
<view>
<view v-if="!isDisable">
<text
class="qucik-text"
v-for="item in quickTextList"
......@@ -37,15 +39,17 @@
</view>
</template>
<script>
import {
pad_room_type,
} from "@/utils/dict.js";
import { pad_room_type } from "@/utils/dict.js";
/**
* 机房值班
*/
export default {
props: {},
props: {
isDisable: {
type: Boolean,
},
},
data() {
return {
list: [],
......
......@@ -19,11 +19,13 @@
v-model="form.dutyHandover"
placeholder-style="color:#C7C7C7"
placeholder="请输入"
:disabled="isDisable"
/>
<view class="quick-input"> 快捷输入 </view>
<view v-if="!isDisable" class="quick-input"> 快捷输入 </view>
<view>
<view v-if="!isDisable">
<text
class="qucik-text"
v-for="item in quickTextList"
......@@ -46,6 +48,8 @@
name="successor"
>
<uni-easyinput
:disabled="isDisable"
type="text"
v-model="form.successor"
placeholder="请输入"
......@@ -62,7 +66,11 @@ import { pad_room_type } from "@/utils/dict.js";
* 值班交接
*/
export default {
props: {},
props: {
isDisable: {
type: Boolean,
},
},
data() {
return {
rules: {
......
......@@ -47,14 +47,18 @@
<!-- 异常状态时显示 -->
<uni-forms-item
v-if="item.inspectionResult == 1"
v-if="item.inspectionResult == 1"
required
class="row-item"
label="情况摘要"
name="notes"
>
<input type="text" v-model="item.notes" placeholder="请输入内容" />
<input
type="text"
:disabled="isDisable"
v-model="item.notes"
placeholder="请输入内容"
/>
</uni-forms-item>
</uni-forms>
</view>
......@@ -70,7 +74,11 @@ import {
* 汇集机房
*/
export default {
props: {},
props: {
isDisable: {
type: Boolean,
},
},
data() {
return {
list: [],
......@@ -103,7 +111,7 @@ export default {
methods: {
// tag 点击事件
tagClick(parentIndex, eleIndex, isActive) {
if (isActive) {
if (isActive || this.isDisable) {
return;
}
this.list[parentIndex].resultArr.forEach((element) => {
......@@ -124,6 +132,9 @@ export default {
},
// tag 点击事件
postionChange(parentIndex, eleIndex, isActive) {
if (this.isDisable) {
return;
}
const postionList = this.list[parentIndex].postionList;
const item = postionList[eleIndex];
item.isActive = !isActive;
......@@ -254,16 +265,16 @@ export default {
align-items: center;
.tag {
background: #f2f3f5;
width: 55px;
height: 36px;
border-radius: 10px;
text-align: center;
line-height: 36px;
margin-right: 10px;
font-size: 14px;
color: #4a4a4a;
text-align: center;
font-weight: 400;
width: 55px;
height: 36px;
border-radius: 10px;
text-align: center;
line-height: 36px;
margin-right: 10px;
font-size: 14px;
color: #4a4a4a;
text-align: center;
font-weight: 400;
}
.active-tag {
background: #3774f6;
......
......@@ -53,7 +53,10 @@
name="notes"
v-if="item.inspectionResult == 1"
>
<input type="text" v-model="item.notes" placeholder="请输入内容" />
<input type="text"
:disabled="isDisable"
v-model="item.notes" placeholder="请输入内容" />
</uni-forms-item>
</uni-forms>
</view>
......@@ -69,6 +72,11 @@ import {
* 屏蔽机房巡检
*/
export default {
props: {
isDisable: {
type: Boolean,
},
},
data() {
return {
list: [],
......@@ -101,7 +109,7 @@ export default {
methods: {
// tag 点击事件
tagClick(parentIndex, eleIndex, isActive) {
if (isActive) {
if (isActive || this.isDisable) {
return;
}
this.list[parentIndex].resultArr.forEach((element) => {
......@@ -122,6 +130,9 @@ export default {
},
// tag 点击事件
postionChange(parentIndex, eleIndex, isActive) {
if (this.isDisable) {
return;
}
const postionList = this.list[parentIndex].postionList;
const item = postionList[eleIndex];
item.isActive = !isActive;
......
......@@ -46,7 +46,15 @@ import {
} from "@/utils/systemCofig";
import getDateTime from "@/common/getdateTime.js";
import { Base64 } from "js-base64";
import { writeInspectionData } from "@/utils/IoReadingAndWriting.js";
import {
writeInspectionData,
copyDirectory,
deleteAllFilesInDirectory,
addLog,
getLogContent,
LOG_TYPE_ENUM,
} from "@/utils/IoReadingAndWriting.js";
import moment from "moment";
export default {
components: {},
......@@ -66,13 +74,46 @@ export default {
close() {
this.$emit("close");
},
/**
* 1.生成两个文件. 机房文件 和 井道文件
* 2. 更新巡检数据状态 synchronization 置为 1
* 3. 写入数据
* 读取上一次打包的文件, 复制到 [ history ] 文件夹中
*/
clickHandle() {
const directoryPath = `${SYNCHRONIZE_DATA_PAD}/发送数据`;
const targetDirectoryPath = `${SYNCHRONIZE_DATA_PAD}/history`;
checkAndCreateDirectory(directoryPath).then(() => {
console.log("---sss");
copyDirectory(directoryPath, targetDirectoryPath)
.then(() => {
console.log("---文件复制完成");
return deleteAllFilesInDirectory(directoryPath);
})
.then(() => {
console.log("---文件删除成功----");
this.coverData();
})
.catch((error) => {
console.log("---error", error);
uni.showToast({
title: error,
icon: "none",
duration: 1000,
});
});
});
},
// 处理数据
coverData() {
const userName = this.$store.state.now_user.name;
const all_data = this.all_data;
console.log("-同步数据--", all_data);
let timeStr = getDateTime.dateTimeStr("y-m-d h-i-s");
let timeStr = moment().format("yyyy-MM-DD_hh:mm:ss");
let JFXJ_DATA_FILE_NAME = `${userName}_JFXJ_${timeStr}.txt`;
let JDXJ_DATA_FILE_NAME = `${userName}_JDXJ_${timeStr}.txt`;
......@@ -92,22 +133,44 @@ export default {
this.packedData(JDXJ_DATA, JDXJ_DATA_FILE_NAME),
])
.then(() => {
// 更新巡检数据状态
const newAllData = all_data.map((item) => {
item.synchronization = 1;
return item;
});
this.$store.commit("SET_ALL_DATA", newAllData);
writeInspectionData(all_data);
setTimeout(() => {
uni.showToast({
title: "打包成功",
icon: "none",
duration: 2000,
writeInspectionData(all_data)
.then(() => {
this.$store.commit("SET_ALL_DATA", newAllData);
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) => {
console.log("日志文件写入成功");
});
}, 2 * 1000);
})
.catch((error) => {
this.loading = false;
uni.showToast({
title: error,
icon: "none",
duration: 2000,
});
});
this.close();
this.loading = false;
}, 2 * 1000);
})
.catch(() => {
setTimeout(() => {
......@@ -121,6 +184,7 @@ export default {
});
},
// 打包文件
packedData(content, fileName) {
const fileContent = setSm2(content);
return createFileWithPlusIO(
......
......@@ -31,7 +31,7 @@
</view>
<!-- 数据打包 -->
<view class="synchronous-button" @click="openDialog(true)">数据打包</view>
<view v-show="isPackedDataBtn" class="synchronous-button" @click="openDialog(true)">数据打包</view>
<!-- 打包弹窗 -->
<Dialog v-show="isDialog" @close="openDialog(false)"></Dialog>
......@@ -59,6 +59,7 @@ export default {
// 搜索条件
},
countNum: 0, // 统计查询总数
isPackedDataBtn: false // 控制打包按钮显示
};
},
mounted() {
......@@ -68,6 +69,10 @@ export default {
init() {
const all_data = this.$store.state.all_data || [];
console.log("---all_data-", all_data)
this.isPackedDataBtn = all_data.filter(item => item.synchronization == 0).length > 0;
const tempAllData = {};
all_data.forEach((item) => {
const val = tempAllData[item.submitTime] || [];
......
......@@ -25,19 +25,19 @@ export const LOG_TYPE_ENUM = {
edit: "编辑成功",
darf: "草稿",
delete: "删除",
sys: "同步",
sys: "同步数据",
updatePassword: "修改密码",
};
// 生成日志
export const getLogContent = (type, detail = "") => {
export const getLogContent = (type, detail = "", module= "其他模块") => {
const now_user = store.state.now_user;
let timeStr = moment().format("yyyy-MM-DD HH:mm:ss");
return {
name: now_user.user,
level: "秘密",
user: now_user.user,
module: "其他",
module,
detail,
type,
time: timeStr,
......@@ -64,7 +64,7 @@ export const addLog = (content) => {
fileName,
fileContent
).then((res) => {
console.log("--日志文件-写入成功", content);
console.log("--日志文件-写入成功", content);
resolve();
});
......@@ -80,7 +80,7 @@ export const readLogData = () => {
readFilesInDirectory(directoryPath)
.then((res) => {
const temp = res.map((element) => {
return JSON.parse(Base64.decode(element));
return JSON.parse(Base64.decode(element));
});
// console.log("读取志文件数据--", temp);
......@@ -151,7 +151,7 @@ export const writeInspectionData = (content, isEncryption = false) => {
let fileName = `${timeStr}.txt`;
console.log("写入-巡检数据--", content);
isEncryption;
// isEncryption;
const temp = Base64.encode(JSON.stringify(content));
const fileContent = isEncryption ? setSm2(temp) : temp;
......@@ -187,28 +187,200 @@ export const readInspectionData = () => {
});
};
// 复制文件夹中的所有数据到另一个文件夹
/**
*
* @param {*} sourceDirectoryPath 复制内容文件夹路径 -- 源路径
* @param {*} targetDirectoryPath 复制到新的文件夹路径 -- 目标路径
*/
export function copyDirectory(sourceDirectoryPath, targetDirectoryPath) {
return new Promise((resolve, reject) => {
// 请求文件系统
plus.io.requestFileSystem(
plus.io.PUBLIC_DOCUMENTS,
function (fs) {
// 获取源文件夹路径的目录条目
fs.root.getDirectory(
sourceDirectoryPath,
{ create: false },
function (sourceDirEntry) {
// 获取目标文件夹路径的目录条目
fs.root.getDirectory(
targetDirectoryPath,
{ create: true, exclusive: false },
function (targetDirEntry) {
// 创建一个空的目录读取器
let directoryReader = sourceDirEntry.createReader();
// 读取源目录中的所有文件和子目录
directoryReader.readEntries(
function (entries) {
console.log("------entries.length-----", entries.length);
// 目标文件夹没有内容,直接返回
if (!entries.length) {
return resolve();
}
let copyNum = 0;
// 遍历文件和子目录
for (let i = 0; i < entries.length; i++) {
let entry = entries[i];
if (entry.isFile) {
// 确保是文件
// 复制文件
entry.copyTo(
targetDirEntry,
entry.name,
function () {
++copyNum;
console.log("文件复制成功:", entry.name);
if (copyNum == entries.length) {
console.log("-copyNum--", copyNum);
resolve();
}
},
function (error) {
console.error("文件复制失败:", error.message);
reject("文件复制失败");
}
);
} else if (entry.isDirectory) {
// 确保是目录
// 创建目标目录
targetDirEntry.getDirectory(
entry.name,
{ create: true, exclusive: false },
function (targetDirEntry) {
// 递归复制目录
copyDirectory(
entry.fullPath,
targetDirEntry.fullPath
);
},
function (error) {
console.error("创建目标目录失败:", error.message);
reject("创建目标目录失败");
}
);
}
}
},
function (error) {
console.error("读取目录条目失败:", error.message);
reject("读取目录条目失败");
}
);
},
function (error) {
console.error("获取目标目录失败:", error.message);
reject("获取目标目录失败");
}
);
},
function (error) {
console.error("获取源目录失败:", error.message);
reject("获取源目录失败");
}
);
},
function (error) {
console.error("请求文件系统失败:", error.message);
reject("请求文件系统失败");
}
);
});
}
// 读取数据文件
export const readDirectoryData = () =>{
return new Promise(async (resolve, reject) => {
readLogData()
.then((res) => {
console.log("----读出来的日志文件", res)
store.commit("SET_LOG_LIST", res);
return readInspectionData();
})
.then((res) => {
store.commit("SET_ALL_DATA", res);
return readDarfData();
})
.then((res) => {
store.commit("SET_DARF_DATA", res);
resolve();
})
.catch((error) => {
console.log("--读取数据文件-报错", error);
resolve();
});
});
}
\ No newline at end of file
// 删除文件夹中所有文件
export function deleteAllFilesInDirectory(directoryPath) {
// 请求文件系统
return new Promise((resolve, reject) => {
plus.io.requestFileSystem(
plus.io.PUBLIC_DOCUMENTS,
function (fs) {
// 获取指定文件夹路径的目录条目
fs.root.getDirectory(
directoryPath,
{ create: false },
function (dirEntry) {
// 创建一个空的目录读取器
var directoryReader = dirEntry.createReader();
// 读取目录中的所有文件和子目录
directoryReader.readEntries(
function (entries) {
// 目标文件夹没有内容,直接返回
if (!entries.length) {
return resolve();
}
let copyNum = 0;
// 遍历文件和子目录
for (var i = 0; i < entries.length; i++) {
var entry = entries[i];
if (entry.isFile) {
// 确保是文件
// 删除文件
entry.remove(
function () {
++copyNum;
console.log("文件删除成功:", entry.name);
if (copyNum == entries.length) {
resolve();
}
},
function (error) {
reject("文件删除失败");
console.error("文件删除失败:", error.message);
}
);
}
}
},
function (error) {
reject("读取目录条目失败");
console.error("读取目录条目失败:", error.message);
}
);
},
function (error) {
reject("获取目录失败");
console.error("获取目录失败:", error.message);
}
);
},
function (error) {
console.error("请求文件系统失败:", error.message);
reject("请求文件系统失败");
}
);
});
}
// // 使用示例
// const directoryPath = '_doc/exampleDirectory';
// deleteAllFilesInDirectory(directoryPath);
// 初始化 -- 读取数据文件
export const readDirectoryData = () => {
return new Promise(async (resolve, reject) => {
readLogData()
.then((res) => {
console.log("----读出来的日志文件", res);
store.commit("SET_LOG_LIST", res);
return readInspectionData();
})
.then((res) => {
store.commit("SET_ALL_DATA", res);
return readDarfData();
})
.then((res) => {
store.commit("SET_DARF_DATA", res);
resolve();
})
.catch((error) => {
console.log("--读取数据文件-报错", error);
resolve();
});
});
};
......@@ -5,6 +5,7 @@ export const SYNCHRONIZE_DATA_PATH = "_documents/data/asmzx"; // 同步数据
export const SYNCHRONIZE_DATA_PAD = "_documents/data/asmzx/pad"; // 存储pad端的生产数据
export const USER_FILE_NAME = "userList.txt"; // 存储内置用户的文件名
// 内置的用户信息
export const USER_LiST = [
{
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论