提交 7f815e98 authored 作者: caodi\cd's avatar caodi\cd

fix:优化

上级 f9931b89
......@@ -5,7 +5,7 @@
<view class="header">
<view class="title">杭州内网监管在线-运维在线</view>
<view class="header-buttons">
<button class="log-button" @click="lookLog">操作日志</button>
<view class="log-button" @click="lookLog">操作日志</view>
<div class="exit-button" @click="logOut">
<image
class="logout"
......@@ -25,9 +25,9 @@
src="@/static/img/add-img/home1.png"
mode="aspectFit"
></image>
<view class="change-password" @click="updatePassword"
<!-- <view class="change-password" @click="updatePassword"
>修改密码</view
>
> -->
</view>
<view class="username">{{ userName }}</view>
</view>
......@@ -206,6 +206,7 @@ export default {
color: #000000;
line-height: 36px;
font-weight: 400;
text-align: center;
}
.exit-button {
......@@ -322,7 +323,6 @@ export default {
.card {
width: 224px;
height: 194px;
background-color: #f0f0f0;
border-radius: 10px;
display: flex;
flex-direction: column;
......
......@@ -3,7 +3,7 @@
<view>
<view v-for="(item, index) in itemData.detail" :key="index">
<template
v-if="!(index > 2 && itemData.detail[2].inspectionResult === 1)"
v-if="!(index > 2 && itemData.detail[2].inspectionResult !== 0)"
>
<view class="form-item">
<text class="form-label"
......@@ -24,40 +24,41 @@
</view>
</view>
</view>
<view v-if="'conclusion' in item" class="form-item">
<text class="form-label"
><text class="required">*</text>情况摘要</text
>
<text class="conclusion" @click="showPopup(index)">{{
item.conclusion || "请输入情况摘要"
}}</text>
</view>
<view class="form-item" v-if="'photos' in item">
<text class="form-label"
><text class="required">*</text>现场照片</text
>
<view class="photo-box">
<view class="photo-container">
<view @click="takePhoto(index)" class="photo-btn"> + </view>
<view
v-for="(photo, itemIndex) in item && item.photos"
:key="itemIndex"
class="photo-item"
>
<image :src="photo" class="photo"></image>
<text
class="delete-photo"
@click="deletePhoto(index, itemIndex)"
>×</text
<template v-if="item.inspectionResult === 1">
<view v-if="'conclusion' in item" class="form-item">
<text class="form-label"
><text class="required">*</text>情况摘要</text
>
<text class="conclusion" @click="showPopup(index)">{{
item.conclusion || "请输入情况摘要"
}}</text>
</view>
<view class="form-item" v-if="'photos' in item">
<text class="form-label"
><text class="required">*</text>现场照片</text
>
<view class="photo-box">
<view class="photo-container">
<view @click="takePhoto(index)" class="photo-btn"> + </view>
<view
v-for="(photo, itemIndex) in item && item.photos"
:key="itemIndex"
class="photo-item"
>
<image :src="photo" class="photo"></image>
<text
class="delete-photo"
@click="deletePhoto(index, itemIndex)"
>×</text
>
</view>
</view>
<view class="photo-limit"
>请对检查项进行拍照留存(限5张)。发现“异常、告警”时,需拍照留存。</view
>
</view>
<view class="photo-limit"
>请对检查项进行拍照留存(限5张)。发现“异常、告警”时,需拍照留存。</view
>
</view>
</view></template
</view></template
></template
> </view
><custom-popup
ref="customPopup"
......@@ -104,7 +105,7 @@ export default {
detail: [
{
label: "门禁功能",
inspectionResult: 0,
inspectionResult: "",
inspectionResultLable: "正常",
lableArr: ["正常", "异常"],
conclusion: "",
......@@ -112,7 +113,7 @@ export default {
},
{
label: "门禁外观破损",
inspectionResult: 0,
inspectionResult: "",
inspectionResultLable: "无",
lableArr: ["无", "有"],
conclusion: "",
......@@ -120,13 +121,13 @@ export default {
},
{
label: "是否有监控",
inspectionResult: 0,
inspectionResult: "",
inspectionResultLable: "有监控",
lableArr: ["有监控", "无监控"],
},
{
label: "监控外观破损",
inspectionResult: 0,
inspectionResult: "",
inspectionResultLable: "无",
lableArr: ["无", "有"],
conclusion: "",
......@@ -134,7 +135,7 @@ export default {
},
{
label: "监控画面清晰",
inspectionResult: 0,
inspectionResult: "",
inspectionResultLable: "清晰",
lableArr: ["清晰", "模糊"],
conclusion: "",
......@@ -142,7 +143,7 @@ export default {
},
{
label: "监控存储连续",
inspectionResult: 0,
inspectionResult: "",
inspectionResultLable: "正常",
lableArr: ["正常", "异常"],
conclusion: "",
......@@ -237,46 +238,71 @@ export default {
this.itemData.isValid = isValid;
this.itemData.inspectionItem = this.inspectionItem;
console.log(222, this.itemData);
if (isAllOne) {
// 全都是正常
this.itemData.status = 1; //1表示已经巡检过没有异常
this.itemData.statusLabel = "已巡检";
} else {
this.itemData.status = 2; //1表示已经巡检过有异常
this.itemData.statusLabel = "巡检异常";
}
this.itemData.status = isAllOne.status; //1表示已经巡检过没有异常
this.itemData.statusLabel = isAllOne.statusLabel;
// console.log(this.itemData);
return this.itemData;
},
// 数据校验方法 true说明有未填项
areAllObjectsValid(arr, skipIndex) {
// 遍历数组中的每个对象
for (let i = 0; i < arr.length; i++) {
const obj = arr[i];
// 如果当前索引大于等于 skipIndex,并且 inspectionResult 为 1,则跳过后续校验
if (i >= skipIndex && obj.inspectionResult === 1) {
break;
areAllObjectsValid(details) {
const thirdItem = details[2]; // 第三个对象
console.log("thirdItem.inspectionResult", thirdItem.inspectionResult);
// 情况1:第三个对象的 inspectionResult 是 "0",校验所有 inspectionResult 是否不为空
if (thirdItem.inspectionResult === 0) {
const hasEmptyInspectionResult = details.some(
(item) => item.inspectionResult === ""
);
if (hasEmptyInspectionResult) {
return false;
}
// 检查对象中的每个属性是否有值
for (const key in obj) {
if (obj.hasOwnProperty(key)) {
// 如果属性值为空(null, undefined, 空字符串等),则校验不通过
if (
obj[key] === null ||
obj[key] === undefined ||
obj[key] === ""
) {
return false;
}
}
}
// 确定需要校验的范围
const itemsToCheck =
thirdItem.inspectionResult === 1 ? details.slice(0, 2) : details;
console.log("确定需要校验的范围 ", itemsToCheck);
// 检查 conclusion 和 photos(如果存在)
for (const item of itemsToCheck) {
if (item.inspectionResult === 0) {
continue; // 跳过检查
}
if ("conclusion" in item && !item.conclusion) {
return false;
}
if ("photos" in item && item.photos.length === 0) {
return false;
}
}
// 如果所有对象都通过校验,返回 true
return true;
},
// 校验是否有异常
areAllInspectionResultsOne(arr) {
return arr.every((obj) => obj.inspectionResult === 0);
areAllInspectionResultsOne(details) {
const thirdItemResult = details[2].inspectionResult;
const shouldCheckAll = !(thirdItemResult === 1 || thirdItemResult === "");
const checkItems = shouldCheckAll ? details : details.slice(0, 3);
let hasEmpty = false;
let hasZero = false;
let hasOne = false;
for (let i = 0; i < checkItems.length; i++) {
if (i === 2) continue;
const result = checkItems[i].inspectionResult;
if (result === 1) {
hasOne = true;
} else if (result === 0) {
hasZero = true;
} else if (result === "") {
console.log("i", i);
hasEmpty = true;
}
}
if (hasOne) {
return { status: 2, statusLabel: "巡检异常" };
} else if (hasZero && !hasEmpty) {
return { status: 1, statusLabel: "已巡检" };
} else {
return { status: 0, statusLabel: "未巡检" };
}
},
},
};
......
......@@ -25,41 +25,49 @@
{{ item.lableArr[1] }}
</view> </view
><input
v-if="'value' in item"
v-if="'value' in item && item.inspectionResult === 1"
class="input"
v-model="item.value"
type="text"
placeholder="请输入"
maxlength="3"
/>{{ item.unit }}
/>{{ item.inspectionResult === 1?item.unit:"" }}
</view>
<view v-if="'conclusion' in item" class="form-item">
<text class="form-label"><text class="required">*</text>情况摘要</text>
<text class="conclusion" @click="showPopup(index)">{{
item.conclusion || "请输入情况摘要"
}}</text>
</view>
<view class="form-item" v-if="'photos' in item">
<text class="form-label"><text class="required">*</text>现场照片</text>
<view class="photo-box">
<view class="photo-container">
<view @click="takePhoto(index)" class="photo-btn"> + </view>
<view
v-for="(photo, itemIndex) in item && item.photos"
:key="itemIndex"
class="photo-item"
>
<image :src="photo" class="photo"></image>
<text class="delete-photo" @click="deletePhoto(index, itemIndex)"
>×</text
<template v-if="item.inspectionResult === 1">
<view v-if="'conclusion' in item" class="form-item">
<text class="form-label"
><text class="required">*</text>情况摘要</text
>
<text class="conclusion" @click="showPopup(index)">{{
item.conclusion || "请输入情况摘要"
}}</text>
</view>
<view class="form-item" v-if="'photos' in item">
<text class="form-label"
><text class="required">*</text>现场照片</text
>
<view class="photo-box">
<view class="photo-container">
<view @click="takePhoto(index)" class="photo-btn"> + </view>
<view
v-for="(photo, itemIndex) in item && item.photos"
:key="itemIndex"
class="photo-item"
>
<image :src="photo" class="photo"></image>
<text
class="delete-photo"
@click="deletePhoto(index, itemIndex)"
>×</text
>
</view>
</view>
<view class="photo-limit"
>请对检查项进行拍照留存(限5张)。发现“异常、告警”时,需拍照留存。</view
>
</view>
<view class="photo-limit"
>请对检查项进行拍照留存(限5张)。发现“异常、告警”时,需拍照留存。</view
>
</view>
</view> </view
</template></view
><custom-popup
ref="customPopup"
:inspectionItem="inspectionItem"
......@@ -112,9 +120,9 @@ export default {
label: "电池电压",
sjLabel: "实际电池电压",
sjLabelShow: "实际电压",
inspectionResult: 0,
inspectionResult: "",
inspectionResultLable: "正常",
lableArr: ["正常", "常"],
lableArr: ["正常", "常"],
conclusion: "",
settingLabel: "设定电池电压",
settingLabelShow: "设定电压",
......@@ -127,9 +135,9 @@ export default {
label: "电池温度",
sjLabel: "实际电池温度",
sjLabelShow: "实际温度",
inspectionResult: 0,
inspectionResult: "",
inspectionResultLable: "正常",
lableArr: ["正常", "常"],
lableArr: ["正常", "常"],
conclusion: "",
settingLabel: "设定电池温度",
settingLabelShow: "设定温度",
......@@ -142,9 +150,9 @@ export default {
label: "电池内阻",
sjLabel: "实际电池内阻",
sjLabelShow: "实际内阻",
inspectionResult: 0,
inspectionResult: "",
inspectionResultLable: "正常",
lableArr: ["正常", "常"],
lableArr: ["正常", "常"],
conclusion: "",
settingLabel: "设定电池内阻",
settingLabelShow: "设定内阻",
......@@ -155,7 +163,6 @@ export default {
},
],
},
};
},
computed: {
......@@ -166,10 +173,10 @@ export default {
watch: {
defaultData(newVal) {
// 在这里处理数据变化
if (Object.keys(this.defaultData).length !== 0) {
this.itemData = this.defaultData;
}
}
if (Object.keys(this.defaultData).length !== 0) {
this.itemData = this.defaultData;
}
},
},
methods: {
// 拍照
......@@ -243,46 +250,71 @@ export default {
this.itemData.isValid = isValid;
this.itemData.inspectionItem = this.inspectionItem;
console.log(222, this.itemData);
if (isAllOne) {
// 全都是正常
this.itemData.status = 1; //1表示已经巡检过没有异常
this.itemData.statusLabel = "已巡检";
} else {
this.itemData.status = 2; //1表示已经巡检过有异常
this.itemData.statusLabel = "巡检异常";
}
this.itemData.status = isAllOne.status; //1表示已经巡检过没有异常
this.itemData.statusLabel = isAllOne.statusLabel;
// console.log(this.itemData);
return this.itemData;
},
// 数据校验方法 true说明有未填项
areAllObjectsValid(arr, skipIndex) {
// 遍历数组中的每个对象
for (let i = 0; i < arr.length; i++) {
const obj = arr[i];
// 如果当前索引大于等于 skipIndex,并且 inspectionResult 为 1,则跳过后续校验
if (i >= skipIndex && obj.inspectionResult === 1) {
break;
}
// 检查对象中的每个属性是否有值
for (const key in obj) {
if (obj.hasOwnProperty(key)) {
// 如果属性值为空(null, undefined, 空字符串等),则校验不通过
if (
obj[key] === null ||
obj[key] === undefined ||
obj[key] === ""
) {
return false;
}
areAllObjectsValid(details) {
// 检查是否有任何项的 inspectionResult 为空字符串
const hasEmptyResult = details.some(
(item) => item.inspectionResult === ""
);
if (hasEmptyResult) {
return false;
}
// 遍历每一项进行检查
for (const item of details) {
if (item.inspectionResult === 0) {
// 如果 inspectionResult 为 0,跳过此项的其他检查
continue;
} else if (item.inspectionResult === 1) {
// 如果 inspectionResult 为 1,检查 conclusion 和 photos
if (!item.conclusion || item.photos.length === 0 || !item.value) {
return false;
}
} else {
// 其他情况(理论上不应该存在,根据当前规则)
return false;
}
}
// 如果所有对象都通过校验,返回 true
// 所有检查都通过
return true;
},
// 校验是否有异常
areAllInspectionResultsOne(arr) {
return arr.every((obj) => obj.inspectionResult === 0);
areAllInspectionResultsOne(details) {
let hasEmpty = false;
let allZero = true;
let hasOne = false;
for (const item of details) {
if (item.inspectionResult === "") {
hasEmpty = true;
break;
} else if (item.inspectionResult === 1) {
hasOne = true;
allZero = false;
} else if (item.inspectionResult === 0) {
// 继续检查
} else {
// 如果有其他值,可以在这里处理
allZero = false;
}
}
if (hasEmpty) {
return { statusLabel: "未巡检", status: 0 };
} else if (allZero) {
return { statusLabel: "已巡检", status: 1 };
} else if (hasOne) {
return { statusLabel: "巡检异常", status: 2 };
} else {
// 默认情况,可以根据需求调整
return { statusLabel: "未巡检", status: 0 };
}
},
},
};
......
......@@ -22,33 +22,41 @@
</view>
</view>
<view class="form-item">
<text class="form-label"><text class="required">*</text>情况摘要</text>
<text class="conclusion" @click="showPopup(index)">{{
item.conclusion || "请输入情况摘要"
}}</text>
</view>
<view class="form-item">
<text class="form-label"><text class="required">*</text>现场照片</text>
<view class="photo-box">
<view class="photo-container">
<view @click="takePhoto(index)" class="photo-btn"> + </view>
<view
v-for="(photo, itemIndex) in item && item.photos"
:key="itemIndex"
class="photo-item"
>
<image :src="photo" class="photo"></image>
<text class="delete-photo" @click="deletePhoto(index, itemIndex)"
>×</text
<template v-if="item.inspectionResult === 1">
<view class="form-item">
<text class="form-label"
><text class="required">*</text>情况摘要</text
>
<text class="conclusion" @click="showPopup(index)">{{
item.conclusion || "请输入情况摘要"
}}</text>
</view>
<view class="form-item">
<text class="form-label"
><text class="required">*</text>现场照片</text
>
<view class="photo-box">
<view class="photo-container">
<view @click="takePhoto(index)" class="photo-btn"> + </view>
<view
v-for="(photo, itemIndex) in item && item.photos"
:key="itemIndex"
class="photo-item"
>
<image :src="photo" class="photo"></image>
<text
class="delete-photo"
@click="deletePhoto(index, itemIndex)"
>×</text
>
</view>
</view>
<view class="photo-limit"
>请对检查项进行拍照留存(限5张)。发现“异常、告警”时,需拍照留存。</view
>
</view>
<view class="photo-limit"
>请对检查项进行拍照留存(限5张)。发现“异常、告警”时,需拍照留存。</view
>
</view>
</view> </view
</template></view
><custom-popup
ref="customPopup"
:inspectionItem="inspectionItem"
......@@ -94,7 +102,7 @@ export default {
detail: [
{
label: "市电输入状态",
inspectionResult: 0,
inspectionResult: "",
inspectionResultLable: "正常",
lableArr: ["正常", "异常"],
conclusion: "",
......@@ -102,7 +110,7 @@ export default {
},
{
label: "UPS状态",
inspectionResult: 0,
inspectionResult: "",
inspectionResultLable: "正常",
lableArr: ["正常", "异常"],
conclusion: "",
......@@ -110,7 +118,7 @@ export default {
},
{
label: "电池状态",
inspectionResult: 0,
inspectionResult: "",
inspectionResultLable: "正常",
lableArr: ["正常", "异常"],
conclusion: "",
......@@ -202,51 +210,72 @@ export default {
const isAllOne = this.areAllInspectionResultsOne(this.itemData.detail);
this.itemData.isValid = isValid;
this.itemData.inspectionItem = this.inspectionItem;
if (isAllOne) {
// 全都是正常
this.itemData.status = 1; //1表示已经巡检过没有异常
this.itemData.statusLabel = "已巡检";
} else {
this.itemData.status = 2; //1表示已经巡检过有异常
this.itemData.statusLabel = "巡检异常";
}
this.itemData.status = isAllOne.status; //1表示已经巡检过没有异常
this.itemData.statusLabel = isAllOne.statusLabel;
// console.log(this.itemData);
return this.itemData;
},
// 数据校验方法 true说明有未填项
areAllObjectsValid(arr) {
for (let i = 0; i < arr.length; i++) {
const obj = arr[i];
const keys = Object.keys(obj);
for (let j = 0; j < keys.length; j++) {
const key = keys[j];
const value = obj[key];
if (value === null || value === undefined || value === "") {
areAllObjectsValid(details) {
// 检查是否有任何项的 inspectionResult 为空字符串
const hasEmptyResult = details.some(
(item) => item.inspectionResult === ""
);
if (hasEmptyResult) {
return false;
}
// 遍历每一项进行检查
for (const item of details) {
if (item.inspectionResult === 0) {
// 如果 inspectionResult 为 0,跳过此项的其他检查
continue;
} else if (item.inspectionResult === 1) {
// 如果 inspectionResult 为 1,检查 conclusion 和 photos
if (!item.conclusion || item.photos.length === 0) {
return false;
}
if (Array.isArray(value)) {
if (value.length === 0) {
return false;
}
for (let k = 0; k < value.length; k++) {
if (typeof value[k] === "object" && value[k] !== null) {
if (!validateArrayObjects([value[k]])) {
return false;
}
}
}
} else if (typeof value === "object" && value !== null) {
if (!validateArrayObjects([value])) {
return false;
}
}
} else {
// 其他情况(理论上不应该存在,根据当前规则)
return false;
}
}
// 所有检查都通过
return true;
},
// 校验是否有异常
areAllInspectionResultsOne(arr) {
return arr.every((obj) => obj.inspectionResult === 0);
areAllInspectionResultsOne(details) {
let hasEmpty = false;
let allZero = true;
let hasOne = false;
for (const item of details) {
if (item.inspectionResult === "") {
hasEmpty = true;
break;
} else if (item.inspectionResult === 1) {
hasOne = true;
allZero = false;
} else if (item.inspectionResult === 0) {
// 继续检查
} else {
// 如果有其他值,可以在这里处理
allZero = false;
}
}
if (hasEmpty) {
return { statusLabel: "未巡检", status: 0 };
} else if (allZero) {
return { statusLabel: "已巡检", status: 1 };
} else if (hasOne) {
return { statusLabel: "巡检异常", status: 2 };
} else {
// 默认情况,可以根据需求调整
return { statusLabel: "未巡检", status: 0 };
}
},
},
};
......
......@@ -25,40 +25,49 @@
{{ item.lableArr[1] }}
</view> </view
><input
v-if="'value' in item && item.inspectionResult === 1"
class="input"
v-model="item.value"
type="text"
placeholder="请输入"
maxlength="3"
/>{{ item.unit }}
/>{{ item.inspectionResult === 1 ? item.unit : "" }}
</view>
<view v-if="'conclusion' in item" class="form-item">
<text class="form-label"><text class="required">*</text>情况摘要</text>
<text class="conclusion" @click="showPopup(index)">{{
item.conclusion || "请输入情况摘要"
}}</text>
</view>
<view class="form-item" v-if="'photos' in item">
<text class="form-label"><text class="required">*</text>现场照片</text>
<view class="photo-box">
<view class="photo-container">
<view @click="takePhoto(index)" class="photo-btn"> + </view>
<view
v-for="(photo, itemIndex) in item && item.photos"
:key="itemIndex"
class="photo-item"
>
<image :src="photo" class="photo"></image>
<text class="delete-photo" @click="deletePhoto(index, itemIndex)"
>×</text
<template v-if="item.inspectionResult === 1">
<view v-if="'conclusion' in item" class="form-item">
<text class="form-label"
><text class="required">*</text>情况摘要</text
>
<text class="conclusion" @click="showPopup(index)">{{
item.conclusion || "请输入情况摘要"
}}</text>
</view>
<view class="form-item" v-if="'photos' in item">
<text class="form-label"
><text class="required">*</text>现场照片</text
>
<view class="photo-box">
<view class="photo-container">
<view @click="takePhoto(index)" class="photo-btn"> + </view>
<view
v-for="(photo, itemIndex) in item && item.photos"
:key="itemIndex"
class="photo-item"
>
<image :src="photo" class="photo"></image>
<text
class="delete-photo"
@click="deletePhoto(index, itemIndex)"
>×</text
>
</view>
</view>
<view class="photo-limit"
>请对检查项进行拍照留存(限5张)。发现“异常、告警”时,需拍照留存。</view
>
</view>
<view class="photo-limit"
>请对检查项进行拍照留存(限5张)。发现“异常、告警”时,需拍照留存。</view
>
</view>
</view></view
</view></template
></view
><custom-popup
ref="customPopup"
:inspectionItem="inspectionItem"
......@@ -105,9 +114,9 @@ export default {
{
label: "机房温度",
sjLabel: "实际温度",
inspectionResult: 0,
inspectionResult: "",
inspectionResultLable: "正常",
lableArr: ["正常", "常"],
lableArr: ["正常", "常"],
conclusion: "",
settingLabel: "设定温度",
setting: "25", //设定温度值
......@@ -118,9 +127,9 @@ export default {
{
label: "机房湿度",
sjLabel: "实际湿度",
inspectionResult: 0,
inspectionResult: "",
inspectionResultLable: "正常",
lableArr: ["正常", "常"],
lableArr: ["正常", "常"],
conclusion: "",
settingLabel: "设定湿度",
setting: "25", //设定湿度值
......@@ -140,10 +149,10 @@ export default {
watch: {
defaultData(newVal) {
// 在这里处理数据变化
if (Object.keys(this.defaultData).length !== 0) {
this.itemData = this.defaultData;
}
}
if (Object.keys(this.defaultData).length !== 0) {
this.itemData = this.defaultData;
}
},
},
methods: {
// 拍照
......@@ -217,51 +226,72 @@ export default {
this.itemData.isValid = isValid;
this.itemData.inspectionItem = this.inspectionItem;
console.log(222, this.itemData);
if (isAllOne) {
// 全都是正常
this.itemData.status = 1; //1表示已经巡检过没有异常
this.itemData.statusLabel = "已巡检";
} else {
this.itemData.status = 2; //1表示已经巡检过有异常
this.itemData.statusLabel = "巡检异常";
}
this.itemData.status = isAllOne.status; //1表示已经巡检过没有异常
this.itemData.statusLabel = isAllOne.statusLabel;
// console.log(this.itemData);
return this.itemData;
},
// / 数据校验方法 true说明有未填项
areAllObjectsValid(arr) {
for (let i = 0; i < arr.length; i++) {
const obj = arr[i];
const keys = Object.keys(obj);
for (let j = 0; j < keys.length; j++) {
const key = keys[j];
const value = obj[key];
if (value === null || value === undefined || value === "") {
// 数据校验方法 true说明有未填项
areAllObjectsValid(details) {
// 检查是否有任何项的 inspectionResult 为空字符串
const hasEmptyResult = details.some(
(item) => item.inspectionResult === ""
);
if (hasEmptyResult) {
return false;
}
// 遍历每一项进行检查
for (const item of details) {
if (item.inspectionResult === 0) {
// 如果 inspectionResult 为 0,跳过此项的其他检查
continue;
} else if (item.inspectionResult === 1) {
// 如果 inspectionResult 为 1,检查 conclusion 和 photos
if (!item.conclusion || item.photos.length === 0 || !item.value) {
return false;
}
if (Array.isArray(value)) {
if (value.length === 0) {
return false;
}
for (let k = 0; k < value.length; k++) {
if (typeof value[k] === "object" && value[k] !== null) {
if (!validateArrayObjects([value[k]])) {
return false;
}
}
}
} else if (typeof value === "object" && value !== null) {
if (!validateArrayObjects([value])) {
return false;
}
}
} else {
// 其他情况(理论上不应该存在,根据当前规则)
return false;
}
}
// 所有检查都通过
return true;
},
// 校验是否有异常
areAllInspectionResultsOne(arr) {
return arr.every((obj) => obj.inspectionResult === 0);
areAllInspectionResultsOne(details) {
let hasEmpty = false;
let allZero = true;
let hasOne = false;
for (const item of details) {
if (item.inspectionResult === "") {
hasEmpty = true;
break;
} else if (item.inspectionResult === 1) {
hasOne = true;
allZero = false;
} else if (item.inspectionResult === 0) {
// 继续检查
} else {
// 如果有其他值,可以在这里处理
allZero = false;
}
}
if (hasEmpty) {
return { statusLabel: "未巡检", status: 0 };
} else if (allZero) {
return { statusLabel: "已巡检", status: 1 };
} else if (hasOne) {
return { statusLabel: "巡检异常", status: 2 };
} else {
// 默认情况,可以根据需求调整
return { statusLabel: "未巡检", status: 0 };
}
},
},
};
......
......@@ -24,69 +24,71 @@
</view>
</view>
</view>
<view class="form-item">
<text class="form-label"
><text class="required">*</text>{{ item.deviceLabel }}</text
><input
class="conclusion"
v-model="item.deviceId"
type="text"
placeholder="请输入编号"
/>
</view>
<view class="form-item">
<text class="form-label"
><text class="required">*</text>{{ item.UpositonLabel }}</text
><input
class="input"
v-model="item.UpositonS"
type="number"
placeholder="请输入"
maxlength="2"
/>
<text class="fg"></text
><input
class="input"
v-model="item.UpositonE"
type="number"
placeholder="请输入"
maxlength="2"
/>
</view>
<view v-if="'conclusion' in item" class="form-item">
<text class="form-label"
><text class="required">*</text>情况摘要</text
>
<text class="conclusion" @click="showPopup(index)">{{
item.conclusion || "请输入情况摘要"
}}</text>
</view>
<view class="form-item" v-if="'photos' in item">
<text class="form-label"
><text class="required">*</text>现场照片</text
>
<view class="photo-box">
<view class="photo-container">
<view @click="takePhoto(index)" class="photo-btn"> + </view>
<view
v-for="(photo, itemIndex) in item && item.photos"
:key="itemIndex"
class="photo-item"
>
<image :src="photo" class="photo"></image>
<text
class="delete-photo"
@click="deletePhoto(index, itemIndex)"
>×</text
<template v-if="item.inspectionResult === 1">
<view class="form-item">
<text class="form-label"
><text class="required">*</text>{{ item.deviceLabel }}</text
><input
class="conclusion"
v-model="item.deviceId"
type="text"
placeholder="请输入编号"
/>
</view>
<view class="form-item">
<text class="form-label"
><text class="required">*</text>{{ item.UpositonLabel }}</text
><input
class="input"
v-model="item.UpositonS"
type="number"
placeholder="请输入"
maxlength="2"
/>
<text class="fg"></text
><input
class="input"
v-model="item.UpositonE"
type="number"
placeholder="请输入"
maxlength="2"
/>
</view>
<view v-if="'conclusion' in item" class="form-item">
<text class="form-label"
><text class="required">*</text>情况摘要</text
>
<text class="conclusion" @click="showPopup(index)">{{
item.conclusion || "请输入情况摘要"
}}</text>
</view>
<view class="form-item" v-if="'photos' in item">
<text class="form-label"
><text class="required">*</text>现场照片</text
>
<view class="photo-box">
<view class="photo-container">
<view @click="takePhoto(index)" class="photo-btn"> + </view>
<view
v-for="(photo, itemIndex) in item && item.photos"
:key="itemIndex"
class="photo-item"
>
<image :src="photo" class="photo"></image>
<text
class="delete-photo"
@click="deletePhoto(index, itemIndex)"
>×</text
>
</view>
</view>
<view class="photo-limit"
>请对检查项进行拍照留存(限5张)。发现“异常、告警”时,需拍照留存。</view
>
</view>
<view class="photo-limit"
>请对检查项进行拍照留存(限5张)。发现“异常、告警”时,需拍照留存。</view
>
</view>
</view></template
> </view
</view></template
>
</template> </view
><custom-popup
ref="customPopup"
:inspectionItem="inspectionItem"
......@@ -132,7 +134,7 @@ export default {
detail: [
{
label: "是否有告警",
inspectionResult: 0,
inspectionResult: "",
inspectionResultLable: "无",
lableArr: ["无", "有"],
conclusion: "",
......@@ -232,46 +234,75 @@ export default {
this.itemData.isValid = isValid;
this.itemData.inspectionItem = this.inspectionItem;
console.log(222, this.itemData);
if (isAllOne) {
// 全都是正常
this.itemData.status = 1; //1表示已经巡检过没有异常
this.itemData.statusLabel = "已巡检";
} else {
this.itemData.status = 2; //1表示已经巡检过有异常
this.itemData.statusLabel = "巡检异常";
}
this.itemData.status = isAllOne.status; //1表示已经巡检过没有异常
this.itemData.statusLabel = isAllOne.statusLabel;
// console.log(this.itemData);
return this.itemData;
},
// 数据校验方法 true说明有未填项
areAllObjectsValid(arr, skipIndex) {
// 遍历数组中的每个对象
for (let i = 0; i < arr.length; i++) {
const obj = arr[i];
// 如果当前索引大于等于 skipIndex,并且 inspectionResult 为 1,则跳过后续校验
if (i >= skipIndex && obj.inspectionResult === 1) {
break;
}
// 检查对象中的每个属性是否有值
for (const key in obj) {
if (obj.hasOwnProperty(key)) {
// 如果属性值为空(null, undefined, 空字符串等),则校验不通过
if (
obj[key] === null ||
obj[key] === undefined ||
obj[key] === ""
) {
return false;
}
areAllObjectsValid(details) {
// 检查是否有任何项的 inspectionResult 为空字符串
const hasEmptyResult = details.some(
(item) => item.inspectionResult === ""
);
if (hasEmptyResult) {
return false;
}
// 遍历每一项进行检查
for (const item of details) {
if (item.inspectionResult === 0) {
// 如果 inspectionResult 为 0,跳过此项的其他检查
continue;
} else if (item.inspectionResult === 1) {
// 如果 inspectionResult 为 1,检查 conclusion 和 photos
if (
!item.conclusion ||
item.photos.length === 0 ||
!item.deviceId ||
!item.UpositonS ||
!item.UpositonE
) {
return false;
}
} else {
// 其他情况(理论上不应该存在,根据当前规则)
return false;
}
}
// 如果所有对象都通过校验,返回 true
// 所有检查都通过
return true;
},
// 校验是否有异常
areAllInspectionResultsOne(arr) {
return arr.every((obj) => obj.inspectionResult === 0);
areAllInspectionResultsOne(details) {
let hasEmpty = false;
let allZero = true;
let hasOne = false;
for (const item of details) {
if (item.inspectionResult === "") {
hasEmpty = true;
break;
} else if (item.inspectionResult === 1) {
hasOne = true;
allZero = false;
} else if (item.inspectionResult === 0) {
// 继续检查
} else {
// 如果有其他值,可以在这里处理
allZero = false;
}
}
if (hasEmpty) {
return { statusLabel: "未巡检", status: 0 };
} else if (allZero) {
return { statusLabel: "已巡检", status: 1 };
} else if (hasOne) {
return { statusLabel: "巡检异常", status: 2 };
} else {
// 默认情况,可以根据需求调整
return { statusLabel: "未巡检", status: 0 };
}
},
},
};
......
......@@ -21,34 +21,41 @@
</view>
</view>
</view>
<view class="form-item">
<text class="form-label"><text class="required">*</text>情况摘要</text>
<text class="conclusion" @click="showPopup(index)">{{
item.conclusion || "请输入情况摘要"
}}</text>
</view>
<view class="form-item">
<text class="form-label"><text class="required">*</text>现场照片</text>
<view class="photo-box">
<view class="photo-container">
<view @click="takePhoto(index)" class="photo-btn"> + </view>
<view
v-for="(photo, itemIndex) in item && item.photos"
:key="itemIndex"
class="photo-item"
>
<image :src="photo" class="photo"></image>
<text class="delete-photo" @click="deletePhoto(index, itemIndex)"
>×</text
<template v-if="item.inspectionResult === 1">
<view class="form-item">
<text class="form-label"
><text class="required">*</text>情况摘要</text
>
<text class="conclusion" @click="showPopup(index)">{{
item.conclusion || "请输入情况摘要"
}}</text>
</view>
<view class="form-item">
<text class="form-label"
><text class="required">*</text>现场照片</text
>
<view class="photo-box">
<view class="photo-container">
<view @click="takePhoto(index)" class="photo-btn"> + </view>
<view
v-for="(photo, itemIndex) in item && item.photos"
:key="itemIndex"
class="photo-item"
>
<image :src="photo" class="photo"></image>
<text
class="delete-photo"
@click="deletePhoto(index, itemIndex)"
>×</text
>
</view>
</view>
<view class="photo-limit"
>请对检查项进行拍照留存(限5张)。发现“异常、告警”时,需拍照留存。</view
>
</view>
<view class="photo-limit"
>请对检查项进行拍照留存(限5张)。发现“异常、告警”时,需拍照留存。</view
>
</view>
</view> </view
</view></template
> </view
><custom-popup
ref="customPopup"
:inspectionItem="inspectionItem"
......@@ -94,7 +101,7 @@ export default {
detail: [
{
label: "地板、墙壁破损",
inspectionResult: 0,
inspectionResult: "",
inspectionResultLable: "正常",
lableArr: ["正常", "异常"],
conclusion: "",
......@@ -102,7 +109,7 @@ export default {
},
{
label: "机房清洁",
inspectionResult: 0,
inspectionResult: "",
inspectionResultLable: "正常",
lableArr: ["正常", "异常"],
conclusion: "",
......@@ -110,7 +117,7 @@ export default {
},
{
label: "机房通风",
inspectionResult: 0,
inspectionResult: "",
inspectionResultLable: "正常",
lableArr: ["正常", "异常"],
conclusion: "",
......@@ -118,7 +125,7 @@ export default {
},
{
label: "机房照明",
inspectionResult: 0,
inspectionResult: "",
inspectionResultLable: "正常",
lableArr: ["正常", "异常"],
conclusion: "",
......@@ -126,7 +133,7 @@ export default {
},
{
label: "漏水检测",
inspectionResult: 0,
inspectionResult: "",
inspectionResultLable: "正常",
lableArr: ["正常", "异常"],
conclusion: "",
......@@ -226,54 +233,74 @@ export default {
// 处理】数据
getFromData() {
const isValid = this.areAllObjectsValid(this.itemData.detail); //false不通过 true通过
console.log("wlhj", isValid);
const isAllOne = this.areAllInspectionResultsOne(this.itemData.detail);
console.log("isAllOne", isAllOne);
this.itemData.isValid = isValid;
this.itemData.inspectionItem = this.inspectionItem;
if (isAllOne) {
// 全都是正常
this.itemData.status = 1; //1表示已经巡检过没有异常
this.itemData.statusLabel = "已巡检";
} else {
this.itemData.status = 2; //1表示已经巡检过有异常
this.itemData.statusLabel = "巡检异常";
}
this.itemData.status = isAllOne.status; //1表示已经巡检过没有异常
this.itemData.statusLabel = isAllOne.statusLabel;
console.log("查看数据", this.itemData);
return this.itemData;
},
// 数据校验方法 true说明有未填项
areAllObjectsValid(arr) {
for (let i = 0; i < arr.length; i++) {
const obj = arr[i];
const keys = Object.keys(obj);
for (let j = 0; j < keys.length; j++) {
const key = keys[j];
const value = obj[key];
if (value === null || value === undefined || value === "") {
areAllObjectsValid(details) {
// 检查是否有任何项的 inspectionResult 为空字符串
const hasEmptyResult = details.some(
(item) => item.inspectionResult === ""
);
if (hasEmptyResult) {
return false;
}
// 遍历每一项进行检查
for (const item of details) {
if (item.inspectionResult === 0) {
// 如果 inspectionResult 为 0,跳过此项的其他检查
continue;
} else if (item.inspectionResult === 1) {
// 如果 inspectionResult 为 1,检查 conclusion 和 photos
if (!item.conclusion || item.photos.length === 0) {
return false;
}
if (Array.isArray(value)) {
if (value.length === 0) {
return false;
}
for (let k = 0; k < value.length; k++) {
if (typeof value[k] === "object" && value[k] !== null) {
if (!validateArrayObjects([value[k]])) {
return false;
}
}
}
} else if (typeof value === "object" && value !== null) {
if (!validateArrayObjects([value])) {
return false;
}
}
} else {
// 其他情况(理论上不应该存在,根据当前规则)
return false;
}
}
// 所有检查都通过
return true;
},
// 校验是否有异常
areAllInspectionResultsOne(arr) {
return arr.every((obj) => obj.inspectionResult === 0);
areAllInspectionResultsOne(details) {
let hasEmpty = false;
let allZero = true;
let hasOne = false;
for (const item of details) {
if (item.inspectionResult === "") {
hasEmpty = true;
break;
} else if (item.inspectionResult === 1) {
hasOne = true;
allZero = false;
} else if (item.inspectionResult === 0) {
// 继续检查
} else {
// 如果有其他值,可以在这里处理
allZero = false;
}
}
if (hasEmpty) {
return { statusLabel: "未巡检", status: 0 };
} else if (allZero) {
return { statusLabel: "已巡检", status: 1 };
} else if (hasOne) {
return { statusLabel: "巡检异常", status: 2 };
} else {
// 默认情况,可以根据需求调整
return { statusLabel: "未巡检", status: 0 };
}
},
},
};
......
......@@ -24,14 +24,16 @@
>
{{ item.lableArr[1] }}
</view> </view
><input v-if="'value' in item"
><input
v-if="'value' in item && item.inspectionResult === 1"
class="input"
v-model="item.value"
type="text"
placeholder="请输入"
maxlength="3"
/>{{ item.unit }}
/>{{ item.inspectionResult === 1?item.unit:"" }}
</view>
<template v-if="item.inspectionResult === 1">
<view v-if="'conclusion' in item" class="form-item">
<text class="form-label"><text class="required">*</text>情况摘要</text>
<text class="conclusion" @click="showPopup(index)">{{
......@@ -58,7 +60,7 @@
>请对检查项进行拍照留存(限5张)。发现“异常、告警”时,需拍照留存。</view
>
</view>
</view></view
</view></template></view
><custom-popup
ref="customPopup"
:inspectionItem="inspectionItem"
......@@ -104,9 +106,9 @@ export default {
detail: [
{
label: "七氟丙烷灭火气压",
inspectionResult: 0,
inspectionResult: "",
inspectionResultLable: "正常",
lableArr: ["正常", "常"],
lableArr: ["正常", "常"],
conclusion: "",
settingLabel: "气压设定值",
setting: "2MPA-4.2MPA", //设定气压
......@@ -116,17 +118,17 @@ export default {
},
{
label: "消防报警器",
inspectionResult: 0,
inspectionResult: "",
inspectionResultLable: "正常",
lableArr: ["正常", "常"],
lableArr: ["正常", "常"],
conclusion: "",
photos: [],
},
{
label: "防毒面具",
inspectionResult: 0,
inspectionResult: "",
inspectionResultLable: "正常",
lableArr: ["正常", "常"],
lableArr: ["正常", "常"],
conclusion: "",
photos: [],
},
......@@ -142,10 +144,10 @@ export default {
watch: {
defaultData(newVal) {
// 在这里处理数据变化
if (Object.keys(this.defaultData).length !== 0) {
this.itemData = this.defaultData;
}
}
if (Object.keys(this.defaultData).length !== 0) {
this.itemData = this.defaultData;
}
},
},
methods: {
// 拍照
......@@ -219,51 +221,77 @@ export default {
this.itemData.isValid = isValid;
this.itemData.inspectionItem = this.inspectionItem;
console.log(222, this.itemData);
if (isAllOne) {
// 全都是正常
this.itemData.status = 1; //1表示已经巡检过没有异常
this.itemData.statusLabel = "已巡检";
} else {
this.itemData.status = 2; //1表示已经巡检过有异常
this.itemData.statusLabel = "巡检异常";
}
this.itemData.status = isAllOne.status; //1表示已经巡检过没有异常
this.itemData.statusLabel = isAllOne.statusLabel;
// console.log(this.itemData);
return this.itemData;
},
// / 数据校验方法 true说明有未填项
areAllObjectsValid(arr) {
for (let i = 0; i < arr.length; i++) {
const obj = arr[i];
const keys = Object.keys(obj);
for (let j = 0; j < keys.length; j++) {
const key = keys[j];
const value = obj[key];
if (value === null || value === undefined || value === "") {
// 数据校验方法 true说明有未填项
areAllObjectsValid(details) {
// 检查是否有任何项的 inspectionResult 为空字符串
const hasEmptyResult = details.some(
(item) => item.inspectionResult === ""
);
if (hasEmptyResult) {
return false;
}
// 遍历每一项进行检查
for (const item of details) {
if (item.inspectionResult === 0) {
// 如果 inspectionResult 为 0,跳过此项的其他检查
continue;
} else if (item.inspectionResult === 1) {
// 如果 inspectionResult 为 1,检查 conclusion 和 photos
if (
!item.conclusion ||
item.photos.length === 0 ||
(item.hasOwnProperty("value") && !item.value)
) {
return false;
}
if (Array.isArray(value)) {
if (value.length === 0) {
return false;
}
for (let k = 0; k < value.length; k++) {
if (typeof value[k] === "object" && value[k] !== null) {
if (!validateArrayObjects([value[k]])) {
return false;
}
}
}
} else if (typeof value === "object" && value !== null) {
if (!validateArrayObjects([value])) {
return false;
}
}
} else {
// 其他情况(理论上不应该存在,根据当前规则)
return false;
}
}
// 所有检查都通过
return true;
},
// 校验是否有异常
areAllInspectionResultsOne(arr) {
return arr.every((obj) => obj.inspectionResult === 0);
areAllInspectionResultsOne(details) {
let hasEmpty = false;
let allZero = true;
let hasOne = false;
for (const item of details) {
if (item.inspectionResult === "") {
hasEmpty = true;
break;
} else if (item.inspectionResult === 1) {
hasOne = true;
allZero = false;
} else if (item.inspectionResult === 0) {
// 继续检查
} else {
// 如果有其他值,可以在这里处理
allZero = false;
}
}
if (hasEmpty) {
return { statusLabel: "未巡检", status: 0 };
} else if (allZero) {
return { statusLabel: "已巡检", status: 1 };
} else if (hasOne) {
return { statusLabel: "巡检异常", status: 2 };
} else {
// 默认情况,可以根据需求调整
return { statusLabel: "未巡检", status: 0 };
}
},
},
};
......@@ -279,7 +307,7 @@ export default {
.form-label {
font-size: 11.2px;
margin-right: 25.6px;
width: 88px;
width: 100px;
text-align: right;
color: #7c7c7c;
......
......@@ -22,33 +22,41 @@
</view>
</view>
<view class="form-item">
<text class="form-label"><text class="required">*</text>情况摘要</text>
<text class="conclusion" @click="showPopup(index)">{{
item.conclusion || "请输入情况摘要"
}}</text>
</view>
<view class="form-item">
<text class="form-label"><text class="required">*</text>现场照片</text>
<view class="photo-box">
<view class="photo-container">
<view @click="takePhoto(index)" class="photo-btn"> + </view>
<view
v-for="(photo, itemIndex) in item && item.photos"
:key="itemIndex"
class="photo-item"
>
<image :src="photo" class="photo"></image>
<text class="delete-photo" @click="deletePhoto(index, itemIndex)"
>×</text
<template v-if="item.inspectionResult === 1">
<view class="form-item">
<text class="form-label"
><text class="required">*</text>情况摘要</text
>
<text class="conclusion" @click="showPopup(index)">{{
item.conclusion || "请输入情况摘要"
}}</text>
</view>
<view class="form-item">
<text class="form-label"
><text class="required">*</text>现场照片</text
>
<view class="photo-box">
<view class="photo-container">
<view @click="takePhoto(index)" class="photo-btn"> + </view>
<view
v-for="(photo, itemIndex) in item && item.photos"
:key="itemIndex"
class="photo-item"
>
<image :src="photo" class="photo"></image>
<text
class="delete-photo"
@click="deletePhoto(index, itemIndex)"
>×</text
>
</view>
</view>
<view class="photo-limit"
>请对检查项进行拍照留存(限5张)。发现“异常、告警”时,需拍照留存。</view
>
</view>
<view class="photo-limit"
>请对检查项进行拍照留存(限5张)。发现“异常、告警”时,需拍照留存。</view
>
</view>
</view> </view
</view></template
> </view
><custom-popup
ref="customPopup"
:inspectionItem="inspectionItem"
......@@ -94,7 +102,7 @@ export default {
detail: [
{
label: "机柜",
inspectionResult: 0,
inspectionResult: "",
inspectionResultLable: "正常",
lableArr: ["正常", "异常"],
conclusion: "",
......@@ -102,7 +110,7 @@ export default {
},
{
label: "配线架",
inspectionResult: 0,
inspectionResult: "",
inspectionResultLable: "正常",
lableArr: ["正常", "异常"],
conclusion: "",
......@@ -110,7 +118,7 @@ export default {
},
{
label: "电力线路",
inspectionResult: 0,
inspectionResult: "",
inspectionResultLable: "正常",
lableArr: ["正常", "异常"],
conclusion: "",
......@@ -128,10 +136,10 @@ export default {
watch: {
defaultData(newVal) {
// 在这里处理数据变化
if (Object.keys(this.defaultData).length !== 0) {
this.itemData = this.defaultData;
}
}
if (Object.keys(this.defaultData).length !== 0) {
this.itemData = this.defaultData;
}
},
},
mounted() {},
methods: {
......@@ -203,51 +211,72 @@ export default {
const isAllOne = this.areAllInspectionResultsOne(this.itemData.detail);
this.itemData.isValid = isValid;
this.itemData.inspectionItem = this.inspectionItem;
if (isAllOne) {
// 全都是正常
this.itemData.status = 1; //1表示已经巡检过没有异常
this.itemData.statusLabel = "已巡检";
} else {
this.itemData.status = 2; //1表示已经巡检过有异常
this.itemData.statusLabel = "巡检异常";
}
this.itemData.status = isAllOne.status; //1表示已经巡检过没有异常
this.itemData.statusLabel = isAllOne.statusLabel;
console.log(this.itemData);
return this.itemData;
},
// 数据校验方法 true说明有未填项
areAllObjectsValid(arr) {
for (let i = 0; i < arr.length; i++) {
const obj = arr[i];
const keys = Object.keys(obj);
for (let j = 0; j < keys.length; j++) {
const key = keys[j];
const value = obj[key];
if (value === null || value === undefined || value === "") {
areAllObjectsValid(details) {
// 检查是否有任何项的 inspectionResult 为空字符串
const hasEmptyResult = details.some(
(item) => item.inspectionResult === ""
);
if (hasEmptyResult) {
return false;
}
// 遍历每一项进行检查
for (const item of details) {
if (item.inspectionResult === 0) {
// 如果 inspectionResult 为 0,跳过此项的其他检查
continue;
} else if (item.inspectionResult === 1) {
// 如果 inspectionResult 为 1,检查 conclusion 和 photos
if (!item.conclusion || item.photos.length === 0) {
return false;
}
if (Array.isArray(value)) {
if (value.length === 0) {
return false;
}
for (let k = 0; k < value.length; k++) {
if (typeof value[k] === "object" && value[k] !== null) {
if (!validateArrayObjects([value[k]])) {
return false;
}
}
}
} else if (typeof value === "object" && value !== null) {
if (!validateArrayObjects([value])) {
return false;
}
}
} else {
// 其他情况(理论上不应该存在,根据当前规则)
return false;
}
}
// 所有检查都通过
return true;
},
// 校验是否有异常
areAllInspectionResultsOne(arr) {
return arr.every((obj) => obj.inspectionResult === 0);
areAllInspectionResultsOne(details) {
let hasEmpty = false;
let allZero = true;
let hasOne = false;
for (const item of details) {
if (item.inspectionResult === "") {
hasEmpty = true;
break;
} else if (item.inspectionResult === 1) {
hasOne = true;
allZero = false;
} else if (item.inspectionResult === 0) {
// 继续检查
} else {
// 如果有其他值,可以在这里处理
allZero = false;
}
}
if (hasEmpty) {
return { statusLabel: "未巡检", status: 0 };
} else if (allZero) {
return { statusLabel: "已巡检", status: 1 };
} else if (hasOne) {
return { statusLabel: "巡检异常", status: 2 };
} else {
// 默认情况,可以根据需求调整
return { statusLabel: "未巡检", status: 0 };
}
},
},
};
......
......@@ -7,13 +7,13 @@
rightWidth="240"
>
<block slot="left">
<view class="uni-nav-bar-text" @click="back">
<view class="" @click="back">
<text class="iconfont icon-fanhui"></text>
</view>
</block>
<block slot="right" class="nav-right">
<view class="header-buttons">
<button class="button" @click="lookTable">查看样表</button>
<view class="button" @click="lookTable">查看样表</view>
</view>
</block>
</uni-nav-bar>
......@@ -72,19 +72,18 @@
>
<view class="card-content">
<view class="first-row">
<text
v-if="card.status == 0"
class="iconfont icon-weixunjian"
></text>
<text
v-if="card.status == 1"
class="iconfont icon-wancheng"
></text>
<text
v-if="card.status == 2"
class="iconfont icon-shibai1"
></text>
v-if="card.status == 0"
class="iconfont icon-weixunjian"
></text>
<text
v-if="card.status == 1"
class="iconfont icon-wancheng"
></text>
<text
v-if="card.status == 2"
class="iconfont icon-shibai1"
></text>
<text class="status">{{ card.statusLable }}</text>
</view>
<view class="second-row">
......@@ -142,7 +141,7 @@
:key="cardIndex"
@click="getDetailsItem(card.name, card.jfType, card.value)"
>
<view class="card">
<view class="card" :class="{ active: card.name == activeName }">
<view class="card-content">
<view class="first-row">
<image
......@@ -196,7 +195,8 @@ export default {
backValue: "",
all_data: [], //所有数据
jfType: "0", //机房类型
allIsSubmitOne:false,
allIsSubmitOne: false,
activeName: "F座3楼-内环屏蔽机房",
};
},
computed: {
......@@ -277,10 +277,15 @@ export default {
3
);
}
this.allIsSubmitOne = detailsInfo.originData.every(item => item.isSubmit === 1);
const group1 = this.cardsInfo.slice(0, 5);
const group2 = this.cardsInfo.slice(5, 10);
const group3 = this.cardsInfo.slice(10);
this.allIsSubmitOne = detailsInfo.originData.every(
(item) => item.isSubmit === 1
);
let group1 = this.cardsInfo.slice(0, 5);
let group2 = this.cardsInfo.slice(5, 10);
let group3 = this.cardsInfo.slice(10);
if(this.isSign) {
group2 = group2.reverse()
}
this.rows = [group1, group2, group3];
console.log("this.cardsInfo", this.cardsInfo);
......@@ -298,6 +303,7 @@ export default {
},
// 获取机房详情
getDetailsItem(location, jfType, value) {
this.activeName = location;
this.detailsItem = this.detailsInfo.originData[value - 1].details;
this.jfType = this.detailsInfo.originData[value - 1].jfType;
if (this.detailsItem.afxt.detail[2].inspectionResult === 1) {
......@@ -405,6 +411,7 @@ export default {
color: #000000;
line-height: 28.8px;
font-weight: 400;
text-align: center;
}
}
.container {
......@@ -578,6 +585,11 @@ export default {
background-color: rgba(242, 242, 242, 0.6);
box-shadow: 0 1.6px 3.2px rgba(0, 0, 0, 0.1);
position: relative;
&.active {
background: #fafcff;
border: 1px solid rgba(55, 116, 246, 1);
box-shadow: 0px 0px 3px 0px rgba(55, 116, 246, 0.2);
}
&.status1 {
background: #f3f7ff;
.status {
......@@ -609,7 +621,7 @@ export default {
}
}
.status {
font-size: 9.6px;
font-size: 12px;
color: #333333;
}
}
......@@ -617,7 +629,7 @@ export default {
margin-top: 3.2px;
padding-left: 20px;
.location {
font-size: 9.6px;
font-size: 12px;
color: #666666;
}
}
......
......@@ -8,7 +8,7 @@
rightWidth="300"
>
<block slot="left">
<view class="uni-nav-bar-text" @click="back">
<view class="" @click="back">
<text class="iconfont icon-fanhui"></text>
</view>
</block>
......@@ -16,122 +16,119 @@
<!-- Tab 操作区域 -->
<view class="module">
<view class="location">{{ location }}</view>
<view class="action-btn complete-btn" @click="submit(1)"> 完成巡检 </view>
<view class="tab-buttons">
<view
v-for="(tab, index) in tabs"
:key="index"
:class="['tab-item', { active: activeTab === index }]"
@click="switchTab(index)"
><text v-if="tab.status == 0" class="iconfont icon-weixunjian"></text>
><text v-if="tab.status == 0" class="iconfont icon-weixunjian"></text>
<text v-if="tab.status == 1" class="iconfont icon-wancheng"></text>
<text v-if="tab.status == 2" class="iconfont icon-shibai1"></text>
<text class="tab-text">{{ tab.label }}</text>
<view v-if="activeTab === index" class="underline"></view>
</view>
</view>
<view class="tip">
<image
class="tip-icon"
src="@/static/img/add-img/home1.png"
mode="aspectFit"
></image
><view class="text">
<view
class="itemText"
v-for="(item, index) in tabs[activeTab].text"
:key="index"
>{{ item }}</view
>
<view class="module-box">
<view class="tip">
<text class="iconfont icon-tixing"></text
><view class="text">
<view
class="itemText"
v-for="(item, index) in tabs[activeTab].text"
:key="index"
>{{ item }}</view
>
</view>
</view>
<view class="tab-content">
<view class="jfImg">
<image
class="weitu"
src="@/static/img/add-img/weitu.png"
mode=""
></image
></view>
<view class="kong"></view>
<!-- 操作区域 -->
<!-- 物理环境 -->
<wlhj
v-show="checkValueInArray(tabs, 'wlhj', activeTab)"
ref="wlhj"
inspectionItem="物理环境"
:defaultData="list.wlhj"
></wlhj>
<!-- 安防系统 -->
<afxt
v-show="checkValueInArray(tabs, 'afxt', activeTab)"
ref="afxt"
inspectionItem="安防系统"
:defaultData="list.afxt || {}"
></afxt>
<!-- 设备告警 -->
<sbgj
v-show="checkValueInArray(tabs, 'sbgj', activeTab)"
ref="sbgj"
inspectionItem="设备告警"
:defaultData="list.sbgj || {}"
></sbgj>
<!-- 电池状态 -->
<dczt
v-show="checkValueInArray(tabs, 'dczt', activeTab)"
ref="dczt"
inspectionItem="电池状态"
:defaultData="list.dczt || {}"
:jfType="jfType"
></dczt>
<!-- 机房温湿度 -->
<jfwsd
v-show="checkValueInArray(tabs, 'jfwsd', activeTab)"
ref="jfwsd"
inspectionItem="机房温湿度"
:defaultData="list.jfwsd || {}"
></jfwsd>
<!-- 电力系统 -->
<dlxt
v-show="checkValueInArray(tabs, 'dlxt', activeTab)"
ref="dlxt"
inspectionItem="电力系统"
:defaultData="list.dlxt || {}"
></dlxt>
<!-- 消防系统 -->
<xfxt
v-show="checkValueInArray(tabs, 'xfxt', activeTab)"
ref="xfxt"
inspectionItem="消防系统"
:defaultData="list.xfxt || {}"
></xfxt>
<!-- 线路情况 -->
<xlqk
v-show="checkValueInArray(tabs, 'xlqk', activeTab)"
ref="xlqk"
inspectionItem="线路情况"
:defaultData="list.xlqk || {}"
></xlqk>
<!-- 其它 -->
<qt
v-show="checkValueInArray(tabs, 'qt', activeTab)"
ref="qt"
inspectionItem="其它"
:defaultData="list.qt || {}"
></qt>
</view>
</view>
<view class="tab-content">
<view class="jfImg">
<image
class="weitu"
src="@/static/img/add-img/weitu.png"
mode="aspectFit"
></image
></view>
<view class="kong"></view>
<!-- 操作区域 -->
<!-- 物理环境 -->
<wlhj
v-show="checkValueInArray(tabs, 'wlhj', activeTab)"
ref="wlhj"
inspectionItem="物理环境"
:defaultData="list.wlhj"
></wlhj>
<!-- 安防系统 -->
<afxt
v-show="checkValueInArray(tabs, 'afxt', activeTab)"
ref="afxt"
inspectionItem="安防系统"
:defaultData="list.afxt || {}"
></afxt>
<!-- 设备告警 -->
<sbgj
v-show="checkValueInArray(tabs, 'sbgj', activeTab)"
ref="sbgj"
inspectionItem="设备告警"
:defaultData="list.sbgj || {}"
></sbgj>
<!-- 电池状态 -->
<dczt
v-show="checkValueInArray(tabs, 'dczt', activeTab)"
ref="dczt"
inspectionItem="电池状态"
:defaultData="list.dczt || {}"
:jfType="jfType"
></dczt>
<!-- 机房温湿度 -->
<jfwsd
v-show="checkValueInArray(tabs, 'jfwsd', activeTab)"
ref="jfwsd"
inspectionItem="机房温湿度"
:defaultData="list.jfwsd || {}"
></jfwsd>
<!-- 电力系统 -->
<dlxt
v-show="checkValueInArray(tabs, 'dlxt', activeTab)"
ref="dlxt"
inspectionItem="电力系统"
:defaultData="list.dlxt || {}"
></dlxt>
<!-- 消防系统 -->
<xfxt
v-show="checkValueInArray(tabs, 'xfxt', activeTab)"
ref="xfxt"
inspectionItem="消防系统"
:defaultData="list.xfxt || {}"
></xfxt>
<!-- 线路情况 -->
<xlqk
v-show="checkValueInArray(tabs, 'xlqk', activeTab)"
ref="xlqk"
inspectionItem="线路情况"
:defaultData="list.xlqk || {}"
></xlqk>
<!-- 其它 -->
<qt
v-show="checkValueInArray(tabs, 'qt', activeTab)"
ref="qt"
inspectionItem="其它"
:defaultData="list.qt || {}"
></qt>
</view>
</view>
<view class="submit-module">
<button class="action-btn" @click="submit(0)">暂存</button>
<button
<view class="action-btn" @click="submit(0)">暂存</view>
<!-- <view
v-if="isSubmitEnabled"
class="action-btn complete-btn"
@click="submit(1)"
>
完成巡检
</button>
<button v-else class="action-btn complete-btn" @click="nextTab">
下一项
</button>
</view> -->
<view class="action-btn complete-btn" @click="nextTab"> 下一项 </view>
</view>
</view>
</template>
......@@ -343,6 +340,7 @@ export default {
let tabList = this.deepClone(dataObj);
let posItem = tabList[this.value - 1];
posItem.details = paramsObj;
posItem.isSubmit = isSubmit;
if (!this.checkInspectionResult(paramsObj)) {
posItem.status = 1; //1表示已经巡检过没有异常
posItem.statusLable = "已巡检";
......@@ -422,14 +420,9 @@ export default {
for (const category in data) {
const categoryData = data[category];
// 检查该类别下的 detail 数组
if (categoryData.detail && Array.isArray(categoryData.detail)) {
for (const item of categoryData.detail) {
// 如果发现任意一个 inspectionResult 为 1,立即返回 true(异常)
if (item.inspectionResult === 1) {
return true;
}
}
// 如果发现任意一个 inspectionResult 为 1,立即返回 true(异常)
if (categoryData.status === 2) {
return true;
}
}
......@@ -438,6 +431,7 @@ export default {
},
// 提交
submit(isSubmit = 1) {
console.log("提交时查看一下数据", this.getAllChildFormData());
let allValid = this.allValid(this.getAllChildFormData());
// 校验是否通过
if (isSubmit && !allValid) {
......@@ -560,10 +554,11 @@ export default {
// });
// return false;
// }
let data = this.getAllChildFormData()
console.log("哒哒哒",data)
console.log("哒哒哒",data,data[this.tabs[this.activeTab].value])
this.tabs[this.activeTab].status = data[this.tabs[this.activeTab].value].status
let data = this.getAllChildFormData();
console.log("哒哒哒", data);
console.log("哒哒哒", data, data[this.tabs[this.activeTab].value]);
this.tabs[this.activeTab].status =
data[this.tabs[this.activeTab].value].status;
if (this.activeTab === this.tabs.length - 1) {
this.isSubmitEnabled = true;
} else {
......@@ -572,6 +567,9 @@ export default {
},
// 切换 Tab
switchTab(index) {
let data = this.getAllChildFormData();
this.tabs[this.activeTab].status =
data[this.tabs[this.activeTab].value].status || 0;
this.activeTab = index;
if (this.activeTab !== this.tabs.length - 1) {
this.isSubmitEnabled = false;
......@@ -615,14 +613,14 @@ export default {
.container {
padding: 19.2px;
height: 100vh;
height: calc(100vh - 160px);
}
.module {
background: #ffffff;
border-radius: 9.6px;
padding: 12.8px 20px;
min-height: calc(100vh - 80px);
overflow: hidden;
position: relative;
.location {
font-size: 14.4px;
color: #000000;
......@@ -630,12 +628,35 @@ export default {
font-weight: 500;
margin-bottom: 14.4px;
}
.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;
position: absolute;
right: 20px;
top: 15px;
&.complete-btn {
background-image: linear-gradient(180deg, #3773f6 0%, #2c57f6 99%);
color: #ffffff;
}
}
}
.tab-content {
height: calc(100vh - 280px); /* 根据实际情况调整高度 */
.module-box {
height: calc(100vh - 212px); /* 根据实际情况调整高度 */
overflow-y: auto; /* 垂直方向滚动 */
overflow-x: hidden; /* 防止水平方向滚动 */
}
.tab-content {
margin-top: 12.8px;
}
.title-bar {
display: flex;
align-items: center;
......@@ -699,9 +720,9 @@ export default {
padding: 4.8px 9.6px;
display: flex;
.tip-icon {
width: 11.2px;
height: 11.2px;
.icon-tixing {
color: #3774f6;
font-size: 9.6px;
margin-right: 6.4px;
}
.text {
......
......@@ -31,7 +31,7 @@
<!-- 关闭按钮 -->
<div class="close-button">
<text class="iconfont icon-a-bianzu16beifen" @click="close"></text>
<text class="iconfont icon-shibai1" @click="close"></text>
</div>
</view>
</view>
......@@ -317,6 +317,7 @@ export default {
<style scoped lang="less">
.synchronous-dialog {
position: fixed;
z-index: 999;
top: 0;
left: 0;
width: 100%;
......@@ -412,7 +413,6 @@ export default {
left: 50%;
transform: translateX(-50%);
.iconfont {
color: #fff;
font-size: 24px;
}
}
......
......@@ -8,14 +8,14 @@
rightWidth="300"
>
<block slot="left">
<view class="uni-nav-bar-text" @click="back">
<view class="" @click="back">
<text class="iconfont icon-fanhui"></text>
</view>
</block>
<block slot="right" class="nav-right">
<view class="header-buttons">
<button class="button" @click="clickInspection(1)">机房巡检</button>
<button class="button" @click="clickInspection(2)">井道巡检</button>
<view class="button" @click="clickInspection(1)">机房巡检</view>
<view class="button" @click="clickInspection(2)">井道巡检</view>
</view>
</block>
</uni-nav-bar>
......@@ -272,6 +272,7 @@ export default {
align-items: center;
justify-content: center;
text-align: center;
z-index: 999;
.iconfont {
font-size: 16px;
......@@ -296,7 +297,7 @@ export default {
color: #000000;
line-height: 28.8px;
font-weight: 400;
border: 0;
text-align: center;
}
}
.inspection-management {
......
......@@ -31,7 +31,7 @@
<!-- 关闭按钮 -->
<div class="close-button">
<text class="iconfont icon-a-bianzu16beifen" @click="close"></text>
<text class="iconfont icon-shibai1" @click="close"></text>
</div>
</view>
</view>
......@@ -117,8 +117,8 @@ export default {
// 复制
copyImagesToFolder(imagePaths, targetPath).then((res) => {
uni.navigateTo({
url: "/pages/listingManagement/index?backValue=home",
})
url: "/pages/listingManagement/index?backValue=home",
});
});
});
},
......@@ -258,6 +258,7 @@ export default {
<style scoped lang="less">
.synchronous-dialog {
position: fixed;
z-index: 999;
top: 0;
left: 0;
width: 100%;
......@@ -353,7 +354,6 @@ export default {
left: 50%;
transform: translateX(-50%);
.iconfont {
color: #fff;
font-size: 24px;
}
}
......
......@@ -34,14 +34,17 @@
</block>
<block slot="right" class="nav-right">
<view class="header-right">
<text class="iconfont icon-quanxuan"></text>
<text class="iconfont icon-shanchu"></text>
<text
class="iconfont icon-quanxuan"
@click.stop="toggleSelectAll"
></text>
<text class="iconfont icon-shanchu" @click.stop="deletePhotos"
>删除</text
>
</view>
</block>
</uni-nav-bar>
<!-- 第二个模块:选中条数显示 -->
<!-- 第三个模块:照片显示模块 -->
<view class="photo-box">
<view class="photo-list">
<view
......@@ -52,20 +55,20 @@
<view class="group-header">
<view
class="circle-button"
:class="{ active: filteredData(selectedPhotos, group, date) }"
@click.stop="toggleSelectAll(date)"
:class="{ active: isDateAllSelected(group, date) }"
@click.stop="toggleSelectDate(date)"
>
<text
class="inner-circle"
v-if="filteredData(selectedPhotos, group, date)"
v-if="isDateAllSelected(group, date)"
></text>
</view>
<text class="date">{{ date }}</text>
</view>
<view class="card-list">
<view
v-for="photo in group"
:key="photo.id"
v-for="(photo, index) in group"
:key="index"
class="card"
@click="previewPhoto(photo)"
>
......@@ -77,41 +80,37 @@
>
<text v-if="photo.selected"></text>
</view>
<view class="delete-icon" @click.stop="deletePhoto(photo)"
>×</view
>
<text
class="delete-icon iconfont icon-shanchu"
@click.stop="deletePhoto(photo)"
></text>
<view class="type">{{
photo.synchronization ? "已同步" : "待同步"
}}</view>
<view class="photo-info">
<text class="no">照片编号:{{ photo.id }}</text>
</view>
<view v-if="false" class="photo-info">
<text>编号:{{ photo.id }}</text>
<text>时间:{{ photo.time }}</text>
<text
>状态:{{ photo.synchronization ? "已同步" : "待同步" }}</text
>
</view>
</view>
</view>
</view>
</view></view
>
</view>
</view>
<view
v-if="selectedPhotos && selectedPhotos.length"
v-if="selectedCount"
class="inspection-button"
@click="openDialog(true)"
@click="showSyncDialog = true"
>数据同步</view
>
<view v-else class="inspection-button" @click="takePhoto">设备拍照</view>
<!-- 打包弹窗 -->
<Dialog
v-show="isDialog && selectedPhotos.length"
v-show="showSyncDialog"
ref="Dialog"
:list="selectedPhotos"
:photos="photos"
@close="openDialog(false)"
@close="showSyncDialog = false"
@getDetails="getDetails"
></Dialog>
</view>
......@@ -127,20 +126,19 @@ import {
writeDeviceData,
} from "@/utils/IoReadingAndWriting.js";
import { getDeviceDataDetails } from "@/request/index.js";
export default {
components: {
Dialog,
},
data() {
return {
isDialog: false, //
photos: [], // 所有照片
selectedPhotos: [], // 选中的照片
syncedPhotos: [], // 已同步的照片
showSyncDialog: false,
photos: [],
selectedPhotos: [],
};
},
computed: {
// 按日期分组照片
photoGroups() {
const groups = {};
this.photos.forEach((photo) => {
......@@ -152,7 +150,6 @@ export default {
});
return groups;
},
// 选中的照片数量
selectedCount() {
return this.selectedPhotos.length;
},
......@@ -160,136 +157,65 @@ export default {
return this.$store.state.now_user || {};
},
},
onLoad(options) {
onLoad() {
this.getDetails();
},
mounted() {},
methods: {
back() {
uni.navigateTo({
url: "/pages/home/home",
});
}, // 回显数据
},
headerClose() {
this.clearSelection();
},
clearSelection() {
this.photos.forEach((photo) => (photo.selected = false));
this.selectedPhotos = [];
},
// 数据获取
getDetails() {
uni.showLoading();
getDeviceDataDetails()
.then((res) => {
this.photos = res;
console.log("this.photos", this.photos);
uni.hideLoading();
})
.catch((error) => {
uni.showToast({
title: error.msg,
icon: "none",
duration: 1000,
});
uni.showToast({ title: error.msg, icon: "none" });
uni.hideLoading();
});
},
// 拍照
takePhoto() {
let $this = this;
uni.chooseImage({
count: 1,
sourceType: ["camera"], // 可以从相机拍摄
success: (res) => {
console.log(111, res);
const tempFilePath = res.tempFilePaths[0];
// 存储照片到本地
uni.saveImageToPhotosAlbum({
filePath: tempFilePath,
success: async function (res) {
console.log("图片已成功保存到相册", tempFilePath, res);
const base64 = await $this.convertFileToBase64(tempFilePath);
// 数据合成
const newPhoto = {
id: $this.getFileName(tempFilePath),
url: base64,
imgPath: res.path,
date: moment(new Date()).format("yyyy-MM-DD"),
time: moment(new Date()).format("yyyy-MM-DD HH:mm"),
selected: false,
synchronization: false,
};
console.log("newPhoto", newPhoto);
$this.photos.unshift(newPhoto);
console.log("$this.photos", $this.photos);
$this.addPhotos(
$this.photos,
`照片编号(${newPhoto.id})`,
"设备上架"
);
},
fail: function (err) {
console.error("保存图片到相册失败:", err);
},
});
},
});
},
// 转化为base64
convertFileToBase64(filePath) {
return new Promise((resolve, reject) => {
plus.io.resolveLocalFileSystemURL(
filePath,
function (entry) {
entry.file(
function (file) {
const reader = new plus.io.FileReader();
reader.onloadend = function (evt) {
const base64 = evt.target.result; // 获取 Base64 数据
resolve(base64); // 返回 Base64 数据
};
reader.readAsDataURL(file); // 读取文件并转换为 Base64
},
function (error) {
reject("获取文件对象失败:" + error.message);
}
);
},
function (error) {
reject("解析文件路径失败:" + error.message);
}
);
});
},
// 照片数据处理
addPhotos(photos, title, type) {
// 传入数据 文案 操作类型
// let deviceData = this.$store.state.deviceData; //获取全部数据
// deviceData = photos;
// 写入设备上架文件
this.$store.commit("SET_DEVICEDATA", photos);
writeDeviceData(photos, this.userInfo.user);
// 日志
let logContent = getLogContent(LOG_TYPE_ENUM.edit, title, type);
const log_list = this.$store.state.log_list;
logContent.inspectionType = "3";
log_list.push(logContent);
this.$store.commit("SET_LOG_LIST", log_list);
addLog(log_list).then((res) => {
console.log("日志文件写入成功");
});
// 日志
console.log("photos", photos, logContent);
},
// 从路径中提取文件名(去掉路径和扩展名)
getFileName(filePath) {
// 获取路径中的文件名部分(包括扩展名)
const fileNameWithExt = filePath.split("/").pop();
// 去掉扩展名
const fileName = fileNameWithExt.split(".").shift();
return fileName;
},
// 根据当前行的日期获取照片集合
filteredData(data, group, targetDate) {
let filteredData =
data && data.filter((item) => item.date === targetDate);
return filteredData.length == group.length;
// 拍照功能
async takePhoto() {
try {
const res = await uni.chooseImage({ count: 1, sourceType: ["camera"] });
const tempFilePath = res.tempFilePaths[0];
const saveRes = await uni.saveImageToPhotosAlbum({
filePath: tempFilePath,
});
const base64 = await this.convertFileToBase64(tempFilePath);
const newPhoto = {
id: this.getFileName(tempFilePath),
url: base64,
imgPath: saveRes.path,
date: moment().format("YYYY-MM-DD"),
time: moment().format("YYYY-MM-DD HH:mm"),
selected: false,
synchronization: false,
};
this.photos.unshift(newPhoto);
this.addPhotos(this.photos, `照片编号(${newPhoto.id})`, "设备上架");
} catch (err) {
console.error("拍照保存失败:", err);
}
},
// 切换选中状态
// 选择功能
toggleSelect(photo) {
photo.selected = !photo.selected;
if (photo.selected) {
......@@ -300,23 +226,43 @@ export default {
);
}
},
// 全选/取消全选
toggleSelectAll(date) {
isDateAllSelected(group, date) {
return group.every((photo) => photo.selected);
},
toggleSelectDate(date) {
const group = this.photoGroups[date];
const allSelected = group.every((photo) => photo.selected);
const isGroupAllSelected = this.isDateAllSelected(group, date);
group.forEach((photo) => {
photo.selected = !allSelected;
if (photo.selected) {
photo.selected = !isGroupAllSelected;
this.updateSelectedPhotos(photo);
});
},
toggleSelectAll() {
const isAllSelected = this.photos.length === this.selectedCount;
this.photos.forEach((photo) => {
photo.selected = !isAllSelected;
this.updateSelectedPhotos(photo);
});
},
updateSelectedPhotos(photo) {
if (photo.selected) {
if (!this.selectedPhotos.some((p) => p.id === photo.id)) {
this.selectedPhotos.push(photo);
} else {
this.selectedPhotos = this.selectedPhotos.filter(
(p) => p.id !== photo.id
);
}
});
console.log(this.selectedPhotos);
} else {
this.selectedPhotos = this.selectedPhotos.filter(
(p) => p.id !== photo.id
);
}
},
// 删除照片
// 删除功能
deletePhoto(photo) {
this.photos = this.photos.filter((p) => p.id !== photo.id);
this.selectedPhotos = this.selectedPhotos.filter(
......@@ -324,23 +270,80 @@ export default {
);
this.addPhotos(this.photos, "删除照片", "删除");
},
// 预览照片
deletePhotos() {
uni.showModal({
title: "提示",
content: "确认删除选中的照片?",
success: (res) => {
if (res.confirm) {
const selectedIds = this.selectedPhotos.map((p) => p.id);
this.photos = this.photos.filter(
(p) => !selectedIds.includes(p.id)
);
this.clearSelection();
this.addPhotos(this.photos, "批量删除照片", "删除");
uni.showToast({ title: "删除成功", icon: "success" });
}
},
});
},
// 其他功能
previewPhoto(photo) {
uni.previewImage({
urls: this.photos.map((p) => p.url),
current: photo.url,
});
},
openDialog(show) {
this.isDialog = show;
if (!show) {
this.getDetails();
}
async convertFileToBase64(filePath) {
return new Promise((resolve, reject) => {
plus.io.resolveLocalFileSystemURL(
filePath,
(entry) => {
entry.file((file) => {
const reader = new plus.io.FileReader();
reader.onloadend = (evt) => resolve(evt.target.result);
reader.readAsDataURL(file);
}, reject);
},
reject
);
});
},
getFileName(filePath) {
return filePath.split("/").pop().split(".").shift();
},
addPhotos(photos, title, type) {
this.$store.commit("SET_DEVICEDATA", photos);
writeDeviceData(photos, this.userInfo.user);
const logContent = getLogContent(LOG_TYPE_ENUM.edit, title, type);
const log_list = [
...this.$store.state.log_list,
{
...logContent,
inspectionType: "3",
},
];
this.$store.commit("SET_LOG_LIST", log_list);
addLog(log_list);
},
},
};
</script>
<style lang="less" scoped>
/* 保持原有的样式不变 */
.container {
background-image: linear-gradient(115deg, #e8f0fb 0%, #e1ebfa 100%);
height: 100%;
}
.uni-nav-bar-text {
height: 28.8px;
width: 28.8px;
......@@ -375,8 +378,8 @@ export default {
.nav-right {
width: 192px;
}
::v-deep .uni-navbar__header-btns-left{
width: 300px!important;
::v-deep .uni-navbar__header-btns-left {
width: 300px !important;
}
.header-buttons {
display: flex;
......@@ -393,7 +396,6 @@ export default {
}
}
.header-right {
.iconfont {
margin: 0 auto;
&.icon-quanxuan {
......@@ -402,41 +404,6 @@ export default {
}
}
.container {
background-image: linear-gradient(115deg, #e8f0fb 0%, #e1ebfa 100%);
height: 100%;
}
.header {
display: flex;
justify-content: space-between;
align-items: center;
margin-bottom: 12.8px;
.title {
display: flex;
align-items: center;
.blue-line {
width: 3.2px;
height: 16px;
background-color: blue;
margin-right: 6.4px;
}
}
.buttons {
display: flex;
.btn {
width: 89.6px;
height: 28.8px;
border-radius: 14.4px;
margin-left: 6.4px;
}
}
}
.photo-box {
width: 100%;
height: 100%;
......@@ -505,7 +472,6 @@ export default {
position: absolute;
bottom: 26.4px;
left: 6.4px;
background-color: rgba(255, 0, 0, 0.8);
border-radius: 50%;
width: 19.2px;
height: 19.2px;
......
......@@ -4,7 +4,7 @@
<view class="login_wrap">
<view class="top-module">
<image src="@/static/logo.png" alt="" />
<image src="@/static/logo.png" mode="aspectFit" alt="" />
<view class="title">杭州内网监管在线-运维在线</view>
</view>
......@@ -61,8 +61,8 @@
// user: "bjqxj",
// pd: "JF85250920",
user: "admin", // 超管账号
pd: "JF123456",
user: "叶一凡", // 超管账号
pd: "123456",
},
backButtonPress: 0,
personList: [],
......
......@@ -37,8 +37,8 @@
</view>
</view>
<view class="row-item bottom-row">
<button class="button btn" @click="handleClose">取消</button>
<button class="button" @click="handleConfirm">确认</button>
<view class="button btn" @click="handleClose">取消</view>
<view class="button" @click="handleConfirm">确认</view>
</view>
</view>
</view>
......
......@@ -14,7 +14,7 @@
</block>
<block slot="right" class="nav-right">
<view class="header-buttons">
<button class="button" @click="lookTable">查看样表</button>
<view class="button" @click="lookTable">查看样表</view>
</view>
</block>
</uni-nav-bar>
......@@ -474,6 +474,7 @@ export default {
color: #000000;
line-height: 28.8px;
font-weight: 400;
text-align: center;
}
}
......@@ -608,7 +609,7 @@ export default {
display: flex;
align-items: center;
justify-content: center;
font-size: 11.2px;
font-size: 12px;
color: #333333;
cursor: pointer;
......@@ -727,7 +728,7 @@ export default {
}
.status-text {
font-size: 10.5px;
font-size: 12px;
color: #7c7c7c;
text-align: center;
line-height: 16.5px;
......@@ -737,7 +738,7 @@ export default {
.info-line {
margin-left: 20px;
font-size: 10.5px;
font-size: 12px;
color: #000000;
line-height: 16.5px;
font-weight: 400;
......
......@@ -48,12 +48,7 @@
</view>
</view>
<view class="tip">
<image
class="tip-icon"
src="@/static/img/add-img/home1.png"
mode="aspectFit"
></image
>{{ tabs[activeTab].text }}
<text class="iconfont icon-tixing"></text>{{ tabs[activeTab].text }}
</view>
<view class="tab-content">
<!-- 操作区域 -->
......@@ -122,17 +117,17 @@
</button>
</view> -->
<view class="submit-module">
<button class="action-btn" @click="submit(0)">暂存</button>
<button
<view class="action-btn" @click="submit(0)">暂存</view>
<view
v-if="isSubmitEnabled"
class="action-btn complete-btn"
@click="submit(1)"
>
完成巡检
</button>
<button v-else class="action-btn complete-btn" @click="nextTab">
</view>
<view v-else class="action-btn complete-btn" @click="nextTab">
下一项
</button> </view
</view> </view
><custom-popup
ref="customPopup"
:inspectionItem="tabs[activeTab].label"
......@@ -796,9 +791,9 @@ export default {
font-weight: 400;
padding: 0 9.6px;
.tip-icon {
width: 11.2px;
height: 11.2px;
.icon-tixing {
color: #3774f6;
font-size: 11.2px;
margin-right: 6.4px;
}
}
......
static/img/add-img/home1.png

49.6 KB | W: | H:

static/img/add-img/home1.png

33.1 KB | W: | H:

static/img/add-img/home1.png
static/img/add-img/home1.png
static/img/add-img/home1.png
static/img/add-img/home1.png
  • 2-up
  • Swipe
  • Onion skin
......@@ -58,13 +58,22 @@ export const FILE_ENUM = {
// 内置的用户信息
export const USER_LiST = [
// name-> roleName
// {
// userId: 1, // 有用
// user: "admin", // 有用 谁创建,谁有权限编辑和删除
// passWord: "JF123456", // 有用
// roleName: "超管", // 有用 -- 职位名称
// unitName: "超管所属单位", // 所属单位
// isAdmin: true, // 标识超管权限
// LastSynchronizationTime: "", // 上次同步时间
// },
{
userId: 1, // 有用
user: "admin", // 有用 谁创建,谁有权限编辑和删除
passWord: "JF123456", // 有用
roleName: "超管", // 有用 -- 职位名称
unitName: "超管所属单位", // 所属单位
isAdmin: true, // 标识超管权限
userId: 0, // 有用
user: "叶一凡", // 有用 谁创建,谁有权限编辑和删除
passWord: "123456", // 有用
roleName: "运维", // 有用 -- 职位名称
unitName: "运维", // 所属单位
isAdmin: false, // 标识超管权限
LastSynchronizationTime: "", // 上次同步时间
},
{
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论