wenlele 2 years ago
parent
commit
189bec007a
  1. 16
      api/app/lib/controllers/patrolRecord/patrolRecord.js
  2. 29
      script/1.0.0/schema/4.create_patrol_record.sql
  3. 1
      weapp/app.js
  4. 3
      weapp/app.json
  5. 70
      weapp/package/inspectionRecord/inspectionRecord.js
  6. 2
      weapp/package/inspectionRecord/inspectionRecord.json
  7. 17
      weapp/package/inspectionRecord/inspectionRecord.wxml
  8. 15
      weapp/package/inspectionRecord/inspectionRecord.wxss
  9. 96
      weapp/package/inspectionRecord/inspectionRecordDetail/inspectionRecordDetail.js
  10. 6
      weapp/package/inspectionRecord/inspectionRecordDetail/inspectionRecordDetail.json
  11. 77
      weapp/package/inspectionRecord/inspectionRecordDetail/inspectionRecordDetail.wxml
  12. 71
      weapp/package/inspectionRecord/inspectionRecordDetail/inspectionRecordDetail.wxss
  13. 4
      weapp/package/polling/polling.js
  14. 170
      weapp/package/startInspection/startInspection.js
  15. 7
      weapp/package/startInspection/startInspection.wxml
  16. 2
      weapp/pages/index/index.wxml
  17. 4
      weapp/utils/getApiUrl.js
  18. 171
      web/client/src/sections/patrolManage/containers/patrolRecord.js

16
api/app/lib/controllers/patrolRecord/patrolRecord.js

