From 7ba1490e216604406ed854aa1f00c38adb2737fd Mon Sep 17 00:00:00 2001 From: liujiangyong Date: Fri, 3 Mar 2023 17:49:10 +0800 Subject: [PATCH] =?UTF-8?q?=E5=B7=A1=E6=A3=80=E6=8A=A5=E5=91=8A=E6=95=B0?= =?UTF-8?q?=E6=8D=AE=E6=8E=A5=E5=85=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controllers/patrolManage/patrolReport.js | 5 +- .../sections/patrolManage/actions/report.js | 20 ++--- .../patrolManage/containers/patrolReport.js | 75 +++++++++++++------ web/client/src/utils/webapi.js | 3 + 4 files changed, 70 insertions(+), 33 deletions(-) diff --git a/api/app/lib/controllers/patrolManage/patrolReport.js b/api/app/lib/controllers/patrolManage/patrolReport.js index 9ff6c05..acf6bb0 100644 --- a/api/app/lib/controllers/patrolManage/patrolReport.js +++ b/api/app/lib/controllers/patrolManage/patrolReport.js @@ -5,7 +5,10 @@ async function getPatrolReport(ctx, next) { const models = ctx.fs.dc.models; const { limit, page, projectId, startTime, endTime } = ctx.query; let options = { - where: {} + where: {}, + include: [{ + model: models.Project + }] }; if (limit) { options.limit = Number(limit); diff --git a/web/client/src/sections/patrolManage/actions/report.js b/web/client/src/sections/patrolManage/actions/report.js index ca1d63e..39a3878 100644 --- a/web/client/src/sections/patrolManage/actions/report.js +++ b/web/client/src/sections/patrolManage/actions/report.js @@ -3,13 +3,13 @@ import { basicAction } from '@peace/utils' import { ApiTable } from '$utils' -// export function getPatrolReport (query) { -// return dispatch => basicAction({ -// type: 'get', -// query, -// dispatch: dispatch, -// actionType: 'GET_PATROL_REPORT', -// url: ApiTable.getPatrolReport, -// msg: { error: '获取巡检报告失败' }, -// }); -// } \ No newline at end of file +export function getPatrolReport (query) { + return dispatch => basicAction({ + type: 'get', + query, + dispatch: dispatch, + actionType: 'GET_PATROL_REPORT', + url: ApiTable.patrolReport, + msg: { error: '获取巡检报告失败' }, + }); +} \ No newline at end of file diff --git a/web/client/src/sections/patrolManage/containers/patrolReport.js b/web/client/src/sections/patrolManage/containers/patrolReport.js index dee37e8..0167421 100644 --- a/web/client/src/sections/patrolManage/containers/patrolReport.js +++ b/web/client/src/sections/patrolManage/containers/patrolReport.js @@ -1,20 +1,43 @@ -import React, { useState, useRef } from 'react'; +import React, { useState, useRef, useEffect } from 'react'; import { connect } from 'react-redux'; import { Button } from 'antd'; import ProTable from '@ant-design/pro-table'; -import { getCheckItems } from '../actions/checkItems'; +import { getPatrolReport } from '../actions/report'; +import { getProjectList } from '../actions/plan'; +import moment from 'moment'; function patrolReport(props) { const { dispatch } = props; const tableRef = useRef(); - const [dataSource, setDataSource] = useState([{}]); + const [selectOpts, setSelectOpts] = useState([]); + const [date, setDate] = useState([moment(), moment()]); + const [dataSource, setDataSource] = useState([]); + + const qnDomain = localStorage.getItem('qnDomain'); + + useEffect(() => { + dispatch(getProjectList()).then(res => { + if (res.success) { + const nextSelectOpts = res.payload?.data?.rows.map(d => { + return { label: d.name, value: d.id } + }) + setSelectOpts(nextSelectOpts) + } + }); + }, []) const columns = [{ title: '结构物名称', - dataIndex: 'name', - key: 'name', + dataIndex: 'projectName', + key: 'projectName', + valueType: 'select', + fieldProps: { + defaultValue: '', + options: [{ label: '全部', value: '' }, ...selectOpts], + }, ellipsis: true, width: 150, + render: (_, record) =>
{record.project.name}
}, { title: '巡检报告名称', dataIndex: 'groupName', @@ -23,17 +46,22 @@ function patrolReport(props) { search: false, width: 250, render: (_, record) => { - return
{record?.checkItemsGroup?.name}
+ const fileName = record?.excelPath?.substring(record?.excelPath?.lastIndexOf('/') + 1); + return
{fileName}
} }, { title: '巡检日期', dataIndex: 'date', key: 'date', valueType: 'dateRange', + fieldProps: { + value: date, + onChange: e => { setDate(e) } + }, ellipsis: true, width: 150, render: (_, record) => { - return
{record?.checkItemsGroup?.name}
+ return
{moment(record?.inspectTm).format('YYYY-MM-DD')}
} }, { title: '操作', @@ -44,10 +72,9 @@ function patrolReport(props) { render: (_, record) => { return <> - + }, }]; @@ -62,16 +89,18 @@ function patrolReport(props) { rowKey='id' pagination={{ pageSize: 10 }} request={async (params = {}) => { - // const res = await dispatch(getCheckItems({ - // limit: params.pageSize, - // page: params.current - 1, - // name: params?.name - // })); - // setDataSource(res?.payload.data?.rows); - // return { - // ...res, - // total: res.payload.data.count ? res.payload.data.count : 0, - // }; + const res = await dispatch(getPatrolReport({ + limit: params?.pageSize, + page: params?.current - 1, + projectId: params?.projectName, + startTime: date ? date[0].format('YYYY-MM-DD') + ' 00:00:00' : '', + endTime: date ? date[1].format('YYYY-MM-DD') + ' 23:59:59' : '', + })); + setDataSource(res?.payload.data?.rows); + return { + ...res, + total: res.payload.data.count ? res.payload.data.count : 0, + }; }} onReset={() => { }} /> @@ -80,9 +109,11 @@ function patrolReport(props) { } function mapStateToProps(state) { - const { auth } = state + const { auth, structureList } = state return { - user: auth.user + user: auth.user, + struList: structureList.data || [], + struLoading: structureList.isRequesting, } } export default connect(mapStateToProps)(patrolReport); diff --git a/web/client/src/utils/webapi.js b/web/client/src/utils/webapi.js index a4ab9b4..8232b71 100644 --- a/web/client/src/utils/webapi.js +++ b/web/client/src/utils/webapi.js @@ -30,6 +30,9 @@ export const ApiTable = { // 巡检记录 patrolRecord: 'patrolRecord/:patrolPlanId/:startTime/:endTime/:alarm/:pointId', + // 巡检报告 + patrolReport: 'patrolReport', + // 检查项设定 checkItems: 'checkItems', // 获取/新增 updateCheckItems: 'checkItems/{id}',