Browse Source

后端处理上次巡检时间

master
liujiangyong 2 years ago
parent
commit
67ab034a55
  1. 8
      api/app/lib/controllers/patrolManage/patrolRecord.js
  2. 7
      weapp/package/inspectionInput/inspectionInput.js

8
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);

7
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'

Loading…
Cancel
Save