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

fix(Pad): 机房巡检数据回显完成,井道数据待完善

上级 983c0c25
<template>
<view class="inspect-item">
<view class="content">
<view class="name">机房</view>
<view class="inspect-item" @click="toPage">
<view
class="content"
:class="details.synchronization == 1 ? 'synchronization' : ''"
>
<view class="name">{{ getLabel(details.inspectionType) }}</view>
<view class="info">
<view class="info-row">
<text class="title">2024-08-24-F301机房巡检记录</text>
<text class="status">待同步</text>
<view class="status alarm">
<text class="title">{{ details.recordName }}</text>
<text class="status">{{
details.synchronization == 0 ? "待同步" : "已同步"
}}</text>
<view v-if="details.isException == 1" class="status alarm">
<text class="iconfont icon-yichang1"></text>
<text>有异常</text></view
>
</view>
<view class="info-row info-row-code">
<text>编号:</text>
<text class="code-num">JF202408241002</text>
<text class="code-num">{{ details.inspectionCode }}</text>
</view>
</view>
<view class="img">
<!-- <image class="bg-img" src="../../static/img/add-img/default.png"></image> -->
<image class="bg-img" src="../../static/img/add-img/active.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>
</view>
</template>
<script>
import { pad_inspection_type } from "@/utils/dict.js";
export default {
props: {},
props: {
details: {
type: Object,
},
},
methods: {
getLabel(val) {
const temp =
(
pad_inspection_type.rows.filter((item) => item.dictValue == val)[0] ||
{}
).dictLabel || "";
return temp.length ? temp.slice(0, 2) : "";
},
toPage() {
const url =
this.details.inspectionType == 1
? "/pages/inspectionContent/inspectionContent"
: "/pages/shaftInspection/shaftInspection";
console.log(" this.details", this.details.uid);
uni.navigateTo({
url: `${url}?uid=${this.details.uid}`,
});
},
},
};
</script>
<style scoped lang="less">
......@@ -43,6 +85,7 @@ export default {
height: 84px;
box-sizing: border-box;
position: relative;
background-image: linear-gradient(-67deg, #ffab2487, #ffab2425 50%);
.name {
background: #ffab2471;
border-radius: 12px;
......@@ -111,5 +154,18 @@ export default {
}
}
}
.synchronization {
background-image: linear-gradient(-67deg, #9c9c9c, #9c9c9c 50%);
.name {
background: #7c7c7ca0;
border-radius: 12px;
color: #4a4a4a;
}
.status {
background: #e0e0e0 !important;
color: #4a4a4a !important;
}
}
}
</style>
......@@ -97,6 +97,12 @@ export default {
userName: this.$store.state.now_user.user,
};
},
onLoad(options={}) {
// options就是路由参数,它是一个对象
// this.tabIndex = ;
this.tabClick({}, options.tabIndex || 0)
console.log("---------------------", options); // 假设路由参数中有一个名为id的参数
},
methods: {
// 修改密码
updatePassword() {
......
......@@ -104,8 +104,8 @@ export default {
this.formData = {
inspectionType: "1",
inspectionCode: `JFXJ${moment().format("yyyyMMDDhhmm")}`,
recordName: `${moment().format("yyyyMMDD")}-机房巡检记录`,
inspectionTime: moment().format("yyyy-MM-DD HH:MM:ss"),
recordName: `${moment().format("yyyyMMDDhhmm")}-机房巡检记录`,
inspectionTime: moment().format("yyyy-MM-DD HH:mm:ss"),
inspectionBy: this.$store.state.now_user.name,
inspectionById: this.$store.state.now_user.id,
isException: "", // 是否有异常
......@@ -113,6 +113,7 @@ export default {
isSubmit: "", // 0 是草稿态; 1 是正式提交
conclusion: "", //结论
fillCheck: "", // tab字典的value值, 校验通过的
items: [
// {
// "itemCode": "1", // 检查项
......@@ -124,7 +125,7 @@ export default {
},
change(val) {
this.formData.recordName = `${moment().format("yyyyMMDD")}-${
this.formData.recordName = `${moment().format("yyyyMMDDhhmm")}-${
val.detail.data.text
}`;
this.formData.inspectionType = val.detail.value;
......
......@@ -33,7 +33,7 @@
<view class="base-row">
<view class="base-row-item"
><text class="name">巡检编号</text
><text class="text">{{ baseInfo.inspectionCode }}</text>
><text class="text">{{ baseInfo.inspectionCode }}</text>
</view>
<view class="base-row-item"
><text class="name">巡检日期</text
......@@ -68,13 +68,28 @@
<view class="fixed-btns">
<view class="button-group">
<view class="btn-draft btn-class" @tap="draft(activeTabIndex)">
<view
v-if="!detailsInfo.uid"
class="btn-draft btn-class"
@tap="draft(activeTabIndex)"
>
保存草稿
</view>
<view class="btn-class" @tap="submit"> 提交 </view>
</view>
</view>
</view>
<!-- 退出账号弹出 -->
<uni-popup ref="inputDialog2" type="dialog">
<uni-popup-dialog
ref="inputClose2"
mode="base"
title="确定删除巡检内容?"
@confirm="dialogInputConfirm2"
>
</uni-popup-dialog>
</uni-popup>
</view>
</template>
......@@ -149,13 +164,23 @@ export default {
tempForm: {
// 对应每个tab下的数据 [示例 0: 数据]
},
detailsInfo: {}, // 详情
};
},
onLoad() {
onLoad(options) {
this.init();
if (options.uid) {
this.getDetails(options.uid);
}
},
mounted() {
this.baseInfo = this.$store.state.temp_data;
if (this.detailsInfo.inspectionType) {
this.tabList.forEach((item, index) => {
this.setComponentData(index, this.tempForm[index]);
});
} else {
this.baseInfo = this.$store.state.temp_data;
}
},
methods: {
......@@ -164,18 +189,84 @@ export default {
this.tabList[index].value = item.dictValue;
});
},
// 删除
deleteClick() {
// 回显数据
getDetails(uid) {
const all_data = this.$store.state.all_data || [];
const detailsInfo = all_data.filter((item) => item.uid == uid)[0] || {};
console.log("--detailsInfo--", detailsInfo);
this.baseInfo = detailsInfo.originData.baseInfo;
this.tempForm = detailsInfo.originData.tempForm;
this.detailsInfo = detailsInfo;
},
// 回显组件数据
setComponentData(activeTabIndex, componentData) {
let refName = "";
switch (activeTabIndex) {
case 0:
refName = "GatherDataCenter";
break;
case 1:
refName = "ShieldedComputerRoom";
break;
case 2:
refName = "BatteryRoom";
break;
case 3:
refName = "ComputerRoomDuty";
break;
case 4:
refName = "DutyHandover";
break;
}
this.$refs[refName].setForm(componentData);
},
//--弹出对话框
dialogInputConfirm2() {
const all_data = this.$store.state.all_data;
const detailsInfo = this.detailsInfo;
const tempAllData = all_data.filter(
(element) => element.uid != detailsInfo.uid
);
// 更新巡检list
this.$store.commit("SET_ALL_DATA", tempAllData);
writeInspectionData(tempAllData);
// 更新日志
const log_list = this.$store.state.log_list;
const logContent = getLogContent(LOG_TYPE_ENUM.delete);
log_list.push(logContent);
this.$store.commit("SET_LOG_LIST", log_list);
addLog(log_list).then((res) => {
console.log("日志文件写入成功");
});
uni.showToast({
title: "删除",
icon: `success`,
title: `删除成功`,
});
uni.redirectTo({
url: "/pages/home/home?tabIndex=1",
success() {
uni.hideLoading();
},
});
},
// 删除
deleteClick() {
this.$refs.inputDialog2.open();
},
lookTable() {
uni.navigateTo({
url: "/pages/report/sampleTable"
})
},
uni.navigateTo({
url: "/pages/report/sampleTable",
});
},
// tab选中change 时间
changeTab(index, item) {
......@@ -219,7 +310,7 @@ export default {
}
});
console.log("---getParams", tempItems);
// console.log("---getParams", tempItems);
const items = tempItems.map((item) => {
return {
......@@ -263,9 +354,20 @@ export default {
const params = this.getParams();
const all_data = this.$store.state.all_data;
all_data.push(params);
let logContent = "";
// 新增 or 编辑
if (params.uid) {
const index = all_data.findIndex(
(element) => element.uid == params.uid
);
all_data[index] = params;
logContent = getLogContent(LOG_TYPE_ENUM.edit);
} else {
params.uid = new Date().getTime(); // 唯一标识 pad 端使用
all_data.push(params);
logContent = getLogContent(LOG_TYPE_ENUM.add);
}
// console.log("--params--",all_data, params)
// return
......@@ -275,11 +377,10 @@ export default {
writeInspectionData(all_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("日志文件写入成功");
});
......@@ -300,13 +401,16 @@ export default {
icon: `${vaild ? "success" : "error"}`,
title: `${vaild ? "校验通过" : "请完善填写内容"}`,
});
if (!vaild) {
return;
}
uni.redirectTo({
url: "/pages/home/home?tabIndex=1",
success() {
uni.hideLoading();
},
});
url: "/pages/home/home?tabIndex=1",
success() {
uni.hideLoading();
},
});
});
},
......@@ -484,7 +588,7 @@ export default {
background-image: linear-gradient(180deg, #3773f6 0%, #2c57f6 99%);
box-shadow: 0px 10px 24px 0px rgba(51, 104, 246, 0.24);
border-radius: 27px;
font-size:18px;
font-size: 18px;
color: #ffffff;
text-align: center;
font-weight: 400;
......
......@@ -106,7 +106,9 @@ export default {
},
methods: {
// 回显数据
setForm() {},
setForm(componentData) {
this.form = componentData;
},
clickQuick(item) {
this.form.roomWatch = `${this.form.roomWatch}${item.text}`;
......
......@@ -34,20 +34,24 @@
</view>
</uni-forms-item>
<view class="user-info">
<uni-forms-item class="row-item" label="交班人" >
<text class="text">{{ form.handoverPerson }}</text>
</uni-forms-item>
<uni-forms-item class="row-item" required label="接班人" name="successor">
<uni-easyinput
type="text"
v-model="form.successor"
placeholder="请输入"
/>
</uni-forms-item>
</view>
<view class="user-info">
<uni-forms-item class="row-item" label="交班人">
<text class="text">{{ form.handoverPerson }}</text>
</uni-forms-item>
<uni-forms-item
class="row-item"
required
label="接班人"
name="successor"
>
<uni-easyinput
type="text"
v-model="form.successor"
placeholder="请输入"
/>
</uni-forms-item>
</view>
</uni-forms>
</view>
</template>
......@@ -137,8 +141,9 @@ export default {
this.form.handoverPerson = this.$store.state.now_user.user;
},
// 回显数据
setForm() {},
setForm(componentData) {
this.form = componentData;
},
clickQuick(item) {
this.form.dutyHandover = `${this.form.dutyHandover}${item.text}`;
// this.quickTextList[index].isActive = item.isActive;
......@@ -215,10 +220,10 @@ export default {
}
}
.user-info{
.user-info {
display: flex;
.uni-forms-item{
flex: 1;;
.uni-forms-item {
flex: 1;
display: flex;
flex-direction: row;
}
......
......@@ -47,7 +47,6 @@
<!-- 异常状态时显示 -->
<uni-forms-item
v-if="item.inspectionResult == 1"
required
class="row-item"
label="情况摘要"
......@@ -69,11 +68,7 @@ import {
* 汇集机房
*/
export default {
props: {
form: {
type: Object,
},
},
props: {},
data() {
return {
list: [],
......@@ -181,7 +176,10 @@ export default {
console.log("---temp", temp);
},
// 回显数据
setForm() {},
setForm(componentData) {
console.log("-componentData---", componentData);
this.list = componentData;
},
// 获取数据
getForm() {
const temp = this.list.map((item) => {
......@@ -214,10 +212,10 @@ export default {
return Promise.all(temp).then((res) => {
const allVaildList = res.filter((item) => item.result);
const formData= this.getForm();
const formData = this.getForm();
return {
vaild: this.list.length == allVaildList.length,
formData
formData,
};
});
},
......
......@@ -47,7 +47,6 @@
<!-- 异常状态时显示 -->
<uni-forms-item
v-if="item.inspectionResult == 1"
required
class="row-item"
label="情况摘要"
......@@ -69,11 +68,7 @@
* 屏蔽机房巡检
*/
export default {
props: {
form: {
type: Object,
},
},
data() {
return {
list: [],
......@@ -181,7 +176,9 @@
console.log("---temp", temp);
},
// 回显数据
setForm() {},
setForm(componentData) {
this.list = componentData
},
// 获取数据
getForm() {
const temp = this.list.map((item) => {
......
......@@ -18,7 +18,7 @@
<!-- 描述 -->
<view v-if="(list[activeIndex]|| {}).value" class="descript">
<view v-if="list[activeIndex].position || []" class="descript-item">
<view v-if="(list[activeIndex].position || []).length" class="descript-item">
<text class="name">巡检位置</text>
<text class="text">{{
list[activeIndex].position.map((item) => item.dictLabel).join("、")
......
......@@ -31,6 +31,7 @@ import {
checkAndCreateDirectory,
createFileWithPlusIO,
TEST,
TEST_2X
} from "@/utils/systemCofig";
import {
......@@ -62,8 +63,7 @@ export default {
mounted() {
// let timeStr = getDateTime.dateTimeStr('y-m-d h-i-s')
// let fileName = "用户名" + timeStr + '.txt'
// console.log("---xxxxx", TEST)
// const fileContent = this.setSm2(TEST)
// const fileContent = this.setSm2(TEST_2X)
// console.log("---加密内容", fileContent)
// createFileWithPlusIO(`${SYNCHRONIZE_DATA_PAD}/同步数据`, fileName,fileContent ).then(res => {
// console.log("---写入成功", res)
......
......@@ -196,8 +196,12 @@ export default {
this.list = temp;
console.log("---temp", temp);
},
// 回显数据
setForm() {},
// 回显数据
setForm(componentData) {
console.log("-componentData---", componentData);
this.list = componentData.temp;
this.form.conclusion = componentData.conclusion
},
// 获取数据
getForm() {
const temp = this.list.map((item) => {
......
......@@ -107,28 +107,64 @@ export default {
tempForm: {
// 对应每个tab下的数据 [示例 0: 数据]
},
detailsInfo: {}, // 详情
};
},
onLoad() {},
onLoad(options) {
if (options.uid) {
this.getDetails(options.uid);
}
},
mounted() {
this.baseInfo = this.$store.state.temp_data;
this.init();
console.log("---baseInfo-", this.baseInfo);
// this.baseInfo = this.$store.state.temp_data;
// console.log("---baseInfo-", this.baseInfo);
this.init().then(() => {
if (this.detailsInfo.inspectionType) {
this.tabList.forEach((item, index) => {
this.setComponentData(item.refName, this.tempForm[index]);
});
} else {
this.baseInfo = this.$store.state.temp_data;
}
this.tabList.forEach((item, index) => {
this.setComponentData(item.refName, this.tempForm[index]);
});
});
},
methods: {
init() {
this.tabList = pad_2_1_inspection_position.rows.map((item, index) => {
return {
name: item.dictLabel,
value: item.dictValue,
isVaild: false, // 校验通过
// type: 1, // 枚举值
position: pad_2_1_inspection_position.rows,
refName: `TabContentItem_${index}`,
};
return new Promise((resolve, reject) => {
this.tabList = pad_2_1_inspection_position.rows.map((item, index) => {
return {
name: item.dictLabel,
value: item.dictValue,
isVaild: false, // 校验通过
// type: 1, // 枚举值
position: pad_2_1_inspection_position.rows,
refName: `TabContentItem_${index}`,
};
});
resolve();
});
},
// 回显数据
getDetails(uid) {
const all_data = this.$store.state.all_data || [];
const detailsInfo = all_data.filter((item) => item.uid == uid)[0] || {};
this.baseInfo = detailsInfo.originData.baseInfo;
this.tempForm = detailsInfo.originData.tempForm;
this.detailsInfo = detailsInfo;
},
// 回显组件数据
setComponentData(refName, componentData) {
console.log("--refs--");
console.log("--refName--", refName);
// this.$refs[refName][0].setForm(componentData);
},
//--弹出对话框
dialogInputConfirm2() {
uni.redirectTo({
......@@ -222,6 +258,7 @@ export default {
items: [],
synchronization: 0, // 是否导出过
submitTime: moment().format("yyyy-MM-DD"), // 记录提交时间
originData: {
baseInfo: this.baseInfo,
tempForm: this.tempForm,
......@@ -235,14 +272,30 @@ export default {
// tempItem.push(temp);
// all_data[time] = tempItem;
all_data.push(temp);
// params.uid = new Date().getTime(); // 唯一标识 pad 端使用
// all_data.push(temp);
let logContent = "";
// 新增 or 编辑
if (params.uid) {
const index = all_data.findIndex(
(element) => element.uid == params.uid
);
all_data[index] = temp;
logContent = getLogContent(LOG_TYPE_ENUM.edit);
} else {
temp.uid = new Date().getTime(); // 唯一标识 pad 端使用
all_data.push(temp);
logContent = getLogContent(LOG_TYPE_ENUM.add);
}
// 更新巡检list
this.$store.commit("SET_ALL_DATA", all_data);
writeInspectionData(all_data);
// 更新日志
const logContent = getLogContent(LOG_TYPE_ENUM.add);
// 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);
......@@ -258,6 +311,7 @@ export default {
// 清空基础缓存信息
this.$store.commit("SET_TEMP_DATA", {}); // 缓存[巡检信息]
console.log("--提交--", params);
}
......@@ -266,6 +320,10 @@ export default {
title: `${vaild ? "提交成功" : "请完善填写内容"}`,
});
if (!vaild) {
return;
}
uni.redirectTo({
url: "/pages/home/home?tabIndex=1",
success() {
......
......@@ -24,7 +24,7 @@
</view>
<view class="row-item bottom-row">
<button class="button" :loading="loading" @click="packedData">
<button class="button" :loading="loading" @click="clickHandle">
数据打包
</button>
</view>
......@@ -46,44 +46,59 @@ import {
} from "@/utils/systemCofig";
import getDateTime from "@/common/getdateTime.js";
import { Base64 } from "js-base64";
import { writeInspectionData } from "@/utils/IoReadingAndWriting.js";
export default {
components: {},
data() {
return {
loading: false,
all_data: []
all_data: [],
};
},
mounted() {
// const all_data = this.$store.state.all_data;
this.all_data = this.$store.state.all_data || [];
// const all_data = this.$store.state.all_data;
this.all_data = this.$store.state.all_data || [];
},
methods: {
change(e) {
console.log("----", e);
},
change(e) {},
close() {
this.$emit("close");
},
packedData() {
this.loading = true;
clickHandle() {
const userName = this.$store.state.now_user.name;
const all_data = this.$store.state.all_data;
const all_data = this.all_data;
console.log("-同步数据--", all_data);
let timeStr = getDateTime.dateTimeStr("y-m-d h-i-s");
let fileName = `${userName}${timeStr}.txt`;
const fileContent = setSm2( Base64.encode(JSON.stringify(all_data)));
createFileWithPlusIO(
`${SYNCHRONIZE_DATA_PAD}/同步数据`,
fileName,
fileContent
)
.then((res) => {
console.log("---写入成功", res);
let JFXJ_DATA_FILE_NAME = `${userName}_JFXJ_${timeStr}.txt`;
let JDXJ_DATA_FILE_NAME = `${userName}_JDXJ_${timeStr}.txt`;
const JFXJ_DATA = all_data
.filter((item) => item.inspectionType == 1)
.map((item) => {
return {
...item,
originData: [],
};
}); // 机房数据类型是 1
const JDXJ_DATA = all_data.filter((item) => item.inspectionType == 2); // 井道数据类型是 2
this.loading = true;
Promise.all([
this.packedData(JFXJ_DATA, JFXJ_DATA_FILE_NAME),
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: "打包成功",
......@@ -105,6 +120,15 @@ export default {
}, 2 * 1000);
});
},
packedData(content, fileName) {
const fileContent = setSm2(content);
return createFileWithPlusIO(
`${SYNCHRONIZE_DATA_PAD}/发送数据`,
fileName,
fileContent
);
},
},
};
</script>
......
......@@ -23,6 +23,7 @@
<InspectionItem
v-for="ele in item.list"
:key="ele.inspectionCode"
:details="ele"
/>
</view>
</view>
......@@ -66,6 +67,7 @@ export default {
methods: {
init() {
const all_data = this.$store.state.all_data || [];
console.log("---all_data-", all_data)
const tempAllData = {};
all_data.forEach((item) => {
const val = tempAllData[item.submitTime] || [];
......@@ -81,8 +83,6 @@ export default {
const { inspectionTime = [] } = this.searchForm;
const startTime = inspectionTime[0];
const endTime = inspectionTime[1];
console.log("--startTime-", startTime);
console.log("--endTime-", startTime);
// 第一步: 筛选有效的时间范围
const timeFrame = keys.filter((key) => {
......@@ -96,7 +96,6 @@ export default {
}
});
console.log("--timeFrame-", timeFrame);
// 第二步: 根据搜索条件过滤
const list = timeFrame.map((key) => {
......@@ -110,7 +109,8 @@ export default {
// console.log("timeFramea", timeFrame);
// console.log("this.all_data", all_data);
// console.log("this.list", list);
console.log("list 数据----", list);
this.countNum = 0;
list.forEach((item) => {
this.countNum += item.list.length;
});
......
This source diff could not be displayed because it is too large. You can view the blob instead.
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论