import React, { useState, useEffect, useRef } from "react"; import { connect } from "react-redux"; import moment from "moment"; import { Button, Form, Table, Pagination, Skeleton, Popconfirm, SideSheet, Tag, } from "@douyinfe/semi-ui"; import "../style.less"; import { ApiTable } from "$utils"; import { Setup } from "$components"; import PushModal from "../components/pushModal"; import PushSideSheet from "../components/pushSideSheet"; // import SideSheets from "../components/sideSheet"; export const accessType = [ { name: "萤石云", key: "yingshi" }, { name: "NVR", key: "nvr" }, { name: "IPC", key: "ipc" }, { name: "级联", key: "cascade" }, ]; const Carrierpigeon = (props) => { const { history, dispatch, actions, user, loading, StatusPushList } = props; const { offline } = actions; const [setup, setSetup] = useState(false); const [setupp, setSetupp] = useState([]); const [query, setQuery] = useState({ limit: 10, page: 0 }); //页码信息 const [search, setearch] = useState({}); //搜索条件 const [rowId, setRowId] = useState(); //表格数据id const [pigeonPush, setPigeonPush] = useState(false); //推送弹框 const [pushTitle, setPushTitle] = useState(''); //提醒弹框 const api = useRef(); const searchData = useRef(search) const limits = useRef(); //每页实际条数 const page = useRef(query.page); const PIGEON = "pigeon"; const cameraList = useRef([]);//第三阶段监听范围摄像头列表 const [sideSheetVisible, setSideSheetVisible] = useState(false); const [pushData, setPushData] = useState({}); const [journal, setJournal] = useState([]); const tableList = [//表格属性 { title: '推送信息', list: [ { name: "策略类型", value: "pushWay" }, { name: "推送机制", value: "noticeWay" }, { name: "监听设备数量", value: "logCount" }, { name: "累计推送次数", value: "monitorCount" }, ] }, ]; const noticeWayObj = { 'offline':'离线及时通知', 'online':'上线及时通知', 'timing':'定时统计', } useEffect(() => { attribute(); dispatch(offline.getCameraListAll()).then((res) => {//第三步 let mycameraList = res.payload.data for (let index = 0; index < mycameraList.length; index++) { mycameraList[index].label=mycameraList[index].name mycameraList[index].key=index+1 mycameraList[index].value=String(mycameraList[index].id) if(mycameraList[index].type=='cascade'){ mycameraList[index].color='#808FD3' mycameraList[index].abbr='级联' } else if(mycameraList[index].type=='nvr'){ mycameraList[index].color='#F6D86F' mycameraList[index].abbr='NVR' } else if(mycameraList[index].type=='ipc'){ mycameraList[index].color='#1859C1' mycameraList[index].abbr='IPC' } else{ mycameraList[index].color='#57CBD3' mycameraList[index].abbr='莹石' } } cameraList.current=mycameraList }); //初始化表格显示设置 localStorage.getItem(PIGEON) == null ? localStorage.setItem( PIGEON, JSON.stringify(['pushWay','noticeWay','logCount','monitorCount']) ) : ""; }, []); useEffect(() => { equipmentGetStatusPush(); }, [query, search]); const equipmentGetStatusPush = () => { searchData.current = { ...query, ...search } dispatch(offline.getStatusPush(searchData.current)).then((res) => { limits.current = res.payload.data.length }); } const columns = [ { title: "序号", render: (_, record, index) => { return index + 1; }, }, { title: "策略名称", dataIndex: "name", render: (_, r, index) => { return r.name }, }, { title: "操作", width: "20%", dataIndex: "", render: (_, row) => { return (
{row.forbidden ? ( ) : ( { dispatch( offline.putPushBanned( { configId: row.id, forbidden: !row.forbidden, }, row.forbidden ) ).then(() => { equipmentGetStatusPush(); }); }} > )} { dispatch(offline.delPush(row.id)).then(() => { if (page.current > 0 && limits.current < 2) { setQuery({ limit: 10, page: page.current - 1 }) } else { setQuery({ limit: 10, page: page.current }) } }); }} >
); }, }, ]; //获取表格属性设置 function attribute () { const arr = localStorage.getItem(PIGEON) ? JSON.parse(localStorage.getItem(PIGEON)) : []; const column = [ { title: "推送机制", dataIndex: "noticeWay", key: "noticeWay", render: (_, r, index) => { let noticeWayValue=[] for (let index = 0; index < r.noticeWay.length; index++) { let val = r.noticeWay[index] noticeWayValue.push(noticeWayObj[val]) } let noticeWayString=noticeWayValue.join(';') return noticeWayString; }, }, { title: "监听设备数量", dataIndex: "logCount", key: "logCount", render: (_, r, index) => { return r.logCount }, }, { title: "累计推送次数", dataIndex: "monitorCount", key: "monitorCount", render: (_, r, index) => { return (r.monitorCount + '次') }, }, { title: "策略类型", dataIndex: "pushWay", key: "pushWay", render: (_, r, index) => { return r.pushWay=='email' ? '邮件通知' : '短信通知'; }, }, ]; for (let i = 0; i < arr.length; i++) { let colum = column.filter((item) => { return item.key === arr[i]; }); columns.splice(i + 2, 0, colum[0]); } setSetupp(columns); } //条件赛选样式 const screen = { width: 193, marginRight: 20, marginBottom: 16, color: "rgba(0, 0, 0, 0.65)", }; return ( <>
筛选条件
console.log(values)} // onValueChange={values=>console.log(values)} getFormApi={(formApi) => (api.current = formApi)} layout="horizontal" style={{ position: "relative", width: "100%", flex: 1 }} > 全部 短信通知 邮件通知
策略详情
s)} dataSource={StatusPushList.rows} bordered={false} empty="暂无数据" style={{ padding: "0px 20px", }} pagination={false} />
共{StatusPushList.count}条策略 { setQuery({ limit: pageSize, page: currentPage - 1 }); page.current = currentPage - 1 }} />
{setup ? ( { setSetup(false); attribute(); }} /> ) : ( "" )} {pigeonPush&& { setPigeonPush(false); setRowId(); setPushData({}) equipmentGetStatusPush(); }} />} {sideSheetVisible&& { setSideSheetVisible(false); setPushData({}) }} />} ); }; function mapStateToProps (state) { const { auth, global, members, StatusPushList } = state; return { loading: StatusPushList.isRequesting && !StatusPushList.data, user: auth.user, actions: global.actions, members: members.data, StatusPushList: StatusPushList.data || {}, }; } export default connect(mapStateToProps)(Carrierpigeon);