|
|
@ -3,8 +3,9 @@ |
|
|
|
|
|
|
|
import React, { useEffect, useState } from 'react'; |
|
|
|
import { connect } from 'react-redux'; |
|
|
|
import { Form, Input, Select, Button, Table, Modal, DatePicker, Checkbox, Row, Col, Collapse } from 'antd'; |
|
|
|
import { Form, Input, Select, Button, Table, Modal, DatePicker, message, Row, Col, Collapse, Popconfirm } from 'antd'; |
|
|
|
import moment from "moment"; |
|
|
|
import XLSX from 'xlsx'; |
|
|
|
import Uploads from '$components/Uploads'; |
|
|
|
import '../style.less' |
|
|
|
|
|
|
@ -20,6 +21,7 @@ const PatrolRecord = (props) => { |
|
|
|
const [limits, setLimits] = useState() |
|
|
|
const format = 'YYYY-MM-DD HH:mm:ss' |
|
|
|
const [search, setSearch] = useState({ name: null, time: [moment().add(-7, 'd').format(format), moment().format(format)], state: 'null' }) |
|
|
|
const [exportLoading, setExportLoading] = useState(false) |
|
|
|
|
|
|
|
useEffect(() => { |
|
|
|
record(search) |
|
|
@ -36,6 +38,34 @@ const PatrolRecord = (props) => { |
|
|
|
}) |
|
|
|
} |
|
|
|
|
|
|
|
const exportRecord = () => { |
|
|
|
if (tableList.length === 0) { |
|
|
|
message.warning('没有数据可以导出') |
|
|
|
return |
|
|
|
} |
|
|
|
setExportLoading(true) |
|
|
|
const workbook = XLSX.utils.book_new(); // 新建工作簿
|
|
|
|
let data = [['结构物名称', '巡检计划', '巡检点位', '巡检人', '巡检单位', '巡检频次', '上次巡检日期', '本次巡检日期', '巡检结果']]; |
|
|
|
for (const item of tableList) { |
|
|
|
data.push([ |
|
|
|
item.points?.project?.name || '--', |
|
|
|
item.patrolPlan?.name || '--', |
|
|
|
item.points?.itemData?.name || '--', |
|
|
|
item.points?.user?.name || '--', |
|
|
|
item.points?.user?.department?.name || '--', |
|
|
|
item.points?.frequency || '--', |
|
|
|
item.lastInspectionTime ? moment(item.lastInspectionTime).format('YYYY-MM-DD HH:mm:ss') : '--', |
|
|
|
moment(item.inspectionTime).format('YYYY-MM-DD HH:mm:ss'), |
|
|
|
!item.alarm ? '正常' : '异常', |
|
|
|
]) |
|
|
|
} |
|
|
|
const worksheet = XLSX.utils.aoa_to_sheet(data); // 从二维数组新建工作表
|
|
|
|
XLSX.utils.book_append_sheet(workbook, worksheet, "sheet1"); // 将工作表添加到工作簿
|
|
|
|
XLSX.writeFile(workbook, '巡检记录.xlsx'); // 将工作簿数据建立为./xlsx文件(浏览器环境下会直接下载)
|
|
|
|
message.success('导出成功') |
|
|
|
setExportLoading(false) |
|
|
|
} |
|
|
|
|
|
|
|
const columns = [{ |
|
|
|
title: '结构物名称', |
|
|
|
dataIndex: 'name', |
|
|
@ -163,9 +193,8 @@ const PatrolRecord = (props) => { |
|
|
|
{ value: true, label: '异常' }]} /> |
|
|
|
</Form.Item> |
|
|
|
<Form.Item wrapperCol={{}}> |
|
|
|
<Button type="primary" htmlType="submit"> |
|
|
|
搜索 |
|
|
|
</Button> |
|
|
|
<Button type="primary" htmlType="submit" style={{ marginRight: 16 }}>搜索</Button> |
|
|
|
<Button type="primary" onClick={exportRecord} loading={exportLoading}>导出</Button> |
|
|
|
</Form.Item> |
|
|
|
</Form> |
|
|
|
</div> |
|
|
|