提交 38f620e9 authored 作者: caodi\cd's avatar caodi\cd

fix:结构优化

上级 1601fb0f
......@@ -2,27 +2,22 @@
<view class="inspect-item" @click="toPage">
<view class="content" :class="details.synchronization == 1 ? 'synchronization' : ''">
<view class="name">{{
details.synchronization == 0 ? "待同步" : "已同步"
details.isSubmit == 0 ? "编辑中" :details.synchronization == 0 ? "待同步" : "已同步"
}}</view>
<view class="info">
<view class="info-row">
<text class="title">{{ getLabel(details.inspectionType) }}</text>
<text class="status">{{
details.synchronization == 0 ? "待同步" : "已同步"
details.isException>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">admin</text>
<text class="code-num">{{details.inspectionBy}}</text>
<text>编号:</text>
<text class="code-num">{{ details.inspectionCode }}</text>
<text>巡检日期:</text>
<text class="code-num">2025-01-29</text>
<text class="code-num">{{ details.submitTime }}</text>
</view>
</view>
<view class="img">
......@@ -46,6 +41,10 @@
type: Boolean,
},
},
mounted() {
console.log(" this.details", this.details)
},
methods: {
getLabel(val) {
const temp =
......@@ -60,7 +59,7 @@
`/pages/inspectionContent/inspectionContent?isDisable=${
this.isDisable ? 1 : 0
}` :
`/pages/shaftInspection/shaftInspectionNew?isDisable=${
`/pages/shaftInspection/shaftInspectionList?isDisable=${
this.isDisable ? 1 : 0
}`;
......@@ -73,26 +72,27 @@
</script>
<style scoped lang="less">
.inspect-item {
width: calc(50% - 8px);
margin-bottom: 16px;
width: calc(50% - 6.4px);
margin-bottom: 12.8px;
.content {
background: #fff;
border: 0.4px solid rgba(224, 224, 224, 1);
border-radius: 12px;
padding: 12px;
border: 0.32px solid rgba(224, 224, 224, 1);
border-radius: 9.6px;
padding: 9.6px;
display: flex;
align-items: center;
height: 78px;
height: 62.4px;
box-sizing: border-box;
position: relative;
.name {
background: #ffab2423;
border-radius: 12px;
width: 54px;
height: 54px;
margin-right: 10px;
border-radius: 9.6px;
font-size: 11.2px;
width: 43.2px;
height: 43.2px;
margin-right: 8px;
display: flex;
justify-content: center;
align-items: center;
......@@ -103,52 +103,53 @@
.info-row {
display: flex;
align-items: center;
margin-bottom: 8px;
margin-bottom: 6.4px;
&:last-of-type {
margin: 0;
}
.title {
font-size: 12px;
font-size: 11.2px;
color: #000000;
font-weight: bold;
margin-right: 8px;
margin-right: 6.4px;
}
.status {
padding: 2px 4px;
font-size: 12px;
padding: 0 6.4px;
font-size: 9.6px;
color: #ffffff;
text-align: center;
line-height: 20px;
line-height: 16px;
font-weight: 400;
background: #ffab24;
border-radius: 3px;
border-radius: 8px;
}
.alarm {
margin-left: 8px;
margin-left: 6.4px;
background: rgba(255, 105, 82, 0.1);
font-size: 12px;
font-size: 11.2px;
color: #ff6952;
text-align: center;
line-height: 20px;
line-height: 16px;
font-weight: 400;
}
}
.info-row-code {
font-size: 12px;
font-size: 11.2px;
color: #7c7c7c;
font-weight: 400;
.code-num {
font-size: 12px;
font-size: 11.2px;
color: #000000;
font-weight: 400;
margin-right: 10px;
&:last-child{
margin-right: 19.2px;
&:last-child {
margin-right: 0;
}
}
......@@ -162,8 +163,10 @@
transform: translateY(-50%);
.bg-img {
width: 80px;
height: 80px;
width: 64px;
/* 80px * 0.8 */
height: 64px;
/* 80px * 0.8 */
}
}
}
......@@ -173,7 +176,8 @@
.name {
background: #9c9c9c16;
border-radius: 12px;
border-radius: 9.6px;
/* 12px * 0.8 */
color: #4a4a4a;
}
......
<template>
<!-- 井道巡检列表 -->
<view class="container">
<uni-nav-bar :fixed="true" background-color="rgba(214, 240, 255, 0.0)" status-bar rightWidth="300">
<uni-nav-bar
:fixed="true"
background-color="rgba(214, 240, 255, 0.0)"
status-bar
rightWidth="300"
>
<block slot="left">
<view class="uni-nav-bar-text" @click="back">
<text class="iconfont icon-Arrow-Left"></text>
......@@ -18,11 +23,16 @@
<view class="profile-box">
<view class="profile-left">
<view class="avatar">
<image src="@/static/img/add-img/home1.png" mode="aspectFit"></image>
<image
src="@/static/img/add-img/home1.png"
mode="aspectFit"
></image>
</view>
<view class="info">
<view class="username">{{ userInfo.user }}</view>
<view class="number">巡检编号:<text class="value">{{inspectionCode}}</text></view>
<view class="number"
>巡检编号:<text class="value">{{ inspectionCode }}</text></view
>
</view>
</view>
<view class="profile-right">
......@@ -35,8 +45,12 @@
<view class="content-box">
<!-- 左侧模块 -->
<view class="left-side">
<view v-for="(tab, index) in tabs" :key="index" :class="['tab-item', { active: activeTab === index }]"
@click="getActiveTab(index)">
<view
v-for="(tab, index) in tabs"
:key="index"
:class="['tab-item', { active: activeTab === index }]"
@click="getActiveTab(index)"
>
{{ tab }}
</view>
</view>
......@@ -45,24 +59,40 @@
<view class="right-side">
<!-- 第一部分:按钮 -->
<view class="button-group">
<view class="button">已巡检{{ inspectedCount }}个井道</view>
<view class="button">已巡检{{ inspectionNumber }}个井道</view>
<view class="button">请点击“需巡检井道”执行巡检</view>
</view>
<!-- 第二部分:卡片组 -->
<view class="card-box">
<view class="card-group" v-for="(item, index) in cardsInfo" :key="index">
<view
class="card-group"
v-for="(item, index) in cardsInfo"
:key="index"
>
<view class="card-title">{{ item.name }}</view>
<view class="card-list">
<view v-for="position in item.position" :key="position.dictValue" class="card"
@click="toShaftInspection(item.value,position.dictValue,item.name+position.dictLabel)">
<view
v-for="position in item.position"
:key="position.dictValue"
class="card"
@click="
toShaftInspection(
item.value,
position.dictValue,
item.name + position.dictLabel
)
"
>
<view class="card-content">
<view class="status-line">
<image src="/static/status-icon.png" class="status-icon" />
<text class="status-text">巡检中</text>
<text class="status-text">{{position.statusLable}}</text>
</view>
<view class="info-line">
<text class="info-text">{{ item.name }}{{position.dictLabel}}</text>
<text class="info-text"
>{{ item.name }}{{ position.dictLabel }}</text
>
</view>
</view>
</view>
......@@ -75,33 +105,36 @@
</template>
<script>
import moment from "moment";
import Tabs from "./model/tabs.vue";
import TabContentItem from "./model/tabContentItem.vue";
import {
import moment from "moment";
import Tabs from "./model/tabs.vue";
import TabContentItem from "./model/tabContentItem.vue";
import {
addLog,
getLogContent,
LOG_TYPE_ENUM,
writeDarf,
writeInspectionData,
} from "@/utils/IoReadingAndWriting.js";
import {
pad_2_1_inspection_position,
pad_2_1_floor
} from "@/utils/dict.js";
import {
getInspectionDetails,
getDarft
} from "@/request/index.js";
export default {
} from "@/utils/IoReadingAndWriting.js";
import { pad_2_1_inspection_position, pad_2_1_floor } from "@/utils/dict.js";
import { getInspectionDetails, getDarft } from "@/request/index.js";
export default {
data() {
return {
tabs: ["所有井道"], // 选项卡内容
activeTab: 0, // 默认选中的选项卡
inspectedCount: 5, // 已巡检的井道数量
cards: ["A座-1楼", "A座-2楼", "A座-3楼", "A座-4楼", "A座-5楼", "A座-6楼", "A座-7楼", "A座-8楼"], // 卡片内容
inspectionCode: `JFXJ${moment().format("yyyyMMDDHHmmss")}${(Math.floor(Math.random() * 900) + 100)}`,
inspectionNumber: 0, // 已巡检的井道数量
cards: [
"A座-1楼",
"A座-2楼",
"A座-3楼",
"A座-4楼",
"A座-5楼",
"A座-6楼",
"A座-7楼",
"A座-8楼",
], // 卡片内容
inspectionCode: "",
cardsInfo: [], //卡片数据
tabList: [],
activeTabIndex: 0,
......@@ -111,6 +144,7 @@
},
detailsInfo: {}, // 详情
isDisable: false, // 禁用
uid: "",
};
},
computed: {
......@@ -119,50 +153,26 @@
},
isOperationPermissions() {
// 是否有操作权限
const {
uid,
createByName
} = this.detailsInfo;
const { uid, createByName } = this.detailsInfo;
return !uid || (uid && createByName == this.userInfo.user);
},
},
onLoad(options) {
this.isDisable = options.isDisable == 1 ? true : false;
console.log("options.uid", options.uid);
if (options.uid) {
this.uid = options.uid;
this.getDetails(options.uid);
} else if (options.isDarf) {
// 获取草稿数据
uni.showLoading();
getDarft()
.then((res) => {
const darf_data = res || {};
this.baseInfo = darf_data.originData.baseInfo;
this.tempForm = darf_data.originData.tempForm;
this.detailsInfo = darf_data;
uni.hideLoading();
} else {
this.init();
})
.catch((error) => {
uni.showToast({
title: error.msg,
icon: "none",
duration: 1000,
});
uni.hideLoading();
});
}
},
mounted() {
this.init();
},
mounted() {},
methods: {
init() {
return new Promise((resolve, reject) => {
this.tabList = pad_2_1_inspection_position.rows.map((item, index) => {
this.tabs.push(item.dictLabel)
this.tabs.push(item.dictLabel);
return {
name: item.dictLabel,
value: item.dictValue,
......@@ -173,8 +183,11 @@
descript: "检查内容包括门禁、卫生、设备告警。",
};
});
this.cardsInfo = this.tabList
console.log("this.tabList", this.tabList)
this.cardsInfo = this.tabList;
this.inspectionCode = `JFXJ${moment().format("yyyyMMDDHHmmss")}${
Math.floor(Math.random() * 900) + 100
}`;
console.log("this.tabList", this.tabList);
if (this.detailsInfo.inspectionType) {
const fillCheck = this.detailsInfo.fillCheck.split(",");
......@@ -192,11 +205,12 @@
});
},
getActiveTab(index) {
this.activeTab = index
this.activeTab = index;
console.log("this.activeTab",this.activeTab)
if (this.activeTab == 0) {
this.cardsInfo = this.tabList
this.cardsInfo = this.tabList;
} else {
this.cardsInfo = [this.tabList[index + 1]]
this.cardsInfo = [this.tabList[index - 1]];
}
},
// 回显数据
......@@ -205,15 +219,19 @@
getInspectionDetails(uid)
.then((res) => {
const detailsInfo = res;
console.log("detailsInfo", detailsInfo);
this.baseInfo = detailsInfo.originData.baseInfo;
this.tempForm = detailsInfo.originData.tempForm;
this.detailsInfo = detailsInfo;
this.inspectionNumber = detailsInfo.inspectionNumber
this.inspectionCode = detailsInfo.inspectionCode;
this.cardsInfo =this.tabList = detailsInfo.originData;
console.log("this.cardsInfo",this.cardsInfo)
this.cardsInfo.forEach((item) => {
this.tabs.push(item.name);
});
this.isDisable = this.isDisable || detailsInfo.synchronization == 1; // 是否禁用 1:已同步数据 0: 未同步数据
uni.hideLoading();
this.init();
})
.catch((error) => {
uni.showToast({
......@@ -228,70 +246,6 @@
setComponentData(refName, componentData) {
this.$refs[refName][0] && this.$refs[refName][0].setForm(componentData);
},
//--弹出对话框
dialogInputConfirm2() {
// uni.redirectTo({
// url: "/pages/home/home?tabIndex=1",
// success: () => {
const userInfo = this.userInfo;
const all_data = this.$store.state.all_data;
const detailsInfo = this.detailsInfo;
const baseInfo = this.baseInfo;
const tempAllData = all_data.filter(
(element) => element.uid != detailsInfo.uid
);
// console.log(
// "---删除内容",
// all_data.filter((element) => element.uid == detailsInfo.uid)
// );
// 更新巡检list
this.$store.commit("SET_ALL_DATA", tempAllData);
const inspectList = tempAllData.filter(
(item) => item.createByName == userInfo.user
);
writeInspectionData(inspectList, userInfo.user);
if (!detailsInfo.uid) {
// 清空草稿数据
this.$store.commit("SET_DARF_DATA", {}); // 缓存[巡检信息]
writeDarf("").then((res) => {
console.log("写入草稿文件成功");
});
}
// 更新日志
const log_list = this.$store.state.log_list;
const logContent = getLogContent(
LOG_TYPE_ENUM.delete,
`${baseInfo.recordName}(${baseInfo.inspectionCode})`,
"巡检模块"
);
logContent.inspectionType = baseInfo.inspectionType;
log_list.push(logContent);
this.$store.commit("SET_LOG_LIST", log_list);
addLog(log_list).then((res) => {
console.log("日志文件写入成功");
});
uni.showToast({
icon: `success`,
title: `删除成功`,
});
uni.redirectTo({
url: "/pages/home/home?tabIndex=1",
success() {
uni.hideLoading();
},
});
// },
// });
},
// 删除
deleteClick() {
this.$refs.inputDialog2.open();
......@@ -311,208 +265,22 @@
// 跳转到具体的井道
toShaftInspection(value, dictValue, location) {
uni.navigateTo({
url: `/pages/shaftInspection/shaftInspectionNew?value=${value}&dictValue=${dictValue}&inspectionCode=${this.inspectionCode}&location=${location}`,
url: `/pages/shaftInspection/shaftInspectionNew?value=${value}&dictValue=${dictValue}&inspectionCode=${this.inspectionCode}&location=${location}&uid=${this.uid}`,
});
},
back() {
uni.navigateBack();
},
// 处理提交数据
getParams() {
const baseInfo = this.baseInfo;
const tempForm = this.tempForm;
const fillCheck = this.tabList
.filter((item) => item.isVaild)
.map((item) => item.value)
.join(",");
const temp = this.tabList.map((item, index) => {
const items = ((tempForm[index] || {}).temp || []).map((ele) => {
return {
itemCode: ele.itemCode,
measuredData: ele.measuredData,
inspectionResult: ele.inspectionResult,
};
});
// 一个tab栏下的数据,是否有异常
const isException = ((tempForm[index] || {}).temp || []).filter(
(item) => item.inspectionResult > 0
).length ?
1 :
0;
return {
...baseInfo,
isSubmit: 1,
conclusion: (tempForm[index] || {}).conclusion || "",
fillCheck,
position: item.value,
isException,
items,
};
});
const item = {
...temp[0],
isSubmit: 0,
isException: temp.filter((item) => item.isException > 0).length ? 1 : 0, // 总的数据
items: [],
synchronization: 0, // 是否导出过
submitTime: moment().format("yyyy-MM-DD"), // 记录提交时间
submitMonth: moment().format("yyyy-MM"), // 记录提交月份
originData: {
baseInfo,
tempForm,
},
};
item[baseInfo.inspectionCode] = temp;
return item;
},
// 提交按钮
submit() {
this.draft(this.activeTabIndex, false, false).then(() => {
const vaild = this.$refs.tabs.isAllVails();
if (vaild) {
/**
* 校验通过,
* 1.更新 store 数据,
* 2. 巡检list文件
* 3.清空草稿文件数据、store草稿数据
*/
const params = this.getParams();
const all_data = this.$store.state.all_data;
const uid = this.detailsInfo.uid;
params.isSubmit = 1;
let logContent = "";
// 新增 or 编辑
if (uid) {
const index = all_data.findIndex((element) => element.uid == uid);
params.uid = uid;
all_data[index] = params;
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,
`${params.recordName}(${params.inspectionCode})`,
"巡检模块"
);
}
// 更新巡检list
const userInfo = this.userInfo;
this.$store.commit("SET_ALL_DATA", all_data);
const inspectList = all_data.filter(
(item) => item.createByName == userInfo.user
);
writeInspectionData(inspectList, userInfo.user);
// 更新日志
const log_list = this.$store.state.log_list;
logContent.inspectionType = params.inspectionType;
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", {}); // 缓存[巡检信息]
}
uni.showToast({
icon: `${vaild ? "success" : "error"}`,
title: `${vaild ? "提交成功" : "请完善填写内容"}`,
});
if (!vaild) {
return;
}
uni.redirectTo({
url: "/pages/home/home?tabIndex=1",
success() {
uni.hideLoading();
},
});
});
},
// 保存草稿按钮
draft(activeTabIndex, isSave = true, iSwtich = true) {
let refName = this.tabList[activeTabIndex].refName;
return new Promise((resolve, reject) => {
this.$refs[refName][0].vaildForm().then(({
vaild,
formData
}) => {
this.$refs.tabs
.setTabVaild(activeTabIndex, vaild, iSwtich)
.then(() => {
this.tempForm[activeTabIndex] = formData;
if (isSave) {
// 写入草稿文件 更新 store 草稿内容
const params = this.getParams();
params.isSubmit = 0;
this.$store.commit("SET_DARF_DATA", params); // 缓存[巡检信息]
writeDarf(params).then((res) => {
console.log("写入草稿文件成功");
uni.showToast({
icon: "success",
title: "保存草稿成功",
});
});
// 新增日志信息
const logContent = getLogContent(
LOG_TYPE_ENUM.darf,
`${params.recordName}(${params.inspectionCode})`,
"巡检模块"
);
const log_list = this.$store.state.log_list;
logContent.inspectionType = params.inspectionType;
log_list.push(logContent);
this.$store.commit("SET_LOG_LIST", log_list);
addLog(log_list).then((res) => {
console.log("日志文件写入成功");
});
}
resolve();
});
});
});
},
},
};
};
</script>
<style lang="less" scoped>
/* 导航栏样式 */
.uni-nav-bar-text {
/* 导航栏样式 */
.uni-nav-bar-text {
height: 28.8px;
width: 28.8px;
background: #ffffff;
......@@ -526,13 +294,13 @@
font-size: 16px;
line-height: 28.8px;
}
}
}
.nav-right {
.nav-right {
width: 192px;
}
}
.header-buttons {
.header-buttons {
display: flex;
align-items: center;
margin-left: auto; // 将按钮组推到最右侧
......@@ -549,9 +317,9 @@
line-height: 28.8px;
font-weight: 400;
}
}
}
.container {
.container {
background-image: linear-gradient(115deg, #e8f0fb 0%, #e1ebfa 100%);
padding: 0 25.6px;
height: 100vh;
......@@ -612,7 +380,7 @@
.number {
font-size: 12.8px;
color: #4A4A4A;
color: #4a4a4a;
line-height: 22.4px;
font-weight: 400;
......@@ -620,7 +388,6 @@
color: #000000;
}
}
}
}
......@@ -664,7 +431,6 @@
background-color: #ffffff;
display: flex;
/* 左侧模块 */
.left-side {
width: 120px;
......@@ -767,7 +533,7 @@
.status-text {
font-size: 10.5px;
color: #7C7C7C;
color: #7c7c7c;
text-align: center;
line-height: 16.5px;
font-weight: 400;
......@@ -788,5 +554,5 @@
}
}
}
}
}
</style>
......@@ -77,16 +77,15 @@
<view class="form-item">
<text class="form-label"><text class="required">*</text>情况摘要</text>
<input class="input-box" v-model="list[activeTab]&&list[activeTab].conclusion" placeholder="请输入情况摘要" />
<input class="input-box" v-model="list[activeTab] && list[activeTab].conclusion" placeholder="请输入情况摘要" />
</view>
<view class="form-item">
<text class="form-label">现场照片</text>
<view class="photo-box">
<view class="photo-container">
<view @click="takePhoto" class="photo-btn">
+
</view>
<view v-for="(photo, index) in list[activeTab]&&list[activeTab].photos" :key="index" class="photo-item">
<view @click="takePhoto" class="photo-btn"> + </view>
<view v-for="(photo, index) in list[activeTab] &&
list[activeTab].photos" :key="index" class="photo-item">
<image :src="photo" class="photo"></image>
<text class="delete-photo" @click="deletePhoto(index)">×</text>
</view>
......@@ -105,15 +104,14 @@
</button>
</view> -->
<view class="module submit-module">
<button class="action-btn" @click="submit(false)">暂存</button>
<button class="action-btn" @click="submit(0)">暂存</button>
<button v-if="isSubmitEnabled" class="action-btn complete-btn" @click="submit">
完成巡检
</button>
<button v-else class="action-btn complete-btn" @click="closePopup">下一项
</button>
<button class="action-btn complete-btn" @click="submit(true)">
完成
<button v-else class="action-btn complete-btn" @click="closePopup">
下一项
</button>
<button class="action-btn complete-btn" @click="submit(1)">完成</button>
</view>
<!-- 使用 uni-popup 组件 完成弹窗 -->
<uni-popup ref="popup" type="center">
......@@ -138,7 +136,7 @@
import {
pad_2_1_inspection_items,
pad_2_1_inspection_position,
pad_2_1_floor
pad_2_1_floor,
} from "@/utils/dict.js"; //巡检位置,A座到F座 楼层2楼4楼到26楼
import {
addLog,
......@@ -153,6 +151,7 @@
getDarft
} from "@/request/index.js";
import moment from "moment";
import _ from 'lodash';
export default {
data() {
......@@ -166,15 +165,15 @@
randomDescription: "这是一段随机说明文字。", // 随机说明文字
tabs: [{
label: "门禁",
icon: "../../static/img/add-img/home1.png"
icon: "../../static/img/add-img/home1.png",
},
{
label: "卫生",
icon: "../../static/img/add-img/home1.png"
icon: "../../static/img/add-img/home1.png",
},
{
label: "设备告警",
icon: "../../static/img/add-img/home1.png"
icon: "../../static/img/add-img/home1.png",
},
],
activeTab: 0, // 当前选中的 Tab
......@@ -204,60 +203,37 @@
onLoad(options) {
this.coverlist();
this.isDisable = options.isDisable == 1 ? true : false;
this.uid = options.uid
this.location = options.location
this.value = options.value
this.dictValue = options.dictValue
this.inspectionCode = options.inspectionCode
console.log("options", options)
this.uid = options.uid;
this.location = options.location;
this.value = options.value;
this.dictValue = options.dictValue;
this.inspectionCode = options.inspectionCode;
console.log("options", options);
if (options.uid) {
this.getDetails(options.uid);
} else if (options.isDarf) {
// 获取草稿数据
uni.showLoading();
getDarft()
.then((res) => {
console.log("res", res)
const darf_data = res || {};
this.baseInfo = darf_data.originData.baseInfo;
this.list = darf_data.originData.tempForm;
this.detailsInfo = darf_data;
uni.hideLoading();
} else {
this.init();
})
.catch((error) => {
uni.showToast({
title: error.msg,
icon: "none",
duration: 1000,
});
uni.hideLoading();
});
}
},
watch: {},
mounted() {
this.init();
},
mounted() {},
methods: {
// 初始化
init() {
return new Promise((resolve, reject) => {
// 判断是否有回显数据
if (!this.uid) {
// 基础数据
this.baseInfo = {
inspectionType: "2",
inspectionCode: `JFXJ${moment().format("yyyyMMDDHHmmss")}${(Math.floor(Math.random() * 900) + 100)}`,
inspectionCode: this.inspectionCode,
recordName: `${moment().format("yyyyMMDD")}-井道巡检`,
inspectionTime: moment().format("yyyy-MM-DD HH:mm"),
inspectionBy: this.$store.state.now_user.user,
inspectionById: this.$store.state.now_user.userId,
createByName: this.$store.state.now_user.user,
isException: "", // 是否有异常
isException: "", // 是否有异常,大于0存在异常
inspectionNumber: 0, //巡检数量
floor: this.floor, // 楼层
isSubmit: "", // 0 是草稿态; 1 是正式提交
isSign: "", // 是否签字
......@@ -265,8 +241,7 @@
creatTime: `${new Date().getTime()}`,
items: [],
};
}
console.log(2222, this.baseInfo, this.list, this.detailsInfo)
console.log(2222, this.baseInfo, this.list, this.detailsInfo);
resolve();
});
},
......@@ -276,14 +251,18 @@
getInspectionDetails(uid)
.then((res) => {
const detailsInfo = res;
console.log("getDetails", res)
this.baseInfo = detailsInfo.originData.baseInfo;
this.list = detailsInfo.originData.tempForm;
console.log("getDetails", res);
let list = detailsInfo.originData[this.value - 1].position[this.dictValue - 1].details;
// 未巡检需要处理默认数据结构
if (list && list.length) {
this.list = list
}
console.log("let list", list)
this.detailsInfo = detailsInfo;
console.log("获取list", this.list);
this.isDisable = this.isDisable || detailsInfo.synchronization == 1; // 是否禁用 1:已同步数据 0: 未同步数据
uni.hideLoading();
this.isSubmitEnabled = this.isAllTabValid()
})
.catch((error) => {
uni.showToast({
......@@ -297,8 +276,11 @@
// 加载历史数据
loadHistoryData() {
const history = uni.getStorageSync("inspectionHistory");
console.log("history", history)
if (history && Date.now() - history.firstSubmitTime < 168 * 60 * 60 * 1000) {
console.log("history", history);
if (
history &&
Date.now() - history.firstSubmitTime < 168 * 60 * 60 * 1000
) {
this.historyData = history;
this.location = history.location;
this.randomDescription = history.randomDescription;
......@@ -383,10 +365,33 @@
deletePhoto(index) {
this.photos.splice(index, 1);
this.list[this.activeTab].photos = this.photos;
}, // 处理提交数据
},
// 处理提交数据
getParams(isSubmit) {
const baseInfo = this.baseInfo;
const tabList = pad_2_1_inspection_position.rows.map((item, index) => {
if (this.uid) {
let posItem = this.detailsInfo.originData[this.value - 1].position[this.dictValue - 1]
posItem.details = this.list
posItem.isSubmit = isSubmit
if (!this.checkInspectionResult(this.list)) {
posItem.status = 2; //1表示已经巡检过有异常
posItem.statusLable = "巡检异常"
} else {
posItem.status = 1; //1表示已经巡检过没有异常
posItem.statusLable = "已巡检"
}
let {
notZeroCount,
equalTwoCount
} = this.count(this.detailsInfo.originData)
this.detailsInfo.inspectionNumber = notZeroCount //巡检总数
this.detailsInfo.isException = equalTwoCount //异常数量
this.detailsInfo.isSubmit = this.typeSubmit(this.detailsInfo.originData) > 0 ? 0 : 1, //是否提交
console.log("this.detailsInfo", this.detailsInfo);
return this.detailsInfo;
} else {
let baseInfo = this.baseInfo;
let dataObj = pad_2_1_inspection_position.rows.map((item, index) => {
return {
name: item.dictLabel,
value: item.dictValue,
......@@ -397,54 +402,70 @@
descript: "检查内容包括门禁、卫生、设备告警。",
};
});
this.updateDetails(tabList, this.value, this.dictValue, this.list);
console.log("this.list", this.list)
let tabList = JSON.parse(JSON.stringify(dataObj))
let posItem = tabList[this.value - 1].position[this.dictValue - 1]
console.log("posItem", posItem);
posItem.details = this.list;
posItem.isSubmit = isSubmit //当前项是否提交
console.log("this.list", this.list)
if (!this.checkInspectionResult(this.list)) {
posItem.status = 2; //1表示已经巡检过有异常
posItem.statusLable = "巡检异常"
} else {
posItem.status = 1; //1表示已经巡检过没有异常
posItem.statusLable = "已巡检"
}
console.log("this.tabList", tabList);
// 根据获取到的每个井道的isSubmit来判断是否有暂存状态
let typeSubmit = this.typeSubmit(tabList)
const data = {
...baseInfo,
isSubmit: isSubmit, //是否提交
isSubmit: typeSubmit > 0 ? 0 : 1, //0暂存 1提交
inspectionNumber: 1,
isException: posItem.status == 2 ? 1 : 0,
items: [],
synchronization: 0, // 是否同步过
submitTime: moment().format("yyyy-MM-DD"), // 记录提交时间
submitMonth: moment().format("yyyy-MM"), // 记录提交月份
originData: tabList, //所有大楼和楼层的数据
};
console.log("getParams,data", data)
console.log("getParams,data", data);
return data;
},
// 操作结果赋值到对应位置
updateDetails(tabList, targetValue, targetDictValue, newDetails) {
// 检查传入的tabList是否有效
if (!Array.isArray(tabList)) {
console.error("Invalid tabList: expected an array");
return;
}
// 遍历tabList数组
tabList.forEach((item) => {
// 检查当前对象的value是否匹配
if (item.value === targetValue) {
// 检查position是否存在且是数组
if (item.position && Array.isArray(item.position)) {
// 遍历position数组
item.position.forEach((posItem) => {
// 检查dictValue是否匹配
if (posItem.dictValue === targetDictValue) {
// 找到匹配的对象,更新details
posItem.details = newDetails;
posItem.status = 1 //1表示已经巡检过
console.log("Details updated successfully");
}
});
} else {
console.warn("Invalid position property: expected an array");
},
count(originData) {
return originData.reduce(
(acc, curr) => {
curr.position.forEach((item) => {
if (item.status !== 0) {
acc.notZeroCount++; // 统计 status 不为 0 的数量
}
if (item.status === 2) {
acc.equalTwoCount++; // 统计 status 等于 2 的数量
}
});
return acc;
}, {
notZeroCount: 0,
equalTwoCount: 0
} // 初始化统计结果
);
},
typeSubmit(originData) {
return originData.reduce((acc, curr) => {
return acc + curr.position.reduce((innerAcc, innerCurr) => {
return innerCurr.status === 0 ? innerAcc + 1 : innerAcc;
}, 0);
}, 0);
},
// 检查是否存在异常
checkInspectionResult(arr) {
return !arr.some((obj) => obj.inspectionResult === 1);
},
// 检查所有Tab 的必填项是否填写完整
isAllTabValid() {
const data = this.list
const data = this.list;
// 校验函数
const validateData = (data) => {
return data.every(
......@@ -454,13 +475,13 @@
};
// 调用校验函数
const isValid = validateData(data);
console.log(141, isValid)
return isValid
console.log(141, isValid);
return isValid;
},
// 检查当前 Tab 的必填项是否填写完整
isCurrentTabValid() {
const currentTabData = this.list[this.activeTab];
console.log("currentTabData", currentTabData)
console.log("currentTabData", currentTabData);
return (
currentTabData.inspectionResult !== null && // 巡检结论必填
currentTabData.conclusion.trim() !== "" // 情况摘要必填
......@@ -470,11 +491,10 @@
// 暂存
saveDraft(isSave = true) {
return new Promise((resolve, reject) => {
if (isSave) {
// 写入草稿文件 更新 store 草稿内容
const params = this.getParams();
console.log("params", params)
console.log("params", params);
params.isSubmit = 0;
this.$store.commit("SET_DARF_DATA", params); // 缓存[巡检信息]
......@@ -505,43 +525,21 @@
resolve();
});
},
// // 完成
// complete() {
// this.isSubmitEnabled = this.isAllTabValid()
// if (this.isCurrentTabValid()) {
// // 暂存All
// this.saveDraft().then(() => {
// if (this.isSubmitEnabled) {
// this.openPopup()
// }
// })
// } else {
// uni.showToast({
// title: "请填写完整必填项",
// icon: "none",
// });
// }
// },
// 提交
submit(isSubmit = true) {
submit(isSubmit = 1) {
// 校验是否通过
if (isSubmit && !this.isCurrentTabValid()) {
uni.showToast({
title: "请填写完整必填项",
icon: "none",
});
return false
return false;
}
if (!this.firstSubmitTime) {
this.firstSubmitTime = Date.now();
this.$st
}
const params = this.getParams(1); //数据获取
const params = this.getParams(isSubmit); //数据获取
const all_data = this.$store.state.all_data; //获取全部数据
params.isSubmit = 1; //修改提交状态
let logContent = "";
console.log("this.uid", this.uid);
console.log("all_data", all_data)
if (this.uid) {
const index = all_data.findIndex((element) => element.uid == this.uid);
params.uid = this.uid;
......@@ -552,8 +550,7 @@
`${params.recordName}(${params.inspectionCode})`,
"巡检模块"
);
} {
} else {
params.uid = new Date().getTime(); // 唯一标识 pad 端使用
all_data.push(params);
logContent = getLogContent(
......@@ -564,11 +561,13 @@
}
// 更新巡检list
const userInfo = this.userInfo;
console.log("all_data存储", all_data)
this.$store.commit("SET_ALL_DATA", all_data);
const inspectList = all_data.filter(
(item) => item.createByName == userInfo.user
);
console.log("inspectList", inspectList);
writeInspectionData(inspectList, userInfo.user);
// 更新日志
......@@ -596,7 +595,7 @@
// };
// uni.setStorageSync("inspectionHistory", historyData);
uni.showToast({
title: "提交成功",
title: `${isSubmit}?'提交成功':'保存草稿成功'`,
icon: "success",
});
uni.navigateTo({
......@@ -609,7 +608,7 @@
this.updateCurrentTabData();
}, // 设置巡检结论
setInspectionResult(value) {
console.log("value", value)
console.log("value", value);
this.inspectionResult = value;
this.list[this.activeTab].inspectionResult = value; // 更新当前 Tab 的数据
},
......@@ -701,7 +700,7 @@
.number {
font-size: 12.8px;
color: #4A4A4A;
color: #4a4a4a;
line-height: 22.4px;
font-weight: 400;
......@@ -715,7 +714,7 @@
}
.module {
background: #FFFFFF;
background: #ffffff;
border-radius: 12px;
padding: 16px 25px;
}
......@@ -728,7 +727,7 @@
.blue-line {
width: 4px;
height: 16px;
background-color: #007AFF;
background-color: #007aff;
margin-right: 8px;
}
......@@ -753,7 +752,7 @@
font-size: 12px;
&.active {
background-color: #007AFF;
background-color: #007aff;
}
}
}
......@@ -781,7 +780,7 @@
border: 1px solid rgba(55, 116, 246, 0.3);
border-radius: 10px;
font-size: 14px;
color: #4A4A4A;
color: #4a4a4a;
letter-spacing: 0;
line-height: 34px;
font-weight: 400;
......@@ -818,7 +817,7 @@
&.active {
.tab-text {
color: #3774F6;
color: #3774f6;
/* 选中时的文字颜色 */
}
......@@ -830,7 +829,7 @@
width: 100%;
/* 横线宽度与内容一致 */
height: 2px;
background-color: #3774F6;
background-color: #3774f6;
/* 选中时的横线颜色 */
}
}
......@@ -841,8 +840,7 @@
align-items: center;
padding: 12px 0;
line-height: 36px;
border-bottom: 1px solid #F2F3F5;
;
border-bottom: 1px solid #f2f3f5;
.form-label {
font-size: 14px;
......@@ -862,22 +860,21 @@
gap: 12px;
/* 按钮之间的间隔 */
.status-btn {
flex: 1;
/* 按钮宽度平分 */
padding: 7px 24px;
font-size: 16px;
color: #000000;
background: #F2F2F2;
background: #f2f2f2;
text-align: center;
font-weight: 400;
line-height: 22px;
border-radius: 18px;
&.active {
color: #FFFFFF;
background: #3774F6;
color: #ffffff;
background: #3774f6;
border: 0.4px solid rgba(224, 224, 224, 1);
}
}
......@@ -931,13 +928,13 @@
}
.photo-btn {
background: #FFFFFF;
background: #ffffff;
border: 0.34px solid rgba(221, 221, 221, 1);
border-radius: 2.05px;
width: 72px;
height: 72px;
font-size: 72px;
color: #CCCCCC;
color: #cccccc;
text-align: center;
line-height: 64px;
}
......@@ -952,7 +949,7 @@
width: 182px;
height: 48px;
line-height: 48px;
background: #FFFFFF;
background: #ffffff;
border: 1px solid rgba(224, 224, 224, 1);
box-shadow: 0px 10px 24px 0px rgba(185, 185, 185, 0.24);
border-radius: 27px 24px 24px 27px;
......@@ -962,8 +959,8 @@
font-weight: 400;
&.complete-btn {
background-image: linear-gradient(180deg, #3773F6 0%, #2C57F6 99%);
color: #FFFFFF;
background-image: linear-gradient(180deg, #3773f6 0%, #2c57f6 99%);
color: #ffffff;
}
}
}
......
......@@ -1074,7 +1074,9 @@ export const pad_2_1_floor = {
"isDefault": "N",
"status": "0",
"default": false,
"details":[]
"statusLable":"未巡检",
"details":[],
"isSubmit":0,
},
{
"createBy": "admin",
......@@ -1092,7 +1094,9 @@ export const pad_2_1_floor = {
"isDefault": "N",
"status": "0",
"default": false,
"details":[]
"statusLable":"未巡检",
"details":[],
"isSubmit":0,
},
{
"createBy": "admin",
......@@ -1110,7 +1114,9 @@ export const pad_2_1_floor = {
"isDefault": "N",
"status": "0",
"default": false,
"details":[]
"statusLable":"未巡检",
"details":[],
"isSubmit":0,
},
{
"createBy": "admin",
......@@ -1128,7 +1134,9 @@ export const pad_2_1_floor = {
"isDefault": "N",
"status": "0",
"default": false,
"details":[]
"statusLable":"未巡检",
"details":[],
"isSubmit":0,
},
{
"createBy": "admin",
......@@ -1146,7 +1154,9 @@ export const pad_2_1_floor = {
"isDefault": "N",
"status": "0",
"default": false,
"details":[]
"statusLable":"未巡检",
"details":[],
"isSubmit":0,
},
{
"createBy": "admin",
......@@ -1164,7 +1174,9 @@ export const pad_2_1_floor = {
"isDefault": "N",
"status": "0",
"default": false,
"details":[]
"statusLable":"未巡检",
"details":[],
"isSubmit":0,
},
{
"createBy": "admin",
......@@ -1182,7 +1194,9 @@ export const pad_2_1_floor = {
"isDefault": "N",
"status": "0",
"default": false,
"details":[]
"statusLable":"未巡检",
"details":[],
"isSubmit":0,
},
{
"createBy": "admin",
......@@ -1200,7 +1214,9 @@ export const pad_2_1_floor = {
"isDefault": "N",
"status": "0",
"default": false,
"details":[]
"statusLable":"未巡检",
"details":[],
"isSubmit":0,
},
{
"createBy": "admin",
......@@ -1218,7 +1234,9 @@ export const pad_2_1_floor = {
"isDefault": "N",
"status": "0",
"default": false,
"details":[]
"statusLable":"未巡检",
"details":[],
"isSubmit":0,
},
{
"createBy": "admin",
......@@ -1236,7 +1254,9 @@ export const pad_2_1_floor = {
"isDefault": "N",
"status": "0",
"default": false,
"details":[]
"statusLable":"未巡检",
"details":[],
"isSubmit":0,
},
{
"createBy": "admin",
......@@ -1254,7 +1274,9 @@ export const pad_2_1_floor = {
"isDefault": "N",
"status": "0",
"default": false,
"details":[]
"statusLable":"未巡检",
"details":[],
"isSubmit":0,
},
{
"createBy": "admin",
......@@ -1272,7 +1294,9 @@ export const pad_2_1_floor = {
"isDefault": "N",
"status": "0",
"default": false,
"details":[]
"statusLable":"未巡检",
"details":[],
"isSubmit":0,
},
{
"createBy": "admin",
......@@ -1290,7 +1314,9 @@ export const pad_2_1_floor = {
"isDefault": "N",
"status": "0",
"default": false,
"details":[]
"statusLable":"未巡检",
"details":[],
"isSubmit":0,
}
]
}
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论