Browse Source

feat:fix bugs

master
zhaobing 12 months ago
parent
commit
3fd68ffd2a
  1. 10
      api/app/lib/controllers/bigScreen/leader.js
  2. 2
      web-screen/client/src/sections/bigScreen/components/leader/left.js

10
api/app/lib/controllers/bigScreen/leader.js

@ -6,7 +6,7 @@ const moment = require("moment");
function getPlanCount(startTime,endTime,frequencyUnit){ function getPlanCount(startTime,endTime,frequencyUnit){
switch(frequencyUnit){ switch(frequencyUnit){
case '天': case '天':
return Math.ceil(moment(endTime).diff(startTime, 'days')) return Math.ceil(moment(endTime).diff(startTime, 'days'))+1
case '周': case '周':
return Math.ceil(moment(endTime).diff(startTime, 'weeks')) return Math.ceil(moment(endTime).diff(startTime, 'weeks'))
case '月': case '月':
@ -61,7 +61,7 @@ async function findPatrolRecords(ctx, next) {
}) })
planCount=getPlanCount(startTime,endTime,frequencyUnit) planCount=getPlanCount(startTime,endTime,frequencyUnit)
} else if (moment(c.startTime).isSameOrAfter(moment(startTime)) && moment(c.startTime).isSameOrBefore(moment(endTime))) { } else if (moment(c.startTime).isSameOrAfter(moment(startTime)) && moment(c.endTime).isSameOrBefore(moment(endTime))) {
done = await models.PatrolRecord.count({ done = await models.PatrolRecord.count({
where: { where: {
inspectionTime: { $between: [c.startTime, endTime] }, inspectionTime: { $between: [c.startTime, endTime] },
@ -77,15 +77,15 @@ async function findPatrolRecords(ctx, next) {
patrolPlanId: c.id patrolPlanId: c.id
} }
}) })
planCount=getPlanCount(c.startTime,endTime,frequencyUnit) planCount=getPlanCount(startTime,c.endTime,frequencyUnit)
} else if (moment(c.startTime).isAfter(moment(startTime)) && moment(c.endTime).isBefore(moment(endTime))) { } else if (moment(c.startTime).isAfter(moment(startTime)) && moment(c.startTime).isBefore(moment(endTime))) {
done = await models.PatrolRecord.count({ done = await models.PatrolRecord.count({
where: { where: {
inspectionTime: { $between: [c.startTime, c.endTime] }, inspectionTime: { $between: [c.startTime, c.endTime] },
patrolPlanId: c.id patrolPlanId: c.id
} }
}) })
planCount=getPlanCount(startTime,c.endTime,frequencyUnit) planCount=getPlanCount(c.startTime,endTime,frequencyUnit)
} }
let dones = await models.PatrolRecord.count({ let dones = await models.PatrolRecord.count({
where: { where: {

2
web-screen/client/src/sections/bigScreen/components/leader/left.js

@ -277,7 +277,7 @@ const Left = props => {
<img src='/assets/bigScreen/doneRate.png'></img> <img src='/assets/bigScreen/doneRate.png'></img>
</div> </div>
<div className='rate' style={{ bottom: '6.5125rem', left: '11.875rem' }}> <div className='rate' style={{ bottom: '6.5125rem', left: '11.875rem' }}>
{`${plan > 0 ? ((done / done + plan) * 100).toFixed(2) : 0}%`} {`${plan > 0 ? ((done / (done + plan)) * 100).toFixed(0) : 0}%`}
</div> </div>
<div style={{ display: 'flex', justifyContent: 'center', marginTop: '.5rem' }}>当前巡检完成率</div> <div style={{ display: 'flex', justifyContent: 'center', marginTop: '.5rem' }}>当前巡检完成率</div>
<div style={{ display: 'flex', justifyContent: 'space-between' }}> <div style={{ display: 'flex', justifyContent: 'space-between' }}>

Loading…
Cancel
Save