liujiangyong
2 years ago
14 changed files with 331 additions and 390 deletions
@ -1,193 +0,0 @@ |
|||
// package/inspectionRecord/inspectionRecord.js
|
|||
import { getPatrolRecord } from "../../utils/getApiUrl"; |
|||
import { Request } from "../../common"; |
|||
const moment = require("../../utils/moment"); |
|||
|
|||
Page({ |
|||
|
|||
/** |
|||
* 页面的初始数据 |
|||
*/ |
|||
data: { |
|||
ResList: [ //阅读状态
|
|||
{ |
|||
value: 'all', |
|||
text: '全部', |
|||
}, |
|||
{ |
|||
value: 'normal', |
|||
text: '正常', |
|||
}, |
|||
{ |
|||
value: 'abnormal', |
|||
text: '异常', |
|||
} |
|||
], |
|||
ResIndex: 0, //巡检结果
|
|||
dataList: [], |
|||
isPickerRender: false, |
|||
isPickerShow: false, |
|||
startTime: "开始日期", //开始日期
|
|||
endTime: "结束日期", //结束日期
|
|||
pickerConfig: { //自定义时间选择器配置项
|
|||
endDate: true, //是否需要结束时间,为true时显示开始时间和结束时间两个picker
|
|||
column: "day", //可选的最小时间范围day、hour、minute、second
|
|||
dateLimit: true, //是否现在时间可选范围,false时可选任意时间;当为数字n时,范围是当前时间的最近n天
|
|||
initStartTime: "", //picker初始时间
|
|||
initEndTime: "", //picker初始结束时间
|
|||
// limitStartTime: "", //最小可选时间
|
|||
// limitEndTime: "" //最大可选时间
|
|||
}, |
|||
hidden: true, |
|||
}, |
|||
|
|||
// 巡检结果
|
|||
bindPickerRes(e) { |
|||
let that = this; |
|||
that.setData({ |
|||
ResIndex: e.detail.value |
|||
}) |
|||
}, |
|||
|
|||
// 时间选择器显示
|
|||
pickerShow: function () { |
|||
this.setData({ |
|||
isPickerShow: true, |
|||
isPickerRender: true, |
|||
}); |
|||
}, |
|||
|
|||
// 时间选择器隐藏
|
|||
pickerHide: function () { |
|||
this.setData({ |
|||
isPickerShow: false, |
|||
}); |
|||
}, |
|||
|
|||
// 获取选择时间
|
|||
setPickerTime: function (val) { |
|||
let data = val.detail; |
|||
this.setData({ |
|||
startTime: data.startTime, |
|||
endTime: data.endTime |
|||
}); |
|||
}, |
|||
|
|||
// 清空提交日期筛选框
|
|||
bindClearDate() { |
|||
this.setData({ |
|||
startTime: '开始日期', |
|||
endTime: '结束日期' |
|||
}) |
|||
}, |
|||
|
|||
// 查询
|
|||
bindSearch() { |
|||
this.getPatrolRecord(); |
|||
}, |
|||
|
|||
// 查看详情
|
|||
bindDetail(e) { |
|||
let data = JSON.stringify(e.currentTarget.dataset.item); |
|||
wx.navigateTo({ |
|||
url: '/package/inspectionRecord/inspectionRecordDetail/inspectionRecordDetail?data=' + encodeURIComponent(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'); |
|||
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(); |
|||
}, |
|||
|
|||
/** |
|||
* 生命周期函数--监听页面初次渲染完成 |
|||
*/ |
|||
onReady() { |
|||
|
|||
}, |
|||
|
|||
/** |
|||
* 生命周期函数--监听页面显示 |
|||
*/ |
|||
onShow() { |
|||
|
|||
}, |
|||
|
|||
/** |
|||
* 生命周期函数--监听页面隐藏 |
|||
*/ |
|||
onHide() { |
|||
|
|||
}, |
|||
|
|||
/** |
|||
* 生命周期函数--监听页面卸载 |
|||
*/ |
|||
onUnload() { |
|||
|
|||
}, |
|||
|
|||
/** |
|||
* 页面相关事件处理函数--监听用户下拉动作 |
|||
*/ |
|||
onPullDownRefresh() { |
|||
let that = this; |
|||
that.setData({ |
|||
dataList: [], |
|||
ResIndex: 0, //巡检结果
|
|||
startTime: "开始日期", //开始日期
|
|||
endTime: "结束日期", //结束日期
|
|||
}) |
|||
that.getPatrolRecord() |
|||
// 手动控制回弹
|
|||
wx.stopPullDownRefresh(); |
|||
}, |
|||
|
|||
/** |
|||
* 页面上拉触底事件的处理函数 |
|||
*/ |
|||
onReachBottom() { |
|||
|
|||
}, |
|||
|
|||
/** |
|||
* 用户点击右上角分享 |
|||
*/ |
|||
onShareAppMessage() { |
|||
|
|||
} |
|||
}) |
@ -1,9 +0,0 @@ |
|||
{ |
|||
"navigationBarBackgroundColor": "#1979ff", |
|||
"navigationBarTextStyle": "white", |
|||
"navigationBarTitleText": "巡检记录", |
|||
"enablePullDownRefresh": true, |
|||
"usingComponents": { |
|||
"timePicker": "/components/timePicker/index" |
|||
} |
|||
} |
@ -1,54 +0,0 @@ |
|||
<!--package/inspectionRecord/inspectionRecord.wxml--> |
|||
<view style="box-shadow:0px 0px 5px #7e7e7e;padding: 15px;background: #fff;position:fixed;top:0;left:0;width: 100%;"> |
|||
<view style="display: flex;"> |
|||
<view style="line-height:50rpx;">时间范围:</view> |
|||
<view style="display: flex;"> |
|||
<!-- 自定义时间选择器 --> |
|||
<view class="page-date" style="{{startTime != '开始日期' && endTime != '结束日期' ? 'float:left' : ''}}" bindtap="pickerShow"> |
|||
<view style="{{startTime == '开始日期' && endTime == '结束日期' ? 'color:#ccc;' : ''}}">{{startTime}}<text style="margin: 0 20rpx;color:#000;"> 至 </text>{{endTime}}</view> |
|||
</view> |
|||
<view class="clearDate" wx:if="{{startTime != '开始日期' && endTime != '结束日期'}}" bindtap="bindClearDate"> |
|||
<image src="/images/close.svg"></image> |
|||
</view> |
|||
<timePicker pickerShow="{{isPickerShow}}" id="picker" wx:if="{{isPickerRender}}" bind:hidePicker="pickerHide" bind:setPickerTime="setPickerTime" config="{{pickerConfig}}"></timePicker> |
|||
</view> |
|||
|
|||
|
|||
|
|||
</view> |
|||
<view style='display:flex;margin-top:28rpx;'> |
|||
<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 42rpx;border-radius: 6rpx;"> |
|||
{{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;" bindtap="bindSearch">查询</view> |
|||
</view> |
|||
</view> |
|||
|
|||
<view class="contentBox"> |
|||
<block wx:for="{{dataList}}" wx:key='*this'> |
|||
<view class="listBox"> |
|||
<view style="padding-bottom:40rpx;overflow: hidden;"> |
|||
<view class="titleBox" style="width: 630rpx; margin: 0 auto;"> |
|||
<view class="title">{{item.points.project.name}}</view> |
|||
</view> |
|||
<view style="line-height:50rpx;font-size:28rpx;width: 630rpx; margin: 0 auto;"> |
|||
本次巡检日期:<text>{{item.inspectionTime}}</text> |
|||
</view> |
|||
<view style="line-height:50rpx;font-size:28rpx;width: 630rpx; margin: 0 auto;"> |
|||
巡检人:<text>{{item.points.user.name}}</text> |
|||
</view> |
|||
<view style="line-height:50rpx;font-size:28rpx;width: 630rpx; margin: 0 auto;"> |
|||
巡检结果:<text>{{item.alarm ? '异常' : '正常'}}</text> |
|||
</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> |
@ -1,79 +0,0 @@ |
|||
/* package/inspectionRecord/inspectionRecord.wxss */ |
|||
page { |
|||
background: #F7F7FA; |
|||
} |
|||
|
|||
.my-picker { |
|||
white-space: nowrap; |
|||
width: 100rpx; |
|||
} |
|||
|
|||
.contentBox { |
|||
padding: 210rpx 30rpx 20rpx; |
|||
} |
|||
|
|||
.listBox { |
|||
background-color: #fff; |
|||
border-radius: 10rpx; |
|||
box-shadow: 0rpx 0rpx 10rpx #ddd; |
|||
margin: 30rpx auto; |
|||
overflow: hidden; |
|||
} |
|||
|
|||
.titleBox { |
|||
overflow: hidden; |
|||
padding-bottom: 20rpx; |
|||
padding-top: 40rpx; |
|||
} |
|||
|
|||
.title { |
|||
float: left; |
|||
font-size: 32rpx; |
|||
width: 460rpx; |
|||
font-weight: bold; |
|||
} |
|||
|
|||
.btn { |
|||
width: 130rpx; |
|||
text-align: center; |
|||
font-size: 30rpx; |
|||
padding: 20rpx; |
|||
background: #1979ff; |
|||
color: #fff; |
|||
border-radius: 10rpx; |
|||
float: left; |
|||
margin-left: 30rpx; |
|||
margin-top: 20rpx; |
|||
} |
|||
|
|||
.page-date { |
|||
text-align: center; |
|||
padding-top: 6rpx; |
|||
margin-right: 20rpx; |
|||
background: #fff; |
|||
} |
|||
|
|||
.clearDate { |
|||
float: left; |
|||
line-height: 50rpx; |
|||
} |
|||
|
|||
.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; |
|||
} |
@ -1,36 +1,99 @@ |
|||
<!--package/polling/polling.wxml--> |
|||
<!-- package/polling/polling.wxml --> |
|||
<view class="page"> |
|||
<!-- 顶部tab切换 --> |
|||
<view class='swiper-tab'> |
|||
<view class="swiper-tab-item active" data-current="0" bindtap="clickTab">巡检记录</view> |
|||
<!-- <view class="swiper-tab-item active" data-current="1" bindtap="clickTab">问题上报</view> --> |
|||
<view class="swiper-tab-item" data-current="0" bindtap="clickTab" style="{{currentTab=='0' ? 'color:#1979ff' : 'color:black'}}">待巡检</view> |
|||
<view class="swiper-tab-item" data-current="1" bindtap="clickTab" style="{{currentTab=='1' ? 'color:#1979ff' : 'color:black'}}">巡检记录</view> |
|||
</view> |
|||
<view class='swiper-tab' style="top:100rpx;"> |
|||
<view class="swiper-tab-item">待巡检</view> |
|||
|
|||
<!-- 待巡检 --> |
|||
<view class="wait-patrol" wx:if="{{currentTab=='0'}}"> |
|||
<view class="contentBox"> |
|||
<block wx:for="{{dataList}}" wx:key='*this'> |
|||
<view class="listBox"> |
|||
<view style="padding-bottom:40rpx;overflow: hidden;"> |
|||
<view class="titleBox" style="width: 630rpx; margin: 0 auto;"> |
|||
<view class="title">{{item.name}}</view> |
|||
</view> |
|||
<view style="line-height:50rpx;font-size:28rpx;width: 630rpx; margin: 0 auto;"> |
|||
计划时间: |
|||
<text>{{item.startTime}}至{{item.endTime}}</text> |
|||
</view> |
|||
<view style="line-height:50rpx;font-size:28rpx;width: 630rpx; margin: 0 auto;"> |
|||
计划时间: |
|||
<text>{{item.way}}({{item.frequency}})</text> |
|||
</view> |
|||
<view class="btn" data-item="{{item}}" bindtap="bindStart">开始巡检</view> |
|||
</view> |
|||
</view> |
|||
</block> |
|||
</view> |
|||
<!-- 暂无数据 --> |
|||
<view hidden="{{hidden}}"> |
|||
<image class="noData" src="../../images/noData.png"></image> |
|||
<view class="noTxt">暂无数据~</view> |
|||
</view> |
|||
</view> |
|||
|
|||
<view class="contentBox"> |
|||
<block wx:for="{{dataList}}" wx:key='*this'> |
|||
<view class="listBox"> |
|||
<view style="padding-bottom:40rpx;overflow: hidden;"> |
|||
<view class="titleBox" style="width: 630rpx; margin: 0 auto;"> |
|||
<view class="title">{{item.name}}</view> |
|||
</view> |
|||
<view style="line-height:50rpx;font-size:28rpx;width: 630rpx; margin: 0 auto;"> |
|||
计划时间:<text>{{item.startTime}}至{{item.endTime}}</text> |
|||
<!-- 巡检记录 --> |
|||
<view id="patrol-record" wx:elif="{{currentTab=='1'}}"> |
|||
<view style="box-shadow:0px 0px 5px #7e7e7e;padding: 15px;background: #fff;position:fixed;top:100rpx;left:0;width: 100%;"> |
|||
<view style="display: flex;"> |
|||
<view style="line-height:50rpx;">时间范围:</view> |
|||
<view style="display: flex;"> |
|||
<!-- 自定义时间选择器 --> |
|||
<view class="page-date" style="{{startTime != '开始日期' && endTime != '结束日期' ? 'float:left' : ''}}" bindtap="pickerShow"> |
|||
<view style="{{startTime == '开始日期' && endTime == '结束日期' ? 'color:#ccc;' : ''}}"> |
|||
{{startTime}} |
|||
<text style="margin: 0 20rpx;color:#000;">至</text> |
|||
{{endTime}} |
|||
</view> |
|||
</view> |
|||
<view style="line-height:50rpx;font-size:28rpx;width: 630rpx; margin: 0 auto;"> |
|||
计划时间:<text>{{item.way}}({{item.frequency}})</text> |
|||
<view class="clearDate" wx:if="{{startTime != '开始日期' && endTime != '结束日期'}}" bindtap="bindClearDate"> |
|||
<image src="/images/close.svg"></image> |
|||
</view> |
|||
<view class="btn" data-item="{{item}}" bindtap="bindStart">开始巡检</view> |
|||
<timePicker pickerShow="{{isPickerShow}}" id="picker" wx:if="{{isPickerRender}}" bind:hidePicker="pickerHide" bind:setPickerTime="setPickerTime" config="{{pickerConfig}}"></timePicker> |
|||
</view> |
|||
</view> |
|||
</block> |
|||
</view> |
|||
|
|||
<!-- 暂无数据 --> |
|||
<view hidden="{{hidden}}"> |
|||
<image class="noData" src="../../images/noData.png"></image> |
|||
<view class="noTxt">暂无数据~</view> |
|||
<view style='display:flex;margin-top:28rpx;'> |
|||
<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 42rpx;border-radius: 6rpx;"> |
|||
{{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;" bindtap="bindSearch"> |
|||
查询 |
|||
</view> |
|||
</view> |
|||
</view> |
|||
<view class="contentBox"> |
|||
<block wx:for="{{recordDataList}}" wx:key='*this'> |
|||
<view class="listBox"> |
|||
<view style="padding-bottom:40rpx;overflow: hidden;"> |
|||
<view class="titleBox" style="width: 630rpx; margin: 0 auto;"> |
|||
<view class="title">{{item.points.project.name}}</view> |
|||
</view> |
|||
<view style="line-height:50rpx;font-size:28rpx;width: 630rpx; margin: 0 auto;"> |
|||
本次巡检日期: |
|||
<text>{{item.inspectionTime}}</text> |
|||
</view> |
|||
<view style="line-height:50rpx;font-size:28rpx;width: 630rpx; margin: 0 auto;"> |
|||
巡检人: |
|||
<text>{{item.points.user.name}}</text> |
|||
</view> |
|||
<view style="line-height:50rpx;font-size:28rpx;width: 630rpx; margin: 0 auto;"> |
|||
巡检结果: |
|||
<text>{{item.alarm ? '异常' : '正常'}}</text> |
|||
</view> |
|||
<view class="btn" data-item="{{item}}" bindtap="bindDetail">查看详情</view> |
|||
</view> |
|||
</view> |
|||
</block> |
|||
</view> |
|||
<!-- 暂无数据 --> |
|||
<view hidden="{{recordHidden}}"> |
|||
<image class="noData" src="../../images/noData.png"></image> |
|||
<view class="noTxt">暂无数据~</view> |
|||
</view> |
|||
</view> |
|||
</view> |
Loading…
Reference in new issue