|
|
@ -1,4 +1,8 @@ |
|
|
|
// package/startInspection/startInspection.js
|
|
|
|
import { addPatrolRecord, getPatrolRecord } from "../../utils/getApiUrl"; |
|
|
|
import { Request } from "../../common"; |
|
|
|
const moment = require("../../utils/moment"); |
|
|
|
|
|
|
|
Page({ |
|
|
|
|
|
|
|
/** |
|
|
@ -7,12 +11,25 @@ Page({ |
|
|
|
data: { |
|
|
|
dataList: '', |
|
|
|
imgs: [], //上传图片
|
|
|
|
imgUrl: getApp().globalData.imgUrl, |
|
|
|
msgInp: '', //巡查详情
|
|
|
|
itemData: '', //单条数据
|
|
|
|
changeTwo: '', //是否异常
|
|
|
|
changeThree: '', //严重等级
|
|
|
|
}, |
|
|
|
|
|
|
|
handleChangeTwo(e) { |
|
|
|
this.setData({ |
|
|
|
changeTwo: e.detail.value |
|
|
|
}) |
|
|
|
if (e.detail.value == 'normal') { |
|
|
|
this.setData({ |
|
|
|
msgInp: '', //巡查详情
|
|
|
|
changeThree: '', //严重等级
|
|
|
|
imgs: [] |
|
|
|
}) |
|
|
|
return; |
|
|
|
} |
|
|
|
}, |
|
|
|
|
|
|
|
handleChangeThree(e) { |
|
|
@ -21,15 +38,21 @@ Page({ |
|
|
|
}) |
|
|
|
}, |
|
|
|
|
|
|
|
showModal() { |
|
|
|
showModal(e) { |
|
|
|
this.setData({ |
|
|
|
showModal: true |
|
|
|
showModal: true, |
|
|
|
itemData: e.currentTarget.dataset.itemdata |
|
|
|
}) |
|
|
|
}, |
|
|
|
|
|
|
|
bindCancel() { |
|
|
|
this.setData({ |
|
|
|
showModal: false |
|
|
|
showModal: false, |
|
|
|
itemData: '', |
|
|
|
msgInp: '', //巡查详情
|
|
|
|
changeTwo: '', //是否异常
|
|
|
|
changeThree: '', //严重等级
|
|
|
|
imgs: [] |
|
|
|
}) |
|
|
|
}, |
|
|
|
|
|
|
@ -39,7 +62,10 @@ Page({ |
|
|
|
var pics = []; |
|
|
|
var detailPics = that.data.imgs; |
|
|
|
if (detailPics.length >= 20) { |
|
|
|
commonJs.showToast('最多选择20张图片上传'); |
|
|
|
wx.showToast({ |
|
|
|
title: '最多选择20张图片上传', |
|
|
|
icon: 'none' |
|
|
|
}); |
|
|
|
return; |
|
|
|
} |
|
|
|
wx.chooseMedia({ |
|
|
@ -48,14 +74,13 @@ Page({ |
|
|
|
sizeType: ['original', 'compressed'], // original 原图,compressed 压缩图,默认二者都有
|
|
|
|
sourceType: ['album', 'camera'], // album 从相册选图,camera 使用相机,默认二者都有
|
|
|
|
success: function (res) { |
|
|
|
console.log(res); |
|
|
|
var imgs = res.tempFiles; |
|
|
|
for (var i = 0; i < imgs.length; i++) { |
|
|
|
if (res.tempFiles[i].size > 15728640) { |
|
|
|
commonJs.showToast('图片大于15M,不可上传'); |
|
|
|
return; |
|
|
|
} |
|
|
|
pics.push(imgs[i]) |
|
|
|
pics.push(imgs[i].tempFilePath) |
|
|
|
} |
|
|
|
that.uploadimg({ |
|
|
|
url: getApp().globalData.webUrl + '_upload/attachments/project', //这里是你图片上传的接口
|
|
|
@ -82,7 +107,8 @@ Page({ |
|
|
|
success: (resp) => { |
|
|
|
wx.hideLoading(); |
|
|
|
success++; |
|
|
|
var str = resp.data //返回的结果,可能不同项目结果不一样
|
|
|
|
var str = JSON.parse(resp.data) //返回的结果,可能不同项目结果不一样
|
|
|
|
str = str.uploaded |
|
|
|
console.log(str); |
|
|
|
if (imgs.length >= 20) { |
|
|
|
that.setData({ |
|
|
@ -90,7 +116,7 @@ Page({ |
|
|
|
}); |
|
|
|
return false; |
|
|
|
} else { |
|
|
|
imgs.push(str); |
|
|
|
imgs.push(that.data.imgUrl + str); |
|
|
|
that.setData({ |
|
|
|
imgs: imgs |
|
|
|
}) |
|
|
@ -138,6 +164,93 @@ Page({ |
|
|
|
}) |
|
|
|
}, |
|
|
|
|
|
|
|
// 巡查详情
|
|
|
|
bindInput: function (e) { |
|
|
|
this.setData({ |
|
|
|
msgInp: e.detail.value |
|
|
|
}) |
|
|
|
}, |
|
|
|
|
|
|
|
// 开始巡检录入
|
|
|
|
addPatrolRecord: function () { |
|
|
|
let that = this; |
|
|
|
let { itemData, imgs, msgInp, changeTwo, changeThree, dataList, imgUrl } = that.data; |
|
|
|
let newImgs = imgs.map(i => { |
|
|
|
i = i.replace(imgUrl, ''); |
|
|
|
return i; |
|
|
|
}) |
|
|
|
if (changeTwo == 'abnormal') { |
|
|
|
if (msgInp == '') { |
|
|
|
wx.showToast({ |
|
|
|
title: '请填写巡查详情', |
|
|
|
icon: 'none' |
|
|
|
}) |
|
|
|
return; |
|
|
|
} |
|
|
|
if (changeThree == '') { |
|
|
|
wx.showToast({ |
|
|
|
title: '请选择严重等级', |
|
|
|
icon: 'none' |
|
|
|
}) |
|
|
|
return; |
|
|
|
} |
|
|
|
let data = { |
|
|
|
patrolPlanId: dataList.id, |
|
|
|
lastInspectionTime: moment().format('YYYY-MM-DD'), |
|
|
|
inspectionTime: moment().format('YYYY-MM-DD'), |
|
|
|
points: { |
|
|
|
user: dataList.user, |
|
|
|
project: dataList.project, |
|
|
|
frequency: dataList.frequency, |
|
|
|
itemData: itemData, |
|
|
|
msgInp: msgInp, |
|
|
|
changeThree: changeThree == 'slight' ? '轻微' : changeThree == 'moderate' ? '中度' : '严重', |
|
|
|
imgs: newImgs, |
|
|
|
}, |
|
|
|
alarm: true |
|
|
|
} |
|
|
|
Request.post(addPatrolRecord(), data).then(res => { |
|
|
|
wx.showToast({ |
|
|
|
title: '提交成功', |
|
|
|
}) |
|
|
|
that.bindCancel(); |
|
|
|
}) |
|
|
|
} else { |
|
|
|
if (changeTwo == 'normal') { |
|
|
|
let data = { |
|
|
|
patrolPlanId: dataList.id, |
|
|
|
lastInspectionTime: moment().format('YYYY-MM-DD'), |
|
|
|
inspectionTime: moment().format('YYYY-MM-DD'), |
|
|
|
points: { |
|
|
|
user: dataList.user, |
|
|
|
project: dataList.project, |
|
|
|
frequency: dataList.frequency, |
|
|
|
itemData: itemData, |
|
|
|
}, |
|
|
|
alarm: false |
|
|
|
} |
|
|
|
Request.post(addPatrolRecord(), data).then(res => { |
|
|
|
wx.showToast({ |
|
|
|
title: '提交成功', |
|
|
|
}) |
|
|
|
that.bindCancel(); |
|
|
|
}) |
|
|
|
return; |
|
|
|
} |
|
|
|
wx.showToast({ |
|
|
|
title: '提交信息不全,请检查', |
|
|
|
icon: 'none' |
|
|
|
}) |
|
|
|
} |
|
|
|
}, |
|
|
|
|
|
|
|
// 获取巡检记录
|
|
|
|
getPatrolRecord: function () { |
|
|
|
Request.get(getPatrolRecord(this.data.dataList.id)).then(res => { |
|
|
|
console.log(res); |
|
|
|
}) |
|
|
|
}, |
|
|
|
|
|
|
|
// selfLocation() {
|
|
|
|
// const self = this
|
|
|
|
// wx.showLoading({
|
|
|
@ -199,6 +312,7 @@ Page({ |
|
|
|
dataList: data, |
|
|
|
points |
|
|
|
}) |
|
|
|
// that.getPatrolRecord()
|
|
|
|
}, |
|
|
|
|
|
|
|
/** |
|
|
|