import React, { useState, useEffect, useRef } from "react";
import { connect } from "react-redux";
import moment from "moment";
import { Button, Form, Table, Pagination, Skeleton, Popconfirm, Popover, Tag, } from "@douyinfe/semi-ui";
import { IconSort,IconCaretdown,IconCaretup } from '@douyinfe/semi-icons';
import "../style.less";
import {Setup} from "$components";
import ProgrammeModal from "../components/programmeModal";
import NotesModal from "../components/notesModal";
export const accessType = {
"yingshi": "萤石云",
"nvr": "NVR",
"ipc": "IPC",
"cascade": "级联"
};
const Statuscode = (props) => {
const { history, dispatch, actions, user, loading, StatusList } = props;
const { offline } = actions;
const [setup, setSetup] = useState(false);//表格设置弹框
const [programme, setProgramme] = useState(false);//方案弹框
const [notes, setNotes] = useState(false);//释义弹框
const [setupp, setSetupp] = useState([]);
const [query, setQuery] = useState({ limit: 10, page: 0 }); //页码信息
const [search, setearch] = useState({}); //搜索条件
const [rowId, setRowId] = useState(); //表格数据id
const api = useRef();
const searchData = useRef(search)
const page = useRef(query.page);
const CODE = "code";
const [nodesAll, setNodesAll] = useState(true);//是否批量
const [mysorter, setMysorter] = useState(true);//排序
const sorter = useRef(false);//排序
const [resolve, setResolve] = useState([]);//解决方案
const [tableNews, setTableNews] = useState([]);//表格当前行数据
const tableList = [//表格属性
{
title:'状态码信息',
list:[
{ name: "常规解决方案", value: "resolve" },
{ name: "状态频率", value: "logCount" },
]
},
];
useEffect(() => {
//初始化表格显示设置
attribute();
localStorage.getItem(CODE) == null
? localStorage.setItem(
CODE,
JSON.stringify(["resolve", "logCount"])
)
: "";
}, [sorter.current]);
useEffect(() => {
codegetStatus();
}, [query, search]);
const codegetStatus = () => {
searchData.current = { ...query, ...search }
dispatch(offline.getStatus(searchData.current)).then((res) => {
});
}
function banned(row){
dispatch(offline.putStatueBanned({statusId: row.id,forbidden: !row.forbidden,})).then(() => {
dispatch(offline.getStatus(searchData.current))
});
}
const columns = [
{
title: "状态码",
dataIndex: "status",
render: (_, record, index) => {
return record.status
},
},
{
title: "平台",
dataIndex: "platform",
render: (_, r, index) => {
let platform=r.platform
return accessType[platform]
},
},
{
title: "错误描述",
dataIndex: "describe",
render: (_, r, index) => {
return r.describe
},
},
{
title: "官方释义",
dataIndex: "paraphrase",
render: (_, r, index) => {
return r.paraphrase
},
},
{
title: "我的自定义释义",
dataIndex: "paraphraseCustom",
render: (_, r, index) => {
return r.paraphraseCustom
},
},
{
title: "操作",
width: "20%",
dataIndex: "",
render: (_, row) => {
return (
{row.forbidden ? (
) : (
banned(row)}
>
)}
);
},
},
];
function tosorter(){
setMysorter(false)
if(sorter.current=="descend"){
searchData.current = { ...query, ...search, orderDirection:'ASC',orderBy:'logCount'}
dispatch(offline.getStatus(searchData.current)).then((res) => {
sorter.current='ascend'
setMysorter('ascend')
});
}
else if(sorter.current=="ascend"){
searchData.current = { ...query, ...search}
dispatch(offline.getStatus(searchData.current)).then((res) => {
sorter.current=''
setMysorter('')
});
}
else{
searchData.current = { ...query, ...search, orderDirection:'DESC',orderBy:'logCount'}
dispatch(offline.getStatus(searchData.current)).then((res) => {
sorter.current='descend'
setMysorter('descend')
});
}
}
//获取表格属性设置
function attribute () {
const arr = localStorage.getItem(CODE)
? JSON.parse(localStorage.getItem(CODE))
: [];
const column = [
{
title: "常规解决方案",
dataIndex: "resolve",
key:'resolve',
render: (_, r, index) => {
let myresolve=''
if(r.resolve.length>0){
let myresolveList=[];
for (let index = 0; index < r.resolve.length; index++) {
if(r.resolve[index]&&r.resolve[index].resolve){
myresolveList.push(r.resolve[index].resolve)
}
}
myresolve=myresolveList.join(';');
}
return myresolve
},
},
{
title:(
状态频率(近30日)
{mysorter=='descend'?:mysorter=='ascend'?:}
),
dataIndex: "logCount",
key:'logCount',
render: (_, r, index) => {
return r.logCount
},
},
];
let mycolumns=columns
for (let i = 0; i < arr.length; i++) {
let colum = column.filter((item) => {
return item.key === arr[i];
});
mycolumns.splice(i + 5, 0, colum[0]);
}
setSetupp(mycolumns);
}
//条件赛选样式
const screen = {
width: 193,
marginRight: 20,
marginBottom: 16,
color: "rgba(0, 0, 0, 0.65)",
};
return (
<>
状态码管理
系统支持状态码显示内容的释义修改,当设备异常时,会为您显示自定义释义内容。
筛选条件
全部
启用
禁用
全部
已设置
未设置
状态码详情
s)}
dataSource={StatusList.rows}
bordered={false}
empty="暂无数据"
style={{
padding: "0px 20px",
}}
pagination={false}
/>
共{StatusList.count}个状态码
{
setQuery({ limit: pageSize, page: currentPage - 1 });
page.current = currentPage - 1
}}
/>
{setup ? (
{
setSetup(false);
attribute();
}}
/>
) : (
""
)}
{programme&& {
setProgramme(false);
setRowId();
codegetStatus();
}}
/>}
{notes&& {
setNotes(false);
setRowId();
codegetStatus();
}}
/>}
>
);
};
function mapStateToProps (state) {
const { auth, global, members, StatusList } = state;
return {
loading: StatusList.isRequesting && !StatusList.data,
user: auth.user,
actions: global.actions,
members: members.data,
StatusList: StatusList.data || {},
};
}
export default connect(mapStateToProps)(Statuscode);