Browse Source

巡检报告数据接入

master
liujiangyong 2 years ago
parent
commit
7ba1490e21
  1. 5
      api/app/lib/controllers/patrolManage/patrolReport.js
  2. 20
      web/client/src/sections/patrolManage/actions/report.js
  3. 75
      web/client/src/sections/patrolManage/containers/patrolReport.js
  4. 3
      web/client/src/utils/webapi.js

5
api/app/lib/controllers/patrolManage/patrolReport.js

@ -5,7 +5,10 @@ async function getPatrolReport(ctx, next) {
const models = ctx.fs.dc.models; const models = ctx.fs.dc.models;
const { limit, page, projectId, startTime, endTime } = ctx.query; const { limit, page, projectId, startTime, endTime } = ctx.query;
let options = { let options = {
where: {} where: {},
include: [{
model: models.Project
}]
}; };
if (limit) { if (limit) {
options.limit = Number(limit); options.limit = Number(limit);

20
web/client/src/sections/patrolManage/actions/report.js

@ -3,13 +3,13 @@
import { basicAction } from '@peace/utils' import { basicAction } from '@peace/utils'
import { ApiTable } from '$utils' import { ApiTable } from '$utils'
// export function getPatrolReport (query) { export function getPatrolReport (query) {
// return dispatch => basicAction({ return dispatch => basicAction({
// type: 'get', type: 'get',
// query, query,
// dispatch: dispatch, dispatch: dispatch,
// actionType: 'GET_PATROL_REPORT', actionType: 'GET_PATROL_REPORT',
// url: ApiTable.getPatrolReport, url: ApiTable.patrolReport,
// msg: { error: '获取巡检报告失败' }, msg: { error: '获取巡检报告失败' },
// }); });
// } }

75
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 { connect } from 'react-redux';
import { Button } from 'antd'; import { Button } from 'antd';
import ProTable from '@ant-design/pro-table'; 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) { function patrolReport(props) {
const { dispatch } = props; const { dispatch } = props;
const tableRef = useRef(); 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 = [{ const columns = [{
title: '结构物名称', title: '结构物名称',
dataIndex: 'name', dataIndex: 'projectName',
key: 'name', key: 'projectName',
valueType: 'select',
fieldProps: {
defaultValue: '',
options: [{ label: '全部', value: '' }, ...selectOpts],
},
ellipsis: true, ellipsis: true,
width: 150, width: 150,
render: (_, record) => <div>{record.project.name}</div>
}, { }, {
title: '巡检报告名称', title: '巡检报告名称',
dataIndex: 'groupName', dataIndex: 'groupName',
@ -23,17 +46,22 @@ function patrolReport(props) {
search: false, search: false,
width: 250, width: 250,
render: (_, record) => { render: (_, record) => {
return <div>{record?.checkItemsGroup?.name}</div> const fileName = record?.excelPath?.substring(record?.excelPath?.lastIndexOf('/') + 1);
return <div>{fileName}</div>
} }
}, { }, {
title: '巡检日期', title: '巡检日期',
dataIndex: 'date', dataIndex: 'date',
key: 'date', key: 'date',
valueType: 'dateRange', valueType: 'dateRange',
fieldProps: {
value: date,
onChange: e => { setDate(e) }
},
ellipsis: true, ellipsis: true,
width: 150, width: 150,
render: (_, record) => { render: (_, record) => {
return <div>{record?.checkItemsGroup?.name}</div> return <div>{moment(record?.inspectTm).format('YYYY-MM-DD')}</div>
} }
}, { }, {
title: '操作', title: '操作',
@ -44,10 +72,9 @@ function patrolReport(props) {
render: (_, record) => { render: (_, record) => {
return <> return <>
<Button type="link" onClick={() => { <Button type="link" onClick={() => {
const qnDomain = localStorage.getItem('qnDomain'); window.open(`https://view.officeapps.live.com/op/view.aspx?src=${qnDomain}/${record?.excelPath}`)
window.open(`https://view.officeapps.live.com/op/view.aspx?src=${qnDomain}${'/project/8fe38891-59c5-4735-b3d9-d8d335fc28ee/test.docx'}`)
}}>预览</Button> }}>预览</Button>
<Button type="link" onClick={() => { /* 下载 */ }}>下载</Button> <Button type="link" onClick={() => { window.open(qnDomain + '/' + record?.excelPath) }}>下载</Button>
</> </>
}, },
}]; }];
@ -62,16 +89,18 @@ function patrolReport(props) {
rowKey='id' rowKey='id'
pagination={{ pageSize: 10 }} pagination={{ pageSize: 10 }}
request={async (params = {}) => { request={async (params = {}) => {
// const res = await dispatch(getCheckItems({ const res = await dispatch(getPatrolReport({
// limit: params.pageSize, limit: params?.pageSize,
// page: params.current - 1, page: params?.current - 1,
// name: params?.name projectId: params?.projectName,
// })); startTime: date ? date[0].format('YYYY-MM-DD') + ' 00:00:00' : '',
// setDataSource(res?.payload.data?.rows); endTime: date ? date[1].format('YYYY-MM-DD') + ' 23:59:59' : '',
// return { }));
// ...res, setDataSource(res?.payload.data?.rows);
// total: res.payload.data.count ? res.payload.data.count : 0, return {
// }; ...res,
total: res.payload.data.count ? res.payload.data.count : 0,
};
}} }}
onReset={() => { }} onReset={() => { }}
/> />
@ -80,9 +109,11 @@ function patrolReport(props) {
} }
function mapStateToProps(state) { function mapStateToProps(state) {
const { auth } = state const { auth, structureList } = state
return { return {
user: auth.user user: auth.user,
struList: structureList.data || [],
struLoading: structureList.isRequesting,
} }
} }
export default connect(mapStateToProps)(patrolReport); export default connect(mapStateToProps)(patrolReport);

3
web/client/src/utils/webapi.js

@ -30,6 +30,9 @@ export const ApiTable = {
// 巡检记录 // 巡检记录
patrolRecord: 'patrolRecord/:patrolPlanId/:startTime/:endTime/:alarm/:pointId', patrolRecord: 'patrolRecord/:patrolPlanId/:startTime/:endTime/:alarm/:pointId',
// 巡检报告
patrolReport: 'patrolReport',
// 检查项设定 // 检查项设定
checkItems: 'checkItems', // 获取/新增 checkItems: 'checkItems', // 获取/新增
updateCheckItems: 'checkItems/{id}', updateCheckItems: 'checkItems/{id}',

Loading…
Cancel
Save