提交 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" : {
......
...@@ -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 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论