From 4dab3a2d4b135cc69a49dc921218277fec9d2a3e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=B2=81=E8=AA=89=E7=A8=8B?= <2659568239@qq.com> Date: Fri, 15 Dec 2023 15:16:33 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/ClearInfoDialog/index.tsx | 40 +++++++ src/layouts/index.less | 7 +- src/layouts/index.tsx | 29 +++-- src/pages/CoreSystemEntrance/index.tsx | 10 +- .../GLQ/TeamViewer/ParamsSetting/index.tsx | 15 ++- src/pages/GLQ/WebMMJ/KeyDestruction/index.tsx | 68 +++++++++++- src/pages/GLQ/WebMMJ/KeyRemoteKill/index.tsx | 69 ++++++++++-- src/pages/GLQ/WebMMJ/MmjInitInstall/index.tsx | 105 ++++++++++++++---- src/pages/GLQ/WebMMJ/MmjRemoteKill/index.tsx | 72 ++++++++++-- src/pages/GLQ/WebMMJ/StatusQuery/index.tsx | 79 +++++++++++-- src/pages/GLQ/index.less | 3 +- .../InitialSystem/DeviceInstall/index.tsx | 10 +- src/pages/InitialSystem/PowerOnAuth/index.tsx | 6 +- src/pages/InitialSystem/index.less | 5 +- src/services/gql.ts | 33 ++++++ 15 files changed, 477 insertions(+), 74 deletions(-) create mode 100644 src/components/ClearInfoDialog/index.tsx create mode 100644 src/services/gql.ts diff --git a/src/components/ClearInfoDialog/index.tsx b/src/components/ClearInfoDialog/index.tsx new file mode 100644 index 0000000..e9539d6 --- /dev/null +++ b/src/components/ClearInfoDialog/index.tsx @@ -0,0 +1,40 @@ +import { FC } from 'react'; +import { Modal } from 'antd'; +import ButtonComp from '../ButtonComp'; + +interface PageProps { + title?: string; + visibility: boolean; + onCancel: () => void; + onOk: () => void; + children?: any; // 插槽内容 +} + +const ClearInfoDialog: FC = ({ + title = "提示框", + visibility = false, + onCancel, + onOk, + ...props +}) => { + + return ( + + {props?.children} +
+ + +
+
+ ) +} + +export default ClearInfoDialog \ No newline at end of file diff --git a/src/layouts/index.less b/src/layouts/index.less index 10159e4..b244c77 100644 --- a/src/layouts/index.less +++ b/src/layouts/index.less @@ -136,10 +136,9 @@ } .right_warp { - height: calc(100vh - 114px); - min-height: 600px; - - width: calc(100vw - 261px) + height: calc(100% - 114px); + min-height: calc(100vh - 114px); + width: calc(100% - 261px) } .right_route { diff --git a/src/layouts/index.tsx b/src/layouts/index.tsx index 7efe939..a6b6947 100644 --- a/src/layouts/index.tsx +++ b/src/layouts/index.tsx @@ -54,11 +54,13 @@ const leftMenuType: any = { } export default function Layout() { + const location = useLocation(); + const [routeName, setRouteName] = useState(''); + const [selectVal, setSelectVal] = useState(1); const [tabList, setTabList] = useState([]); const [active, setActive] = useState(1); const [activeName, setActiveName] = useState('GLQ远程维护'); - const [treeData, setTreeData] = useState([ { title: 'Parent 1', @@ -110,6 +112,10 @@ export default function Layout() { } }, []) + useEffect(() => { + setRouteName(getCurrentPageName(location.pathname)) + }, [location]); + // 页面销毁前记录下当前布局信息 window.addEventListener('beforeunload', function (event) { let layoutInfo: any = { @@ -125,7 +131,7 @@ export default function Layout() { if (tabList.length > 0 && !layoutInfo) { setActiveName(tabList[0].name) let info = MenuType[tabList[0].name]; - if(isTreeType(info)) return + if (isTreeType(info)) return if (info[0].data) { history.push(`${info[0].data[0].url}`) @@ -138,9 +144,9 @@ export default function Layout() { // 校验是否是树结构列表 const isTreeType = (info: any) => { if (info[0].name == '设备注册') { - for(let i=0; i 0) { - history.push(`/registerManage/deviceRegister/${treeData[i].children[0].key}`) + history.push(`/registerManage/deviceRegister/${treeData[i].children[0].key}`) break; } } @@ -148,6 +154,13 @@ export default function Layout() { } } + // 获取路由名称 + const getCurrentPageName = (pathname: string) => { + const routes = require('../../config/routes/index').default; + const currentRoute = routes.find((route: any) => route.path === pathname); + return currentRoute?.name || '未知页面'; + }; + return (
软件当前版本:0.0.0
当前用户:admin
-
当前操作:设备注册
+
当前操作:{routeName}
); -} +} \ No newline at end of file diff --git a/src/pages/CoreSystemEntrance/index.tsx b/src/pages/CoreSystemEntrance/index.tsx index 21104be..f5c8f98 100644 --- a/src/pages/CoreSystemEntrance/index.tsx +++ b/src/pages/CoreSystemEntrance/index.tsx @@ -1,7 +1,7 @@ import { FC, useEffect, useState } from 'react'; import { history, useLocation } from "umi"; import styles from './index.less'; -import { Input, Modal } from 'antd'; +import { Input, Modal, message } from 'antd'; import ButtonComp from '@/components/ButtonComp'; interface PageProps { } @@ -34,13 +34,15 @@ const CoreSystemEntrance: FC = ({ }) => { } const submit = () => { - if (key == '一') { + if (key == '一' && pin == '123123') { setKey('二'); setPin('') - } else { + } else if (key == '二' && pin == '123123') { initData() // 登录成功进入系统 history.push('/teamViewer/paramsSetting') + }else { + message.error('PIN码错误,请重新输入') } } @@ -56,7 +58,7 @@ const CoreSystemEntrance: FC = ({ }) => { {/* 登录弹窗 */} { - console.log('表单提交:', values); + setParameter({ + ipAddress: values.ipAddress + }).then((res) => { + if (res.result == 'success') { + message.success('连接成功') + }else { + message.success(res.errorMsg) + } + }) }; return ( @@ -37,7 +46,7 @@ export default function Page() {
- form.submit()} /> + form.submit()} /> form.resetFields()} />
diff --git a/src/pages/GLQ/WebMMJ/KeyDestruction/index.tsx b/src/pages/GLQ/WebMMJ/KeyDestruction/index.tsx index 78f02e8..40de81c 100644 --- a/src/pages/GLQ/WebMMJ/KeyDestruction/index.tsx +++ b/src/pages/GLQ/WebMMJ/KeyDestruction/index.tsx @@ -1,11 +1,51 @@ import ContentWarp from '@/components/ContentWarp'; import styles from '../../index.less'; import ButtonComp from '@/components/ButtonComp'; -import { useState } from 'react'; +import { useEffect, useRef, useState } from 'react'; +import { secretInit_sendCommand } from '@/services/gql'; +import ClearInfoDialog from '@/components/ClearInfoDialog'; // 网络MMJ管理 --> 密钥销毁 export default function Page() { - const [htmlText, setHtmlText] = useState('
文本内容
') + const [lines, setLines] = useState([]); + const [currentLineIndex, setCurrentLineIndex] = useState(0); + const [visibility, setVisibility] = useState(false); + const outputRef: any = useRef(null); + + useEffect(() => { + const timer = setInterval(() => { + if (currentLineIndex < lines.length) { + setCurrentLineIndex((prevIndex) => prevIndex + 1); + } else { + clearInterval(timer); + } + }, 300); + + if (outputRef.current.scrollHeight > 330) { + outputRef.current.scrollTop = outputRef.current.scrollHeight; + } + + return () => { + clearInterval(timer); // 组件卸载时清除定时器 + }; + }, [currentLineIndex, lines.length]); + + const sending = () => { + + secretInit_sendCommand({type: 1}).then((res) => { + if (res?.result == "success") { + setLines([ + ...lines, + '发送命令成功', + `执行密码销毁`, + `正在密码销毁中...`, + `密码销毁完成` + ]) + } else { + setLines([`${res?.errorMsg}`]) + } + }) + } return (
@@ -13,15 +53,31 @@ export default function Page() {
销毁被控端设备的安装密钥和分发密钥
-
-
+
+
+ {lines.slice(0, currentLineIndex).map((line: string, index: number) => ( +

{line}

+ ))} +
- { }} /> - setHtmlText('')} /> + sending()} /> + setVisibility(true)} />
+ + setVisibility(false)} + onOk={() => { + if (lines.length == 0) return; + setLines([]); + setCurrentLineIndex(0); + setVisibility(false); + }}> +
确定清空信息吗?
+
); } diff --git a/src/pages/GLQ/WebMMJ/KeyRemoteKill/index.tsx b/src/pages/GLQ/WebMMJ/KeyRemoteKill/index.tsx index 0b4db07..62cbb10 100644 --- a/src/pages/GLQ/WebMMJ/KeyRemoteKill/index.tsx +++ b/src/pages/GLQ/WebMMJ/KeyRemoteKill/index.tsx @@ -1,11 +1,51 @@ import ContentWarp from '@/components/ContentWarp'; import styles from '../../index.less'; import ButtonComp from '@/components/ButtonComp'; -import { useState } from 'react'; +import { useEffect, useRef, useState } from 'react'; +import { secretInit_sendCommand } from '@/services/gql'; +import ClearInfoDialog from '@/components/ClearInfoDialog'; // 网络MMJ管理 --> 密码遥毙 export default function Page() { - const [htmlText, setHtmlText] = useState('
文本内容
') + const [lines, setLines] = useState([]); + const [currentLineIndex, setCurrentLineIndex] = useState(0); + const [visibility, setVisibility] = useState(false); + const outputRef: any = useRef(null); + + useEffect(() => { + const timer = setInterval(() => { + if (currentLineIndex < lines.length) { + setCurrentLineIndex((prevIndex) => prevIndex + 1); + } else { + clearInterval(timer); + } + }, 300); + + if (outputRef.current.scrollHeight > 330) { + outputRef.current.scrollTop = outputRef.current.scrollHeight; + } + + return () => { + clearInterval(timer); // 组件卸载时清除定时器 + }; + }, [currentLineIndex, lines.length]); + + const sending = () => { + + secretInit_sendCommand({type: 2}).then((res) => { + if (res?.result == "success") { + setLines([ + ...lines, + '发送命令成功', + `执行密码遥毙`, + `正在密码遥毙中...`, + `密码遥毙完成` + ]) + } else { + setLines([`${res?.errorMsg}`]) + } + }) + } return (
@@ -13,16 +53,31 @@ export default function Page() {
销毁被控端设备的初装密钥、安装密钥及分发密钥
-
-
+
+
+ {lines.slice(0, currentLineIndex).map((line: string, index: number) => ( +

{line}

+ ))} +
- { }} /> - setHtmlText('')} /> + sending()} /> + setVisibility(true)} />
+ + setVisibility(false)} + onOk={() => { + if (lines.length == 0) return; + setLines([]); + setCurrentLineIndex(0); + setVisibility(false); + }}> +
确定清空信息吗?
+
); } - diff --git a/src/pages/GLQ/WebMMJ/MmjInitInstall/index.tsx b/src/pages/GLQ/WebMMJ/MmjInitInstall/index.tsx index 1a245a1..eda6ec0 100644 --- a/src/pages/GLQ/WebMMJ/MmjInitInstall/index.tsx +++ b/src/pages/GLQ/WebMMJ/MmjInitInstall/index.tsx @@ -1,18 +1,70 @@ import ContentWarp from '@/components/ContentWarp'; import styles from '../../index.less'; import styles1 from './index.less'; -import { Form, Input } from 'antd'; +import { Form, Input, Upload, UploadProps, message } from 'antd'; import ButtonComp from '@/components/ButtonComp'; +import { secretInit_cleanInfo, secretInit_loadData, secretInit_sendData } from '@/services/gql'; +import { useEffect, useState, } from 'react'; +import ClearInfoDialog from '@/components/ClearInfoDialog'; // 网络MMJ管理 --> MMJ初装 export default function Page() { - + const [dataLoading, setDataLoading] = useState(false); const [form] = Form.useForm(); + const [visibility, setVisibility] = useState(false); const onFinish = (values: any) => { console.log('表单提交:', values); }; + useEffect(() => { + let layoutInfo: any = localStorage.getItem('MMJInit'); + if (layoutInfo) { + form.setFieldsValue({...JSON.parse(layoutInfo)}) + } + }, []) + + const props: UploadProps = { + maxCount: 1, + beforeUpload: (file: any) => { + secretInit_loadData(file).then((res) => { + if (res?.result == "success" && res?.data.length > 0) { + message.success('加载数据成功'); + form.setFieldsValue({...res?.data[0]}) + localStorage.setItem('MMJInit', JSON.stringify(res?.data[0])); + setDataLoading(true); + } else { + message.error('加载数据失败'); + } + }) + } + }; + + const goData = () => { + if (!dataLoading) { + message.info('请先加载数据'); + return + } + secretInit_sendData({}).then((res) => { + if (res?.result == "success") { + message.success('发送数据成功'); + } else { + message.error('发送数据失败'); + } + }) + } + + const clearInfo = () => { + secretInit_cleanInfo({}).then((res) => { + if (res?.result == "success") { + message.success('清空信息成功'); + form.resetFields() + localStorage.removeItem('MMJInit'); + } else { + message.error('清空信息失败'); + } + }) + } return (
@@ -25,40 +77,53 @@ export default function Page() { onFinish={onFinish} > - + - + - +
- form.submit()} /> - { }} /> - form.resetFields()} /> + + + + { + goData() + }} /> + setVisibility(true)} />
+ + setVisibility(false)} + onOk={() => { + clearInfo() + }}> +
确定清空信息吗?
+
); } diff --git a/src/pages/GLQ/WebMMJ/MmjRemoteKill/index.tsx b/src/pages/GLQ/WebMMJ/MmjRemoteKill/index.tsx index 10b549a..7bfce0d 100644 --- a/src/pages/GLQ/WebMMJ/MmjRemoteKill/index.tsx +++ b/src/pages/GLQ/WebMMJ/MmjRemoteKill/index.tsx @@ -1,11 +1,51 @@ import ContentWarp from '@/components/ContentWarp'; import styles from '../../index.less'; import ButtonComp from '@/components/ButtonComp'; -import { useState } from 'react'; +import { useEffect, useRef, useState } from 'react'; +import { secretInit_sendCommand } from '@/services/gql'; +import ClearInfoDialog from '@/components/ClearInfoDialog'; -// 网络MMJ管理 --> MMJ遥毙 +// 网络MMJ管理 --> 密码机遥毙 export default function Page() { - const [htmlText, setHtmlText] = useState('
文本内容
') + const [lines, setLines] = useState([]); + const [currentLineIndex, setCurrentLineIndex] = useState(0); + const [visibility, setVisibility] = useState(false); + const outputRef: any = useRef(null); + + useEffect(() => { + const timer = setInterval(() => { + if (currentLineIndex < lines.length) { + setCurrentLineIndex((prevIndex) => prevIndex + 1); + } else { + clearInterval(timer); + } + }, 300); + + if (outputRef.current.scrollHeight > 330) { + outputRef.current.scrollTop = outputRef.current.scrollHeight; + } + + return () => { + clearInterval(timer); // 组件卸载时清除定时器 + }; + }, [currentLineIndex, lines.length]); + + const sending = () => { + + secretInit_sendCommand({type: 2}).then((res) => { + if (res?.result == "success") { + setLines([ + ...lines, + '发送命令成功', + `执行密码机遥毙`, + `正在密码机遥毙中...`, + `密码机遥毙完成` + ]) + } else { + setLines([`${res?.errorMsg}`]) + } + }) + } return (
@@ -13,16 +53,32 @@ export default function Page() {
销毁被控端设备的二次构造数据及全部密钥
-
-
+
+
+ {lines.slice(0, currentLineIndex).map((line: string, index: number) => ( +

{line}

+ ))} +
注意:执行此操作后,设备需返厂修复!
- { }} /> - setHtmlText('')} /> + sending()} /> + setVisibility(true)} />
+ + setVisibility(false)} + onOk={() => { + if (lines.length == 0) return; + setLines([]); + setCurrentLineIndex(0); + setVisibility(false); + }}> +
确定清空信息吗?
+
); -} \ No newline at end of file +} diff --git a/src/pages/GLQ/WebMMJ/StatusQuery/index.tsx b/src/pages/GLQ/WebMMJ/StatusQuery/index.tsx index e1a4dd4..7a59198 100644 --- a/src/pages/GLQ/WebMMJ/StatusQuery/index.tsx +++ b/src/pages/GLQ/WebMMJ/StatusQuery/index.tsx @@ -1,11 +1,58 @@ import ContentWarp from '@/components/ContentWarp'; import styles from '../../index.less'; import ButtonComp from '@/components/ButtonComp'; -import { useState } from 'react'; +import { useEffect, useRef, useState } from 'react'; +import { secretInit_getStatus } from '@/services/gql'; +import { message } from 'antd'; +import ClearInfoDialog from '@/components/ClearInfoDialog'; // 网络MMJ管理 --> 状态查询 export default function Page() { - const [htmlText, setHtmlText] = useState('
文本内容
') + const [lines, setLines] = useState([]); + const [currentLineIndex, setCurrentLineIndex] = useState(0); + const [visibility, setVisibility] = useState(false); + const outputRef: any = useRef(null); + + useEffect(() => { + const timer = setInterval(() => { + if (currentLineIndex < lines.length) { + setCurrentLineIndex((prevIndex) => prevIndex + 1); + } else { + clearInterval(timer); + } + }, 300); + + if (outputRef.current.scrollHeight > 330) { + outputRef.current.scrollTop = outputRef.current.scrollHeight; + } + + return () => { + clearInterval(timer); // 组件卸载时清除定时器 + }; + }, [currentLineIndex, lines.length]); + + const statusQuery = () => { + secretInit_getStatus({}).then((res) => { + if (res?.result == "success") { + let data = res?.data[0]; + setLines([ + ...lines, + `算法参数--${data?.algorithmParam}`, + `创建时间--${data?.createTime}`, + `导入文件名--${data?.fileName}`, + `未遥毙--${data?.mmjKill}`, + `参数自检码--${data?.paramCode}`, + `初装秘钥--${data?.passwordInit}`, + `秘钥数据状态--${data?.secretDataStatus}`, + `秘钥机未遥毙--${data?.secretKill}`, + `秘钥未销毁--${data?.secretRain}`, + `更新时间--${data?.updateTime}`, + ]) + } else { + setLines([`${res?.errorMsg}`]) + } + }) + } return (
@@ -13,16 +60,34 @@ export default function Page() {
隔离器所用密钥数据信息
-
-
+
+
+ {lines.slice(0, currentLineIndex).map((line: string, index: number) => ( +

{line}

+ ))} +
- { }} /> - { }} /> - setHtmlText('')} /> + { statusQuery() }} /> + { + message.info('该功能还在开发中!'); + }} /> + setVisibility(true)} />
+ + setVisibility(false)} + onOk={() => { + if (lines.length == 0) return; + setLines([]); + setCurrentLineIndex(0); + setVisibility(false); + }}> +
确定清空信息吗?
+
); } \ No newline at end of file diff --git a/src/pages/GLQ/index.less b/src/pages/GLQ/index.less index 743149f..ab1a135 100644 --- a/src/pages/GLQ/index.less +++ b/src/pages/GLQ/index.less @@ -28,6 +28,5 @@ border: 1px solid #E3E3E3; width: 100%; height: 330px; - overflow: hidden; - overflow-y: auto; + overflow-y: scroll; } \ No newline at end of file diff --git a/src/pages/InitialSystem/DeviceInstall/index.tsx b/src/pages/InitialSystem/DeviceInstall/index.tsx index 9314384..a3e5be6 100644 --- a/src/pages/InitialSystem/DeviceInstall/index.tsx +++ b/src/pages/InitialSystem/DeviceInstall/index.tsx @@ -23,6 +23,13 @@ const DeviceInstall: FC = ({ }) => { "dataInstalled": null }); + useEffect(() => { + let layoutInfo: any = localStorage.getItem('deviceInit'); + if (layoutInfo) { + setFileInfo(JSON.parse(layoutInfo)) + } + }, []) + const props: UploadProps = { maxCount: 1, @@ -31,6 +38,7 @@ const DeviceInstall: FC = ({ }) => { if (res?.result == "success" && res?.data.length > 0) { message.success('数据加载成功'); setFileInfo(res?.data[0]); + localStorage.setItem('deviceInit', JSON.stringify(res?.data[0])); setDataLoading(true); } else { message.error('数据加载失败'); @@ -63,7 +71,7 @@ const DeviceInstall: FC = ({ }) => { { if (!dataLoading) { - message.info('请先完成数据加载'); + message.info('请先数据加载'); return } diff --git a/src/pages/InitialSystem/PowerOnAuth/index.tsx b/src/pages/InitialSystem/PowerOnAuth/index.tsx index 99a654f..a64d5eb 100644 --- a/src/pages/InitialSystem/PowerOnAuth/index.tsx +++ b/src/pages/InitialSystem/PowerOnAuth/index.tsx @@ -28,7 +28,11 @@ const PowerOnAuth: FC = ({ }) => { useEffect(() => { college_table_query({}).then((res) => { if (res?.result == "success" && res?.data.length > 0) { - setVisibility(false); + let layoutInfo: any = localStorage.getItem('powerOn'); + if (!JSON.parse(layoutInfo).powerOn) { + setVisibility(true); + localStorage.setItem('powerOn', JSON.stringify({ powerOn: true })); + } setDeviceInfo(res?.data[0]); } else { message.error('开机认证失败'); diff --git a/src/pages/InitialSystem/index.less b/src/pages/InitialSystem/index.less index 68eaf5d..1f0ac20 100644 --- a/src/pages/InitialSystem/index.less +++ b/src/pages/InitialSystem/index.less @@ -48,9 +48,8 @@ } .right_warp { - height: calc(100vh - 58px); - min-height: 600px; - + height: calc(100% - 58px); + min-height: calc(100vh - 58px); width: calc(100vw - 261px); background: #F1F1F1; overflow: hidden; diff --git a/src/services/gql.ts b/src/services/gql.ts new file mode 100644 index 0000000..35481f5 --- /dev/null +++ b/src/services/gql.ts @@ -0,0 +1,33 @@ +import { getRequest, postRequest, uploadFile } from "@/utils/request"; + +// 参数设置 +export async function setParameter(data: any) { + return postRequest(`/xgd/parameterSet/setParameter`, data); +} + +// -----------------------------MMJ初装------------------------- +// 清空信息 +export async function secretInit_cleanInfo(params: any) { + return getRequest(`/xgd/secretInit/cleanInfo`, params); +} + +// 状态查询 +export async function secretInit_getStatus(params: any) { + return getRequest(`/xgd/secretInit/getStatus`, params); +} + +// 加载数据 +export async function secretInit_loadData(params: any) { + return uploadFile(`/xgd/secretInit/loadData`, params); +} + +// 发送命令 +// @param type 1 密销毁 2 密毙 密机遥毙 +export async function secretInit_sendCommand(params: any) { + return getRequest(`/xgd/secretInit/sendCommand`, params); +} + +// 发送数据 +export async function secretInit_sendData(params: any) { + return postRequest(`/xgd/secretInit/sendData`, params); +} \ No newline at end of file