From 806c69b8f71ff0c2339a6ff3f720bc6ee3c6ec2a Mon Sep 17 00:00:00 2001 From: liujiangyong Date: Wed, 25 Oct 2023 11:24:30 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E4=BB=8A=E6=97=A5=E5=BE=85=E6=A3=80?= =?UTF-8?q?=E5=88=86=E5=B8=83=E8=AE=A1=E7=AE=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../subSystem/dayPatrolInfo/dayPatrolInfo.js | 64 +++++++++++-------- 1 file changed, 38 insertions(+), 26 deletions(-) diff --git a/weapp/package/subSystem/dayPatrolInfo/dayPatrolInfo.js b/weapp/package/subSystem/dayPatrolInfo/dayPatrolInfo.js index a5cb997..19d984a 100644 --- a/weapp/package/subSystem/dayPatrolInfo/dayPatrolInfo.js +++ b/weapp/package/subSystem/dayPatrolInfo/dayPatrolInfo.js @@ -123,28 +123,49 @@ Page({ this.inspectedPoints = inspectedPoints; // 今日待检分布 - // let needInspectPoints = []; - // subSystemPatrol.dayPatrolPlan.forEach((plan) => { - // const unit = plan.frequency.split('/')[1]; - // const frequency = plan.frequency.split('/')[0]; - // let record = [...patrolRecord]; - // switch (unit) { - // case '周': - // record = patrolRecord.filter(r => moment(r.inspectionTime).isSame(this.day, 'day')); - // break; - // case '天': - // record = patrolRecord.filter(r => moment(r.inspectionTime).isSame(this.day, 'day')); - // break; - // default: - // break; - // } - // }) + let needInspectPoints = []; + subSystemPatrol.dayPatrolPlan.forEach((plan) => { + const unit = plan.frequency.split('/')[1]; + const frequency = Number(plan.frequency.split('次')[0]); + let record = patrolRecord.filter(r => + moment(r.inspectionTime).isBefore(moment(this.day).endOf('day')) // 当前选定日期及之前的巡检记录 + && r.patrolPlanId === plan.id // 关联当前计划的记录 + ); + switch (unit) { + case '月': + record = record.filter(r => moment(r.inspectionTime).isSame(this.day, 'month ')); + break; + case '周': + record = record.filter(r => moment(r.inspectionTime).isSame(this.day, 'isoWeek')); + break; + case '天': + record = record.filter(r => moment(r.inspectionTime).isSame(this.day, 'day')); + break; + default: + break; + } + plan.points.forEach(p => { + const index = needInspectPoints.findIndex(n => n.name === p.name) + if (index === -1) { + needInspectPoints.push({ name: p.name, value: frequency }); + } else { + needInspectPoints[index].value += frequency; + } + }) + record.forEach(r => { + const index = needInspectPoints.findIndex(n => n.name === r.points.itemData.name); + if (index !== -1 && needInspectPoints[index].value > 0) { + needInspectPoints[index].value -= 1; + } + }) + }) + 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), - }) }) }, @@ -158,15 +179,6 @@ Page({ this.day = options.day; this.subType = options.subType; this.getData(); - setTimeout(() => { - this.initNeedChart([ - { value: 1048, name: '点位1' }, - { value: 735, name: '点位2' }, - { value: 580, name: '点位3' }, - { value: 580, name: '点位4' }, - { value: 580, name: '点位5' }, - ]) - }, 1000) }, /**