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 { limit, page, projectId, startTime, endTime } = ctx.query;
let options = {
where: {}
where: {},
include: [{
model: models.Project
}]
};
if (limit) {
options.limit = Number(limit);

20
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: '获取巡检报告失败' },
// });
// }
export function getPatrolReport (query) {
return dispatch => basicAction({
type: 'get',
query,
dispatch: dispatch,
actionType: 'GET_PATROL_REPORT',
url: ApiTable.patrolReport,
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 { 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) => <div>{record.project.name}</div>
}, {
title: '巡检报告名称',
dataIndex: 'groupName',
@ -23,17 +46,22 @@ function patrolReport(props) {
search: false,
width: 250,
render: (_, record) => {
return <div>{record?.checkItemsGroup?.name}</div>
const fileName = record?.excelPath?.substring(record?.excelPath?.lastIndexOf('/') + 1);
return <div>{fileName}</div>
}
}, {
title: '巡检日期',
dataIndex: 'date',
key: 'date',
valueType: 'dateRange',
fieldProps: {
value: date,
onChange: e => { setDate(e) }
},
ellipsis: true,
width: 150,
render: (_, record) => {
return <div>{record?.checkItemsGroup?.name}</div>
return <div>{moment(record?.inspectTm).format('YYYY-MM-DD')}</div>
}
}, {
title: '操作',
@ -44,10 +72,9 @@ function patrolReport(props) {
render: (_, record) => {
return <>
<Button type="link" onClick={() => {
const qnDomain = localStorage.getItem('qnDomain');
window.open(`https://view.officeapps.live.com/op/view.aspx?src=${qnDomain}${'/project/8fe38891-59c5-4735-b3d9-d8d335fc28ee/test.docx'}`)
window.open(`https://view.officeapps.live.com/op/view.aspx?src=${qnDomain}/${record?.excelPath}`)
}}>预览</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'
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);

3
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}',

Loading…
Cancel
Save