From 7ff02b99f4b56f0813b5816ad993335d57849a77 Mon Sep 17 00:00:00 2001 From: Archer_cdm Date: Thu, 19 Jan 2023 18:17:05 +0800 Subject: [PATCH] =?UTF-8?q?=EF=BC=88*=EF=BC=89=E5=B7=A1=E6=A3=80=E6=8F=90?= =?UTF-8?q?=E4=BA=A4+=E5=B7=A1=E6=A3=80=E8=AE=B0=E5=BD=95=E5=88=97?= =?UTF-8?q?=E8=A1=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- weapp/app.json | 3 +- .../inspectionRecord/inspectionRecord.js | 66 +++++++++---- .../inspectionRecord/inspectionRecord.json | 2 +- .../inspectionRecord/inspectionRecord.wxml | 15 ++- .../inspectionRecord/inspectionRecord.wxss | 15 +++ .../inspectionRecordDetail.js | 96 +++++++++++++++++++ .../inspectionRecordDetail.json | 6 ++ .../inspectionRecordDetail.wxml | 77 +++++++++++++++ .../inspectionRecordDetail.wxss | 71 ++++++++++++++ .../startInspection/startInspection.js | 23 ++++- 10 files changed, 345 insertions(+), 29 deletions(-) create mode 100644 weapp/package/inspectionRecord/inspectionRecordDetail/inspectionRecordDetail.js create mode 100644 weapp/package/inspectionRecord/inspectionRecordDetail/inspectionRecordDetail.json create mode 100644 weapp/package/inspectionRecord/inspectionRecordDetail/inspectionRecordDetail.wxml create mode 100644 weapp/package/inspectionRecord/inspectionRecordDetail/inspectionRecordDetail.wxss diff --git a/weapp/app.json b/weapp/app.json index 0a09b15..2a31459 100644 --- a/weapp/app.json +++ b/weapp/app.json @@ -11,7 +11,8 @@ "polling/polling", "basic/basic", "startInspection/startInspection", - "inspectionRecord/inspectionRecord" + "inspectionRecord/inspectionRecord", + "inspectionRecord/inspectionRecordDetail/inspectionRecordDetail" ] }], "window": { diff --git a/weapp/package/inspectionRecord/inspectionRecord.js b/weapp/package/inspectionRecord/inspectionRecord.js index e6a94f3..32d6315 100644 --- a/weapp/package/inspectionRecord/inspectionRecord.js +++ b/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(); }, /** diff --git a/weapp/package/inspectionRecord/inspectionRecord.json b/weapp/package/inspectionRecord/inspectionRecord.json index 07ca620..ceacfdc 100644 --- a/weapp/package/inspectionRecord/inspectionRecord.json +++ b/weapp/package/inspectionRecord/inspectionRecord.json @@ -2,7 +2,7 @@ "navigationBarBackgroundColor": "#1979ff", "navigationBarTextStyle": "white", "navigationBarTitleText": "巡检记录", - "enablePullDownRefresh": false, + "enablePullDownRefresh": true, "usingComponents": { "timePicker": "/components/timePicker/index" } diff --git a/weapp/package/inspectionRecord/inspectionRecord.wxml b/weapp/package/inspectionRecord/inspectionRecord.wxml index 34b99e8..f792566 100644 --- a/weapp/package/inspectionRecord/inspectionRecord.wxml +++ b/weapp/package/inspectionRecord/inspectionRecord.wxml @@ -31,19 +31,24 @@ - 结构物A + {{item.points.project.name}} - 本次巡检日期:2022-12-21 17:00 + 本次巡检日期:{{item.inspectionTime}} - 巡检人:巡检人 + 巡检人:{{item.points.user.name}} - 巡检结果:异常 + 巡检结果:{{item.alarm ? '异常' : '正常'}} - 查看详情 + 查看详情 + + + \ No newline at end of file diff --git a/weapp/package/inspectionRecord/inspectionRecord.wxss b/weapp/package/inspectionRecord/inspectionRecord.wxss index f959722..2d2b196 100644 --- a/weapp/package/inspectionRecord/inspectionRecord.wxss +++ b/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; } \ No newline at end of file diff --git a/weapp/package/inspectionRecord/inspectionRecordDetail/inspectionRecordDetail.js b/weapp/package/inspectionRecord/inspectionRecordDetail/inspectionRecordDetail.js new file mode 100644 index 0000000..7135107 --- /dev/null +++ b/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() { + + } +}) \ No newline at end of file diff --git a/weapp/package/inspectionRecord/inspectionRecordDetail/inspectionRecordDetail.json b/weapp/package/inspectionRecord/inspectionRecordDetail/inspectionRecordDetail.json new file mode 100644 index 0000000..aa08bbe --- /dev/null +++ b/weapp/package/inspectionRecord/inspectionRecordDetail/inspectionRecordDetail.json @@ -0,0 +1,6 @@ +{ + "navigationBarBackgroundColor": "#1979ff", + "navigationBarTextStyle": "white", + "navigationBarTitleText": "巡检记录详情", + "enablePullDownRefresh": false +} \ No newline at end of file diff --git a/weapp/package/inspectionRecord/inspectionRecordDetail/inspectionRecordDetail.wxml b/weapp/package/inspectionRecord/inspectionRecordDetail/inspectionRecordDetail.wxml new file mode 100644 index 0000000..4e94f7b --- /dev/null +++ b/weapp/package/inspectionRecord/inspectionRecordDetail/inspectionRecordDetail.wxml @@ -0,0 +1,77 @@ + + + + + 结构物名称: + + {{dataList.points.project.name}} + + + + 巡检人: + + {{dataList.points.user.name}} + + + + 巡检单位: + + {{dataList.points.user.department.name}} + + + + 巡检频次: + + {{dataList.points.frequency}} + + + + 上次巡检日期: + + {{dataList.lastInspectionTime}} + + + + 本次巡检日期: + + {{dataList.inspectionTime}} + + + + 巡检结果: + + {{dataList.alarm ? '异常' : '正常'}} + + + + 当前点位: + + {{dataList.points.itemData.name}} + + + + 当前位置: + + {{dataList.points.address}} + + + + 巡检详情: + + {{dataList.points.msgInp || '--'}} + + + + 异常等级: + + {{dataList.points.changeThree || '--'}} + + + + + + + + + + \ No newline at end of file diff --git a/weapp/package/inspectionRecord/inspectionRecordDetail/inspectionRecordDetail.wxss b/weapp/package/inspectionRecord/inspectionRecordDetail/inspectionRecordDetail.wxss new file mode 100644 index 0000000..dc028ca --- /dev/null +++ b/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; +} \ No newline at end of file diff --git a/weapp/package/startInspection/startInspection.js b/weapp/package/startInspection/startInspection.js index 2661992..96333fb 100644 --- a/weapp/package/startInspection/startInspection.js +++ b/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;