Browse Source

(*)巡检结果录入+巡检记录列表暂交

master
Archer_cdm 2 years ago
parent
commit
f857524e7f
  1. 12
      api/app/lib/controllers/patrolRecord/patrolRecord.js
  2. 1
      weapp/app.js
  3. 42
      weapp/package/inspectionRecord/inspectionRecord.js
  4. 2
      weapp/package/inspectionRecord/inspectionRecord.wxml
  5. 144
      weapp/package/startInspection/startInspection.js
  6. 7
      weapp/package/startInspection/startInspection.wxml
  7. 4
      weapp/utils/getApiUrl.js

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

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

1
weapp/app.js

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

42
weapp/package/inspectionRecord/inspectionRecord.js

@ -1,4 +1,8 @@
// package/inspectionRecord/inspectionRecord.js // package/inspectionRecord/inspectionRecord.js
import { getPatrolRecord } from "../../utils/getApiUrl";
import { Request } from "../../common";
const moment = require("../../utils/moment");
Page({ Page({
/** /**
@ -16,7 +20,7 @@ Page({
} }
], ],
ResIndex: 0, //巡检结果 ResIndex: 0, //巡检结果
dataList: [1, 2, 3, 4, 5,], dataList: [],
isPickerRender: false, isPickerRender: false,
isPickerShow: false, isPickerShow: false,
startTime: "开始日期", //开始日期 startTime: "开始日期", //开始日期
@ -72,11 +76,45 @@ Page({
}) })
}, },
// 查询
bindSearch() {
this.getPatrolRecord();
},
// 获取巡检记录
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;
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
// })
})
},
/** /**
* 生命周期函数--监听页面加载 * 生命周期函数--监听页面加载
*/ */
onLoad(options) { onLoad(options) {
this.getPatrolRecord();
}, },
/** /**

2
weapp/package/inspectionRecord/inspectionRecord.wxml

@ -22,7 +22,7 @@
{{ResList[ResIndex].text}} {{ResList[ResIndex].text}}
<image style="width:20rpx;height:20rpx;margin-left:10rpx;" src="../../images/down.svg" /> <image style="width:20rpx;height:20rpx;margin-left:10rpx;" src="../../images/down.svg" />
</picker> </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>
</view> </view>

144
weapp/package/startInspection/startInspection.js

@ -16,6 +16,7 @@ Page({
itemData: '', //单条数据 itemData: '', //单条数据
changeTwo: '', //是否异常 changeTwo: '', //是否异常
changeThree: '', //严重等级 changeThree: '', //严重等级
address: '', //当前位置
}, },
handleChangeTwo(e) { handleChangeTwo(e) {
@ -52,7 +53,8 @@ Page({
msgInp: '', //巡查详情 msgInp: '', //巡查详情
changeTwo: '', //是否异常 changeTwo: '', //是否异常
changeThree: '', //严重等级 changeThree: '', //严重等级
imgs: [] imgs: [],
address: ''
}) })
}, },
@ -174,7 +176,7 @@ Page({
// 开始巡检录入 // 开始巡检录入
addPatrolRecord: function () { addPatrolRecord: function () {
let that = this; 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 => { let newImgs = imgs.map(i => {
i = i.replace(imgUrl, ''); i = i.replace(imgUrl, '');
return i; return i;
@ -196,7 +198,8 @@ Page({
} }
let data = { let data = {
patrolPlanId: dataList.id, patrolPlanId: dataList.id,
lastInspectionTime: moment().format('YYYY-MM-DD'), pointId: itemData.id,
lastInspectionTime: itemData.lastInspectionTime,
inspectionTime: moment().format('YYYY-MM-DD'), inspectionTime: moment().format('YYYY-MM-DD'),
points: { points: {
user: dataList.user, user: dataList.user,
@ -206,6 +209,7 @@ Page({
msgInp: msgInp, msgInp: msgInp,
changeThree: changeThree == 'slight' ? '轻微' : changeThree == 'moderate' ? '中度' : '严重', changeThree: changeThree == 'slight' ? '轻微' : changeThree == 'moderate' ? '中度' : '严重',
imgs: newImgs, imgs: newImgs,
address: address
}, },
alarm: true alarm: true
} }
@ -219,13 +223,15 @@ Page({
if (changeTwo == 'normal') { if (changeTwo == 'normal') {
let data = { let data = {
patrolPlanId: dataList.id, patrolPlanId: dataList.id,
lastInspectionTime: moment().format('YYYY-MM-DD'), pointId: itemData.id,
lastInspectionTime: itemData.lastInspectionTime,
inspectionTime: moment().format('YYYY-MM-DD'), inspectionTime: moment().format('YYYY-MM-DD'),
points: { points: {
user: dataList.user, user: dataList.user,
project: dataList.project, project: dataList.project,
frequency: dataList.frequency, frequency: dataList.frequency,
itemData: itemData, itemData: itemData,
address: address
}, },
alarm: false alarm: false
} }
@ -246,58 +252,90 @@ Page({
// 获取巡检记录 // 获取巡检记录
getPatrolRecord: function () { getPatrolRecord: function () {
Request.get(getPatrolRecord(this.data.dataList.id)).then(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 => {
console.log(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
})
}) })
}, },
// selfLocation() { // 解析经纬度
// const self = this ToDegrees(val) {
// wx.showLoading({ if (typeof (val) == "undefined" || val == "") {
// title: '定位中', return "";
// mask: true, }
// }); var i = val.indexOf('.');
// wx.getLocation({ var strDu = i < 0 ? val : val.substring(0, i);//获取度
// type: 'gcj02', var strFen = 0;
// success: (res) => { var strMiao = 0;
// let latitude, longitude; if (i > 0) {
// latitude = res.latitude.toString(); var strFen = "0" + val.substring(i);
// longitude = res.longitude.toString(); strFen = strFen * 60 + "";
// this.latitude = res.latitude i = strFen.indexOf('.');
// this.longitude = res.longitude if (i > 0) {
// getGeocoder({ lat: latitude, long: longitude }).then(res => { // 获取详细信息的接口 strMiao = "0" + strFen.substring(i);
// const data = res.data; strFen = strFen.substring(0, i);//获取分
// self.userAddress.userAddressdetail = '' strMiao = strMiao * 60 + "";
// var params = { i = strMiao.indexOf('.');
// text: data.address strMiao = strMiao.substring(0, i + 4);//取到小数点后面三位
// } strMiao = parseFloat(strMiao).toFixed(2);//精确小数点后面两位
// parseAddress(params).then(res => { // 粘贴详细信息的接口 }
// console.log(res) }
// if (res.status == 200 && res.message == "success") { return strDu + "°" + strFen + "′" + strMiao + "″";
// 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 : {}; selfLocation() {
// this.addressInfo[1] = res.data.city_info ? res.data.city_info : {}; const that = this
// this.addressInfo[2] = res.data.county_info ? res.data.county_info : {}; wx.showLoading({
// } title: '定位中',
// }).catch(res => { mask: true,
// console.log("没有地址信息") });
// }) wx.getLocation({
// wx.hideLoading(); type: 'wgs84',
// }) success: (res) => {
// }, wx.request({
// fail: (res) => { url: `https://apis.map.qq.com/ws/geocoder/v1/?location=${res.latitude},${res.longitude}&key=${getApp().globalData.key}`,
// console.log(res) success: function (res) {
// wx.hideLoading(); wx.hideLoading();
// wx.showToast({ //根据自己项目需求获取res内容
// title: res.errMsg, that.setData({
// icon: 'none', address: res.data.result.address
// duration: 1000 })
// }); }
// } })
// }); },
// }, fail: (res) => {
console.log(res)
wx.hideLoading();
wx.showToast({
title: res.errMsg,
icon: 'none',
duration: 1000
});
}
});
},
/** /**
* 生命周期函数--监听页面加载 * 生命周期函数--监听页面加载
@ -312,7 +350,7 @@ Page({
dataList: data, dataList: data,
points points
}) })
// that.getPatrolRecord() that.getPatrolRecord();
}, },
/** /**

7
weapp/package/startInspection/startInspection.wxml

@ -44,7 +44,7 @@
</view> </view>
<view class="txt" style="margin-bottom: 20rpx;"> <view class="txt" style="margin-bottom: 20rpx;">
<view style="float: left;font-weight: bold;">上次巡检日期</view> <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>
<view class="txt" style="margin-bottom: 20rpx;"> <view class="txt" style="margin-bottom: 20rpx;">
<view style="float: left;font-weight: bold;">巡检人</view> <view style="float: left;font-weight: bold;">巡检人</view>
@ -52,7 +52,7 @@
</view> </view>
<view class="txt" style="margin-bottom: 20rpx;"> <view class="txt" style="margin-bottom: 20rpx;">
<view style="float: left;font-weight: bold;">本次巡检日期</view> <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>
</view> </view>
</block> </block>
@ -66,7 +66,8 @@
</view> </view>
<view style="padding:20rpx 30rpx;overflow: hidden;"> <view style="padding:20rpx 30rpx;overflow: hidden;">
<view style="float: left;">当前位置:</view> <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> </view>
<radio-group style="padding:10px 15px;display:flex;justify-content: space-evenly;" bindchange="handleChangeTwo"> <radio-group style="padding:10px 15px;display:flex;justify-content: space-evenly;" bindchange="handleChangeTwo">
<radio style="color:#1979ff;" color="#1979ff" value="normal">正常</radio> <radio style="color:#1979ff;" color="#1979ff" value="normal">正常</radio>

4
weapp/utils/getApiUrl.js

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