From f4efacf553dafa48a74a273311e7eaeb2bde776a Mon Sep 17 00:00:00 2001 From: lishenfeng Date: Thu, 20 Feb 2025 17:54:01 +0800 Subject: [PATCH] =?UTF-8?q?feat():=20=E6=B5=8B=E7=AB=99=E5=88=B0=E6=8A=A5?= =?UTF-8?q?=E7=8E=87=E8=A1=A8=E6=A0=BC=E4=B8=8E=E6=A0=91=E5=BD=A2=E8=81=94?= =?UTF-8?q?=E5=8A=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/views/Ptjs/Czdbl/dblOption.js | 14 +++++++--- src/views/Ptjs/Czdbl/index.js | 45 +++++++++++++++++++++++++++---- src/views/Ptjs/Czdbl/index.less | 3 +++ src/views/Ptjs/Czdbl/toolbar.js | 4 +-- src/views/Ptjs/Lssj/index.js | 18 ++++++------- src/views/Ptjs/Lssj/qsOption.js | 4 +-- src/views/Ptjs/Lssj/toolbar.js | 9 ++++--- src/views/Ptjs/Sssj/Cpu.js | 12 ++++----- src/views/Ptjs/Sssj/Memory.js | 40 ++++++++++++++++++--------- 9 files changed, 106 insertions(+), 43 deletions(-) create mode 100644 src/views/Ptjs/Czdbl/index.less diff --git a/src/views/Ptjs/Czdbl/dblOption.js b/src/views/Ptjs/Czdbl/dblOption.js index 42fdba2..3ee5453 100644 --- a/src/views/Ptjs/Czdbl/dblOption.js +++ b/src/views/Ptjs/Czdbl/dblOption.js @@ -1,4 +1,12 @@ -export default function dblOption(sellist,selday) { +export default function dblOption(sellist, selday) { + const copySellist = JSON.parse(JSON.stringify(sellist)); + copySellist.sort(function (o1, o2) { + if (o1[selday]?.rate > o2[selday]?.rate) { + return 1; + } else { + return -1; + } + }); let itemStyle = { normal: { label: { @@ -18,8 +26,8 @@ export default function dblOption(sellist,selday) { }; const yAxisData = []; - for (let si = 0; si < sellist.length; si++) { - let obj = sellist[si]; + for (let si = 0; si < copySellist.length; si++) { + let obj = copySellist[si]; yAxisData.push(obj.adnm); serdata.data.push(parseFloat((obj[selday]?.rate * 100).toFixed(2))); } diff --git a/src/views/Ptjs/Czdbl/index.js b/src/views/Ptjs/Czdbl/index.js index 01b96a1..24ccbf2 100644 --- a/src/views/Ptjs/Czdbl/index.js +++ b/src/views/Ptjs/Czdbl/index.js @@ -10,6 +10,7 @@ import ReactEcharts from 'echarts-for-react'; import qsOption from './qsOption.js' import dblOption from './dblOption.js' import moment from 'moment'; +import './index.less' export default function Czrz() { const [newColumns, setNewColumns] = useState([]) const [tableList, setTableList] = useState([]) @@ -339,6 +340,7 @@ export default function Czrz() { })) setNewColumns([...columns, ...dayarrColumns]) console.log("hbobj", newhbobj); + console.log("adlist", adlist); setHbobj(newhbobj); setAdcdList(adlist); filterdata(adlist, newhbobj) @@ -442,7 +444,27 @@ export default function Czrz() { } } const onSelect = (keys, arr) => { - console.log(keys, arr); + console.log('adcdList', adcdList, keys); + if (keys.length > 0) { + const adcd = keys[0]; + if (adcd.slice(2) == '0000000000000') { + filterdata(adcdList,hbobj) + } else if (adcd.slice(4) == '00000000000') { + const filterData = adcdList.filter(item => { + return item.adcd.substring(0,4) == adcd.substring(0,4); + }); + setTableList(filterData) + }else if (adcd.slice(6) == '000000000'|| adcd =="420381450000000") { + const filterData = adcdList.find(item => { + if (adcd == "420381450000000") { + return item.adcd.substring(0,7) == adcd.substring(0,7) + } else { + return item.adcd.substring(0,6) == adcd.substring(0,6) + } + }); + setTableList([filterData]) + } + } setSelectedKeys(keys) setAdcd(keys[0]) } @@ -476,19 +498,31 @@ export default function Czrz() { } } sellist.sort(function (o1, o2) { - if (o1[selday]?.rate > o2[selday]?.rate) { + if (o1[selday]?.rate < o2[selday]?.rate) { return 1; } else { return -1; } }); + console.log("sellist", sellist); setSubTableData(sellist) } // 下载测站离线表 const download = () => { - httpGetFile(apiurl.ptjs.export + '?' + `tm=${SearchBottom.operTime}`).then((res) => { + let substrData = '42' + const substrAdcd2 = adcd.substring(0, 2); + const substrAdcd4 = adcd.substring(0, 4); + const substrAdcd6 = adcd.substring(0, 6); + if (adcd.slice(2) == '0000000000000') { + substrData = substrAdcd2; + } else if (adcd.slice(4) == '00000000000') { + substrData = substrAdcd4; + } else if (adcd.slice(6) == '000000000') { + substrData = substrAdcd6; + } + httpGetFile(apiurl.ptjs.export + '?' + `tm=${SearchBottom.operTime}` + `&adcd=${substrData}`).then((res) => { if (res) { exportFile('测站离线表.xlsx', res.data) } @@ -573,7 +607,8 @@ export default function Czrz() { columns={newColumns} dataSource={tableList} pagination={false} - scroll={{ x: width, y: "calc( 100vh - 500px )" }} + rowClassName={(r,i) => tableList.length == 1 ? 'onlyOne':''} + scroll={{ x: width, y: "calc( 100vh - 450px )" }} rowKey="inx" /> @@ -609,7 +644,7 @@ export default function Czrz() { columns={detailsColumns} dataSource={subTableData} pagination={false} - scroll={{ x: 1200, y: "calc( 100vh - 600px )" }} + scroll={{ x: 1200, y: "calc( 100vh - 500px )" }} rowKey="inx" /> diff --git a/src/views/Ptjs/Czdbl/index.less b/src/views/Ptjs/Czdbl/index.less new file mode 100644 index 0000000..0c1efdd --- /dev/null +++ b/src/views/Ptjs/Czdbl/index.less @@ -0,0 +1,3 @@ +.onlyOne{ + height: 110px; +} \ No newline at end of file diff --git a/src/views/Ptjs/Czdbl/toolbar.js b/src/views/Ptjs/Czdbl/toolbar.js index 484ac4b..ccfbbfe 100644 --- a/src/views/Ptjs/Czdbl/toolbar.js +++ b/src/views/Ptjs/Czdbl/toolbar.js @@ -19,8 +19,8 @@ const ToolBar = ({ setToolVal }) => { useEffect(() => { const defaultValue = [ - dayjs().subtract(10, 'days'), - dayjs().subtract(1,'days') + dayjs().subtract(7, 'days'), + dayjs() ] form.setFieldsValue({ operTime: defaultValue }) setToolVal({stm:defaultValue[0].format('YYYY-MM-DD'), etm:defaultValue[1].format('YYYY-MM-DD')}) diff --git a/src/views/Ptjs/Lssj/index.js b/src/views/Ptjs/Lssj/index.js index 2461968..97ba835 100644 --- a/src/views/Ptjs/Lssj/index.js +++ b/src/views/Ptjs/Lssj/index.js @@ -67,21 +67,21 @@ export default function Lssj() { align: "center", }, { - title: '总内存(MB)', + title: '总内存', dataIndex: 'totalSpace', key: 'totalSpace', width: 120, align: "center", }, { - title: '已用内存(MB)', + title: '已用内存', dataIndex: 'usedSpace', key: 'usedSpace', width: 120, align: "center", }, { - title: '可用内存(MB)', + title: '可用内存', dataIndex: 'freeSpace', key: 'freeSpace', width: 120, @@ -118,21 +118,21 @@ export default function Lssj() { align: "center", }, { - title: '总磁盘量(GB)', + title: '总磁盘量', dataIndex: 'totalSpace', key: 'totalSpace', width: 120, align: "center", }, { - title: '已用磁盘量(GB)', + title: '已用磁盘量', dataIndex: 'usedSpace', key: 'usedSpace', width: 120, align: "center", }, { - title: '可用磁盘量(GB)', + title: '可用磁盘量', dataIndex: 'freeSpace', key: 'freeSpace', width: 120, @@ -205,7 +205,7 @@ export default function Lssj() { const res = await httppost(url,params) if (res.code == 200) { const result = res.data.map(item => ({...item,tm:moment(item.tm).format('HH:mm:ss')})) - setOptionsData(result) + setOptionsData(res.data) } } catch (error) { console.log(error); @@ -243,7 +243,7 @@ export default function Lssj() { /> {optionsData.length > 0 && tableProps.dataSource.length > 0 ? <> -
+
{searchVal.type == 2 &&
: diff --git a/src/views/Ptjs/Lssj/qsOption.js b/src/views/Ptjs/Lssj/qsOption.js index bc88448..acaf9e2 100644 --- a/src/views/Ptjs/Lssj/qsOption.js +++ b/src/views/Ptjs/Lssj/qsOption.js @@ -2,8 +2,8 @@ import { color } from "echarts"; import moment from "moment" export default function qsOption(data=[],type=0) { - const minY = Math.ceil(Math.min(...data?.map(item => item.rate))); - const maxY = Math.floor(Math.max(...data?.map(item => item.rate))); + const minY = Math.floor(Math.min(...data?.map(item => item.rate))); + const maxY = Math.ceil(Math.max(...data?.map(item => item.rate))); const name = type == 0 ? 'CPU使用率' : type == 1 ? '内存使用率' : type == 2 ? '存储使用率' : 'CPU使用率' diff --git a/src/views/Ptjs/Lssj/toolbar.js b/src/views/Ptjs/Lssj/toolbar.js index d169cce..22f0a1f 100644 --- a/src/views/Ptjs/Lssj/toolbar.js +++ b/src/views/Ptjs/Lssj/toolbar.js @@ -16,7 +16,7 @@ const ToolBar = ({ setToolVal }) => { const Stypes = [ { label: 'CPU', value: 0 }, { label: '内存', value: 1 }, - { label: '存储', value: 2 }, + // { label: '存储', value: 2 }, ]; const [form] = Form.useForm(); @@ -70,7 +70,8 @@ const ToolBar = ({ setToolVal }) => { return (
- + + { -
{ setShowIcon(!showIcon) }} diff --git a/src/views/Ptjs/Sssj/Cpu.js b/src/views/Ptjs/Sssj/Cpu.js index 7e54aba..cfba0b0 100644 --- a/src/views/Ptjs/Sssj/Cpu.js +++ b/src/views/Ptjs/Sssj/Cpu.js @@ -26,22 +26,22 @@ export default function Cpu({data}) { {data?.cpu64bit ? '是':'否'} - + {/* {data?.cpuVendorFreq} - - + */} + {data?.logicalProcessorCount} - + {data?.physicalProcessorCount} {(data?.systemCpuLoad * 100).toFixed(2)} - + {data?.maxFreq} - + {data?.cacheSize} diff --git a/src/views/Ptjs/Sssj/Memory.js b/src/views/Ptjs/Sssj/Memory.js index 7468d3c..ae09dca 100644 --- a/src/views/Ptjs/Sssj/Memory.js +++ b/src/views/Ptjs/Sssj/Memory.js @@ -2,29 +2,45 @@ import React from 'react' import { Descriptions } from 'antd' import './index.less' export default function Memory({ data }) { - + // 工具函数:格式化字节大小 + const formatBytes = (bytes, decimals = 2) => { + if (bytes === 0) return '0 Bytes'; + + const k = 1024; // 1 KB = 1024 Bytes + const sizes = ['Bytes', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB']; + const i = Math.floor(Math.log(bytes) / Math.log(k)); // 计算单位索引 + + // 格式化数值并保留指定小数位数 + return `${parseFloat((bytes / Math.pow(k, i)).toFixed(decimals))} ${sizes[i]}`; + }; return (
- - {data?.virtualMemory?.swapTotal} + + {formatBytes(data?.total)} - - {data?.virtualMemory?.swapUsed} + + {formatBytes(data?.available)} + + + {formatBytes(data?.virtualMemory?.swapTotal)} + + + {formatBytes(data?.virtualMemory?.swapUsed)} - {data?.virtualMemory?.swapPagesIn} + {data?.virtualMemory?.swapPagesIn} - {data?.virtualMemory?.swapPagesOut} + {data?.virtualMemory?.swapPagesOut} - - {data?.virtualMemory?.virtualMax} + + {formatBytes(data?.virtualMemory?.virtualMax)} - - {data?.virtualMemory?.virtualInUse} + + {formatBytes(data?.virtualMemory?.virtualInUse)} - + {/*
CPU