提交 19d9eb70 authored 作者: caodi\cd's avatar caodi\cd

fix:井道巡检编辑

上级 4952c520
......@@ -64,7 +64,7 @@ export default {
? `/pages/inspectionContent/inspectionContent?isDisable=${
this.isDisable ? 1 : 0
}`
: `/pages/shaftInspection/shaftInspection?isDisable=${
: `/pages/shaftInspection/shaftInspectionNew?isDisable=${
this.isDisable ? 1 : 0
}`;
......
<template>
<view class="inspect-item" @click="toPage">
<view
class="content"
:class="details.synchronization == 1 ? 'synchronization' : ''"
>
<view class="name">{{ getLabel(details.inspectionType) }}</view>
<view class="info">
<view class="info-row">
<text class="title">{{ details.recordName }}</text>
<text class="status">{{
details.synchronization == 0 ? "待同步" : "已同步"
}}</text>
<view v-if="details.isException == 1" class="status alarm">
<text class="iconfont icon-yichang1"></text>
<text>有异常</text></view
>
</view>
<view class="info-row info-row-code">
<text>编号:</text>
<text class="code-num">{{ details.inspectionCode }}</text>
</view>
</view>
<view class="img">
<image
v-if="details.synchronization == 1"
class="bg-img"
src="../../static/img/add-img/default.png"
></image>
<image
v-else
class="bg-img"
src="../../static/img/add-img/active.png"
></image>
</view>
</view>
</view>
</template>
<script>
import { pad_inspection_type } from "@/utils/dict.js";
export default {
props: {
details: {
type: Object,
},
isDisable: {
type: Boolean,
},
},
methods: {
getLabel(val) {
const temp =
(
pad_inspection_type.rows.filter((item) => item.dictValue == val)[0] ||
{}
).dictLabel || "";
return temp.length ? temp.slice(0, 2) : "";
},
toPage() {
const url =
this.details.inspectionType == 1
? `/pages/inspectionContent/inspectionContent?isDisable=${
this.isDisable ? 1 : 0
}`
: `/pages/shaftInspection/shaftInspection?isDisable=${
this.isDisable ? 1 : 0
}`;
uni.navigateTo({
url: `${url}&uid=${this.details.uid}`,
});
},
},
};
</script>
<style scoped lang="less">
.inspect-item {
width: 50%;
padding-right: 16px;
margin-bottom: 16px;
.content {
background: #fff;
border: 0.4px solid rgba(224, 224, 224, 1);
border-radius: 12px;
padding: 18px 16px 14px 10px;
display: flex;
align-items: center;
height: 84px;
box-sizing: border-box;
position: relative;
background-image: linear-gradient(-67deg, #ffab2423, #ffab2411 50%);
.name {
background: #ffab2423;
border-radius: 12px;
width: 54px;
height: 54px;
margin-right: 10px;
display: flex;
justify-content: center;
align-items: center;
color: #f39800;
}
.info {
.info-row {
display: flex;
align-items: center;
margin-bottom: 8px;
&:last-of-type {
margin: 0;
}
.title {
font-size: 12px;
color: #000000;
font-weight: bold;
margin-right: 8px;
}
.status {
padding: 2px 4px;
font-size: 12px;
color: #ffffff;
text-align: center;
line-height: 20px;
font-weight: 400;
background: #ffab24;
border-radius: 3px;
}
.alarm {
margin-left: 8px;
background: rgba(255, 105, 82, 0.1);
font-size: 12px;
color: #ff6952;
text-align: center;
line-height: 20px;
font-weight: 400;
}
}
.info-row-code {
font-size: 14px;
color: #7c7c7c;
font-weight: 400;
.code-num {
font-size: 14px;
color: #000000;
font-weight: 400;
}
}
}
.img {
position: absolute;
right: 0;
top: 50%;
transform: translateY(-50%);
.bg-img {
width: 80px;
height: 80px;
}
}
}
.synchronization {
background-image: linear-gradient(-67deg, #9c9c9c16, #9c9c9c09 50%);
.name {
background: #9c9c9c16;
border-radius: 12px;
color: #4a4a4a;
}
.status {
background: #9c9c9c16 !important;
color: #4a4a4a !important;
}
}
}
</style>
<template>
<view class="inspection-management">
<!-- 搜索项 -->
<SearchCom @change="change" />
<!-- 结果 -->
<view class="inspection-management-content">
<view class="count-tatal">
<text class="num">{{ countNum || 0 }}</text>
<text>查询结果</text>
</view>
<view class="month-list">
<!-- 每月记录 -->
<view
class="month-record-item"
v-for="(item, index) in list"
:key="index"
>
<view v-if="(item.list || []).length" class="seconed-title">
{{ item.submitTime || item.time}}
</view>
<view class="inspect-list">
<InspectionItem
v-for="ele in item.list"
:key="ele.uid"
:details="ele"
/>
</view>
</view>
<Empty v-if="list.length == 0" />
</view>
</view>
<!-- 开始巡检 -->
<view class="inspection-button" @click="toPage"
>开始巡检</view
>
</view>
</template>
<script>
import SearchCom from "@/components/searchCom/index.vue";
import InspectionItem from "@/components/inspectionItem/index.vue";
import { getDarft } from "@/request/index.js";
import { getAllInspections } from "@/request/index.js";
import Empty from "@/components/empty/index.vue";
export default {
components: {
SearchCom,
InspectionItem,
Empty,
},
data() {
return {
isDialog: false, //
list: [], // 展示数据
all_data: [], // 所有数据
searchForm: {
// 搜索条件
},
countNum: 0, // 统计查询总数
};
},
mounted() {
uni.showLoading();
getAllInspections()
.then((res) => {
this.all_data = res;
this.init();
uni.hideLoading();
})
.catch((error) => {
if (0 == error.code) {
uni.showToast({
title: error.msg,
icon: "none",
duration: 1000,
});
}
this.all_data = [];
uni.hideLoading();
});
},
computed: {
userInfo() {
return this.$store.state.now_user || {};
},
},
methods: {
init() {
const all_data = this.all_data || [];
const { inspectionTime = [] } = this.searchForm;
const startTime = inspectionTime[0];
const endTime = inspectionTime[1];
// 第一步: 筛选有效的时间范围
const timeFrame = all_data.filter((item) => {
if (!inspectionTime.length) {
return true;
} else {
return (
new Date(startTime).getTime() <= new Date(item.submitTime).getTime() &&
new Date(item.submitTime).getTime() <= new Date(endTime).getTime()
);
}
});
// 属于同一个月的数据 聚合
const tempAllData = {};
timeFrame.forEach((item) => {
const val = tempAllData[item.submitMonth] || [];
if (val.length) {
tempAllData[item.submitMonth].push(item);
} else {
tempAllData[item.submitMonth] = [item];
}
});
const keys = Object.keys(tempAllData);
// 第二步: 根据搜索条件过滤
const list = keys.map((key) => {
return {
time: key,
list: this.coverData(tempAllData[key]),
};
});
this.countNum = 0;
list.forEach((item) => {
this.countNum += item.list.length;
});
this.list = list;
},
coverData(arr = []) {
const {
isException = "",
inspectionType = "",
synchronization = "",
} = this.searchForm;
return arr.filter((item) => {
return (
( !isException || isException =="all" || item.isException == isException) &&
( !inspectionType || inspectionType =="all" || item.inspectionType == inspectionType) &&
( !synchronization || synchronization =="all" || item.synchronization == synchronization)
);
});
},
change(e) {
this.searchForm = e;
this.init();
},
toPage() {
uni.showLoading();
getDarft()
.then((res) => {
const darf_data = res || {};
if (darf_data.inspectionType == 1) {
uni.navigateTo({
url: `/pages/inspectionContent/inspectionContent?isDarf=1`,
});
} else if (darf_data.inspectionType == 2) {
uni.navigateTo({
url: `/pages/shaftInspection/shaftInspection?isDarf=1`,
});
} else {
uni.navigateTo({
url: "/pages/inspection/inspFirst",
});
}
uni.hideLoading();
})
.catch((error) => {
if (error.code == 0) {
uni.showToast({
title: error.msg,
icon: "none",
duration: 1000,
});
}
uni.navigateTo({
url: "/pages/inspection/inspFirst",
});
uni.hideLoading();
});
},
},
};
</script>
<style scoped lang="less">
.inspection-management {
padding-top: 16px;
.count-tatal {
margin: 16px 0 8px 0;
font-size: 14px;
color: #4a4a4a;
font-weight: 400;
.num {
font-size: 18px;
color: #3774f6;
line-height: 26px;
font-weight: 600;
margin-right: 5px;
}
}
.inspection-management-content {
.month-list {
height: calc(100vh - 26px - 16px - 8px - 36px - 62px);
overflow: auto;
padding-bottom: 140px;
.seconed-title {
margin-top: 16px;
font-size: 18px;
color: #000000;
font-weight: bold;
}
.month-record-item {
margin-bottom: 24px;
&:last-of-type {
margin: 0;
}
.inspect-list {
display: flex;
flex-wrap: wrap;
}
}
}
}
.inspection-button {
display: flex;
align-items: center;
justify-content: center;
position: fixed;
bottom: 60px;
width: 240px;
height: 48px;
left: 50%;
color: #fff;
transform: translateX(-50%);
background-image: linear-gradient(180deg, #3773f6 0%, #2c57f6 99%);
box-shadow: 0px 10px 24px 0px rgba(51, 104, 246, 0.24);
border-radius: 27px;
}
}
</style>
......@@ -15,7 +15,7 @@
<text class="title">巡检井道:</text>
<text class="location">{{ location }}{{floor}}</text>
<button class="submit-btn" :class="{ active: isSubmitEnabled }" :disabled="!isSubmitEnabled" @click="submit">
提交
完成当前机房全部巡检
</button>
</view>
</view>
......@@ -52,13 +52,13 @@
</view>
<view class="form-item">
<text class="form-label"><text class="required">*</text>情况摘要:</text>
<input v-model="list[activeTab].conclusion" placeholder="请输入情况摘要" class="input-box" />
<input v-model="list[activeTab]&&list[activeTab].conclusion" placeholder="请输入情况摘要" class="input-box" />
</view>
<view class="form-item">
<text class="form-label">现场照片:</text>
<text class="photo-limit">(最多5张)</text>
<view class="photo-container">
<view v-for="(photo, index) in list[activeTab].photos" :key="index" class="photo-item">
<view v-for="(photo, index) in list[activeTab]&&list[activeTab].photos" :key="index" class="photo-item">
<image :src="photo" class="photo"></image>
<text class="delete-photo" @click="deletePhoto(index)">×</text>
</view>
......@@ -122,6 +122,7 @@
location: "A座", // 从上一个页面带过来的位置
floor: "2楼", // 从上一个页面带过来的位置
isSubmitEnabled: false, // 提交按钮是否可点击
uid: "",
randomDescription: "这是一段随机说明文字。", // 随机说明文字
tabs: [{
label: "门禁",
......@@ -160,9 +161,40 @@
// return !uid || (uid && createByName == this.userInfo.user);
// },
},
onLoad() {
this.loadHistoryData();
onLoad(options) {
this.coverlist();
this.isDisable = options.isDisable == 1 ? true : false;
this.uid = options.uid
console.log("options", options)
if (options.uid) {
this.getDetails(options.uid);
} else if (options.isDarf) {
// 获取草稿数据
uni.showLoading();
getDarft()
.then((res) => {
console.log("res", res)
const darf_data = res || {};
this.baseInfo = darf_data.originData.baseInfo;
this.list = darf_data.originData.tempForm;
this.detailsInfo = darf_data;
uni.hideLoading();
this.init();
})
.catch((error) => {
uni.showToast({
title: error.msg,
icon: "none",
duration: 1000,
});
uni.hideLoading();
});
}
},
watch: {},
mounted() {
this.init();
},
......@@ -171,7 +203,7 @@
init() {
return new Promise((resolve, reject) => {
// 判断是否有回显数据
if (this.detailsInfo && this.detailsInfo.inspectionType) {} else {
if (!this.uid) {
// 基础数据
this.baseInfo = {
inspectionType: "2",
......@@ -190,11 +222,34 @@
items: [],
};
}
console.log(2222, this.baseInfo)
this.coverlist();
console.log(2222, this.baseInfo, this.list, this.detailsInfo)
resolve();
});
},
// 回显数据
getDetails(uid) {
uni.showLoading();
getInspectionDetails(uid)
.then((res) => {
const detailsInfo = res;
console.log("getDetails", res)
this.baseInfo = detailsInfo.originData.baseInfo;
this.list = detailsInfo.originData.tempForm;
this.detailsInfo = detailsInfo;
this.isDisable = this.isDisable || detailsInfo.synchronization == 1; // 是否禁用 1:已同步数据 0: 未同步数据
uni.hideLoading();
this.isSubmitEnabled = this.isAllTabValid()
})
.catch((error) => {
uni.showToast({
title: error.msg,
icon: "none",
duration: 1000,
});
uni.hideLoading();
});
},
// 加载历史数据
loadHistoryData() {
const history = uni.getStorageSync("inspectionHistory");
......@@ -281,6 +336,31 @@
console.log("getParams,data", data)
return data;
},
// 检查所有Tab 的必填项是否填写完整
isAllTabValid() {
const data = this.list
// 校验函数
const validateData = (data) => {
return data.every(
(item) =>
item.inspectionResult !== null && item.conclusion.trim() !== ""
);
};
// 调用校验函数
const isValid = validateData(data);
console.log(141, isValid)
return isValid
},
// 检查当前 Tab 的必填项是否填写完整
isCurrentTabValid() {
const currentTabData = this.list[this.activeTab];
console.log("currentTabData", currentTabData)
return (
currentTabData.inspectionResult !== null && // 巡检结论必填
currentTabData.conclusion.trim() !== "" // 情况摘要必填
// 现场照片为非必填项,不做校验
);
},
// 暂存
saveDraft(isSave = true) {
return new Promise((resolve, reject) => {
......@@ -319,32 +399,23 @@
resolve();
});
},
// 检查当前 Tab 的必填项是否填写完整
isCurrentTabValid() {
const data = this.list
// 校验函数
const validateData = (data) => {
return data.every(
(item) =>
item.inspectionResult !== null && item.conclusion.trim() !== ""
);
};
// 调用校验函数
const isValid = validateData(data);
console.log(141, isValid)
return isValid
},
// 完成
complete() {
this.saveDraft().then(() => {
if (this.isCurrentTabValid()) {
this.isSubmitEnabled = true
this.isSubmitEnabled = this.isAllTabValid()
if (this.isCurrentTabValid()) {
// 暂存All
this.saveDraft().then(() => {
if (this.isSubmitEnabled) {
this.openPopup()
}
})
} else {
uni.showToast({
title: "请填写完整必填项",
icon: "none",
});
}
} else {
this.isSubmitEnabled = false
this.openPopup()
}
})
},
// 提交
......@@ -356,10 +427,18 @@
}
const params = this.getParams(); //数据获取
const all_data = this.$store.state.all_data; //获取全部数据
const uid = ""
params.isSubmit = 1; //修改提交状态
let logContent = "";
if (uid) {
if (this.uid) {
const index = all_data.findIndex((element) => element.uid == this.uid);
params.uid = this.uid;
all_data[index] = params;
logContent = getLogContent(
LOG_TYPE_ENUM.edit,
`${params.recordName}(${params.inspectionCode})`,
"巡检模块"
);
} {
params.uid = new Date().getTime(); // 唯一标识 pad 端使用
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论