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

fix:井道完成

上级 38f620e9
...@@ -15,11 +15,24 @@ uni-page-head .uni-btn-icon { ...@@ -15,11 +15,24 @@ uni-page-head .uni-btn-icon {
} }
.uni-nav-bar-right-text{ .uni-nav-bar-right-text {
font-size: 14px !important; font-size: 14px !important;
} }
.uni-navbar-btn-text>text{ .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;
display: flex;
align-items: center;
justify-content: center;
text-align: center;
}
.uni-navbar-btn-text>text {
font-size: 14px !important; font-size: 14px !important;
} }
...@@ -45,7 +58,7 @@ uni-page-head .uni-btn-icon { ...@@ -45,7 +58,7 @@ uni-page-head .uni-btn-icon {
} }
.uni-navbar__header { .uni-navbar__header {
padding: 0 32px !important; padding: 0 25.6px !important;
/* padding-right: 18px !important; */ /* padding-right: 18px !important; */
} }
......
<template>
<view>
<view class="canvas-container">
<canvas canvas-id="canvas" id="canvas" :disable-scroll="true" style="width: 100%; height: 200px;background-color: #FFFFFF;"
@touchstart="handleTouchStart($event)" @touchmove="handleTouchMove($event)" @touchend="handleTouchEnd($event)"
@touchcancel="handleEnd($event)"></canvas>
</view>
<view class="btn-container">
<button class="cu-btn lg bg-blue" @click="handleConfirm()">确定</button>
<button class="cu-btn lg line-gray" @click="reset()">重置</button>
</view>
</view>
</template>
<script>
var context = null
export default {
props: {
dialogVisiable: {
type: Boolean,
default: false
}
},
data() {
return {
canvasData: []
};
},
watch: {
dialogVisiable() {
if (this.dialogVisiable === true) {
context = uni.createCanvasContext('canvas')
context.setLineWidth(3)
context.setStrokeStyle("#000000")
this.reset()
}
},
canvasData() {
context.moveTo(this.canvasData[0].x, this.canvasData[0].y)
for (let i = 0; i < this.canvasData.length; i++) {
context.lineTo(this.canvasData[i].x, this.canvasData[i].y)
}
context.stroke()
context.draw(true)
}
},
methods: {
reset() {
context.draw()
},
hideModal() {
this.$emit('update:dialogVisiable', false)
},
handleTouchStart(e) {
this.canvasData = []
const a = e.changedTouches[0]
this.canvasData.push({
x: a.x,
y: a.y
})
},
handleTouchMove(e) {
const a = e.changedTouches[0]
this.canvasData.push({
x: a.x,
y: a.y
})
},
handleTouchEnd(e) {
const a = e.changedTouches[0]
this.canvasData.push({
x: a.x,
y: a.y
})
},
handleEnd() {
context.stroke()
context.draw(true)
},
handleConfirm() {
uni.canvasToTempFilePath({
canvasId: 'canvas',
success: res => {
this.$emit('success', res.tempFilePath)
}
})
}
}
}
</script>
<style lang="scss" scoped>
.canvas-container {
width: 400px;
}
.btn-container {
padding-bottom: 20rpx;
display: flex;
justify-content: space-around;
}
</style>
import Signature from './components/jackyq-signature.vue'
export default Signature
\ No newline at end of file
<template> <template>
<!-- 巡检管理 --> <!-- 巡检管理 -->
<view class="inspection-management"> <view class="inspection-management">
<uni-nav-bar :fixed="true" background-color="rgba(214, 240, 255, 0.0)" status-bar rightWidth="300"> <uni-nav-bar
<block slot="left"> :fixed="true"
<view class="uni-nav-bar-text" @click="back"> background-color="rgba(214, 240, 255, 0.0)"
<text class="iconfont icon-Arrow-Left"></text> status-bar
</view> rightWidth="300"
</block> >
<block slot="right" class="nav-right"> <block slot="left">
<view class="header-buttons"> <view class="uni-nav-bar-text" @click="back">
<button class="button" @click="clickInspection(1)">机房巡检</button> <text class="iconfont icon-Arrow-Left"></text>
<button class="button" @click="clickInspection(2)">井道巡检</button> </view>
</view> </block>
</block> <block slot="right" class="nav-right">
</uni-nav-bar> <view class="header-buttons">
<!-- 搜索项 --> <button class="button" @click="clickInspection(1)">机房巡检</button>
<SearchCom @change="change" /> <button class="button" @click="clickInspection(2)">井道巡检</button>
</view>
<!-- 结果 --> </block>
<view class="inspection-management-content"> </uni-nav-bar>
<view class="count-tatal"> <!-- 搜索项 -->
<text class="num">{{ countNum || 0 }}</text> <SearchCom @change="change" />
<text calss="">查询结果</text>
</view> <!-- 结果 -->
<view class="inspection-management-content">
<view class="month-list"> <view class="count-tatal">
<!-- 每月记录 --> <text class="num">{{ countNum || 0 }}</text>
<view class="month-record-item" v-for="(item, index) in list" :key="index"> <text calss="">查询结果</text>
<view v-if="(item.list || []).length" class="seconed-title"> </view>
{{ item.submitTime || item.time}}
</view> <view class="month-list">
<!-- 每月记录 -->
<view class="inspect-list"> <view
<InspectionItem v-for="ele in item.list" :key="ele.uid" :details="ele" /> class="month-record-item"
</view> v-for="(item, index) in list"
</view> :key="index"
>
<Empty v-if="list.length == 0" /> <view v-if="(item.list || []).length" class="seconed-title">
</view> {{ item.submitTime || item.time }}
</view> </view>
<!-- 开始巡检 --> <view class="inspect-list">
<view class="inspection-button" @click="toPage">同步数据</view> <InspectionItem
</view> 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> </template>
<script> <script>
import SearchCom from "@/components/searchCom/index.vue"; import SearchCom from "@/components/searchCom/index.vue";
import InspectionItem from "@/components/inspectionItem/index.vue"; import InspectionItem from "@/components/inspectionItem/index.vue";
import { import { getDarft } from "@/request/index.js";
getDarft import { getAllInspections } from "@/request/index.js";
} from "@/request/index.js"; import Empty from "@/components/empty/index.vue";
import {
getAllInspections export default {
} from "@/request/index.js"; components: {
import Empty from "@/components/empty/index.vue"; SearchCom,
InspectionItem,
export default { Empty,
components: { },
SearchCom, data() {
InspectionItem, return {
Empty, isDialog: false, //
}, list: [], // 展示数据
data() { all_data: [], // 所有数据
return { searchForm: {
isDialog: false, // // 搜索条件
list: [], // 展示数据 },
all_data: [], // 所有数据 countNum: 0, // 统计查询总数
searchForm: { };
// 搜索条件 },
}, mounted() {
countNum: 0, // 统计查询总数 uni.showLoading();
};
}, getAllInspections()
mounted() { .then((res) => {
uni.showLoading(); this.all_data = res;
this.init();
getAllInspections() uni.hideLoading();
.then((res) => { })
this.all_data = res; .catch((error) => {
this.init(); if (0 == error.code) {
uni.hideLoading(); uni.showToast({
}) title: error.msg,
.catch((error) => { icon: "none",
if (0 == error.code) { duration: 1000,
uni.showToast({ });
title: error.msg, }
icon: "none", this.all_data = [];
duration: 1000, uni.hideLoading();
}); });
} },
this.all_data = []; computed: {
uni.hideLoading(); userInfo() {
}); return this.$store.state.now_user || {};
}, },
computed: { },
userInfo() { methods: {
return this.$store.state.now_user || {}; // 返回
}, back() {
uni.navigateBack();
}, },
methods: { clickInspection(type) {
// 返回 if (type == 1) {
back() { uni.navigateTo({
uni.navigateBack(); url: "/pages/shaftInspection/shaftInspectionNew",
}, });
clickInspection(type) { } else {
if (type == 1) { uni.navigateTo({
uni.navigateTo({ url: "/pages/shaftInspection/shaftInspectionNew",
url: "/pages/shaftInspection/shaftInspectionNew", });
}); }
} else { },
uni.navigateTo({ init() {
url: "/pages/shaftInspection/shaftInspectionNew", const all_data = this.all_data || [];
});
const { inspectionTime = [] } = this.searchForm;
} const startTime = inspectionTime[0];
}, const endTime = inspectionTime[1];
init() {
const all_data = this.all_data || []; // 第一步: 筛选有效的时间范围
const timeFrame = all_data.filter((item) => {
const { if (!inspectionTime.length) {
inspectionTime = [] return true;
} = this.searchForm; } else {
const startTime = inspectionTime[0]; return (
const endTime = inspectionTime[1]; new Date(startTime).getTime() <=
new Date(item.submitTime).getTime() &&
// 第一步: 筛选有效的时间范围 new Date(item.submitTime).getTime() <= new Date(endTime).getTime()
const timeFrame = all_data.filter((item) => { );
if (!inspectionTime.length) { }
return true; });
} else {
return ( // 属于同一个月的数据 聚合
new Date(startTime).getTime() <= new Date(item.submitTime).getTime() && const tempAllData = {};
new Date(item.submitTime).getTime() <= new Date(endTime).getTime() timeFrame.forEach((item) => {
); const val = tempAllData[item.submitMonth] || [];
} if (val.length) {
}); tempAllData[item.submitMonth].push(item);
} else {
tempAllData[item.submitMonth] = [item];
// 属于同一个月的数据 聚合 }
const tempAllData = {}; });
timeFrame.forEach((item) => { const keys = Object.keys(tempAllData);
const val = tempAllData[item.submitMonth] || [];
if (val.length) { // 第二步: 根据搜索条件过滤
tempAllData[item.submitMonth].push(item); const list = keys.map((key) => {
} else { return {
tempAllData[item.submitMonth] = [item]; time: key,
} list: this.coverData(tempAllData[key]),
}); };
const keys = Object.keys(tempAllData); });
// 第二步: 根据搜索条件过滤 this.countNum = 0;
const list = keys.map((key) => { list.forEach((item) => {
return { this.countNum += item.list.length;
time: key, });
list: this.coverData(tempAllData[key]),
}; this.list = list;
}); console.log("this.list", this.list);
},
this.countNum = 0;
list.forEach((item) => { coverData(arr = []) {
this.countNum += item.list.length; console.log("arr",arr)
}); const {
isException = "",
this.list = list; inspectionType = "",
console.log("this.list",this.list) synchronization = "",
}, } = this.searchForm;
coverData(arr = []) { return arr.filter((item) => {
const { return (
isException = "", (!isException ||
inspectionType = "", isException == "all" ||
synchronization = "", item.isException == isException) &&
} = this.searchForm; (!inspectionType ||
inspectionType == "all" ||
item.inspectionType == inspectionType) &&
(!synchronization ||
return arr.filter((item) => { synchronization == "all" ||
return ( item.synchronization == synchronization)
(!isException || isException == "all" || item.isException == isException) && );
(!inspectionType || inspectionType == "all" || item.inspectionType == inspectionType) && });
(!synchronization || synchronization == "all" || item.synchronization == synchronization) },
); change(e) {
}); this.searchForm = e;
},
change(e) { this.init();
this.searchForm = e; },
this.init(); toPage() {
}, uni.showLoading();
toPage() { getDarft()
uni.showLoading(); .then((res) => {
const darf_data = res || {};
getDarft()
.then((res) => { if (darf_data.inspectionType == 1) {
const darf_data = res || {}; uni.navigateTo({
url: `/pages/inspectionContent/inspectionContent?isDarf=1`,
if (darf_data.inspectionType == 1) { });
uni.navigateTo({ } else if (darf_data.inspectionType == 2) {
url: `/pages/inspectionContent/inspectionContent?isDarf=1`, uni.navigateTo({
}); url: `/pages/shaftInspection/shaftInspection?isDarf=1`,
} else if (darf_data.inspectionType == 2) { });
uni.navigateTo({ } else {
url: `/pages/shaftInspection/shaftInspection?isDarf=1`, uni.navigateTo({
}); url: "/pages/inspection/inspFirst",
} else { });
uni.navigateTo({ }
url: "/pages/inspection/inspFirst", uni.hideLoading();
}); })
} .catch((error) => {
uni.hideLoading(); if (error.code == 0) {
}) uni.showToast({
.catch((error) => { title: error.msg,
if (error.code == 0) {
uni.showToast({ icon: "none",
title: error.msg, duration: 1000,
});
icon: "none", }
duration: 1000, uni.navigateTo({
}); url: "/pages/inspection/inspFirst",
} });
uni.navigateTo({
url: "/pages/inspection/inspFirst", uni.hideLoading();
}); });
},
uni.hideLoading(); },
}); };
},
},
};
</script> </script>
<style scoped lang="less"> <style scoped lang="less">
/* 导航栏样式 */ .uni-nav-bar-text {
.uni-nav-bar-text { height: 28.8px;
height: 36px; width: 28.8px;
width: 36px; background: #ffffff;
background: #ffffff; border: 0.32px solid rgba(224, 224, 224, 1);
border: 0.4px solid rgba(224, 224, 224, 1); border-radius: 14.4px;
border-radius: 18px; color: #333;
border-radius: 50%; display: flex;
color: #333; align-items: center;
text-align: center; justify-content: center;
text-align: center;
.iconfont {
font-size: 20px; .iconfont {
line-height: 36px; font-size: 16px;
} line-height: 28.8px;
}
.nav-right {
width: 240px;
}
.header-buttons {
display: flex;
align-items: center;
margin-left: auto; // 将按钮组推到最右侧
.button {
width: 112px;
height: 36px;
background: #FFFFFF;
border-radius: 18px;
margin-left: 16px;
font-family: PingFangSC-Regular;
font-size: 16px;
color: #000000;
line-height: 36px;
font-weight: 400;
}
}
.inspection-management {
background-image: linear-gradient(115deg, #E8F0FB 0%, #E1EBFA 100%);
padding: 0 32px;
.inspection-management-content {
.count-tatal {
font-family: PingFangSC-Medium;
margin: 16px 0px 24px;
font-size: 14px;
color: #4a4a4a;
font-weight: 400;
height: 28px;
line-height: 28px;
.num {
font-size: 20px;
color: #3774f6;
line-height: 28px;
font-weight: 500;
margin-right: 2px;
}
}
.month-list {
height: calc(100vh - 26px - 16px - 8px - 36px - 62px);
overflow: auto;
padding-bottom: 140px;
.seconed-title {
font-size: 20px;
color: #000000;
line-height: 28px;
font-weight: 500;
margin-bottom: 12px;
}
.month-record-item {
margin-bottom: 24px;
&:last-of-type {
margin: 0;
}
.inspect-list {
display: flex;
flex-wrap: wrap;
justify-content: space-between;
}
}
}
}
.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> }
\ No newline at end of file .nav-right {
width: 192px;
}
.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;
border: 0;
}
}
.inspection-management {
background-image: linear-gradient(115deg, #e8f0fb 0%, #e1ebfa 100%);
padding: 0 25.6px;
.inspection-management-content {
.count-tatal {
font-family: PingFangSC-Medium;
margin: 12.8px 0px 19.2px;
font-size: 11.2px;
color: #4a4a4a;
font-weight: 400;
height: 22.4px;
line-height: 22.4px;
.num {
font-size: 16px;
color: #3774f6;
line-height: 22.4px;
font-weight: 500;
margin-right: 1.6px;
}
}
.month-list {
height: calc(100vh - 20.8px - 12.8px - 6.4px - 28.8px - 49.6px - 25px);
overflow: auto;
// padding-bottom: 112px;
.seconed-title {
font-size: 16px;
color: #000000;
line-height: 22.4px;
font-weight: 500;
margin-bottom: 9.6px;
}
.month-record-item {
margin-bottom: 19.2px;
&:last-of-type {
margin: 0;
}
.inspect-list {
display: flex;
flex-wrap: wrap;
justify-content: space-between;
}
}
}
}
.inspection-button {
display: flex;
align-items: center;
justify-content: center;
position: fixed;
bottom: 48px;
width: 192px;
height: 38.4px;
left: 50%;
color: #fff;
transform: translateX(-50%);
background-image: linear-gradient(180deg, #3773f6 0%, #2c57f6 99%);
box-shadow: 0px 8px 19.2px 0px rgba(51, 104, 246, 0.24);
border-radius: 21.6px;
}
}
</style>
...@@ -325,19 +325,21 @@ export default { ...@@ -325,19 +325,21 @@ export default {
</script> </script>
<style lang="less" scoped> <style lang="less" scoped>
.uni-nav-bar-text { .uni-nav-bar-text {
height: 28.8px; height: 28.8px;
width: 28.8px; width: 28.8px;
background: #ffffff; background: #ffffff;
border: 0.32px solid rgba(224, 224, 224, 1); border: 0.32px solid rgba(224, 224, 224, 1);
border-radius: 14.4px; border-radius: 14.4px;
border-radius: 50%; color: #333;
color: #333; display: flex;
text-align: center; align-items: center;
justify-content: center;
.iconfont { text-align: center;
font-size: 16px;
line-height: 28.8px; .iconfont {
} font-size: 16px;
line-height: 28.8px;
}
} }
.nav-right { .nav-right {
......
...@@ -280,21 +280,6 @@ export default { ...@@ -280,21 +280,6 @@ export default {
<style lang="less" scoped> <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;
border-radius: 50%;
color: #333;
text-align: center;
.iconfont {
font-size: 16px;
line-height: 28.8px;
}
}
.nav-right { .nav-right {
width: 192px; width: 192px;
......
<template> <template>
<!-- 井道巡检操作 --> <!-- 井道巡检操作 -->
<view class="container"> <view class="container">
<uni-nav-bar :fixed="true" background-color="rgba(214, 240, 255, 0.0)" status-bar rightWidth="300"> <uni-nav-bar
<block slot="left"> :fixed="true"
<view class="uni-nav-bar-text" @click="back"> background-color="rgba(214, 240, 255, 0.0)"
<text class="iconfont icon-Arrow-Left"></text> status-bar
</view> rightWidth="300"
</block> >
</uni-nav-bar> <block slot="left">
<view class="profile-section"> <view class="uni-nav-bar-text" @click="back">
<view class="profile-box"> <text class="iconfont icon-Arrow-Left"></text>
<view class="profile-left"> </view>
<view class="avatar"> </block>
<image src="@/static/img/add-img/home1.png" mode="aspectFit"></image> </uni-nav-bar>
</view> <view class="profile-section">
<view class="info"> <view class="profile-box">
<view class="username">井道巡检</view> <view class="profile-left">
<view class="number">位置:<text class="value">{{ location }}</text></view> <view class="avatar">
</view> <image
</view> src="@/static/img/add-img/home1.png"
</view> mode="aspectFit"
</view> ></image>
</view>
<!-- 模块1:巡检井道 --> <view class="info">
<!-- <view class="module"> <view class="username">井道巡检</view>
<view class="title-bar"> <view class="number"
<view class="blue-line"></view> >位置:<text class="value">{{ location }}</text></view
<text class="title">巡检井道</text> >
<text class="location">{{ location }}{{floor}}</text> </view>
<button class="submit-btn" :class="{ active: isSubmitEnabled }" :disabled="!isSubmitEnabled" @click="submit"> </view>
完成当前机房全部巡检 </view>
</button> </view>
</view> <!-- 模块3:Tab 操作区域 -->
</view> --> <view class="module">
<view class="tab-buttons">
<!-- 模块2:巡检说明 --> <view
<!-- <view class="module"> v-for="(tab, index) in tabs"
<view class="title-bar"> :key="index"
<view class="blue-line"></view> :class="['tab-item', { active: activeTab === index }]"
<text class="title">巡检说明</text> @click="switchTab(index)"
</view> >
<text class="description">{{ randomDescription }}</text> <image :src="tab.icon" class="tab-icon"></image>
</view> --> <text class="tab-text">{{ tab.label }}</text>
<view v-if="activeTab === index" class="underline"></view>
<!-- 模块3:Tab 操作区域 --> </view>
<view class="module"> </view>
<view class="tab-buttons"> <view class="tip">
<view v-for="(tab, index) in tabs" :key="index" :class="['tab-item', { active: activeTab === index }]" <image
@click="switchTab(index)"> class="tip-icon"
<image :src="tab.icon" class="tab-icon"></image> src="@/static/img/add-img/home1.png"
<text class="tab-text">{{ tab.label }}</text> mode="aspectFit"
<view v-if="activeTab === index" class="underline"></view> ></image
</view> >请点击“需巡检井道”执行巡检
</view> </view>
<view class="tip"> <view class="tab-content">
<image class="tip-icon" src="@/static/img/add-img/home1.png" mode="aspectFit"></image>请点击“需巡检井道”执行巡检 <!-- 操作区域 -->
</view> <view class="form-item"
<view class="tab-content"> ><text class="form-label">巡检项</text>
<!-- 操作区域 --> <view class="label">
<view class="form-item"><text class="form-label">巡检项</text> <text>{{ tabs[activeTab].label }}</text>
<view class="label"> </view>
<text>{{ tabs[activeTab].label }}</text> </view>
</view> <view class="form-item">
</view> <text class="form-label"
<view class="form-item"> ><text class="required">*</text>巡检结论</text
<text class="form-label"><text class="required">*</text>巡检结论</text> >
<view class="switch-container"> <view class="switch-container">
<view :class="['status-btn', { active: inspectionResult === 0 }]" @click="setInspectionResult(0)"> <view
正常 :class="['status-btn', { active: inspectionResult === 0 }]"
</view> @click="setInspectionResult(0)"
<view :class="['status-btn', { active: inspectionResult === 1 }]" @click="setInspectionResult(1)"> >
异常 正常
</view> </view>
</view> <view
</view> :class="['status-btn', { active: inspectionResult === 1 }]"
@click="setInspectionResult(1)"
<view class="form-item"> >
<text class="form-label"><text class="required">*</text>情况摘要</text> 异常
<input class="input-box" v-model="list[activeTab] && list[activeTab].conclusion" placeholder="请输入情况摘要" /> </view>
</view> </view>
<view class="form-item"> </view>
<text class="form-label">现场照片</text>
<view class="photo-box"> <view class="form-item">
<view class="photo-container"> <text class="form-label"
<view @click="takePhoto" class="photo-btn"> + </view> ><text class="required">*</text>情况摘要</text
<view v-for="(photo, index) in list[activeTab] && >
list[activeTab].photos" :key="index" class="photo-item"> <input
<image :src="photo" class="photo"></image> class="input-box"
<text class="delete-photo" @click="deletePhoto(index)">×</text> v-model="list[activeTab] && list[activeTab].conclusion"
</view> placeholder="请输入情况摘要"
</view> />
<view class="photo-limit">请对检查项进行拍照留存(限5张)。发现“异常、告警”时,需拍照留存。</view> </view>
</view> <view class="form-item">
</view> <text class="form-label">现场照片</text>
</view> <view class="photo-box">
</view> <view class="photo-container">
<view @click="takePhoto" class="photo-btn"> + </view>
<!-- 模块4:提交模块 --> <view
<!-- <view class="module submit-module"> 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>
</view>
<view class="photo-limit"
>请对检查项进行拍照留存(限5张)。发现“异常、告警”时,需拍照留存。</view
>
</view>
</view>
</view>
</view>
<!-- 模块4:提交模块 -->
<!-- <view class="module submit-module">
<button class="action-btn" @click="saveDraft">暂存</button> <button class="action-btn" @click="saveDraft">暂存</button>
<button class="action-btn complete-btn" @click="complete"> <button class="action-btn complete-btn" @click="complete">
完成 完成
</button> </button>
</view> --> </view> -->
<view class="module submit-module"> <view class="submit-module">
<button class="action-btn" @click="submit(0)">暂存</button> <button class="action-btn" @click="submit(0)">暂存</button>
<button v-if="isSubmitEnabled" class="action-btn complete-btn" @click="submit"> <button
完成巡检 v-if="isSubmitEnabled"
</button> class="action-btn complete-btn"
<button v-else class="action-btn complete-btn" @click="closePopup"> @click="submit(1)"
下一项 >
</button> 完成巡检
<button class="action-btn complete-btn" @click="submit(1)">完成</button> </button>
</view> <button v-else class="action-btn complete-btn" @click="nextTab">
<!-- 使用 uni-popup 组件 完成弹窗 --> 下一项
<uni-popup ref="popup" type="center"> </button>
<view class="popup-content"> </view>
<!-- 关闭按钮 --> <!-- 使用 uni-popup 组件 完成弹窗 -->
<view class="close-icon" @click="closePopup">×</view> <uni-popup ref="popup" type="center">
<view class="popup-content">
<!-- 成功图标 --> <!-- 关闭按钮 -->
<view class="icon-success">✔️</view> <view class="close-icon" @click="closePopup">×</view>
<!-- 保存成功的文字 --> <!-- 成功图标 -->
<view class="success-text">保存成功</view> <view class="icon-success">✔️</view>
<!-- 下一项按钮 --> <!-- 保存成功的文字 -->
<view class="next-button" @click="closePopup">下一项</view> <view class="success-text">保存成功</view>
</view>
</uni-popup> <!-- 下一项按钮 -->
</view> <view class="next-button" @click="closePopup">下一项</view>
</view>
</uni-popup>
</view>
</template> </template>
<script> <script>
import { import {
pad_2_1_inspection_items, pad_2_1_inspection_items,
pad_2_1_inspection_position, pad_2_1_inspection_position,
pad_2_1_floor, pad_2_1_floor,
} from "@/utils/dict.js"; //巡检位置,A座到F座 楼层2楼4楼到26楼 } from "@/utils/dict.js"; //巡检位置,A座到F座 楼层2楼4楼到26楼
import { import {
addLog, addLog,
getLogContent, getLogContent,
LOG_TYPE_ENUM, LOG_TYPE_ENUM,
writeDarf, writeDarf,
writeInspectionData, writeInspectionData,
} from "@/utils/IoReadingAndWriting.js"; } from "@/utils/IoReadingAndWriting.js";
import { import { getInspectionDetails, getDarft } from "@/request/index.js";
getInspectionDetails, import moment from "moment";
getDarft import _ from "lodash";
} from "@/request/index.js";
import moment from "moment"; export default {
import _ from 'lodash'; data() {
return {
export default { location: "",
data() { value: "",
return { dictValue: "",
location: "", inspectionCode: "",
value: "", isSubmitEnabled: false, // 提交按钮是否可点击
dictValue: "", uid: "",
inspectionCode: "", randomDescription: "这是一段随机说明文字。", // 随机说明文字
isSubmitEnabled: false, // 提交按钮是否可点击 tabs: [
uid: "", {
randomDescription: "这是一段随机说明文字。", // 随机说明文字 label: "门禁",
tabs: [{ icon: "../../static/img/add-img/home1.png",
label: "门禁", },
icon: "../../static/img/add-img/home1.png", {
}, label: "卫生",
{ icon: "../../static/img/add-img/home1.png",
label: "卫生", },
icon: "../../static/img/add-img/home1.png", {
}, label: "设备告警",
{ icon: "../../static/img/add-img/home1.png",
label: "设备告警", },
icon: "../../static/img/add-img/home1.png", ],
}, activeTab: 0, // 当前选中的 Tab
], inspectionResult: 0, // Switch 值(0: 正常, 1: 异常)
activeTab: 0, // 当前选中的 Tab conclusion: "", // 情况摘要
inspectionResult: 0, // Switch 值(0: 正常, 1: 异常) photos: [], // 现场照片
conclusion: "", // 情况摘要 historyData: null, // 历史数据
photos: [], // 现场照片 firstSubmitTime: null, // 首次提交时间
historyData: null, // 历史数据 detailsInfo: {}, // 详情
firstSubmitTime: null, // 首次提交时间 baseInfo: {}, // 基础信息
detailsInfo: {}, // 详情 list: [], //巡检信息
baseInfo: {}, // 基础信息 };
list: [], //巡检信息 },
}; computed: {
}, userInfo() {
computed: { return this.$store.state.now_user || {};
userInfo() { },
return this.$store.state.now_user || {}; // isOperationPermissions() {
}, // // 是否有操作权限
// isOperationPermissions() { // const {
// // 是否有操作权限 // uid,
// const { // createByName
// uid, // } = this.detailsInfo;
// createByName // return !uid || (uid && createByName == this.userInfo.user);
// } = this.detailsInfo; // },
// return !uid || (uid && createByName == this.userInfo.user); },
// }, onLoad(options) {
}, this.coverlist();
onLoad(options) { this.isDisable = options.isDisable == 1 ? true : false;
this.coverlist(); this.uid = options.uid;
this.isDisable = options.isDisable == 1 ? true : false; this.location = options.location;
this.uid = options.uid; this.value = options.value;
this.location = options.location; this.dictValue = options.dictValue;
this.value = options.value; this.inspectionCode = options.inspectionCode;
this.dictValue = options.dictValue; console.log("options", options);
this.inspectionCode = options.inspectionCode;
console.log("options", options); if (options.uid) {
this.getDetails(options.uid);
if (options.uid) { } else {
this.getDetails(options.uid); this.init();
} else { }
this.init(); },
} watch: {},
}, mounted() {},
watch: {}, methods: {
mounted() {}, // 初始化
methods: { init() {
// 初始化 return new Promise((resolve, reject) => {
init() { // 判断是否有回显数据
return new Promise((resolve, reject) => { // 基础数据
// 判断是否有回显数据 this.baseInfo = {
// 基础数据 inspectionType: "2",
this.baseInfo = { inspectionCode: this.inspectionCode,
inspectionType: "2", recordName: `${moment().format("yyyyMMDD")}-井道巡检`,
inspectionCode: this.inspectionCode, inspectionTime: moment().format("yyyy-MM-DD HH:mm"),
recordName: `${moment().format("yyyyMMDD")}-井道巡检`, inspectionBy: this.$store.state.now_user.user,
inspectionTime: moment().format("yyyy-MM-DD HH:mm"), inspectionById: this.$store.state.now_user.userId,
inspectionBy: this.$store.state.now_user.user, createByName: this.$store.state.now_user.user,
inspectionById: this.$store.state.now_user.userId, isException: "", // 是否有异常,大于0存在异常
createByName: this.$store.state.now_user.user, inspectionNumber: 0, //巡检数量
isException: "", // 是否有异常,大于0存在异常 floor: this.floor, // 楼层
inspectionNumber: 0, //巡检数量 isSubmit: "", // 0 是草稿态; 1 是正式提交
floor: this.floor, // 楼层 isSign: "", // 是否签字
isSubmit: "", // 0 是草稿态; 1 是正式提交 conclusion: "", //摘要
isSign: "", // 是否签字 creatTime: `${new Date().getTime()}`,
conclusion: "", //摘要 items: [],
creatTime: `${new Date().getTime()}`, };
items: [], console.log(2222, this.baseInfo, this.list, this.detailsInfo);
}; resolve();
console.log(2222, this.baseInfo, this.list, this.detailsInfo); });
resolve(); },
}); // 回显数据
}, getDetails(uid) {
// 回显数据 uni.showLoading();
getDetails(uid) { getInspectionDetails(uid)
uni.showLoading(); .then((res) => {
getInspectionDetails(uid) const detailsInfo = res;
.then((res) => { console.log("getDetails", res);
const detailsInfo = res; let list =
console.log("getDetails", res); detailsInfo.originData[this.value - 1].position[this.dictValue - 1]
let list = detailsInfo.originData[this.value - 1].position[this.dictValue - 1].details; .details;
// 未巡检需要处理默认数据结构 // 未巡检需要处理默认数据结构
if (list && list.length) { if (list && list.length) {
this.list = list this.list = list;
} }
console.log("let list", list) this.inspectionResult = list[0].inspectionResult
this.detailsInfo = detailsInfo; console.log("let list", list);
console.log("获取list", this.list); this.detailsInfo = detailsInfo;
console.log("获取list", this.list);
this.isDisable = this.isDisable || detailsInfo.synchronization == 1; // 是否禁用 1:已同步数据 0: 未同步数据
uni.hideLoading(); this.isDisable = this.isDisable || detailsInfo.synchronization == 1; // 是否禁用 1:已同步数据 0: 未同步数据
}) uni.hideLoading();
.catch((error) => { })
uni.showToast({ .catch((error) => {
title: error.msg, uni.showToast({
icon: "none", title: error.msg,
duration: 1000, icon: "none",
}); duration: 1000,
uni.hideLoading(); });
}); uni.hideLoading();
}, });
// 加载历史数据 },
loadHistoryData() { // 加载历史数据
const history = uni.getStorageSync("inspectionHistory"); loadHistoryData() {
console.log("history", history); const history = uni.getStorageSync("inspectionHistory");
if ( console.log("history", history);
history && if (
Date.now() - history.firstSubmitTime < 168 * 60 * 60 * 1000 history &&
) { Date.now() - history.firstSubmitTime < 168 * 60 * 60 * 1000
this.historyData = history; ) {
this.location = history.location; this.historyData = history;
this.randomDescription = history.randomDescription; this.location = history.location;
this.list = history.tabData; this.randomDescription = history.randomDescription;
this.activeTab = 0; // 默认切换到第一个 Tab this.list = history.tabData;
this.updateCurrentTabData(); this.activeTab = 0; // 默认切换到第一个 Tab
} this.updateCurrentTabData();
}, }
// 数据结构重组 },
coverlist() { // 数据结构重组
// 获取井道巡检的三个检查项固定数据再进行处理 coverlist() {
const data = pad_2_1_inspection_items.rows.map((item) => { // 获取井道巡检的三个检查项固定数据再进行处理
return { const data = pad_2_1_inspection_items.rows.map((item) => {
// ...item, return {
dictLabel: item.dictLabel, // ...item,
dictValue: item.dictValue, dictLabel: item.dictLabel,
conclusion: "", // 情况摘要 dictValue: item.dictValue,
// roomType, conclusion: "", // 情况摘要
inspectionResult: 0, // 异常结论 // roomType,
itemCode: item.dictValue, // 检查项 如:门禁 inspectionResult: 0, // 异常结论
measuredData: this.floor, // 逗号分隔字符串 itemCode: item.dictValue, // 检查项 如:门禁
photos: [], // 照片 measuredData: this.floor, // 逗号分隔字符串
}; photos: [], // 照片
}); };
});
this.list = data;
}, this.list = data;
},
// 更新当前 Tab 数据
updateCurrentTabData() { // 更新当前 Tab 数据
const currentTabData = this.list[this.activeTab]; updateCurrentTabData() {
this.inspectionResult = currentTabData.inspectionResult; const currentTabData = this.list[this.activeTab];
this.conclusion = currentTabData.conclusion; this.inspectionResult = currentTabData.inspectionResult;
this.photos = currentTabData.photos; this.conclusion = currentTabData.conclusion;
}, this.photos = currentTabData.photos;
// 拍照 },
takePhoto() { // 拍照
uni.chooseImage({ takePhoto() {
count: 1, uni.chooseImage({
sourceType: ["camera"], // 可以从相机拍摄 count: 1,
success: async (res) => { sourceType: ["camera"], // 可以从相机拍摄
if (this.photos.length < 5) { success: async (res) => {
const base64 = await this.convertFileToBase64(res.tempFilePaths[0]); if (this.photos.length < 5) {
this.photos.push(base64); const base64 = await this.convertFileToBase64(res.tempFilePaths[0]);
this.list[this.activeTab].photos = this.photos; this.photos.push(base64);
} else { this.list[this.activeTab].photos = this.photos;
uni.showToast({ } else {
title: "最多只能上传5张照片", uni.showToast({
icon: "none", title: "最多只能上传5张照片",
}); icon: "none",
} });
}, }
}); },
}, });
// 转化为base64 },
convertFileToBase64(filePath) { // 转化为base64
return new Promise((resolve, reject) => { convertFileToBase64(filePath) {
plus.io.resolveLocalFileSystemURL( return new Promise((resolve, reject) => {
filePath, plus.io.resolveLocalFileSystemURL(
function(entry) { filePath,
entry.file( function (entry) {
function(file) { entry.file(
const reader = new plus.io.FileReader(); function (file) {
reader.onloadend = function(evt) { const reader = new plus.io.FileReader();
const base64 = evt.target.result; // 获取 Base64 数据 reader.onloadend = function (evt) {
resolve(base64); // 返回 Base64 数据 const base64 = evt.target.result; // 获取 Base64 数据
}; resolve(base64); // 返回 Base64 数据
reader.readAsDataURL(file); // 读取文件并转换为 Base64 };
}, reader.readAsDataURL(file); // 读取文件并转换为 Base64
function(error) { },
reject("获取文件对象失败:" + error.message); function (error) {
} reject("获取文件对象失败:" + error.message);
); }
}, );
function(error) { },
reject("解析文件路径失败:" + error.message); function (error) {
} reject("解析文件路径失败:" + error.message);
); }
}); );
}, });
// 删除照片 },
deletePhoto(index) { // 删除照片
this.photos.splice(index, 1); deletePhoto(index) {
this.list[this.activeTab].photos = this.photos; this.photos.splice(index, 1);
}, this.list[this.activeTab].photos = this.photos;
// 处理提交数据 },
getParams(isSubmit) { // 处理提交数据
if (this.uid) { getParams(isSubmit) {
if (this.uid) {
let posItem = this.detailsInfo.originData[this.value - 1].position[this.dictValue - 1] let posItem =
posItem.details = this.list this.detailsInfo.originData[this.value - 1].position[
posItem.isSubmit = isSubmit this.dictValue - 1
if (!this.checkInspectionResult(this.list)) { ];
posItem.status = 2; //1表示已经巡检过有异常 posItem.details = this.list;
posItem.statusLable = "巡检异常" posItem.isSubmit = isSubmit;
} else { // 提交才会有巡检状态,暂存没有
posItem.status = 1; //1表示已经巡检过没有异常 if (isSubmit) {
posItem.statusLable = "已巡检" if (!this.checkInspectionResult(this.list)) {
} posItem.status = 2; //1表示已经巡检过有异常
let { posItem.statusLable = "巡检异常";
notZeroCount, } else {
equalTwoCount posItem.status = 1; //1表示已经巡检过没有异常
} = this.count(this.detailsInfo.originData) posItem.statusLable = "已巡检";
this.detailsInfo.inspectionNumber = notZeroCount //巡检总数 }
this.detailsInfo.isException = equalTwoCount //异常数量 } else {
this.detailsInfo.isSubmit = this.typeSubmit(this.detailsInfo.originData) > 0 ? 0 : 1, //是否提交 posItem.status = 0; //暂存就是未巡检
console.log("this.detailsInfo", this.detailsInfo); posItem.statusLable = "未巡检";
return this.detailsInfo; }
} else { let { notZeroCount, equalTwoCount } = this.count(
let baseInfo = this.baseInfo; this.detailsInfo.originData
let dataObj = pad_2_1_inspection_position.rows.map((item, index) => { );
return { this.detailsInfo.inspectionNumber = notZeroCount; //巡检总数
name: item.dictLabel, this.detailsInfo.isException = equalTwoCount; //异常数量
value: item.dictValue, this.detailsInfo.isSubmit =
isVaild: false, // 校验通过 this.typeSubmit(this.detailsInfo.originData) > 0 ? 0 : 1; //是否提交
// type: 1, // 枚举值 console.log("this.detailsInfo", this.detailsInfo);
position: pad_2_1_floor.rows, this.detailsInfo.submitTime = moment().format("yyyy-MM-DD"); // 记录提交时间
refName: `TabContentItem_${index}`, this.detailsInfo.submitMonth = moment().format("yyyy-MM"); // 记录提交月份
descript: "检查内容包括门禁、卫生、设备告警。", this.detailsInfo.synchronization = 2 //编辑中
}; return this.detailsInfo;
}); } else {
let tabList = JSON.parse(JSON.stringify(dataObj)) let baseInfo = this.baseInfo;
let posItem = tabList[this.value - 1].position[this.dictValue - 1] let dataObj = pad_2_1_inspection_position.rows.map((item, index) => {
console.log("posItem", posItem); return {
name: item.dictLabel,
posItem.details = this.list; value: item.dictValue,
posItem.isSubmit = isSubmit //当前项是否提交 isVaild: false, // 校验通过
console.log("this.list", this.list) // type: 1, // 枚举值
if (!this.checkInspectionResult(this.list)) { position: pad_2_1_floor.rows,
posItem.status = 2; //1表示已经巡检过有异常 refName: `TabContentItem_${index}`,
posItem.statusLable = "巡检异常" descript: "检查内容包括门禁、卫生、设备告警。",
} else { };
posItem.status = 1; //1表示已经巡检过没有异常 });
posItem.statusLable = "已巡检" let tabList = JSON.parse(JSON.stringify(dataObj));
} let posItem = tabList[this.value - 1].position[this.dictValue - 1];
console.log("this.tabList", tabList);
// 根据获取到的每个井道的isSubmit来判断是否有暂存状态 posItem.details = this.list;
let typeSubmit = this.typeSubmit(tabList) posItem.isSubmit = isSubmit; //当前项是否提交
const data = { if (!this.checkInspectionResult(this.list)) {
...baseInfo, posItem.status = 2; //1表示已经巡检过有异常
isSubmit: typeSubmit > 0 ? 0 : 1, //0暂存 1提交 posItem.statusLable = "巡检异常";
inspectionNumber: 1, } else {
isException: posItem.status == 2 ? 1 : 0, posItem.status = 1; //1表示已经巡检过没有异常
items: [], posItem.statusLable = "已巡检";
synchronization: 0, // 是否同步过 }
submitTime: moment().format("yyyy-MM-DD"), // 记录提交时间 // 根据获取到的每个井道的isSubmit来判断是否有暂存状态,只有有一个井道是暂存,那就是编辑中、暂存状态
submitMonth: moment().format("yyyy-MM"), // 记录提交月份 let typeSubmit = this.typeSubmit(tabList);
originData: tabList, //所有大楼和楼层的数据 const data = {
}; ...baseInfo,
console.log("getParams,data", data); isSubmit: typeSubmit > 0 ? 0 : 1, //0暂存(编辑中) 1提交(待同步,已同步)
return data; inspectionNumber: 1,
} isException: posItem.status == 2 ? 1 : 0,
}, items: [],
count(originData) { synchronization: typeSubmit > 0 ? 2 : 0, // 是否同步过
return originData.reduce( submitTime: moment().format("yyyy-MM-DD"), // 记录提交时间
(acc, curr) => { submitMonth: moment().format("yyyy-MM"), // 记录提交月份
curr.position.forEach((item) => { originData: tabList, //所有大楼和楼层的数据
if (item.status !== 0) { };
acc.notZeroCount++; // 统计 status 不为 0 的数量 console.log("getParams,data", data);
} return data;
if (item.status === 2) { }
acc.equalTwoCount++; // 统计 status 等于 2 的数量 },
} count(originData) {
}); return originData.reduce(
return acc; (acc, curr) => {
}, { curr.position.forEach((item) => {
notZeroCount: 0, if (item.status !== 0) {
equalTwoCount: 0 acc.notZeroCount++; // 统计 status 不为 0 的数量
} // 初始化统计结果 }
); if (item.status === 2) {
}, acc.equalTwoCount++; // 统计 status 等于 2 的数量
typeSubmit(originData) { }
return originData.reduce((acc, curr) => { });
return acc + curr.position.reduce((innerAcc, innerCurr) => { return acc;
return innerCurr.status === 0 ? innerAcc + 1 : innerAcc; },
}, 0); {
}, 0); notZeroCount: 0,
}, equalTwoCount: 0,
// 检查是否存在异常 } // 初始化统计结果
checkInspectionResult(arr) { );
return !arr.some((obj) => obj.inspectionResult === 1); },
}, typeSubmit(originData) {
// 检查所有Tab 的必填项是否填写完整 return originData.reduce((acc, curr) => {
isAllTabValid() { return (
const data = this.list; acc +
// 校验函数 curr.position.reduce((innerAcc, innerCurr) => {
const validateData = (data) => { return innerCurr.status === 0 ? innerAcc + 1 : innerAcc;
return data.every( }, 0)
(item) => );
item.inspectionResult !== null && item.conclusion.trim() !== "" }, 0);
); },
}; // 检查是否存在异常
// 调用校验函数 checkInspectionResult(arr) {
const isValid = validateData(data); return !arr.some((obj) => obj.inspectionResult === 1);
console.log(141, isValid); },
return isValid; // 提交
}, submit(isSubmit = 1) {
// 检查当前 Tab 的必填项是否填写完整 // 校验是否通过
isCurrentTabValid() { if (isSubmit && !this.isAllTabValid()) {
const currentTabData = this.list[this.activeTab]; uni.showToast({
console.log("currentTabData", currentTabData); title: "请填写完整必填项",
return ( icon: "none",
currentTabData.inspectionResult !== null && // 巡检结论必填 });
currentTabData.conclusion.trim() !== "" // 情况摘要必填 return false;
// 现场照片为非必填项,不做校验 }
); const params = this.getParams(isSubmit); //数据获取
}, const all_data = this.$store.state.all_data; //获取全部数据
// 暂存 let logContent = "";
saveDraft(isSave = true) { console.log("this.uid", this.uid);
return new Promise((resolve, reject) => { console.log("all_data", all_data);
if (isSave) { if (this.uid) {
// 写入草稿文件 更新 store 草稿内容 const index = all_data.findIndex((element) => element.uid == this.uid);
const params = this.getParams(); params.uid = this.uid;
console.log("params", params);
params.isSubmit = 0; all_data[index] = params;
logContent = getLogContent(
this.$store.commit("SET_DARF_DATA", params); // 缓存[巡检信息] LOG_TYPE_ENUM.edit,
writeDarf(params).then((res) => { `${params.recordName}(${params.inspectionCode})`,
console.log("写入草稿文件成功"); "巡检模块"
uni.showToast({ );
icon: "success", } else {
title: "保存草稿成功", params.uid = new Date().getTime(); // 唯一标识 pad 端使用
}); all_data.push(params);
}); logContent = getLogContent(
LOG_TYPE_ENUM.add,
// 新增日志信息 `${params.recordName}(${params.inspectionCode})`,
const logContent = getLogContent( "巡检模块"
LOG_TYPE_ENUM.darf, );
`${params.recordName}(${params.inspectionCode})`, }
"巡检模块" // 更新巡检list
); const userInfo = this.userInfo;
console.log("all_data存储", all_data);
const log_list = this.$store.state.log_list; this.$store.commit("SET_ALL_DATA", all_data);
logContent.inspectionType = params.inspectionType; const inspectList = all_data.filter(
(item) => item.createByName == userInfo.user
log_list.push(logContent); );
this.$store.commit("SET_LOG_LIST", log_list);
addLog(log_list).then((res) => { console.log("inspectList", inspectList);
console.log("日志文件写入成功"); writeInspectionData(inspectList, userInfo.user);
});
} // 更新日志
resolve(); const log_list = this.$store.state.log_list;
}); logContent.inspectionType = params.inspectionType;
}, log_list.push(logContent);
// 提交 this.$store.commit("SET_LOG_LIST", log_list);
submit(isSubmit = 1) { addLog(log_list).then((res) => {
// 校验是否通过 console.log("日志文件写入成功");
if (isSubmit && !this.isCurrentTabValid()) { });
uni.showToast({
title: "请填写完整必填项", // 清空基础缓存信息
icon: "none", this.$store.commit("SET_TEMP_DATA", {}); // 缓存[巡检信息]
}); uni.showToast({
return false; title: isSubmit ? "提交成功" : "保存草稿成功",
} icon: "success",
const params = this.getParams(isSubmit); //数据获取 });
const all_data = this.$store.state.all_data; //获取全部数据 uni.navigateTo({
let logContent = ""; url: "/pages/inspectionManagement/index",
console.log("this.uid", this.uid); });
console.log("all_data", all_data) },
if (this.uid) { // 检查所有Tab 的必填项是否填写完整
const index = all_data.findIndex((element) => element.uid == this.uid); isAllTabValid() {
params.uid = this.uid; const data = this.list;
// 校验函数
all_data[index] = params; const validateData = (data) => {
logContent = getLogContent( return data.every(
LOG_TYPE_ENUM.edit, (item) =>
`${params.recordName}(${params.inspectionCode})`, item.inspectionResult !== null && item.conclusion.trim() !== ""
"巡检模块" );
); };
} else { // 调用校验函数
params.uid = new Date().getTime(); // 唯一标识 pad 端使用 const isValid = validateData(data);
all_data.push(params); console.log(141, isValid);
logContent = getLogContent( return isValid;
LOG_TYPE_ENUM.add, },
`${params.recordName}(${params.inspectionCode})`, // 检查当前 Tab 的必填项是否填写完整
"巡检模块" isCurrentTabValid() {
); const currentTabData = this.list[this.activeTab];
} console.log("currentTabData", currentTabData);
// 更新巡检list return (
const userInfo = this.userInfo; currentTabData.inspectionResult !== null && // 巡检结论必填
console.log("all_data存储", all_data) currentTabData.conclusion.trim() !== "" // 情况摘要必填
this.$store.commit("SET_ALL_DATA", all_data); // 现场照片为非必填项,不做校验
const inspectList = all_data.filter( );
(item) => item.createByName == userInfo.user },
); // 下一项
nextTab() {
console.log("inspectList", inspectList); console.log(5215415, this.isCurrentTabValid());
writeInspectionData(inspectList, userInfo.user); if (!this.isCurrentTabValid()) {
uni.showToast({
// 更新日志 title: "请填写完整必填项",
const log_list = this.$store.state.log_list; icon: "none",
logContent.inspectionType = params.inspectionType; });
log_list.push(logContent); return false;
this.$store.commit("SET_LOG_LIST", log_list); }
addLog(log_list).then((res) => { if (this.activeTab === 2) {
console.log("日志文件写入成功"); this.isSubmitEnabled = true;
}); } else {
this.switchTab(this.activeTab + 1);
// 清空草稿数据 }
// this.$store.commit("SET_DARF_DATA", {}); // 缓存[巡检信息] },
// writeDarf("").then((res) => { // 切换 Tab
// console.log("写入草稿文件成功"); switchTab(index) {
// }); this.activeTab = index;
this.updateCurrentTabData();
// 清空基础缓存信息 }, // 设置巡检结论
this.$store.commit("SET_TEMP_DATA", {}); // 缓存[巡检信息] setInspectionResult(value) {
// const historyData = { console.log("value", value);
// location: this.location, this.inspectionResult = value;
// randomDescription: this.randomDescription, this.list[this.activeTab].inspectionResult = value; // 更新当前 Tab 的数据
// tabData: this.list, },
// firstSubmitTime: this.firstSubmitTime, // 返回
// }; back() {
// uni.setStorageSync("inspectionHistory", historyData); uni.navigateBack();
uni.showToast({ },
title: `${isSubmit}?'提交成功':'保存草稿成功'`, // 关闭弹窗
icon: "success", closePopup() {
}); this.switchTab((this.activeTab + 1) % this.tabs.length);
uni.navigateTo({ },
url: "/pages/inspectionManagement/index", },
}); };
},
// 切换 Tab
switchTab(index) {
this.activeTab = index;
this.updateCurrentTabData();
}, // 设置巡检结论
setInspectionResult(value) {
console.log("value", value);
this.inspectionResult = value;
this.list[this.activeTab].inspectionResult = value; // 更新当前 Tab 的数据
},
// 返回
back() {
uni.navigateBack();
},
// 关闭弹窗
closePopup() {
this.switchTab((this.activeTab + 1) % this.tabs.length);
},
},
};
</script> </script>
<style scoped lang="less"> <style scoped lang="less">
/* 导航栏样式 */ .uni-nav-bar-text {
.uni-nav-bar-text { height: 28.8px;
height: 36px; width: 28.8px;
width: 36px; background: #ffffff;
background: #ffffff; border: 0.32px solid rgba(224, 224, 224, 1);
border: 0.4px solid rgba(224, 224, 224, 1); border-radius: 14.4px;
border-radius: 18px; color: #333;
color: #333; display: flex;
text-align: center; align-items: center;
justify-content: center;
.iconfont { text-align: center;
font-size: 20px;
line-height: 36px; .iconfont {
} font-size: 16px;
} line-height: 28.8px;
}
.container { }
padding: 24px;
} .container {
padding: 19.2px;
.profile-section { height: calc(100vh - 115px);
width: 100%; }
margin-bottom: 12.8px;
.profile-section {
.profile-box { width: 100%;
background-color: #fff; margin-bottom: 10.24px;
border-radius: 9.6px;
padding: 12.8px 25.6px; .profile-box {
display: flex; background-color: #fff;
justify-content: space-between; border-radius: 7.68px;
align-items: center; padding: 10.24px 20.48px;
display: flex;
.profile-left { justify-content: space-between;
display: flex; align-items: center;
align-items: center;
.profile-left {
.avatar { display: flex;
position: relative; align-items: center;
width: 40.5px;
height: 40.5px; .avatar {
border-radius: 50%; position: relative;
overflow: hidden; width: 32.4px;
margin-right: 9px; height: 32.4px;
border-radius: 50%;
image { overflow: hidden;
width: 100%; margin-right: 7.2px;
height: 100%;
} image {
width: 100%;
.change-password { height: 100%;
position: absolute; }
bottom: 0;
left: 0; .change-password {
right: 0; position: absolute;
background-color: rgba(0, 0, 0, 0.5); bottom: 0;
text-align: center; left: 0;
height: 17.6px; right: 0;
font-family: PingFangSC-Regular; background-color: rgba(0, 0, 0, 0.5);
font-size: 9.6px; text-align: center;
color: #ffffff; height: 14.08px;
line-height: 16px; font-family: PingFangSC-Regular;
font-weight: 400; font-size: 7.68px;
} color: #ffffff;
} line-height: 12.8px;
font-weight: 400;
.info { }
.username { }
font-size: 16px;
color: #000000; .info {
line-height: 22.4px; .username {
font-weight: 500; font-size: 12.8px;
margin-bottom: 7.2px; color: #000000;
} line-height: 17.92px;
font-weight: 500;
.number { margin-bottom: 5.76px;
font-size: 12.8px; }
color: #4a4a4a;
line-height: 22.4px; .number {
font-weight: 400; font-size: 10.24px;
color: #4a4a4a;
.value { line-height: 17.92px;
color: #000000; font-weight: 400;
}
} .value {
} color: #000000;
} }
} }
} }
}
.module { }
background: #ffffff; }
border-radius: 12px;
padding: 16px 25px; .module {
} background: #ffffff;
height: 100%;
.title-bar { border-radius: 9.6px;
display: flex; padding: 12.8px 20px;
align-items: center; }
margin-bottom: 10px;
.title-bar {
.blue-line { display: flex;
width: 4px; align-items: center;
height: 16px; margin-bottom: 8px;
background-color: #007aff;
margin-right: 8px; .blue-line {
} width: 3.2px;
height: 12.8px;
.title { background-color: #007aff;
font-size: 16px; margin-right: 6.4px;
font-weight: bold; }
}
.title {
.location { font-size: 12.8px;
margin-left: 8px; font-weight: bold;
color: #666; }
}
.location {
.submit-btn { margin-left: 6.4px;
position: absolute; color: #666;
right: 24px; }
width: 20%;
background-color: #ccc; .submit-btn {
color: #fff; position: absolute;
border-radius: 4px; right: 19.2px;
padding: 4px 8px; width: 20%;
font-size: 12px; background-color: #ccc;
color: #fff;
&.active { border-radius: 3.2px;
background-color: #007aff; padding: 3.2px 6.4px;
} font-size: 9.6px;
}
} &.active {
background-color: #007aff;
.description { }
font-size: 14px; }
color: #666; }
}
.description {
.tab-buttons { font-size: 11.2px;
display: flex; color: #666;
justify-content: flex-start; }
/* 左对齐 */
align-items: center; .tab-buttons {
margin-bottom: 10px; display: flex;
gap: 20px; justify-content: flex-start;
/* Tab 之间的间隔 */ align-items: center;
/* 容器内边距 */ margin-bottom: 8px;
} gap: 16px;
}
.tip {
width: 100%; .tip {
height: 34px; width: 100%;
background: rgba(55, 116, 246, 0.05); height: 27.2px;
border: 1px solid rgba(55, 116, 246, 0.3); background: rgba(55, 116, 246, 0.05);
border-radius: 10px; border: 0.8px solid rgba(55, 116, 246, 0.3);
font-size: 14px; border-radius: 8px;
color: #4a4a4a; font-size: 11.2px;
letter-spacing: 0; color: #4a4a4a;
line-height: 34px; letter-spacing: 0;
font-weight: 400; line-height: 27.2px;
padding: 0 12px; font-weight: 400;
padding: 0 9.6px;
.tip-icon {
width: 14px; .tip-icon {
height: 14px; width: 11.2px;
margin-right: 8px; height: 11.2px;
} margin-right: 6.4px;
} }
}
.tab-item {
display: flex; .tab-item {
align-items: flex-start; display: flex;
position: relative; align-items: flex-start;
padding: 8px 0; position: relative;
/* 上下内边距 */ padding: 6.4px 0;
cursor: pointer; cursor: pointer;
white-space: nowrap; white-space: nowrap;
/* 防止文字换行 */
.tab-icon {
.tab-icon { width: 8.4px;
width: 10.5px; height: 8.4px;
height: 10.5px; margin-bottom: 3.2px;
margin-bottom: 4px; margin-right: 2.4px;
margin-right: 3px; }
}
.tab-text {
.tab-text { font-size: 11.2px;
font-size: 14px; color: #333;
color: #333; }
}
&.active {
&.active { .tab-text {
.tab-text { color: #3774f6;
color: #3774f6; }
/* 选中时的文字颜色 */
} .underline {
position: absolute;
.underline { bottom: 0;
position: absolute; left: 50%;
bottom: 0; transform: translateX(-50%);
left: 50%; width: 100%;
transform: translateX(-50%); height: 1.6px;
width: 100%; background-color: #3774f6;
/* 横线宽度与内容一致 */ }
height: 2px; }
background-color: #3774f6; }
/* 选中时的横线颜色 */
} .form-item {
} display: flex;
} align-items: center;
padding: 9.6px 0;
.form-item { line-height: 28.8px;
display: flex; border-bottom: 0.8px solid #f2f3f5;
align-items: center;
padding: 12px 0; .form-label {
line-height: 36px; font-size: 11.2px;
border-bottom: 1px solid #f2f3f5; font-weight: bold;
margin-right: 25.6px;
.form-label { width: 58.4px;
font-size: 14px; text-align: right;
font-weight: bold;
margin-right: 32px; .required {
width: 73px; color: red;
text-align: right; margin-right: 3.2px;
}
.required { }
color: red;
margin-right: 4px; .switch-container {
} display: flex;
} gap: 9.6px;
.switch-container { .status-btn {
display: flex; flex: 1;
gap: 12px; padding: 5.6px 19.2px;
/* 按钮之间的间隔 */ font-size: 12.8px;
color: #000000;
.status-btn { background: #f2f2f2;
flex: 1; text-align: center;
/* 按钮宽度平分 */ font-weight: 400;
padding: 7px 24px; line-height: 17.6px;
font-size: 16px; border-radius: 14.4px;
color: #000000;
background: #f2f2f2; &.active {
text-align: center; color: #ffffff;
font-weight: 400; background: #3774f6;
line-height: 22px; border: 0.32px solid rgba(224, 224, 224, 1);
border-radius: 18px; }
}
&.active { }
color: #ffffff;
background: #3774f6; .input-box {
border: 0.4px solid rgba(224, 224, 224, 1); flex: 1;
} border-radius: 3.2px;
} font-size: 12.8px;
} line-height: 19.2px;
}
.input-box {
flex: 1; .photo-limit {
border-radius: 4px; font-size: 12.8px;
font-size: 16px; color: #959595;
line-height: 24px; line-height: 19.2px;
} font-weight: 400;
}
.photo-limit {
font-size: 16px; .photo-container {
color: #959595; display: flex;
line-height: 24px; flex-wrap: wrap;
font-weight: 400; margin-bottom: 6.4px;
}
.photo-item {
.photo-container { position: relative;
display: flex; margin-right: 6.4px;
flex-wrap: wrap; margin-bottom: 6.4px;
margin-bottom: 8px;
.photo {
.photo-item { width: 57.6px;
position: relative; height: 57.6px;
margin-right: 8px; border-radius: 3.2px;
margin-bottom: 8px; margin-left: 9.6px;
}
.photo {
width: 72px; .delete-photo {
height: 72px; position: absolute;
border-radius: 4px; top: -6.4px;
margin-left: 12px; right: -6.4px;
} background-color: #ff4d4f;
color: #fff;
.delete-photo { width: 12.8px;
position: absolute; height: 12.8px;
top: -8px; border-radius: 50%;
right: -8px; text-align: center;
background-color: #ff4d4f; line-height: 12.8px;
color: #fff; font-size: 9.6px;
width: 16px; }
height: 16px; }
border-radius: 50%; }
text-align: center;
line-height: 16px; .photo-btn {
font-size: 12px; background: #ffffff;
} border: 0.272px solid rgba(221, 221, 221, 1);
} border-radius: 1.64px;
} width: 57.6px;
height: 57.6px;
.photo-btn { font-size: 57.6px;
background: #ffffff; color: #cccccc;
border: 0.34px solid rgba(221, 221, 221, 1); text-align: center;
border-radius: 2.05px; line-height: 51.2px;
width: 72px; }
height: 72px; }
font-size: 72px;
color: #cccccc; .submit-module {
text-align: center; display: flex;
line-height: 64px; justify-content: center;
} position: fixed;
} gap: 16px;
left: 50%;
.submit-module { transform: translateX(-50%);
display: flex; bottom: 25.6px;
justify-content: center;
gap: 20px; .action-btn {
width: 145.6px;
.action-btn { height: 38.4px;
width: 182px; line-height: 38.4px;
height: 48px; background: #ffffff;
line-height: 48px; border: 0.8px solid rgba(224, 224, 224, 1);
background: #ffffff; box-shadow: 0px 8px 19.2px 0px rgba(185, 185, 185, 0.24);
border: 1px solid rgba(224, 224, 224, 1); border-radius: 21.6px 19.2px 19.2px 21.6px;
box-shadow: 0px 10px 24px 0px rgba(185, 185, 185, 0.24); font-size: 16px;
border-radius: 27px 24px 24px 27px; color: #000000;
font-size: 20px; text-align: center;
color: #000000; font-weight: 400;
text-align: center;
font-weight: 400; &.complete-btn {
background-image: linear-gradient(180deg, #3773f6 0%, #2c57f6 99%);
&.complete-btn { color: #ffffff;
background-image: linear-gradient(180deg, #3773f6 0%, #2c57f6 99%); }
color: #ffffff; }
} }
}
} .popup-content {
background-color: white;
// 弹窗内容样式 padding: 32px;
.popup-content { border-radius: 8px;
background-color: white; text-align: center;
padding: 40px; position: relative;
border-radius: 10px; width: 240px;
text-align: center;
position: relative; .close-icon {
width: 300px; position: absolute;
top: 8px;
// 关闭按钮样式 right: 8px;
.close-icon { font-size: 16px;
position: absolute; cursor: pointer;
top: 10px; }
right: 10px;
font-size: 20px; .icon-success {
cursor: pointer; font-size: 32px;
} color: green;
margin-bottom: 16px;
// 成功图标样式 }
.icon-success {
font-size: 40px; .success-text {
color: green; font-size: 14.4px;
margin-bottom: 20px; margin-bottom: 16px;
} }
// 成功文字样式 .next-button {
.success-text { background-color: blue;
font-size: 18px; color: white;
margin-bottom: 20px; padding: 8px 16px;
} border-radius: 4px;
cursor: pointer;
// 下一项按钮样式 font-size: 12.8px;
.next-button {
background-color: blue; &:hover {
color: white; opacity: 0.9;
padding: 10px 20px; }
border-radius: 5px; }
cursor: pointer; }
font-size: 16px; </style>
// 按钮 hover 效果
&:hover {
opacity: 0.9;
}
}
}
</style>
\ No newline at end of file
<template> <template>
<view class="uni-navbar" :class="{'uni-dark':dark, 'uni-nvue-fixed': fixed}"> <view class="uni-navbar" :class="{'uni-dark':dark, 'uni-nvue-fixed': fixed}">
<view class="uni-navbar__content" :class="{ 'uni-navbar--fixed': fixed, 'uni-navbar--shadow': shadow, 'uni-navbar--border': border }" <view class="uni-navbar__content"
:style="{ 'background-color': themeBgColor }" > :class="{ 'uni-navbar--fixed': fixed, 'uni-navbar--shadow': shadow, 'uni-navbar--border': border }"
:style="{ 'background-color': themeBgColor }">
<status-bar v-if="statusBar" /> <status-bar v-if="statusBar" />
<view :style="{ color: themeColor,backgroundColor: themeBgColor ,height:navbarHeight}" <view :style="{ color: themeColor,backgroundColor: themeBgColor ,height:navbarHeight}" class="uni-navbar__header">
class="uni-navbar__header">
<view @tap="onClickLeft" class="uni-navbar__header-btns uni-navbar__header-btns-left" <view @tap="onClickLeft" class="uni-navbar__header-btns uni-navbar__header-btns-left"
:style="{width:leftIconWidth}"> :style="{width:leftIconWidth}">
<slot name="left"> <slot name="left">
...@@ -20,8 +20,7 @@ ...@@ -20,8 +20,7 @@
<view class="uni-navbar__header-container " @tap="onClickTitle"> <view class="uni-navbar__header-container " @tap="onClickTitle">
<slot> <slot>
<view class="uni-navbar__header-container-inner" v-if="title.length>0"> <view class="uni-navbar__header-container-inner" v-if="title.length>0">
<text class="uni-nav-bar-text uni-ellipsis-1" <text class="uni-nav-bar-text uni-ellipsis-1" :style="{color: themeColor }">{{ title }}</text>
:style="{color: themeColor }">{{ title }}</text>
</view> </view>
</slot> </slot>
</view> </view>
...@@ -205,11 +204,16 @@ ...@@ -205,11 +204,16 @@
position: sticky; position: sticky;
/* #endif */ /* #endif */
} }
.uni-navbar { .uni-navbar {
// box-sizing: border-box; // box-sizing: border-box;
} }
.uni-nav-bar-text { .uni-nav-bar-text {
display: flex;
align-items: center;
justify-content: center;
text-align: center;
/* #ifdef APP-PLUS */ /* #ifdef APP-PLUS */
font-size: 34rpx; font-size: 34rpx;
/* #endif */ /* #endif */
...@@ -354,4 +358,4 @@ ...@@ -354,4 +358,4 @@
// 暗主题配置 // 暗主题配置
.uni-dark {} .uni-dark {}
</style> </style>
\ No newline at end of file
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论