Browse Source

fix 小程序-新增巡检记录操作失败

master
巴林闲侠 2 years ago
parent
commit
41d0523c17
  1. 21
      api/app/lib/controllers/patrolManage/patrolRecord.js
  2. 3
      weapp/package/inspectionInput/inspectionInput.js

21
api/app/lib/controllers/patrolManage/patrolRecord.js

@ -176,19 +176,30 @@ async function addPatrolRecord (ctx, next) {
attributes: ['inspectionTime'],
});
const lastInspectionTime = pointRecord.length ? pointRecord[0].dataValues.inspectionTime : null;
let record = { patrolPlanId, lastInspectionTime, inspectionTime, points, alarm, pointId }
const recordRes = await models.PatrolRecord.create(record, transaction);
const recordRes = await models.PatrolRecord.create(
// record
{
patrolPlanId: patrolPlanId,
lastInspectionTime,
inspectionTime,
points,
alarm,
pointId: pointId
}
, {
transaction
});
if (alarm) {
await models.PatrolRecord.create({
await models.PatrolRecordIssueHandle.create({
patrolRecordId: recordRes.id,
state: 1,
}, transaction);
}, { transaction });
}
// 更新巡检次数统计
const curPlanRecord = await models.PatrolRecord.findAndCountAll({
where: { patrolPlanId }
where: { patrolPlanId: patrolPlanId }
});
const patrolCount = curPlanRecord.count;

3
weapp/package/inspectionInput/inspectionInput.js

@ -83,7 +83,6 @@ Page({
onPickerChange (e) {
const { key } = e.currentTarget.dataset;
const { value } = e.detail;
this.setData({
[`${key}Visible`]: false,
[`${key}Value`]: value,
@ -131,7 +130,6 @@ Page({
})
},
fail: (res) => {
console.log(res)
wx.hideLoading();
wx.showToast({
title: res.errMsg,
@ -233,7 +231,6 @@ Page({
success++;
let str = JSON.parse(resp.data) // 返回的结果,可能不同项目结果不一样
str = str.uploaded
console.log(str);
if (imgs.length >= 20) {
const inspectContent = that.data.inspectContent;
inspectContent[itemName].imgs = imgs;

Loading…
Cancel
Save