diff --git a/api/app/lib/controllers/patrolManage/patrolRecord.js b/api/app/lib/controllers/patrolManage/patrolRecord.js index 28d791b..615e2aa 100644 --- a/api/app/lib/controllers/patrolManage/patrolRecord.js +++ b/api/app/lib/controllers/patrolManage/patrolRecord.js @@ -130,7 +130,13 @@ async function addPatrolRecord (ctx, next) { try { const models = ctx.fs.dc.models; const data = ctx.request.body; - let { patrolPlanId, lastInspectionTime, inspectionTime, points, alarm, pointId } = data + let { patrolPlanId, inspectionTime, points, alarm, pointId } = data + const pointRecord = await models.PatrolRecord.findAll({ + where: { pointId: pointId }, + order: [['inspectionTime', 'desc']], + attributes: ['inspectionTime'], + }); + const lastInspectionTime = pointRecord.length ? pointRecord[0].dataValues.inspectionTime : null; let record = { patrolPlanId, lastInspectionTime, inspectionTime, points, alarm, pointId } await models.PatrolRecord.create(record); diff --git a/weapp/package/inspectionInput/inspectionInput.js b/weapp/package/inspectionInput/inspectionInput.js index 8b377f9..cf00504 100644 --- a/weapp/package/inspectionInput/inspectionInput.js +++ b/weapp/package/inspectionInput/inspectionInput.js @@ -14,6 +14,7 @@ Page({ imgUrl: getApp().globalData.imgUrl, checkItems: [], // 检查项 inspectContent: {}, // 巡检内容 + isCommitting: false, /*** 扫码巡检 ***/ planList: null, // 巡检计划列表 planListVisible: true, @@ -300,6 +301,7 @@ Page({ // 开始巡检录入 addPatrolRecord: function () { const that = this; + if (that.data.isCommitting) { return } let { itemData, inspectContent, @@ -342,7 +344,6 @@ Page({ let data = { patrolPlanId: dataList.id, pointId: itemData.id, - lastInspectionTime: itemData.lastInspectionTime, inspectionTime: moment().format('YYYY-MM-DD HH:mm:ss'), points: { user: dataList.user, @@ -354,7 +355,11 @@ Page({ }, alarm } + wx.showLoading({ title: '提交中...' }); + that.setData({ isCommitting: true }); Request.post(addPatrolRecord(), data).then(res => { + wx.hideLoading(); + that.setData({ isCommitting: false }); wx.showToast({ title: '提交成功', icon: 'success'