|
@ -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); |
|
|