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

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

上级 89406c09
......@@ -2,8 +2,8 @@
"name" : "杭州内网机房巡检",
"appid" : "__UNI__A11BFD5",
"description" : "",
"versionName" : "1.0.2",
"versionCode" : 102,
"versionName" : "1.0.3",
"versionCode" : 103,
"transformPx" : false,
/* 5+App特有相关 */
"app-plus" : {
......
......@@ -2,44 +2,59 @@
<!-- 机房巡检操作 -->
<view>
<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">
<text class="form-label"
><text class="required"></text>{{ item.label }}</text
>
<text
:class="['conclusion', { 'no-text': !item.conclusion }]"
@click="showPopup(item, index)"
>
{{ item.conclusion || "请输入情况摘要" }}</text
>
<text class="form-label"><text class="required" v-if="item.required"></text>{{ item.label }}</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="9999"
@input="onPhotoChange"
>
<template #tip><div></div></template>
<CommonUpload v-model="item.photos" :max-count="9999" @input="onPhotoChange">
<template #tip>
<div></div>
</template>
</CommonUpload>
</view>
</template>
</view>
<custom-popup
ref="customPopup"
:inspectionItem="inspectionItem"
@confirm="handlePopupConfirm"
>
<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 CommonUpload from "@/components/CommonUpload/index.vue";
import customPopup from "./customPopup.vue";
import _ from "lodash";
import mixin from "./mixin";
export default {
import mixin from "./mixin";
export default {
mixins: [mixin],
components: {
CommonUpload,
......@@ -69,12 +84,21 @@ export default {
photos: [],
// 父组件传递的数据
itemData: {
isValid: true, // true是不校验
isValid: false, // true是不校验
status: 0, //0是未巡检 1是已巡检 2巡检异常
statusLabel: "未巡检",
inspectionItem: "", //巡检事项
detail: [
detail: [{
required: true,
label: "水箱",
inspectionResult: "",
inspectionResultLable: "正常",
lableArr: ["正常", "异常"],
conclusion: "",
photos: [],
},
{
required: false,
label: "其他问题",
inspectionResult: 0,
inspectionResultLable: "正常",
......@@ -101,10 +125,6 @@ export default {
},
mounted() {},
methods: {
// 设置巡检结论
setInspectionResult(index, value) {
this.itemData.detail[index].inspectionResult = value; // 0正常 1异常
},
// 处理弹窗确认
handlePopupConfirm(summary) {
this.itemData.detail[this.currentIndex].conclusion = summary; // 回显到文字显示区域
......@@ -112,12 +132,41 @@ export default {
// 处理】数据
getFromData() {
this.itemData.inspectionItem = this.inspectionItem;
console.log(222, this.itemData);
// 全都是正常
this.itemData.status = 1; //1表示已经巡检过没有异常
this.itemData.statusLabel = "已巡检";
const {isValid, status, statusLabel} = this.validForm(this.itemData.detail);
this.itemData.isValid = isValid;
this.itemData.status = status
this.itemData.statusLabel = statusLabel
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说明有未填项
areAllObjectsValid(arr) {
for (let i = 0; i < arr.length; i++) {
......@@ -154,13 +203,13 @@ export default {
return arr.every((obj) => obj.inspectionResult === 0);
},
onPhotoChange(val) {
this.itemData.detail[this.currentIndex].photos = val;
this.itemData.detail[1].photos = val;
},
},
};
};
</script>
<style scoped lang="less">
.form-item {
.form-item {
display: flex;
align-items: center;
padding: 9.6px 0;
......@@ -179,14 +228,17 @@ export default {
margin-right: 3.2px;
}
}
.conclusion {
&.no-text {
color: #c7c7c7;
}
.have {
color: #000;
}
}
.label {
font-size: 11.2px;
}
......@@ -272,5 +324,5 @@ export default {
text-align: center;
line-height: 51.2px;
}
}
}
</style>
\ No newline at end of file
......@@ -3,58 +3,42 @@
<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
>
<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])"
>
<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])"
>
<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
>
<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
>
<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>
</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";
import CommonUpload from "@/components/CommonUpload/index.vue";
import customPopup from "./customPopup.vue";
import _ from "lodash";
import mixin from "./mixin";
export default {
export default {
components: {
CommonUpload,
customPopup,
......@@ -86,8 +70,7 @@ export default {
status: 0, //0是未巡检 1是已巡检 2巡检异常
statusLabel: "未巡检",
inspectionItem: "", //巡检事项
detail: [
{
detail: [{
label: "地板、墙壁破损",
inspectionResult: "",
inspectionResultLable: "正常",
......@@ -174,22 +157,22 @@ export default {
return new Promise((resolve, reject) => {
plus.io.resolveLocalFileSystemURL(
filePath,
function (entry) {
function(entry) {
entry.file(
function (file) {
function(file) {
const reader = new plus.io.FileReader();
reader.onloadend = function (evt) {
reader.onloadend = function(evt) {
const base64 = evt.target.result; // 获取 Base64 数据
resolve(base64); // 返回 Base64 数据
};
reader.readAsDataURL(file); // 读取文件并转换为 Base64
},
function (error) {
function(error) {
reject("获取文件对象失败:" + error.message);
}
);
},
function (error) {
function(error) {
reject("解析文件路径失败:" + error.message);
}
);
......@@ -265,14 +248,26 @@ export default {
}
if (hasEmpty) {
return { statusLabel: "未巡检", status: 0 };
return {
statusLabel: "未巡检",
status: 0
};
} else if (allZero) {
return { statusLabel: "已巡检", status: 1 };
return {
statusLabel: "已巡检",
status: 1
};
} else if (hasOne) {
return { statusLabel: "巡检异常", status: 2 };
return {
statusLabel: "巡检异常",
status: 2
};
} else {
// 默认情况,可以根据需求调整
return { statusLabel: "未巡检", status: 0 };
return {
statusLabel: "未巡检",
status: 0
};
}
},
setNormal() {
......@@ -281,10 +276,10 @@ export default {
});
},
},
};
};
</script>
<style scoped lang="less">
.form-item {
.form-item {
display: flex;
align-items: center;
padding: 9.6px 0;
......@@ -303,14 +298,17 @@ export default {
margin-right: 3.2px;
}
}
.conclusion {
&.no-text {
color: #c7c7c7;
}
.have {
color: #000;
}
}
.label {
font-size: 11.2px;
}
......@@ -396,5 +394,5 @@ export default {
text-align: center;
line-height: 51.2px;
}
}
}
</style>
\ No newline at end of file
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论