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. 273
      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. 58
      weapp/package/subSystem/subSystem.js
  24. 9
      weapp/package/subSystem/subSystem.json
  25. 23
      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 {
const models = ctx.fs.dc.models;
const { startTime, endTime, alarm, patrolPlanId, pointId } = ctx.params;
const { home } = ctx.query
const sequelize = ctx.fs.dc.orm;
// patrolPlanId传all查所有
let generalInclude = [{
model: models.PatrolPlan,
@ -42,15 +44,19 @@ async function findPatrolRecord(ctx, next) {
}
} else {
if (alarm == 'null') {
rslt = await models.PatrolRecord.findAll({
where: {
inspectionTime: { $between: [startTime, endTime] }
let option={ where: {
inspectionTime: { $between: [startTime, endTime] },
},
include: generalInclude.concat([{
model: models.Point,
attributes: ['id', 'name']
}])
});
}
// 小程序首页优化(只查对应数据条数,不需要详细数据)
if(home=='true'){
option.attributes=['id', 'alarm','inspection_time','project_id']
}
rslt = await models.PatrolRecord.findAll(option)
} else {
rslt = await models.PatrolRecord.findAll({
where: {
@ -126,7 +132,12 @@ async function findPatrolRecord(ctx, next) {
rslt = rslt.filter(f => f)
if (userInfo.username != 'SuperAdmin') {
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))
}
} else {
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 = {
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) {
app.fs.api.logAttr['GET/patrolReport'] = { content: '获取巡检报告', visible: false };
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": [
"getLocation"
"getLocation","chooseLocation"
],
"sitemapLocation": "sitemap.json",
"usingComponents": {}

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

@ -68,12 +68,9 @@ Page({
const res=await Request.get(getProjectList())
const rslt=await Request.get(getRelationList())
if(res.rows.length&&rslt.rows.length){
const data=res.rows.map(item=>{
return {
value: item.id,
text:item.name
}
})
const filterData=res.rows.filter(s => s.type=='管廊' )
const data=filterData?.map(item=>( { value: item.id, text:item.name }))
if(res1&&res1.length){
listt=res1.map(item=>{
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 rslt = await Request.get(getRelationList())
if (res.rows.length && rslt.rows.length) {
const data=res.rows.map(item=>{
return {
value: item.id,
text:item.name
}
})
const filterData=res.rows.filter(s => s.type=='管廊' )
const data=filterData?.map(item=>( { value: item.id, text:item.name }))
data.unshift({ text: '全部', value: 'all' })
if (complexArray && complexArray.length) {
dd = complexArray.map(item => {
@ -57,6 +52,7 @@ Page({
}
})
}
console.log('dd',dd)
this.setData({
structList: data,
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) {
let normal = 0;
let abnormal = 0;

273
weapp/package/inspectionInput/inspectionInput.js

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

14
weapp/package/inspectionReport/inspectionReport.js

@ -59,7 +59,6 @@ Page({
showMenu: true,
fileType:url.includes('xlsx')?'xlsx':url.includes('docx')?'docx':'',
success: function (res) {
console.log('打开文档成功');
},
fail: function (error) {
@ -94,13 +93,22 @@ Page({
getStructuresList() {
this.setData({ struLoading: true });
Request.get(getStructuresList()).then(res => {
const filterData=res.rows.filter(s => s.type=='管廊' )
this.setData({
struLoading: false,
structures: [
{ 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({
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) {
that.setData({
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}`,
success: function (res) {
wx.hideLoading();
// 根据自己项目需求获取res内容
wx.chooseLocation({
success:function(res){
that.setData({
address: res.data.result.address
address: res.name
})
}
})
// 根据自己项目需求获取res内容
}
})
},

2
weapp/package/report/report.json

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

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

@ -63,7 +63,7 @@ Page({
*/
onLoad(options) {
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)
for (let i = 6; i >= 0; i--) {
const month = moment().subtract(i, 'day').month();

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

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

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

@ -103,3 +103,16 @@
.content-right {
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({
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();
dataList.points.map(e => {
res.map(i => {

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

@ -53,6 +53,7 @@ Page({
// 今日待检分布图表
initNeedChart: function (data) {
if(this.needEcComponent){
this.needEcComponent.init((canvas, width, height, dpr) => {
const chart = echarts.init(canvas, null, {
width: width,
@ -62,10 +63,13 @@ Page({
setPieOptions(chart, data)
return chart;
});
}
},
// 今日已检分布图表
initAlreadyChart: function (data) {
if( this.alreadyEcComponent){
this.alreadyEcComponent.init((canvas, width, height, dpr) => {
const chart = echarts.init(canvas, null, {
width: width,
@ -75,14 +79,16 @@ Page({
setPieOptions(chart, data)
return chart;
});
}
},
getData() {
const promiseArr = [
Request.get(getSubSystemPatrol(this.day, this.subType)),
Request.get(getSubSystemPatrolAbout({
STime: moment().startOf('month').format('YYYY-MM-DD HH:mm:ss'),
ETime: moment().endOf('month').format('YYYY-MM-DD HH:mm:ss'),
STime: moment(this.day).startOf('month').format('YYYY-MM-DD HH:mm:ss'),
ETime: moment(this.day).endOf('month').format('YYYY-MM-DD HH:mm:ss'),
keywords: this.subType,
})),
]
@ -161,13 +167,19 @@ Page({
})
})
this.initNeedChart(needInspectPoints)
this.initAlreadyChart(inspectedPoints)
this.setData({
dayIssues: nextDayIssues,
needInspectCount: needInspectPoints.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() {
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>
<image src="/images/question_card_bg.png" class="card-bg" />
</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>
<progress
style="width: 70%;"
percent="{{item.percent}}"
activeColor="{{item.color}}"
stroke-width="8"
show-info
font-size="14"
border-radius="4"
/>
<progress style="width: 70%;" percent="{{item.percent}}" activeColor="{{item.color}}" stroke-width="8" show-info font-size="14" border-radius="4" />
</view>
<!-- 暂无数据 -->
<view wx:if="{{!dayIssues.length}}">
<image class="noData" src="../../../images/noData.svg"></image>
<view class="noTxt">暂无数据</view>
</view>
</view>
<view class="card" style="margin-bottom: 10px">
<view class="card-top flex flex-between">
<view class="card-left flex">
@ -30,10 +28,31 @@
<view class="card-right">总次数:{{needInspectCount}}次</view>
<image src="/images/hourglass_card_bg.png" class="card-bg" />
</view>
<!-- 有数据时显示图表 -->
<!-- <view wx:if="{{needInspectCount}}">
<view class="pie-chart-box">
<ec-canvas id="need-chart-dom" canvas-id="need-chart" ec="{{ needEc }}"></ec-canvas>
</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 class="card" style="margin-bottom: 10px">
<view class="card-top flex flex-between">
<view class="card-left flex">
@ -43,8 +62,27 @@
<view class="card-right">总次数:{{inspectedCount}}次</view>
<image src="/images/right_card_bg.png" class="card-bg" />
</view>
<!-- 有数据时显示图表 -->
<!-- <view wx:if="{{inspectedCount}}">
<view class="pie-chart-box">
<ec-canvas id="already-chart-dom" canvas-id="already-chart" ec="{{ alreadyEc }}"></ec-canvas>
</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 wx:else>
<image class="noData" src="../../../images/noData.svg"></image>
<view class="noTxt">暂无数据</view>
</view>
</view>
</view>

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

@ -69,3 +69,17 @@
height: 280px;
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;
}

58
weapp/package/subSystem/subSystem.js

@ -8,8 +8,6 @@ import {
} from "../../common";
const moment = require("../../utils/moment");
Page({
initECharts(option) {
this.ecComponent.init((canvas, width, height, dpr) => {
@ -20,10 +18,8 @@ Page({
});
// 设置图表的配置
chart.setOption(option);
// 将 ECharts 实例保存在数据中
this.chart = chart;
// 返回 ECharts 实例
return chart;
});
@ -40,19 +36,32 @@ Page({
record: [],//巡检记录
currentPatrolCount: 0, //当月巡检次数
currentRepairCount: 0, //当月维修次数
currentDate: new Date().getTime(),
minDate: 0,
curSelect: null,//当前选择
// level1Count: 0, //轻微
// level2Count: 0, //中度
// level3Count: 0, //严重
// dataList:[],//饼图数据
selectedDate: new Date(), // 设置默认选中的日期为当前日期
questions: 0,//故障数量
datePickerShow: false,//选择日期
formatter(day) {
return day;
},
},
datePickerPopup() {
this.setData({
datePickerShow: true
})
},
closeDatePickerPopup() {
this.setData({
datePickerShow: false
})
},
onDisplay() {
this.setData({
show: true
@ -71,6 +80,22 @@ 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) {
const currentDate = moment(e.detail).format('YYYY-MM-DD')
const inspectionData = this.data.record.find(item => currentDate == moment(item.inspectionTime).format('YYYY-MM-DD'));
@ -133,10 +158,8 @@ Page({
getSubSystemPatrolAbout: function (options) {
// const userInfo=wx.getStorageSync('userInfo');
let that = this;
//当月开始时间
const STime = moment().startOf('month').format('YYYY-MM-DD')
//当月结束时间
const ETime = moment().endOf('month').format('YYYY-MM-DD')
const STime = moment('1970-01-01').format('YYYY-MM-DD')
const ETime = moment('2099-12-31').format('YYYY-MM-DD')
//子系统关键字
let keywords = options.key
const maxInspectionTimeByPointId = {};
@ -144,6 +167,23 @@ Page({
const query = { STime, ETime, keywords }
Request.get(getSubSystemPatrolAbout(query)).then(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
res.forEach((item) => {
const { pointId, inspectionTime } = item;

9
weapp/package/subSystem/subSystem.json

@ -2,7 +2,12 @@
"usingComponents": {
"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"
}
}

23
weapp/package/subSystem/subSystem.wxml

@ -23,18 +23,35 @@
总数:{{questions}}
</view>
</view>
<view style="height: 300px"> <ec-canvas id="mychart-dom-pie" canvas-id="mychart-pie" ec="{{ ec }}"></ec-canvas>
<view style="height: 300px">
<ec-canvas id="mychart-dom-pie" canvas-id="mychart-pie" ec="{{ ec }}"></ec-canvas>
</view>
</view>
<!--巡检日历-->
<view class="card heightStyle">
<view class="header">
<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>
<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>
<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>

8
weapp/package/subSystem/subSystem.wxss

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

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

@ -394,7 +394,7 @@ Page({
let yujingafchishu = undefined;
let yujingshijian = 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 => (
r.pointId === PatrolRecord.pointId
&& r.points.projectId === PatrolRecord.points.projectId

Loading…
Cancel
Save