提交 409b2861 authored 作者: 邓文彬's avatar 邓文彬

fix(pad): 与PCj数据交互格式处理完成,数据使用方式待处理

上级 95bfd4aa
...@@ -91,6 +91,19 @@ export default { ...@@ -91,6 +91,19 @@ export default {
recordName: `${moment().format("yyyyMMDD")}-机房巡检记录`, recordName: `${moment().format("yyyyMMDD")}-机房巡检记录`,
inspectionTime: moment().format("yyyy-MM-DD HH:MM:ss"), inspectionTime: moment().format("yyyy-MM-DD HH:MM:ss"),
inspectionBy: this.$store.state.now_user.name, inspectionBy: this.$store.state.now_user.name,
inspectionById: this.$store.state.now_user.id,
isException: "", // 是否有异常
position: "", // 位置
isSubmit: "", // 0 是草稿态; 1 是正式提交
conclusion: "", //结论
"fillCheck": "", // tab字典的value值, 校验通过的
items:[
// {
// "itemCode": "1", // 检查项
// "measuredData": "2,3", // 异常的楼层
// "inspectionResult": "1" // 检查项的结果, 1是异常 0 是正常
// },
]
}; };
}, },
......
...@@ -28,7 +28,7 @@ ...@@ -28,7 +28,7 @@
<view class="content_header">巡检项目(pm)</view> <view class="content_header">巡检项目(pm)</view>
<!-- tabls --> <!-- tabls -->
<Tabs class="tabs" ref="tabs" @change="changeTab" /> <Tabs class="tabs" ref="tabs" :options="tabList" @change="changeTab" />
<GatherDataCenter v-show="activeTabIndex == 0" ref="GatherDataCenter" /> <GatherDataCenter v-show="activeTabIndex == 0" ref="GatherDataCenter" />
<ShieldedComputerRoom <ShieldedComputerRoom
...@@ -70,8 +70,15 @@ import { ...@@ -70,8 +70,15 @@ import {
addLog, addLog,
getLogContent, getLogContent,
LOG_TYPE_ENUM, LOG_TYPE_ENUM,
writeDarf writeDarf,
writeInspectionData,
} from "@/utils/IoReadingAndWriting.js"; } from "@/utils/IoReadingAndWriting.js";
import {
pad_1_1_inspection_position,
pad_1_2_inspection_position,
pad_1_3_inspection_position,
pad_room_type,
} from "@/utils/dict.js";
export default { export default {
components: { components: {
...@@ -84,6 +91,39 @@ export default { ...@@ -84,6 +91,39 @@ export default {
}, },
data() { data() {
return { return {
tabList: [
{
name: "汇聚机房",
isVaild: false, // 校验通过
position: pad_1_1_inspection_position.rows,
descript:
"痕迹检查地面、墙壁、天花板、是否有裂痕、水渍,机房内是否有鼠患、蚁患、蟑螂活动的痕迹,温湿度取最高值,正常室温:20~25℃,湿度:40~60%。",
},
{
name: "屏蔽机房",
isVaild: false, // 校验通过
position: pad_1_2_inspection_position.rows,
descript: "UPS检查包含UPS主机、UPS输入柜、UPS输出柜。",
},
{
name: "电池间",
isVaild: false, // 校验通过
position: pad_1_3_inspection_position.rows,
descript: "痕迹检查",
},
{
name: "机房值班",
isVaild: false, // 校验通过
descript: "记录哪些人员进出机房、总计次数。",
position: [],
},
{
name: "值班交接",
isVaild: false, // 校验通过
descript: "未完事项交换。",
position: [],
},
],
activeTabIndex: 0, activeTabIndex: 0,
baseInfo: {}, // 基础信息 baseInfo: {}, // 基础信息
tempForm: { tempForm: {
...@@ -91,12 +131,19 @@ export default { ...@@ -91,12 +131,19 @@ export default {
}, },
}; };
}, },
onLoad() {}, onLoad() {
this.init();
},
mounted() { mounted() {
this.baseInfo = this.$store.state.temp_data; this.baseInfo = this.$store.state.temp_data;
}, },
methods: { methods: {
init() {
pad_room_type.rows.forEach((item, index) => {
this.tabList[index].value = item.dictValue;
});
},
// tab选中change 时间 // tab选中change 时间
changeTab(index, item) { changeTab(index, item) {
this.draft(this.activeTabIndex, false, false).then(() => { this.draft(this.activeTabIndex, false, false).then(() => {
...@@ -108,54 +155,116 @@ export default { ...@@ -108,54 +155,116 @@ export default {
uni.navigateBack(); uni.navigateBack();
}, },
// 处理提交数据
getParams() {
const tabList = this.tabList;
const tempForm = this.tempForm;
const baseInfo = this.baseInfo;
const fillCheck = tabList.map((item) => item.value).join(",");
let temp = {
...baseInfo,
isSubmit: 1,
fillCheck,
isException: "",
roomWatch: "",
dutyHandover: "",
successor: "",
handoverPerson: "",
};
const tempItems = [];
tabList.forEach((element, index) => {
if (Array.isArray(tempForm[index])) {
console.log("---ARRAY", tempForm[index]);
tempItems.push(...tempForm[index]);
} else {
temp = {
...temp,
...tempForm[index],
};
}
});
console.log("---getParams", tempItems);
const items = tempItems.map((item) => {
return {
itemCode: item.itemCode,
measuredData: item.measuredData,
notes: item.notes,
inspectionResult: item.inspectionResult,
roomType: item.roomType,
};
});
const isException = items.filter((item) => item.inspectionResult > 0)
.length
? 1
: 0;
return {
...temp,
items,
isException,
originData: {
baseInfo,
tempForm,
},
};
},
// 提交按钮 // 提交按钮
submit() { submit() {
this.draft(this.activeTabIndex, false, false).then(() => { this.draft(this.activeTabIndex, false, false).then(() => {
const vaild = this.$refs.tabs.isAllVails(); const vaild = this.$refs.tabs.isAllVails();
uni.showToast({
icon: `${vaild ? "success" : "error"}`,
title: `${vaild ? "校验通过" : "请完善填写内容"}`,
});
if (vaild) { if (vaild) {
/** /**
* 校验通过, * 校验通过,
* 1.更新 store数据, * 1.更新 store 数据,
* 2. 巡检list文件 * 2. 巡检list文件
* 3.清空草稿文件数据、store草稿数据 * 3.清空草稿文件数据、store草稿数据
*/ */
const params = this.getParams();
const all_user_data = this.$store.state.all_user_data;
// const temp = params;
// temp[this.baseInfo.inspectionCode] = params;
all_user_data.push(params);
// 更新巡检list
this.$store.commit("SET_ALL_USER_DATA", all_user_data);
writeInspectionData(all_user_data);
// 更新日志
const logContent = getLogContent(LOG_TYPE_ENUM.add);
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.$store.commit("SET_DARF_DATA", {}); // 缓存[巡检信息]
writeDarf("").then((res) => {
console.log("写入草稿文件成功");
});
// 清空基础缓存信息
this.$store.commit("SET_TEMP_DATA", {}); // 缓存[巡检信息]
console.log("--提交--", params);
} }
console.log("基础信息", this.baseInfo); uni.showToast({
console.log("巡检信息", this.baseInfo); icon: `${vaild ? "success" : "error"}`,
title: `${vaild ? "校验通过" : "请完善填写内容"}`,
});
}); });
}, },
// // 表单填写结果
// isAllVails(vaild, formData) {
// console.log("--this.activeTabIndex---", this.$refs.tabs.setTabVaild);
// switch (this.activeTabIndex) {
// case 0:
// this.$refs.tabs.setTabVaild(this.activeTabIndex, vaild); // 给tab栏设置状态,全部填写会高亮icon图标
// console.log("--formData", formData);
// break;
// case 1:
// this.$refs.tabs.setTabVaild(this.activeTabIndex, vaild);
// break;
// case 2:
// this.$refs.tabs.setTabVaild(this.activeTabIndex, vaild);
// break;
// case 3:
// this.$refs.tabs.setTabVaild(this.activeTabIndex, vaild);
// break;
// case 4:
// this.$refs.tabs.setTabVaild(this.activeTabIndex, vaild);
// break;
// }
// },
// 保存草稿按钮 // 保存草稿按钮
draft(activeTabIndex, isSave = true, iSwtich = true) { draft(activeTabIndex, isSave = true, iSwtich = true) {
let refName = ""; let refName = "";
...@@ -186,14 +295,12 @@ export default { ...@@ -186,14 +295,12 @@ export default {
.setTabVaild(activeTabIndex, vaild, iSwtich) .setTabVaild(activeTabIndex, vaild, iSwtich)
.then(() => { .then(() => {
this.tempForm[activeTabIndex] = formData; this.tempForm[activeTabIndex] = formData;
console.log("--this.tempForm--", formData); // console.log("--this.tempForm--", formData);
if (isSave) { if (isSave) {
// 更新store 和 [草稿文件] 日志数据
console.log("--保存草稿--"); console.log("--保存草稿--");
this.$store.commit("SET_DARF_DATA", this.tempForm); // 缓存[巡检信息]
// // 新增日志信息 // 新增日志信息
const logContent = getLogContent(LOG_TYPE_ENUM.darf); const logContent = getLogContent(LOG_TYPE_ENUM.darf);
const log_list = this.$store.state.log_list; const log_list = this.$store.state.log_list;
log_list.push(logContent); log_list.push(logContent);
...@@ -202,9 +309,16 @@ export default { ...@@ -202,9 +309,16 @@ export default {
console.log("日志文件写入成功"); console.log("日志文件写入成功");
}); });
// 写入草稿文件 // 写入草稿文件 更新 store 草稿内容
// ...BatteryRoom.. this.$store.commit("SET_DARF_DATA", {
writeDarf(this.tempForm).then((res) => { ...this.tempForm,
...this.baseInfo,
});
// 缓存[巡检信息]
writeDarf({
...this.tempForm,
...this.baseInfo,
}).then((res) => {
console.log("写入草稿文件成功"); console.log("写入草稿文件成功");
uni.showToast({ uni.showToast({
icon: "success", icon: "success",
......
...@@ -170,7 +170,8 @@ export default { ...@@ -170,7 +170,8 @@ export default {
display: inline-block; display: inline-block;
border: 1px solid rgba(242, 242, 242, 1); border: 1px solid rgba(242, 242, 242, 1);
border-radius: 8px; border-radius: 8px;
width: 72px; padding: 0 10px;
height: 32px; height: 32px;
font-size: 12px; font-size: 12px;
color: #4a4a4a; color: #4a4a4a;
......
...@@ -202,7 +202,8 @@ export default { ...@@ -202,7 +202,8 @@ export default {
display: inline-block; display: inline-block;
border: 1px solid rgba(242, 242, 242, 1); border: 1px solid rgba(242, 242, 242, 1);
border-radius: 8px; border-radius: 8px;
width: 72px; // width: 72px;
padding: 0 10px;
height: 32px; height: 32px;
font-size: 12px; font-size: 12px;
color: #4a4a4a; color: #4a4a4a;
......
...@@ -17,8 +17,8 @@ ...@@ -17,8 +17,8 @@
</view> </view>
<!-- 描述 --> <!-- 描述 -->
<view class="descript"> <view v-if="(list[activeIndex]|| {}).value" class="descript">
<view v-if="list[activeIndex].position" class="descript-item"> <view v-if="list[activeIndex].position || []" class="descript-item">
<text class="name">巡检位置</text> <text class="name">巡检位置</text>
<text class="text">{{ <text class="text">{{
list[activeIndex].position.map((item) => item.dictLabel).join("、") list[activeIndex].position.map((item) => item.dictLabel).join("、")
...@@ -47,44 +47,17 @@ export default { ...@@ -47,44 +47,17 @@ export default {
data() { data() {
return { return {
activeIndex: 0, activeIndex: 0,
list: [ list: [],
{
name: "汇聚机房",
isVaild: false, // 校验通过
type: 1, // 枚举值
position: pad_1_1_inspection_position.rows,
descript:
"痕迹检查地面、墙壁、天花板、是否有裂痕、水渍,机房内是否有鼠患、蚁患、蟑螂活动的痕迹,温湿度取最高值,正常室温:20~25℃,湿度:40~60%。",
},
{
name: "屏蔽机房",
isVaild: false, // 校验通过
type: 1, // 枚举值
position: pad_1_2_inspection_position.rows,
descript: "UPS检查包含UPS主机、UPS输入柜、UPS输出柜。",
},
{
name: "电池间",
isVaild: false, // 校验通过
type: 1, // 枚举值
position: pad_1_3_inspection_position.rows,
descript: "痕迹检查",
},
{
name: "机房值班",
isVaild: false, // 校验通过
type: 1, // 枚举值
descript: "记录哪些人员进出机房、总计次数。",
},
{
name: "值班交接",
isVaild: false, // 校验通过
type: 1, // 枚举值
descript: "未完事项交换。",
},
],
}; };
}, },
mounted() {
this.list = this.options;
},
watch: {
options(newData) {
this.list = newData;
},
},
methods: { methods: {
tabClick(index, item) { tabClick(index, item) {
this.activeIndex = index; this.activeIndex = index;
...@@ -93,21 +66,19 @@ export default { ...@@ -93,21 +66,19 @@ export default {
}, },
/** /**
* 设置单个校验状态 * 设置单个校验状态
* @param index * @param index
* @param vaild * @param vaild
* @param iSwtich 是否自动切换到下一个tab * @param iSwtich 是否自动切换到下一个tab
*/ */
setTabVaild(index, vaild = false, iSwtich=true) { setTabVaild(index, vaild = false, iSwtich = true) {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
this.list[index].isVaild = vaild; this.list[index].isVaild = vaild;
if (iSwtich && index < this.list.length - 1) { if (iSwtich && index < this.list.length - 1) {
this.tabClick(index + 1, {}); this.tabClick(index + 1, {});
} }
resolve() resolve();
}); });
}, },
......
...@@ -167,7 +167,7 @@ export default { ...@@ -167,7 +167,7 @@ export default {
dictLabel: item.dictLabel, dictLabel: item.dictLabel,
dictValue: item.dictValue, dictValue: item.dictValue,
notes: "", // 情况摘要 notes: "", // 情况摘要
inspectionResult: 0, // 异常 inspectionResult: 0, // 异常结论
itemCode: item.dictValue, // 检查项 如:门禁 itemCode: item.dictValue, // 检查项 如:门禁
roomType, // 机房类型 roomType, // 机房类型
resultArr: [ resultArr: [
......
...@@ -43,9 +43,10 @@ import { ...@@ -43,9 +43,10 @@ import {
checkAndCreateDirectory, checkAndCreateDirectory,
createFileWithPlusIO, createFileWithPlusIO,
setSm2, setSm2,
TEST,
} from "@/utils/systemCofig"; } from "@/utils/systemCofig";
import getDateTime from "@/common/getdateTime.js"; import getDateTime from "@/common/getdateTime.js";
import { Base64 } from "js-base64";
export default { export default {
components: {}, components: {},
...@@ -64,10 +65,11 @@ export default { ...@@ -64,10 +65,11 @@ export default {
packedData() { packedData() {
this.loading = true; this.loading = true;
const userName = this.$store.state.now_user.name; const userName = this.$store.state.now_user.name;
const all_user_data = this.$store.state.all_user_data;
let timeStr = getDateTime.dateTimeStr("y-m-d h-i-s"); let timeStr = getDateTime.dateTimeStr("y-m-d h-i-s");
let fileName = `${userName}${timeStr}.txt`; let fileName = `${userName}${timeStr}.txt`;
const fileContent = setSm2(TEST); const fileContent = setSm2( Base64.encode(JSON.stringify(all_user_data)));
createFileWithPlusIO( createFileWithPlusIO(
`${SYNCHRONIZE_DATA_PAD}/同步数据`, `${SYNCHRONIZE_DATA_PAD}/同步数据`,
fileName, fileName,
...@@ -76,24 +78,25 @@ export default { ...@@ -76,24 +78,25 @@ export default {
.then((res) => { .then((res) => {
console.log("---写入成功", res); console.log("---写入成功", res);
setTimeout(() => {
uni.showToast({ uni.showToast({
title: "打包成功", title: "打包成功",
icon: "none", icon: "none",
duration: 2000, duration: 2000,
}); });
this.close();
this.loading = false; this.loading = false;
this.close() }, 2 * 1000);
}) })
.catch(() => { .catch(() => {
uni.showToast({ setTimeout(() => {
title: "打包失败", uni.showToast({
icon: "none", title: "打包失败",
duration: 2000, icon: "none",
}); duration: 2000,
this.loading = false; });
this.loading = false;
}, 2 * 1000);
}); });
}, },
}, },
......
...@@ -6,13 +6,13 @@ ...@@ -6,13 +6,13 @@
<!-- 结果 --> <!-- 结果 -->
<view class="synchronous-management-content"> <view class="synchronous-management-content">
<view class="count-tatal"> <view class="count-tatal">
<text class="num">123</text> <text class="num">{{ list.length || 0 }}</text>
<text>查询结果</text> <text>查询结果</text>
</view> </view>
<view class="month-list"> <view class="month-list">
<!-- 每月记录 --> <!-- 每月记录 -->
<view class="month-record-item" v-for="item in 20" :key="item"> <view class="month-record-item" v-for="(item, index) in list" :key="index">
<view class="seconed-title"> 2024年08月 </view> <view class="seconed-title"> 2024年08月 </view>
<view class="inspect-list"> <view class="inspect-list">
...@@ -25,7 +25,6 @@ ...@@ -25,7 +25,6 @@
<!-- 数据打包 --> <!-- 数据打包 -->
<view class="synchronous-button" @click="openDialog(true)">数据打包</view> <view class="synchronous-button" @click="openDialog(true)">数据打包</view>
<!-- 打包弹窗 --> <!-- 打包弹窗 -->
<Dialog v-show="isDialog" @close="openDialog(false)"></Dialog> <Dialog v-show="isDialog" @close="openDialog(false)"></Dialog>
...@@ -37,25 +36,30 @@ import SearchCom from "@/components/searchCom/index.vue"; ...@@ -37,25 +36,30 @@ import SearchCom from "@/components/searchCom/index.vue";
import InspectionItem from "@/components/inspectionItem/index.vue"; import InspectionItem from "@/components/inspectionItem/index.vue";
import Dialog from "./dialog.vue"; import Dialog from "./dialog.vue";
export default { export default {
components: { components: {
SearchCom, SearchCom,
InspectionItem, InspectionItem,
Dialog Dialog,
}, },
data() { data() {
return { return {
isDialog: false, // isDialog: false, //
list: [], // 展示数据
all_user_data: [], // 所有数据
}; };
}, },
mounted() {
this.all_user_data = this.list = this.$store.state.all_user_data || [];
console.log("this.all_user_data", this.all_user_data)
},
methods: { methods: {
change(e) { change(e) {
console.log("----", e); console.log("----", e);
}, },
openDialog(show){ openDialog(show) {
this.isDialog = show; this.isDialog = show;
} },
}, },
}; };
</script> </script>
......
...@@ -76,8 +76,8 @@ const store = new Vuex.Store({ ...@@ -76,8 +76,8 @@ const store = new Vuex.Store({
state.all_user_data = payload; state.all_user_data = payload;
}, },
SET_LOG_LIST(state, payload) { SET_LOG_LIST(state, payload) {
console.log("payload", payload) console.log("payload", payload);
// 保存 日志文件 // 保存 日志文件
state.log_list = payload; state.log_list = payload;
}, },
}, },
......
This source diff could not be displayed because it is too large. You can view the blob instead.
差异被折叠。
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论