|
@ -1,6 +1,6 @@ |
|
|
import React, { useState, useRef, useEffect } from 'react'; |
|
|
import React, { useState, useRef, useEffect } from 'react'; |
|
|
import { connect } from 'react-redux'; |
|
|
import { connect } from 'react-redux'; |
|
|
import { Button, Tabs, Popconfirm, Tooltip,Spin } from 'antd'; |
|
|
import { Button, Tabs, Popconfirm, Tooltip, Spin } from 'antd'; |
|
|
import ProTable from '@ant-design/pro-table'; |
|
|
import ProTable from '@ant-design/pro-table'; |
|
|
import { getPatrolReport } from '../actions/report'; |
|
|
import { getPatrolReport } from '../actions/report'; |
|
|
import { getProjectList } from '../actions/plan'; |
|
|
import { getProjectList } from '../actions/plan'; |
|
@ -8,20 +8,20 @@ import moment from 'moment'; |
|
|
import AddReportRulesModal from '../components/addReportRulesModal'; |
|
|
import AddReportRulesModal from '../components/addReportRulesModal'; |
|
|
function patrolReport(props) { |
|
|
function patrolReport(props) { |
|
|
const { dispatch, actions } = props; |
|
|
const { dispatch, actions } = props; |
|
|
const { projectRegime, patrolManage } = actions |
|
|
const { projectRegime, patrolManage } = actions |
|
|
const tableRef = useRef(); |
|
|
const tableRef = useRef(); |
|
|
const tableRef2 = useRef(); |
|
|
const tableRef2 = useRef(); |
|
|
const [selectOpts, setSelectOpts] = useState([]); |
|
|
const [selectOpts, setSelectOpts] = useState([]); |
|
|
const [date, setDate] = useState([moment().subtract(1, 'days'), moment()]); |
|
|
const [date, setDate] = useState([moment().subtract(1, 'days'), moment()]); |
|
|
const [dataSource, setDataSource] = useState([]); |
|
|
const [dataSource, setDataSource] = useState([]); |
|
|
const [modalVis, setModalVis] = useState(false) |
|
|
const [modalVis, setModalVis] = useState(false) |
|
|
const [structAll,setStructAll]=useState([])//完整的结构物列表(包括subType)
|
|
|
const [structAll, setStructAll] = useState([])//完整的结构物列表(包括subType)
|
|
|
const [reportList, setReportList] = useState([])//报表
|
|
|
const [reportList, setReportList] = useState([])//报表
|
|
|
const qnDomain = localStorage.getItem('qnDomain'); |
|
|
const qnDomain = localStorage.getItem('qnDomain'); |
|
|
const [query, setQuery] = useState({ limit: 10, page: 0 }) |
|
|
const [query, setQuery] = useState({ limit: 10, page: 0 }) |
|
|
const [typeList, setTypeList] = useState([{ value: 1, label: '周报表' }, { value: 2, label: '月报表' }]) |
|
|
const [typeList, setTypeList] = useState([{ value: 1, label: '周报表' }, { value: 2, label: '月报表' }]) |
|
|
const [modalData, setModalData] = useState(null) |
|
|
const [modalData, setModalData] = useState(null) |
|
|
const [loading,setLoading]=useState(false) |
|
|
const [loading, setLoading] = useState(false) |
|
|
//报表配置
|
|
|
//报表配置
|
|
|
// const getReportConfig = (query) => {
|
|
|
// const getReportConfig = (query) => {
|
|
|
// const { limit, page, name } = query
|
|
|
// const { limit, page, name } = query
|
|
@ -72,26 +72,32 @@ function patrolReport(props) { |
|
|
} |
|
|
} |
|
|
}) |
|
|
}) |
|
|
} |
|
|
} |
|
|
const generateReport=(record)=>{ |
|
|
const generateReport = (record) => { |
|
|
setLoading(true) |
|
|
setLoading(true) |
|
|
let data={ |
|
|
let data = { |
|
|
reportName:record?.name, |
|
|
reportName: record?.name, |
|
|
startTime:moment(record?.startTime).format('YYYY-MM-DD HH:mm:ss'), |
|
|
startTime: moment(record?.startTime).format('YYYY-MM-DD HH:mm:ss'), |
|
|
endTime:moment(record?.endTime).format('YYYY-MM-DD HH:mm:ss'), |
|
|
endTime: moment(record?.endTime).format('YYYY-MM-DD HH:mm:ss'), |
|
|
structIds:record?.structure, |
|
|
structIds: record?.structure, |
|
|
structNames:structAll?.filter(item=>record?.structure.some(q=>q==item.id))?.map(o=>o.name)||[], |
|
|
structNames: structAll?.filter(item => record?.structure.some(q => q == item.id))?.map(o => o.name) || [], |
|
|
reportType:record?.type, |
|
|
reportType: record?.type, |
|
|
system:record?.system, |
|
|
system: record?.system, |
|
|
images:record?.reportpic.map(item=>qnDomain+'/'+item)||[] |
|
|
images: record?.reportpic.map(item => qnDomain + '/' + item) || [] |
|
|
} |
|
|
} |
|
|
dispatch(patrolManage.postGenerateReport(data)).then(res => { |
|
|
dispatch(patrolManage.postGenerateReport(data)).then(res => { |
|
|
if(res.success){ |
|
|
if (res.success) { |
|
|
setLoading(false) |
|
|
setLoading(false) |
|
|
tableRef.current.reload(); |
|
|
tableRef.current.reload(); |
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
}) |
|
|
}) |
|
|
} |
|
|
} |
|
|
|
|
|
//删除巡检记录
|
|
|
|
|
|
const delReport = (id) => { |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const columns = [{ |
|
|
const columns = [{ |
|
|
title: '结构物名称', |
|
|
title: '结构物名称', |
|
|
dataIndex: 'projectName', |
|
|
dataIndex: 'projectName', |
|
@ -104,13 +110,12 @@ function patrolReport(props) { |
|
|
}, |
|
|
}, |
|
|
ellipsis: true, |
|
|
ellipsis: true, |
|
|
width: 150, |
|
|
width: 150, |
|
|
render: (_, record) => |
|
|
render: (_, record) => { |
|
|
{ |
|
|
const rslt = structAll?.filter(p => record.structure?.some(q => q == p.id)) |
|
|
const rslt=structAll?.filter(p => record.structure?.some(q => q == p.id)) |
|
|
|
|
|
return <> |
|
|
return <> |
|
|
<div>{record?.project?record?.project?.name: record.structure?.length > 1 ? <Tooltip title={rslt?.map(item => item.name)?.join(',')}> |
|
|
<div>{record?.project ? record?.project?.name : record.structure?.length > 1 ? <Tooltip title={rslt?.map(item => item.name)?.join(',')}> |
|
|
<span>{rslt&&rslt.length?rslt[0].name+'...':''}</span> |
|
|
<span>{rslt && rslt.length ? rslt[0].name + '...' : ''}</span> |
|
|
</Tooltip> : rslt?.map(item => item.name)?.join(',') |
|
|
</Tooltip> : rslt?.map(item => item.name)?.join(',') |
|
|
}</div> |
|
|
}</div> |
|
|
|
|
|
|
|
|
</> |
|
|
</> |
|
@ -129,7 +134,7 @@ function patrolReport(props) { |
|
|
return <div>{fileName}</div> |
|
|
return <div>{fileName}</div> |
|
|
} |
|
|
} |
|
|
}, { |
|
|
}, { |
|
|
title: '巡检日期', |
|
|
title: '生成日期', |
|
|
dataIndex: 'date', |
|
|
dataIndex: 'date', |
|
|
key: 'date', |
|
|
key: 'date', |
|
|
valueType: 'dateRange', |
|
|
valueType: 'dateRange', |
|
@ -155,6 +160,19 @@ function patrolReport(props) { |
|
|
}}>预览</Button> |
|
|
}}>预览</Button> |
|
|
{/* onClick={() => { window.open() }} */} |
|
|
{/* onClick={() => { window.open() }} */} |
|
|
<a href={'/_file-server' + '/' + record?.excelPath}>下载</a> |
|
|
<a href={'/_file-server' + '/' + record?.excelPath}>下载</a> |
|
|
|
|
|
<Popconfirm |
|
|
|
|
|
placement='left' |
|
|
|
|
|
title={`确定删除?`} |
|
|
|
|
|
onConfirm={() => { |
|
|
|
|
|
dispatch(patrolManage.delpatrolRecord(record?.id)).then(res=>{ |
|
|
|
|
|
if(res.success){ |
|
|
|
|
|
tableRef.current.reload(); |
|
|
|
|
|
} |
|
|
|
|
|
}) |
|
|
|
|
|
}} |
|
|
|
|
|
> |
|
|
|
|
|
<Button type="link">删除</Button> |
|
|
|
|
|
</Popconfirm> |
|
|
</> |
|
|
</> |
|
|
}, |
|
|
}, |
|
|
}]; |
|
|
}]; |
|
@ -192,10 +210,10 @@ function patrolReport(props) { |
|
|
search: false, |
|
|
search: false, |
|
|
width: 250, |
|
|
width: 250, |
|
|
render: (_, record) => { |
|
|
render: (_, record) => { |
|
|
const rslt=structAll?.filter(p => record.structure?.some(q => q == p.id)) |
|
|
const rslt = structAll?.filter(p => record.structure?.some(q => q == p.id)) |
|
|
return <> |
|
|
return <> |
|
|
{record.structure.length > 1 ? <Tooltip title={rslt?.map(item => item.name)?.join(',')}> |
|
|
{record.structure.length > 1 ? <Tooltip title={rslt?.map(item => item.name)?.join(',')}> |
|
|
<span>{rslt&&rslt.length?rslt[0].name+'...':''}</span> |
|
|
<span>{rslt && rslt.length ? rslt[0].name + '...' : ''}</span> |
|
|
</Tooltip> : rslt?.map(item => item.name)?.join(',')} |
|
|
</Tooltip> : rslt?.map(item => item.name)?.join(',')} |
|
|
</> |
|
|
</> |
|
|
} |
|
|
} |
|
@ -220,7 +238,7 @@ function patrolReport(props) { |
|
|
width: 250, |
|
|
width: 250, |
|
|
render: (_, record) => { |
|
|
render: (_, record) => { |
|
|
return <> |
|
|
return <> |
|
|
{record.system?record.system===1?'动力系统':record.system===2?'网络系统':'--':'--'} |
|
|
{record.system ? record.system === 1 ? '动力系统' : record.system === 2 ? '网络系统' : '--' : '--'} |
|
|
</> |
|
|
</> |
|
|
} |
|
|
} |
|
|
}, |
|
|
}, |
|
@ -237,7 +255,7 @@ function patrolReport(props) { |
|
|
description="确定删除报表吗?" |
|
|
description="确定删除报表吗?" |
|
|
onConfirm={() => { confirmHandler(record?.id) }} |
|
|
onConfirm={() => { confirmHandler(record?.id) }} |
|
|
><Button type="primary" style={{ marginRight: 10 }} danger>删除</Button></Popconfirm> |
|
|
><Button type="primary" style={{ marginRight: 10 }} danger>删除</Button></Popconfirm> |
|
|
<Button type="primary" onClick={()=>{generateReport(record)}}>立即生成</Button> |
|
|
<Button type="primary" onClick={() => { generateReport(record) }}>立即生成</Button> |
|
|
</> |
|
|
</> |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
@ -300,41 +318,41 @@ function patrolReport(props) { |
|
|
key: '2', |
|
|
key: '2', |
|
|
children: <> |
|
|
children: <> |
|
|
<Spin spinning={loading}> |
|
|
<Spin spinning={loading}> |
|
|
<ProTable |
|
|
<ProTable |
|
|
|
|
|
|
|
|
actionRef={tableRef2} |
|
|
actionRef={tableRef2} |
|
|
options={false} |
|
|
options={false} |
|
|
columns={column2} |
|
|
columns={column2} |
|
|
dataSource={reportList || []} |
|
|
dataSource={reportList || []} |
|
|
pagination={{ pageSize: 10, size: 'default', className: 'global-pagination' }} |
|
|
pagination={{ pageSize: 10, size: 'default', className: 'global-pagination' }} |
|
|
request={async (query) => { |
|
|
request={async (query) => { |
|
|
const { limit, page, name } = query |
|
|
const { limit, page, name } = query |
|
|
const res = await dispatch(patrolManage.getReportList({ limit, page, name })) |
|
|
const res = await dispatch(patrolManage.getReportList({ limit, page, name })) |
|
|
const list = res?.payload?.data?.rows |
|
|
const list = res?.payload?.data?.rows |
|
|
setReportList(list) |
|
|
setReportList(list) |
|
|
return { |
|
|
return { |
|
|
...res, |
|
|
...res, |
|
|
total: res.payload.data.count ? res.payload.data.count : 0, |
|
|
total: res.payload.data.count ? res.payload.data.count : 0, |
|
|
}; |
|
|
}; |
|
|
}} |
|
|
}} |
|
|
// cardProps={{ title: '新建报表规则', bordered: true }}
|
|
|
// cardProps={{ title: '新建报表规则', bordered: true }}
|
|
|
headerTitle={ |
|
|
headerTitle={ |
|
|
<Button |
|
|
<Button |
|
|
key="primary" |
|
|
key="primary" |
|
|
type="primary" |
|
|
type="primary" |
|
|
onClick={() => { |
|
|
onClick={() => { |
|
|
setModalVis(true) |
|
|
setModalVis(true) |
|
|
}} |
|
|
}} |
|
|
> |
|
|
> |
|
|
新建报表规则 |
|
|
新建报表规则 |
|
|
</Button> |
|
|
</Button> |
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
rowKey="key" |
|
|
rowKey="key" |
|
|
search={true} |
|
|
search={true} |
|
|
/> |
|
|
/> |
|
|
</Spin> |
|
|
</Spin> |
|
|
<AddReportRulesModal structAll={structAll} typeList={typeList} modalData={modalData} onOk={onOk} visible={modalVis} cancelHandle={cancelHandle}> |
|
|
<AddReportRulesModal structAll={structAll} typeList={typeList} modalData={modalData} onOk={onOk} visible={modalVis} cancelHandle={cancelHandle}> |
|
|
|
|
|
|
|
|
</AddReportRulesModal> |
|
|
</AddReportRulesModal> |
|
|
</> |
|
|
</> |
|
|