Browse Source

feat:1.6版本代码

master
zhaobing’ 1 year ago
parent
commit
067d5409e2
  1. 19
      api/app/lib/controllers/patrolManage/patrolRecord.js
  2. 17
      api/app/lib/controllers/patrolManage/patrolReport.js
  3. 3
      api/app/lib/routes/patrolManage/patrolReport.js
  4. 2
      script/1.6/schema/1.update_device.sql
  5. 2
      weapp/app.json
  6. 9
      weapp/package/AIOTOverview/electricityMonitoring/electricityMonitoring.js
  7. 10
      weapp/package/AIOTOverview/flowMonitoring/flowMonitoring.js
  8. 2
      weapp/package/deviceBigdataGraph/deviceBigdataGraph.js
  9. 277
      weapp/package/inspectionInput/inspectionInput.js
  10. 4
      weapp/package/inspectionInput/inspectionInput.json
  11. 139
      weapp/package/inspectionInput/inspectionInput.wxml
  12. 14
      weapp/package/inspectionReport/inspectionReport.js
  13. 2
      weapp/package/polling/polling.js
  14. 9
      weapp/package/report/report.js
  15. 2
      weapp/package/report/report.json
  16. 2
      weapp/package/riskManagement/riskCalendar/riskCalendar.js
  17. 5
      weapp/package/riskManagement/riskCalendar/riskCalendar.wxml
  18. 13
      weapp/package/riskManagement/riskCalendar/riskCalendar.wxss
  19. 2
      weapp/package/startInspection/startInspection.js
  20. 23
      weapp/package/subSystem/dayPatrolInfo/dayPatrolInfo.js
  21. 58
      weapp/package/subSystem/dayPatrolInfo/dayPatrolInfo.wxml
  22. 14
      weapp/package/subSystem/dayPatrolInfo/dayPatrolInfo.wxss
  23. 90
      weapp/package/subSystem/subSystem.js
  24. 9
      weapp/package/subSystem/subSystem.json
  25. 25
      weapp/package/subSystem/subSystem.wxml
  26. 8
      weapp/package/subSystem/subSystem.wxss
  27. 2
      weapp/package/troubleshooting/shootingForm/index.js

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

