Browse Source

(*)巡检提交+巡检记录列表

master
Archer_cdm 2 years ago
parent
commit
7ff02b99f4
  1. 3
      weapp/app.json
  2. 66
      weapp/package/inspectionRecord/inspectionRecord.js
  3. 2
      weapp/package/inspectionRecord/inspectionRecord.json
  4. 15
      weapp/package/inspectionRecord/inspectionRecord.wxml
  5. 15
      weapp/package/inspectionRecord/inspectionRecord.wxss
  6. 96
      weapp/package/inspectionRecord/inspectionRecordDetail/inspectionRecordDetail.js
  7. 6
      weapp/package/inspectionRecord/inspectionRecordDetail/inspectionRecordDetail.json
  8. 77
      weapp/package/inspectionRecord/inspectionRecordDetail/inspectionRecordDetail.wxml
  9. 71
      weapp/package/inspectionRecord/inspectionRecordDetail/inspectionRecordDetail.wxss
  10. 23
      weapp/package/startInspection/startInspection.js

3
weapp/app.json

@ -11,7 +11,8 @@
"polling/polling",
"basic/basic",
"startInspection/startInspection",
"inspectionRecord/inspectionRecord"
"inspectionRecord/inspectionRecord",
"inspectionRecord/inspectionRecordDetail/inspectionRecordDetail"
]
}],
"window": {

66
weapp/package/inspectionRecord/inspectionRecord.js

@ -10,6 +10,10 @@ Page({
*/
data: {
ResList: [ //阅读状态
{
value: 'all',
text: '全部',
},
{
value: 'normal',
text: '正常',
@ -34,6 +38,7 @@ Page({
// limitStartTime: "", //最小可选时间
// limitEndTime: "" //最大可选时间
},
hidden: true,
},
// 巡检结果
@ -81,32 +86,44 @@ Page({
this.getPatrolRecord();
},
// 查看详情
bindDetail(e) {
let data = e.currentTarget.dataset.item;
wx.navigateTo({
url: '/package/inspectionRecord/inspectionRecordDetail/inspectionRecordDetail?data=' + JSON.stringify(data),
})
},
// 获取巡检记录
getPatrolRecord: function () {
let that = this;
let { endTime, startTime, ResList, ResIndex } = that.data;
let sevenYearAgo = moment().subtract(7, 'days').format('YYYY-MM-DD');
let currentData = moment().format('YYYY-MM-DD');
let alarm = ResList[ResIndex].text == '正常' ? false : true;
let sevenYearAgo = moment().subtract(7, 'days').format('YYYY-MM-DD 00:00:00');
let currentData = moment().startOf('days').format('YYYY-MM-DD 23:59:59');
console.log(currentData, 'currentData');
let alarm = ResList[ResIndex].value == 'all' ? 'null' : ResList[ResIndex].value == 'normal' ? false : true;
wx.showLoading({
title: '加载中'
})
Request.get(getPatrolRecord('all', startTime == '开始日期' ? sevenYearAgo : startTime, endTime == '结束日期' ? currentData : endTime, 'null', 'null')).then(res => {
console.log(res);
// dataList.points.map(e => {
// res.map(i => {
// wx.hideLoading();
// console.log(i, '------');
// if (i == null) {
// e.lastInspectionTime = moment().format('YYYY-MM-DD');
// e.inspectionTime = moment().format('YYYY-MM-DD');
// }
// })
// return e;
// })
// that.setData({
// dataList
// })
Request.get(getPatrolRecord('all', startTime == '开始日期' ? sevenYearAgo : startTime + ' 00:00:00', endTime == '结束日期' ? currentData : endTime + ' 23:59:59', alarm, 'null')).then(res => {
if (res.length == 0) {
that.setData({
dataList: res,
hidden: false
})
wx.hideLoading()
return;
}
let dataSource = res.map(e => {
e.lastInspectionTime = moment(e.lastInspectionTime).format('YYYY-MM-DD');
e.inspectionTime = moment(e.inspectionTime).format('YYYY-MM-DD');
return e;
})
that.setData({
dataList: dataSource,
hidden: true
})
wx.hideLoading()
})
},
@ -149,7 +166,16 @@ Page({
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh() {
let that = this;
that.setData({
dataList: [],
ResIndex: 0, //巡检结果
startTime: "开始日期", //开始日期
endTime: "结束日期", //结束日期
})
that.getPatrolRecord()
// 手动控制回弹
wx.stopPullDownRefresh();
},
/**

2
weapp/package/inspectionRecord/inspectionRecord.json

@ -2,7 +2,7 @@
"navigationBarBackgroundColor": "#1979ff",
"navigationBarTextStyle": "white",
"navigationBarTitleText": "巡检记录",
"enablePullDownRefresh": false,
"enablePullDownRefresh": true,
"usingComponents": {
"timePicker": "/components/timePicker/index"
}

15
weapp/package/inspectionRecord/inspectionRecord.wxml

@ -31,19 +31,24 @@
<view class="listBox">
<view style="padding-bottom:40rpx;overflow: hidden;">
<view class="titleBox" style="width: 630rpx; margin: 0 auto;">
<view class="title">结构物A</view>
<view class="title">{{item.points.project.name}}</view>
</view>
<view style="line-height:50rpx;font-size:28rpx;width: 630rpx; margin: 0 auto;">
本次巡检日期:<text>2022-12-21 17:00</text>
本次巡检日期:<text>{{item.inspectionTime}}</text>
</view>
<view style="line-height:50rpx;font-size:28rpx;width: 630rpx; margin: 0 auto;">
巡检人:<text>巡检人</text>
巡检人:<text>{{item.points.user.name}}</text>
</view>
<view style="line-height:50rpx;font-size:28rpx;width: 630rpx; margin: 0 auto;">
巡检结果:<text>异常</text>
巡检结果:<text>{{item.alarm ? '异常' : '正常'}}</text>
</view>
<view class="btn" bindtap="bindStart">查看详情</view>
<view class="btn" data-item="{{item}}" bindtap="bindDetail">查看详情</view>
</view>
</view>
</block>
</view>
<!-- 暂无数据 -->
<view hidden="{{hidden}}">
<image class="noData" src="../../images/noData.png"></image>
<view class="noTxt">暂无数据~</view>
</view>

15
weapp/package/inspectionRecord/inspectionRecord.wxss

@ -62,3 +62,18 @@ page {
width: 20rpx;
height: 20rpx;
}
/* 暂无数据 */
.noData {
width: 254rpx;
height: 298rpx;
display: block;
margin: 280rpx auto 16rpx;
}
.noTxt {
font-size: 30rpx;
color: #999;
font-weight: bold;
text-align: center;
}

96
weapp/package/inspectionRecord/inspectionRecordDetail/inspectionRecordDetail.js

@ -0,0 +1,96 @@
// package/inspectionRecord/inspectionRecordDetail/inspectionRecordDetail.js
Page({
/**
* 页面的初始数据
*/
data: {
dataList: '',
imgUrl: getApp().globalData.imgUrl
},
// 预览图片
previewImg: function (e) {
//获取当前图片的下标
var index = e.currentTarget.dataset.index;
//所有图片
var imgs = this.data.dataList.imgs;
wx.previewImage({
//当前显示图片
current: imgs[index],
//所有图片
urls: imgs
})
},
/**
* 生命周期函数--监听页面加载
*/
onLoad(options) {
let that = this;
let data = JSON.parse(options.data)
if (data.points.imgs != undefined) {
let newArr = data.points.imgs.map(e => {
e = that.data.imgUrl + e;
return e;
})
that.setData({
dataList: { ...data, imgs: newArr }
})
} else {
that.setData({
dataList: data
})
}
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady() {
},
/**
* 生命周期函数--监听页面显示
*/
onShow() {
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide() {
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload() {
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh() {
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom() {
},
/**
* 用户点击右上角分享
*/
onShareAppMessage() {
}
})

6
weapp/package/inspectionRecord/inspectionRecordDetail/inspectionRecordDetail.json

@ -0,0 +1,6 @@
{
"navigationBarBackgroundColor": "#1979ff",
"navigationBarTextStyle": "white",
"navigationBarTitleText": "巡检记录详情",
"enablePullDownRefresh": false
}

77
weapp/package/inspectionRecord/inspectionRecordDetail/inspectionRecordDetail.wxml

@ -0,0 +1,77 @@
<!--package/inspectionRecord/inspectionRecordDetail/inspectionRecordDetail.wxml-->
<view class="page">
<view class='list'>
<view class='content'>
<view class='title'>结构物名称:</view>
<view class='value'>
{{dataList.points.project.name}}
</view>
</view>
<view class='content'>
<view class='title'>巡检人:</view>
<view class='value'>
{{dataList.points.user.name}}
</view>
</view>
<view class='content'>
<view class='title'>巡检单位:</view>
<view class='value'>
{{dataList.points.user.department.name}}
</view>
</view>
<view class='content'>
<view class='title'>巡检频次:</view>
<view class='value'>
{{dataList.points.frequency}}
</view>
</view>
<view class='content'>
<view class='title'>上次巡检日期:</view>
<view class='value'>
{{dataList.lastInspectionTime}}
</view>
</view>
<view class='content'>
<view class='title'>本次巡检日期:</view>
<view class='value'>
{{dataList.inspectionTime}}
</view>
</view>
<view class='content'>
<view class='title'>巡检结果:</view>
<view class='value'>
{{dataList.alarm ? '异常' : '正常'}}
</view>
</view>
<view class='content'>
<view class='title'>当前点位:</view>
<view class='value'>
{{dataList.points.itemData.name}}
</view>
</view>
<view class='content'>
<view class='title'>当前位置:</view>
<view class='value'>
{{dataList.points.address}}
</view>
</view>
<view class='content'>
<view class='title'>巡检详情:</view>
<view class='value'>
{{dataList.points.msgInp || '--'}}
</view>
</view>
<view class='content'>
<view class='title'>异常等级:</view>
<view class='value'>
{{dataList.points.changeThree || '--'}}
</view>
</view>
<view class="img-v weui-uploader__bd" style="overflow:hidden;">
<view class='pic' wx:for="{{dataList.imgs}}" wx:for-item="item" wx:key="*this">
<image class='weui-uploader__img showImg' src="{{item}}" data-index="{{index}}" mode="aspectFill" bindtap="previewImg"></image>
</view>
</view>
</view>
</view>

71
weapp/package/inspectionRecord/inspectionRecordDetail/inspectionRecordDetail.wxss

@ -0,0 +1,71 @@
/* package/inspectionRecord/inspectionRecordDetail/inspectionRecordDetail.wxss */
page {
background-color: #F7F7FA;
}
.page {
padding: 30rpx;
}
.header-item-container {
width: 100%;
height: 180rpx;
background: rgb(255, 255, 255);
border-radius: 10rpx;
flex-direction: row;
display: flex;
justify-content: start;
align-items: center;
box-shadow: 0rpx 0rpx 16rpx #ccc;
}
.logo {
width: 120rpx;
height: 120rpx;
padding: 30rpx;
}
.userName {
font-size: 36rpx;
font-weight: 600;
}
.list {
color: #6C6C6C;
background: #fff;
padding: 20rpx 30rpx;
box-sizing: border-box;
width: 100%;
margin: 40rpx auto;
border-radius: 10rpx;
box-shadow: 0rpx 0rpx 16rpx #ccc;
}
.content {
width: 100%;
overflow: hidden;
margin: 30rpx auto;
}
.title {
float: left;
}
.value {
float: left;
text-align: justify;
width: 400rpx;
word-break: break-word;
}
.pic {
float: left;
position: relative;
margin-right: 8px;
margin-bottom: 8px;
}
.showImg {
width: 160rpx;
height: 160rpx;
}

23
weapp/package/startInspection/startInspection.js

@ -196,11 +196,18 @@ Page({
})
return;
}
if (address == '') {
wx.showToast({
title: '请获取当前位置',
icon: 'none'
})
return;
}
let data = {
patrolPlanId: dataList.id,
pointId: itemData.id,
lastInspectionTime: itemData.lastInspectionTime,
inspectionTime: moment().format('YYYY-MM-DD'),
inspectionTime: moment().format('YYYY-MM-DD HH:mm:ss'),
points: {
user: dataList.user,
project: dataList.project,
@ -217,15 +224,23 @@ Page({
wx.showToast({
title: '提交成功',
})
that.getPatrolRecord()
that.bindCancel();
})
} else {
if (changeTwo == 'normal') {
if (address == '') {
wx.showToast({
title: '请获取当前位置',
icon: 'none'
})
return;
}
let data = {
patrolPlanId: dataList.id,
pointId: itemData.id,
lastInspectionTime: itemData.lastInspectionTime,
inspectionTime: moment().format('YYYY-MM-DD'),
inspectionTime: moment().format('YYYY-MM-DD HH:mm:ss'),
points: {
user: dataList.user,
project: dataList.project,
@ -239,6 +254,7 @@ Page({
wx.showToast({
title: '提交成功',
})
that.getPatrolRecord()
that.bindCancel();
})
return;
@ -269,6 +285,9 @@ Page({
if (i == null) {
e.lastInspectionTime = moment().format('YYYY-MM-DD');
e.inspectionTime = moment().format('YYYY-MM-DD');
} else {
e.lastInspectionTime = moment(i.lastInspectionTime).format('YYYY-MM-DD');
e.inspectionTime = moment(i.inspectionTime).format('YYYY-MM-DD');
}
})
return e;

Loading…
Cancel
Save