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

fix:井道完成

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