@ -9,6 +9,8 @@ async function findPatrolRecord(ctx, next) {
try { try {
const models = ctx.fs.dc.models; const models = ctx.fs.dc.models;
const { startTime, endTime, alarm, patrolPlanId, pointId } = ctx.params; const { startTime, endTime, alarm, patrolPlanId, pointId } = ctx.params;
const { home } = ctx.query
const sequelize = ctx.fs.dc.orm;
// patrolPlanId传all查所有 // patrolPlanId传all查所有
let generalInclude = [{ let generalInclude = [{
model: models.PatrolPlan, model: models.PatrolPlan,
@ -42,15 +44,19 @@ async function findPatrolRecord(ctx, next) {
} }
} else { } else {
if (alarm == 'null') { if (alarm == 'null') {
rslt = await models.PatrolRecord.findAll({ let option={ where: {
where: { inspectionTime: { $between: [startTime, endTime] },
inspectionTime: { $between: [startTime, endTime] }
}, },
include: generalInclude.concat([{ include: generalInclude.concat([{
model: models.Point, model: models.Point,
attributes: ['id', 'name'] attributes: ['id', 'name']
}]) }])
}); }
// 小程序首页优化(只查对应数据条数,不需要详细数据)
if(home=='true'){
option.attributes=['id', 'alarm','inspection_time','project_id']
}
rslt = await models.PatrolRecord.findAll(option)
} else { } else {
rslt = await models.PatrolRecord.findAll({ rslt = await models.PatrolRecord.findAll({
where: { where: {
@ -126,7 +132,12 @@ async function findPatrolRecord(ctx, next) {
rslt = rslt.filter(f => f) rslt = rslt.filter(f => f)
if (userInfo.username != 'SuperAdmin') { if (userInfo.username != 'SuperAdmin') {
if (userInfo.structure) { if (userInfo.structure) {
if(home=='true'){
rslt=rslt.filter(s => userInfo.structure.find(x => x == s.dataValues.project_id))
}else{
rslt = rslt.filter(s => userInfo.structure.find(x => x == s.points.project.id)) rslt = rslt.filter(s => userInfo.structure.find(x => x == s.points.project.id))
}
} else { } else {
rslt = [] rslt = []
} }

17
api/app/lib/controllers/patrolManage/patrolReport.js

@ -34,6 +34,23 @@ async function getPatrolReport(ctx, next) {
} }
} }
async function delPatrolReport(ctx, next) {
try {
const models = ctx.fs.dc.models;
const { id } = ctx.params
await models.ReportInfo.destroy({where:{id}})
ctx.status = 204;
} catch (error) {
ctx.fs.logger.error(`path: ${ctx.path}, error: ${error}`);
ctx.status = 400;
ctx.body = {
"message": "删除巡检报告失败"
}
}
}
module.exports = { module.exports = {
getPatrolReport, getPatrolReport,
delPatrolReport
} }

3
api/app/lib/routes/patrolManage/patrolReport.js

@ -5,4 +5,7 @@ const patrolReport = require('../../controllers/patrolManage/patrolReport');
module.exports = function (app, router, opts) { module.exports = function (app, router, opts) {
app.fs.api.logAttr['GET/patrolReport'] = { content: '获取巡检报告', visible: false }; app.fs.api.logAttr['GET/patrolReport'] = { content: '获取巡检报告', visible: false };
router.get('/patrolReport', patrolReport.getPatrolReport); router.get('/patrolReport', patrolReport.getPatrolReport);
app.fs.api.logAttr['DELETE/patrolReport/:id'] = { content: '删除巡检报告', visible: false };
router.delete('/patrolReport/:id', patrolReport.delPatrolReport);
}; };

2
script/1.6/schema/1.update_device.sql

@ -0,0 +1,2 @@
UPDATE device SET date_guarantee = '2022-12-20';
UPDATE device SET date_mainten = '2026-12-20 ';

2
weapp/app.json

@ -87,7 +87,7 @@
} }
}, },
"requiredPrivateInfos": [ "requiredPrivateInfos": [
"getLocation" "getLocation","chooseLocation"
], ],
"sitemapLocation": "sitemap.json", "sitemapLocation": "sitemap.json",
"usingComponents": {} "usingComponents": {}

9
weapp/package/AIOTOverview/electricityMonitoring/electricityMonitoring.js

@ -68,12 +68,9 @@ Page({
const res=await Request.get(getProjectList()) const res=await Request.get(getProjectList())
const rslt=await Request.get(getRelationList()) const rslt=await Request.get(getRelationList())
if(res.rows.length&&rslt.rows.length){ if(res.rows.length&&rslt.rows.length){
const data=res.rows.map(item=>{ const filterData=res.rows.filter(s => s.type=='管廊' )
return { const data=filterData?.map(item=>( { value: item.id, text:item.name }))
value: item.id,
text:item.name
}
})
if(res1&&res1.length){ if(res1&&res1.length){
listt=res1.map(item=>{ listt=res1.map(item=>{
const c=rslt.rows?.find(q => q.axyProjectId == item.structId)?.structureId const c=rslt.rows?.find(q => q.axyProjectId == item.structId)?.structureId

10
weapp/package/AIOTOverview/flowMonitoring/flowMonitoring.js

@ -41,13 +41,8 @@ Page({
const res = await Request.get(getProjectList()) const res = await Request.get(getProjectList())
const rslt = await Request.get(getRelationList()) const rslt = await Request.get(getRelationList())
if (res.rows.length && rslt.rows.length) { if (res.rows.length && rslt.rows.length) {
const filterData=res.rows.filter(s => s.type=='管廊' )
const data=res.rows.map(item=>{ const data=filterData?.map(item=>( { value: item.id, text:item.name }))
return {
value: item.id,
text:item.name
}
})
data.unshift({ text: '全部', value: 'all' }) data.unshift({ text: '全部', value: 'all' })
if (complexArray && complexArray.length) { if (complexArray && complexArray.length) {
dd = complexArray.map(item => { dd = complexArray.map(item => {
@ -57,6 +52,7 @@ Page({
} }
}) })
} }
console.log('dd',dd)
this.setData({ this.setData({
structList: data, structList: data,
cardData:dd , cardData:dd ,

2
weapp/package/deviceBigdataGraph/deviceBigdataGraph.js

@ -130,7 +130,7 @@ Page({
} }
}) })
Request.get(getPatrolRecord('all', moment(date1).format('YYYY-MM-DD') + ' 00:00:00', moment('2099-12-31').format('YYYY-MM-DD') + ' 23:59:59', 'null', 'null')).then(res => { Request.get(getPatrolRecord('all', moment(date1).format('YYYY-MM-DD') + ' 00:00:00', moment('2099-12-31').format('YYYY-MM-DD') + ' 23:59:59', 'null', 'null',{home:false})).then(res => {
if (res) { if (res) {
let normal = 0; let normal = 0;
let abnormal = 0; let abnormal = 0;

277
weapp/package/inspectionInput/inspectionInput.js

@ -1,6 +1,12 @@
// package/inspectionInput/inspectionInput.js // package/inspectionInput/inspectionInput.js
import { addPatrolRecord, getPatrolTemplate, getPatrolPlan } from "../../utils/getApiUrl"; import {
import { Request } from "../../common"; addPatrolRecord,
getPatrolTemplate,
getPatrolPlan
} from "../../utils/getApiUrl";
import {
Request
} from "../../common";
const moment = require("../../utils/moment"); const moment = require("../../utils/moment");
Page({ Page({
@ -14,11 +20,14 @@ Page({
imgUrl: getApp().globalData.imgUrl, imgUrl: getApp().globalData.imgUrl,
checkItems: [], // 检查项 checkItems: [], // 检查项
inspectContentArr: [], // 巡检内容 inspectContentArr: [], // 巡检内容
inspectContentArrCopy:[],//保持源数据结构的巡检内容数组
isCommitting: false, isCommitting: false,
/*** 扫码巡检 ***/ /*** 扫码巡检 ***/
planList: null, // 巡检计划列表 planList: null, // 巡检计划列表
planListVisible: true, planListVisible: true,
scenePointId: null, // 当前点位id scenePointId: null, // 当前点位id
devicesChecked: [], //设备复选框
pointDevices:[],
}, },
// 获取巡检计划 // 获取巡检计划
@ -28,7 +37,9 @@ Page({
title: '加载中', title: '加载中',
}) })
const userInfo = wx.getStorageSync('userInfo'); const userInfo = wx.getStorageSync('userInfo');
Request.get(getPatrolPlan(), { userId: userInfo.id }).then(res => { Request.get(getPatrolPlan(), {
userId: userInfo.id
}).then(res => {
wx.hideLoading(); wx.hideLoading();
let pointPlan = res.rows.filter(plan => { let pointPlan = res.rows.filter(plan => {
for (const point of plan.points) { for (const point of plan.points) {
@ -65,10 +76,27 @@ Page({
Request.get(getPatrolTemplate(templateId)).then(res => { Request.get(getPatrolTemplate(templateId)).then(res => {
const checkItems = res.rows[0].checkItems; const checkItems = res.rows[0].checkItems;
let inspectContentArr = []; let inspectContentArr = [];
let inspectContentArrCopy = [];
// 有绑定设备的点位,每个设备都要检查各个检查项 // 有绑定设备的点位,每个设备都要检查各个检查项
if (pointDevices.length) { if (pointDevices.length) {
pointDevices.forEach(device => { //渲染数组
checkItems.forEach(c => {
inspectContentArr.push({ inspectContentArr.push({
id: `${c.id}`,
name: c.name,
isNormal: true,
imgs: [],
msgInp: null,
level: null,
devices: pointDevices.map(device => ({
deviceName: device?.device?.name,
deviceId: device.deviceId,
id: `${device.deviceId}-${c.id}`
}))
})
})
pointDevices.forEach(device => {
inspectContentArrCopy.push({
deviceName: device?.device?.name, deviceName: device?.device?.name,
deviceId: device.deviceId, deviceId: device.deviceId,
checkItems: checkItems.map(c => ({ checkItems: checkItems.map(c => ({
@ -81,28 +109,48 @@ Page({
})) }))
}) })
}); });
// pointDevices.forEach(device => {
// inspectContentArr.push({
// deviceName: device?.device?.name,
// deviceId: device.deviceId,
// checkItems: checkItems.map(c => ({
// id: `${device.deviceId}-${c.id}`,
// name: c.name,
// isNormal: true,
// msgInp: null,
// level: null,
// imgs: [],
// }))
// })
// });
} else { } else {
checkItems.forEach(c => {
inspectContentArr.push({ inspectContentArr.push({
checkItems: checkItems.map(c => ({
id: c.id, id: c.id,
name: c.name, name: c.name,
isNormal: true, isNormal: true,
msgInp: null, msgInp: null,
level: null, level: null,
imgs: [], imgs: [],
})) })})
})
} }
this.setData({ this.setData({
checkItems, checkItems,
inspectContentArr: inspectContentArr, inspectContentArr: inspectContentArr,
inspectContentArrCopy:inspectContentArrCopy,
pointDevices:pointDevices
}) })
}) })
}, },
onPickerChange(e) { onPickerChange(e) {
const { key } = e.currentTarget.dataset; const {
const { value } = e.detail; key
} = e.currentTarget.dataset;
const {
value
} = e.detail;
this.setData({ this.setData({
[`${key}Visible`]: false, [`${key}Visible`]: false,
[`${key}Value`]: value, [`${key}Value`]: value,
@ -119,14 +167,18 @@ Page({
}, },
onPickerCancel(e) { onPickerCancel(e) {
const { key } = e.currentTarget.dataset; const {
key
} = e.currentTarget.dataset;
this.setData({ this.setData({
[`${key}Visible`]: false, [`${key}Visible`]: false,
}); });
}, },
onPlanListPicker() { onPlanListPicker() {
this.setData({ planListVisible: true }); this.setData({
planListVisible: true
});
}, },
// 获取当前位置 // 获取当前位置
@ -170,7 +222,9 @@ Page({
confirmText: '去设置', confirmText: '去设置',
content: '请允许位置权限', content: '请允许位置权限',
success: function (res) { success: function (res) {
const { confirm } = res || {} const {
confirm
} = res || {}
if (confirm) { if (confirm) {
wx.openSetting() wx.openSetting()
} }
@ -179,41 +233,61 @@ Page({
}, },
handleChangeTwo(e) { handleChangeTwo(e) {
const { deviceidx, itemidx } = e.currentTarget.dataset; const {itemidx} = e.currentTarget.dataset
let nextInspectContentArr = this.data.inspectContentArr; let nextInspectContentArr = this.data.inspectContentArr;
nextInspectContentArr[deviceidx].checkItems[itemidx].isNormal = e.detail; // nextInspectContentArr.forEach(e=>{
// const r=devicesChecked.find(i=>i?.join('-')==e.)
// e.isNormal=
// })
nextInspectContentArr[itemidx].isNormal = e.detail;
if (e.detail) { // 清除异常数据 if (e.detail) { // 清除异常数据
nextInspectContentArr[deviceidx].checkItems[itemidx].msgInp = null; nextInspectContentArr[itemidx].msgInp = null;
nextInspectContentArr[deviceidx].checkItems[itemidx].level = null; nextInspectContentArr[itemidx].level = null;
nextInspectContentArr[deviceidx].checkItems[itemidx].imgs = []; nextInspectContentArr[itemidx].imgs = [];
this.setData({
devicesChecked: []
})
} }
this.setData({ inspectContentArr: nextInspectContentArr }) this.setData({
inspectContentArr: nextInspectContentArr
})
}, },
handleChangeThree(e) { handleChangeDevice(e) {
const { deviceidx, itemidx } = e.currentTarget.dataset; this.setData({
let nextInspectContentArr = this.data.inspectContentArr; devicesChecked: e.detail
})
},
nextInspectContentArr[deviceidx].checkItems[itemidx].level = e.detail; handleChangeThree(e) {
this.setData({ inspectContentArr: nextInspectContentArr }) const { itemidx } = e.currentTarget.dataset;
let nextInspectContentArr = this.data.inspectContentArr
nextInspectContentArr[itemidx].level= e.detail
this.setData({
inspectContentArr: nextInspectContentArr
})
}, },
// 巡查详情 // 巡查详情
bindInput: function (e) { bindInput: function (e) {
const { deviceidx, itemidx } = e.currentTarget.dataset; const {deviceidx,itemidx} = e.currentTarget.dataset;
let nextInspectContentArr = this.data.inspectContentArr; let nextInspectContentArr = this.data.inspectContentArr
nextInspectContentArr[itemidx].msgInp= e.detail.value
nextInspectContentArr[deviceidx].checkItems[itemidx].msgInp = e.detail.value; this.setData({
this.setData({ inspectContentArr: nextInspectContentArr }) inspectContentArr: nextInspectContentArr
})
}, },
// 上传图片 // 上传图片
chooseImg: function (e) { // 这里是选取图片的方法 chooseImg: function (e) { // 这里是选取图片的方法
const { deviceidx, itemidx } = e.currentTarget.dataset; const {
deviceidx,
itemidx
} = e.currentTarget.dataset;
const that = this; const that = this;
let pics = []; let pics = [];
const detailPics = that.data.inspectContentArr[deviceidx].checkItems[itemidx].imgs; const detailPics = that.data.inspectContentArr[itemidx].imgs;
if (detailPics.length >= 20) { if (detailPics.length >= 20) {
wx.showToast({ wx.showToast({
title: '最多选择20张图片上传', title: '最多选择20张图片上传',
@ -230,13 +304,19 @@ Page({
const imgs = res.tempFiles; const imgs = res.tempFiles;
for (let i = 0; i < imgs.length; i++) { for (let i = 0; i < imgs.length; i++) {
if (res.tempFiles[i].size > 15728640) { if (res.tempFiles[i].size > 15728640) {
wx.showToast({ title: '图片大于15M,不可上传', icon: 'none' }); wx.showToast({
title: '图片大于15M,不可上传',
icon: 'none'
});
return; return;
} }
const fileNameArr = res.tempFiles[i].tempFilePath.split('.'); const fileNameArr = res.tempFiles[i].tempFilePath.split('.');
const extension = res.tempFiles[i].tempFilePath.split('.')[fileNameArr.length - 1]; const extension = res.tempFiles[i].tempFilePath.split('.')[fileNameArr.length - 1];
if (extension !== 'jpg' && extension !== 'png' && extension !== 'jpeg') { if (extension !== 'jpg' && extension !== 'png' && extension !== 'jpeg') {
wx.showToast({ title: '只能上传jpg、jpeg、png格式的图片', icon: 'none' }); wx.showToast({
title: '只能上传jpg、jpeg、png格式的图片',
icon: 'none'
});
return; return;
} }
pics.push(imgs[i].tempFilePath) pics.push(imgs[i].tempFilePath)
@ -259,7 +339,7 @@ Page({
i = data.i ? data.i : 0, i = data.i ? data.i : 0,
success = data.success ? data.success : 0, success = data.success ? data.success : 0,
fail = data.fail ? data.fail : 0; fail = data.fail ? data.fail : 0;
let imgs = that.data.inspectContentArr[deviceidx].checkItems[itemidx].imgs; let imgs = that.data.inspectContentArr[itemidx].imgs;
wx.uploadFile({ wx.uploadFile({
url: data.url, url: data.url,
filePath: data.path[i], filePath: data.path[i],
@ -270,15 +350,15 @@ Page({
let str = JSON.parse(resp.data) // 返回的结果,可能不同项目结果不一样 let str = JSON.parse(resp.data) // 返回的结果,可能不同项目结果不一样
str = str.uploaded str = str.uploaded
if (imgs.length >= 20) { if (imgs.length >= 20) {
let nextInspectContentArr = that.data.inspectContentArr; let nextInspectContentArr = that.data.inspectContentArr
nextInspectContentArr[deviceidx].checkItems[itemidx].imgs = imgs; nextInspectContentArr[itemidx].imgs = imgs;
that.setData({ inspectContentArr: nextInspectContentArr }); that.setData({ inspectContentArr: nextInspectContentArr });
return false; return false;
} else { } else {
imgs.push(str); imgs.push(str);
let nextInspectContentArr = that.data.inspectContentArr; let nextInspectContentArr = that.data.inspectContentArr
nextInspectContentArr[deviceidx].checkItems[itemidx].imgs = imgs; nextInspectContentArr[itemidx].imgs = imgs
that.setData({ inspectContentArr: nextInspectContentArr }); that.setData({ inspectContentArr: nextInspectContentArr })
} }
}, },
fail: (res) => { fail: (res) => {
@ -302,19 +382,28 @@ Page({
// 删除图片 // 删除图片
deleteImg: function (e) { deleteImg: function (e) {
const { deviceidx, itemidx, index } = e.currentTarget.dataset; const {
let imgs = this.data.inspectContentArr[deviceidx].checkItems[itemidx].imgs; itemidx,
index
} = e.currentTarget.dataset;
let imgs = this.data.inspectContentArr[itemidx].imgs;
imgs.splice(index, 1); imgs.splice(index, 1);
let nextInspectContentArr = this.data.inspectContentArr; let nextInspectContentArr = this.data.inspectContentArr;
nextInspectContentArr[deviceidx].checkItems[itemidx].imgs = imgs; nextInspectContentArr[itemidx].imgs = imgs;
this.setData({ inspectContentArr: nextInspectContentArr }) this.setData({
inspectContentArr: nextInspectContentArr
})
}, },
// 预览图片 // 预览图片
previewImg: function (e) { previewImg: function (e) {
const { deviceidx, itemidx, index } = e.currentTarget.dataset; const {
deviceidx,
itemidx,
index
} = e.currentTarget.dataset;
// 所有图片 // 所有图片
const imgs = this.data.inspectContentArr[deviceidx].checkItems[itemidx].imgs; const imgs = this.data.inspectContentArr[itemidx].imgs;
const newImgs = imgs.map(i => this.data.imgUrl + i); const newImgs = imgs.map(i => this.data.imgUrl + i);
wx.previewImage({ wx.previewImage({
// 当前显示图片 // 当前显示图片
@ -326,7 +415,9 @@ Page({
bindCancel() { bindCancel() {
if (this.data.scenePointId) { if (this.data.scenePointId) {
wx.switchTab({ url: '/pages/index/index' }) wx.switchTab({
url: '/pages/index/index'
})
} else { } else {
wx.navigateBack(); wx.navigateBack();
} }
@ -335,13 +426,11 @@ Page({
// 开始巡检录入 // 开始巡检录入
addPatrolRecord: function () { addPatrolRecord: function () {
const that = this; const that = this;
if (that.data.isCommitting) { return } if (that.data.isCommitting) {
let { return
itemData, }
inspectContentArr, let {itemData, inspectContentArrCopy, inspectContentArr, dataList,address,devicesChecked,pointDevices } = that.data;
dataList,
address
} = that.data;
let alarm = false; let alarm = false;
// if (!address) { // if (!address) {
// wx.showToast({ // wx.showToast({
@ -351,10 +440,40 @@ Page({
// }) // })
// return; // return;
// } // }
let reportArr = inspectContentArr.map(d => ({ ...d, alarm: false })); let reportArr =[]
for (const [index, device] of inspectContentArr.entries()) { if(pointDevices.length){
for (const item of device.checkItems) { reportArr=inspectContentArrCopy.map(d => {
if (item.isNormal === null) { const r=devicesChecked.find(j=>j?.split('-')[0]==d.deviceId)
return {
...d,
checkItems:d.checkItems.map(i=>{
const cp=d.deviceId+'-'+i.id.split('-')[1]
const isExist=devicesChecked.some(l=>l==cp)
const rlst=inspectContentArr.find(q=>q.id==i.id.split('-')[1])
return {
isNormal:isExist?rlst?.isNormal:true,
level:isExist?rlst?.level:null,
msgInp:isExist?rlst?.msgInp:null,
imgs:isExist?rlst?.imgs:[],
name:i.name,
id:i.id
}
}),
alarm: r?true:false
}
})
}else{
reportArr = [{
checkItems:inspectContentArr,
alarm:false
}
]
}
for (const [index, checkItems] of inspectContentArr.entries()) {
if (checkItems.isNormal === null) {
wx.showToast({ wx.showToast({
title: '请填写完整', title: '请填写完整',
icon: 'none', icon: 'none',
@ -362,7 +481,17 @@ Page({
}) })
return; return;
} }
if ((!item.isNormal) && (!item.level || !item.msgInp)) { if(checkItems.devices){
if(!checkItems.isNormal&&devicesChecked&&devicesChecked.length==0){
wx.showToast({
title: '选择了检查项异常,但未选择具体设备',
icon: 'none',
duration: 1500
})
return;
}
}
if ((!checkItems.isNormal) && (!checkItems.level || !checkItems.msgInp)) {
wx.showToast({ wx.showToast({
title: '异常项必须输入巡查详情和选择严重等级', title: '异常项必须输入巡查详情和选择严重等级',
icon: 'none', icon: 'none',
@ -370,19 +499,18 @@ Page({
}) })
return; return;
} }
if (item.isNormal === false) { if (checkItems.isNormal === false) {
alarm = true; // 巡检记录异常 alarm = true; // 巡检记录异常
reportArr[index].alarm = true; // 设备异常 // reportArr[index].alarm = true; // 设备异常
} }
} }
}
const { id, name, departmentId, deptName } = wx.getStorageSync('userInfo'); const { id, name,departmentId, deptName } = wx.getStorageSync('userInfo');
let data = { let data = {
patrolPlanId: dataList.id, patrolPlanId: dataList.id,
pointId: itemData.id, pointId: itemData.id,
inspectionTime: moment().format('YYYY-MM-DD HH:mm:ss'), inspectionTime: moment().format('YYYY-MM-DD HH:mm:ss'),
points: { points: { user: { id, name, department: { id: departmentId, name: deptName }},
user: { id, name, department: { id: departmentId, name: deptName } },
project: dataList.project, project: dataList.project,
frequency: dataList.frequency, frequency: dataList.frequency,
itemData: itemData, itemData: itemData,
@ -392,11 +520,17 @@ Page({
alarm, alarm,
projectId: dataList.project.id projectId: dataList.project.id
} }
wx.showLoading({ title: '提交中...' }); wx.showLoading({
that.setData({ isCommitting: true }); title: '提交中...'
});
that.setData({
isCommitting: true
});
Request.post(addPatrolRecord(), data).then(res => { Request.post(addPatrolRecord(), data).then(res => {
wx.hideLoading(); wx.hideLoading();
that.setData({ isCommitting: false }); that.setData({
isCommitting: false
});
wx.showToast({ wx.showToast({
title: '提交成功', title: '提交成功',
icon: 'success' icon: 'success'
@ -412,18 +546,21 @@ Page({
*/ */
onLoad(options) { onLoad(options) {
const that = this; const that = this;
// console.log('inspectContentArr',inspectContentArr)
const scenePointId = options.scene; const scenePointId = options.scene;
if (scenePointId) { // 扫小程序码进入 if (scenePointId) { // 扫小程序码进入
const userInfo = wx.getStorageSync('userInfo'); const userInfo = wx.getStorageSync('userInfo');
if (!userInfo || !userInfo.id) { // 如果没登录,先登录 if (!userInfo || !userInfo.id) { // 如果没登录,先登录
wx.showToast({ title: '请先登录' }) wx.showToast({
title: '请先登录'
})
wx.reLaunch({ wx.reLaunch({
url: `/pages/login/login?scene=${scenePointId}` url: `/pages/login/login?scene=${scenePointId}`
}); });
return; return;
} }
that.setData({ scenePointId }); that.setData({
scenePointId
});
that.getPatrolPlan(scenePointId); that.getPatrolPlan(scenePointId);
} else { // 正常点击进入 } else { // 正常点击进入
const dataList = JSON.parse(decodeURIComponent(options.dataList)); const dataList = JSON.parse(decodeURIComponent(options.dataList));
@ -485,3 +622,5 @@ Page({
} }
}) })

4
weapp/package/inspectionInput/inspectionInput.json

@ -10,6 +10,8 @@
"t-picker": "tdesign-miniprogram/picker/picker", "t-picker": "tdesign-miniprogram/picker/picker",
"t-picker-item": "tdesign-miniprogram/picker-item/picker-item", "t-picker-item": "tdesign-miniprogram/picker-item/picker-item",
"van-radio": "@vant/weapp/radio/index", "van-radio": "@vant/weapp/radio/index",
"van-radio-group": "@vant/weapp/radio-group/index" "van-radio-group": "@vant/weapp/radio-group/index",
"van-checkbox": "@vant/weapp/checkbox/index",
"van-checkbox-group": "@vant/weapp/checkbox-group/index"
} }
} }

139
weapp/package/inspectionInput/inspectionInput.wxml

@ -1,24 +1,8 @@
<!-- package/inspectionInput/inspectionInput.wxml --> <!-- package/inspectionInput/inspectionInput.wxml -->
<view class="popBox"> <view class="popBox">
<view wx:if="{{planList}}"> <view wx:if="{{planList}}">
<t-cell <t-cell class="block" title="选择巡检计划" arrow hover note="{{planListText}}" bind:click="onPlanListPicker" />
class="block" <t-picker visible="{{planListVisible}}" value="{{planListValue}}" data-key="planList" title="选择巡检计划" cancelBtn="取消" confirmBtn="确认" bindchange="onPickerChange" bindcancel="onPickerCancel">
title="选择巡检计划"
arrow
hover
note="{{planListText}}"
bind:click="onPlanListPicker"
/>
<t-picker
visible="{{planListVisible}}"
value="{{planListValue}}"
data-key="planList"
title="选择巡检计划"
cancelBtn="取消"
confirmBtn="确认"
bindchange="onPickerChange"
bindcancel="onPickerCancel"
>
<t-picker-item options="{{planList}}" format></t-picker-item> <t-picker-item options="{{planList}}" format></t-picker-item>
</t-picker> </t-picker>
</view> </view>
@ -42,110 +26,53 @@
<view class="divider" /> <view class="divider" />
<!-- 渲染巡检内容 --> <!-- 渲染巡检内容 -->
<view <view wx:for="{{inspectContentArr}}" wx:key="id" wx:for-item="item" wx:for-index="itemidx">
wx:for="{{inspectContentArr}}" <!-- <view wx:for="{{device.checkItems}}" wx:key="id" wx:for-index="itemidx"> -->
wx:key="deviceId"
wx:for-item="device"
wx:for-index="deviceidx"
>
<view wx:if="{{device.deviceName}}" class="flex flex-start" style="height: 40px"
>{{device.deviceName}}</view
>
<view wx:for="{{device.checkItems}}" wx:key="id" wx:for-index="itemidx">
<view class="flex-between"> <view class="flex-between">
<view class="item-name">{{item.name}}:</view> <view class="item-name">{{item.name}}:</view>
<van-radio-group <van-radio-group style="padding:10px 15px;" data-deviceidx="{{item.id}}" data-itemidx="{{itemidx}}" bindchange="handleChangeTwo" value="{{item.isNormal}}">
style="padding:10px 15px;" <van-radio style="margin-right: 20px;" class="radio-text" color="#1979ff" name="{{true}}">正常</van-radio>
data-deviceidx="{{deviceidx}}"
data-itemidx="{{itemidx}}"
bindchange="handleChangeTwo"
value="{{item.isNormal}}"
>
<van-radio style="margin-right: 20px;" class="radio-text" color="#1979ff" name="{{true}}"
>正常</van-radio
>
<van-radio class="radio-text" checked-color="#CC0000" name="{{false}}">异常</van-radio> <van-radio class="radio-text" checked-color="#CC0000" name="{{false}}">异常</van-radio>
</van-radio-group> </van-radio-group>
</view> </view>
<view class="divider" /> <view class="divider" />
<van-radio-group <!--渲染设备-->
class="flex-end" <!-- <van-checkbox-group wx:if="{{!item.isNormal}}" value="{{ device.isNormal }}" bind:change="handleChangeDevice">
style="padding:10px 15px;" <van-checkbox name="a">复选框 a</van-checkbox>
data-deviceidx="{{deviceidx}}" </van-checkbox-group> -->
data-itemidx="{{itemidx}}" <view wx:if="{{!item.isNormal}}" wx:for-index="deviceidx" wx:for="{{item.devices}}" wx:key="deviceId" wx:for-item="device" class="flex flex-start" style="height: 40px">
bindchange="handleChangeThree" <!-- <van-radio-group style="padding:10px 15px;" value="{{device.isNormal}}" data-deviceidx="{{deviceidx}}" data-itemidx="{{itemidx}}" bindchange="handleChangeDevice">
wx:if="{{item.isNormal === false}}" {{device.deviceName}}:
> <van-radio style="margin-right: 20px;" class="radio-text" color="#1979ff" name="{{true}}">正常</van-radio>
<van-radio <van-radio class="radio-text" checked-color="#CC0000" name="{{false}}">异常</van-radio>
style="margin-right: 20px;" </van-radio-group> -->
class="radio-text" <van-checkbox-group value="{{ devicesChecked }}" data-deviceidx="{{deviceidx}}" data-itemidx="{{itemidx}}" bind:change="handleChangeDevice">
checked-color="#FF9900" <van-checkbox name="{{device.deviceId+'-'+item.id}}">{{device.deviceName}}</van-checkbox>
name="轻微" </van-checkbox-group>
>轻微</van-radio </view>
> <!--巡检的具体内容-->
<van-radio <view style="margin-top: 10px;">
style="margin-right: 20px;" <van-radio-group class="flex-end" style="padding:10px 15px;" data-deviceidx="{{deviceidx}}" data-itemidx="{{itemidx}}" bindchange="handleChangeThree" wx:if="{{item.isNormal === false}}">
class="radio-text" <van-radio style="margin-right: 20px;" class="radio-text" checked-color="#FF9900" name="轻微">轻微</van-radio>
checked-color="#FF3300" <van-radio style="margin-right: 20px;" class="radio-text" checked-color="#FF3300" name="中度">中度</van-radio>
name="中度"
>中度</van-radio
>
<van-radio class="radio-text" checked-color="#990000" name="严重">严重</van-radio> <van-radio class="radio-text" checked-color="#990000" name="严重">严重</van-radio>
</van-radio-group> </van-radio-group>
<textarea <textarea class="textarea" placeholder="请输入巡查详情" maxlength="-1" wx:if="{{item.isNormal === false}}" data-deviceidx="{{deviceidx}}" data-itemidx="{{itemidx}}" bindinput="bindInput" />
class="textarea" </view>
placeholder="请输入巡查详情" <view class="weui-uploader" style="padding: 20rpx 30rpx;overflow-y:scroll;" wx:if="{{item.isNormal === false}}">
maxlength="-1"
wx:if="{{item.isNormal === false}}"
data-deviceidx="{{deviceidx}}"
data-itemidx="{{itemidx}}"
bindinput="bindInput"
/>
<view
class="weui-uploader"
style="padding: 20rpx 30rpx;overflow-y:scroll;"
wx:if="{{item.isNormal === false}}"
>
<view class="img-v weui-uploader__bd" style="overflow:hidden;"> <view class="img-v weui-uploader__bd" style="overflow:hidden;">
<view <view class="pic" wx:for="{{item.imgs}}" wx:for-item="img" wx:key="*this">
class="pic" <image class="weui-uploader__img showImg" src="{{imgUrl + img}}" data-index="{{index}}" data-deviceidx="{{deviceidx}}" data-itemidx="{{itemidx}}" mode="aspectFill" bindtap="previewImg">
wx:for="{{item.imgs}}" <icon type="cancel" class="delete-btn" data-index="{{index}}" data-deviceidx="{{deviceidx}}" data-itemidx="{{itemidx}}" catchtap="deleteImg" />
wx:for-item="img"
wx:key="*this"
>
<image
class="weui-uploader__img showImg"
src="{{imgUrl + img}}"
data-index="{{index}}"
data-deviceidx="{{deviceidx}}"
data-itemidx="{{itemidx}}"
mode="aspectFill"
bindtap="previewImg"
>
<icon
type="cancel"
class="delete-btn"
data-index="{{index}}"
data-deviceidx="{{deviceidx}}"
data-itemidx="{{itemidx}}"
catchtap="deleteImg"
/>
</image> </image>
</view> </view>
<!-- 用来提示用户上传图片 --> <!-- 用来提示用户上传图片 -->
<view <view class="weui-uploader__input-box pic" data-item="{{item.name}}" data-deviceidx="{{devicesChecked}}" data-itemidx="{{itemidx}}" bindtap="chooseImg">
class="weui-uploader__input-box pic"
data-item="{{item.name}}"
data-deviceidx="{{deviceidx}}"
data-itemidx="{{itemidx}}"
bindtap="chooseImg"
>
<image class="upload" src="/images/upload.png" /> <image class="upload" src="/images/upload.png" />
</view> </view>
</view> </view>
</view> </view>
<view class="divider" /> <!-- </view> -->
</view>
</view> </view>
<view class="btnBox"> <view class="btnBox">

14
weapp/package/inspectionReport/inspectionReport.js

@ -59,7 +59,6 @@ Page({
showMenu: true, showMenu: true,
fileType:url.includes('xlsx')?'xlsx':url.includes('docx')?'docx':'', fileType:url.includes('xlsx')?'xlsx':url.includes('docx')?'docx':'',
success: function (res) { success: function (res) {
console.log('打开文档成功'); console.log('打开文档成功');
}, },
fail: function (error) { fail: function (error) {
@ -94,13 +93,22 @@ Page({
getStructuresList() { getStructuresList() {
this.setData({ struLoading: true }); this.setData({ struLoading: true });
Request.get(getStructuresList()).then(res => { Request.get(getStructuresList()).then(res => {
const filterData=res.rows.filter(s => s.type=='管廊' )
this.setData({ this.setData({
struLoading: false, struLoading: false,
structures: [ structures: [
{ text: '全部', value: 'all' }, { text: '全部', value: 'all' },
...res.rows.map(s => ({ text: s.name, value: s.id })) ...filterData.map(p=>(
{ text: p.name, value: p.id }
))
] ]
}, () => { this.getPatrolReport(); }) }, () => {
this.getPatrolReport(); })
}) })
}, },

2
weapp/package/polling/polling.js

@ -160,7 +160,7 @@ Page({
wx.showLoading({ wx.showLoading({
title: '加载中' title: '加载中'
}) })
Request.get(getPatrolRecord('all', moment(startTime).format('YYYY-MM-DD') + ' 00:00:00', moment(endTime).format('YYYY-MM-DD') + ' 23:59:59', alarm, 'null')).then(res => { Request.get(getPatrolRecord('all', moment(startTime).format('YYYY-MM-DD') + ' 00:00:00', moment(endTime).format('YYYY-MM-DD') + ' 23:59:59', alarm, 'null',{home:false})).then(res => {
if (res.length == 0) { if (res.length == 0) {
that.setData({ that.setData({
recordDataList: res, recordDataList: res,

9
weapp/package/report/report.js

@ -489,10 +489,15 @@ Page({
url: `https://apis.map.qq.com/ws/geocoder/v1/?location=${res.latitude},${res.longitude}&key=${getApp().globalData.key}`, url: `https://apis.map.qq.com/ws/geocoder/v1/?location=${res.latitude},${res.longitude}&key=${getApp().globalData.key}`,
success: function (res) { success: function (res) {
wx.hideLoading(); wx.hideLoading();
// 根据自己项目需求获取res内容 wx.chooseLocation({
success:function(res){
that.setData({ that.setData({
address: res.data.result.address address: res.name
})
}
}) })
// 根据自己项目需求获取res内容
} }
}) })
}, },

2
weapp/package/report/report.json

@ -1,7 +1,7 @@
{ {
"navigationBarBackgroundColor": "#1979ff", "navigationBarBackgroundColor": "#1979ff",
"navigationBarTextStyle": "white", "navigationBarTextStyle": "white",
"navigationBarTitleText": "发现问题", "navigationBarTitleText": "巡检指派",
"enablePullDownRefresh": false, "enablePullDownRefresh": false,
"componentFramework": "glass-easel", "componentFramework": "glass-easel",
"usingComponents": { "usingComponents": {

2
weapp/package/riskManagement/riskCalendar/riskCalendar.js

@ -63,7 +63,7 @@ Page({
*/ */
onLoad(options) { onLoad(options) {
const { minDate, maxDate } = this.data; const { minDate, maxDate } = this.data;
Request.get(getPatrolRecord('all', moment(minDate).format('YYYY-MM-DD HH:mm:ss'), moment(maxDate).format('YYYY-MM-DD HH:mm:ss'), true, 'null')).then(res => { Request.get(getPatrolRecord('all', moment(minDate).format('YYYY-MM-DD HH:mm:ss'), moment(maxDate).format('YYYY-MM-DD HH:mm:ss'), true, 'null',{home:false})).then(res => {
let dayData = new Array(7) let dayData = new Array(7)
for (let i = 6; i >= 0; i--) { for (let i = 6; i >= 0; i--) {
const month = moment().subtract(i, 'day').month(); const month = moment().subtract(i, 'day').month();

5
weapp/package/riskManagement/riskCalendar/riskCalendar.wxml

@ -75,4 +75,9 @@
</view> </view>
</view> </view>
</view> </view>
<view wx:if="{{!showList.length}}">
<!-- 暂无数据 -->
<image class="noData" src="../../../images/noData.svg"></image>
<view class="noTxt">暂无数据</view>
</view>
</view> </view>

13
weapp/package/riskManagement/riskCalendar/riskCalendar.wxss

@ -103,3 +103,16 @@
.content-right { .content-right {
font-size: 14px; font-size: 14px;
} }
.noData {
width: 254rpx;
height: 298rpx;
display: block;
margin: 0rpx auto 16rpx;
}
.noTxt {
font-size: 30rpx;
color: #999;
font-weight: bold;
text-align: center;
}

2
weapp/package/startInspection/startInspection.js

@ -344,7 +344,7 @@ Page({
wx.showLoading({ wx.showLoading({
title: '加载中' title: '加载中'
}) })
Request.get(getPatrolRecord(dataList.id, 'null', 'null', 'null', pointId)).then(res => { Request.get(getPatrolRecord(dataList.id, 'null', 'null', 'null', pointId,{home:false})).then(res => {
wx.hideLoading(); wx.hideLoading();
dataList.points.map(e => { dataList.points.map(e => {
res.map(i => { res.map(i => {

23
weapp/package/subSystem/dayPatrolInfo/dayPatrolInfo.js

@ -53,6 +53,7 @@ Page({
// 今日待检分布图表 // 今日待检分布图表
initNeedChart: function (data) { initNeedChart: function (data) {
if(this.needEcComponent){
this.needEcComponent.init((canvas, width, height, dpr) => { this.needEcComponent.init((canvas, width, height, dpr) => {
const chart = echarts.init(canvas, null, { const chart = echarts.init(canvas, null, {
width: width, width: width,
@ -62,10 +63,13 @@ Page({
setPieOptions(chart, data) setPieOptions(chart, data)
return chart; return chart;
}); });
}
}, },
// 今日已检分布图表 // 今日已检分布图表
initAlreadyChart: function (data) { initAlreadyChart: function (data) {
if( this.alreadyEcComponent){
this.alreadyEcComponent.init((canvas, width, height, dpr) => { this.alreadyEcComponent.init((canvas, width, height, dpr) => {
const chart = echarts.init(canvas, null, { const chart = echarts.init(canvas, null, {
width: width, width: width,
@ -75,14 +79,16 @@ Page({
setPieOptions(chart, data) setPieOptions(chart, data)
return chart; return chart;
}); });
}
}, },
getData() { getData() {
const promiseArr = [ const promiseArr = [
Request.get(getSubSystemPatrol(this.day, this.subType)), Request.get(getSubSystemPatrol(this.day, this.subType)),
Request.get(getSubSystemPatrolAbout({ Request.get(getSubSystemPatrolAbout({
STime: moment().startOf('month').format('YYYY-MM-DD HH:mm:ss'), STime: moment(this.day).startOf('month').format('YYYY-MM-DD HH:mm:ss'),
ETime: moment().endOf('month').format('YYYY-MM-DD HH:mm:ss'), ETime: moment(this.day).endOf('month').format('YYYY-MM-DD HH:mm:ss'),
keywords: this.subType, keywords: this.subType,
})), })),
] ]
@ -161,13 +167,19 @@ Page({
}) })
}) })
this.initNeedChart(needInspectPoints)
this.initAlreadyChart(inspectedPoints)
this.setData({ this.setData({
dayIssues: nextDayIssues, dayIssues: nextDayIssues,
needInspectCount: needInspectPoints.reduce((accumulator, currentValue) => accumulator + currentValue.value, 0), needInspectCount: needInspectPoints.reduce((accumulator, currentValue) => accumulator + currentValue.value, 0),
inspectedCount: inspectedPoints.reduce((accumulator, currentValue) => accumulator + currentValue.value, 0), inspectedCount: inspectedPoints.reduce((accumulator, currentValue) => accumulator + currentValue.value, 0),
},()=>{
//需要在节点挂载后才能拿到!!!!!所以写在setData回调中
this.needEcComponent = this.selectComponent('#need-chart-dom');
this.alreadyEcComponent = this.selectComponent('#already-chart-dom');
this.initNeedChart(needInspectPoints)
this.initAlreadyChart(inspectedPoints)
}) })
}) })
}, },
@ -186,8 +198,7 @@ Page({
* 生命周期函数--监听页面初次渲染完成 * 生命周期函数--监听页面初次渲染完成
*/ */
onReady() { onReady() {
this.needEcComponent = this.selectComponent('#need-chart-dom');
this.alreadyEcComponent = this.selectComponent('#already-chart-dom');
}, },
/** /**

58
weapp/package/subSystem/dayPatrolInfo/dayPatrolInfo.wxml

@ -8,19 +8,17 @@
</view> </view>
<image src="/images/question_card_bg.png" class="card-bg" /> <image src="/images/question_card_bg.png" class="card-bg" />
</view> </view>
<view wx:for="{{dayIssues}}" class="problem-box flex"> <view wx:for="{{dayIssues}}" wx:key="*this" class="problem-box flex">
<view class="problem-title text---">{{item.pointName}}</view> <view class="problem-title text---">{{item.pointName}}</view>
<progress <progress style="width: 70%;" percent="{{item.percent}}" activeColor="{{item.color}}" stroke-width="8" show-info font-size="14" border-radius="4" />
style="width: 70%;"
percent="{{item.percent}}"
activeColor="{{item.color}}"
stroke-width="8"
show-info
font-size="14"
border-radius="4"
/>
</view> </view>
<!-- 暂无数据 -->
<view wx:if="{{!dayIssues.length}}">
<image class="noData" src="../../../images/noData.svg"></image>
<view class="noTxt">暂无数据</view>
</view> </view>
</view>
<view class="card" style="margin-bottom: 10px"> <view class="card" style="margin-bottom: 10px">
<view class="card-top flex flex-between"> <view class="card-top flex flex-between">
<view class="card-left flex"> <view class="card-left flex">
@ -30,10 +28,31 @@
<view class="card-right">总次数:{{needInspectCount}}次</view> <view class="card-right">总次数:{{needInspectCount}}次</view>
<image src="/images/hourglass_card_bg.png" class="card-bg" /> <image src="/images/hourglass_card_bg.png" class="card-bg" />
</view> </view>
<!-- 有数据时显示图表 -->
<!-- <view wx:if="{{needInspectCount}}">
<view class="pie-chart-box"> <view class="pie-chart-box">
<ec-canvas id="need-chart-dom" canvas-id="need-chart" ec="{{ needEc }}"></ec-canvas> <ec-canvas id="need-chart-dom" canvas-id="need-chart" ec="{{ needEc }}"></ec-canvas>
</view> </view>
</view> -->
<!-- 没有数据时显示图表但不显示内容 -->
<!-- <view wx:else>
<view class="pie-chart-box" hidden="{{!needInspectCount}}">
<ec-canvas id="need-chart-dom" canvas-id="need-chart" ec="{{ needEc }}"></ec-canvas>
</view>
<image class="noData" src="../../../images/noData.svg"></image>
<view class="noTxt">暂无数据</view>
</view> -->
<view class="pie-chart-box" wx:if="{{needInspectCount}}">
<ec-canvas id="need-chart-dom" canvas-id="need-chart" ec="{{ needEc }}"></ec-canvas>
</view>
<view wx:else>
<image class="noData" src="../../../images/noData.svg"></image>
<view class="noTxt">暂无数据</view>
</view>
</view> </view>
<view class="card" style="margin-bottom: 10px"> <view class="card" style="margin-bottom: 10px">
<view class="card-top flex flex-between"> <view class="card-top flex flex-between">
<view class="card-left flex"> <view class="card-left flex">
@ -43,8 +62,27 @@
<view class="card-right">总次数:{{inspectedCount}}次</view> <view class="card-right">总次数:{{inspectedCount}}次</view>
<image src="/images/right_card_bg.png" class="card-bg" /> <image src="/images/right_card_bg.png" class="card-bg" />
</view> </view>
<!-- 有数据时显示图表 -->
<!-- <view wx:if="{{inspectedCount}}">
<view class="pie-chart-box"> <view class="pie-chart-box">
<ec-canvas id="already-chart-dom" canvas-id="already-chart" ec="{{ alreadyEc }}"></ec-canvas> <ec-canvas id="already-chart-dom" canvas-id="already-chart" ec="{{ alreadyEc }}"></ec-canvas>
</view> </view>
</view> -->
<!-- 没有数据时显示图表但不显示内容 -->
<!-- <view wx:else>
<view class="pie-chart-box" hidden="{{!inspectedCount}}">
<ec-canvas id="already-chart-dom" canvas-id="already-chart" ec="{{ alreadyEc }}"></ec-canvas>
</view>
<image class="noData" src="../../../images/noData.svg"></image>
<view class="noTxt">暂无数据</view>
</view> -->
<view class="pie-chart-box" wx:if="{{inspectedCount}}">
<ec-canvas id="already-chart-dom" canvas-id="already-chart" ec="{{ alreadyEc }}"></ec-canvas>
</view> </view>
<view wx:else>
<image class="noData" src="../../../images/noData.svg"></image>
<view class="noTxt">暂无数据</view>
</view>
</view>
</view> </view>

14
weapp/package/subSystem/dayPatrolInfo/dayPatrolInfo.wxss

@ -69,3 +69,17 @@
height: 280px; height: 280px;
padding: 0 10px 10px; padding: 0 10px 10px;
} }
.noData {
width: 254rpx;
height: 298rpx;
display: block;
margin: 0rpx auto 16rpx;
}
.noTxt {
font-size: 30rpx;
color: #999;
font-weight: bold;
text-align: center;
}

90
weapp/package/subSystem/subSystem.js

@ -8,8 +8,6 @@ import {
} from "../../common"; } from "../../common";
const moment = require("../../utils/moment"); const moment = require("../../utils/moment");
Page({ Page({
initECharts(option) { initECharts(option) {
this.ecComponent.init((canvas, width, height, dpr) => { this.ecComponent.init((canvas, width, height, dpr) => {
@ -20,10 +18,8 @@ Page({
}); });
// 设置图表的配置 // 设置图表的配置
chart.setOption(option); chart.setOption(option);
// 将 ECharts 实例保存在数据中 // 将 ECharts 实例保存在数据中
this.chart = chart; this.chart = chart;
// 返回 ECharts 实例 // 返回 ECharts 实例
return chart; return chart;
}); });
@ -37,22 +33,35 @@ Page({
}, },
date: '', date: '',
show: true, show: true,
record:[],//巡检记录 record: [],//巡检记录
currentPatrolCount: 0, //当月巡检次数 currentPatrolCount: 0, //当月巡检次数
currentRepairCount: 0, //当月维修次数 currentRepairCount: 0, //当月维修次数
currentDate: new Date().getTime(),
minDate: 0,
curSelect: null,//当前选择
// level1Count: 0, //轻微 // level1Count: 0, //轻微
// level2Count: 0, //中度 // level2Count: 0, //中度
// level3Count: 0, //严重 // level3Count: 0, //严重
// dataList:[],//饼图数据 // dataList:[],//饼图数据
selectedDate: new Date(), // 设置默认选中的日期为当前日期 selectedDate: new Date(), // 设置默认选中的日期为当前日期
questions:0,//故障数量 questions: 0,//故障数量
datePickerShow: false,//选择日期
formatter(day) { formatter(day) {
return day; return day;
}, },
}, },
datePickerPopup() {
this.setData({
datePickerShow: true
})
},
closeDatePickerPopup() {
this.setData({
datePickerShow: false
})
},
onDisplay() { onDisplay() {
this.setData({ this.setData({
show: true show: true
@ -71,14 +80,30 @@ Page({
}); });
}, },
onDateChange(e) {
const dateObject = new Date(e.detail);
const firstDay = new Date(dateObject.getFullYear(), dateObject.getMonth(), 1);
firstDay.setHours(0, 0, 0, 0);
const firstDayTimestamp = firstDay.getTime();
const nextMonthFirstDay = new Date(dateObject.getFullYear(), dateObject.getMonth() + 1, 1);
const lastDayTimestamp = nextMonthFirstDay.getTime() - 1; // 减去1毫秒得到本月最后一天
const currentYear = dateObject.getFullYear();
const currentMonth = dateObject.getMonth() + 1;
this.setData({
currentYear: currentYear,
currentMonth: currentMonth,
lastDay: lastDayTimestamp,
firstDay: firstDayTimestamp,
})
},
onDateSelect(e) { onDateSelect(e) {
const currentDate =moment(e.detail).format('YYYY-MM-DD') const currentDate = moment(e.detail).format('YYYY-MM-DD')
const inspectionData = this.data.record.find(item => currentDate == moment(item.inspectionTime).format('YYYY-MM-DD')); const inspectionData = this.data.record.find(item => currentDate == moment(item.inspectionTime).format('YYYY-MM-DD'));
if (inspectionData) { if (inspectionData) {
wx.navigateTo({ wx.navigateTo({
url: `/package/subSystem/dayPatrolInfo/dayPatrolInfo?day=${moment(e.detail).format('YYYY-MM-DD')}&subType=${this.subType}`, url: `/package/subSystem/dayPatrolInfo/dayPatrolInfo?day=${moment(e.detail).format('YYYY-MM-DD')}&subType=${this.subType}`,
}) })
}else{ } else {
wx.showToast({ wx.showToast({
title: '当天没有巡检记录', title: '当天没有巡检记录',
icon: 'none', icon: 'none',
@ -133,10 +158,8 @@ Page({
getSubSystemPatrolAbout: function (options) { getSubSystemPatrolAbout: function (options) {
// const userInfo=wx.getStorageSync('userInfo'); // const userInfo=wx.getStorageSync('userInfo');
let that = this; let that = this;
//当月开始时间 const STime = moment('1970-01-01').format('YYYY-MM-DD')
const STime = moment().startOf('month').format('YYYY-MM-DD') const ETime = moment('2099-12-31').format('YYYY-MM-DD')
//当月结束时间
const ETime = moment().endOf('month').format('YYYY-MM-DD')
//子系统关键字 //子系统关键字
let keywords = options.key let keywords = options.key
const maxInspectionTimeByPointId = {}; const maxInspectionTimeByPointId = {};
@ -144,6 +167,23 @@ Page({
const query = { STime, ETime, keywords } const query = { STime, ETime, keywords }
Request.get(getSubSystemPatrolAbout(query)).then(res => { Request.get(getSubSystemPatrolAbout(query)).then(res => {
if (res) { if (res) {
//求出最小时间
const minTimeObject = res.reduce((min, current) => {
// 比较时间,选择最小的时间
return !min || new Date(current.inspectionTime) < new Date(min.inspectionTime) ? current : min;
}, null)
let inputDate = new Date()
let firstDayTimestamp = new Date().getTime()
if (minTimeObject) {
inputDate = new Date(minTimeObject.inspectionTime)
inputDate.setDate(1);
inputDate.setHours(0, 0, 0, 0);
firstDayTimestamp = inputDate.getTime();
}
this.setData({
minDate: firstDayTimestamp
})
// 遍历数据并更新maxInspectionTimeByPointId // 遍历数据并更新maxInspectionTimeByPointId
res.forEach((item) => { res.forEach((item) => {
const { pointId, inspectionTime } = item; const { pointId, inspectionTime } = item;
@ -165,7 +205,7 @@ Page({
// 创建一个对象来存储按设备分类的最低level统计 // 创建一个对象来存储按设备分类的最低level统计
const deviceLevelStatistics = {}; const deviceLevelStatistics = {};
// 初始化一个包含所有level的对象 // 初始化一个包含所有level的对象
const levelValues = {轻微: 0,中度: 1,严重: 2}; const levelValues = { 轻微: 0, 中度: 1, 严重: 2 };
// 遍历巡检记录 // 遍历巡检记录
filteredData.forEach((record) => { filteredData.forEach((record) => {
const points = record.points; const points = record.points;
@ -174,7 +214,7 @@ Page({
const device = content.deviceId; const device = content.deviceId;
content.checkItems.forEach(checkItem => { content.checkItems.forEach(checkItem => {
const level = checkItem.level; const level = checkItem.level;
if(!checkItem.isNormal){ if (!checkItem.isNormal) {
if (!deviceLevelStatistics[device]) { if (!deviceLevelStatistics[device]) {
// 如果设备不存在于统计对象中,初始化 // 如果设备不存在于统计对象中,初始化
deviceLevelStatistics[device] = { deviceLevelStatistics[device] = {
@ -190,7 +230,7 @@ Page({
}) })
} }
}) })
const levelCounts = {轻微: 0,中度: 0, 严重: 0}; const levelCounts = { 轻微: 0, 中度: 0, 严重: 0 };
for (const deviceId in deviceLevelStatistics) { for (const deviceId in deviceLevelStatistics) {
if (deviceLevelStatistics.hasOwnProperty(deviceId)) { if (deviceLevelStatistics.hasOwnProperty(deviceId)) {
const deviceInfo = deviceLevelStatistics[deviceId]; const deviceInfo = deviceLevelStatistics[deviceId];
@ -199,21 +239,21 @@ Page({
levelCounts[level]++; levelCounts[level]++;
} }
} }
const data1=Object.entries(levelCounts).map(([name, value]) => ({ name, value })); const data1 = Object.entries(levelCounts).map(([name, value]) => ({ name, value }));
const totalValue = data1.reduce((accumulator, item) => accumulator + item.value, 0); const totalValue = data1.reduce((accumulator, item) => accumulator + item.value, 0);
that.setData({ that.setData({
currentRepairCount: res?.filter(i => i.patrolRecordIssueHandles.length > 0?i.patrolRecordIssueHandles[0].state===6:false).length || 0, currentRepairCount: res?.filter(i => i.patrolRecordIssueHandles.length > 0 ? i.patrolRecordIssueHandles[0].state === 6 : false).length || 0,
currentPatrolCount: res.length, currentPatrolCount: res.length,
questions:totalValue, questions: totalValue,
record:res, record: res,
formatter: function (e) { formatter: function (e) {
const currentDate = moment(e.date).format('YYYY-MM-DD'); const currentDate = moment(e.date).format('YYYY-MM-DD');
const rs= res.filter(item=> currentDate===moment(item.inspectionTime).format('YYYY-MM-DD') ) const rs = res.filter(item => currentDate === moment(item.inspectionTime).format('YYYY-MM-DD'))
if(rs&&rs.length){ if (rs && rs.length) {
if(rs.some(item=>item.patrolRecordIssueHandles.length>0)){ if (rs.some(item => item.patrolRecordIssueHandles.length > 0)) {
e.bottomInfo = '.'; e.bottomInfo = '.';
e.className = 'yellowClass'; e.className = 'yellowClass';
}else{ } else {
e.bottomInfo = '.'; e.bottomInfo = '.';
e.className = 'greenClass'; e.className = 'greenClass';
} }
@ -240,7 +280,7 @@ Page({
type: 'pie', type: 'pie',
center: ['50%', '50%'], center: ['50%', '50%'],
radius: ['20%', '40%'], radius: ['20%', '40%'],
data:data1 data: data1
}] }]
}; };
that.initECharts(option); that.initECharts(option);

9
weapp/package/subSystem/subSystem.json

@ -2,7 +2,12 @@
"usingComponents": { "usingComponents": {
"ec-canvas": "../components/ec-canvas/ec-canvas", "ec-canvas": "../components/ec-canvas/ec-canvas",
"van-calendar": "@vant/weapp/calendar/index" "van-calendar": "@vant/weapp/calendar/index",
"van-dropdown-menu": "@vant/weapp/dropdown-menu/index",
"van-dropdown-item": "@vant/weapp/dropdown-item/index",
"van-popup": "@vant/weapp/popup/index",
"van-picker": "@vant/weapp/picker/index",
"van-icon": "@vant/weapp/icon/index",
"van-datetime-picker": "@vant/weapp/datetime-picker/index"
} }
} }

25
weapp/package/subSystem/subSystem.wxml

@ -23,18 +23,35 @@
总数:{{questions}} 总数:{{questions}}
</view> </view>
</view> </view>
<view style="height: 300px"> <ec-canvas id="mychart-dom-pie" canvas-id="mychart-pie" ec="{{ ec }}"></ec-canvas> <view style="height: 300px">
</view> <ec-canvas id="mychart-dom-pie" canvas-id="mychart-pie" ec="{{ ec }}"></ec-canvas>
</view>
</view> </view>
<!--巡检日历--> <!--巡检日历-->
<view class="card heightStyle"> <view class="card heightStyle">
<view class="header"> <view class="header">
<view style="display:flex;align-items: center;"> <view style="display:flex;align-items: center;">
<image style="width: 30px; height: 30px;" src="/images/calendar.png" /> <image style="width: 30px; height: 30px;margin-right:10px ;" src="/images/calendar.png" />
<view class="xunjian">巡检日历</view> <view class="xunjian">巡检日历</view>
</view> </view>
<image src="/images/shape2.png" class="imgStyle"></image> <image src="/images/shape2.png" class="imgStyle"></image>
<view class="yearMonth">{{currentYear+'年'+currentMonth+'月'}}</view> <view class="yearMonth">
<!-- <van-dropdown-menu active-color="#1989fa">
<van-dropdown-item title="{{ '日期' }}" bind:change="dateChange" value="{{ curSelect }}" options="{{ cList }}" />
</van-dropdown-menu> -->
<view class="fs-cell-content" style="width:100%;text-align:left" bindtap="datePickerPopup">
{{currentYear+'年'+currentMonth+'月'}}<van-icon name="arrow-down" style="float:right;position:relative; top:4px" />
</view>
<van-popup show="{{ datePickerShow }}" position="bottom" custom-style="height: 50%;" bind:close="closeDatePickerPopup">
<view style="display:flex;justify-content: space-between;padding:24rpx;font-size:larger;border-bottom:1px solid #f5f5f5">
<view bindtap="closeDatePickerPopup" data-option='cancel'>取消</view>
<view style="color:#07c160;" data-option='confirmed' bindtap="closeDatePickerPopup">
确定
</view>
</view>
<van-datetime-picker type="year-month" value="{{ currentDate }}" max-date="{{currentDate}}" min-date="{{ minDate }}" bind:input="onDateChange" show-toolbar="{{false}}" />
</van-popup>
</view>
</view> </view>
<van-calendar min-date="{{firstDay}}" max-date="{{lastDay}}" v-model="selectedDate" show-title="{{false}}" show-subtitle="{{false}}" poppable="{{ false }}" show-confirm="{{ false }}" default-date="{{selectedDate}}" formatter="{{formatter}}" bind:select="onDateSelect" color="#0000FF" class="calendar" /> <van-calendar min-date="{{firstDay}}" max-date="{{lastDay}}" v-model="selectedDate" show-title="{{false}}" show-subtitle="{{false}}" poppable="{{ false }}" show-confirm="{{ false }}" default-date="{{selectedDate}}" formatter="{{formatter}}" bind:select="onDateSelect" color="#0000FF" class="calendar" />
</view> </view>

8
weapp/package/subSystem/subSystem.wxss

@ -27,7 +27,9 @@
.heightStyle{ .heightStyle{
height: 100%; height: 100%;
} }
.van-dropdown-item{
padding :0 12px
}
.xunjian{ .xunjian{
width: 64px; width: 64px;
height: 22px; height: 22px;
@ -38,8 +40,8 @@
letter-spacing: 0; letter-spacing: 0;
} }
.yearMonth{ .yearMonth{
width: 85px; width: 95px;
height: 20px; /* height: 20px; */
font-family: PingFangSC-Medium; font-family: PingFangSC-Medium;
font-weight: 500; font-weight: 500;
font-size: 14px; font-size: 14px;

2
weapp/package/troubleshooting/shootingForm/index.js

@ -394,7 +394,7 @@ Page({
let yujingafchishu = undefined; let yujingafchishu = undefined;
let yujingshijian = undefined; let yujingshijian = undefined;
let isgaojing = undefined; let isgaojing = undefined;
await Request.get(getPatrolRecord('all', moment().subtract(50, 'years').format('YYYY-MM-DD HH:mm:ss'), moment().format('YYYY-MM-DD HH:mm:ss'), true, null)).then(res => { await Request.get(getPatrolRecord('all', moment().subtract(50, 'years').format('YYYY-MM-DD HH:mm:ss'), moment().format('YYYY-MM-DD HH:mm:ss'), true, null,{home:false})).then(res => {
const formatData = res.filter(r => ( const formatData = res.filter(r => (
r.pointId === PatrolRecord.pointId r.pointId === PatrolRecord.pointId
&& r.points.projectId === PatrolRecord.points.projectId && r.points.projectId === PatrolRecord.points.projectId

Loading…
Cancel
Save