@ -1,6 +1,6 @@
'use strict';
async function findPatrolRecord (ctx, next) {
async function findPatrolRecord(ctx, next) {
let rslt = [];
let error = { name: 'FindError', message: '获取巡检记录失败' };
try {
@ -10,7 +10,7 @@ async function findPatrolRecord (ctx, next) {
if (patrolPlanId == 'all') {
/* 如果有startTime && endTime,查询所有符合条件的数据 */
if (startTime !== 'null' && endTime !== 'null') {
if (pointId) {
if (pointId !== 'null') {
if (alarm == 'null') {
rslt = await models.PatrolRecord.findAll({
where: { inspectionTime: { $between: [startTime, endTime] }, pointId: { $in: pointId.split(',') } },
@ -34,18 +34,18 @@ async function findPatrolRecord (ctx, next) {
} else {
/* 如果没有startTime && endTime,查询每个点位最新一条符合条件的数据 */
let a = []
if (pointId) {
if (pointId !== 'null') {
a = await models.PatrolRecord.findAll({
where: { pointId: { $in: pointId.split(',') } },
});
}
rslt = pointId.split(',').map(i => {
return a.filter(t => t.pointId === i).sort((a, b) => b.id - a.id)[0] || null
return a.filter(t => t.pointId == i).sort((a, b) => b.id - a.id)[0] || null
})
}
} else {
if (startTime !== 'null' && endTime !== 'null') {
if (pointId) {
if (pointId !== 'null') {
rslt = await models.PatrolRecord.findAll({
where: { patrolPlanId: { $in: patrolPlanId.split(',') }, alarm, inspectionTime: { $between: [startTime, endTime] }, pointId: { $in: pointId.split(',') } },
});
@ -58,7 +58,7 @@ async function findPatrolRecord (ctx, next) {
} else {
let a = []
/* 如果没有startTime && endTime,查询每个点位最新一条符合条件的数据 */
if (pointId) {
if (pointId !== 'null') {
a = await models.PatrolRecord.findAll({
where: { patrolPlanId: { $in: patrolPlanId.split(',') }, pointId: { $in: pointId.split(',') } },
});
@ -69,7 +69,7 @@ async function findPatrolRecord (ctx, next) {
}
rslt = pointId.split(',').map(i => {
return a.filter(t => t.pointId === i).sort((a, b) => b.id - a.id)[0] || null
return a.filter(t => t.pointId == i).sort((a, b) => b.id - a.id)[0] || null
})
}
}
@ -86,7 +86,7 @@ async function findPatrolRecord (ctx, next) {
}
}
async function addPatrolRecord (ctx, next) {
async function addPatrolRecord(ctx, next) {
let error = { name: 'addError', message: '新增巡检记录失败' };
try {
const models = ctx.fs.dc.models;

29
script/1.0.0/schema/4.create_patrol_record.sql

@ -0,0 +1,29 @@
create table patrol_record
(
id serial,
patrol_plan_id int not null,
last_inspection_time timestamp,
inspection_time timestamp,
points jsonb,
alarm boolean default false not null,
point_id int,
);
comment on column patrol_record.patrol_plan_id is '对应巡检计划的id';
comment on column patrol_record.last_inspection_time is '上次巡检时间';
comment on column patrol_record.inspection_time is '本次巡检时间';
comment on column patrol_record.points is '点位详情数组';
comment on column patrol_record.alarm is '是否异常';
comment on column patrol_record.point_id is '点位Id';
create unique index patrol_record_id_uindex
on patrol_record (id);
alter table patrol_record
add constraint patrol_record_pk
primary key (id);

1
weapp/app.js

@ -6,6 +6,7 @@ App({
baseUrl: 'http://10.8.16.221:4900', //api 本地环境
webUrl: "http://10.8.16.221:5900/", //web 本地环境
imgUrl: 'http://10.8.16.221:5900/_file-server/', //文件 本地环境
key: 'ODQBZ-3FZAU-6VIVL-2XXNM-F7CP7-WVFCY' //获取位置信息
},
onShow(e) {
// 检查是否有更新

3
weapp/app.json

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

70
weapp/package/inspectionRecord/inspectionRecord.js

@ -1,4 +1,8 @@
// package/inspectionRecord/inspectionRecord.js
import { getPatrolRecord } from "../../utils/getApiUrl";
import { Request } from "../../common";
const moment = require("../../utils/moment");
Page({
/**
@ -6,6 +10,10 @@ Page({
*/
data: {
ResList: [ //阅读状态
{
value: 'all',
text: '全部',
},
{
value: 'normal',
text: '正常',
@ -16,7 +24,7 @@ Page({
}
],
ResIndex: 0, //巡检结果
dataList: [1, 2, 3, 4, 5,],
dataList: [],
isPickerRender: false,
isPickerShow: false,
startTime: "开始日期", //开始日期
@ -30,6 +38,7 @@ Page({
// limitStartTime: "", //最小可选时间
// limitEndTime: "" //最大可选时间
},
hidden: true,
},
// 巡检结果
@ -72,11 +81,57 @@ Page({
})
},
// 查询
bindSearch() {
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 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 + ' 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()
})
},
/**
* 生命周期函数--监听页面加载
*/
onLoad(options) {
this.getPatrolRecord();
},
/**
@ -111,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"
}

17
weapp/package/inspectionRecord/inspectionRecord.wxml

@ -22,7 +22,7 @@
{{ResList[ResIndex].text}}
<image style="width:20rpx;height:20rpx;margin-left:10rpx;" src="../../images/down.svg" />
</picker>
<view style="padding:6rpx 64rpx;background:#1979ff;border-radius:6rpx;color:#fff;margin-left:70rpx;">查询</view>
<view style="padding:6rpx 64rpx;background:#1979ff;border-radius:6rpx;color:#fff;margin-left:70rpx;" bindtap="bindSearch">查询</view>
</view>
</view>
@ -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

@ -61,4 +61,19 @@ page {
.clearDate image {
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;
}

4
weapp/package/polling/polling.js

@ -30,9 +30,9 @@ Page({
// 开始巡检
bindStart(e) {
let data = e.currentTarget.dataset.item;
let data = JSON.stringify(e.currentTarget.dataset.item);
wx.navigateTo({
url: '/package/startInspection/startInspection?data=' + JSON.stringify(data),
url: '/package/startInspection/startInspection?data=' + encodeURIComponent(data),
})
},

170
weapp/package/startInspection/startInspection.js

@ -16,6 +16,7 @@ Page({
itemData: '', //单条数据
changeTwo: '', //是否异常
changeThree: '', //严重等级
address: '', //当前位置
},
handleChangeTwo(e) {
@ -52,7 +53,8 @@ Page({
msgInp: '', //巡查详情
changeTwo: '', //是否异常
changeThree: '', //严重等级
imgs: []
imgs: [],
address: ''
})
},
@ -174,7 +176,7 @@ Page({
// 开始巡检录入
addPatrolRecord: function () {
let that = this;
let { itemData, imgs, msgInp, changeTwo, changeThree, dataList, imgUrl } = that.data;
let { itemData, imgs, msgInp, changeTwo, changeThree, dataList, imgUrl, address } = that.data;
let newImgs = imgs.map(i => {
i = i.replace(imgUrl, '');
return i;
@ -194,10 +196,18 @@ Page({
})
return;
}
if (address == '') {
wx.showToast({
title: '请获取当前位置',
icon: 'none'
})
return;
}
let data = {
patrolPlanId: dataList.id,
lastInspectionTime: moment().format('YYYY-MM-DD'),
inspectionTime: moment().format('YYYY-MM-DD'),
pointId: itemData.id,
lastInspectionTime: itemData.lastInspectionTime,
inspectionTime: moment().format('YYYY-MM-DD HH:mm:ss'),
points: {
user: dataList.user,
project: dataList.project,
@ -206,6 +216,7 @@ Page({
msgInp: msgInp,
changeThree: changeThree == 'slight' ? '轻微' : changeThree == 'moderate' ? '中度' : '严重',
imgs: newImgs,
address: address
},
alarm: true
}
@ -213,19 +224,29 @@ 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,
lastInspectionTime: moment().format('YYYY-MM-DD'),
inspectionTime: moment().format('YYYY-MM-DD'),
pointId: itemData.id,
lastInspectionTime: itemData.lastInspectionTime,
inspectionTime: moment().format('YYYY-MM-DD HH:mm:ss'),
points: {
user: dataList.user,
project: dataList.project,
frequency: dataList.frequency,
itemData: itemData,
address: address
},
alarm: false
}
@ -233,6 +254,7 @@ Page({
wx.showToast({
title: '提交成功',
})
that.getPatrolRecord()
that.bindCancel();
})
return;
@ -246,65 +268,99 @@ Page({
// 获取巡检记录
getPatrolRecord: function () {
Request.get(getPatrolRecord(this.data.dataList.id)).then(res => {
console.log(res);
let that = this;
let { dataList } = that.data;
let pointId = dataList.points.map(i => {
return i.id;
})
wx.showLoading({
title: '加载中'
})
Request.get(getPatrolRecord(dataList.id, 'null', 'null', 'null', pointId)).then(res => {
dataList.points.map(e => {
res.map(i => {
wx.hideLoading();
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;
})
that.setData({
dataList
})
})
},
// 解析经纬度
ToDegrees(val) {
if (typeof (val) == "undefined" || val == "") {
return "";
}
var i = val.indexOf('.');
var strDu = i < 0 ? val : val.substring(0, i);//获取度
var strFen = 0;
var strMiao = 0;
if (i > 0) {
var strFen = "0" + val.substring(i);
strFen = strFen * 60 + "";
i = strFen.indexOf('.');
if (i > 0) {
strMiao = "0" + strFen.substring(i);
strFen = strFen.substring(0, i);//获取分
strMiao = strMiao * 60 + "";
i = strMiao.indexOf('.');
strMiao = strMiao.substring(0, i + 4);//取到小数点后面三位
strMiao = parseFloat(strMiao).toFixed(2);//精确小数点后面两位
}
}
return strDu + "°" + strFen + "′" + strMiao + "″";
},
// selfLocation() {
// const self = this
// wx.showLoading({
// title: '定位中',
// mask: true,
// });
// wx.getLocation({
// type: 'gcj02',
// success: (res) => {
// let latitude, longitude;
// latitude = res.latitude.toString();
// longitude = res.longitude.toString();
// this.latitude = res.latitude
// this.longitude = res.longitude
// getGeocoder({ lat: latitude, long: longitude }).then(res => { // 获取详细信息的接口
// const data = res.data;
// self.userAddress.userAddressdetail = ''
// var params = {
// text: data.address
// }
// parseAddress(params).then(res => { // 粘贴详细信息的接口
// console.log(res)
// if (res.status == 200 && res.message == "success") {
// this.$forceUpdate(); // 定位后,界面没有反应,因此加上强制刷新
// this.userAddress.userAddressdetail = res.data.town + res.data.detail;
// this.$set(this.userAddress, 'selectAddress', parseInt(res.data.county_info.city_id));
// this.addressInfo[0] = res.data.province_info ? res.data.province_info : {};
// this.addressInfo[1] = res.data.city_info ? res.data.city_info : {};
// this.addressInfo[2] = res.data.county_info ? res.data.county_info : {};
// }
// }).catch(res => {
// console.log("没有地址信息")
// })
// wx.hideLoading();
// })
// },
// fail: (res) => {
// console.log(res)
// wx.hideLoading();
// wx.showToast({
// title: res.errMsg,
// icon: 'none',
// duration: 1000
// });
// }
// });
// },
// 获取当前位置
selfLocation() {
const that = this
wx.showLoading({
title: '定位中',
mask: true,
});
wx.getLocation({
type: 'wgs84',
success: (res) => {
wx.request({
url: `https://apis.map.qq.com/ws/geocoder/v1/?location=${res.latitude},${res.longitude}&key=${getApp().globalData.key}`,
success: function (res) {
wx.hideLoading();
//根据自己项目需求获取res内容
that.setData({
address: res.data.result.address
})
}
})
},
fail: (res) => {
console.log(res)
wx.hideLoading();
wx.showToast({
title: res.errMsg,
icon: 'none',
duration: 1000
});
}
});
},
/**
* 生命周期函数--监听页面加载
*/
onLoad(options) {
console.log(options, '-------');
let that = this;
let data = JSON.parse(options.data);
let data = JSON.parse(decodeURIComponent(options.data));
let points = data.points.map(e => {
return e.name
}).join('、')
@ -312,7 +368,7 @@ Page({
dataList: data,
points
})
// that.getPatrolRecord()
that.getPatrolRecord();
},
/**

7
weapp/package/startInspection/startInspection.wxml

@ -44,7 +44,7 @@
</view>
<view class="txt" style="margin-bottom: 20rpx;">
<view style="float: left;font-weight: bold;">上次巡检日期</view>
<view style="float:left;width:55%;margin-left:40rpx;">2022-10-26</view>
<view style="float:left;width:55%;margin-left:40rpx;">{{item.lastInspectionTime}}</view>
</view>
<view class="txt" style="margin-bottom: 20rpx;">
<view style="float: left;font-weight: bold;">巡检人</view>
@ -52,7 +52,7 @@
</view>
<view class="txt" style="margin-bottom: 20rpx;">
<view style="float: left;font-weight: bold;">本次巡检日期</view>
<view style="float:left;width:55%;margin-left:40rpx;">2022-12-23</view>
<view style="float:left;width:55%;margin-left:40rpx;">{{item.inspectionTime}}</view>
</view>
</view>
</block>
@ -66,7 +66,8 @@
</view>
<view style="padding:20rpx 30rpx;overflow: hidden;">
<view style="float: left;">当前位置:</view>
<view style="float:left;width:480rpx;text-align: justify;">点位A</view>
<view style="float:left;width:480rpx;text-align: justify;" wx:if="{{address}}">{{address}}</view>
<view style="float:left;width:480rpx;text-align: justify;" bindtap="selfLocation" wx:if="{{!address}}">点击获取当前位置</view>
</view>
<radio-group style="padding:10px 15px;display:flex;justify-content: space-evenly;" bindchange="handleChangeTwo">
<radio style="color:#1979ff;" color="#1979ff" value="normal">正常</radio>

2
weapp/pages/index/index.wxml

@ -10,7 +10,7 @@
<view style="margin-top: 140rpx;">
<block wx:for="{{dataList}}" wx:key='*this'>
<view style="padding-bottom: 60rpx;">
<image wx:if="{{item.img != null || item.img.length > 0}}" style="width: 100%;height: 372rpx;display: block;" src="{{imgUrl + item.img[0]}}"></image>
<image wx:if="{{item.img != null && item.img.length > 0}}" style="width: 100%;height: 372rpx;display: block;" src="{{imgUrl + item.img[0]}}"></image>
<view wx:if="{{item.img == null || item.img.length == 0}}" style="width: 100%;height: 372rpx;line-height: 372rpx;text-align: center;background: #fff;border-bottom: 2rpx solid #ccc;">暂无图片</view>
<view class="box">
<view style="font-weight:bold;font-size:32rpx;">{{item.name}}</view>

4
weapp/utils/getApiUrl.js

@ -24,6 +24,6 @@ exports.addPatrolRecord = () => {
}
// 获取巡检记录
exports.getPatrolRecord = (patrolPlanId, startTime, endTime, alarm) => {
return `/patrolRecord/${patrolPlanId}/${startTime}/${endTime}/${alarm}`
exports.getPatrolRecord = (patrolPlanId, startTime, endTime, alarm, pointId) => {
return `/patrolRecord/${patrolPlanId}/${startTime}/${endTime}/${alarm}/${pointId}`
}

171
web/client/src/sections/patrolManage/containers/patrolRecord.js

@ -3,14 +3,14 @@
import React, { useEffect, useState } from 'react';
import { connect } from 'react-redux';
import { Form, Input, Select, Button, Table, Modal, DatePicker } from 'antd';
import { Form, Input, Select, Button, Table, Modal, DatePicker, Checkbox, Row, Col } from 'antd';
import moment from "moment";
const PatrolRecord = (props) => {
const { dispatch, actions, } = props
const { patrolManage } = actions
const [tableList, settableList] = useState([])
const [addModel, setAddModel] = useState(false)
const [showDetailModal, setShowDetail] = useState(false)
const [modelData, setModelData] = useState({})
const [query, setQuery] = useState({ limit: 10, page: 0 })
const [limits, setLimits] = useState()
@ -22,80 +22,82 @@ const PatrolRecord = (props) => {
}, [])
const record = (params) => {
dispatch(patrolManage.records(`patrolRecord/all/${params.time[0]}/${params.time[1]}/${params.state}/1`)).then(res => {
dispatch(patrolManage.records(`patrolRecord/all/${params.time[0]}/${params.time[1]}/${params.state}/null`)).then(res => {
if (res.success) {
settableList(res.payload.data?.map(v => ({ ...v, key: v.id })))
settableList(params.name != null ? res.payload.data?.filter(v =>
(v.points.user.name.indexOf(params.name) != -1 || v.points.project.name.indexOf(params.name) != -1))
.map(v => ({ ...v, key: v.id })) : res.payload.data?.map(v => ({ ...v, key: v.id })))
setLimits(res.payload.data?.length)
}
})
}
const columns = [{
title: '结构物名称',
dataIndex: 'name',
key: 'name',
render: (text, record, index) => {
return !record.points?.project? '':<div style={{ width: 100 }}>{record.points.project.name}</div>
}
}, {
title: '巡检人',
dataIndex: 'type',
key: 'type',
render: (text, record, index) => {
return !record.points?.user? '':<div style={{ width: 100 }}>{record.points.user.name}</div>
}
}, {
title: '巡检点位',
dataIndex: 'type',
key: 'type',
render: (text, record, index) => {
return !record.points?.user? '':<div style={{ width: 100 }}>{record.points.itemData.name}</div>
}
}, {
title: '巡检单位',
dataIndex: 'type',
key: 'type',
render: (text, record, index) => {
return !record.points?.user? '':<div style={{ width: 100 }}>{record.points.user.department.name}</div>
}
}, {
title: '巡检频次',
dataIndex: 'describe',
key: 'describe',
render: (text, record, index) => {
return !record.points? '':<div style={{ width: 100 }}>{record.points.frequency}</div>
}
}, {
title: '上次巡检日期',
dataIndex: 'describe',
key: 'describe',
render: (text, record, index) => moment(record.lastInspectionTime).format('YYYY-MM-DD HH:mm') || '--'
}, {
title: '本次巡检日期',
dataIndex: 'describe',
key: 'describe',
render: (text, record, index) => moment(record.inspectionTime).format('YYYY-MM-DD HH:mm') || '--'
}, {
title: '巡检结果',
dataIndex: 'describe',
key: 'describe',
render: (text, record, index) => !record.alarm? '正常':'异常'
}, {
title: '操作',
dataIndex: 'operation',
key: 'operation',
render: (text, record, index) => {
return (
<div style={{ width: 190 }}>
<Button type="link" onClick={() => {
setAddModel(true)
setModelData(record)
}}>
查看详情</Button>
</div>
)
}
title: '结构物名称',
dataIndex: 'name',
key: 'name',
render: (text, record, index) => {
return !record.points?.project ? '' : <div style={{ width: 100 }}>{record.points.project.name}</div>
}
}, {
title: '巡检人',
dataIndex: 'type',
key: 'type',
render: (text, record, index) => {
return !record.points?.user ? '' : <div style={{ width: 100 }}>{record.points.user.name}</div>
}
}, {
title: '巡检点位',
dataIndex: 'type',
key: 'type',
render: (text, record, index) => {
return !record.points?.user ? '' : <div style={{ width: 100 }}>{record.points.itemData.name}</div>
}
}, {
title: '巡检单位',
dataIndex: 'type',
key: 'type',
render: (text, record, index) => {
return !record.points?.user ? '' : <div style={{ width: 100 }}>{record.points.user.department.name}</div>
}
}, {
title: '巡检频次',
dataIndex: 'describe',
key: 'describe',
render: (text, record, index) => {
return !record.points ? '' : <div style={{ width: 100 }}>{record.points.frequency}</div>
}
}, {
title: '上次巡检日期',
dataIndex: 'describe',
key: 'describe',
render: (text, record, index) => moment(record.lastInspectionTime).format('YYYY-MM-DD HH:mm') || '--'
}, {
title: '本次巡检日期',
dataIndex: 'describe',
key: 'describe',
render: (text, record, index) => moment(record.inspectionTime).format('YYYY-MM-DD HH:mm') || '--'
}, {
title: '巡检结果',
dataIndex: 'describe',
key: 'describe',
render: (text, record, index) => !record.alarm ? '正常' : '异常'
}, {
title: '操作',
dataIndex: 'operation',
key: 'operation',
render: (text, record, index) => {
return (
<div style={{ width: 190 }}>
<Button type="link" onClick={() => {
setShowDetail(true)
setModelData(record)
}}>
查看详情</Button>
</div>
)
}
}
]
return (
@ -122,10 +124,10 @@ const PatrolRecord = (props) => {
style={{ marginRight: 16, }}
initialValue={[moment(search.time[0], format), moment(search.time[1], format)]}
>
<DatePicker.RangePicker style={{ marginRight: 16, }}/>
<DatePicker.RangePicker showTime style={{ marginRight: 16, }} />
</Form.Item>
<Form.Item
name="state"
<Form.Item
name="state"
style={{ marginRight: 16, }}
initialValue={'null'}
>
@ -160,6 +162,33 @@ const PatrolRecord = (props) => {
}
}}
/>
<Modal
title='巡检记录详情'
open={showDetailModal}
onCancel={() => setShowDetail(false)}
footer={[<Button onClick={() => setShowDetail(false)}>关闭</Button>]}
>
<Row align='middle' justify='center' style={{ marginBottom: 10 }}>
当前点位{modelData?.points?.itemData?.name}
</Row>
<Row align='middle' justify='center' style={{ marginBottom: 10 }}>
当前位置{modelData?.points?.address}
</Row>
<Row align='middle' justify='center' style={{ marginBottom: 10 }}>
巡检结果{modelData.alarm? '异常':'正常'}
</Row>
{ !modelData.alarm? '':
<Row align='middle' justify='center' style={{ marginBottom: 10 }}>
巡检详情{modelData?.points?.msgInp}
</Row> }
{ !modelData.alarm? '':
<Row align='middle' justify='center' style={{ marginBottom: 10 }}>
异常等级{modelData?.points?.changeThree}
</Row> }
{ !modelData.alarm? '':<Row align='middle' justify='center' style={{ marginBottom: 10 }}>
{ modelData?.points?.imgs?.map(rs => <img key={rs} src={`/_file-server/${rs}`} style={{ display: 'inline-block', width: 260, marginBottom: 10 }} />)}
</Row> }
</Modal>
</>
)
}

Loading…
Cancel
Save