diff --git a/api/app/lib/controllers/pointDeploy/index.js b/api/app/lib/controllers/pointDeploy/index.js index 8a7360e..0b3d8c7 100644 --- a/api/app/lib/controllers/pointDeploy/index.js +++ b/api/app/lib/controllers/pointDeploy/index.js @@ -126,7 +126,7 @@ async function getProjectPoints(ctx) { const projectId = ctx.params.projectId; const models = ctx.fs.dc.models; rslt = await models.Point.findAll({ - attributes: ['id', 'name'], + attributes: ['id', 'name', 'equipmentNo', 'equipmentModel'], where: { projectId: projectId } }) ctx.status = 200; diff --git a/api/app/lib/models/patrol_record_issue_handle.js b/api/app/lib/models/patrol_record_issue_handle.js index 278709a..c536d66 100644 --- a/api/app/lib/models/patrol_record_issue_handle.js +++ b/api/app/lib/models/patrol_record_issue_handle.js @@ -208,7 +208,7 @@ module.exports = dc => { type: DataTypes.DECIMAL(11, 2), allowNull: true, defaultValue: null, - comment: '成本', + comment: '成本(元)', primaryKey: false, field: "cost", autoIncrement: false diff --git a/script/1.0.5/schema/3.update_patrol_record_issue_handle.sql b/script/1.0.5/schema/3.update_patrol_record_issue_handle.sql index 8f1541a..cf8473f 100644 --- a/script/1.0.5/schema/3.update_patrol_record_issue_handle.sql +++ b/script/1.0.5/schema/3.update_patrol_record_issue_handle.sql @@ -1,4 +1,4 @@ ALTER TABLE "public"."patrol_record_issue_handle" ADD COLUMN "cost" decimal(11,2); -COMMENT ON COLUMN "public"."patrol_record_issue_handle"."cost" IS '成本'; \ No newline at end of file +COMMENT ON COLUMN "public"."patrol_record_issue_handle"."cost" IS '成本(元)'; \ No newline at end of file diff --git a/weapp/package/pointsStatus/pointsStatus.js b/weapp/package/pointsStatus/pointsStatus.js index 358ec28..d83b990 100644 --- a/weapp/package/pointsStatus/pointsStatus.js +++ b/weapp/package/pointsStatus/pointsStatus.js @@ -1,18 +1,66 @@ // package/pointsStatus/pointsStatus.js +import { getProjectGraph, getDeployPoints } from "../../utils/getApiUrl"; +import { Request } from "../../common"; + Page({ /** * 页面的初始数据 */ data: { + imgUrl: getApp().globalData.imgUrl, + image: '', + allPoints: [], + setedPoints: [], + }, + + getData(projectId) { + const that = this; + wx.showLoading({ title: '加载中...' }); + Request.get(getProjectGraph(projectId)).then(res => { + if (res) { + Request.get(getDeployPoints(res.id)).then(pointsRes => { + that.setData({ + image: res.graph, + allPoints: pointsRes.allPoints, + setedPoints: pointsRes.setedPoints.map(p => ({ + ...p, + position: JSON.parse(p.position), + pointInfo: pointsRes.allPoints.find(a => a.id === p.pointId), + })), + }) + }) + } else { + // 未布设 + } + wx.hideLoading() + }) + }, + calcTooltip(e) { + const pointNodeId = e.currentTarget.id; + const pointId = e.currentTarget.dataset.id; + const windowWidth = wx.getSystemInfoSync().windowWidth; + const query = this.createSelectorQuery().in(this); + query.select('#' + pointNodeId).boundingClientRect(data => { + const sub = windowWidth - data.left < 100 ? 100 - (windowWidth - data.left) : 0; + const nextSetedPoints = this.data.setedPoints.map(p => { + if (p.id == pointId) { + p.sub = sub; + p.show = !p.show; + } + return p; + }) + this.setData({ setedPoints: nextSetedPoints }) + }).exec() }, /** * 生命周期函数--监听页面加载 */ onLoad(options) { - console.log(options, 'options') + const { projectId } = options; + this.getData(projectId); }, /** diff --git a/weapp/package/pointsStatus/pointsStatus.json b/weapp/package/pointsStatus/pointsStatus.json index 8835af0..0f32b15 100644 --- a/weapp/package/pointsStatus/pointsStatus.json +++ b/weapp/package/pointsStatus/pointsStatus.json @@ -1,3 +1,9 @@ { - "usingComponents": {} + "navigationBarBackgroundColor": "#1979ff", + "navigationBarTextStyle": "white", + "navigationBarTitleText": "点位状态", + "enablePullDownRefresh": true, + "usingComponents": { + "van-empty": "@vant/weapp/empty/index" + } } \ No newline at end of file diff --git a/weapp/package/pointsStatus/pointsStatus.wxml b/weapp/package/pointsStatus/pointsStatus.wxml index c9f4651..f1e2a9b 100644 --- a/weapp/package/pointsStatus/pointsStatus.wxml +++ b/weapp/package/pointsStatus/pointsStatus.wxml @@ -1,2 +1,25 @@ - -package/pointsStatus/pointsStatus.wxml + + + + + + + 设备编号:{{item.pointInfo.equipmentNo || '--'}} + 设备型号:{{item.pointInfo.equipmentModel || '--'}} + 设备状态:正常 + + + + +结构物介绍 \ No newline at end of file diff --git a/weapp/package/pointsStatus/pointsStatus.wxss b/weapp/package/pointsStatus/pointsStatus.wxss index 6d831ae..39206f0 100644 --- a/weapp/package/pointsStatus/pointsStatus.wxss +++ b/weapp/package/pointsStatus/pointsStatus.wxss @@ -1 +1,23 @@ -/* package/pointsStatus/pointsStatus.wxss */ \ No newline at end of file +/* package/pointsStatus/pointsStatus.wxss */ +.image-box { + width: 100%; + position: relative; +} + +.image-box .image { + width: 100%; +} + +.image-box .point { + position: absolute; + width: 10px; + height: 10px; +} + +.image-box .tooltip { + position: absolute; + font-size: 12px; + background-color: white; + border: 1px solid gainsboro; + width: 98px; +} \ No newline at end of file diff --git a/weapp/pages/index/index.js b/weapp/pages/index/index.js index 0775da1..afe59d6 100644 --- a/weapp/pages/index/index.js +++ b/weapp/pages/index/index.js @@ -74,7 +74,6 @@ Page({ }, onMarkerTap(e) { - console.log(e.detail.markerId, 'e.detail.markerId') wx.navigateTo({url: `/package/pointsStatus/pointsStatus?projectId=${e.detail.markerId}`}) }, diff --git a/weapp/utils/getApiUrl.js b/weapp/utils/getApiUrl.js index cf8313e..002c778 100644 --- a/weapp/utils/getApiUrl.js +++ b/weapp/utils/getApiUrl.js @@ -13,6 +13,14 @@ exports.getProjectList = () => { return `/projectList` } +// 获取点位布设信息 +exports.getProjectGraph = (projectId) => { + return `/project/${projectId}/planarGraph` +} +exports.getDeployPoints = (pictureId) => { + return `/picture/${pictureId}/deploy/points` +} + // 获取巡检计划 exports.getPatrolPlan = () => { return `/patrolPlan` diff --git a/web/client/src/sections/shouye/containers/shouye.js b/web/client/src/sections/shouye/containers/shouye.js index 1863a2d..2dc21fc 100644 --- a/web/client/src/sections/shouye/containers/shouye.js +++ b/web/client/src/sections/shouye/containers/shouye.js @@ -5,7 +5,7 @@ import moment from "moment"; import '../style.less'; import { push } from 'react-router-redux'; import { Model } from 'echarts'; -import { getPatrolPlan } from '../../patrolManage/actions/plan' +import {getPatrolPlan} from '../../patrolManage/actions/plan' import XColumn from '../components/charts/xColumn' import StackColumn from '../components/charts/stackColumn' import AlarmStatistics from '../components/alarm/alarmStatistics' @@ -14,42 +14,50 @@ import Column from '../components/charts/column' const Information = (props) => { const { dispatch, actions, user, loading, clientHeight } = props const { patrolManage, issueHandle } = actions - const [planedata, setplandata] = useState([]) - const [xunjiandata, setxunjiandata] = useState([]) - const [shijiandata, setshijiandata] = useState([]) + const [planedata,setplandata] = useState([]) + const [xunjiandata,setxunjiandata] = useState([]) + const [shijiandata,setshijiandata] = useState([]) const [chartData1, setChartData1] = useState([]) const [chartData2, setChartData2] = useState([]) const [chartData3, setChartData3] = useState([]) const [chartData4, setChartData4] = useState([]) - const topdata = [] + const topdata =[] const format = 'YYYY-MM-DD HH:mm:ss' const times = [moment().subtract(70, 'years').format(format), moment().format(format)] - useEffect(() => { - dispatch(getPatrolPlan()).then(async (res) => { - const res2 = await dispatch(patrolManage.records(`patrolRecord/all/${times[0]}/${times[1]}/null/null`)) - setshijiandata(res2?.payload?.data) - setxunjiandata(res2?.payload?.data.filter(i => parseInt(moment().format('YYYYMMDD')) === parseInt(moment(i.inspectionTime).format('YYYYMMDD')))) - const count = res?.payload?.data?.rows?.filter(i => { - if (i?.frequency.split('/')[i?.frequency.split('/').length - 1] === '天') { - return parseInt(moment().format('YYYYMMDD')) <= parseInt(moment(i.endTime).format('YYYYMMDD')) - } else if (i?.frequency.split('/')[i?.frequency.split('/').length - 1] === '周') { - return parseInt(moment().format('YYYYMMDD')) <= parseInt(moment(i.endTime).format('YYYYMMDD')) && res2?.payload?.data?.filter(j => j.patrolPlanId === i.id - && moment(j.inspectionTim).week() === moment().week()).length < parseInt(i?.frequency?.match(/[\d.]/g).join('')) + useEffect(()=>{ + dispatch(getPatrolPlan()).then(async (res)=>{ + const res2 = await dispatch(patrolManage.records(`patrolRecord/all/${times[0]}/${times[1]}/null/null`)) + console.log(res2,'res2') + setshijiandata(res2?.payload?.data) + setxunjiandata(res2?.payload?.data.filter(i=>parseInt(moment().format('YYYYMMDD'))=== parseInt(moment(i.inspectionTime ).format('YYYYMMDD')))) + const count = res?.payload?.data?.rows?.filter(i=>{ + // console.log(i?.frequency?.match(/^[0-9]*$/),'jjj') + if(i?.frequency.split('/')[i?.frequency.split('/').length-1]==='天'){ + // console.log(i?.frequency?.match(/[\d.]/g).join(''),'jjj') + return parseInt(moment().format('YYYYMMDD'))<=parseInt(moment(i.endTime).format('YYYYMMDD')) + // console.log('是的',i?.frequency.split('/')[i?.frequency.split('/').length-1]) + }else if(i?.frequency.split('/')[i?.frequency.split('/').length-1]==='周'){ + // console.log(i?.frequency?.match(/^[0-9]*$/),'jjj') + return parseInt(moment().format('YYYYMMDD'))<=parseInt(moment(i.endTime).format('YYYYMMDD'))&&res2?.payload?.data?.filter(j=>j.patrolPlanId===i.id + &&moment(j.inspectionTim).week()===moment().week()).length j.patrolPlanId === i.id - && moment(j.inspectionTim).month() === moment().month()).length < parseInt(i?.frequency?.match(/[\d.]/g).join('')) + else if(i?.frequency.split('/')[i?.frequency.split('/').length-1]==='月'){ + // console.log(i?.frequency?.match(/^[0-9]*$/),'jjj') + return parseInt(moment().format('YYYYMMDD'))<=parseInt(moment(i.endTime).format('YYYYMMDD'))&&res2?.payload?.data?.filter(j=>j.patrolPlanId===i.id + &&moment(j.inspectionTim).month()===moment().month()).length { let arr = [] @@ -67,38 +75,38 @@ const Information = (props) => { return ( <> -
-
-
-
今日巡检
-
{planedata.length}
-
-
-
完成巡检:{xunjiandata.length}个
-
巡检上报:{xunjiandata.filter(i => i?.alarm === true).length}个
-
+
+
+
+
今日巡检
+
{planedata.length}
-
-
-
今日事件
-
{xunjiandata.filter(i => i?.alarm === true).length}
-
-
-
已处理:个
-
未处理:2个
-
+
+
完成巡检:{xunjiandata.length}个
+
巡检上报:{xunjiandata.filter(i=>i?.alarm===true).length}个
-
-
-
今日预警
-
0
-
-
-
已下发:2个
-
+
+
+
+
今日事件
+
{xunjiandata.filter(i=>i?.alarm===true).length}
+
+
+
已处理:个
+
未处理:2个
+
+
+
+
+
今日预警
+
0
+
+
+
已下发:2个
- +
+
{ ) } -function mapStateToProps(state) { +function mapStateToProps (state) { const { auth, global } = state; return { user: auth.user, @@ -137,4 +145,4 @@ function mapStateToProps(state) { }; } -export default connect(mapStateToProps)(Information); +export default connect(mapStateToProps)(Information); \ No newline at end of file