提交 8e1277e0 authored 作者: 刘守彩's avatar 刘守彩

feat(巡检): 其他增加水箱检查

上级 89406c09
...@@ -2,8 +2,8 @@ ...@@ -2,8 +2,8 @@
"name" : "杭州内网机房巡检", "name" : "杭州内网机房巡检",
"appid" : "__UNI__A11BFD5", "appid" : "__UNI__A11BFD5",
"description" : "", "description" : "",
"versionName" : "1.0.2", "versionName" : "1.0.3",
"versionCode" : 102, "versionCode" : 103,
"transformPx" : false, "transformPx" : false,
/* 5+App特有相关 */ /* 5+App特有相关 */
"app-plus" : { "app-plus" : {
......
...@@ -10,19 +10,10 @@ ...@@ -10,19 +10,10 @@
<view v-if="detailsItem.wlhj" class="container-item"> <view v-if="detailsItem.wlhj" class="container-item">
<view class="title">物理环境</view> <view class="title">物理环境</view>
<view class="cards"> <view class="cards">
<view <view v-for="(item, index) in detailsItem.wlhj.detail" :key="index" class="cards-item">
v-for="(item, index) in detailsItem.wlhj.detail" <view class="name">{{ item.label
:key="index" }}<text class="status"
class="cards-item" :class="{ warning: item.inspectionResult === 1 }">{{ item.inspectionResultLable }}</text></view>
>
<view class="name"
>{{ item.label
}}<text
class="status"
:class="{ warning: item.inspectionResult === 1 }"
>{{ item.inspectionResultLable }}</text
></view
>
<view class="list"> <view class="list">
<view class="label">情况描述:</view> <view class="label">情况描述:</view>
<view class="content"> <view class="content">
...@@ -35,14 +26,8 @@ ...@@ -35,14 +26,8 @@
未拍摄照片 未拍摄照片
</view> </view>
<view v-else class="content"> <view v-else class="content">
<image <image v-for="(url, urlIndex) in item.photos" :key="urlIndex" class="image-item" :src="url"
v-for="(url, urlIndex) in item.photos" mode="aspectFit" @click="previewImage(item.photos, urlIndex)"></image>
:key="urlIndex"
class="image-item"
:src="url"
mode="aspectFit"
@click="previewImage(item.photos, urlIndex)"
></image>
</view> </view>
</view> </view>
</view> </view>
...@@ -52,21 +37,11 @@ ...@@ -52,21 +37,11 @@
<view v-if="detailsItem.afxt" class="container-item"> <view v-if="detailsItem.afxt" class="container-item">
<view class="title">安防系统</view> <view class="title">安防系统</view>
<view class="cards"> <view class="cards">
<view <view v-for="(item, index) in detailsItem.afxt.detail" :key="index" class="cards-item" v-if="showItem(item)">
v-for="(item, index) in detailsItem.afxt.detail"
:key="index"
class="cards-item"
v-if="showItem(item)"
>
<template></template> <template></template>
<view class="name" <view class="name">{{ item.label
>{{ item.label }}<text class="status"
}}<text :class="{ warning: item.inspectionResult === 1 }">{{ item.inspectionResultLable }}</text></view>
class="status"
:class="{ warning: item.inspectionResult === 1 }"
>{{ item.inspectionResultLable }}</text
></view
>
<view class="list"> <view class="list">
<view class="label">情况描述:</view> <view class="label">情况描述:</view>
<view class="content"> <view class="content">
...@@ -75,21 +50,12 @@ ...@@ -75,21 +50,12 @@
</view> </view>
<view class="list"> <view class="list">
<view class="label">现场照片:</view> <view class="label">现场照片:</view>
<view <view v-if="item.photos && item.photos.length === 0" class="content">
v-if="item.photos && item.photos.length === 0"
class="content"
>
未拍摄照片 未拍摄照片
</view> </view>
<view v-else class="content"> <view v-else class="content">
<image <image v-for="(url, urlIndex) in item.photos" :key="urlIndex" class="image-item" :src="url"
v-for="(url, urlIndex) in item.photos" mode="aspectFit" @click="previewImage(item.photos, urlIndex)"></image>
:key="urlIndex"
class="image-item"
:src="url"
mode="aspectFit"
@click="previewImage(item.photos, urlIndex)"
></image>
</view> </view>
</view> </view>
</view> </view>
...@@ -99,19 +65,10 @@ ...@@ -99,19 +65,10 @@
<view v-if="detailsItem.dczt" class="container-item"> <view v-if="detailsItem.dczt" class="container-item">
<view class="title">电池状态</view> <view class="title">电池状态</view>
<view class="cards"> <view class="cards">
<view <view v-for="(item, index) in detailsItem.dczt.detail" :key="index" class="cards-item">
v-for="(item, index) in detailsItem.dczt.detail" <view class="name">{{ item.label
:key="index" }}<text class="status"
class="cards-item" :class="{ warning: item.inspectionResult === 1 }">{{ item.inspectionResultLable }}</text></view>
>
<view class="name"
>{{ item.label
}}<text
class="status"
:class="{ warning: item.inspectionResult === 1 }"
>{{ item.inspectionResultLable }}</text
></view
>
<view class="list"> <view class="list">
<view class="label">{{ item.settingLabelShow }}:</view> <view class="label">{{ item.settingLabelShow }}:</view>
<view class="content"> <view class="content">
...@@ -134,14 +91,8 @@ ...@@ -134,14 +91,8 @@
未拍摄照片 未拍摄照片
</view> </view>
<view v-else class="content"> <view v-else class="content">
<image <image v-for="(url, urlIndex) in item.photos" :key="urlIndex" class="image-item" :src="url"
v-for="(url, urlIndex) in item.photos" mode="aspectFit" @click="previewImage(item.photos, urlIndex)"></image>
:key="urlIndex"
class="image-item"
:src="url"
mode="aspectFit"
@click="previewImage(item.photos, urlIndex)"
></image>
</view> </view>
</view> </view>
</view> </view>
...@@ -151,19 +102,10 @@ ...@@ -151,19 +102,10 @@
<view v-if="detailsItem.sbgj" class="container-item"> <view v-if="detailsItem.sbgj" class="container-item">
<view class="title">设备告警</view> <view class="title">设备告警</view>
<view class="cards"> <view class="cards">
<view <view v-for="(item, index) in detailsItem.sbgj.detail" :key="index" class="cards-item sbgj">
v-for="(item, index) in detailsItem.sbgj.detail" <view class="name">{{ item.label
:key="index" }}<text class="status"
class="cards-item sbgj" :class="{ warning: item.inspectionResult === 1 }">{{ item.inspectionResultLable }}</text></view>
>
<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 v-if="item.inspectionResult === 1" class="list">
<view class="label">故障设备:</view> <view class="label">故障设备:</view>
<view class="content"> <view class="content">
...@@ -186,14 +128,8 @@ ...@@ -186,14 +128,8 @@
未拍摄照片 未拍摄照片
</view> </view>
<view v-else class="content"> <view v-else class="content">
<image <image v-for="(url, urlIndex) in item.photos" :key="urlIndex" class="image-item" :src="url"
v-for="(url, urlIndex) in item.photos" mode="aspectFit" @click="previewImage(item.photos, urlIndex)"></image>
:key="urlIndex"
class="image-item"
:src="url"
mode="aspectFit"
@click="previewImage(item.photos, urlIndex)"
></image>
</view> </view>
</view> </view>
</view> </view>
...@@ -203,19 +139,10 @@ ...@@ -203,19 +139,10 @@
<view v-if="detailsItem.jfwsd" class="container-item"> <view v-if="detailsItem.jfwsd" class="container-item">
<view class="title">机房温湿度</view> <view class="title">机房温湿度</view>
<view class="cards"> <view class="cards">
<view <view v-for="(item, index) in detailsItem.jfwsd.detail" :key="index" class="cards-item">
v-for="(item, index) in detailsItem.jfwsd.detail" <view class="name">{{ item.label
:key="index" }}<text class="status"
class="cards-item" :class="{ warning: item.inspectionResult === 1 }">{{ item.inspectionResultLable }}</text></view>
>
<view class="name"
>{{ item.label
}}<text
class="status"
:class="{ warning: item.inspectionResult === 1 }"
>{{ item.inspectionResultLable }}</text
></view
>
<view class="list"> <view class="list">
<view class="label">{{ item.settingLabel }}:</view> <view class="label">{{ item.settingLabel }}:</view>
<view class="content"> {{ item.setting }}{{ item.unit }} </view> <view class="content"> {{ item.setting }}{{ item.unit }} </view>
...@@ -236,14 +163,8 @@ ...@@ -236,14 +163,8 @@
未拍摄照片 未拍摄照片
</view> </view>
<view v-else class="content"> <view v-else class="content">
<image <image v-for="(url, urlIndex) in item.photos" :key="urlIndex" class="image-item" :src="url"
v-for="(url, urlIndex) in item.photos" mode="aspectFit" @click="previewImage(item.photos, urlIndex)"></image>
:key="urlIndex"
class="image-item"
:src="url"
mode="aspectFit"
@click="previewImage(item.photos, urlIndex)"
></image>
</view> </view>
</view> </view>
</view> </view>
...@@ -253,19 +174,10 @@ ...@@ -253,19 +174,10 @@
<view v-if="detailsItem.dlxt" class="container-item"> <view v-if="detailsItem.dlxt" class="container-item">
<view class="title">电力系统</view> <view class="title">电力系统</view>
<view class="cards"> <view class="cards">
<view <view v-for="(item, index) in detailsItem.dlxt.detail" :key="index" class="cards-item">
v-for="(item, index) in detailsItem.dlxt.detail" <view class="name">{{ item.label
:key="index" }}<text class="status"
class="cards-item" :class="{ warning: item.inspectionResult === 1 }">{{ item.inspectionResultLable }}</text></view>
>
<view class="name"
>{{ item.label
}}<text
class="status"
:class="{ warning: item.inspectionResult === 1 }"
>{{ item.inspectionResultLable }}</text
></view
>
<view class="list"> <view class="list">
<view class="label">情况描述:</view> <view class="label">情况描述:</view>
<view class="content"> <view class="content">
...@@ -278,14 +190,8 @@ ...@@ -278,14 +190,8 @@
未拍摄照片 未拍摄照片
</view> </view>
<view v-else class="content"> <view v-else class="content">
<image <image v-for="(url, urlIndex) in item.photos" :key="urlIndex" class="image-item" :src="url"
v-for="(url, urlIndex) in item.photos" mode="aspectFit" @click="previewImage(item.photos, urlIndex)"></image>
:key="urlIndex"
class="image-item"
:src="url"
mode="aspectFit"
@click="previewImage(item.photos, urlIndex)"
></image>
</view> </view>
</view> </view>
</view> </view>
...@@ -295,34 +201,23 @@ ...@@ -295,34 +201,23 @@
<view v-if="detailsItem.xfxt" class="container-item"> <view v-if="detailsItem.xfxt" class="container-item">
<view class="title">消防系统</view> <view class="title">消防系统</view>
<view class="cards"> <view class="cards">
<view <view v-for="(item, index) in detailsItem.xfxt.detail" :key="index" class="cards-item">
v-for="(item, index) in detailsItem.xfxt.detail"
:key="index"
class="cards-item"
>
<view class="name" <view class="name">
>
<template v-if="index==0"> <template v-if="index==0">
<view> <view>
{{ item.label }} (气压范围:{{item.setting}} {{ item.label }} (气压范围:{{item.setting}}
<text <text class="status"
class="status" :class="{ warning: item.inspectionResult === 1 }">{{ item.inspectionResultLable }}
:class="{ warning: item.inspectionResult === 1 }"
>{{ item.inspectionResultLable }}
</text> </text>
</view> </view>
</template> </template>
<template v-else> <template v-else>
{{ item.label }} {{ item.label }}
<text <text class="status" :class="{ warning: item.inspectionResult === 1 }">{{ item.inspectionResultLable }}
class="status"
:class="{ warning: item.inspectionResult === 1 }"
>{{ item.inspectionResultLable }}
</text> </text>
</template> </template>
</view </view>
>
<!-- <template v-if="index==0"> <!-- <template v-if="index==0">
<view class="list"> <view class="list">
<view class="label" style="width: 70px;">{{item.settingLabel}}:</view> <view class="label" style="width: 70px;">{{item.settingLabel}}:</view>
...@@ -349,14 +244,8 @@ ...@@ -349,14 +244,8 @@
未拍摄照片 未拍摄照片
</view> </view>
<view v-else class="content"> <view v-else class="content">
<image <image v-for="(url, urlIndex) in item.photos" :key="urlIndex" class="image-item" :src="url"
v-for="(url, urlIndex) in item.photos" mode="aspectFit" @click="previewImage(item.photos, urlIndex)"></image>
:key="urlIndex"
class="image-item"
:src="url"
mode="aspectFit"
@click="previewImage(item.photos, urlIndex)"
></image>
</view> </view>
</view> </view>
</view> </view>
...@@ -366,19 +255,10 @@ ...@@ -366,19 +255,10 @@
<view v-if="detailsItem.xlqk" class="container-item"> <view v-if="detailsItem.xlqk" class="container-item">
<view class="title">线路情况</view> <view class="title">线路情况</view>
<view class="cards"> <view class="cards">
<view <view v-for="(item, index) in detailsItem.xlqk.detail" :key="index" class="cards-item">
v-for="(item, index) in detailsItem.xlqk.detail" <view class="name">{{ item.label
:key="index" }}<text class="status" :class="{ warning: item.inspectionResult === 1 }">{{ item.inspectionResultLable }}
class="cards-item" </text></view>
>
<view class="name"
>{{ item.label
}}<text
class="status"
:class="{ warning: item.inspectionResult === 1 }"
>{{ item.inspectionResultLable }}
</text></view
>
<view class="list"> <view class="list">
<view class="label">情况描述:</view> <view class="label">情况描述:</view>
<view class="content"> <view class="content">
...@@ -391,14 +271,8 @@ ...@@ -391,14 +271,8 @@
未拍摄照片 未拍摄照片
</view> </view>
<view v-else class="content"> <view v-else class="content">
<image <image v-for="(url, urlIndex) in item.photos" :key="urlIndex" class="image-item" :src="url"
v-for="(url, urlIndex) in item.photos" mode="aspectFit" @click="previewImage(item.photos, urlIndex)"></image>
:key="urlIndex"
class="image-item"
:src="url"
mode="aspectFit"
@click="previewImage(item.photos, urlIndex)"
></image>
</view> </view>
</view> </view>
</view> </view>
...@@ -408,12 +282,20 @@ ...@@ -408,12 +282,20 @@
<view v-if="detailsItem.qt" class="container-item"> <view v-if="detailsItem.qt" class="container-item">
<view class="title">其它</view> <view class="title">其它</view>
<view class="cards"> <view class="cards">
<view <view v-for="(item, index) in detailsItem.qt.detail" :key="index" class="cards-item">
v-for="(item, index) in detailsItem.qt.detail" <template v-if="item.required">
:key="index" <view class="name">{{ item.label }}
class="cards-item" <text class="status" :class="{ warning: item.inspectionResult === 1 }">{{ item.inspectionResultLable }}
> </text>
</view>
<view class="list"> <view class="list">
<view class="label">情况描述:</view>
<view class="content">
{{ item.conclusion }}
</view>
</view>
</template>
<view v-if="!item.required" class="list">
<view class="label">其它问题:</view> <view class="label">其它问题:</view>
<view class="content"> <view class="content">
{{ item.conclusion }} {{ item.conclusion }}
...@@ -425,14 +307,8 @@ ...@@ -425,14 +307,8 @@
未拍摄照片 未拍摄照片
</view> </view>
<view v-else class="content"> <view v-else class="content">
<image <image v-for="(url, urlIndex) in item.photos" :key="urlIndex" class="image-item" :src="url"
v-for="(url, urlIndex) in item.photos" mode="aspectFit" @click="previewImage(item.photos, urlIndex)"></image>
:key="urlIndex"
class="image-item"
:src="url"
mode="aspectFit"
@click="previewImage(item.photos, urlIndex)"
></image>
</view> </view>
</view> </view>
</view> </view>
...@@ -443,7 +319,7 @@ ...@@ -443,7 +319,7 @@
</template> </template>
<script> <script>
export default { export default {
props: { props: {
// 父组件传递的详情 // 父组件传递的详情
detailsItem: { detailsItem: {
...@@ -473,22 +349,25 @@ export default { ...@@ -473,22 +349,25 @@ export default {
}); });
}, },
}, },
}; };
</script> </script>
<style scoped lang="less"> <style scoped lang="less">
.detail-box { .detail-box {
height: calc(100vh - 180px); height: calc(100vh - 180px);
border-radius: 0 0 9.6px 9.6px; border-radius: 0 0 9.6px 9.6px;
background-color: #fff; background-color: #fff;
.weitu { .weitu {
width: 100%; width: 100%;
margin-bottom: 19.2px; margin-bottom: 19.2px;
height: 280px; height: 280px;
} }
.container { .container {
.container-item { .container-item {
margin-bottom: 19.2px; margin-bottom: 19.2px;
.title { .title {
font-size: 12.8px; font-size: 12.8px;
color: #000000; color: #000000;
...@@ -496,25 +375,30 @@ export default { ...@@ -496,25 +375,30 @@ export default {
font-weight: 500; font-weight: 500;
margin-bottom: 9.6px; margin-bottom: 9.6px;
} }
.cards { .cards {
display: flex; display: flex;
flex-wrap: wrap; flex-wrap: wrap;
justify-content: space-between; justify-content: space-between;
.cards-item { .cards-item {
width: calc(50% - 6.4px); width: calc(50% - 6.4px);
margin-bottom: 12.8px; margin-bottom: 12.8px;
background: #f9f9f9; background: #f9f9f9;
border-radius: 6.4px; border-radius: 6.4px;
padding: 6.4px; padding: 6.4px;
&.sbgj { &.sbgj {
width: 100%; width: 100%;
} }
.name { .name {
font-size: 12.8px; font-size: 12.8px;
color: #000000; color: #000000;
line-height: 19.2px; line-height: 19.2px;
font-weight: 500; font-weight: 500;
margin-bottom: 9.6px; margin-bottom: 9.6px;
.status { .status {
margin-left: 6.4px; margin-left: 6.4px;
padding: 0 6.4px; padding: 0 6.4px;
...@@ -524,19 +408,23 @@ export default { ...@@ -524,19 +408,23 @@ export default {
color: #0cc991; color: #0cc991;
line-height: 16px; line-height: 16px;
font-weight: 400; font-weight: 400;
&.warning { &.warning {
background: #fdebe9; background: #fdebe9;
color: #f55a42; color: #f55a42;
} }
} }
} }
.list { .list {
display: flex; display: flex;
align-items: flex-start; align-items: flex-start;
margin-bottom: 9.6px; margin-bottom: 9.6px;
&:last-child { &:last-child {
margin-bottom: 0; margin-bottom: 0;
} }
.label { .label {
width: 56px; width: 56px;
font-size: 11.2px; font-size: 11.2px;
...@@ -544,6 +432,7 @@ export default { ...@@ -544,6 +432,7 @@ export default {
line-height: 17.6px; line-height: 17.6px;
font-weight: 400; font-weight: 400;
} }
.content { .content {
flex: 1; flex: 1;
word-wrap: break-word; word-wrap: break-word;
...@@ -553,6 +442,7 @@ export default { ...@@ -553,6 +442,7 @@ export default {
font-weight: 400; font-weight: 400;
display: flex; display: flex;
flex-wrap: nowrap; flex-wrap: nowrap;
// justify-content: space-between; // justify-content: space-between;
.image-item { .image-item {
width: 57.6px; width: 57.6px;
...@@ -566,5 +456,5 @@ export default { ...@@ -566,5 +456,5 @@ export default {
} }
} }
} }
} }
</style> </style>
\ No newline at end of file
...@@ -2,44 +2,59 @@ ...@@ -2,44 +2,59 @@
<!-- 机房巡检操作 --> <!-- 机房巡检操作 -->
<view> <view>
<view v-for="(item, index) in itemData.detail" :key="index"> <view v-for="(item, index) in itemData.detail" :key="index">
<view v-if="index==0" class="form-item">
<text class="form-label"><text class="required" v-if="item.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 && index==0">
<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>
<template v-if="index==1">
<view class="form-item"> <view class="form-item">
<text class="form-label" <text class="form-label"><text class="required" v-if="item.required"></text>{{ item.label }}</text>
><text class="required"></text>{{ item.label }}</text <text :class="['conclusion', { 'no-text': !item.conclusion }]" @click="showPopup(item, index)">
> {{ item.conclusion || "请输入情况摘要" }}</text>
<text
:class="['conclusion', { 'no-text': !item.conclusion }]"
@click="showPopup(item, index)"
>
{{ item.conclusion || "请输入情况摘要" }}</text
>
</view> </view>
<view class="form-item"> <view class="form-item">
<text class="form-label"><text class="required"></text>现场照片</text> <text class="form-label"><text class="required"></text>现场照片</text>
<CommonUpload <CommonUpload v-model="item.photos" :max-count="9999" @input="onPhotoChange">
v-model="item.photos" <template #tip>
:max-count="9999" <div></div>
@input="onPhotoChange" </template>
>
<template #tip><div></div></template>
</CommonUpload> </CommonUpload>
</view> </view>
</template>
</view> </view>
<custom-popup <custom-popup ref="customPopup" :inspectionItem="inspectionItem" @confirm="handlePopupConfirm">
ref="customPopup"
:inspectionItem="inspectionItem"
@confirm="handlePopupConfirm"
>
</custom-popup> </custom-popup>
</view> </view>
</template> </template>
<script> <script>
import CommonUpload from "@/components/CommonUpload/index.vue"; import CommonUpload from "@/components/CommonUpload/index.vue";
import customPopup from "./customPopup.vue"; import customPopup from "./customPopup.vue";
import _ from "lodash"; import _ from "lodash";
import mixin from "./mixin"; import mixin from "./mixin";
export default { export default {
mixins: [mixin], mixins: [mixin],
components: { components: {
CommonUpload, CommonUpload,
...@@ -69,12 +84,21 @@ export default { ...@@ -69,12 +84,21 @@ export default {
photos: [], photos: [],
// 父组件传递的数据 // 父组件传递的数据
itemData: { itemData: {
isValid: true, // true是不校验 isValid: false, // true是不校验
status: 0, //0是未巡检 1是已巡检 2巡检异常 status: 0, //0是未巡检 1是已巡检 2巡检异常
statusLabel: "未巡检", statusLabel: "未巡检",
inspectionItem: "", //巡检事项 inspectionItem: "", //巡检事项
detail: [ detail: [{
required: true,
label: "水箱",
inspectionResult: "",
inspectionResultLable: "正常",
lableArr: ["正常", "异常"],
conclusion: "",
photos: [],
},
{ {
required: false,
label: "其他问题", label: "其他问题",
inspectionResult: 0, inspectionResult: 0,
inspectionResultLable: "正常", inspectionResultLable: "正常",
...@@ -101,10 +125,6 @@ export default { ...@@ -101,10 +125,6 @@ export default {
}, },
mounted() {}, mounted() {},
methods: { methods: {
// 设置巡检结论
setInspectionResult(index, value) {
this.itemData.detail[index].inspectionResult = value; // 0正常 1异常
},
// 处理弹窗确认 // 处理弹窗确认
handlePopupConfirm(summary) { handlePopupConfirm(summary) {
this.itemData.detail[this.currentIndex].conclusion = summary; // 回显到文字显示区域 this.itemData.detail[this.currentIndex].conclusion = summary; // 回显到文字显示区域
...@@ -112,12 +132,41 @@ export default { ...@@ -112,12 +132,41 @@ export default {
// 处理】数据 // 处理】数据
getFromData() { getFromData() {
this.itemData.inspectionItem = this.inspectionItem; this.itemData.inspectionItem = this.inspectionItem;
console.log(222, this.itemData); const {isValid, status, statusLabel} = this.validForm(this.itemData.detail);
// 全都是正常 this.itemData.isValid = isValid;
this.itemData.status = 1; //1表示已经巡检过没有异常 this.itemData.status = status
this.itemData.statusLabel = "已巡检"; this.itemData.statusLabel = statusLabel
return this.itemData; return this.itemData;
}, },
validForm(list) {
let isValid = list.every(item => this.validFormItem(item))
let status = list.some(item => item.inspectionResult === 1 && item.required) ? 2: 1;
let statusLabel = isValid ? '已巡检' : '未巡检'
const ret = {
isValid, // 必填 false 不通过 true 通过
status, // 1 正常 2 异常
statusLabel // 已巡检 | 未巡检
}
console.log('validForm', ret)
return ret;
},
validFormItem(item) {
if(item.required) {
if (item.inspectionResult === 1) {
// 如果 inspectionResult 为 1,检查 conclusion 和 photos
if (!item.conclusion || item.photos.length === 0) {
return false;
} else {
return true
}
} else {
return true
}
} else {
return true
}
},
// 数据校验方法 true说明有未填项 // 数据校验方法 true说明有未填项
areAllObjectsValid(arr) { areAllObjectsValid(arr) {
for (let i = 0; i < arr.length; i++) { for (let i = 0; i < arr.length; i++) {
...@@ -154,13 +203,13 @@ export default { ...@@ -154,13 +203,13 @@ export default {
return arr.every((obj) => obj.inspectionResult === 0); return arr.every((obj) => obj.inspectionResult === 0);
}, },
onPhotoChange(val) { onPhotoChange(val) {
this.itemData.detail[this.currentIndex].photos = val; this.itemData.detail[1].photos = val;
}, },
}, },
}; };
</script> </script>
<style scoped lang="less"> <style scoped lang="less">
.form-item { .form-item {
display: flex; display: flex;
align-items: center; align-items: center;
padding: 9.6px 0; padding: 9.6px 0;
...@@ -179,14 +228,17 @@ export default { ...@@ -179,14 +228,17 @@ export default {
margin-right: 3.2px; margin-right: 3.2px;
} }
} }
.conclusion { .conclusion {
&.no-text { &.no-text {
color: #c7c7c7; color: #c7c7c7;
} }
.have { .have {
color: #000; color: #000;
} }
} }
.label { .label {
font-size: 11.2px; font-size: 11.2px;
} }
...@@ -272,5 +324,5 @@ export default { ...@@ -272,5 +324,5 @@ export default {
text-align: center; text-align: center;
line-height: 51.2px; line-height: 51.2px;
} }
} }
</style> </style>
\ No newline at end of file
...@@ -3,58 +3,42 @@ ...@@ -3,58 +3,42 @@
<view> <view>
<view v-for="(item, index) in itemData.detail" :key="index"> <view v-for="(item, index) in itemData.detail" :key="index">
<view class="form-item"> <view class="form-item">
<text class="form-label" <text class="form-label"><text class="required">*</text>{{ item.label }}</text>
><text class="required">*</text>{{ item.label }}</text
>
<view class="switch-container"> <view class="switch-container">
<view <view :class="['status-btn', { active: item.inspectionResult === 0 }]"
:class="['status-btn', { active: item.inspectionResult === 0 }]" @click="setInspectionResult(index, 0, item.lableArr[0])">
@click="setInspectionResult(index, 0, item.lableArr[0])"
>
{{ item.lableArr[0] }} {{ item.lableArr[0] }}
</view> </view>
<view <view :class="['status-btn', { active: item.inspectionResult === 1 }]"
:class="['status-btn', { active: item.inspectionResult === 1 }]" @click="setInspectionResult(index, 1, item.lableArr[1])">
@click="setInspectionResult(index, 1, item.lableArr[1])"
>
{{ item.lableArr[1] }} {{ item.lableArr[1] }}
</view> </view>
</view> </view>
</view> </view>
<template v-if="item.inspectionResult === 1"> <template v-if="item.inspectionResult === 1">
<view class="form-item"> <view class="form-item">
<text class="form-label" <text class="form-label"><text class="required">*</text>情况摘要</text>
><text class="required">*</text>情况摘要</text <text :class="['conclusion', { 'no-text': !item.conclusion }]" @click="showPopup(item, index)">
> {{ item.conclusion || "请输入情况摘要" }}</text>
<text
:class="['conclusion', { 'no-text': !item.conclusion }]"
@click="showPopup(item, index)"
>
{{ item.conclusion || "请输入情况摘要" }}</text
>
</view> </view>
<view class="form-item"> <view class="form-item">
<text class="form-label" <text class="form-label"><text class="required">*</text>现场照片</text>
><text class="required">*</text>现场照片</text
>
<CommonUpload v-model="item.photos" :max-count="5"> <CommonUpload v-model="item.photos" :max-count="5">
</CommonUpload> </view </CommonUpload>
></template> </view </view>
><custom-popup </template>
ref="customPopup" </view><custom-popup ref="customPopup" :inspectionItem="inspectionItem"
:inspectionItem="inspectionItem" @confirm="handlePopupConfirm"></custom-popup>
@confirm="handlePopupConfirm"
></custom-popup>
</view> </view>
</template> </template>
<script> <script>
import CommonUpload from "@/components/CommonUpload/index.vue"; import CommonUpload from "@/components/CommonUpload/index.vue";
import customPopup from "./customPopup.vue"; import customPopup from "./customPopup.vue";
import _ from "lodash"; import _ from "lodash";
import mixin from "./mixin"; import mixin from "./mixin";
export default { export default {
components: { components: {
CommonUpload, CommonUpload,
customPopup, customPopup,
...@@ -86,8 +70,7 @@ export default { ...@@ -86,8 +70,7 @@ export default {
status: 0, //0是未巡检 1是已巡检 2巡检异常 status: 0, //0是未巡检 1是已巡检 2巡检异常
statusLabel: "未巡检", statusLabel: "未巡检",
inspectionItem: "", //巡检事项 inspectionItem: "", //巡检事项
detail: [ detail: [{
{
label: "地板、墙壁破损", label: "地板、墙壁破损",
inspectionResult: "", inspectionResult: "",
inspectionResultLable: "正常", inspectionResultLable: "正常",
...@@ -174,22 +157,22 @@ export default { ...@@ -174,22 +157,22 @@ export default {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
plus.io.resolveLocalFileSystemURL( plus.io.resolveLocalFileSystemURL(
filePath, filePath,
function (entry) { function(entry) {
entry.file( entry.file(
function (file) { function(file) {
const reader = new plus.io.FileReader(); const reader = new plus.io.FileReader();
reader.onloadend = function (evt) { reader.onloadend = function(evt) {
const base64 = evt.target.result; // 获取 Base64 数据 const base64 = evt.target.result; // 获取 Base64 数据
resolve(base64); // 返回 Base64 数据 resolve(base64); // 返回 Base64 数据
}; };
reader.readAsDataURL(file); // 读取文件并转换为 Base64 reader.readAsDataURL(file); // 读取文件并转换为 Base64
}, },
function (error) { function(error) {
reject("获取文件对象失败:" + error.message); reject("获取文件对象失败:" + error.message);
} }
); );
}, },
function (error) { function(error) {
reject("解析文件路径失败:" + error.message); reject("解析文件路径失败:" + error.message);
} }
); );
...@@ -265,14 +248,26 @@ export default { ...@@ -265,14 +248,26 @@ export default {
} }
if (hasEmpty) { if (hasEmpty) {
return { statusLabel: "未巡检", status: 0 }; return {
statusLabel: "未巡检",
status: 0
};
} else if (allZero) { } else if (allZero) {
return { statusLabel: "已巡检", status: 1 }; return {
statusLabel: "已巡检",
status: 1
};
} else if (hasOne) { } else if (hasOne) {
return { statusLabel: "巡检异常", status: 2 }; return {
statusLabel: "巡检异常",
status: 2
};
} else { } else {
// 默认情况,可以根据需求调整 // 默认情况,可以根据需求调整
return { statusLabel: "未巡检", status: 0 }; return {
statusLabel: "未巡检",
status: 0
};
} }
}, },
setNormal() { setNormal() {
...@@ -281,10 +276,10 @@ export default { ...@@ -281,10 +276,10 @@ export default {
}); });
}, },
}, },
}; };
</script> </script>
<style scoped lang="less"> <style scoped lang="less">
.form-item { .form-item {
display: flex; display: flex;
align-items: center; align-items: center;
padding: 9.6px 0; padding: 9.6px 0;
...@@ -303,14 +298,17 @@ export default { ...@@ -303,14 +298,17 @@ export default {
margin-right: 3.2px; margin-right: 3.2px;
} }
} }
.conclusion { .conclusion {
&.no-text { &.no-text {
color: #c7c7c7; color: #c7c7c7;
} }
.have { .have {
color: #000; color: #000;
} }
} }
.label { .label {
font-size: 11.2px; font-size: 11.2px;
} }
...@@ -396,5 +394,5 @@ export default { ...@@ -396,5 +394,5 @@ export default {
text-align: center; text-align: center;
line-height: 51.2px; line-height: 51.2px;
} }
} }
</style> </style>
\ No newline at end of file
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论