Browse Source

(*)巡检计划列表+开始巡检列表数据

master
Archer_cdm 2 years ago
parent
commit
ce8c68be7c
  1. 2
      weapp/package/basic/basic.wxss
  2. 3
      weapp/package/inspectionRecord/inspectionRecord.wxml
  3. 76
      weapp/package/polling/polling.js
  4. 2
      weapp/package/polling/polling.json
  5. 14
      weapp/package/polling/polling.wxml
  6. 15
      weapp/package/polling/polling.wxss
  7. 106
      weapp/package/startInspection/startInspection.js
  8. 21
      weapp/package/startInspection/startInspection.wxml
  9. 11
      weapp/pages/index/index.js
  10. 2
      weapp/pages/index/index.wxss
  11. 2
      weapp/pages/myInfo/myInfo.wxss
  12. 2
      weapp/pages/overview/overview.wxss
  13. 7
      weapp/utils/getApiUrl.js
  14. 4603
      weapp/utils/moment.js

2
weapp/package/basic/basic.wxss

@ -1,7 +1,7 @@
/* package/basic/basic.wxss */ /* package/basic/basic.wxss */
page { page {
background-color: rgb(242, 242, 245); background-color: #F7F7FA;
} }
.page { .page {

3
weapp/package/inspectionRecord/inspectionRecord.wxml

@ -10,10 +10,11 @@
</view> </view>
<view style='display:flex;margin-top:28rpx;'> <view style='display:flex;margin-top:28rpx;'>
<view style="line-height: 55rpx;">巡检结果:</view> <view style="line-height: 55rpx;">巡检结果:</view>
<picker class='my-picker' bindchange="bindPickerRes" value="{{ResIndex}}" rangeKey='text' range='{{ResList}}' style="border:2rpx solid #ccc;padding:6rpx 20rpx;border-radius: 6rpx;"> <picker class='my-picker' bindchange="bindPickerRes" value="{{ResIndex}}" rangeKey='text' range='{{ResList}}' style="border:2rpx solid #ccc;padding:6rpx 54rpx;border-radius: 6rpx;">
{{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 74rpx;background:#1979ff;border-radius:6rpx;color:#fff;margin-left:70rpx;">查询</view>
</view> </view>
</view> </view>

76
weapp/package/polling/polling.js

@ -1,11 +1,20 @@
// package/polling/polling.js // package/polling/polling.js
import { getPatrolPlan } from "../../utils/getApiUrl";
import { Request } from "../../common";
const moment = require("../../utils/moment");
Page({ Page({
/** /**
* 页面的初始数据 * 页面的初始数据
*/ */
data: { data: {
dataList: [1, 2, 3, 4, 5,] dataList: [],
limit: 10, //条数
page: 0, //当前页
count: '', //总条数
hidden: true,
}, },
// 顶部tab切换 // 顶部tab切换
@ -21,9 +30,43 @@ Page({
}, },
// 开始巡检 // 开始巡检
bindStart() { bindStart(e) {
let data = e.currentTarget.dataset.item;
wx.navigateTo({ wx.navigateTo({
url: '/package/startInspection/startInspection', url: '/package/startInspection/startInspection?data=' + JSON.stringify(data),
})
},
// 获取巡检计划
getPatrolPlan: function () {
let that = this;
let { page, limit } = that.data;
wx.showLoading({
title: '加载中',
})
Request.get(getPatrolPlan(), { limit, page }).then(res => {
if (res.rows.length == 0) {
that.setData({
dataList: res.rows,
hidden: false
})
wx.hideLoading()
return;
}
let dataSource = res.rows.map(e => {
e.startTime = moment(e.startTime).format('YYYY-MM-DD');
e.endTime = moment(e.endTime).format('YYYY-MM-DD');
return e;
})
var arr1 = that.data.dataList; //从data获取当前dataList数组
var arr2 = dataSource; //从此次请求返回的数据中获取新数组
arr1 = arr1.concat(arr2); //合并数组
that.setData({
dataList: arr1,
count: res.count, //总条数
hidden: true
})
wx.hideLoading()
}) })
}, },
@ -31,7 +74,7 @@ Page({
* 生命周期函数--监听页面加载 * 生命周期函数--监听页面加载
*/ */
onLoad(options) { onLoad(options) {
this.getPatrolPlan();
}, },
/** /**
@ -66,14 +109,35 @@ Page({
* 页面相关事件处理函数--监听用户下拉动作 * 页面相关事件处理函数--监听用户下拉动作
*/ */
onPullDownRefresh() { onPullDownRefresh() {
let that = this;
that.setData({
dataList: [],
page: 0, //当前页
count: '', //总条数
})
that.getPatrolPlan()
// 手动控制回弹
wx.stopPullDownRefresh();
}, },
/** /**
* 页面上拉触底事件的处理函数 * 页面上拉触底事件的处理函数
*/ */
onReachBottom() { onReachBottom() {
let _that = this;
let page = _that.data.page + 1; //获取当前页数并+1
let { dataList, count } = _that.data;
if (dataList.length == count) {
wx.showToast({
title: '没有更多数据了...',
icon: 'none',
})
return;
}
_that.setData({
page: page, //更新当前页数
})
_that.getPatrolPlan()
}, },
/** /**

2
weapp/package/polling/polling.json

@ -2,5 +2,5 @@
"navigationBarBackgroundColor": "#1979ff", "navigationBarBackgroundColor": "#1979ff",
"navigationBarTextStyle": "white", "navigationBarTextStyle": "white",
"navigationBarTitleText": "巡检", "navigationBarTitleText": "巡检",
"enablePullDownRefresh": false "enablePullDownRefresh": true
} }

14
weapp/package/polling/polling.wxml

@ -14,17 +14,23 @@
<view class="listBox"> <view class="listBox">
<view style="padding-bottom:40rpx;overflow: hidden;"> <view style="padding-bottom:40rpx;overflow: hidden;">
<view class="titleBox" style="width: 630rpx; margin: 0 auto;"> <view class="titleBox" style="width: 630rpx; margin: 0 auto;">
<view class="title">结构物A巡检计划</view> <view class="title">{{item.name}}</view>
</view> </view>
<view style="line-height:50rpx;font-size:28rpx;width: 630rpx; margin: 0 auto;"> <view style="line-height:50rpx;font-size:28rpx;width: 630rpx; margin: 0 auto;">
计划时间:<text>2022-12-21至2023-01-15</text> 计划时间:<text>{{item.startTime}}至{{item.endTime}}</text>
</view> </view>
<view style="line-height:50rpx;font-size:28rpx;width: 630rpx; margin: 0 auto;"> <view style="line-height:50rpx;font-size:28rpx;width: 630rpx; margin: 0 auto;">
计划时间:<text>周期巡检(3天一次)</text> 计划时间:<text>{{item.way}}({{item.frequency}})</text>
</view> </view>
<view class="btn" bindtap="bindStart">开始巡检</view> <view class="btn" data-item="{{item}}" bindtap="bindStart">开始巡检</view>
</view> </view>
</view> </view>
</block> </block>
</view> </view>
<!-- 暂无数据 -->
<view hidden="{{hidden}}">
<image class="noData" src="../../images/noData.png"></image>
<view class="noTxt">暂无数据~</view>
</view>
</view> </view>

15
weapp/package/polling/polling.wxss

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

106
weapp/package/startInspection/startInspection.js

@ -5,7 +5,7 @@ Page({
* 页面的初始数据 * 页面的初始数据
*/ */
data: { data: {
dataList: [1, 2, 3] dataList: ''
}, },
handleChangeTwo(e) { handleChangeTwo(e) {
@ -32,59 +32,67 @@ Page({
}) })
}, },
selfLocation() { // selfLocation() {
const self = this // const self = this
wx.showLoading({ // wx.showLoading({
title: '定位中', // title: '定位中',
mask: true, // mask: true,
}); // });
wx.getLocation({ // wx.getLocation({
type: 'gcj02', // type: 'gcj02',
success: (res) => { // success: (res) => {
let latitude, longitude; // let latitude, longitude;
latitude = res.latitude.toString(); // latitude = res.latitude.toString();
longitude = res.longitude.toString(); // longitude = res.longitude.toString();
this.latitude = res.latitude // this.latitude = res.latitude
this.longitude = res.longitude // this.longitude = res.longitude
getGeocoder({ lat: latitude, long: longitude }).then(res => { // 获取详细信息的接口 // getGeocoder({ lat: latitude, long: longitude }).then(res => { // 获取详细信息的接口
const data = res.data; // const data = res.data;
self.userAddress.userAddressdetail = '' // self.userAddress.userAddressdetail = ''
var params = { // var params = {
text: data.address // text: data.address
} // }
parseAddress(params).then(res => { // 粘贴详细信息的接口 // parseAddress(params).then(res => { // 粘贴详细信息的接口
console.log(res) // console.log(res)
if (res.status == 200 && res.message == "success") { // if (res.status == 200 && res.message == "success") {
this.$forceUpdate(); // 定位后,界面没有反应,因此加上强制刷新 // this.$forceUpdate(); // 定位后,界面没有反应,因此加上强制刷新
this.userAddress.userAddressdetail = res.data.town + res.data.detail; // this.userAddress.userAddressdetail = res.data.town + res.data.detail;
this.$set(this.userAddress, 'selectAddress', parseInt(res.data.county_info.city_id)); // 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[0] = res.data.province_info ? res.data.province_info : {};
this.addressInfo[1] = res.data.city_info ? res.data.city_info : {}; // this.addressInfo[1] = res.data.city_info ? res.data.city_info : {};
this.addressInfo[2] = res.data.county_info ? res.data.county_info : {}; // this.addressInfo[2] = res.data.county_info ? res.data.county_info : {};
} // }
}).catch(res => { // }).catch(res => {
console.log("没有地址信息") // console.log("没有地址信息")
}) // })
wx.hideLoading(); // wx.hideLoading();
}) // })
}, // },
fail: (res) => { // fail: (res) => {
console.log(res) // console.log(res)
wx.hideLoading(); // wx.hideLoading();
wx.showToast({ // wx.showToast({
title: res.errMsg, // title: res.errMsg,
icon: 'none', // icon: 'none',
duration: 1000 // duration: 1000
}); // });
} // }
}); // });
}, // },
/** /**
* 生命周期函数--监听页面加载 * 生命周期函数--监听页面加载
*/ */
onLoad(options) { onLoad(options) {
let that = this;
let data = JSON.parse(options.data);
let points = data.points.map(e => {
return e.name
}).join('、')
that.setData({
dataList: data,
points
})
}, },
/** /**

21
weapp/package/startInspection/startInspection.wxml

@ -3,43 +3,43 @@
<view class="titleFirst">巡检要求</view> <view class="titleFirst">巡检要求</view>
<view class="txt"> <view class="txt">
<view style="float: left;font-weight: bold;">结构物名称</view> <view style="float: left;font-weight: bold;">结构物名称</view>
<view style="float:left;width:70%;margin-left:40rpx;">结构物名称</view> <view style="float:left;width:70%;margin-left:40rpx;">{{dataList.name}}</view>
</view> </view>
<view class="txt"> <view class="txt">
<view style="float: left;font-weight: bold;">开始时间</view> <view style="float: left;font-weight: bold;">开始时间</view>
<view style="float:left;width:70%;margin-left:40rpx;">2022-12-25</view> <view style="float:left;width:70%;margin-left:40rpx;">{{dataList.startTime}}</view>
</view> </view>
<view class="txt"> <view class="txt">
<view style="float: left;font-weight: bold;">结束时间</view> <view style="float: left;font-weight: bold;">结束时间</view>
<view style="float:left;width:70%;margin-left:40rpx;">2023-01-15</view> <view style="float:left;width:70%;margin-left:40rpx;">{{dataList.endTime}}</view>
</view> </view>
<view class="txt"> <view class="txt">
<view style="float: left;font-weight: bold;">巡检方式</view> <view style="float: left;font-weight: bold;">巡检方式</view>
<view style="float:left;width:70%;margin-left:40rpx;">周期巡检</view> <view style="float:left;width:70%;margin-left:40rpx;">{{dataList.way}}</view>
</view> </view>
<view class="txt"> <view class="txt">
<view style="float: left;font-weight: bold;">巡检频次</view> <view style="float: left;font-weight: bold;">巡检频次</view>
<view style="float:left;width:70%;margin-left:40rpx;">3天一次</view> <view style="float:left;width:70%;margin-left:40rpx;">{{dataList.frequency}}</view>
</view> </view>
<view class="txt"> <view class="txt">
<view style="float: left;font-weight: bold;">巡检人</view> <view style="float: left;font-weight: bold;">巡检人</view>
<view style="float:left;width:70%;margin-left:40rpx;">巡检人</view> <view style="float:left;width:70%;margin-left:40rpx;">{{dataList.user.name}}</view>
</view> </view>
<view class="txt"> <view class="txt">
<view style="float: left;font-weight: bold;">巡检单位</view> <view style="float: left;font-weight: bold;">巡检单位</view>
<view style="float:left;width:70%;margin-left:40rpx;">巡检单位</view> <view style="float:left;width:70%;margin-left:40rpx;">{{dataList.user.department.name}}</view>
</view> </view>
<view class="txt"> <view class="txt">
<view style="float: left;font-weight: bold;">巡检点位</view> <view style="float: left;font-weight: bold;">巡检点位</view>
<view style="float:left;width:70%;margin-left:40rpx;">点位A、点位B、点位C</view> <view style="float:left;width:70%;margin-left:40rpx;">{{points}}</view>
</view> </view>
<view class="line"></view> <view class="line"></view>
<view class="titleFirst">巡检结果录入</view> <view class="titleFirst">巡检结果录入</view>
<block wx:for="{{dataList}}" wx:key="*this"> <block wx:for="{{dataList.points}}" wx:key="*this">
<view style="margin-bottom: 60rpx;"> <view style="margin-bottom: 60rpx;">
<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;">点位A</view> <view style="float:left;width:55%;margin-left:40rpx;">{{item.name}}</view>
<view class="startBtn" bindtap="showModal">开始巡检</view> <view class="startBtn" bindtap="showModal">开始巡检</view>
</view> </view>
<view class="txt" style="margin-bottom: 20rpx;"> <view class="txt" style="margin-bottom: 20rpx;">
@ -57,6 +57,7 @@
</view> </view>
</block> </block>
<!-- 开始巡检弹框 -->
<view class="modal" wx:if="{{showModal}}"> <view class="modal" wx:if="{{showModal}}">
<view class="popBox"> <view class="popBox">
<view style="padding:20rpx 30rpx;overflow: hidden;"> <view style="padding:20rpx 30rpx;overflow: hidden;">

11
weapp/pages/index/index.js

@ -31,7 +31,7 @@ Page({
that.setData({ that.setData({
page: 0, //当前页 page: 0, //当前页
count: '', //总条数 count: '', //总条数
dataList:[] dataList: []
}) })
that.getProjectList(); that.getProjectList();
}, },
@ -42,22 +42,26 @@ Page({
that.setData({ that.setData({
page: 0, //当前页 page: 0, //当前页
count: '', //总条数 count: '', //总条数
dataList:[] dataList: []
}) })
that.getProjectList(); that.getProjectList();
}, },
// 获取结构物列表 // 获取巡检总览列表
getProjectList: function () { getProjectList: function () {
let that = this; let that = this;
let { page, limit, keyName } = that.data; let { page, limit, keyName } = that.data;
let data = keyName ? { limit, page, name: keyName } : { limit, page } let data = keyName ? { limit, page, name: keyName } : { limit, page }
wx.showLoading({
title: '加载中',
})
Request.get(getProjectList(), data).then(res => { Request.get(getProjectList(), data).then(res => {
if (res.rows.length == 0) { if (res.rows.length == 0) {
that.setData({ that.setData({
dataList: res.rows, dataList: res.rows,
hidden: false hidden: false
}) })
wx.hideLoading()
return; return;
} }
var arr1 = that.data.dataList; //从data获取当前dataList数组 var arr1 = that.data.dataList; //从data获取当前dataList数组
@ -68,6 +72,7 @@ Page({
count: res.count, //总条数 count: res.count, //总条数
hidden: true hidden: true
}) })
wx.hideLoading()
}) })
}, },

2
weapp/pages/index/index.wxss

@ -1,6 +1,6 @@
/* pages/index/index.wxss */ /* pages/index/index.wxss */
page { page {
background: rgb(242, 242, 245); background: #F7F7FA;
} }
.searchBoxs { .searchBoxs {

2
weapp/pages/myInfo/myInfo.wxss

@ -1,7 +1,7 @@
/* pages/myInfo/myInfo.wxss */ /* pages/myInfo/myInfo.wxss */
page { page {
background-color: rgb(242, 242, 245); background-color: #F7F7FA;
} }
/* 容器 */ /* 容器 */

2
weapp/pages/overview/overview.wxss

@ -1,7 +1,7 @@
/* pages/overview/overview.wxss */ /* pages/overview/overview.wxss */
page { page {
background-color: rgb(242, 242, 245); background-color: #F7F7FA;
} }
.box { .box {

7
weapp/utils/getApiUrl.js

@ -8,7 +8,12 @@ exports.logoutUrl = () => {
return `/logout` return `/logout`
} }
// 登出 // 获取巡检总览
exports.getProjectList = () => { exports.getProjectList = () => {
return `/projectList` return `/projectList`
} }
// 获取巡检计划
exports.getPatrolPlan = () => {
return `/patrolPlan`
}

4603
weapp/utils/moment.js

File diff suppressed because it is too large
Loading…
Cancel
Save