|
@ -1,6 +1,6 @@ |
|
|
import React, { useState, useEffect, useRef } from "react"; |
|
|
import React, { useState, useEffect, useRef } from "react"; |
|
|
import { connect } from "react-redux"; |
|
|
import { connect } from "react-redux"; |
|
|
import { Button, Form, Modal, Skeleton, Pagination, Table } from "@douyinfe/semi-ui"; |
|
|
import { Button, Form, Modal, Skeleton, Pagination, Table, Tooltip, Toast } from "@douyinfe/semi-ui"; |
|
|
import { SkeletonScreen, } from "$components"; |
|
|
import { SkeletonScreen, } from "$components"; |
|
|
import moment from "moment"; |
|
|
import moment from "moment"; |
|
|
import { validate } from "schema-utils"; |
|
|
import { validate } from "schema-utils"; |
|
@ -10,14 +10,14 @@ import qs from "qs"; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const TableData = ({ route, dispatch, actions, collectData, setSetup, exhibition, pepProjectId, |
|
|
const TableData = ({ route, dispatch, actions, collectData, setSetup, exhibition, pepProjectId, |
|
|
selected, setSelected, setIfBulk, setConfirm, genre, setGenre, query, setQuery, tableData, setTableData, location, user }) => { |
|
|
selected, setSelected, setIfBulk, setConfirm, genre, setGenre, query, setQuery, tableData, setTableData, location, user, statusId, setStatusId }) => { |
|
|
const { problem } = actions |
|
|
const { problem } = actions |
|
|
|
|
|
|
|
|
const [count, setCount] = useState(0) // |
|
|
const [count, setCount] = useState(0) // |
|
|
const [checkAll, setCheckAll] = useState(true) //查询 |
|
|
const [checkAll, setCheckAll] = useState(true) //查询 |
|
|
const api = useRef(); |
|
|
const api = useRef(); |
|
|
const search = useRef({ |
|
|
const search = useRef({ |
|
|
state: '', keywordTarget: '', keyword: '', kindId: '', groupUnitId: '', |
|
|
state: '', keywordTarget: '', keyword: '', kindId: '', groupUnitId: '', statusId: '', |
|
|
errType: '', confirmState: '', onlineState: '', sustainTimeStart: '', sustainTimeEnd: '' |
|
|
errType: '', confirmState: '', onlineState: '', sustainTimeStart: '', sustainTimeEnd: '' |
|
|
}) |
|
|
}) |
|
|
const kindName = useRef() |
|
|
const kindName = useRef() |
|
@ -122,7 +122,7 @@ const TableData = ({ route, dispatch, actions, collectData, setSetup, exhibition |
|
|
useEffect(() => { |
|
|
useEffect(() => { |
|
|
if (location) { |
|
|
if (location) { |
|
|
search.current = { ...search.current, ...location, state: 'new' } |
|
|
search.current = { ...search.current, ...location, state: 'new' } |
|
|
api.current?.setValues({...location, state: 'new'}) |
|
|
api.current?.setValues({ ...location, state: 'new' }) |
|
|
} |
|
|
} |
|
|
if (route !== 'videoAbnormal' && route !== 'useAbnormal') { |
|
|
if (route !== 'videoAbnormal' && route !== 'useAbnormal') { |
|
|
dispatch(problem.getAlarmDataGroup()).then((res) => { |
|
|
dispatch(problem.getAlarmDataGroup()).then((res) => { |
|
@ -153,23 +153,68 @@ const TableData = ({ route, dispatch, actions, collectData, setSetup, exhibition |
|
|
setGenre(res.payload.data.map(v => ({ name: v.kind, value: v.id }))) |
|
|
setGenre(res.payload.data.map(v => ({ name: v.kind, value: v.id }))) |
|
|
} |
|
|
} |
|
|
}) |
|
|
}) |
|
|
|
|
|
dispatch(problem.getAlarmVideoExceptionType()).then((res) => { |
|
|
|
|
|
if (res.success) { |
|
|
|
|
|
setStatusId(res.payload.data.map(v => ({ name: v.describe, value: v.statusId }))) |
|
|
|
|
|
} |
|
|
|
|
|
}) |
|
|
} |
|
|
} |
|
|
}, []) |
|
|
}, []) |
|
|
|
|
|
|
|
|
const handleExport = () => { |
|
|
const handleExport = () => { |
|
|
let url = '' |
|
|
let url = '' |
|
|
let { keywordTarget, keyword = '', errType = '', state = '', kindId = '', groupUnitId = '', confirmState = '', onlineState = '', sustainTimeStart = '', sustainTimeEnd = '' } = search.current |
|
|
let { keywordTarget, keyword = '', errType = '', state = '', kindId = '', statusId = '', groupUnitId = '', confirmState = '', onlineState = '', sustainTimeStart = '', sustainTimeEnd = '' } = search.current |
|
|
|
|
|
if (sustainTimeStart && sustainTimeEnd) { |
|
|
|
|
|
let range = moment(sustainTimeEnd).diff(moment(sustainTimeStart), 'minutes') |
|
|
|
|
|
if (range > 24 * 60 * 7) { |
|
|
|
|
|
Toast.warning({ |
|
|
|
|
|
content: '导出自定义时间跨度不超过7天', |
|
|
|
|
|
duration: 3, |
|
|
|
|
|
}) |
|
|
|
|
|
return false; |
|
|
|
|
|
} |
|
|
|
|
|
} else { |
|
|
|
|
|
sustainTimeStart = moment().add(-7, 'day').format("YYYY-MM-DD HH:mm:ss") |
|
|
|
|
|
sustainTimeEnd = moment().format("YYYY-MM-DD HH:mm:ss") |
|
|
|
|
|
} |
|
|
switch (route) { |
|
|
switch (route) { |
|
|
case 'useAbnormal': |
|
|
case 'useAbnormal': |
|
|
|
|
|
dispatch(problem.getAlarmLnspectionApi({ ...search.current, limit: 1, sustainTimeStart, sustainTimeEnd, pepProjectId: pepProjectId })).then((res) => { |
|
|
|
|
|
if (res.success) { |
|
|
|
|
|
if (res.payload.data.count) { |
|
|
url = `alarm/application/api?token=${user.token}&toExport=1×tamp=${moment().valueOf()}&keyword=${keyword}&errType=${errType} |
|
|
url = `alarm/application/api?token=${user.token}&toExport=1×tamp=${moment().valueOf()}&keyword=${keyword}&errType=${errType} |
|
|
&state=${state}stainTimeStart=${sustainTimeStart}&sustainTimeEnd=${sustainTimeEnd}&pepProjectId=${pepProjectId || ''}` |
|
|
&state=${state}stainTimeStart=${sustainTimeStart}&sustainTimeEnd=${sustainTimeEnd}&pepProjectId=${pepProjectId || ''}` |
|
|
|
|
|
setExportUrl(url); |
|
|
|
|
|
} else { |
|
|
|
|
|
Toast.info({ |
|
|
|
|
|
content: '暂无可导出的数据', |
|
|
|
|
|
duration: 3, |
|
|
|
|
|
}) |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
}) |
|
|
break; |
|
|
break; |
|
|
case 'videoAbnormal': |
|
|
case 'videoAbnormal': |
|
|
|
|
|
dispatch(problem.getAlarmVideoList({ ...search.current, limit: 1, sustainTimeStart, sustainTimeEnd, pepProjectId: pepProjectId })).then((res) => { |
|
|
|
|
|
if (res.success) { |
|
|
|
|
|
if (res.payload.data.count) { |
|
|
url = `alarm/video/list?token=${user.token}&toExport=1×tamp=${moment().valueOf()}&keywordTarget=${keywordTarget} |
|
|
url = `alarm/video/list?token=${user.token}&toExport=1×tamp=${moment().valueOf()}&keywordTarget=${keywordTarget} |
|
|
&keyword=${keyword}&kindId=${kindId}&state=${state}&sustainTimeStart=${sustainTimeStart}&sustainTimeEnd=${sustainTimeEnd} |
|
|
&keyword=${keyword}&kindId=${kindId}&statusId=${statusId}&state=${state}&sustainTimeStart=${sustainTimeStart}&sustainTimeEnd=${sustainTimeEnd} |
|
|
&pepProjectId=${pepProjectId || ''}` |
|
|
&pepProjectId=${pepProjectId || ''}` |
|
|
|
|
|
setExportUrl(url); |
|
|
|
|
|
} else { |
|
|
|
|
|
Toast.info({ |
|
|
|
|
|
content: '暂无可导出的数据', |
|
|
|
|
|
duration: 3, |
|
|
|
|
|
}) |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
}) |
|
|
break; |
|
|
break; |
|
|
default: |
|
|
default: |
|
|
|
|
|
dispatch(problem.getAlarmDataList({ ...query, ...search.current, limit: 1, sustainTimeStart, sustainTimeEnd, groupId: groupId.current.map(v => v.id).join(), pepProjectId: pepProjectId })).then((res) => { |
|
|
|
|
|
if (res.success) { |
|
|
|
|
|
if (res.payload.data.count) { |
|
|
let groups = { |
|
|
let groups = { |
|
|
"dataLnterrupt": "1", |
|
|
"dataLnterrupt": "1", |
|
|
"dataAbnormal": "2", |
|
|
"dataAbnormal": "2", |
|
@ -179,9 +224,17 @@ const TableData = ({ route, dispatch, actions, collectData, setSetup, exhibition |
|
|
url = `alarm/data/list?token=${user.token}&toExport=1×tamp=${moment().valueOf()}&state=${state}&keywordTarget=${keywordTarget}&keyword=${keyword}&kindId=${kindId} |
|
|
url = `alarm/data/list?token=${user.token}&toExport=1×tamp=${moment().valueOf()}&state=${state}&keywordTarget=${keywordTarget}&keyword=${keyword}&kindId=${kindId} |
|
|
&groupUnitId=${groupUnitId}&errType=${errType}&confirmState=${confirmState}&onlineState=${onlineState}&sustainTimeStart=${sustainTimeStart} |
|
|
&groupUnitId=${groupUnitId}&errType=${errType}&confirmState=${confirmState}&onlineState=${onlineState}&sustainTimeStart=${sustainTimeStart} |
|
|
&sustainTimeEnd=${sustainTimeEnd}&pepProjectId=${pepProjectId || ''}&groupId=${groups[route]}` |
|
|
&sustainTimeEnd=${sustainTimeEnd}&pepProjectId=${pepProjectId || ''}&groupId=${groups[route]}` |
|
|
|
|
|
setExportUrl(url); |
|
|
|
|
|
} else { |
|
|
|
|
|
Toast.info({ |
|
|
|
|
|
content: '暂无可导出的数据', |
|
|
|
|
|
duration: 3, |
|
|
|
|
|
}) |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
}) |
|
|
break; |
|
|
break; |
|
|
} |
|
|
} |
|
|
setExportUrl(url); |
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
return ( |
|
|
return ( |
|
@ -269,7 +322,8 @@ const TableData = ({ route, dispatch, actions, collectData, setSetup, exhibition |
|
|
marginBottom: 16 |
|
|
marginBottom: 16 |
|
|
}} |
|
|
}} |
|
|
> |
|
|
> |
|
|
<img title='导出' src="/assets/images/problem/export.png" style={{ width: 20 }} |
|
|
<Tooltip content={'默认导出最近7天的数据,自定义时间跨度不超过7天'}> |
|
|
|
|
|
<img title='导出' src="/assets/images/problem/export.png" style={{ width: 20, cursor: 'pointer' }} |
|
|
onClick={() => { |
|
|
onClick={() => { |
|
|
api.current.validate().then((v) => { |
|
|
api.current.validate().then((v) => { |
|
|
search.current = { |
|
|
search.current = { |
|
@ -277,6 +331,7 @@ const TableData = ({ route, dispatch, actions, collectData, setSetup, exhibition |
|
|
keywordTarget: v.keywordTarget, |
|
|
keywordTarget: v.keywordTarget, |
|
|
keyword: v.keyword, |
|
|
keyword: v.keyword, |
|
|
kindId: v.kindId, |
|
|
kindId: v.kindId, |
|
|
|
|
|
statusId: v.statusId, |
|
|
groupUnitId: v.groupUnitId, |
|
|
groupUnitId: v.groupUnitId, |
|
|
errType: v.errType, |
|
|
errType: v.errType, |
|
|
confirmState: v.confirmState, |
|
|
confirmState: v.confirmState, |
|
@ -287,7 +342,8 @@ const TableData = ({ route, dispatch, actions, collectData, setSetup, exhibition |
|
|
handleExport(); |
|
|
handleExport(); |
|
|
}); |
|
|
}); |
|
|
}} /> |
|
|
}} /> |
|
|
<img title='设置' src="/assets/images/problem/setup.png" style={{ width: 20 }} onClick={() => setSetup(true)} /> |
|
|
</Tooltip> |
|
|
|
|
|
<img title='设置' src="/assets/images/problem/setup.png" style={{ width: 20, cursor: 'pointer' }} onClick={() => setSetup(true)} /> |
|
|
<Button |
|
|
<Button |
|
|
theme="solid" |
|
|
theme="solid" |
|
|
type="primary" |
|
|
type="primary" |
|
@ -299,6 +355,7 @@ const TableData = ({ route, dispatch, actions, collectData, setSetup, exhibition |
|
|
keywordTarget: v.keywordTarget, |
|
|
keywordTarget: v.keywordTarget, |
|
|
keyword: v.keyword, |
|
|
keyword: v.keyword, |
|
|
kindId: v.kindId, |
|
|
kindId: v.kindId, |
|
|
|
|
|
statusId: v.statusId, |
|
|
groupUnitId: v.groupUnitId, |
|
|
groupUnitId: v.groupUnitId, |
|
|
errType: v.errType, |
|
|
errType: v.errType, |
|
|
confirmState: v.confirmState, |
|
|
confirmState: v.confirmState, |
|
@ -415,7 +472,7 @@ const TableData = ({ route, dispatch, actions, collectData, setSetup, exhibition |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function mapStateToProps (state) { |
|
|
function mapStateToProps(state) { |
|
|
const { auth, global, members } = state; |
|
|
const { auth, global, members } = state; |
|
|
// console.log(global); |
|
|
// console.log(global); |
|
|
return { |
|
|
return { |
|
|