提交 59bad0b2 authored 作者: 何宗全's avatar 何宗全

巡检月报和年报

上级 713c576b
......@@ -73,8 +73,8 @@
},
toPage() {
const url =
this.details.inspectionType == 1 ?
`/pages/inspectionContent/inspectionContentList?isDisable=${
this.details.inspectionType != 2 ?
`/pages/inspectionContent/inspectionContentList?inspectionType=${this.details.inspectionType}&isDisable=${
this.isDisable ? 1 : 0
}` :
`/pages/shaftInspection/shaftInspectionList?isDisable=${
......
......@@ -78,17 +78,6 @@
"navigationBarTitleText": ""
}
},
// 机房月度巡检列表
{
"path": "pages/inspectionContent/inspectionContentMonthlyList",
"style": {
"navigationBarTitleText": "",
"app-plus": {
// 将回弹属性关掉
"bounce": "none"
}
}
},
// 机房月度巡检新页面
{
"path": "pages/inspectionContent/inspectionContentMonthlyNew",
......@@ -96,17 +85,6 @@
"navigationBarTitleText": ""
}
},
// 机房年度巡检列表
{
"path": "pages/inspectionContent/inspectionContentYearList",
"style": {
"navigationBarTitleText": "",
"app-plus": {
// 将回弹属性关掉
"bounce": "none"
}
}
},
// 机房年度巡检新页面
{
"path": "pages/inspectionContent/inspectionContentYearNew",
......
......@@ -72,7 +72,7 @@
<script>
import { copyDirectory } from "@/utils/IoReadingAndWriting.js";
import inspectApi from "@/api/inspect.js";
import { cleanTimeoutDataApi } from '@/api/base.js'
import { cleanTimeoutDataApi } from "@/api/base.js";
export default {
data() {
return {
......@@ -80,7 +80,7 @@ export default {
{
image: "../../static/img/jf.png",
text: "机房日常巡检",
url: "/pages/inspectionContent/inspectionContentList?backValue=home",
url: "/pages/inspectionContent/inspectionContentList?backValue=home&inspectionType=1",
},
{
image: "../../static/img/jd.png",
......@@ -95,12 +95,12 @@ export default {
{
image: "../../static/img/jf.png",
text: "机房月度巡检",
url: "/pages/inspectionContent/inspectionContentMonthlyList?backValue=home",
url: "/pages/inspectionContent/inspectionContentList?backValue=home&inspectionType=3",
},
{
image: "../../static/img/jf.png",
text: "机房年度巡检",
url: "/pages/inspectionContent/inspectionContentYearList?backValue=home",
url: "/pages/inspectionContent/inspectionContentList?backValue=home&inspectionType=4",
},
],
userName: this.$store.state.now_user.user,
......@@ -164,7 +164,7 @@ export default {
uni.setStorageSync("now_user", this.$store.state.now_user);
uni.setStorageSync(
"last_time",
this.$store.state.now_user.LastSynchronizationTime || ""
this.$store.state.now_user.LastSynchronizationTime || "",
);
},
});
......
......@@ -77,13 +77,21 @@ export default {
return {
rooms: [
{
text: "机房巡检",
text: "机房日常巡检",
value: "1",
},
{
text: "井道巡检",
value: "2",
},
{
text: "机房月度巡检",
value: "11",
},
{
text: "机房年度巡检",
value: "12",
},
],
formData: {
inspectionType: "",
......
......@@ -7,443 +7,141 @@
></image> -->
<view class="container">
<!-- 物理环境 -->
<view v-if="detailsItem.wlhj" class="container-item">
<view class="title">物理环境</view>
<view class="cards">
<view
v-for="(item, index) in detailsItem.wlhj.detail"
:key="index"
class="cards-item"
>
<view class="name"
>{{ item.label
}}<text
class="status"
:class="{ warning: item.inspectionResult === 1 }"
>{{ item.inspectionResultLable }}</text
></view
>
<view class="list">
<view class="label">情况描述:</view>
<view class="content">
{{ item.conclusion }}
</view>
</view>
<view class="list">
<view class="label">现场照片:</view>
<view v-if="item.photos.length === 0" class="content">
未拍摄照片
</view>
<view v-else class="content">
<image
v-for="(url, urlIndex) in item.photos"
:key="urlIndex"
class="image-item"
:src="url"
mode="aspectFit"
@click="previewImage(item.photos, urlIndex)"
></image>
</view>
</view>
</view>
</view>
</view>
<detailItem
v-if="detailsItem.wlhj"
:detailObj="detailsItem.wlhj"
title="物理环境"
></detailItem>
<!-- 安防系统 -->
<view v-if="detailsItem.afxt" class="container-item">
<view class="title">安防系统</view>
<view class="cards">
<view
v-for="(item, index) in detailsItem.afxt.detail"
:key="index"
class="cards-item"
v-if="showItem(item)"
>
<template></template>
<view class="name"
>{{ item.label
}}<text
class="status"
:class="{ warning: item.inspectionResult === 1 }"
>{{ item.inspectionResultLable }}</text
></view
>
<view class="list">
<view class="label">情况描述:</view>
<view class="content">
{{ item.conclusion }}
</view>
</view>
<view class="list">
<view class="label">现场照片:</view>
<view
v-if="item.photos && item.photos.length === 0"
class="content"
>
未拍摄照片
</view>
<view v-else class="content">
<image
v-for="(url, urlIndex) in item.photos"
:key="urlIndex"
class="image-item"
:src="url"
mode="aspectFit"
@click="previewImage(item.photos, urlIndex)"
></image>
</view>
</view>
</view>
</view>
</view>
<detailItem
v-if="detailsItem.afxt"
:detailObj="detailsItem.afxt"
title="安防系统"
:isShowItem="true"
></detailItem>
<!-- 电池状态 -->
<view v-if="detailsItem.dczt" class="container-item">
<view class="title">电池状态</view>
<view class="cards">
<view
v-for="(item, index) in detailsItem.dczt.detail"
:key="index"
class="cards-item"
>
<view class="name"
>{{ item.label
}}<text
class="status"
:class="{ warning: item.inspectionResult === 1 }"
>{{ item.inspectionResultLable }}</text
></view
>
<view class="list">
<view class="label">{{ item.settingLabelShow }}:</view>
<view class="content">
{{ item.setting }}
</view>
</view>
<!-- <view class="list">
<view class="label">{{ item.sjLabelShow }}:</view>
<view class="content"> {{ item.value }}{{ item.unit }} </view>
</view> -->
<view class="list">
<view class="label">情况描述:</view>
<view class="content">
{{ item.conclusion }}
</view>
</view>
<view class="list">
<view class="label">现场照片:</view>
<view v-if="item.photos.length === 0" class="content">
未拍摄照片
</view>
<view v-else class="content">
<image
v-for="(url, urlIndex) in item.photos"
:key="urlIndex"
class="image-item"
:src="url"
mode="aspectFit"
@click="previewImage(item.photos, urlIndex)"
></image>
</view>
</view>
</view>
</view>
</view>
<detailItem
v-if="detailsItem.dczt"
:detailObj="detailsItem.dczt"
title="电池状态"
type="1"
></detailItem>
<!-- 设备告警 -->
<view v-if="detailsItem.sbgj" class="container-item">
<view class="title">设备告警</view>
<view class="cards">
<view
v-for="(item, index) in detailsItem.sbgj.detail"
:key="index"
class="cards-item sbgj"
>
<view class="name"
>{{ item.label
}}<text
class="status"
:class="{ warning: item.inspectionResult === 1 }"
>{{ item.inspectionResultLable }}</text
></view
>
<view v-if="item.inspectionResult === 1" class="list">
<view class="label">故障设备:</view>
<view class="content">
<text v-for="(current,idx) in item.cabinets" :key="idx">
【{{ current.deviceId }}机柜,{{ current.UpositonS }}~{{
current.UpositonE
}}U】
</text>
</view>
</view>
<view class="list">
<view class="label">情况描述:</view>
<view class="content">
{{ item.conclusion }}
</view>
</view>
<view class="list">
<view class="label">现场照片:</view>
<view v-if="item.photos.length === 0" class="content">
未拍摄照片
</view>
<view v-else class="content">
<image
v-for="(url, urlIndex) in item.photos"
:key="urlIndex"
class="image-item"
:src="url"
mode="aspectFit"
@click="previewImage(item.photos, urlIndex)"
></image>
</view>
</view>
</view>
</view>
</view>
<detailItem
v-if="detailsItem.sbgj"
:detailObj="detailsItem.sbgj"
title="设备告警"
type="2"
></detailItem>
<!-- 机房温湿度 -->
<view v-if="detailsItem.jfwsd" class="container-item">
<view class="title">机房温湿度</view>
<view class="cards">
<view
v-for="(item, index) in detailsItem.jfwsd.detail"
:key="index"
class="cards-item"
>
<view class="name"
>{{ item.label
}}<text
class="status"
:class="{ warning: item.inspectionResult === 1 }"
>{{ item.inspectionResultLable }}</text
></view
>
<view class="list">
<view class="label">{{ item.settingLabel }}:</view>
<view class="content"> {{ item.setting }}{{ item.unit }} </view>
</view>
<view class="list">
<view class="label">{{ item.sjLabel }}:</view>
<view class="content"> {{ item.value }}{{ item.unit }} </view>
</view>
<view class="list">
<view class="label">情况描述:</view>
<view class="content">
{{ item.conclusion }}
</view>
</view>
<view class="list">
<view class="label">现场照片:</view>
<view v-if="item.photos.length === 0" class="content">
未拍摄照片
</view>
<view v-else class="content">
<image
v-for="(url, urlIndex) in item.photos"
:key="urlIndex"
class="image-item"
:src="url"
mode="aspectFit"
@click="previewImage(item.photos, urlIndex)"
></image>
</view>
</view>
</view>
</view>
</view>
<detailItem
v-if="detailsItem.jfwsd"
:detailObj="detailsItem.jfwsd"
title="机房温湿度"
type="3"
></detailItem>
<!-- 电力系统 -->
<view v-if="detailsItem.dlxt" class="container-item">
<view class="title">电力系统</view>
<view class="cards">
<view
v-for="(item, index) in detailsItem.dlxt.detail"
:key="index"
class="cards-item"
>
<view class="name"
>{{ item.label
}}<text
class="status"
:class="{ warning: item.inspectionResult === 1 }"
>{{ item.inspectionResultLable }}</text
></view
>
<view class="list">
<view class="label">情况描述:</view>
<view class="content">
{{ item.conclusion }}
</view>
</view>
<view class="list">
<view class="label">现场照片:</view>
<view v-if="item.photos.length === 0" class="content">
未拍摄照片
</view>
<view v-else class="content">
<image
v-for="(url, urlIndex) in item.photos"
:key="urlIndex"
class="image-item"
:src="url"
mode="aspectFit"
@click="previewImage(item.photos, urlIndex)"
></image>
</view>
</view>
</view>
</view>
</view>
<detailItem
v-if="detailsItem.dlxt"
:detailObj="detailsItem.dlxt"
title="电力系统"
></detailItem>
<!-- 消防系统 -->
<view v-if="detailsItem.xfxt" class="container-item">
<view class="title">消防系统</view>
<view class="cards">
<view
v-for="(item, index) in detailsItem.xfxt.detail"
:key="index"
class="cards-item"
>
<detailItem
v-if="detailsItem.xfxt"
:detailObj="detailsItem.xfxt"
title="消防系统"
type="4"
:hasLabel="false"
></detailItem>
<view class="name"
>
<template v-if="index==0">
<view>
{{ item.label }} (气压范围:{{item.setting}}
<text
class="status"
:class="{ warning: item.inspectionResult === 1 }"
>{{ item.inspectionResultLable }}
</text>
</view>
</template>
<template v-else>
{{ item.label }}
<text
class="status"
:class="{ warning: item.inspectionResult === 1 }"
>{{ item.inspectionResultLable }}
</text>
</template>
</view
>
<!-- <template v-if="index==0">
<view class="list">
<view class="label" style="width: 70px;">{{item.settingLabel}}:</view>
<view class="content">
{{ item.setting }}
</view>
</view>
<view class="list">
<view class="label" style="width: 70px;">{{item.sjLabel}}:</view>
<view class="content">
{{ item.value || '--' }} MPa
</view>
</view>
</template> -->
<view class="list">
<view class="label">情况描述:</view>
<view class="content">
{{ item.conclusion }}
</view>
</view>
<view class="list">
<view class="label">现场照片:</view>
<view v-if="item.photos.length === 0" class="content">
未拍摄照片
</view>
<view v-else class="content">
<image
v-for="(url, urlIndex) in item.photos"
:key="urlIndex"
class="image-item"
:src="url"
mode="aspectFit"
@click="previewImage(item.photos, urlIndex)"
></image>
</view>
</view>
</view>
</view>
</view>
<!-- 线路情况 -->
<view v-if="detailsItem.xlqk" class="container-item">
<view class="title">线路情况</view>
<view class="cards">
<view
v-for="(item, index) in detailsItem.xlqk.detail"
:key="index"
class="cards-item"
>
<view class="name"
>{{ item.label
}}<text
class="status"
:class="{ warning: item.inspectionResult === 1 }"
>{{ item.inspectionResultLable }}
</text></view
>
<view class="list">
<view class="label">情况描述:</view>
<view class="content">
{{ item.conclusion }}
</view>
</view>
<view class="list">
<view class="label">现场照片:</view>
<view v-if="item.photos.length === 0" class="content">
未拍摄照片
</view>
<view v-else class="content">
<image
v-for="(url, urlIndex) in item.photos"
:key="urlIndex"
class="image-item"
:src="url"
mode="aspectFit"
@click="previewImage(item.photos, urlIndex)"
></image>
</view>
</view>
</view>
</view>
</view>
<detailItem
v-if="detailsItem.xlqk"
:detailObj="detailsItem.xlqk"
title="线路情况"
></detailItem>
<!-- 其它 -->
<view v-if="detailsItem.qt" class="container-item">
<view class="title">其它</view>
<view class="cards">
<view
v-for="(item, index) in detailsItem.qt.detail"
:key="index"
class="cards-item"
>
<view class="list">
<view class="label">其它问题:</view>
<view class="content">
{{ item.conclusion }}
</view>
</view>
<view class="list">
<view class="label">现场照片:</view>
<view v-if="item.photos.length === 0" class="content">
未拍摄照片
</view>
<view v-else class="content">
<image
v-for="(url, urlIndex) in item.photos"
:key="urlIndex"
class="image-item"
:src="url"
mode="aspectFit"
@click="previewImage(item.photos, urlIndex)"
></image>
</view>
</view>
</view>
</view>
</view>
<detailItem
v-if="detailsItem.qt"
:detailObj="detailsItem.qt"
title="其它"
conclusionName="其它问题"
:hasLabel="false"
></detailItem>
<!-- 空调系统 -->
<detailItem
v-if="detailsItem.ktxt"
:detailObj="detailsItem.ktxt"
title="空调系统"
></detailItem>
<!-- UPS系统 -->
<detailItem
v-if="detailsItem.upsxt"
:detailObj="detailsItem.upsxt"
title="UPS系统"
></detailItem>
<!-- 冷通道系统 -->
<detailItem
v-if="detailsItem.ltdxt"
:detailObj="detailsItem.ltdxt"
title="冷通道系统"
></detailItem>
<!-- 屏蔽系统 -->
<detailItem
v-if="detailsItem.pbxt"
:detailObj="detailsItem.pbxt"
title="屏蔽系统"
></detailItem>
<!-- 除湿机 -->
<detailItem
v-if="detailsItem.csj"
:detailObj="detailsItem.csj"
title="除湿机"
></detailItem>
<!-- 内网监管在线平台 -->
<detailItem
v-if="detailsItem.nwjgzx"
:detailObj="detailsItem.nwjgzx"
title="内网监管在线平台"
></detailItem>
<!-- 专网监管在线平台 -->
<detailItem
v-if="detailsItem.zwjgzx"
:detailObj="detailsItem.zwjgzx"
title="专网监管在线平台"
></detailItem>
<!-- LED屏 -->
<detailItem
v-if="detailsItem.ledp"
:detailObj="detailsItem.ledp"
title="LED屏"
></detailItem>
</view>
</view>
</template>
<script>
import detailItem from "./detailItem.vue";
export default {
components: {
detailItem,
},
props: {
// 父组件传递的详情
detailsItem: {
......@@ -456,23 +154,9 @@ export default {
},
mounted() {
console.log("this.detailsItem", this.detailsItem);
console.log(this.detailsItem)
},
methods: {
showItem(item) {
const hasMonitor = this.detailsItem.afxt.detail.find(i => i.label === "是否有监控");
if (hasMonitor && hasMonitor.inspectionResultLable === "无监控") {
return !["监控外观破损", "监控画面清晰", "监控存储连续"].includes(item.label);
}
return true;
},
previewImage(images, index) {
uni.previewImage({
current: index,
urls: images,
});
},
console.log(this.detailsItem);
},
methods: {},
};
</script>
......@@ -486,85 +170,5 @@ export default {
margin-bottom: 19.2px;
height: 280px;
}
.container {
.container-item {
margin-bottom: 19.2px;
.title {
font-size: 12.8px;
color: #000000;
line-height: 19.2px;
font-weight: 500;
margin-bottom: 9.6px;
}
.cards {
display: flex;
flex-wrap: wrap;
justify-content: space-between;
.cards-item {
width: calc(50% - 6.4px);
margin-bottom: 12.8px;
background: #f9f9f9;
border-radius: 6.4px;
padding: 6.4px;
&.sbgj {
width: 100%;
}
.name {
font-size: 12.8px;
color: #000000;
line-height: 19.2px;
font-weight: 500;
margin-bottom: 9.6px;
.status {
margin-left: 6.4px;
padding: 0 6.4px;
font-size: 9.6px;
background: #e6f9f3;
border-radius: 8.8px;
color: #0cc991;
line-height: 16px;
font-weight: 400;
&.warning {
background: #fdebe9;
color: #f55a42;
}
}
}
.list {
display: flex;
align-items: flex-start;
margin-bottom: 9.6px;
&:last-child {
margin-bottom: 0;
}
.label {
width: 56px;
font-size: 11.2px;
color: #7c7c7c;
line-height: 17.6px;
font-weight: 400;
}
.content {
flex: 1;
word-wrap: break-word;
font-size: 11.2px;
color: #000000;
line-height: 17.6px;
font-weight: 400;
display: flex;
flex-wrap: nowrap;
// justify-content: space-between;
.image-item {
width: 57.6px;
height: 57.6px;
margin-right: 6.4px;
border-radius: 3.2px;
}
}
}
}
}
}
}
}
</style>
<template>
<view class="container-item">
<view class="title">{{ title }}</view>
<view class="cards">
<view
v-for="(item, index) in detailObj.detail"
:key="index"
class="cards-item"
v-if="showItem(item)"
>
<view v-if="hasLabel" class="name"
>{{ item.label
}}<text
class="status"
:class="{ warning: item.inspectionResult === 1 }"
>{{ item.inspectionResultLable }}</text
></view
>
<view class="list" v-if="type == 1">
<view class="label">{{ item.settingLabelShow }}</view>
<view class="content">
{{ item.setting }}
</view>
</view>
<view v-if="type == 2 && item.inspectionResult === 1" class="list">
<view class="label">故障设备:</view>
<view class="content">
<text v-for="(current, idx) in item.cabinets" :key="idx">
{{ current.deviceId }}机柜,{{ current.UpositonS }}~{{
current.UpositonE
}}U】
</text>
</view>
</view>
<view class="list" v-if="type == 3">
<view class="label">{{ item.settingLabel }}</view>
<view class="content"> {{ item.setting }}{{ item.unit }} </view>
</view>
<view class="list" v-if="type == 3">
<view class="label">{{ item.sjLabel }}</view>
<view class="content"> {{ item.value }}{{ item.unit }} </view>
</view>
<view class="name" v-if="type == 4">
<template v-if="index == 0">
<view>
{{ item.label }} (气压范围:{{ item.setting }}
<text
class="status"
:class="{ warning: item.inspectionResult === 1 }"
>{{ item.inspectionResultLable }}
</text>
</view>
</template>
<template v-else>
{{ item.label }}
<text
class="status"
:class="{ warning: item.inspectionResult === 1 }"
>{{ item.inspectionResultLable }}
</text>
</template>
</view>
<view class="list">
<view class="label">{{ conclusionName || "情况描述" }}:</view>
<view class="content">
{{ item.conclusion }}
</view>
</view>
<view class="list">
<view class="label">现场照片:</view>
<view v-if="item.photos.length === 0" class="content">
未拍摄照片
</view>
<view v-else class="content">
<image
v-for="(url, urlIndex) in item.photos"
:key="urlIndex"
class="image-item"
:src="url"
mode="aspectFit"
@click="previewImage(item.photos, urlIndex)"
></image>
</view>
</view>
</view>
</view>
</view>
</template>
<script>
export default {
props: {
detailObj: {
type: Object,
default: () => ({}),
},
title: {
type: String,
default: "",
},
type: {
type: [String, Number],
default: "",
},
conclusionName: {
type: String,
default: "情况描述",
},
hasLabel: {
type: Boolean,
default: true,
},
isShowItem: {
type: Boolean,
default: false,
},
},
data() {
return {};
},
methods: {
showItem(item) {
if (!this.isShowItem) return true;
const hasMonitor = this.detailsItem.afxt.detail.find(
(i) => i.label === "是否有监控",
);
if (hasMonitor && hasMonitor.inspectionResultLable === "无监控") {
return !["监控外观破损", "监控画面清晰", "监控存储连续"].includes(
item.label,
);
}
return true;
},
previewImage(images, index) {
uni.previewImage({
current: index,
urls: images,
});
},
},
};
</script>
<style scoped lang="less">
.container-item {
margin-bottom: 19.2px;
.title {
font-size: 12.8px;
color: #000000;
line-height: 19.2px;
font-weight: 500;
margin-bottom: 9.6px;
}
.cards {
display: flex;
flex-wrap: wrap;
justify-content: space-between;
.cards-item {
width: calc(50% - 6.4px);
margin-bottom: 12.8px;
background: #f9f9f9;
border-radius: 6.4px;
padding: 6.4px;
&.sbgj {
width: 100%;
}
.name {
font-size: 12.8px;
color: #000000;
line-height: 19.2px;
font-weight: 500;
margin-bottom: 9.6px;
.status {
margin-left: 6.4px;
padding: 0 6.4px;
font-size: 9.6px;
background: #e6f9f3;
border-radius: 8.8px;
color: #0cc991;
line-height: 16px;
font-weight: 400;
&.warning {
background: #fdebe9;
color: #f55a42;
}
}
}
.list {
display: flex;
align-items: flex-start;
margin-bottom: 9.6px;
&:last-child {
margin-bottom: 0;
}
.label {
width: 56px;
font-size: 11.2px;
color: #7c7c7c;
line-height: 17.6px;
font-weight: 400;
}
.content {
flex: 1;
word-wrap: break-word;
font-size: 11.2px;
color: #000000;
line-height: 17.6px;
font-weight: 400;
display: flex;
flex-wrap: nowrap;
// justify-content: space-between;
.image-item {
width: 57.6px;
height: 57.6px;
margin-right: 6.4px;
border-radius: 3.2px;
}
}
}
}
}
}
</style>
<template>
<!-- 机房巡检操作 -->
<view>
<view v-for="(item, index) in itemData.detail" :key="index">
<view class="form-item">
<text class="form-label"
><text class="required">*</text>{{ item.label }}</text
>
<view class="switch-container">
<view
:class="['status-btn', { active: item.inspectionResult === 0 }]"
@click="setInspectionResult(index, 0, item.lableArr[0])"
>
{{ item.lableArr[0] }}
</view>
<view
:class="['status-btn', { active: item.inspectionResult === 1 }]"
@click="setInspectionResult(index, 1, item.lableArr[1])"
>
{{ item.lableArr[1] }}
</view>
</view>
</view>
<template v-if="item.inspectionResult === 1">
<view class="form-item">
<text class="form-label"
><text class="required">*</text>情况摘要</text
>
<text
:class="['conclusion', { 'no-text': !item.conclusion }]"
@click="showPopup(item, index)"
>
{{ item.conclusion || "请输入情况摘要" }}</text
>
</view>
<view class="form-item">
<text class="form-label"
><text class="required">*</text>现场照片</text
>
<CommonUpload v-model="item.photos" :max-count="5">
</CommonUpload> </view
></template> </view
><custom-popup
ref="customPopup"
:inspectionItem="inspectionItem"
@confirm="handlePopupConfirm"
></custom-popup>
</view>
</template>
<script>
import CommonUpload from "@/components/CommonUpload/index.vue";
import customPopup from "./customPopup.vue";
import _ from "lodash";
import mixin from "./mixin";
export default {
components: {
CommonUpload,
customPopup,
},
mixins: [mixin],
props: {
// 父组件传递的巡检状态
status: {
type: Number,
default: 0,
},
// 父组件传递的巡检事项名
inspectionItem: {
type: String,
default: "",
},
// 父组件传递的数据
defaultData: {
type: Object,
default: () => ({}),
},
},
data() {
return {
currentIndex: 0, // 当前操作的索引
photos: [],
itemData: {
isValid: false, // false是校验未通过 true是校验通过
status: 0, //0是未巡检 1是已巡检 2巡检异常
statusLabel: "未巡检",
inspectionItem: "", //巡检事项
detail: [
{
label: "浪涌保护器开关",
inspectionResult: "",
inspectionResultLable: "正常",
lableArr: ["正常", "异常"],
conclusion: "",
photos: [],
},
],
},
};
},
computed: {
userInfo() {
return this.$store.state.now_user || {};
},
},
watch: {
defaultData(newVal) {
// 在这里处理数据变化
if (Object.keys(this.defaultData).length !== 0) {
this.itemData = this.defaultData;
}
},
},
async mounted() {
console.log("sdsadasd", this.itemData);
// if (Object.keys(this.defaultData).length !== 0) {
// this.itemData = this.defaultData;
// }
},
methods: {
// 拍照
takePhoto(index) {
uni.chooseImage({
count: 1,
sourceType: ["camera"], // 可以从相机拍摄
success: async (res) => {
if (this.photos.length < 5) {
const base64 = await this.convertFileToBase64(res.tempFilePaths[0]);
this.itemData.detail[index].photos.push(base64);
} else {
uni.showToast({
title: "最多只能上传5张照片",
icon: "none",
});
}
},
});
},
// 转化为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);
},
);
});
},
// 删除照片
deletePhoto(index, itemIndex) {
this.itemData.detail[index].photos.splice(itemIndex, 1);
},
// 处理弹窗确认
handlePopupConfirm(summary) {
this.itemData.detail[this.currentIndex].conclusion = summary; // 回显到文字显示区域
},
// 处理】数据
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;
this.itemData.status = isAllOne.status; //1表示已经巡检过没有异常
this.itemData.statusLabel = isAllOne.statusLabel;
console.log("查看数据", this.itemData);
return this.itemData;
},
// 数据校验方法 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) {
return false;
}
} else {
// 其他情况(理论上不应该存在,根据当前规则)
return false;
}
}
// 所有检查都通过
return true;
},
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 };
}
},
setNormal() {
this.itemData.detail.forEach((item) => {
item.inspectionResult = 0;
});
},
},
};
</script>
<style scoped lang="less">
.form-item {
display: flex;
align-items: center;
padding: 9.6px 0;
line-height: 28.8px;
border-bottom: 0.8px solid #f2f3f5;
.form-label {
font-size: 11.2px;
margin-right: 25.6px;
width: 88px;
text-align: right;
color: #7c7c7c;
.required {
color: red;
margin-right: 3.2px;
}
}
.conclusion {
&.no-text {
color: #c7c7c7;
}
.have {
color: #000;
}
}
.label {
font-size: 11.2px;
}
.switch-container {
display: flex;
gap: 9.6px;
.status-btn {
flex: 1;
padding: 5.6px 19.2px;
font-size: 12.8px;
color: #000000;
background: #f2f2f2;
text-align: center;
font-weight: 400;
line-height: 17.6px;
border-radius: 14.4px;
&.active {
color: #ffffff;
background: #3774f6;
border: 0.32px solid rgba(224, 224, 224, 1);
}
}
}
.input-box {
flex: 1;
border-radius: 3.2px;
font-size: 12.8px;
line-height: 19.2px;
}
.photo-limit {
font-size: 12.8px;
color: #959595;
line-height: 19.2px;
font-weight: 400;
}
.photo-container {
display: flex;
flex-wrap: wrap;
margin-bottom: 6.4px;
.photo-item {
position: relative;
margin-right: 6.4px;
margin-bottom: 6.4px;
.photo {
width: 57.6px;
height: 57.6px;
border-radius: 3.2px;
margin-left: 9.6px;
}
.delete-photo {
position: absolute;
top: -6.4px;
right: -6.4px;
background-color: #ff4d4f;
color: #fff;
width: 12.8px;
height: 12.8px;
border-radius: 50%;
text-align: center;
line-height: 12.8px;
font-size: 9.6px;
}
}
}
.photo-btn {
background: #ffffff;
border: 0.272px solid rgba(221, 221, 221, 1);
border-radius: 1.64px;
width: 57.6px;
height: 57.6px;
font-size: 57.6px;
color: #cccccc;
text-align: center;
line-height: 51.2px;
}
}
</style>
<template>
<!-- 机房巡检操作 -->
<view>
<view v-for="(item, index) in itemData.detail" :key="index">
<view class="form-item">
<text class="form-label"
><text class="required">*</text>{{ item.label }}</text
>
<view class="switch-container">
<view
:class="['status-btn', { active: item.inspectionResult === 0 }]"
@click="setInspectionResult(index, 0, item.lableArr[0])"
>
{{ item.lableArr[0] }}
</view>
<view
:class="['status-btn', { active: item.inspectionResult === 1 }]"
@click="setInspectionResult(index, 1, item.lableArr[1])"
>
{{ item.lableArr[1] }}
</view>
</view>
</view>
<template v-if="item.inspectionResult === 1">
<view class="form-item">
<text class="form-label"
><text class="required">*</text>情况摘要</text
>
<text
:class="['conclusion', { 'no-text': !item.conclusion }]"
@click="showPopup(item, index)"
>
{{ item.conclusion || "请输入情况摘要" }}</text
>
</view>
<view class="form-item">
<text class="form-label"
><text class="required">*</text>现场照片</text
>
<CommonUpload v-model="item.photos" :max-count="5">
</CommonUpload> </view
></template> </view
><custom-popup
ref="customPopup"
:inspectionItem="inspectionItem"
@confirm="handlePopupConfirm"
></custom-popup>
</view>
</template>
<script>
import CommonUpload from "@/components/CommonUpload/index.vue";
import customPopup from "./customPopup.vue";
import _ from "lodash";
import mixin from "./mixin";
export default {
components: {
CommonUpload,
customPopup,
},
mixins: [mixin],
props: {
// 父组件传递的巡检状态
status: {
type: Number,
default: 0,
},
// 父组件传递的巡检事项名
inspectionItem: {
type: String,
default: "",
},
// 父组件传递的数据
defaultData: {
type: Object,
default: () => ({}),
},
},
data() {
return {
currentIndex: 0, // 当前操作的索引
photos: [],
itemData: {
isValid: false, // false是校验未通过 true是校验通过
status: 0, //0是未巡检 1是已巡检 2巡检异常
statusLabel: "未巡检",
inspectionItem: "", //巡检事项
detail: [
{
label: "配套装置",
inspectionResult: "",
inspectionResultLable: "正常",
lableArr: ["正常", "异常"],
conclusion: "",
photos: [],
},
{
label: "电缆、接线端子",
inspectionResult: "",
inspectionResultLable: "正常",
lableArr: ["正常", "异常"],
conclusion: "",
photos: [],
},
{
label: "熔断器",
inspectionResult: "",
inspectionResultLable: "正常",
lableArr: ["正常", "异常"],
conclusion: "",
photos: [],
},
],
},
};
},
computed: {
userInfo() {
return this.$store.state.now_user || {};
},
},
watch: {
defaultData(newVal) {
// 在这里处理数据变化
if (Object.keys(this.defaultData).length !== 0) {
this.itemData = this.defaultData;
}
},
},
async mounted() {
console.log("sdsadasd", this.itemData);
// if (Object.keys(this.defaultData).length !== 0) {
// this.itemData = this.defaultData;
// }
},
methods: {
// 拍照
takePhoto(index) {
uni.chooseImage({
count: 1,
sourceType: ["camera"], // 可以从相机拍摄
success: async (res) => {
if (this.photos.length < 5) {
const base64 = await this.convertFileToBase64(res.tempFilePaths[0]);
this.itemData.detail[index].photos.push(base64);
} else {
uni.showToast({
title: "最多只能上传5张照片",
icon: "none",
});
}
},
});
},
// 转化为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);
},
);
});
},
// 删除照片
deletePhoto(index, itemIndex) {
this.itemData.detail[index].photos.splice(itemIndex, 1);
},
// 处理弹窗确认
handlePopupConfirm(summary) {
this.itemData.detail[this.currentIndex].conclusion = summary; // 回显到文字显示区域
},
// 处理】数据
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;
this.itemData.status = isAllOne.status; //1表示已经巡检过没有异常
this.itemData.statusLabel = isAllOne.statusLabel;
console.log("查看数据", this.itemData);
return this.itemData;
},
// 数据校验方法 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) {
return false;
}
} else {
// 其他情况(理论上不应该存在,根据当前规则)
return false;
}
}
// 所有检查都通过
return true;
},
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 };
}
},
setNormal() {
this.itemData.detail.forEach((item) => {
item.inspectionResult = 0;
});
},
},
};
</script>
<style scoped lang="less">
.form-item {
display: flex;
align-items: center;
padding: 9.6px 0;
line-height: 28.8px;
border-bottom: 0.8px solid #f2f3f5;
.form-label {
font-size: 11.2px;
margin-right: 25.6px;
width: 88px;
text-align: right;
color: #7c7c7c;
.required {
color: red;
margin-right: 3.2px;
}
}
.conclusion {
&.no-text {
color: #c7c7c7;
}
.have {
color: #000;
}
}
.label {
font-size: 11.2px;
}
.switch-container {
display: flex;
gap: 9.6px;
.status-btn {
flex: 1;
padding: 5.6px 19.2px;
font-size: 12.8px;
color: #000000;
background: #f2f2f2;
text-align: center;
font-weight: 400;
line-height: 17.6px;
border-radius: 14.4px;
&.active {
color: #ffffff;
background: #3774f6;
border: 0.32px solid rgba(224, 224, 224, 1);
}
}
}
.input-box {
flex: 1;
border-radius: 3.2px;
font-size: 12.8px;
line-height: 19.2px;
}
.photo-limit {
font-size: 12.8px;
color: #959595;
line-height: 19.2px;
font-weight: 400;
}
.photo-container {
display: flex;
flex-wrap: wrap;
margin-bottom: 6.4px;
.photo-item {
position: relative;
margin-right: 6.4px;
margin-bottom: 6.4px;
.photo {
width: 57.6px;
height: 57.6px;
border-radius: 3.2px;
margin-left: 9.6px;
}
.delete-photo {
position: absolute;
top: -6.4px;
right: -6.4px;
background-color: #ff4d4f;
color: #fff;
width: 12.8px;
height: 12.8px;
border-radius: 50%;
text-align: center;
line-height: 12.8px;
font-size: 9.6px;
}
}
}
.photo-btn {
background: #ffffff;
border: 0.272px solid rgba(221, 221, 221, 1);
border-radius: 1.64px;
width: 57.6px;
height: 57.6px;
font-size: 57.6px;
color: #cccccc;
text-align: center;
line-height: 51.2px;
}
}
</style>
<template>
<!-- 机房巡检操作 -->
<view>
<view v-for="(item, index) in itemData.detail" :key="index">
<view class="form-item">
<text class="form-label"
><text class="required">*</text>{{ item.label }}</text
>
<view class="switch-container">
<view
:class="['status-btn', { active: item.inspectionResult === 0 }]"
@click="setInspectionResult(index, 0, item.lableArr[0])"
>
{{ item.lableArr[0] }}
</view>
<view
:class="['status-btn', { active: item.inspectionResult === 1 }]"
@click="setInspectionResult(index, 1, item.lableArr[1])"
>
{{ item.lableArr[1] }}
</view>
</view>
</view>
<template v-if="item.inspectionResult === 1">
<view class="form-item">
<text class="form-label"
><text class="required">*</text>情况摘要</text
>
<text
:class="['conclusion', { 'no-text': !item.conclusion }]"
@click="showPopup(item, index)"
>
{{ item.conclusion || "请输入情况摘要" }}</text
>
</view>
<view class="form-item">
<text class="form-label"
><text class="required">*</text>现场照片</text
>
<CommonUpload v-model="item.photos" :max-count="5">
</CommonUpload> </view
></template> </view
><custom-popup
ref="customPopup"
:inspectionItem="inspectionItem"
@confirm="handlePopupConfirm"
></custom-popup>
</view>
</template>
<script>
import CommonUpload from "@/components/CommonUpload/index.vue";
import customPopup from "./customPopup.vue";
import _ from "lodash";
import mixin from "./mixin";
export default {
components: {
CommonUpload,
customPopup,
},
mixins: [mixin],
props: {
// 父组件传递的巡检状态
status: {
type: Number,
default: 0,
},
// 父组件传递的巡检事项名
inspectionItem: {
type: String,
default: "",
},
// 父组件传递的数据
defaultData: {
type: Object,
default: () => ({}),
},
},
data() {
return {
currentIndex: 0, // 当前操作的索引
photos: [],
itemData: {
isValid: false, // false是校验未通过 true是校验通过
status: 0, //0是未巡检 1是已巡检 2巡检异常
statusLabel: "未巡检",
inspectionItem: "", //巡检事项
detail: [
{
label: "滤网清洁",
inspectionResult: "",
inspectionResultLable: "有",
lableArr: ["有", "无"],
conclusion: "",
photos: [],
},
{
label: "翅片清洁",
inspectionResult: "",
inspectionResultLable: "有",
lableArr: ["有", "无"],
conclusion: "",
photos: [],
},
{
label: "积水盘清洁",
inspectionResult: "",
inspectionResultLable: "有",
lableArr: ["有", "无"],
conclusion: "",
photos: [],
},
{
label: "空调内机清洁",
inspectionResult: "",
inspectionResultLable: "有",
lableArr: ["有", "无"],
conclusion: "",
photos: [],
},
],
},
};
},
computed: {
userInfo() {
return this.$store.state.now_user || {};
},
},
watch: {
defaultData(newVal) {
// 在这里处理数据变化
if (Object.keys(this.defaultData).length !== 0) {
this.itemData = this.defaultData;
}
},
},
async mounted() {
console.log("sdsadasd", this.itemData);
// if (Object.keys(this.defaultData).length !== 0) {
// this.itemData = this.defaultData;
// }
},
methods: {
// 拍照
takePhoto(index) {
uni.chooseImage({
count: 1,
sourceType: ["camera"], // 可以从相机拍摄
success: async (res) => {
if (this.photos.length < 5) {
const base64 = await this.convertFileToBase64(res.tempFilePaths[0]);
this.itemData.detail[index].photos.push(base64);
} else {
uni.showToast({
title: "最多只能上传5张照片",
icon: "none",
});
}
},
});
},
// 转化为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);
},
);
});
},
// 删除照片
deletePhoto(index, itemIndex) {
this.itemData.detail[index].photos.splice(itemIndex, 1);
},
// 处理弹窗确认
handlePopupConfirm(summary) {
this.itemData.detail[this.currentIndex].conclusion = summary; // 回显到文字显示区域
},
// 处理】数据
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;
this.itemData.status = isAllOne.status; //1表示已经巡检过没有异常
this.itemData.statusLabel = isAllOne.statusLabel;
console.log("查看数据", this.itemData);
return this.itemData;
},
// 数据校验方法 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) {
return false;
}
} else {
// 其他情况(理论上不应该存在,根据当前规则)
return false;
}
}
// 所有检查都通过
return true;
},
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 };
}
},
setNormal() {
this.itemData.detail.forEach((item) => {
item.inspectionResult = 0;
});
},
},
};
</script>
<style scoped lang="less">
.form-item {
display: flex;
align-items: center;
padding: 9.6px 0;
line-height: 28.8px;
border-bottom: 0.8px solid #f2f3f5;
.form-label {
font-size: 11.2px;
margin-right: 25.6px;
width: 88px;
text-align: right;
color: #7c7c7c;
.required {
color: red;
margin-right: 3.2px;
}
}
.conclusion {
&.no-text {
color: #c7c7c7;
}
.have {
color: #000;
}
}
.label {
font-size: 11.2px;
}
.switch-container {
display: flex;
gap: 9.6px;
.status-btn {
flex: 1;
padding: 5.6px 19.2px;
font-size: 12.8px;
color: #000000;
background: #f2f2f2;
text-align: center;
font-weight: 400;
line-height: 17.6px;
border-radius: 14.4px;
&.active {
color: #ffffff;
background: #3774f6;
border: 0.32px solid rgba(224, 224, 224, 1);
}
}
}
.input-box {
flex: 1;
border-radius: 3.2px;
font-size: 12.8px;
line-height: 19.2px;
}
.photo-limit {
font-size: 12.8px;
color: #959595;
line-height: 19.2px;
font-weight: 400;
}
.photo-container {
display: flex;
flex-wrap: wrap;
margin-bottom: 6.4px;
.photo-item {
position: relative;
margin-right: 6.4px;
margin-bottom: 6.4px;
.photo {
width: 57.6px;
height: 57.6px;
border-radius: 3.2px;
margin-left: 9.6px;
}
.delete-photo {
position: absolute;
top: -6.4px;
right: -6.4px;
background-color: #ff4d4f;
color: #fff;
width: 12.8px;
height: 12.8px;
border-radius: 50%;
text-align: center;
line-height: 12.8px;
font-size: 9.6px;
}
}
}
.photo-btn {
background: #ffffff;
border: 0.272px solid rgba(221, 221, 221, 1);
border-radius: 1.64px;
width: 57.6px;
height: 57.6px;
font-size: 57.6px;
color: #cccccc;
text-align: center;
line-height: 51.2px;
}
}
</style>
<template>
<!-- 机房巡检操作 -->
<view>
<view v-for="(item, index) in itemData.detail" :key="index">
<view class="form-item">
<text class="form-label"
><text class="required">*</text>{{ item.label }}</text
>
<view class="switch-container">
<view
:class="['status-btn', { active: item.inspectionResult === 0 }]"
@click="setInspectionResult(index, 0, item.lableArr[0])"
>
{{ item.lableArr[0] }}
</view>
<view
:class="['status-btn', { active: item.inspectionResult === 1 }]"
@click="setInspectionResult(index, 1, item.lableArr[1])"
>
{{ item.lableArr[1] }}
</view>
</view>
</view>
<template v-if="item.inspectionResult === 1">
<view class="form-item">
<text class="form-label"
><text class="required">*</text>情况摘要</text
>
<text
:class="['conclusion', { 'no-text': !item.conclusion }]"
@click="showPopup(item, index)"
>
{{ item.conclusion || "请输入情况摘要" }}</text
>
</view>
<view class="form-item">
<text class="form-label"
><text class="required">*</text>现场照片</text
>
<CommonUpload v-model="item.photos" :max-count="5">
</CommonUpload> </view
></template> </view
><custom-popup
ref="customPopup"
:inspectionItem="inspectionItem"
@confirm="handlePopupConfirm"
></custom-popup>
</view>
</template>
<script>
import CommonUpload from "@/components/CommonUpload/index.vue";
import customPopup from "./customPopup.vue";
import _ from "lodash";
import mixin from "./mixin";
export default {
components: {
CommonUpload,
customPopup,
},
mixins: [mixin],
props: {
// 父组件传递的巡检状态
status: {
type: Number,
default: 0,
},
// 父组件传递的巡检事项名
inspectionItem: {
type: String,
default: "",
},
// 父组件传递的数据
defaultData: {
type: Object,
default: () => ({}),
},
},
data() {
return {
currentIndex: 0, // 当前操作的索引
photos: [],
itemData: {
isValid: false, // false是校验未通过 true是校验通过
status: 0, //0是未巡检 1是已巡检 2巡检异常
statusLabel: "未巡检",
inspectionItem: "", //巡检事项
detail: [
{
label: "弹簧片、门扇插口",
inspectionResult: "",
inspectionResultLable: "正常",
lableArr: ["正常", "异常"],
conclusion: "",
photos: [],
},
{
label: "屏蔽门手动转换",
inspectionResult: "",
inspectionResultLable: "正常",
lableArr: ["正常", "异常"],
conclusion: "",
photos: [],
},
{
label: "进、回波导水管",
inspectionResult: "",
inspectionResultLable: "正常",
lableArr: ["正常", "异常"],
conclusion: "",
photos: [],
},
{
label: "光纤波导管",
inspectionResult: "",
inspectionResultLable: "正常",
lableArr: ["正常", "异常"],
conclusion: "",
photos: [],
},
{
label: "壳体、龙骨架外观",
inspectionResult: "",
inspectionResultLable: "正常",
lableArr: ["正常", "异常"],
conclusion: "",
photos: [],
},
],
},
};
},
computed: {
userInfo() {
return this.$store.state.now_user || {};
},
},
watch: {
defaultData(newVal) {
// 在这里处理数据变化
if (Object.keys(this.defaultData).length !== 0) {
this.itemData = this.defaultData;
}
},
},
async mounted() {
console.log("sdsadasd", this.itemData);
// if (Object.keys(this.defaultData).length !== 0) {
// this.itemData = this.defaultData;
// }
},
methods: {
// 拍照
takePhoto(index) {
uni.chooseImage({
count: 1,
sourceType: ["camera"], // 可以从相机拍摄
success: async (res) => {
if (this.photos.length < 5) {
const base64 = await this.convertFileToBase64(res.tempFilePaths[0]);
this.itemData.detail[index].photos.push(base64);
} else {
uni.showToast({
title: "最多只能上传5张照片",
icon: "none",
});
}
},
});
},
// 转化为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);
},
);
});
},
// 删除照片
deletePhoto(index, itemIndex) {
this.itemData.detail[index].photos.splice(itemIndex, 1);
},
// 处理弹窗确认
handlePopupConfirm(summary) {
this.itemData.detail[this.currentIndex].conclusion = summary; // 回显到文字显示区域
},
// 处理】数据
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;
this.itemData.status = isAllOne.status; //1表示已经巡检过没有异常
this.itemData.statusLabel = isAllOne.statusLabel;
console.log("查看数据", this.itemData);
return this.itemData;
},
// 数据校验方法 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) {
return false;
}
} else {
// 其他情况(理论上不应该存在,根据当前规则)
return false;
}
}
// 所有检查都通过
return true;
},
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 };
}
},
setNormal() {
this.itemData.detail.forEach((item) => {
item.inspectionResult = 0;
});
},
},
};
</script>
<style scoped lang="less">
.form-item {
display: flex;
align-items: center;
padding: 9.6px 0;
line-height: 28.8px;
border-bottom: 0.8px solid #f2f3f5;
.form-label {
font-size: 11.2px;
margin-right: 25.6px;
width: 108px;
text-align: right;
color: #7c7c7c;
.required {
color: red;
margin-right: 3.2px;
}
}
.conclusion {
&.no-text {
color: #c7c7c7;
}
.have {
color: #000;
}
}
.label {
font-size: 11.2px;
}
.switch-container {
display: flex;
gap: 9.6px;
.status-btn {
flex: 1;
padding: 5.6px 19.2px;
font-size: 12.8px;
color: #000000;
background: #f2f2f2;
text-align: center;
font-weight: 400;
line-height: 17.6px;
border-radius: 14.4px;
&.active {
color: #ffffff;
background: #3774f6;
border: 0.32px solid rgba(224, 224, 224, 1);
}
}
}
.input-box {
flex: 1;
border-radius: 3.2px;
font-size: 12.8px;
line-height: 19.2px;
}
.photo-limit {
font-size: 12.8px;
color: #959595;
line-height: 19.2px;
font-weight: 400;
}
.photo-container {
display: flex;
flex-wrap: wrap;
margin-bottom: 6.4px;
.photo-item {
position: relative;
margin-right: 6.4px;
margin-bottom: 6.4px;
.photo {
width: 57.6px;
height: 57.6px;
border-radius: 3.2px;
margin-left: 9.6px;
}
.delete-photo {
position: absolute;
top: -6.4px;
right: -6.4px;
background-color: #ff4d4f;
color: #fff;
width: 12.8px;
height: 12.8px;
border-radius: 50%;
text-align: center;
line-height: 12.8px;
font-size: 9.6px;
}
}
}
.photo-btn {
background: #ffffff;
border: 0.272px solid rgba(221, 221, 221, 1);
border-radius: 1.64px;
width: 57.6px;
height: 57.6px;
font-size: 57.6px;
color: #cccccc;
text-align: center;
line-height: 51.2px;
}
}
</style>
<template>
<!-- 机房巡检操作 -->
<view>
<view v-for="(item, index) in itemData.detail" :key="index">
<view class="form-item">
<text class="form-label"
><text class="required">*</text>{{ item.label }}</text
>
<view class="switch-container">
<view
:class="['status-btn', { active: item.inspectionResult === 0 }]"
@click="setInspectionResult(index, 0, item.lableArr[0])"
>
{{ item.lableArr[0] }}
</view>
<view
:class="['status-btn', { active: item.inspectionResult === 1 }]"
@click="setInspectionResult(index, 1, item.lableArr[1])"
>
{{ item.lableArr[1] }}
</view>
</view>
</view>
<template v-if="item.inspectionResult === 1">
<view class="form-item">
<text class="form-label"
><text class="required">*</text>情况摘要</text
>
<text
:class="['conclusion', { 'no-text': !item.conclusion }]"
@click="showPopup(item, index)"
>
{{ item.conclusion || "请输入情况摘要" }}</text
>
</view>
<view class="form-item">
<text class="form-label"
><text class="required">*</text>现场照片</text
>
<CommonUpload v-model="item.photos" :max-count="5">
</CommonUpload> </view
></template> </view
><custom-popup
ref="customPopup"
:inspectionItem="inspectionItem"
@confirm="handlePopupConfirm"
></custom-popup>
</view>
</template>
<script>
import CommonUpload from "@/components/CommonUpload/index.vue";
import customPopup from "./customPopup.vue";
import _ from "lodash";
import mixin from "./mixin";
export default {
components: {
CommonUpload,
customPopup,
},
mixins: [mixin],
props: {
// 父组件传递的巡检状态
status: {
type: Number,
default: 0,
},
// 父组件传递的巡检事项名
inspectionItem: {
type: String,
default: "",
},
// 父组件传递的数据
defaultData: {
type: Object,
default: () => ({}),
},
},
data() {
return {
currentIndex: 0, // 当前操作的索引
photos: [],
itemData: {
isValid: false, // false是校验未通过 true是校验通过
status: 0, //0是未巡检 1是已巡检 2巡检异常
statusLabel: "未巡检",
inspectionItem: "", //巡检事项
detail: [
{
label: "主机清洁",
inspectionResult: "",
inspectionResultLable: "有",
lableArr: ["有", "无"],
conclusion: "",
photos: [],
},
{
label: "系统参数设置",
inspectionResult: "",
inspectionResultLable: "正常",
lableArr: ["正常", "异常"],
conclusion: "",
photos: [],
},
{
label: "整流器、逆变器外观",
inspectionResult: "",
inspectionResultLable: "正常",
lableArr: ["正常", "异常"],
conclusion: "",
photos: [],
},
],
},
};
},
computed: {
userInfo() {
return this.$store.state.now_user || {};
},
},
watch: {
defaultData(newVal) {
// 在这里处理数据变化
if (Object.keys(this.defaultData).length !== 0) {
this.itemData = this.defaultData;
}
},
},
async mounted() {
console.log("sdsadasd", this.itemData);
// if (Object.keys(this.defaultData).length !== 0) {
// this.itemData = this.defaultData;
// }
},
methods: {
// 拍照
takePhoto(index) {
uni.chooseImage({
count: 1,
sourceType: ["camera"], // 可以从相机拍摄
success: async (res) => {
if (this.photos.length < 5) {
const base64 = await this.convertFileToBase64(res.tempFilePaths[0]);
this.itemData.detail[index].photos.push(base64);
} else {
uni.showToast({
title: "最多只能上传5张照片",
icon: "none",
});
}
},
});
},
// 转化为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);
},
);
});
},
// 删除照片
deletePhoto(index, itemIndex) {
this.itemData.detail[index].photos.splice(itemIndex, 1);
},
// 处理弹窗确认
handlePopupConfirm(summary) {
this.itemData.detail[this.currentIndex].conclusion = summary; // 回显到文字显示区域
},
// 处理】数据
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;
this.itemData.status = isAllOne.status; //1表示已经巡检过没有异常
this.itemData.statusLabel = isAllOne.statusLabel;
console.log("查看数据", this.itemData);
return this.itemData;
},
// 数据校验方法 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) {
return false;
}
} else {
// 其他情况(理论上不应该存在,根据当前规则)
return false;
}
}
// 所有检查都通过
return true;
},
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 };
}
},
setNormal() {
this.itemData.detail.forEach((item) => {
item.inspectionResult = 0;
});
},
},
};
</script>
<style scoped lang="less">
.form-item {
display: flex;
align-items: center;
padding: 9.6px 0;
line-height: 28.8px;
border-bottom: 0.8px solid #f2f3f5;
.form-label {
font-size: 11.2px;
margin-right: 25.6px;
width: 108px;
text-align: right;
color: #7c7c7c;
.required {
color: red;
margin-right: 3.2px;
}
}
.conclusion {
&.no-text {
color: #c7c7c7;
}
.have {
color: #000;
}
}
.label {
font-size: 11.2px;
}
.switch-container {
display: flex;
gap: 9.6px;
.status-btn {
flex: 1;
padding: 5.6px 19.2px;
font-size: 12.8px;
color: #000000;
background: #f2f2f2;
text-align: center;
font-weight: 400;
line-height: 17.6px;
border-radius: 14.4px;
&.active {
color: #ffffff;
background: #3774f6;
border: 0.32px solid rgba(224, 224, 224, 1);
}
}
}
.input-box {
flex: 1;
border-radius: 3.2px;
font-size: 12.8px;
line-height: 19.2px;
}
.photo-limit {
font-size: 12.8px;
color: #959595;
line-height: 19.2px;
font-weight: 400;
}
.photo-container {
display: flex;
flex-wrap: wrap;
margin-bottom: 6.4px;
.photo-item {
position: relative;
margin-right: 6.4px;
margin-bottom: 6.4px;
.photo {
width: 57.6px;
height: 57.6px;
border-radius: 3.2px;
margin-left: 9.6px;
}
.delete-photo {
position: absolute;
top: -6.4px;
right: -6.4px;
background-color: #ff4d4f;
color: #fff;
width: 12.8px;
height: 12.8px;
border-radius: 50%;
text-align: center;
line-height: 12.8px;
font-size: 9.6px;
}
}
}
.photo-btn {
background: #ffffff;
border: 0.272px solid rgba(221, 221, 221, 1);
border-radius: 1.64px;
width: 57.6px;
height: 57.6px;
font-size: 57.6px;
color: #cccccc;
text-align: center;
line-height: 51.2px;
}
}
</style>
<template>
<!-- 机房巡检操作 -->
<view>
<view v-for="(item, index) in itemData.detail" :key="index">
<view class="form-item">
<text class="form-label"
><text class="required">*</text>{{ item.label }}</text
>
<view class="switch-container">
<view
:class="['status-btn', { active: item.inspectionResult === 0 }]"
@click="setInspectionResult(index, 0, item.lableArr[0])"
>
{{ item.lableArr[0] }}
</view>
<view
:class="['status-btn', { active: item.inspectionResult === 1 }]"
@click="setInspectionResult(index, 1, item.lableArr[1])"
>
{{ item.lableArr[1] }}
</view>
</view>
</view>
<template v-if="item.inspectionResult === 1">
<view class="form-item">
<text class="form-label"
><text class="required">*</text>情况摘要</text
>
<text
:class="['conclusion', { 'no-text': !item.conclusion }]"
@click="showPopup(item, index)"
>
{{ item.conclusion || "请输入情况摘要" }}</text
>
</view>
<view class="form-item">
<text class="form-label"
><text class="required">*</text>现场照片</text
>
<CommonUpload v-model="item.photos" :max-count="5">
</CommonUpload> </view
></template> </view
><custom-popup
ref="customPopup"
:inspectionItem="inspectionItem"
@confirm="handlePopupConfirm"
></custom-popup>
</view>
</template>
<script>
import CommonUpload from "@/components/CommonUpload/index.vue";
import customPopup from "./customPopup.vue";
import _ from "lodash";
import mixin from "./mixin";
export default {
components: {
CommonUpload,
customPopup,
},
mixins: [mixin],
props: {
// 父组件传递的巡检状态
status: {
type: Number,
default: 0,
},
// 父组件传递的巡检事项名
inspectionItem: {
type: String,
default: "",
},
// 父组件传递的数据
defaultData: {
type: Object,
default: () => ({}),
},
},
data() {
return {
currentIndex: 0, // 当前操作的索引
photos: [],
itemData: {
isValid: false, // false是校验未通过 true是校验通过
status: 0, //0是未巡检 1是已巡检 2巡检异常
statusLabel: "未巡检",
inspectionItem: "", //巡检事项
detail: [
{
label: "应急灯功能",
inspectionResult: "",
inspectionResultLable: "正常",
lableArr: ["正常", "异常"],
conclusion: "",
photos: [],
},
],
},
};
},
computed: {
userInfo() {
return this.$store.state.now_user || {};
},
},
watch: {
defaultData(newVal) {
// 在这里处理数据变化
if (Object.keys(this.defaultData).length !== 0) {
this.itemData = this.defaultData;
}
},
},
async mounted() {
console.log("sdsadasd", this.itemData);
// if (Object.keys(this.defaultData).length !== 0) {
// this.itemData = this.defaultData;
// }
},
methods: {
// 拍照
takePhoto(index) {
uni.chooseImage({
count: 1,
sourceType: ["camera"], // 可以从相机拍摄
success: async (res) => {
if (this.photos.length < 5) {
const base64 = await this.convertFileToBase64(res.tempFilePaths[0]);
this.itemData.detail[index].photos.push(base64);
} else {
uni.showToast({
title: "最多只能上传5张照片",
icon: "none",
});
}
},
});
},
// 转化为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);
},
);
});
},
// 删除照片
deletePhoto(index, itemIndex) {
this.itemData.detail[index].photos.splice(itemIndex, 1);
},
// 处理弹窗确认
handlePopupConfirm(summary) {
this.itemData.detail[this.currentIndex].conclusion = summary; // 回显到文字显示区域
},
// 处理】数据
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;
this.itemData.status = isAllOne.status; //1表示已经巡检过没有异常
this.itemData.statusLabel = isAllOne.statusLabel;
console.log("查看数据", this.itemData);
return this.itemData;
},
// 数据校验方法 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) {
return false;
}
} else {
// 其他情况(理论上不应该存在,根据当前规则)
return false;
}
}
// 所有检查都通过
return true;
},
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 };
}
},
setNormal() {
this.itemData.detail.forEach((item) => {
item.inspectionResult = 0;
});
},
},
};
</script>
<style scoped lang="less">
.form-item {
display: flex;
align-items: center;
padding: 9.6px 0;
line-height: 28.8px;
border-bottom: 0.8px solid #f2f3f5;
.form-label {
font-size: 11.2px;
margin-right: 25.6px;
width: 88px;
text-align: right;
color: #7c7c7c;
.required {
color: red;
margin-right: 3.2px;
}
}
.conclusion {
&.no-text {
color: #c7c7c7;
}
.have {
color: #000;
}
}
.label {
font-size: 11.2px;
}
.switch-container {
display: flex;
gap: 9.6px;
.status-btn {
flex: 1;
padding: 5.6px 19.2px;
font-size: 12.8px;
color: #000000;
background: #f2f2f2;
text-align: center;
font-weight: 400;
line-height: 17.6px;
border-radius: 14.4px;
&.active {
color: #ffffff;
background: #3774f6;
border: 0.32px solid rgba(224, 224, 224, 1);
}
}
}
.input-box {
flex: 1;
border-radius: 3.2px;
font-size: 12.8px;
line-height: 19.2px;
}
.photo-limit {
font-size: 12.8px;
color: #959595;
line-height: 19.2px;
font-weight: 400;
}
.photo-container {
display: flex;
flex-wrap: wrap;
margin-bottom: 6.4px;
.photo-item {
position: relative;
margin-right: 6.4px;
margin-bottom: 6.4px;
.photo {
width: 57.6px;
height: 57.6px;
border-radius: 3.2px;
margin-left: 9.6px;
}
.delete-photo {
position: absolute;
top: -6.4px;
right: -6.4px;
background-color: #ff4d4f;
color: #fff;
width: 12.8px;
height: 12.8px;
border-radius: 50%;
text-align: center;
line-height: 12.8px;
font-size: 9.6px;
}
}
}
.photo-btn {
background: #ffffff;
border: 0.272px solid rgba(221, 221, 221, 1);
border-radius: 1.64px;
width: 57.6px;
height: 57.6px;
font-size: 57.6px;
color: #cccccc;
text-align: center;
line-height: 51.2px;
}
}
</style>
<template>
<!-- 机房巡检操作 -->
<view>
<view v-for="(item, index) in itemData.detail" :key="index">
<view class="form-item">
<text class="form-label"
><text class="required">*</text>{{ item.label }}</text
>
<view class="switch-container">
<view
:class="['status-btn', { active: item.inspectionResult === 0 }]"
@click="setInspectionResult(index, 0, item.lableArr[0])"
>
{{ item.lableArr[0] }}
</view>
<view
:class="['status-btn', { active: item.inspectionResult === 1 }]"
@click="setInspectionResult(index, 1, item.lableArr[1])"
>
{{ item.lableArr[1] }}
</view>
</view>
</view>
<template v-if="item.inspectionResult === 1">
<view class="form-item">
<text class="form-label"
><text class="required">*</text>情况摘要</text
>
<text
:class="['conclusion', { 'no-text': !item.conclusion }]"
@click="showPopup(item, index)"
>
{{ item.conclusion || "请输入情况摘要" }}</text
>
</view>
<view class="form-item">
<text class="form-label"
><text class="required">*</text>现场照片</text
>
<CommonUpload v-model="item.photos" :max-count="5">
</CommonUpload> </view
></template> </view
><custom-popup
ref="customPopup"
:inspectionItem="inspectionItem"
@confirm="handlePopupConfirm"
></custom-popup>
</view>
</template>
<script>
import CommonUpload from "@/components/CommonUpload/index.vue";
import customPopup from "./customPopup.vue";
import _ from "lodash";
import mixin from "./mixin";
export default {
components: {
CommonUpload,
customPopup,
},
mixins: [mixin],
props: {
// 父组件传递的巡检状态
status: {
type: Number,
default: 0,
},
// 父组件传递的巡检事项名
inspectionItem: {
type: String,
default: "",
},
// 父组件传递的数据
defaultData: {
type: Object,
default: () => ({}),
},
},
data() {
return {
currentIndex: 0, // 当前操作的索引
photos: [],
itemData: {
isValid: false, // false是校验未通过 true是校验通过
status: 0, //0是未巡检 1是已巡检 2巡检异常
statusLabel: "未巡检",
inspectionItem: "", //巡检事项
detail: [
{
label: "漏水报警功能",
inspectionResult: "",
inspectionResultLable: "正常",
lableArr: ["正常", "异常"],
conclusion: "",
photos: [],
},
],
},
};
},
computed: {
userInfo() {
return this.$store.state.now_user || {};
},
},
watch: {
defaultData(newVal) {
// 在这里处理数据变化
if (Object.keys(this.defaultData).length !== 0) {
this.itemData = this.defaultData;
}
},
},
async mounted() {
console.log("sdsadasd", this.itemData);
// if (Object.keys(this.defaultData).length !== 0) {
// this.itemData = this.defaultData;
// }
},
methods: {
// 拍照
takePhoto(index) {
uni.chooseImage({
count: 1,
sourceType: ["camera"], // 可以从相机拍摄
success: async (res) => {
if (this.photos.length < 5) {
const base64 = await this.convertFileToBase64(res.tempFilePaths[0]);
this.itemData.detail[index].photos.push(base64);
} else {
uni.showToast({
title: "最多只能上传5张照片",
icon: "none",
});
}
},
});
},
// 转化为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);
},
);
});
},
// 删除照片
deletePhoto(index, itemIndex) {
this.itemData.detail[index].photos.splice(itemIndex, 1);
},
// 处理弹窗确认
handlePopupConfirm(summary) {
this.itemData.detail[this.currentIndex].conclusion = summary; // 回显到文字显示区域
},
// 处理】数据
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;
this.itemData.status = isAllOne.status; //1表示已经巡检过没有异常
this.itemData.statusLabel = isAllOne.statusLabel;
console.log("查看数据", this.itemData);
return this.itemData;
},
// 数据校验方法 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) {
return false;
}
} else {
// 其他情况(理论上不应该存在,根据当前规则)
return false;
}
}
// 所有检查都通过
return true;
},
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 };
}
},
setNormal() {
this.itemData.detail.forEach((item) => {
item.inspectionResult = 0;
});
},
},
};
</script>
<style scoped lang="less">
.form-item {
display: flex;
align-items: center;
padding: 9.6px 0;
line-height: 28.8px;
border-bottom: 0.8px solid #f2f3f5;
.form-label {
font-size: 11.2px;
margin-right: 25.6px;
width: 88px;
text-align: right;
color: #7c7c7c;
.required {
color: red;
margin-right: 3.2px;
}
}
.conclusion {
&.no-text {
color: #c7c7c7;
}
.have {
color: #000;
}
}
.label {
font-size: 11.2px;
}
.switch-container {
display: flex;
gap: 9.6px;
.status-btn {
flex: 1;
padding: 5.6px 19.2px;
font-size: 12.8px;
color: #000000;
background: #f2f2f2;
text-align: center;
font-weight: 400;
line-height: 17.6px;
border-radius: 14.4px;
&.active {
color: #ffffff;
background: #3774f6;
border: 0.32px solid rgba(224, 224, 224, 1);
}
}
}
.input-box {
flex: 1;
border-radius: 3.2px;
font-size: 12.8px;
line-height: 19.2px;
}
.photo-limit {
font-size: 12.8px;
color: #959595;
line-height: 19.2px;
font-weight: 400;
}
.photo-container {
display: flex;
flex-wrap: wrap;
margin-bottom: 6.4px;
.photo-item {
position: relative;
margin-right: 6.4px;
margin-bottom: 6.4px;
.photo {
width: 57.6px;
height: 57.6px;
border-radius: 3.2px;
margin-left: 9.6px;
}
.delete-photo {
position: absolute;
top: -6.4px;
right: -6.4px;
background-color: #ff4d4f;
color: #fff;
width: 12.8px;
height: 12.8px;
border-radius: 50%;
text-align: center;
line-height: 12.8px;
font-size: 9.6px;
}
}
}
.photo-btn {
background: #ffffff;
border: 0.272px solid rgba(221, 221, 221, 1);
border-radius: 1.64px;
width: 57.6px;
height: 57.6px;
font-size: 57.6px;
color: #cccccc;
text-align: center;
line-height: 51.2px;
}
}
</style>
<template>
<!-- 机房巡检操作 -->
<view>
<view v-for="(item, index) in itemData.detail" :key="index">
<view class="form-item">
<text class="form-label"
><text class="required">*</text>{{ item.label }}</text
>
<view class="switch-container">
<view
:class="['status-btn', { active: item.inspectionResult === 0 }]"
@click="setInspectionResult(index, 0, item.lableArr[0])"
>
{{ item.lableArr[0] }}
</view>
<view
:class="['status-btn', { active: item.inspectionResult === 1 }]"
@click="setInspectionResult(index, 1, item.lableArr[1])"
>
{{ item.lableArr[1] }}
</view>
</view>
</view>
<template v-if="item.inspectionResult === 1">
<view class="form-item">
<text class="form-label"
><text class="required">*</text>情况摘要</text
>
<text
:class="['conclusion', { 'no-text': !item.conclusion }]"
@click="showPopup(item, index)"
>
{{ item.conclusion || "请输入情况摘要" }}</text
>
</view>
<view class="form-item">
<text class="form-label"
><text class="required">*</text>现场照片</text
>
<CommonUpload v-model="item.photos" :max-count="5">
</CommonUpload> </view
></template> </view
><custom-popup
ref="customPopup"
:inspectionItem="inspectionItem"
@confirm="handlePopupConfirm"
></custom-popup>
</view>
</template>
<script>
import CommonUpload from "@/components/CommonUpload/index.vue";
import customPopup from "./customPopup.vue";
import _ from "lodash";
import mixin from "./mixin";
export default {
components: {
CommonUpload,
customPopup,
},
mixins: [mixin],
props: {
// 父组件传递的巡检状态
status: {
type: Number,
default: 0,
},
// 父组件传递的巡检事项名
inspectionItem: {
type: String,
default: "",
},
// 父组件传递的数据
defaultData: {
type: Object,
default: () => ({}),
},
},
data() {
return {
currentIndex: 0, // 当前操作的索引
photos: [],
itemData: {
isValid: false, // false是校验未通过 true是校验通过
status: 0, //0是未巡检 1是已巡检 2巡检异常
statusLabel: "未巡检",
inspectionItem: "", //巡检事项
detail: [
{
label: "等电位连接",
inspectionResult: "",
inspectionResultLable: "正常",
lableArr: ["正常", "异常"],
conclusion: "",
photos: [],
},
{
label: "外壳、机架连接",
inspectionResult: "",
inspectionResultLable: "正常",
lableArr: ["正常", "异常"],
conclusion: "",
photos: [],
},
{
label: "接地装置",
inspectionResult: "",
inspectionResultLable: "正常",
lableArr: ["正常", "异常"],
conclusion: "",
photos: [],
},
],
},
};
},
computed: {
userInfo() {
return this.$store.state.now_user || {};
},
},
watch: {
defaultData(newVal) {
// 在这里处理数据变化
if (Object.keys(this.defaultData).length !== 0) {
this.itemData = this.defaultData;
}
},
},
async mounted() {
console.log("sdsadasd", this.itemData);
// if (Object.keys(this.defaultData).length !== 0) {
// this.itemData = this.defaultData;
// }
},
methods: {
// 拍照
takePhoto(index) {
uni.chooseImage({
count: 1,
sourceType: ["camera"], // 可以从相机拍摄
success: async (res) => {
if (this.photos.length < 5) {
const base64 = await this.convertFileToBase64(res.tempFilePaths[0]);
this.itemData.detail[index].photos.push(base64);
} else {
uni.showToast({
title: "最多只能上传5张照片",
icon: "none",
});
}
},
});
},
// 转化为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);
},
);
});
},
// 删除照片
deletePhoto(index, itemIndex) {
this.itemData.detail[index].photos.splice(itemIndex, 1);
},
// 处理弹窗确认
handlePopupConfirm(summary) {
this.itemData.detail[this.currentIndex].conclusion = summary; // 回显到文字显示区域
},
// 处理】数据
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;
this.itemData.status = isAllOne.status; //1表示已经巡检过没有异常
this.itemData.statusLabel = isAllOne.statusLabel;
console.log("查看数据", this.itemData);
return this.itemData;
},
// 数据校验方法 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) {
return false;
}
} else {
// 其他情况(理论上不应该存在,根据当前规则)
return false;
}
}
// 所有检查都通过
return true;
},
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 };
}
},
setNormal() {
this.itemData.detail.forEach((item) => {
item.inspectionResult = 0;
});
},
},
};
</script>
<style scoped lang="less">
.form-item {
display: flex;
align-items: center;
padding: 9.6px 0;
line-height: 28.8px;
border-bottom: 0.8px solid #f2f3f5;
.form-label {
font-size: 11.2px;
margin-right: 25.6px;
width: 88px;
text-align: right;
color: #7c7c7c;
.required {
color: red;
margin-right: 3.2px;
}
}
.conclusion {
&.no-text {
color: #c7c7c7;
}
.have {
color: #000;
}
}
.label {
font-size: 11.2px;
}
.switch-container {
display: flex;
gap: 9.6px;
.status-btn {
flex: 1;
padding: 5.6px 19.2px;
font-size: 12.8px;
color: #000000;
background: #f2f2f2;
text-align: center;
font-weight: 400;
line-height: 17.6px;
border-radius: 14.4px;
&.active {
color: #ffffff;
background: #3774f6;
border: 0.32px solid rgba(224, 224, 224, 1);
}
}
}
.input-box {
flex: 1;
border-radius: 3.2px;
font-size: 12.8px;
line-height: 19.2px;
}
.photo-limit {
font-size: 12.8px;
color: #959595;
line-height: 19.2px;
font-weight: 400;
}
.photo-container {
display: flex;
flex-wrap: wrap;
margin-bottom: 6.4px;
.photo-item {
position: relative;
margin-right: 6.4px;
margin-bottom: 6.4px;
.photo {
width: 57.6px;
height: 57.6px;
border-radius: 3.2px;
margin-left: 9.6px;
}
.delete-photo {
position: absolute;
top: -6.4px;
right: -6.4px;
background-color: #ff4d4f;
color: #fff;
width: 12.8px;
height: 12.8px;
border-radius: 50%;
text-align: center;
line-height: 12.8px;
font-size: 9.6px;
}
}
}
.photo-btn {
background: #ffffff;
border: 0.272px solid rgba(221, 221, 221, 1);
border-radius: 1.64px;
width: 57.6px;
height: 57.6px;
font-size: 57.6px;
color: #cccccc;
text-align: center;
line-height: 51.2px;
}
}
</style>
<template>
<!-- 机房巡检操作 -->
<view>
<view v-for="(item, index) in itemData.detail" :key="index">
<view class="form-item">
<text class="form-label"
><text class="required">*</text>{{ item.label }}</text
>
<view class="switch-container">
<view
:class="['status-btn', { active: item.inspectionResult === 0 }]"
@click="setInspectionResult(index, 0, item.lableArr[0])"
>
{{ item.lableArr[0] }}
</view>
<view
:class="['status-btn', { active: item.inspectionResult === 1 }]"
@click="setInspectionResult(index, 1, item.lableArr[1])"
>
{{ item.lableArr[1] }}
</view>
</view>
</view>
<template v-if="item.inspectionResult === 1">
<view class="form-item">
<text class="form-label"
><text class="required">*</text>情况摘要</text
>
<text
:class="['conclusion', { 'no-text': !item.conclusion }]"
@click="showPopup(item, index)"
>
{{ item.conclusion || "请输入情况摘要" }}</text
>
</view>
<view class="form-item">
<text class="form-label"
><text class="required">*</text>现场照片</text
>
<CommonUpload v-model="item.photos" :max-count="5">
</CommonUpload> </view
></template> </view
><custom-popup
ref="customPopup"
:inspectionItem="inspectionItem"
@confirm="handlePopupConfirm"
></custom-popup>
</view>
</template>
<script>
import CommonUpload from "@/components/CommonUpload/index.vue";
import customPopup from "./customPopup.vue";
import _ from "lodash";
import mixin from "./mixin";
export default {
components: {
CommonUpload,
customPopup,
},
mixins: [mixin],
props: {
// 父组件传递的巡检状态
status: {
type: Number,
default: 0,
},
// 父组件传递的巡检事项名
inspectionItem: {
type: String,
default: "",
},
// 父组件传递的数据
defaultData: {
type: Object,
default: () => ({}),
},
},
data() {
return {
currentIndex: 0, // 当前操作的索引
photos: [],
itemData: {
isValid: false, // false是校验未通过 true是校验通过
status: 0, //0是未巡检 1是已巡检 2巡检异常
statusLabel: "未巡检",
inspectionItem: "", //巡检事项
detail: [
{
label: "风机内过滤器清洗",
inspectionResult: "",
inspectionResultLable: "有",
lableArr: ["有", "无"],
conclusion: "",
photos: [],
},
],
},
};
},
computed: {
userInfo() {
return this.$store.state.now_user || {};
},
},
watch: {
defaultData(newVal) {
// 在这里处理数据变化
if (Object.keys(this.defaultData).length !== 0) {
this.itemData = this.defaultData;
}
},
},
async mounted() {
console.log("sdsadasd", this.itemData);
// if (Object.keys(this.defaultData).length !== 0) {
// this.itemData = this.defaultData;
// }
},
methods: {
// 拍照
takePhoto(index) {
uni.chooseImage({
count: 1,
sourceType: ["camera"], // 可以从相机拍摄
success: async (res) => {
if (this.photos.length < 5) {
const base64 = await this.convertFileToBase64(res.tempFilePaths[0]);
this.itemData.detail[index].photos.push(base64);
} else {
uni.showToast({
title: "最多只能上传5张照片",
icon: "none",
});
}
},
});
},
// 转化为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);
},
);
});
},
// 删除照片
deletePhoto(index, itemIndex) {
this.itemData.detail[index].photos.splice(itemIndex, 1);
},
// 处理弹窗确认
handlePopupConfirm(summary) {
this.itemData.detail[this.currentIndex].conclusion = summary; // 回显到文字显示区域
},
// 处理】数据
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;
this.itemData.status = isAllOne.status; //1表示已经巡检过没有异常
this.itemData.statusLabel = isAllOne.statusLabel;
console.log("查看数据", this.itemData);
return this.itemData;
},
// 数据校验方法 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) {
return false;
}
} else {
// 其他情况(理论上不应该存在,根据当前规则)
return false;
}
}
// 所有检查都通过
return true;
},
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 };
}
},
setNormal() {
this.itemData.detail.forEach((item) => {
item.inspectionResult = 0;
});
},
},
};
</script>
<style scoped lang="less">
.form-item {
display: flex;
align-items: center;
padding: 9.6px 0;
line-height: 28.8px;
border-bottom: 0.8px solid #f2f3f5;
.form-label {
font-size: 11.2px;
margin-right: 25.6px;
width: 98px;
text-align: right;
color: #7c7c7c;
.required {
color: red;
margin-right: 3.2px;
}
}
.conclusion {
&.no-text {
color: #c7c7c7;
}
.have {
color: #000;
}
}
.label {
font-size: 11.2px;
}
.switch-container {
display: flex;
gap: 9.6px;
.status-btn {
flex: 1;
padding: 5.6px 19.2px;
font-size: 12.8px;
color: #000000;
background: #f2f2f2;
text-align: center;
font-weight: 400;
line-height: 17.6px;
border-radius: 14.4px;
&.active {
color: #ffffff;
background: #3774f6;
border: 0.32px solid rgba(224, 224, 224, 1);
}
}
}
.input-box {
flex: 1;
border-radius: 3.2px;
font-size: 12.8px;
line-height: 19.2px;
}
.photo-limit {
font-size: 12.8px;
color: #959595;
line-height: 19.2px;
font-weight: 400;
}
.photo-container {
display: flex;
flex-wrap: wrap;
margin-bottom: 6.4px;
.photo-item {
position: relative;
margin-right: 6.4px;
margin-bottom: 6.4px;
.photo {
width: 57.6px;
height: 57.6px;
border-radius: 3.2px;
margin-left: 9.6px;
}
.delete-photo {
position: absolute;
top: -6.4px;
right: -6.4px;
background-color: #ff4d4f;
color: #fff;
width: 12.8px;
height: 12.8px;
border-radius: 50%;
text-align: center;
line-height: 12.8px;
font-size: 9.6px;
}
}
}
.photo-btn {
background: #ffffff;
border: 0.272px solid rgba(221, 221, 221, 1);
border-radius: 1.64px;
width: 57.6px;
height: 57.6px;
font-size: 57.6px;
color: #cccccc;
text-align: center;
line-height: 51.2px;
}
}
</style>
<template>
<!-- 机房巡检操作 -->
<view>
<view v-for="(item, index) in itemData.detail" :key="index">
<view class="form-item">
<text class="form-label"
><text class="required">*</text>{{ item.label }}</text
>
<view class="switch-container">
<view
:class="['status-btn', { active: item.inspectionResult === 0 }]"
@click="setInspectionResult(index, 0, item.lableArr[0])"
>
{{ item.lableArr[0] }}
</view>
<view
:class="['status-btn', { active: item.inspectionResult === 1 }]"
@click="setInspectionResult(index, 1, item.lableArr[1])"
>
{{ item.lableArr[1] }}
</view>
</view>
</view>
<template v-if="item.inspectionResult === 1">
<view class="form-item">
<text class="form-label"
><text class="required">*</text>情况摘要</text
>
<text
:class="['conclusion', { 'no-text': !item.conclusion }]"
@click="showPopup(item, index)"
>
{{ item.conclusion || "请输入情况摘要" }}</text
>
</view>
<view class="form-item">
<text class="form-label"
><text class="required">*</text>现场照片</text
>
<CommonUpload v-model="item.photos" :max-count="5">
</CommonUpload> </view
></template> </view
><custom-popup
ref="customPopup"
:inspectionItem="inspectionItem"
@confirm="handlePopupConfirm"
></custom-popup>
</view>
</template>
<script>
import CommonUpload from "@/components/CommonUpload/index.vue";
import customPopup from "./customPopup.vue";
import _ from "lodash";
import mixin from "./mixin";
export default {
components: {
CommonUpload,
customPopup,
},
mixins: [mixin],
props: {
// 父组件传递的巡检状态
status: {
type: Number,
default: 0,
},
// 父组件传递的巡检事项名
inspectionItem: {
type: String,
default: "",
},
// 父组件传递的数据
defaultData: {
type: Object,
default: () => ({}),
},
},
data() {
return {
currentIndex: 0, // 当前操作的索引
photos: [],
itemData: {
isValid: false, // false是校验未通过 true是校验通过
status: 0, //0是未巡检 1是已巡检 2巡检异常
statusLabel: "未巡检",
inspectionItem: "", //巡检事项
detail: [
{
label: "信号强度",
inspectionResult: "",
inspectionResultLable: "正常",
lableArr: ["正常", "异常"],
conclusion: "",
photos: [],
},
],
},
};
},
computed: {
userInfo() {
return this.$store.state.now_user || {};
},
},
watch: {
defaultData(newVal) {
// 在这里处理数据变化
if (Object.keys(this.defaultData).length !== 0) {
this.itemData = this.defaultData;
}
},
},
async mounted() {
console.log("sdsadasd", this.itemData);
// if (Object.keys(this.defaultData).length !== 0) {
// this.itemData = this.defaultData;
// }
},
methods: {
// 拍照
takePhoto(index) {
uni.chooseImage({
count: 1,
sourceType: ["camera"], // 可以从相机拍摄
success: async (res) => {
if (this.photos.length < 5) {
const base64 = await this.convertFileToBase64(res.tempFilePaths[0]);
this.itemData.detail[index].photos.push(base64);
} else {
uni.showToast({
title: "最多只能上传5张照片",
icon: "none",
});
}
},
});
},
// 转化为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);
},
);
});
},
// 删除照片
deletePhoto(index, itemIndex) {
this.itemData.detail[index].photos.splice(itemIndex, 1);
},
// 处理弹窗确认
handlePopupConfirm(summary) {
this.itemData.detail[this.currentIndex].conclusion = summary; // 回显到文字显示区域
},
// 处理】数据
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;
this.itemData.status = isAllOne.status; //1表示已经巡检过没有异常
this.itemData.statusLabel = isAllOne.statusLabel;
console.log("查看数据", this.itemData);
return this.itemData;
},
// 数据校验方法 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) {
return false;
}
} else {
// 其他情况(理论上不应该存在,根据当前规则)
return false;
}
}
// 所有检查都通过
return true;
},
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 };
}
},
setNormal() {
this.itemData.detail.forEach((item) => {
item.inspectionResult = 0;
});
},
},
};
</script>
<style scoped lang="less">
.form-item {
display: flex;
align-items: center;
padding: 9.6px 0;
line-height: 28.8px;
border-bottom: 0.8px solid #f2f3f5;
.form-label {
font-size: 11.2px;
margin-right: 25.6px;
width: 88px;
text-align: right;
color: #7c7c7c;
.required {
color: red;
margin-right: 3.2px;
}
}
.conclusion {
&.no-text {
color: #c7c7c7;
}
.have {
color: #000;
}
}
.label {
font-size: 11.2px;
}
.switch-container {
display: flex;
gap: 9.6px;
.status-btn {
flex: 1;
padding: 5.6px 19.2px;
font-size: 12.8px;
color: #000000;
background: #f2f2f2;
text-align: center;
font-weight: 400;
line-height: 17.6px;
border-radius: 14.4px;
&.active {
color: #ffffff;
background: #3774f6;
border: 0.32px solid rgba(224, 224, 224, 1);
}
}
}
.input-box {
flex: 1;
border-radius: 3.2px;
font-size: 12.8px;
line-height: 19.2px;
}
.photo-limit {
font-size: 12.8px;
color: #959595;
line-height: 19.2px;
font-weight: 400;
}
.photo-container {
display: flex;
flex-wrap: wrap;
margin-bottom: 6.4px;
.photo-item {
position: relative;
margin-right: 6.4px;
margin-bottom: 6.4px;
.photo {
width: 57.6px;
height: 57.6px;
border-radius: 3.2px;
margin-left: 9.6px;
}
.delete-photo {
position: absolute;
top: -6.4px;
right: -6.4px;
background-color: #ff4d4f;
color: #fff;
width: 12.8px;
height: 12.8px;
border-radius: 50%;
text-align: center;
line-height: 12.8px;
font-size: 9.6px;
}
}
}
.photo-btn {
background: #ffffff;
border: 0.272px solid rgba(221, 221, 221, 1);
border-radius: 1.64px;
width: 57.6px;
height: 57.6px;
font-size: 57.6px;
color: #cccccc;
text-align: center;
line-height: 51.2px;
}
}
</style>
<template>
<!-- 机房巡检操作 -->
<view>
<view v-for="(item, index) in itemData.detail" :key="index">
<view class="form-item">
<text class="form-label"
><text class="required">*</text>{{ item.label }}</text
>
<view class="switch-container">
<view
:class="['status-btn', { active: item.inspectionResult === 0 }]"
@click="setInspectionResult(index, 0, item.lableArr[0])"
>
{{ item.lableArr[0] }}
</view>
<view
:class="['status-btn', { active: item.inspectionResult === 1 }]"
@click="setInspectionResult(index, 1, item.lableArr[1])"
>
{{ item.lableArr[1] }}
</view>
</view>
</view>
<template v-if="item.inspectionResult === 1">
<view class="form-item">
<text class="form-label"
><text class="required">*</text>情况摘要</text
>
<text
:class="['conclusion', { 'no-text': !item.conclusion }]"
@click="showPopup(item, index)"
>
{{ item.conclusion || "请输入情况摘要" }}</text
>
</view>
<view class="form-item">
<text class="form-label"
><text class="required">*</text>现场照片</text
>
<CommonUpload v-model="item.photos" :max-count="5">
</CommonUpload> </view
></template> </view
><custom-popup
ref="customPopup"
:inspectionItem="inspectionItem"
@confirm="handlePopupConfirm"
></custom-popup>
</view>
</template>
<script>
import CommonUpload from "@/components/CommonUpload/index.vue";
import customPopup from "./customPopup.vue";
import _ from "lodash";
import mixin from "./mixin";
export default {
components: {
CommonUpload,
customPopup,
},
mixins: [mixin],
props: {
// 父组件传递的巡检状态
status: {
type: Number,
default: 0,
},
// 父组件传递的巡检事项名
inspectionItem: {
type: String,
default: "",
},
// 父组件传递的数据
defaultData: {
type: Object,
default: () => ({}),
},
},
data() {
return {
currentIndex: 0, // 当前操作的索引
photos: [],
itemData: {
isValid: false, // false是校验未通过 true是校验通过
status: 0, //0是未巡检 1是已巡检 2巡检异常
statusLabel: "未巡检",
inspectionItem: "", //巡检事项
detail: [
{
label: "旁路模式供电检查",
inspectionResult: "",
inspectionResultLable: "正常",
lableArr: ["正常", "异常"],
conclusion: "",
photos: [],
},
{
label: "蓄电池放电测试",
inspectionResult: "",
inspectionResultLable: "正常",
lableArr: ["正常", "异常"],
conclusion: "",
photos: [],
},
{
label: "电池电压",
inspectionResult: "",
inspectionResultLable: "正常",
lableArr: ["正常", "异常"],
conclusion: "",
photos: [],
},
],
},
};
},
computed: {
userInfo() {
return this.$store.state.now_user || {};
},
},
watch: {
defaultData(newVal) {
// 在这里处理数据变化
if (Object.keys(this.defaultData).length !== 0) {
this.itemData = this.defaultData;
}
},
},
async mounted() {
console.log("sdsadasd", this.itemData);
// if (Object.keys(this.defaultData).length !== 0) {
// this.itemData = this.defaultData;
// }
},
methods: {
// 拍照
takePhoto(index) {
uni.chooseImage({
count: 1,
sourceType: ["camera"], // 可以从相机拍摄
success: async (res) => {
if (this.photos.length < 5) {
const base64 = await this.convertFileToBase64(res.tempFilePaths[0]);
this.itemData.detail[index].photos.push(base64);
} else {
uni.showToast({
title: "最多只能上传5张照片",
icon: "none",
});
}
},
});
},
// 转化为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);
},
);
});
},
// 删除照片
deletePhoto(index, itemIndex) {
this.itemData.detail[index].photos.splice(itemIndex, 1);
},
// 处理弹窗确认
handlePopupConfirm(summary) {
this.itemData.detail[this.currentIndex].conclusion = summary; // 回显到文字显示区域
},
// 处理】数据
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;
this.itemData.status = isAllOne.status; //1表示已经巡检过没有异常
this.itemData.statusLabel = isAllOne.statusLabel;
console.log("查看数据", this.itemData);
return this.itemData;
},
// 数据校验方法 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) {
return false;
}
} else {
// 其他情况(理论上不应该存在,根据当前规则)
return false;
}
}
// 所有检查都通过
return true;
},
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 };
}
},
setNormal() {
this.itemData.detail.forEach((item) => {
item.inspectionResult = 0;
});
},
},
};
</script>
<style scoped lang="less">
.form-item {
display: flex;
align-items: center;
padding: 9.6px 0;
line-height: 28.8px;
border-bottom: 0.8px solid #f2f3f5;
.form-label {
font-size: 11.2px;
margin-right: 25.6px;
width: 98px;
text-align: right;
color: #7c7c7c;
.required {
color: red;
margin-right: 3.2px;
}
}
.conclusion {
&.no-text {
color: #c7c7c7;
}
.have {
color: #000;
}
}
.label {
font-size: 11.2px;
}
.switch-container {
display: flex;
gap: 9.6px;
.status-btn {
flex: 1;
padding: 5.6px 19.2px;
font-size: 12.8px;
color: #000000;
background: #f2f2f2;
text-align: center;
font-weight: 400;
line-height: 17.6px;
border-radius: 14.4px;
&.active {
color: #ffffff;
background: #3774f6;
border: 0.32px solid rgba(224, 224, 224, 1);
}
}
}
.input-box {
flex: 1;
border-radius: 3.2px;
font-size: 12.8px;
line-height: 19.2px;
}
.photo-limit {
font-size: 12.8px;
color: #959595;
line-height: 19.2px;
font-weight: 400;
}
.photo-container {
display: flex;
flex-wrap: wrap;
margin-bottom: 6.4px;
.photo-item {
position: relative;
margin-right: 6.4px;
margin-bottom: 6.4px;
.photo {
width: 57.6px;
height: 57.6px;
border-radius: 3.2px;
margin-left: 9.6px;
}
.delete-photo {
position: absolute;
top: -6.4px;
right: -6.4px;
background-color: #ff4d4f;
color: #fff;
width: 12.8px;
height: 12.8px;
border-radius: 50%;
text-align: center;
line-height: 12.8px;
font-size: 9.6px;
}
}
}
.photo-btn {
background: #ffffff;
border: 0.272px solid rgba(221, 221, 221, 1);
border-radius: 1.64px;
width: 57.6px;
height: 57.6px;
font-size: 57.6px;
color: #cccccc;
text-align: center;
line-height: 51.2px;
}
}
</style>
......@@ -295,7 +295,7 @@ export default {
isDialog: false,
propList: [],
did: "", // 最近7天数据的id
patrolType: "JFXJ", // 巡检类型
inspectionType: "1",
};
},
computed: {
......@@ -329,6 +329,7 @@ export default {
onLoad(options) {
this.options = options;
this.backValue = this.options.backValue || "";
this.inspectionType = options.inspectionType || "1";
this.isDisable = options.isDisable == 1 ? true : false;
this.uid = this.options.uid || "";
this.value = this.options.value || "1";
......@@ -344,8 +345,11 @@ export default {
});
} else {
this.getRoomList().then((res) => {
console.log(11111111111111, res);
// 获取7日(168小时)内最后一条巡检记录回显到页面(选项、文案、照片;异常项-不调出文案及照片)
getHistoryData().then((detailsInfo) => {
getHistoryData(this.inspectionType).then((detailsInfo) => {
console.log(111111222222233, detailsInfo);
if (detailsInfo) {
// 处理历史数据(选项、文案、照片;异常项-不调出文案及照片)
console.log("detailsInfo", detailsInfo);
......@@ -359,9 +363,7 @@ export default {
this.detailsInfo = detailsInfo;
this.inspectionNumber = detailsInfo.inspectionNumber;
this.inspectionCode = `${this.patrolType}${moment().format("yyyyMMDDHHmmss")}${
Math.floor(Math.random() * 900) + 100
}`;
this.inspectionCode = this.getInspectionCode();
this.cardsInfo = detailsInfo.originData;
this.isSubmit = 0;
this.isSign = false;
......@@ -452,9 +454,7 @@ export default {
if (this.uid) {
this.inspectionCode = this.detailsInfo.inspectionCode;
} else {
this.inspectionCode = `${this.patrolType}${moment().format("yyyyMMDDHHmmss")}${
Math.floor(Math.random() * 900) + 100
}`;
this.inspectionCode = this.getInspectionCode();
}
resolve();
});
......@@ -589,9 +589,22 @@ export default {
// 跳转到具体的机房
toShaftInspection(name, jfType, value) {
console.log("name, 跳转到具体的机房, value", name, jfType, value);
if (this.inspectionType == "3") {
// 跳转月度巡检
uni.navigateTo({
url: `/pages/inspectionContent/inspectionContentMonthlyNew?value=${value}&inspectionCode=${this.inspectionCode}&jfType=${jfType}&location=${name}&uid=${this.uid}&backValue=${this.backValue}&did=${this.did}`,
});
} else if (this.inspectionType == "4") {
// 跳转年度巡检
uni.navigateTo({
url: `/pages/inspectionContent/inspectionContentYearNew?value=${value}&inspectionCode=${this.inspectionCode}&jfType=${jfType}&location=${name}&uid=${this.uid}&backValue=${this.backValue}&did=${this.did}`,
});
} else {
// 跳转日常巡检
uni.navigateTo({
url: `/pages/inspectionContent/inspectionContentNew?value=${value}&inspectionCode=${this.inspectionCode}&jfType=${jfType}&location=${name}&uid=${this.uid}&backValue=${this.backValue}&did=${this.did}`,
});
}
},
lookTable() {
uni.navigateTo({
......@@ -659,18 +672,15 @@ export default {
this.detailsInfo.synchronization = 0;
}
this.detailsInfo.inspectionType = this.inspectionType || "1";
this.realSave(this.detailsInfo);
},
realSave(params, type = "sign") {
const send = dataToSql(params);
const api = this.uid ? inspectApi.update : inspectApi.save;
const inspectionCode =
this.inspectionCode ||
`${this.patrolType}${moment().format("yyyyMMDDHHmmss")}${
Math.floor(Math.random() * 900) + 100
}`;
const inspectionCode = this.inspectionCode || this.getInspectionCode();
send.inspectionCode = inspectionCode;
console.log("send", send);
......@@ -696,6 +706,11 @@ export default {
}
});
},
getInspectionCode() {
return `${this.inspectionType == "3" ? "YDXJ" : this.inspectionType == "4" ? "NDXJ" : "JFXJ"}${moment().format("yyyyMMDDHHmmss")}${
Math.floor(Math.random() * 900) + 100
}`;
},
back() {
if (this.backValue === "home") {
uni.navigateTo({
......
<template>
<view class="container">
<uni-nav-bar
:fixed="true"
background-color="rgba(214, 240, 255, 0.0)"
status-bar
rightWidth="240"
>
<block slot="left">
<view class="" @click="back">
<text class="iconfont icon-fanhui"></text>
</view>
</block>
<block slot="right" class="nav-right">
<view class="header-buttons">
<view class="button" @click="lookTable">查看样表</view>
</view>
</block>
</uni-nav-bar>
<view class="profile-section">
<view class="profile-box">
<view class="profile-left">
<view class="avatar">
<image
src="@/static/img/add-img/defaultAvatar.png"
mode="aspectFit"
></image>
</view>
<view class="info">
<view class="describe">
<view class="username">{{ userInfo.user }}</view>
<view v-if="abnormalLengths" class="abnormal"
>存在异常 {{ abnormalLengths }}</view
>
</view>
<view class="describe">
<view class="number">
巡检编号:
<text class="value">{{ inspectionCode }}</text>
</view>
<view v-if="!!isSign" class="number">
巡检时间:
<text class="value">
{{ updateDate }}
</text>
</view>
</view>
</view>
</view>
<!-- v-if="allIsSubmitOne" -->
<view class="profile-right">
<view
v-if="!isSign"
:disabled="!allIsSubmitOne"
:class="{
'record-button': true,
'disabled-btn': !allIsSubmitOne,
}"
@click="toSign"
>
巡检人签字
</view>
<div v-else style="display: flex">
<image
class="sign-img"
mode="aspectFit"
:src="detailsInfo.signImg"
@click="previewImage([detailsInfo.signImg], 0)"
></image>
<button
v-if="detailsInfo.synchronization != 1"
class="record-button"
@click="toSign"
>
重签
</button>
</div>
<template v-if="allIsSubmitOne">
<button
v-if="detailsInfo.synchronization != 1 && isSign"
class="inspection-button ml-10"
@click="onSyncData(true)"
>
数据同步
</button>
</template>
</view>
</view>
</view>
<view class="box" v-if="!isSign">
<view class="bar">
<view class="title">巡检进度</view>
<view class="dai">
待巡检
<text class="num">{{ listData.length - inspectionNumber }}</text>
个机房
</view>
<view class="yi">
已完成
<text class="num">{{ inspectionNumber }}</text>
个机房
</view>
</view>
</view>
<view v-if="!isSign" class="card-box">
<view
class="card-row"
:class="{ right: rowIndex % 2 !== 0 }"
v-for="(row, rowIndex) in rows"
:key="rowIndex"
>
<view
class="card-wrapper"
v-for="(card, cardIndex) in row"
:key="cardIndex"
@click="startDialog(card.name, card.jfType, card.value, false)"
>
<view
class="card"
:class="{
status1: card.status == 1,
status2: card.status == 2,
active: value === card.value,
}"
>
<view class="card-content">
<view class="first-row">
<template v-if="card.isSubmit == 0">
<text class="iconfont icon-weixunjian"></text>
</template>
<template v-else>
<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>
</template>
<text class="status" v-if="card.isSubmit == 0">草稿</text>
<text class="status" v-else>{{ card.statusLable }}</text>
</view>
<view class="second-row">
<text class="location">{{ card.name }}</text>
</view>
</view>
<view class="spacer-image right" v-if="cardIndex < row.length - 1">
<image
v-if="inspectionNumber == 11"
class="img"
src="@/static/img/arr2.svg"
mode="aspectFit"
></image>
<image
v-else
class="img"
src="@/static/img/arr1.svg"
mode="aspectFit"
></image>
</view>
<view class="spacer-image bottom" v-if="rowIndex < rows.length - 1">
<view
v-if="
(rowIndex == 1 && cardIndex == 0) ||
(rowIndex == 0 && cardIndex == 4)
"
>
<image
v-if="inspectionNumber == 11"
class="img"
src="@/static/img/arr2.svg"
mode="aspectFit"
></image>
<image
v-else
class="img"
src="@/static/img/arr1.svg"
mode="aspectFit"
></image>
</view>
</view>
</view>
</view>
</view>
</view>
<view v-else class="card-box detail">
<view
class="card-row"
:class="{ right: rowIndex % 2 !== 0 }"
v-for="(row, rowIndex) in rows"
:key="rowIndex"
>
<view
class="card-wrapper"
v-for="(card, cardIndex) in row"
:key="cardIndex"
@click="getDetailsItem(card.name, card.jfType, card.value)"
>
<view
class="card"
:class="{
active: value === card.value,
warning: card.statusLable == '巡检异常',
}"
>
<view class="card-content">
<view class="first-row">
<image
class="icon"
src="@/static/img/add-img/home1.png"
></image>
<text class="status">{{ card.statusLable }}</text>
</view>
<view class="second-row">
<text class="location">{{ card.name }}</text>
</view>
</view>
</view>
</view>
</view>
<detail ref="detail" :jfType="jfType" :detailsItem="detailsItem"></detail>
</view>
<view v-if="!isSign" class="submit-module">
<view class="action-btn" @click="startDialogBtn()">开始巡检</view>
</view>
<signDialog ref="signDialog" @confirm="handlePopupConfirm"></signDialog>
<!-- 巡检弹窗 -->
<startDialog
ref="startDialog"
:startDialogData="startDialogData"
@confirm="handleStartDialog"
></startDialog>
<Dialog
v-show="isDialog"
:list="propList"
@close="onSyncData(false)"
></Dialog>
</view>
</template>
<script>
import moment from "moment";
import {
writeInspectionData,
addLog,
getLogContent,
LOG_TYPE_ENUM,
} from "@/utils/IoReadingAndWriting.js";
import signDialog from "@/components/signDialog.vue";
import detail from "./components/detail.vue";
import startDialog from "./components/dialog.vue";
import assRoomApi from "@/api/assRoom.js";
import inspectApi from "@/api/inspect";
import { sqlToData, dataToSql, getHistoryData } from "./shared";
import Dialog from "@/pages/inspectionManagement/dialog.vue";
export default {
components: {
signDialog,
detail,
startDialog,
Dialog,
},
data() {
return {
inspectionCode: "",
rows: [],
baseInfo: {}, // 基础信息
inspectionNumber: 0, // 已巡检的井道数量
detailsInfo: {}, // 详情
detailsItem: {},
isDisable: false, // 禁用
isSign: false, //签名状态
isSubmit: 0, //提交状态
uid: "",
options: {}, //存储数据
backValue: "",
all_data: [], //所有数据
jfType: "0", //机房类型
allIsSubmitOne: false,
startDialogData: {
text: [],
isList: true,
isLast: false,
}, //弹窗文案
name: "F座3楼-内环屏蔽机房",
value: "1",
listData: [],
isDialog: false,
propList: [],
did: "", // 最近7天数据的id
};
},
computed: {
userInfo() {
return this.$store.state.now_user || {};
},
updateDate() {
return moment(
Number(this.detailsInfo.updateTime || this.detailsInfo.createTime)
).format("YYYY-MM-DD");
},
abnormalLengths() {
const originData = this.detailsInfo?.originData;
let ret = 0;
(originData || []).forEach((jf) => {
const details = jf.details || {};
Object.keys(details).forEach((key) => {
const item = details[key];
console.log("x", key, item);
(item.detail || []).forEach((current) => {
if (current.inspectionResult === 1) {
ret++;
}
});
});
});
console.log("ret", ret);
return ret;
},
},
onLoad(options) {
this.options = options;
this.backValue = this.options.backValue || "";
this.isDisable = options.isDisable == 1 ? true : false;
this.uid = this.options.uid || "";
this.value = this.options.value || "1";
},
onShow() {
// 已经签名不触发更新,主要用于图片预览关闭后会触发onShow
if (!this.isSign) {
if (this.uid) {
this.getRoomList().then((res) => {
this.init(res).then(() => {
this.getDetails(this.uid);
});
});
} else {
this.getRoomList().then((res) => {
// 获取7日(168小时)内最后一条巡检记录回显到页面(选项、文案、照片;异常项-不调出文案及照片)
getHistoryData().then((detailsInfo) => {
if (detailsInfo) {
// 处理历史数据(选项、文案、照片;异常项-不调出文案及照片)
console.log("detailsInfo", detailsInfo);
this.did = detailsInfo.id;
delete detailsInfo.id;
delete detailsInfo.inspectionCode;
this.listData = this.listFormat(detailsInfo.originData);
this.detailsInfo = detailsInfo;
this.inspectionNumber = detailsInfo.inspectionNumber;
this.inspectionCode = `JFXJ${moment().format("yyyyMMDDHHmmss")}${
Math.floor(Math.random() * 900) + 100
}`;
this.cardsInfo = detailsInfo.originData;
this.isSubmit = 0;
this.isSign = false;
// 默认选中第一个机房
this.detailsItem = detailsInfo.originData[0].details;
if (
this.detailsItem.afxt &&
this.detailsItem.afxt.detail &&
this.detailsItem.afxt.detail[2].inspectionResult === 1
) {
this.detailsItem.afxt.detail =
this.detailsItem.afxt.detail.slice(0, 3);
}
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];
this.detailsInfo = detailsInfo;
} else {
this.init(res);
}
});
});
}
}
// this.startDialogData.text = [
// `请到“${this.name}”后;`,
// "点击“我已到达”开始巡检",
// ];
console.log("this.startDialogData", this.startDialogData);
this.all_data = this.$store.state.all_data;
},
methods: {
getRoomList() {
return assRoomApi.selectRoomList(1).then((res) => {
console.log("机房列表", res);
return res;
});
},
listFormat(baseList) {
const roomFeatureMap = {
1: "1",
2: "0",
3: "2",
};
let list = baseList.map((item, index) => {
const jfType = roomFeatureMap[item.roomFeature];
return {
id: item.id,
name: item.roomName,
value: item.dictValue,
/** 只是为了映射jfType,为了兼容之前的逻辑
* 前端用的:jfType 机房类型 0屏蔽  1汇聚  2电池间(1) 3电池间(2)
* roomFeature 机房类型枚举:1.汇聚机房,2.屏蔽机房,3.UPS机房,4.数据机房
*/
jfType: item.dictValue == "11" ? "3" : jfType,
isVaild: item.isVaild || false, // 校验通过
status: item.status || 0,
statusLable: item.statusLable || "未巡检",
};
});
return list;
},
init(baseList) {
this.value = baseList[0].dictValue;
return new Promise((resolve, reject) => {
let list = this.listFormat(baseList);
this.listData = this.deepClone(list);
console.log("this.listData", this.listData);
const group1 = list.slice(0, 5);
const group2 = list.slice(5, 10).reverse();
const group3 = list.slice(10);
this.rows = [group1, group2, group3];
if (this.uid) {
this.inspectionCode = this.detailsInfo.inspectionCode;
} else {
this.inspectionCode = `JFXJ${moment().format("yyyyMMDDHHmmss")}${
Math.floor(Math.random() * 900) + 100
}`;
}
resolve();
});
},
deepClone(target) {
if (typeof target !== "object" || target === null) {
return target;
}
let clone;
if (Array.isArray(target)) {
clone = [];
for (let i = 0; i < target.length; i++) {
clone[i] = this.deepClone(target[i]);
}
} else {
clone = {};
for (const key in target) {
if (target.hasOwnProperty(key)) {
clone[key] = this.deepClone(target[key]);
}
}
}
return clone;
},
// 回显数据
getDetails(uid) {
uni.showLoading();
return inspectApi
.info(uid)
.then((res) => {
console.log("before sqlToData", res);
const detailsInfo = sqlToData(res);
console.log("getDetails", detailsInfo);
this.listData = this.listFormat(detailsInfo.originData);
this.detailsInfo = detailsInfo;
this.inspectionNumber = detailsInfo.inspectionNumber;
this.inspectionCode = detailsInfo.inspectionCode;
this.cardsInfo = detailsInfo.originData;
this.isSubmit = this.detailsInfo.isSubmit;
this.isSign = this.detailsInfo.isSign;
// 默认选中第一个机房
this.detailsItem = detailsInfo.originData[0].details;
if (
this.detailsItem.afxt &&
this.detailsItem.afxt.detail &&
this.detailsItem.afxt.detail[2].inspectionResult === 1
) {
this.detailsItem.afxt.detail = this.detailsItem.afxt.detail.slice(
0,
3
);
}
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);
this.isDisable = this.isDisable || detailsInfo.synchronization == 1; // 是否禁用 1:已同步数据 0: 未同步数据
uni.hideLoading();
})
.catch((error) => {
uni.showToast({
title: error.msg,
icon: "none",
duration: 1000,
});
uni.hideLoading();
});
},
// 获取机房详情
getDetailsItem(location, jfType, value) {
this.activeName = location;
this.value = value;
this.detailsItem = this.detailsInfo.originData[value - 1].details;
this.jfType = this.detailsInfo.originData[value - 1].jfType;
if (this.detailsItem.afxt.detail[2].inspectionResult === 1) {
this.detailsItem.afxt.detail = this.detailsItem.afxt.detail.slice(0, 3);
}
console.log("this.detailsItem", this.detailsItem);
},
startDialogBtn(name = "F座3楼-内环屏蔽机房", jfType = "0", value = "1") {
let item = this.findTargetObject(this.listData);
console.log("即将操作的机房", item);
this.name = this.uid ? item.name : name;
this.jfType = this.uid ? item.jfType : jfType;
this.value = this.uid ? item.value : value;
this.startDialogData.text = [
`请到“${name}”后;`,
"点击“我已到达”开始巡检",
];
this.name = name;
this.jfType = jfType;
this.value = value;
this.$refs.startDialog.open();
},
startDialog(name = "F座3楼-内环屏蔽机房", jfType = "0", value = "1") {
this.name = name;
this.jfType = jfType;
this.value = value;
if (!this.uid && value != "1") {
this.startDialogData.text = [
`当前线路非常用巡检线路,`,
`是否需要从“${this.name}”开始巡检`,
];
} else {
this.startDialogData.text = [
`请到“${this.name}”后;`,
"点击“我已到达”开始巡检",
];
}
this.$refs.startDialog.open();
},
// 处理弹窗确认
handleStartDialog(summary) {
this.toShaftInspection(this.name, this.jfType, this.value);
},
// 跳转到具体的机房
toShaftInspection(name, jfType, value) {
console.log("name, 跳转到具体的机房, value", name, jfType, value);
uni.navigateTo({
url: `/pages/inspectionContent/inspectionContentNew?value=${value}&inspectionCode=${this.inspectionCode}&jfType=${jfType}&location=${name}&uid=${this.uid}&backValue=${this.backValue}&did=${this.did}`,
});
},
lookTable() {
uni.navigateTo({
url: "/pages/report/sampleTable?isJF=1",
});
},
toSign() {
if(!this.allIsSubmitOne) {
return;
}
this.$refs.signDialog.open();
},
findTargetObject(rows) {
if (!rows || rows.length === 0) return null;
let lastNonZeroIndex = -1;
// 首先检查所有对象,记录最后一个 status 不为 0 的索引
for (let i = 0; i < rows.length; i++) {
if (rows[i].status !== 0) {
lastNonZeroIndex = i;
}
}
// 如果没有找到任何 status 不为 0 的对象,返回 null
if (lastNonZeroIndex === -1) return null;
// 计算目标对象的索引
let targetIndex = lastNonZeroIndex + 1;
// 如果最后一个非零对象是数组的最后一个元素,则从第一个对象开始检查
if (lastNonZeroIndex === rows.length - 1) {
for (let i = 0; i < rows.length; i++) {
if (rows[i].status !== 0) {
targetIndex = i + 1;
break; // 找到第一个就停止
}
}
// 如果 targetIndex 超出数组范围,则返回 null
return targetIndex < rows.length ? rows[targetIndex] : null;
}
// 正常情况:返回最后一个非零对象的下一个对象
return rows[targetIndex];
},
// 处理弹窗确认
handlePopupConfirm(signImg) {
this.detailsInfo.isSign = this.isSign = true; // 回显到文字显示区域
this.detailsInfo.signImg = signImg; // 回显到文字显示区域
this.detailsInfo.isSubmit = 1; // 提交状态
const isException = this.detailsInfo.originData.some(
(item) => item.status == 2
);
this.detailsInfo.isException = isException ? 1 : 0; // 巡检异常
let allIsSubmitOne = this.detailsInfo.originData.every(
(item) => item.isSubmit === 1
);
if (!allIsSubmitOne) {
// 如果有机房没有巡检完,记录是编辑状态
this.detailsInfo.synchronization = 2;
} else {
this.detailsInfo.synchronization = 0;
}
this.realSave(this.detailsInfo);
},
realSave(params, type = "sign") {
const send = dataToSql(params);
const api = this.uid ? inspectApi.update : inspectApi.save;
const inspectionCode =
this.inspectionCode ||
`JFXJ${moment().format("yyyyMMDDHHmmss")}${
Math.floor(Math.random() * 900) + 100
}`;
send.inspectionCode = inspectionCode;
console.log("send", send);
api(this.uid ? { id: this.uid, ...send } : send).then((res) => {
const logContent = getLogContent(
LOG_TYPE_ENUM.sys,
`巡检编号(${inspectionCode})`,
"同步"
);
this.$logApi.addlog(logContent);
console.log("logContent", logContent);
uni.showToast({
title: type == "sign" ? "签字成功" : "同步成功",
icon: "success",
});
if (!this.uid) {
this.uid = res.lastInsertId;
setTimeout(() => {
this.getDetails(res.lastInsertId);
}, 300);
}
});
},
back() {
if (this.backValue === "home") {
uni.navigateTo({
url: "/pages/home/home",
});
} else {
uni.navigateTo({
url: `/pages/inspectionManagement/index`,
});
}
},
previewImage(images, index) {
uni.previewImage({
current: index,
urls: images,
success: (res) => {},
});
},
onSyncData(show) {
this.isDialog = show;
this.propList = [
{
...dataToSql(this.detailsInfo),
id: this.uid,
},
];
console.log("propList", this.propList);
if (!show) {
this.getDetails(this.uid);
}
},
},
};
</script>
<style lang="less" scoped>
.uni-nav-bar-text {
height: 28.8px;
width: 28.8px;
background: #ffffff;
border: 0.32px solid rgba(224, 224, 224, 1);
border-radius: 14.4px;
color: #333;
text-align: center;
.iconfont {
font-size: 16px;
line-height: 28.8px;
}
}
.nav-right {
width: 192px;
z-index: 10;
}
.header-buttons {
display: flex;
align-items: center;
margin-left: auto;
.button {
width: 89.6px;
height: 28.8px;
background: #ffffff;
border-radius: 14.4px;
margin-left: 12.8px;
font-family: PingFangSC-Regular;
font-size: 12.8px;
color: #000000;
line-height: 28.8px;
font-weight: 400;
text-align: center;
}
}
.container {
background-image: linear-gradient(115deg, #e8f0fb 0%, #e1ebfa 100%);
padding: 0 25.6px;
height: 100vh;
}
.profile-section {
width: 100%;
margin-bottom: 12.8px;
.profile-box {
background-color: #fff;
border-radius: 9.6px;
padding: 12.8px 25.6px;
display: flex;
justify-content: space-between;
align-items: center;
.profile-left {
display: flex;
align-items: center;
.avatar {
position: relative;
width: 68.8px;
height: 68.8px;
margin-right: 9.6px;
border-radius: 50%;
overflow: hidden;
image {
width: 100%;
height: 100%;
}
.change-password {
position: absolute;
bottom: 0;
left: 0;
right: 0;
background-color: rgba(0, 0, 0, 0.5);
text-align: center;
height: 17.6px;
font-family: PingFangSC-Regular;
font-size: 9.6px;
color: #ffffff;
line-height: 16px;
font-weight: 400;
}
}
.info {
.username {
font-size: 16px;
color: #000000;
line-height: 22.4px;
font-weight: 500;
margin-bottom: 7.2px;
margin-right: 10px;
}
.number {
font-size: 12.8px;
color: #4a4a4a;
line-height: 22.4px;
font-weight: 400;
margin-right: 9.6px;
.value {
color: #000000;
}
}
.describe {
display: flex;
.abnormal {
color: #fff;
line-height: 22.4px;
height: 22.4px;
padding: 0 8px;
font-size: 12px;
background-color: #f55a42;
border-radius: 11px;
}
}
}
}
.profile-right {
display: flex;
.inspection-button {
width: 89.6px;
height: 28.8px;
background-image: linear-gradient(105deg, #68acfb 0%, #3774f6 100%);
border-radius: 14.4px;
font-family: PingFangSC-Regular;
font-size: 12.8px;
color: #ffffff;
line-height: 28.8px;
font-weight: 400;
margin-right: 12.8px;
}
.record-button {
display: block;
width: 115.2px;
height: 28.8px;
background: #ffffff;
border: 0.8px solid rgba(55, 116, 246, 1);
border-radius: 14.4px;
font-family: PingFangSC-Regular;
font-size: 12.8px;
color: #3774f6;
line-height: 28.8px;
font-weight: 400;
display: flex;
justify-content: center;
&.disabled-btn {
color: #c7c7c7;
background-color: #f9f9f9;
border-color: #f2f2f2;
}
}
}
}
}
.box {
background: #ffffff;
border-radius: 9.6px 9.6px 0 0;
padding: 12.8px 19.2px;
.bar {
display: flex;
justify-content: flex-start;
.title {
font-family: PingFangSC-Medium;
font-size: 14.4px;
color: #000000;
line-height: 27.2px;
font-weight: 500;
}
.dai {
background: rgba(243, 152, 0, 0.08);
border-radius: 8px;
font-family: PingFangSC-Regular;
font-size: 11.2px;
color: #4a4a4a;
letter-spacing: 0;
text-align: right;
line-height: 27.2px;
font-weight: 400;
margin: 0 9.6px;
padding: 0 9.6px;
.num {
color: #f39800;
}
}
.yi {
background: rgba(55, 116, 246, 0.08);
border-radius: 8px;
font-family: PingFangSC-Regular;
font-size: 11.2px;
color: #4a4a4a;
letter-spacing: 0;
text-align: right;
line-height: 27.2px;
font-weight: 400;
padding: 0 9.6px;
.num {
color: #000;
}
}
}
}
.card-box {
background: #ffffff;
border-radius: 0 0 9.6px 9.6px;
padding: 12.8px 19.2px;
height: calc(100vh - 232px - 19.2px);
&.detail {
height: calc(100vh - 200px);
border-radius: 9.6px;
overflow: auto;
.card-wrapper {
width: calc((100% - 4 * 12.8px) / 5); /* 严格五等分宽度 */
.card {
margin-bottom: 12.8px;
}
}
}
}
.card-row {
display: flex;
justify-content: space-between;
align-items: center;
position: relative;
width: 100%;
.card-wrapper {
width: calc((100% - 4 * 43.2px) / 5); /* 严格五等分宽度 */
.card {
height: 51.2px;
margin-bottom: 43.2px;
border-radius: 8px;
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);
}
&.warning {
background: #fff5f4;
&.active {
border: 1px solid #ff4a34;
}
.status {
color: #ff4a34 !important;
}
}
&.status1 {
background: #f3f7ff;
.status {
color: #3774f6;
}
}
&.status2 {
background: #fff5f4;
.status {
color: #f55a42;
}
}
.card-content {
padding: 6.4px;
.first-row {
display: flex;
align-items: center;
.iconfont {
font-size: 12px;
margin-right: 6.4px;
&.icon-weixunjian {
color: #959595;
}
&.icon-shibai1 {
color: #ff4a34;
}
&.icon-wancheng {
color: #3774f6;
}
}
.status {
font-size: 12px;
color: #333333;
}
}
.second-row {
margin-top: 3.2px;
padding-left: 20px;
.location {
font-size: 12px;
color: #666666;
}
}
}
}
.spacer-image.right {
position: absolute;
right: -43.2px;
top: 50%;
transform: translateY(-50%);
.img {
width: 30.4px;
height: 6.4px;
margin: 0 6.4px;
}
}
}
.spacer-image.bottom {
position: absolute;
bottom: -33.6px;
left: 50%;
transform: translateX(-50%) rotate(90deg);
.img {
width: 30.4px;
height: 6.4px;
margin: 6.4px 0;
}
}
&.right {
.card-wrapper {
.spacer-image.right {
position: absolute;
left: -43.2px;
top: 50%;
transform: translateY(-50%) rotate(180deg);
.img {
width: 30.4px;
height: 6.4px;
margin: 0 6.4px;
}
}
}
}
}
.submit-module {
display: flex;
justify-content: center;
position: fixed;
gap: 16px;
left: 50%;
transform: translateX(-50%);
bottom: 25.6px;
.action-btn {
width: 145.6px;
height: 38.4px;
line-height: 38.4px;
background-image: linear-gradient(180deg, #3773f6 0%, #2c57f6 99%);
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: #fff;
text-align: center;
font-weight: 400;
&.complete-btn {
background-image: linear-gradient(180deg, #3773f6 0%, #2c57f6 99%);
color: #ffffff;
}
}
}
.sign-img {
width: 80px;
height: 28.8px;
margin-right: 10px;
border: 1px solid #c5c5c5;
&.no-border {
border: none;
}
}
</style>
......@@ -48,70 +48,50 @@
></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 || {}"
<!-- 空调系统 -->
<monthKtxt
v-show="checkValueInArray(tabs, 'monthKtxt', activeTab)"
ref="monthKtxt"
inspectionItem="空调系统"
:defaultData="list.monthKtxt"
></monthKtxt>
<!-- UPS系统 -->
<monthUpsxt
v-show="checkValueInArray(tabs, 'monthUpsxt', activeTab)"
ref="monthUpsxt"
inspectionItem="UPS系统"
:defaultData="list.monthUpsxt || {}"
></monthUpsxt>
<!-- 供配电系统 -->
<monthGpdxt
v-show="checkValueInArray(tabs, 'monthGpdxt', activeTab)"
ref="monthGpdxt"
inspectionItem="供配电系统"
:defaultData="list.monthGpdxt || {}"
></monthGpdxt>
<!-- 照明系统 -->
<monthZmxt
v-show="checkValueInArray(tabs, 'monthZmxt', activeTab)"
ref="monthZmxt"
inspectionItem="照明系统"
:defaultData="list.monthZmxt || {}"
: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>
></monthZmxt>
<!-- 防雷接地系统 -->
<monthFljdxt
v-show="checkValueInArray(tabs, 'monthFljdxt', activeTab)"
ref="monthFljdxt"
inspectionItem="防雷接地系统"
:defaultData="list.monthFljdxt || {}"
></monthFljdxt>
<!-- 屏蔽系统 -->
<monthPbxt
v-show="checkValueInArray(tabs, 'monthPbxt', activeTab)"
ref="monthPbxt"
inspectionItem="屏蔽系统"
:defaultData="list.monthPbxt || {}"
></monthPbxt>
</view>
</view>
</view>
......@@ -142,11 +122,7 @@ import assRoomApi from "@/api/assRoom.js";
import inspectApi from "@/api/inspect.js";
import { dataToSql, sqlToData, getHistoryData } from "./shared";
import {
pad_all_inspection_position,
tabsInfo1,
tabsInfo2,
} from "@/utils/dict.js"; //巡检位置,A座到F座 楼层2楼4楼到26楼
import { tabsInfoMonth } from "@/utils/dict.js"; //巡检位置,A座到F座 楼层2楼4楼到26楼
import {
addLog,
getLogContent,
......@@ -157,28 +133,22 @@ import {
import { getInspectionDetails } from "@/request/index.js";
import moment from "moment";
import _ from "lodash";
import wlhj from "./components/wlhj.vue"; //物理环境
import afxt from "./components/afxt.vue"; //安防系统
import sbgj from "./components/sbgj.vue"; //设备告警
import dczt from "./components/dczt.vue"; //电池状态
import jfwsd from "./components/jfwsd.vue"; //机房温湿度
import dlxt from "./components/dlxt.vue"; //电力系统
import xfxt from "./components/xfxt.vue"; //消防系统
import xlqk from "./components/xlqk.vue"; //线路情况
import qt from "./components/qt.vue"; //其它
import monthKtxt from "./components/monthKtxt.vue"; //空调系统
import monthUpsxt from "./components/monthUpsxt.vue"; //UPS系统
import monthGpdxt from "./components/monthGpdxt.vue"; //供配电系统
import monthZmxt from "./components/monthZmxt.vue"; //照明系统
import monthFljdxt from "./components/monthFljdxt.vue"; //防雷接地系统
import monthPbxt from "./components/monthPbxt.vue"; //屏蔽系统
import startDialog from "./components/dialog.vue";
export default {
components: {
wlhj,
afxt,
sbgj,
dczt,
jfwsd,
dlxt,
xfxt,
xlqk,
qt,
monthKtxt,
monthUpsxt,
monthGpdxt,
monthZmxt,
monthFljdxt,
monthPbxt,
startDialog,
},
data() {
......@@ -218,6 +188,7 @@ export default {
// 我新增的
jfList: [],
did: "",
inspectionType: "3",
};
},
computed: {
......@@ -249,10 +220,7 @@ export default {
this.backValue = options.backValue || "";
this.imgSrc = `../../static/img/jf/jf${this.value}.png`;
this.tabs =
this.jfType === "2" || this.jfType === "3"
? this.deepClone(tabsInfo2)
: this.deepClone(tabsInfo1);
this.tabs = this.deepClone(tabsInfoMonth);
console.log("机房查看options", options);
this.all_data = this.$store.state.all_data || [];
......@@ -263,18 +231,18 @@ export default {
this.init();
this.paramsObjFirst = this.getAllChildFormData();
// 临时id
getHistoryData().then((detailsInfo) => {
getHistoryData(this.inspectionType).then((detailsInfo) => {
console.log("history", detailsInfo);
if (detailsInfo) {
delete detailsInfo.id;
delete detailsInfo.inspectionCode
delete detailsInfo.inspectionCode;
// 处理历史数据(选项、文案、照片;异常项-不调出文案及照片)
this.list = detailsInfo.originData[this.value - 1].details;
this.inspectionNumber = detailsInfo.inspectionNumber;
this.inspectionCode = `JFXJ${moment().format("yyyyMMDDHHmmss")}${
this.inspectionCode = `YDXJ${moment().format("yyyyMMDDHHmmss")}${
Math.floor(Math.random() * 900) + 100
}`;
......@@ -319,9 +287,9 @@ export default {
// 判断是否有回显数据
// 基础数据
this.baseInfo = {
inspectionType: "1",
inspectionType: "3",
inspectionCode: this.inspectionCode,
recordName: `${moment().format("yyyyMMDD")}-机房巡检`,
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,
......@@ -401,11 +369,11 @@ export default {
}
// 使用 filter 方法筛选出 status 为 1 或 2 的对象
const inspectedItems = this.detailsInfo.originData.filter(
(item) => item.status === 1 || item.status === 2
(item) => item.status === 1 || item.status === 2,
);
const isException = this.detailsInfo.originData.some(
(item) => item.status == 2
(item) => item.status == 2,
);
console.log("isException", isException);
......@@ -419,7 +387,7 @@ export default {
this.listData = this.detailsInfo.originData;
let allIsSubmitOne = this.detailsInfo.originData.every(
(item) => item.isSubmit === 1
(item) => item.isSubmit === 1,
);
if (!allIsSubmitOne) {
......@@ -482,7 +450,7 @@ export default {
* 得检测每个机房是否巡检完
*/
let allIsSubmitOne = data.originData.every(
(item) => item.isSubmit === 1
(item) => item.isSubmit === 1,
);
if (!allIsSubmitOne) {
// 如果有机房没有巡检完,记录是编辑状态
......@@ -533,7 +501,7 @@ export default {
{
notZeroCount: 0,
equalTwoCount: 0,
} // 初始化统计结果
}, // 初始化统计结果
);
},
typeSubmit(originData) {
......@@ -590,16 +558,19 @@ export default {
console.log("提交时获取一次", params);
this.all_data = this.$store.state.all_data || [];
params.inspectionCode = this.inspectionCode || `JFXJ${moment().format("yyyyMMDDHHmmss")}${
params.inspectionCode =
this.inspectionCode ||
`YDXJ${moment().format("yyyyMMDDHHmmss")}${
Math.floor(Math.random() * 900) + 100
}`
}`;
params.inspectionType = this.inspectionType;
this.realSave(params).then(() => {
let logContent = "";
console.log("all_data", this.all_data);
if (this.uid) {
const index = this.all_data.findIndex(
(element) => element.uid == this.uid
(element) => element.uid == this.uid,
);
params.uid = this.uid;
......@@ -607,14 +578,14 @@ export default {
logContent = getLogContent(
LOG_TYPE_ENUM.edit,
`巡检编号(${params.inspectionCode})`,
"巡检模块"
"巡检模块",
);
} else {
this.all_data.push(params);
logContent = getLogContent(
LOG_TYPE_ENUM.add,
`巡检编号(${params.inspectionCode})`,
"巡检模块"
"巡检模块",
);
}
// 更新巡检list
......@@ -622,7 +593,7 @@ export default {
console.log("all_data存储", this.all_data);
this.$store.commit("SET_ALL_DATA", this.all_data);
const inspectList = this.all_data.filter(
(item) => item.createByName == userInfo.user
(item) => item.createByName == userInfo.user,
);
console.log("inspectList", inspectList);
......@@ -631,7 +602,7 @@ export default {
// 更新日志
const log_list = this.$store.state.log_list;
logContent.inspectionType = params.inspectionType;
this.$logApi.addlog(logContent)
this.$logApi.addlog(logContent);
console.log("logContent", logContent);
log_list.push(logContent);
......@@ -660,7 +631,7 @@ export default {
// let item = this.findTargetObject(this.listData);
const item = this.listData.find(
(item) => !item.status || item.isSubmit == 0
(item) => !item.status || item.isSubmit == 0,
);
console.log("即将操作的机房", item);
......@@ -685,7 +656,7 @@ export default {
handleStartDialog() {
console.log("跳转前", this.uid);
uni.navigateTo({
url: `/pages/inspectionContent/inspectionContentNew?value=${this.value}&inspectionCode=${this.inspectionCode}&jfType=${this.jfType}&location=${this.name}&uid=${this.uid}&backValue=${this.backValue}`,
url: `/pages/inspectionContent/inspectionContentMonthlyNew?value=${this.value}&inspectionCode=${this.inspectionCode}&jfType=${this.jfType}&location=${this.name}&uid=${this.uid}&backValue=${this.backValue}`,
});
},
findTargetObject(rows) {
......@@ -765,7 +736,7 @@ export default {
const validateData = (data) => {
return data.every(
(item) =>
item.inspectionResult !== null && item.conclusion.trim() !== ""
item.inspectionResult !== null && item.conclusion.trim() !== "",
);
};
// 调用校验函数
......@@ -825,7 +796,7 @@ export default {
// 返回
back() {
uni.navigateTo({
url: `/pages/inspectionContent/inspectionContentList?uid=${this.uid}&backValue=${this.backValue}&value=${this.value}`,
url: `/pages/inspectionContent/inspectionContentList?uid=${this.uid}&backValue=${this.backValue}&value=${this.value}&inspectionType=3`,
});
},
// 关闭弹窗
......
......@@ -15,7 +15,7 @@
</uni-nav-bar>
<!-- Tab 操作区域 -->
<view class="module">
<view class="location">{{ location }}</view>
<view class="location">{{ location }} {{ inspectionCode }}</view>
<scroll-view
scroll-x
......@@ -301,7 +301,7 @@ export default {
jfList: [],
did: "",
scrollLeft: 0, // 横向滚动位置
patrolType: "JFXJ", // 巡检类型
inspectionType: "1",
};
},
computed: {
......@@ -347,7 +347,7 @@ export default {
this.init();
this.paramsObjFirst = this.getAllChildFormData();
// 临时id
getHistoryData().then((detailsInfo) => {
getHistoryData(this.inspectionType).then((detailsInfo) => {
console.log("history", detailsInfo);
if (detailsInfo) {
......@@ -358,7 +358,7 @@ export default {
this.list = detailsInfo.originData[this.value - 1].details;
this.inspectionNumber = detailsInfo.inspectionNumber;
this.inspectionCode = `${this.patrolType}${moment().format("yyyyMMDDHHmmss")}${
this.inspectionCode = `JFXJ${moment().format("yyyyMMDDHHmmss")}${
Math.floor(Math.random() * 900) + 100
}`;
......@@ -405,7 +405,7 @@ export default {
this.baseInfo = {
inspectionType: "1",
inspectionCode: this.inspectionCode,
recordName: `${moment().format("yyyyMMDD")}-机房巡检`,
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,
......@@ -676,9 +676,10 @@ export default {
params.inspectionCode =
this.inspectionCode ||
`${this.patrolType}${moment().format("yyyyMMDDHHmmss")}${
`JFXJ${moment().format("yyyyMMDDHHmmss")}${
Math.floor(Math.random() * 900) + 100
}`;
params.inspectionType = this.inspectionType;
this.realSave(params).then(() => {
let logContent = "";
......
<template>
<view class="container">
<uni-nav-bar
:fixed="true"
background-color="rgba(214, 240, 255, 0.0)"
status-bar
rightWidth="240"
>
<block slot="left">
<view class="" @click="back">
<text class="iconfont icon-fanhui"></text>
</view>
</block>
<block slot="right" class="nav-right">
<view class="header-buttons">
<view class="button" @click="lookTable">查看样表</view>
</view>
</block>
</uni-nav-bar>
<view class="profile-section">
<view class="profile-box">
<view class="profile-left">
<view class="avatar">
<image
src="@/static/img/add-img/defaultAvatar.png"
mode="aspectFit"
></image>
</view>
<view class="info">
<view class="describe">
<view class="username">{{ userInfo.user }}</view>
<view v-if="abnormalLengths" class="abnormal"
>存在异常 {{ abnormalLengths }}</view
>
</view>
<view class="describe">
<view class="number">
巡检编号:
<text class="value">{{ inspectionCode }}</text>
</view>
<view v-if="!!isSign" class="number">
巡检时间:
<text class="value">
{{ updateDate }}
</text>
</view>
</view>
</view>
</view>
<!-- v-if="allIsSubmitOne" -->
<view class="profile-right">
<view
v-if="!isSign"
:disabled="!allIsSubmitOne"
:class="{
'record-button': true,
'disabled-btn': !allIsSubmitOne,
}"
@click="toSign"
>
巡检人签字
</view>
<div v-else style="display: flex">
<image
class="sign-img"
mode="aspectFit"
:src="detailsInfo.signImg"
@click="previewImage([detailsInfo.signImg], 0)"
></image>
<button
v-if="detailsInfo.synchronization != 1"
class="record-button"
@click="toSign"
>
重签
</button>
</div>
<template v-if="allIsSubmitOne">
<button
v-if="detailsInfo.synchronization != 1 && isSign"
class="inspection-button ml-10"
@click="onSyncData(true)"
>
数据同步
</button>
</template>
</view>
</view>
</view>
<view class="box" v-if="!isSign">
<view class="bar">
<view class="title">巡检进度</view>
<view class="dai">
待巡检
<text class="num">{{ listData.length - inspectionNumber }}</text>
个机房
</view>
<view class="yi">
已完成
<text class="num">{{ inspectionNumber }}</text>
个机房
</view>
</view>
</view>
<view v-if="!isSign" class="card-box">
<view
class="card-row"
:class="{ right: rowIndex % 2 !== 0 }"
v-for="(row, rowIndex) in rows"
:key="rowIndex"
>
<view
class="card-wrapper"
v-for="(card, cardIndex) in row"
:key="cardIndex"
@click="startDialog(card.name, card.jfType, card.value, false)"
>
<view
class="card"
:class="{
status1: card.status == 1,
status2: card.status == 2,
active: value === card.value,
}"
>
<view class="card-content">
<view class="first-row">
<template v-if="card.isSubmit == 0">
<text class="iconfont icon-weixunjian"></text>
</template>
<template v-else>
<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>
</template>
<text class="status" v-if="card.isSubmit == 0">草稿</text>
<text class="status" v-else>{{ card.statusLable }}</text>
</view>
<view class="second-row">
<text class="location">{{ card.name }}</text>
</view>
</view>
<view class="spacer-image right" v-if="cardIndex < row.length - 1">
<image
v-if="inspectionNumber == 11"
class="img"
src="@/static/img/arr2.svg"
mode="aspectFit"
></image>
<image
v-else
class="img"
src="@/static/img/arr1.svg"
mode="aspectFit"
></image>
</view>
<view class="spacer-image bottom" v-if="rowIndex < rows.length - 1">
<view
v-if="
(rowIndex == 1 && cardIndex == 0) ||
(rowIndex == 0 && cardIndex == 4)
"
>
<image
v-if="inspectionNumber == 11"
class="img"
src="@/static/img/arr2.svg"
mode="aspectFit"
></image>
<image
v-else
class="img"
src="@/static/img/arr1.svg"
mode="aspectFit"
></image>
</view>
</view>
</view>
</view>
</view>
</view>
<view v-else class="card-box detail">
<view
class="card-row"
:class="{ right: rowIndex % 2 !== 0 }"
v-for="(row, rowIndex) in rows"
:key="rowIndex"
>
<view
class="card-wrapper"
v-for="(card, cardIndex) in row"
:key="cardIndex"
@click="getDetailsItem(card.name, card.jfType, card.value)"
>
<view
class="card"
:class="{
active: value === card.value,
warning: card.statusLable == '巡检异常',
}"
>
<view class="card-content">
<view class="first-row">
<image
class="icon"
src="@/static/img/add-img/home1.png"
></image>
<text class="status">{{ card.statusLable }}</text>
</view>
<view class="second-row">
<text class="location">{{ card.name }}</text>
</view>
</view>
</view>
</view>
</view>
<detail ref="detail" :jfType="jfType" :detailsItem="detailsItem"></detail>
</view>
<view v-if="!isSign" class="submit-module">
<view class="action-btn" @click="startDialogBtn()">开始巡检</view>
</view>
<signDialog ref="signDialog" @confirm="handlePopupConfirm"></signDialog>
<!-- 巡检弹窗 -->
<startDialog
ref="startDialog"
:startDialogData="startDialogData"
@confirm="handleStartDialog"
></startDialog>
<Dialog
v-show="isDialog"
:list="propList"
@close="onSyncData(false)"
></Dialog>
</view>
</template>
<script>
import moment from "moment";
import {
writeInspectionData,
addLog,
getLogContent,
LOG_TYPE_ENUM,
} from "@/utils/IoReadingAndWriting.js";
import signDialog from "@/components/signDialog.vue";
import detail from "./components/detail.vue";
import startDialog from "./components/dialog.vue";
import assRoomApi from "@/api/assRoom.js";
import inspectApi from "@/api/inspect";
import { sqlToData, dataToSql, getHistoryData } from "./shared";
import Dialog from "@/pages/inspectionManagement/dialog.vue";
export default {
components: {
signDialog,
detail,
startDialog,
Dialog,
},
data() {
return {
inspectionCode: "",
rows: [],
baseInfo: {}, // 基础信息
inspectionNumber: 0, // 已巡检的井道数量
detailsInfo: {}, // 详情
detailsItem: {},
isDisable: false, // 禁用
isSign: false, //签名状态
isSubmit: 0, //提交状态
uid: "",
options: {}, //存储数据
backValue: "",
all_data: [], //所有数据
jfType: "0", //机房类型
allIsSubmitOne: false,
startDialogData: {
text: [],
isList: true,
isLast: false,
}, //弹窗文案
name: "F座3楼-内环屏蔽机房",
value: "1",
listData: [],
isDialog: false,
propList: [],
did: "", // 最近7天数据的id
};
},
computed: {
userInfo() {
return this.$store.state.now_user || {};
},
updateDate() {
return moment(
Number(this.detailsInfo.updateTime || this.detailsInfo.createTime)
).format("YYYY-MM-DD");
},
abnormalLengths() {
const originData = this.detailsInfo?.originData;
let ret = 0;
(originData || []).forEach((jf) => {
const details = jf.details || {};
Object.keys(details).forEach((key) => {
const item = details[key];
console.log("x", key, item);
(item.detail || []).forEach((current) => {
if (current.inspectionResult === 1) {
ret++;
}
});
});
});
console.log("ret", ret);
return ret;
},
},
onLoad(options) {
this.options = options;
this.backValue = this.options.backValue || "";
this.isDisable = options.isDisable == 1 ? true : false;
this.uid = this.options.uid || "";
this.value = this.options.value || "1";
},
onShow() {
// 已经签名不触发更新,主要用于图片预览关闭后会触发onShow
if (!this.isSign) {
if (this.uid) {
this.getRoomList().then((res) => {
this.init(res).then(() => {
this.getDetails(this.uid);
});
});
} else {
this.getRoomList().then((res) => {
// 获取7日(168小时)内最后一条巡检记录回显到页面(选项、文案、照片;异常项-不调出文案及照片)
getHistoryData().then((detailsInfo) => {
if (detailsInfo) {
// 处理历史数据(选项、文案、照片;异常项-不调出文案及照片)
console.log("detailsInfo", detailsInfo);
this.did = detailsInfo.id;
delete detailsInfo.id;
delete detailsInfo.inspectionCode;
this.listData = this.listFormat(detailsInfo.originData);
this.detailsInfo = detailsInfo;
this.inspectionNumber = detailsInfo.inspectionNumber;
this.inspectionCode = `JFXJ${moment().format("yyyyMMDDHHmmss")}${
Math.floor(Math.random() * 900) + 100
}`;
this.cardsInfo = detailsInfo.originData;
this.isSubmit = 0;
this.isSign = false;
// 默认选中第一个机房
this.detailsItem = detailsInfo.originData[0].details;
if (
this.detailsItem.afxt &&
this.detailsItem.afxt.detail &&
this.detailsItem.afxt.detail[2].inspectionResult === 1
) {
this.detailsItem.afxt.detail =
this.detailsItem.afxt.detail.slice(0, 3);
}
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];
this.detailsInfo = detailsInfo;
} else {
this.init(res);
}
});
});
}
}
// this.startDialogData.text = [
// `请到“${this.name}”后;`,
// "点击“我已到达”开始巡检",
// ];
console.log("this.startDialogData", this.startDialogData);
this.all_data = this.$store.state.all_data;
},
methods: {
getRoomList() {
return assRoomApi.selectRoomList(1).then((res) => {
console.log("机房列表", res);
return res;
});
},
listFormat(baseList) {
const roomFeatureMap = {
1: "1",
2: "0",
3: "2",
};
let list = baseList.map((item, index) => {
const jfType = roomFeatureMap[item.roomFeature];
return {
id: item.id,
name: item.roomName,
value: item.dictValue,
/** 只是为了映射jfType,为了兼容之前的逻辑
* 前端用的:jfType 机房类型 0屏蔽  1汇聚  2电池间(1) 3电池间(2)
* roomFeature 机房类型枚举:1.汇聚机房,2.屏蔽机房,3.UPS机房,4.数据机房
*/
jfType: item.dictValue == "11" ? "3" : jfType,
isVaild: item.isVaild || false, // 校验通过
status: item.status || 0,
statusLable: item.statusLable || "未巡检",
};
});
return list;
},
init(baseList) {
this.value = baseList[0].dictValue;
return new Promise((resolve, reject) => {
let list = this.listFormat(baseList);
this.listData = this.deepClone(list);
console.log("this.listData", this.listData);
const group1 = list.slice(0, 5);
const group2 = list.slice(5, 10).reverse();
const group3 = list.slice(10);
this.rows = [group1, group2, group3];
if (this.uid) {
this.inspectionCode = this.detailsInfo.inspectionCode;
} else {
this.inspectionCode = `JFXJ${moment().format("yyyyMMDDHHmmss")}${
Math.floor(Math.random() * 900) + 100
}`;
}
resolve();
});
},
deepClone(target) {
if (typeof target !== "object" || target === null) {
return target;
}
let clone;
if (Array.isArray(target)) {
clone = [];
for (let i = 0; i < target.length; i++) {
clone[i] = this.deepClone(target[i]);
}
} else {
clone = {};
for (const key in target) {
if (target.hasOwnProperty(key)) {
clone[key] = this.deepClone(target[key]);
}
}
}
return clone;
},
// 回显数据
getDetails(uid) {
uni.showLoading();
return inspectApi
.info(uid)
.then((res) => {
console.log("before sqlToData", res);
const detailsInfo = sqlToData(res);
console.log("getDetails", detailsInfo);
this.listData = this.listFormat(detailsInfo.originData);
this.detailsInfo = detailsInfo;
this.inspectionNumber = detailsInfo.inspectionNumber;
this.inspectionCode = detailsInfo.inspectionCode;
this.cardsInfo = detailsInfo.originData;
this.isSubmit = this.detailsInfo.isSubmit;
this.isSign = this.detailsInfo.isSign;
// 默认选中第一个机房
this.detailsItem = detailsInfo.originData[0].details;
if (
this.detailsItem.afxt &&
this.detailsItem.afxt.detail &&
this.detailsItem.afxt.detail[2].inspectionResult === 1
) {
this.detailsItem.afxt.detail = this.detailsItem.afxt.detail.slice(
0,
3
);
}
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);
this.isDisable = this.isDisable || detailsInfo.synchronization == 1; // 是否禁用 1:已同步数据 0: 未同步数据
uni.hideLoading();
})
.catch((error) => {
uni.showToast({
title: error.msg,
icon: "none",
duration: 1000,
});
uni.hideLoading();
});
},
// 获取机房详情
getDetailsItem(location, jfType, value) {
this.activeName = location;
this.value = value;
this.detailsItem = this.detailsInfo.originData[value - 1].details;
this.jfType = this.detailsInfo.originData[value - 1].jfType;
if (this.detailsItem.afxt.detail[2].inspectionResult === 1) {
this.detailsItem.afxt.detail = this.detailsItem.afxt.detail.slice(0, 3);
}
console.log("this.detailsItem", this.detailsItem);
},
startDialogBtn(name = "F座3楼-内环屏蔽机房", jfType = "0", value = "1") {
let item = this.findTargetObject(this.listData);
console.log("即将操作的机房", item);
this.name = this.uid ? item.name : name;
this.jfType = this.uid ? item.jfType : jfType;
this.value = this.uid ? item.value : value;
this.startDialogData.text = [
`请到“${name}”后;`,
"点击“我已到达”开始巡检",
];
this.name = name;
this.jfType = jfType;
this.value = value;
this.$refs.startDialog.open();
},
startDialog(name = "F座3楼-内环屏蔽机房", jfType = "0", value = "1") {
this.name = name;
this.jfType = jfType;
this.value = value;
if (!this.uid && value != "1") {
this.startDialogData.text = [
`当前线路非常用巡检线路,`,
`是否需要从“${this.name}”开始巡检`,
];
} else {
this.startDialogData.text = [
`请到“${this.name}”后;`,
"点击“我已到达”开始巡检",
];
}
this.$refs.startDialog.open();
},
// 处理弹窗确认
handleStartDialog(summary) {
this.toShaftInspection(this.name, this.jfType, this.value);
},
// 跳转到具体的机房
toShaftInspection(name, jfType, value) {
console.log("name, 跳转到具体的机房, value", name, jfType, value);
uni.navigateTo({
url: `/pages/inspectionContent/inspectionContentNew?value=${value}&inspectionCode=${this.inspectionCode}&jfType=${jfType}&location=${name}&uid=${this.uid}&backValue=${this.backValue}&did=${this.did}`,
});
},
lookTable() {
uni.navigateTo({
url: "/pages/report/sampleTable?isJF=1",
});
},
toSign() {
if(!this.allIsSubmitOne) {
return;
}
this.$refs.signDialog.open();
},
findTargetObject(rows) {
if (!rows || rows.length === 0) return null;
let lastNonZeroIndex = -1;
// 首先检查所有对象,记录最后一个 status 不为 0 的索引
for (let i = 0; i < rows.length; i++) {
if (rows[i].status !== 0) {
lastNonZeroIndex = i;
}
}
// 如果没有找到任何 status 不为 0 的对象,返回 null
if (lastNonZeroIndex === -1) return null;
// 计算目标对象的索引
let targetIndex = lastNonZeroIndex + 1;
// 如果最后一个非零对象是数组的最后一个元素,则从第一个对象开始检查
if (lastNonZeroIndex === rows.length - 1) {
for (let i = 0; i < rows.length; i++) {
if (rows[i].status !== 0) {
targetIndex = i + 1;
break; // 找到第一个就停止
}
}
// 如果 targetIndex 超出数组范围,则返回 null
return targetIndex < rows.length ? rows[targetIndex] : null;
}
// 正常情况:返回最后一个非零对象的下一个对象
return rows[targetIndex];
},
// 处理弹窗确认
handlePopupConfirm(signImg) {
this.detailsInfo.isSign = this.isSign = true; // 回显到文字显示区域
this.detailsInfo.signImg = signImg; // 回显到文字显示区域
this.detailsInfo.isSubmit = 1; // 提交状态
const isException = this.detailsInfo.originData.some(
(item) => item.status == 2
);
this.detailsInfo.isException = isException ? 1 : 0; // 巡检异常
let allIsSubmitOne = this.detailsInfo.originData.every(
(item) => item.isSubmit === 1
);
if (!allIsSubmitOne) {
// 如果有机房没有巡检完,记录是编辑状态
this.detailsInfo.synchronization = 2;
} else {
this.detailsInfo.synchronization = 0;
}
this.realSave(this.detailsInfo);
},
realSave(params, type = "sign") {
const send = dataToSql(params);
const api = this.uid ? inspectApi.update : inspectApi.save;
const inspectionCode =
this.inspectionCode ||
`JFXJ${moment().format("yyyyMMDDHHmmss")}${
Math.floor(Math.random() * 900) + 100
}`;
send.inspectionCode = inspectionCode;
console.log("send", send);
api(this.uid ? { id: this.uid, ...send } : send).then((res) => {
const logContent = getLogContent(
LOG_TYPE_ENUM.sys,
`巡检编号(${inspectionCode})`,
"同步"
);
this.$logApi.addlog(logContent);
console.log("logContent", logContent);
uni.showToast({
title: type == "sign" ? "签字成功" : "同步成功",
icon: "success",
});
if (!this.uid) {
this.uid = res.lastInsertId;
setTimeout(() => {
this.getDetails(res.lastInsertId);
}, 300);
}
});
},
back() {
if (this.backValue === "home") {
uni.navigateTo({
url: "/pages/home/home",
});
} else {
uni.navigateTo({
url: `/pages/inspectionManagement/index`,
});
}
},
previewImage(images, index) {
uni.previewImage({
current: index,
urls: images,
success: (res) => {},
});
},
onSyncData(show) {
this.isDialog = show;
this.propList = [
{
...dataToSql(this.detailsInfo),
id: this.uid,
},
];
console.log("propList", this.propList);
if (!show) {
this.getDetails(this.uid);
}
},
},
};
</script>
<style lang="less" scoped>
.uni-nav-bar-text {
height: 28.8px;
width: 28.8px;
background: #ffffff;
border: 0.32px solid rgba(224, 224, 224, 1);
border-radius: 14.4px;
color: #333;
text-align: center;
.iconfont {
font-size: 16px;
line-height: 28.8px;
}
}
.nav-right {
width: 192px;
z-index: 10;
}
.header-buttons {
display: flex;
align-items: center;
margin-left: auto;
.button {
width: 89.6px;
height: 28.8px;
background: #ffffff;
border-radius: 14.4px;
margin-left: 12.8px;
font-family: PingFangSC-Regular;
font-size: 12.8px;
color: #000000;
line-height: 28.8px;
font-weight: 400;
text-align: center;
}
}
.container {
background-image: linear-gradient(115deg, #e8f0fb 0%, #e1ebfa 100%);
padding: 0 25.6px;
height: 100vh;
}
.profile-section {
width: 100%;
margin-bottom: 12.8px;
.profile-box {
background-color: #fff;
border-radius: 9.6px;
padding: 12.8px 25.6px;
display: flex;
justify-content: space-between;
align-items: center;
.profile-left {
display: flex;
align-items: center;
.avatar {
position: relative;
width: 68.8px;
height: 68.8px;
margin-right: 9.6px;
border-radius: 50%;
overflow: hidden;
image {
width: 100%;
height: 100%;
}
.change-password {
position: absolute;
bottom: 0;
left: 0;
right: 0;
background-color: rgba(0, 0, 0, 0.5);
text-align: center;
height: 17.6px;
font-family: PingFangSC-Regular;
font-size: 9.6px;
color: #ffffff;
line-height: 16px;
font-weight: 400;
}
}
.info {
.username {
font-size: 16px;
color: #000000;
line-height: 22.4px;
font-weight: 500;
margin-bottom: 7.2px;
margin-right: 10px;
}
.number {
font-size: 12.8px;
color: #4a4a4a;
line-height: 22.4px;
font-weight: 400;
margin-right: 9.6px;
.value {
color: #000000;
}
}
.describe {
display: flex;
.abnormal {
color: #fff;
line-height: 22.4px;
height: 22.4px;
padding: 0 8px;
font-size: 12px;
background-color: #f55a42;
border-radius: 11px;
}
}
}
}
.profile-right {
display: flex;
.inspection-button {
width: 89.6px;
height: 28.8px;
background-image: linear-gradient(105deg, #68acfb 0%, #3774f6 100%);
border-radius: 14.4px;
font-family: PingFangSC-Regular;
font-size: 12.8px;
color: #ffffff;
line-height: 28.8px;
font-weight: 400;
margin-right: 12.8px;
}
.record-button {
display: block;
width: 115.2px;
height: 28.8px;
background: #ffffff;
border: 0.8px solid rgba(55, 116, 246, 1);
border-radius: 14.4px;
font-family: PingFangSC-Regular;
font-size: 12.8px;
color: #3774f6;
line-height: 28.8px;
font-weight: 400;
display: flex;
justify-content: center;
&.disabled-btn {
color: #c7c7c7;
background-color: #f9f9f9;
border-color: #f2f2f2;
}
}
}
}
}
.box {
background: #ffffff;
border-radius: 9.6px 9.6px 0 0;
padding: 12.8px 19.2px;
.bar {
display: flex;
justify-content: flex-start;
.title {
font-family: PingFangSC-Medium;
font-size: 14.4px;
color: #000000;
line-height: 27.2px;
font-weight: 500;
}
.dai {
background: rgba(243, 152, 0, 0.08);
border-radius: 8px;
font-family: PingFangSC-Regular;
font-size: 11.2px;
color: #4a4a4a;
letter-spacing: 0;
text-align: right;
line-height: 27.2px;
font-weight: 400;
margin: 0 9.6px;
padding: 0 9.6px;
.num {
color: #f39800;
}
}
.yi {
background: rgba(55, 116, 246, 0.08);
border-radius: 8px;
font-family: PingFangSC-Regular;
font-size: 11.2px;
color: #4a4a4a;
letter-spacing: 0;
text-align: right;
line-height: 27.2px;
font-weight: 400;
padding: 0 9.6px;
.num {
color: #000;
}
}
}
}
.card-box {
background: #ffffff;
border-radius: 0 0 9.6px 9.6px;
padding: 12.8px 19.2px;
height: calc(100vh - 232px - 19.2px);
&.detail {
height: calc(100vh - 200px);
border-radius: 9.6px;
overflow: auto;
.card-wrapper {
width: calc((100% - 4 * 12.8px) / 5); /* 严格五等分宽度 */
.card {
margin-bottom: 12.8px;
}
}
}
}
.card-row {
display: flex;
justify-content: space-between;
align-items: center;
position: relative;
width: 100%;
.card-wrapper {
width: calc((100% - 4 * 43.2px) / 5); /* 严格五等分宽度 */
.card {
height: 51.2px;
margin-bottom: 43.2px;
border-radius: 8px;
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);
}
&.warning {
background: #fff5f4;
&.active {
border: 1px solid #ff4a34;
}
.status {
color: #ff4a34 !important;
}
}
&.status1 {
background: #f3f7ff;
.status {
color: #3774f6;
}
}
&.status2 {
background: #fff5f4;
.status {
color: #f55a42;
}
}
.card-content {
padding: 6.4px;
.first-row {
display: flex;
align-items: center;
.iconfont {
font-size: 12px;
margin-right: 6.4px;
&.icon-weixunjian {
color: #959595;
}
&.icon-shibai1 {
color: #ff4a34;
}
&.icon-wancheng {
color: #3774f6;
}
}
.status {
font-size: 12px;
color: #333333;
}
}
.second-row {
margin-top: 3.2px;
padding-left: 20px;
.location {
font-size: 12px;
color: #666666;
}
}
}
}
.spacer-image.right {
position: absolute;
right: -43.2px;
top: 50%;
transform: translateY(-50%);
.img {
width: 30.4px;
height: 6.4px;
margin: 0 6.4px;
}
}
}
.spacer-image.bottom {
position: absolute;
bottom: -33.6px;
left: 50%;
transform: translateX(-50%) rotate(90deg);
.img {
width: 30.4px;
height: 6.4px;
margin: 6.4px 0;
}
}
&.right {
.card-wrapper {
.spacer-image.right {
position: absolute;
left: -43.2px;
top: 50%;
transform: translateY(-50%) rotate(180deg);
.img {
width: 30.4px;
height: 6.4px;
margin: 0 6.4px;
}
}
}
}
}
.submit-module {
display: flex;
justify-content: center;
position: fixed;
gap: 16px;
left: 50%;
transform: translateX(-50%);
bottom: 25.6px;
.action-btn {
width: 145.6px;
height: 38.4px;
line-height: 38.4px;
background-image: linear-gradient(180deg, #3773f6 0%, #2c57f6 99%);
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: #fff;
text-align: center;
font-weight: 400;
&.complete-btn {
background-image: linear-gradient(180deg, #3773f6 0%, #2c57f6 99%);
color: #ffffff;
}
}
}
.sign-img {
width: 80px;
height: 28.8px;
margin-right: 10px;
border: 1px solid #c5c5c5;
&.no-border {
border: none;
}
}
</style>
......@@ -48,70 +48,42 @@
></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 || {}"
<!-- 防雷接地系统 -->
<yearFljdxt
v-show="checkValueInArray(tabs, 'yearFljdxt', activeTab)"
ref="yearFljdxt"
inspectionItem="防雷接地系统"
:defaultData="list.yearFljdxt"
></yearFljdxt>
<!-- 屏蔽系统 -->
<yearPbxt
v-show="checkValueInArray(tabs, 'yearPbxt', activeTab)"
ref="yearPbxt"
inspectionItem="屏蔽系统"
:defaultData="list.yearPbxt || {}"
></yearPbxt>
<!-- 动力环境监控系统 -->
<yearDlhjjkxt
v-show="checkValueInArray(tabs, 'yearDlhjjkxt', activeTab)"
ref="yearDlhjjkxt"
inspectionItem="动力环境监控系统"
:defaultData="list.yearDlhjjkxt || {}"
></yearDlhjjkxt>
<!-- 空调系统 -->
<yearKtxt
v-show="checkValueInArray(tabs, 'yearKtxt', activeTab)"
ref="yearKtxt"
inspectionItem="空调系统"
:defaultData="list.yearKtxt || {}"
: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>
></yearKtxt>
<!-- UPS系统 -->
<yearUpsxt
v-show="checkValueInArray(tabs, 'yearUpsxt', activeTab)"
ref="yearUpsxt"
inspectionItem="UPS系统"
:defaultData="list.yearUpsxt || {}"
></yearUpsxt>
</view>
</view>
</view>
......@@ -142,11 +114,7 @@ import assRoomApi from "@/api/assRoom.js";
import inspectApi from "@/api/inspect.js";
import { dataToSql, sqlToData, getHistoryData } from "./shared";
import {
pad_all_inspection_position,
tabsInfo1,
tabsInfo2,
} from "@/utils/dict.js"; //巡检位置,A座到F座 楼层2楼4楼到26楼
import { tabsInfoYear } from "@/utils/dict.js"; //巡检位置,A座到F座 楼层2楼4楼到26楼
import {
addLog,
getLogContent,
......@@ -157,28 +125,20 @@ import {
import { getInspectionDetails } from "@/request/index.js";
import moment from "moment";
import _ from "lodash";
import wlhj from "./components/wlhj.vue"; //物理环境
import afxt from "./components/afxt.vue"; //安防系统
import sbgj from "./components/sbgj.vue"; //设备告警
import dczt from "./components/dczt.vue"; //电池状态
import jfwsd from "./components/jfwsd.vue"; //机房温湿度
import dlxt from "./components/dlxt.vue"; //电力系统
import xfxt from "./components/xfxt.vue"; //消防系统
import xlqk from "./components/xlqk.vue"; //线路情况
import qt from "./components/qt.vue"; //其它
import yearFljdxt from "./components/yearFljdxt.vue"; //防雷接地系统
import yearPbxt from "./components/yearPbxt.vue"; //屏蔽系统
import yearDlhjjkxt from "./components/yearDlhjjkxt.vue"; //动力环境监控系统
import yearKtxt from "./components/yearKtxt.vue"; //空调系统
import yearUpsxt from "./components/yearUpsxt.vue"; //UPS系统
import startDialog from "./components/dialog.vue";
export default {
components: {
wlhj,
afxt,
sbgj,
dczt,
jfwsd,
dlxt,
xfxt,
xlqk,
qt,
yearFljdxt,
yearPbxt,
yearDlhjjkxt,
yearKtxt,
yearUpsxt,
startDialog,
},
data() {
......@@ -218,6 +178,7 @@ export default {
// 我新增的
jfList: [],
did: "",
inspectionType: "4",
};
},
computed: {
......@@ -249,10 +210,7 @@ export default {
this.backValue = options.backValue || "";
this.imgSrc = `../../static/img/jf/jf${this.value}.png`;
this.tabs =
this.jfType === "2" || this.jfType === "3"
? this.deepClone(tabsInfo2)
: this.deepClone(tabsInfo1);
this.tabs = this.deepClone(tabsInfoYear);
console.log("机房查看options", options);
this.all_data = this.$store.state.all_data || [];
......@@ -263,18 +221,18 @@ export default {
this.init();
this.paramsObjFirst = this.getAllChildFormData();
// 临时id
getHistoryData().then((detailsInfo) => {
getHistoryData(this.inspectionType).then((detailsInfo) => {
console.log("history", detailsInfo);
if (detailsInfo) {
delete detailsInfo.id;
delete detailsInfo.inspectionCode
delete detailsInfo.inspectionCode;
// 处理历史数据(选项、文案、照片;异常项-不调出文案及照片)
this.list = detailsInfo.originData[this.value - 1].details;
this.inspectionNumber = detailsInfo.inspectionNumber;
this.inspectionCode = `JFXJ${moment().format("yyyyMMDDHHmmss")}${
this.inspectionCode = `NDXJ${moment().format("yyyyMMDDHHmmss")}${
Math.floor(Math.random() * 900) + 100
}`;
......@@ -319,9 +277,9 @@ export default {
// 判断是否有回显数据
// 基础数据
this.baseInfo = {
inspectionType: "1",
inspectionType: "4",
inspectionCode: this.inspectionCode,
recordName: `${moment().format("yyyyMMDD")}-机房巡检`,
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,
......@@ -401,11 +359,11 @@ export default {
}
// 使用 filter 方法筛选出 status 为 1 或 2 的对象
const inspectedItems = this.detailsInfo.originData.filter(
(item) => item.status === 1 || item.status === 2
(item) => item.status === 1 || item.status === 2,
);
const isException = this.detailsInfo.originData.some(
(item) => item.status == 2
(item) => item.status == 2,
);
console.log("isException", isException);
......@@ -419,7 +377,7 @@ export default {
this.listData = this.detailsInfo.originData;
let allIsSubmitOne = this.detailsInfo.originData.every(
(item) => item.isSubmit === 1
(item) => item.isSubmit === 1,
);
if (!allIsSubmitOne) {
......@@ -482,7 +440,7 @@ export default {
* 得检测每个机房是否巡检完
*/
let allIsSubmitOne = data.originData.every(
(item) => item.isSubmit === 1
(item) => item.isSubmit === 1,
);
if (!allIsSubmitOne) {
// 如果有机房没有巡检完,记录是编辑状态
......@@ -533,7 +491,7 @@ export default {
{
notZeroCount: 0,
equalTwoCount: 0,
} // 初始化统计结果
}, // 初始化统计结果
);
},
typeSubmit(originData) {
......@@ -590,16 +548,19 @@ export default {
console.log("提交时获取一次", params);
this.all_data = this.$store.state.all_data || [];
params.inspectionCode = this.inspectionCode || `JFXJ${moment().format("yyyyMMDDHHmmss")}${
params.inspectionCode =
this.inspectionCode ||
`NDXJ${moment().format("yyyyMMDDHHmmss")}${
Math.floor(Math.random() * 900) + 100
}`
}`;
params.inspectionType = this.inspectionType;
this.realSave(params).then(() => {
let logContent = "";
console.log("all_data", this.all_data);
if (this.uid) {
const index = this.all_data.findIndex(
(element) => element.uid == this.uid
(element) => element.uid == this.uid,
);
params.uid = this.uid;
......@@ -607,14 +568,14 @@ export default {
logContent = getLogContent(
LOG_TYPE_ENUM.edit,
`巡检编号(${params.inspectionCode})`,
"巡检模块"
"巡检模块",
);
} else {
this.all_data.push(params);
logContent = getLogContent(
LOG_TYPE_ENUM.add,
`巡检编号(${params.inspectionCode})`,
"巡检模块"
"巡检模块",
);
}
// 更新巡检list
......@@ -622,7 +583,7 @@ export default {
console.log("all_data存储", this.all_data);
this.$store.commit("SET_ALL_DATA", this.all_data);
const inspectList = this.all_data.filter(
(item) => item.createByName == userInfo.user
(item) => item.createByName == userInfo.user,
);
console.log("inspectList", inspectList);
......@@ -631,7 +592,7 @@ export default {
// 更新日志
const log_list = this.$store.state.log_list;
logContent.inspectionType = params.inspectionType;
this.$logApi.addlog(logContent)
this.$logApi.addlog(logContent);
console.log("logContent", logContent);
log_list.push(logContent);
......@@ -660,7 +621,7 @@ export default {
// let item = this.findTargetObject(this.listData);
const item = this.listData.find(
(item) => !item.status || item.isSubmit == 0
(item) => !item.status || item.isSubmit == 0,
);
console.log("即将操作的机房", item);
......@@ -685,7 +646,7 @@ export default {
handleStartDialog() {
console.log("跳转前", this.uid);
uni.navigateTo({
url: `/pages/inspectionContent/inspectionContentNew?value=${this.value}&inspectionCode=${this.inspectionCode}&jfType=${this.jfType}&location=${this.name}&uid=${this.uid}&backValue=${this.backValue}`,
url: `/pages/inspectionContent/inspectionContentYearNew?value=${this.value}&inspectionCode=${this.inspectionCode}&jfType=${this.jfType}&location=${this.name}&uid=${this.uid}&backValue=${this.backValue}`,
});
},
findTargetObject(rows) {
......@@ -765,7 +726,7 @@ export default {
const validateData = (data) => {
return data.every(
(item) =>
item.inspectionResult !== null && item.conclusion.trim() !== ""
item.inspectionResult !== null && item.conclusion.trim() !== "",
);
};
// 调用校验函数
......@@ -825,7 +786,7 @@ export default {
// 返回
back() {
uni.navigateTo({
url: `/pages/inspectionContent/inspectionContentList?uid=${this.uid}&backValue=${this.backValue}&value=${this.value}`,
url: `/pages/inspectionContent/inspectionContentList?uid=${this.uid}&backValue=${this.backValue}&value=${this.value}&inspectionType=4`,
});
},
// 关闭弹窗
......
......@@ -90,9 +90,9 @@ export function sqlToData(sqlData) {
return ret;
}
export function getHistoryData() {
export function getHistoryData(inspectionType=1) {
return new Promise((resolve, reject) => {
inspectApi.selectLastData(store.state.now_user.userId).then((history) => {
inspectApi.selectLastData(store.state.now_user.userId, inspectionType).then((history) => {
if (history && history.length) {
const detailsInfo = sqlToData(history[0]);
// 处理历史数据(选项、文案、照片;异常项-不调出文案及照片)
......
......@@ -547,6 +547,7 @@ export default {
return false;
}
const params = this.getParams(isSubmit); //数据获取
params.inspectionType = "2";
// const all_data = this.$store.state.all_data; //获取全部数据
let logContent = "";
console.log("this.uid", this.uid);
......
......@@ -14,7 +14,7 @@ export const pad_inspection_type = {
remark: null,
dictCode: 1263,
dictSort: 1,
dictLabel: "机房巡检",
dictLabel: "机房日常巡检",
dictValue: "1",
dictType: "pad_inspection_type",
cssClass: null,
......@@ -40,6 +40,40 @@ export const pad_inspection_type = {
status: "0",
default: false,
},
{
createBy: "admin",
createTime: "2024-09-05 15:48:07",
updateBy: null,
updateTime: null,
remark: null,
dictCode: 1265,
dictSort: 1,
dictLabel: "机房月度巡检",
dictValue: "3",
dictType: "pad_inspection_type",
cssClass: null,
listClass: "default",
isDefault: "N",
status: "0",
default: false,
},
{
createBy: "admin",
createTime: "2024-09-05 15:48:07",
updateBy: null,
updateTime: null,
remark: null,
dictCode: 1266,
dictSort: 1,
dictLabel: "机房年度巡检",
dictValue: "4",
dictType: "pad_inspection_type",
cssClass: null,
listClass: "default",
isDefault: "N",
status: "0",
default: false,
},
],
code: 200,
msg: "查询成功",
......@@ -1993,3 +2027,116 @@ export const tabsInfo2 = [
],
},
];
// 月度tab配置
export const tabsInfoMonth = [
{
label: "空调系统",
value: "monthKtxt",
status: 0,
text: [
"1、滤网清洁:每个月清洁一次过滤网",
"2、翅片清洁:检查翅片是否有积灰",
"3、积水盘清洁:检查翅片下方积水盘有无积水或水渍",
"4、空调内机清洁:清除空调内机表面灰尘",
],
},
{
label: "UPS系统",
value: "monthUpsxt",
status: 0,
text: [
"1、主机清洁:观察主机内部灰尘情况,清扫除尘、清洁过滤网",
"2、系统参数设置:观察系统参数设置是否正常",
"3、整流器、逆变器外观:观察整流器、逆变器外观是否正常",
],
},
{
label: "供配电系统",
status: 0,
value: "monthGpdxt",
text: [
"1、配套装置:检查配套装置是否完好,有无异响、膨胀、接点松动现象,各连接线有无焦糊变色现象",
"2、电缆、接线端子:检查连接电缆、接线端子是否紧固",
"3、熔断器:观察熔断器是否完好",
],
},
{
label: "照明系统",
value: "monthZmxt",
status: 0,
text: [
"1、应急灯功能:检查应急照明功能是否正常,有无偏暗或者不亮",
],
},
{
label: "防雷接地系统",
value: "monthFljdxt",
status: 0,
text: [
"1、浪涌保护器开关:观察浪涌保护器开关状态是否正常",
],
},
{
label: "屏蔽系统",
value: "monthPbxt",
status: 0,
text: [
"1、弹簧片、门扇插口:屏蔽门弹簧片及门扇插口:用干净纱布蘸上无水酒精擦洗,如有损坏的簧片要及时更换",
"2、屏蔽门手动转换:检查手动转换插销起拨是否轻松,手动开关门是否轻便,清洁加润滑油",
"3、进、回波导水管:检查空调屏蔽处接口,进、回波导水管是否有漏水发生,水管与波导管间的配件是否松动等其它非正常现象",
"4、光纤波导管:检查光纤波导管,去除管内积尘,检查是否有非光纤类线缆通过,检查确认进入光纤均为非加强钢芯类",
"5、壳体、龙骨架外观:检查四周裸露的屏蔽壳体、龙骨架是否有异常变形、裂纹或破坏。表面防腐层是否完好。",
],
},
];
// 年度tab配置
export const tabsInfoYear = [
{
label: "防雷接地系统",
value: "yearFljdxt",
status: 0,
text: [
"1、等电位连接:检测等电位连接有无异常",
"2、外壳、机架连接:检测设备金属外壳、机架与等电位连接是否正常",
"3、接地装置:检测接地装置是否正常",
],
},
{
label: "屏蔽系统",
value: "yearPbxt",
status: 0,
text: [
"1、信号强度:每年使用专用设备自测壳体内不同位置的信号强度,是否符合设计标准",
],
},
{
label: "动力环境监控系统",
value: "yearDlhjjkxt",
status: 0,
text: [
"1、漏水报警功能:测试漏水报警功能是否正常",
],
},
{
label: "空调系统",
status: 0,
value: "yearKtxt",
text: [
"1、风机内过滤器清洗:空调换气风机内的过滤器每年清洗一次",
],
},
{
label: "UPS系统",
value: "yearUpsxt",
status: 0,
text: [
"1、旁路模式供电检查:观察转换为旁路工作模式后UPS供电是否正常",
"2、蓄电池放电测试:蓄电池核对性放电测试",
"3、电池电压:测量单体电池电压,是否符合电池规格要求",
],
},
];
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论