diff --git a/api/app/lib/controllers/patrolRecord/patrolRecord.js b/api/app/lib/controllers/patrolRecord/patrolRecord.js index f00a75c..cc1dd8b 100644 --- a/api/app/lib/controllers/patrolRecord/patrolRecord.js +++ b/api/app/lib/controllers/patrolRecord/patrolRecord.js @@ -9,15 +9,27 @@ async function findPatrolRecord (ctx, next) { // patrolPlanId传all查所有 if (patrolPlanId == 'all') { /* 如果有startTime && endTime,查询所有符合条件的数据 */ - if (startTime && endTime) { + if (startTime !== 'null' && endTime !== 'null') { if (pointId) { - rslt = await models.PatrolRecord.findAll({ - where: { alarm, inspectionTime: { $between: [startTime, endTime] }, pointId: { $in: pointId.split(',') } }, - }); + if (alarm == 'null') { + rslt = await models.PatrolRecord.findAll({ + where: { inspectionTime: { $between: [startTime, endTime] }, pointId: { $in: pointId.split(',') } }, + }); + } else { + rslt = await models.PatrolRecord.findAll({ + where: { alarm, inspectionTime: { $between: [startTime, endTime] }, pointId: { $in: pointId.split(',') } }, + }); + } } else { - rslt = await models.PatrolRecord.findAll({ - where: { alarm, inspectionTime: { $between: [startTime, endTime] } }, - }); + if (alarm == 'null') { + rslt = await models.PatrolRecord.findAll({ + where: { inspectionTime: { $between: [startTime, endTime] } }, + }); + } else { + rslt = await models.PatrolRecord.findAll({ + where: { alarm, inspectionTime: { $between: [startTime, endTime] } }, + }); + } } } else { /* 如果没有startTime && endTime,查询每个点位最新一条符合条件的数据 */ @@ -32,7 +44,7 @@ async function findPatrolRecord (ctx, next) { }) } } else { - if (startTime && endTime) { + if (startTime !== 'null' && endTime !== 'null') { if (pointId) { rslt = await models.PatrolRecord.findAll({ where: { patrolPlanId: { $in: patrolPlanId.split(',') }, alarm, inspectionTime: { $between: [startTime, endTime] }, pointId: { $in: pointId.split(',') } }, diff --git a/web/client/src/sections/patrolManage/actions/index.js b/web/client/src/sections/patrolManage/actions/index.js index aaaafe9..c465b0f 100644 --- a/web/client/src/sections/patrolManage/actions/index.js +++ b/web/client/src/sections/patrolManage/actions/index.js @@ -1,7 +1,9 @@ 'use strict'; import * as plan from './plan' +import * as record from './record' export default { ...plan, + ...record, } \ No newline at end of file diff --git a/web/client/src/sections/patrolManage/actions/record.js b/web/client/src/sections/patrolManage/actions/record.js new file mode 100644 index 0000000..a6ae77e --- /dev/null +++ b/web/client/src/sections/patrolManage/actions/record.js @@ -0,0 +1,17 @@ +'use strict'; + +import { basicAction } from '@peace/utils' + +export const GET_PATROL_RECORD_LIST = 'GET_PATROL_RECORD_LIST'; +export const GET_PATROL_RECORD_LIST_SUCCESS = 'GET_PATROL_RECORD_LIST_SUCCESS'; +export const GET_PATROL_RECORD_LIST_ERROR = 'GET_PATROL_RECORD_LIST_ERROR'; +export function records(url) { + return (dispatch) => basicAction({ + type: 'get', + dispatch, + actionType: GET_PATROL_RECORD_LIST, + url: url, + msg: { error: '获取巡检记录失败', }, + reducer: { name: 'record' } + }); +} \ No newline at end of file diff --git a/web/client/src/sections/patrolManage/containers/index.js b/web/client/src/sections/patrolManage/containers/index.js index 4121322..d83768a 100644 --- a/web/client/src/sections/patrolManage/containers/index.js +++ b/web/client/src/sections/patrolManage/containers/index.js @@ -1,5 +1,6 @@ 'use strict'; import PatrolPlan from './patrolPlan'; +import PatrolReocrd from './patrolRecord'; -export { PatrolPlan }; \ No newline at end of file +export { PatrolPlan, PatrolReocrd }; \ No newline at end of file diff --git a/web/client/src/sections/patrolManage/containers/patrolRecord.js b/web/client/src/sections/patrolManage/containers/patrolRecord.js new file mode 100644 index 0000000..e10829e --- /dev/null +++ b/web/client/src/sections/patrolManage/containers/patrolRecord.js @@ -0,0 +1,175 @@ + +'use strict' + +import React, { useEffect, useState } from 'react'; +import { connect } from 'react-redux'; +import { Form, Input, Select, Button, Table, Modal, DatePicker } from 'antd'; +import moment from "moment"; + +const PatrolRecord = (props) => { + const { dispatch, actions, } = props + const { patrolManage } = actions + const [tableList, settableList] = useState([]) + const [addModel, setAddModel] = useState(false) + const [modelData, setModelData] = useState({}) + const [query, setQuery] = useState({ limit: 10, page: 0 }) + const [limits, setLimits] = useState() + const format = 'YYYY-MM-DD' + const [search, setSearch] = useState({ name: null, time: [moment().add(-7, 'd').format(format), moment().format(format)], state: 'null' }) + + useEffect(() => { + record(search) + }, []) + + const record = (params) => { + dispatch(patrolManage.records(`patrolRecord/all/${params.time[0]}/${params.time[1]}/${params.state}/1`)).then(res => { + if (res.success) { + settableList(res.payload.data?.map(v => ({ ...v, key: v.id }))) + setLimits(res.payload.data?.length) + } + }) + } + + const columns = [{ + title: '结构物名称', + dataIndex: 'name', + key: 'name', + render: (text, record, index) => { + return !record.points?.project? '':