From 0a9a8176a0d85f25b839114a0a92b281c19d5c25 Mon Sep 17 00:00:00 2001 From: lishenfeng Date: Mon, 10 Feb 2025 17:56:43 +0800 Subject: [PATCH] =?UTF-8?q?feat():=20=E5=B9=B3=E5=8F=B0=E7=9B=91=E8=A7=86?= =?UTF-8?q?=E5=BC=80=E5=8F=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/Crud/_.js | 30 +++++- src/components/Crud/usePageTable.js | 5 +- src/layouts/Layout/index.js | 7 +- src/models/apiurl.js | 7 +- src/models/session/index.js | 11 +- src/routes.js | 8 +- src/setupProxy.js | 11 ++ src/utils/request.js | 30 ++++++ src/views/Login/index.js | 3 +- src/views/Ptjs/Czdbl/index.js | 151 ++++++++++++++++++++++++++++ src/views/Ptjs/Czdbl/toolbar.js | 67 ++++++++++++ src/views/Ptjs/Czrz/form.js | 59 +++++++++++ src/views/Ptjs/Czrz/index.js | 150 +++++++++++++++++++++++++++ src/views/Ptjs/Czrz/toolbar.js | 70 +++++++++++++ 14 files changed, 596 insertions(+), 13 deletions(-) create mode 100644 src/views/Ptjs/Czdbl/index.js create mode 100644 src/views/Ptjs/Czdbl/toolbar.js create mode 100644 src/views/Ptjs/Czrz/form.js create mode 100644 src/views/Ptjs/Czrz/index.js create mode 100644 src/views/Ptjs/Czrz/toolbar.js diff --git a/src/components/Crud/_.js b/src/components/Crud/_.js index 3cdd2ce..0d71f43 100644 --- a/src/components/Crud/_.js +++ b/src/components/Crud/_.js @@ -1,4 +1,4 @@ -import { httppost, httpget } from "../../utils/request"; +import { httppost, httpget,xyt_httpget2 } from "../../utils/request"; export async function findPage(url, params = {},type='post') { @@ -38,3 +38,31 @@ export async function findPage1(url, params = {}, type = 'post') { } return {list: [], totalRow: 0}; } + +export async function xyt_paginate_noCode(url, params = {}) { + const {pageNumber, pageSize, ...ret} = params; + const pam = { + pageNum:pageNumber, + pageSize:pageSize, + ...ret + } + const result = await xyt_httpget2(url, pam); + if (result && result.rows) { + return { + list: result.rows.map((m, index) => ({inx: (pageNumber - 1) * pageSize + index + 1, ...m})), + totalRow: result.total + }; + } + return {list: [], totalRow: 0}; +} + + +export function createCrudService(urlSet) { + const xyt_find_noCode = async (params) => { + return xyt_paginate_noCode(urlSet, params); + } + + return { + xyt_find_noCode, + } +} \ No newline at end of file diff --git a/src/components/Crud/usePageTable.js b/src/components/Crud/usePageTable.js index 1b65d23..0000f40 100644 --- a/src/components/Crud/usePageTable.js +++ b/src/components/Crud/usePageTable.js @@ -32,11 +32,12 @@ const usePageTable = (service,service2, { defaultParams, defaultPageSize, defaul sort: opt?.sort ?? state.sort, search: opt?.params ?? state.params, }; - let data={} + let data = {} + const { search, ...params } = pageParams; if(opt?.params?.yearShow){ data=await service(pageParams) }else{ - data=opt.params?.year?await service2(pageParams):await service(pageParams) + data=opt.params?.year?await service2(pageParams):await service({...search, ...params}) } if (!abort.current) { diff --git a/src/layouts/Layout/index.js b/src/layouts/Layout/index.js index 5e78764..4880e61 100644 --- a/src/layouts/Layout/index.js +++ b/src/layouts/Layout/index.js @@ -35,14 +35,15 @@ function LayoutPage(props) { const token = getParameter('token'); const oldToken = sessionStorage.getItem("token") const myLayout = getParameter('Layout') - const loading = useMemo(()=>user!==null&&menu.length!==0,[user,menu]) - + // const loading = useMemo(() => user !== null && menu.length !== 0, [user, menu]) + const loading = useMemo(() => menu.length !== 0, [user, menu]) useEffect(()=>{ if(token){ if(oldToken!==token){ dispatch.session.byToken(token) }else{ - dispatch.session.loadMenu(user); + // dispatch.session.loadMenu(user); + dispatch.session.loadMenu(); } } else { dispatch.session.loadMenu(); diff --git a/src/models/apiurl.js b/src/models/apiurl.js index f4fcbd1..1c292bd 100644 --- a/src/models/apiurl.js +++ b/src/models/apiurl.js @@ -8,7 +8,7 @@ const shengUrl2 = 'service28080' // const shengUrlPro = 'http://223.75.53.141:28080' // const shengUrlPro = 'http://223.75.53.141:8000' //正式 const shengUrlPro = 'http://223.75.53.141:9001' //正式 - +const guishiPro = '/gunshiApp/ptjs' // const shengUrlPro = 'http://223.75.53.141:9001' @@ -20,6 +20,11 @@ const nmjPro = '/shzh/jcsj' const jsapi = { + ptjs: { + czrz: shengUrlPro + '/prod-api/baseplat-system/operlog/hb/list', + czdbl: guishiPro + '/monitor/summary' + }, + service: { sysuser: { getCaptcha: shengUrlPro + '/prod-api/baseplat-auth/tokenHB/getCaptcha', diff --git a/src/models/session/index.js b/src/models/session/index.js index 9c0e9ec..261285d 100644 --- a/src/models/session/index.js +++ b/src/models/session/index.js @@ -141,8 +141,8 @@ const session = { // const { data } = await httpget(`${apiurl.service.adcd.tree}/${userData.adcd}`) || {} // dbStorage.setItem('dataTree',data) - await setTree('dataTree',userData) - await setTree123('dataTree123',userData) + // await setTree('dataTree',userData) + // await setTree123('dataTree123',userData) // const im = new IMSDK(); // im.init({ @@ -270,7 +270,12 @@ const session = { { id: 119, path: "/fhrz/yjgx", parent_id: 500, name: "预警关系", type: 0, order: 1 }, ] }, - + { + id:121, redirect: "/ptjs/czrz", parent_id: -1, name: "平台监视", type: 1, order: 1, children: [ + { id: 402, path: "/ptjs/czrz", parent_id: 500, name: "操作日志", type: 0, order: 1}, + { id: 403, path: "/ptjs/Czdbl", parent_id: 500, name: "测站到报率", type: 0, order: 1}, + ] + }, ] let arr = myMenu.map((item,index)=>{ diff --git a/src/routes.js b/src/routes.js index 33e53b5..979af53 100644 --- a/src/routes.js +++ b/src/routes.js @@ -26,7 +26,7 @@ const routes = [ }, { route: '*', component: Layout, routes: [ - { path: '/', exact: true, component: () => }, + { path: '/', exact: true, component: () => }, //行政区划 { path: '/xzqh/xzqhbg', exact: true, component: lazy(() => import('./views/Adcd/Bg')) }, { path: '/xzqh/yhjmwh', exact: true, component: lazy(() => import('./views/Adcd/Wh')) }, @@ -38,6 +38,12 @@ const routes = [ //防御责任人 { path: '/fyzrr/zrrbg', exact: true, component: lazy(() => import('./views/Zrr/Bg')) }, { path: '/fyzrr/zrrcx', exact: true, component: lazy(() => import('./views/Zrr/Cx')) }, + + // 平台监视 + { path: '/ptjs/czrz', exact: true, component: lazy(() => import('./views/Ptjs/Czrz')) }, + // 测站到报率 + { path: '/ptjs/czdbl', exact: true, component: lazy(() => import('./views/Ptjs/Czdbl')) }, + //监测站点 { path: '/jczd/zdbg', exact: true, component: lazy(() => import('./views/Jczd/Bg')) }, { path: '/jczd/zdsp', exact: true, component: lazy(() => import('./views/Jczd/Sp')) }, diff --git a/src/setupProxy.js b/src/setupProxy.js index 1bf3742..85e66a2 100644 --- a/src/setupProxy.js +++ b/src/setupProxy.js @@ -49,5 +49,16 @@ module.exports = function (app) { }, }) ); + + app.use( + '/gunshiApp/ptjs', + createProxyMiddleware({ + target: 'http://192.168.66.7:20019', + changeOrigin: true, + pathRewrite: { + '^/gunshiApp/ptjs': '', + }, + }) + ); }; diff --git a/src/utils/request.js b/src/utils/request.js index 56c5dc0..b84441d 100644 --- a/src/utils/request.js +++ b/src/utils/request.js @@ -133,6 +133,36 @@ export function httppost(url, data = {}) { return send(url, options); } +export function xyt_httpget2(url, data = {}) { + const params = []; + for (const k in data) { + const v = data[k]; + if (tools.strIsEmpty(v)) { continue; } + + params.push(`${encodeURIComponent(k)}=${encodeURIComponent(v)}`); + } + const strparams = params.join('&'); + if (params.length > 0) { + if (url.indexOf('?') > 0) { + url += `&${strparams}`; + } else { + url += `?${strparams}`; + } + } + const options = { + method: 'GET', + headers: { + "cookie":'Token=' + localStorage.getItem('access_token'), + "dataScope":"CUSTOM_WATERSHED", + "customWatershedCode":localStorage.getItem('customWatershedCode'), + "SHOW_LOADING": true, + "authorization":"Bearer" + ' ' + sessionStorage.getItem('token') + }, + }; + + return send(url, options); +} + export function httpPostFile(url, data = {}) { const form = new FormData(); for (const k in data) { diff --git a/src/views/Login/index.js b/src/views/Login/index.js index 4250d8c..50d7fc6 100644 --- a/src/views/Login/index.js +++ b/src/views/Login/index.js @@ -25,9 +25,8 @@ const Login = ({ isModal = false }) => { if (result) { // debugger; setLoadings(false) - debugger // history.push(getMainPage(result)); - history.push('/fyzrr/zrrbg'); + history.push('/ptjs/czrz'); }else{ setLoadings(false) message.error('登录失败'); diff --git a/src/views/Ptjs/Czdbl/index.js b/src/views/Ptjs/Czdbl/index.js new file mode 100644 index 0000000..c376c34 --- /dev/null +++ b/src/views/Ptjs/Czdbl/index.js @@ -0,0 +1,151 @@ +import React, { useEffect, useState, useMemo, useRef } from 'react'; +import { Card, message, Table, Space, Button } from 'antd'; +import ToolBar from './toolbar.js'; +import usePageTable from '../../../components/Crud/usePageTable.js' +import apiurl from '../../../models/apiurl' +import { createCrudService } from '../../../components/Crud/_'; +import {xyt_httpget2} from "../../../utils/request" +export default function Czrz() { + const refModal = useRef(); + const businessType = { + // 0: "其它", + 1: "新增", + 2: "修改", + 3: "删除", + 4: "授权", + 5: "导出", + 6: "导入", + 7: "强退", + 8: "生成代码", + 9: "清空数据", + } + const operatorStatus = { + 0: '正常', + 1: '异常' + } + const columns = [ + { + title: '日志编号', + dataIndex: 'operId', + key: 'operId', + width: 100, + align: "center", + }, + { + title: '系统模块', + dataIndex: 'title', + key: 'title', + width: 120, + align: "center", + }, + { + title: '操作类型', + dataIndex: 'businessType', + key: 'businessType', + width: 100, + align: "center", + render: (text, record) => ( + + {businessType[text]} + + ) + }, + { + title: '请求方式', + dataIndex: 'requestMethod', + key: 'requestMethod', + width: 100, + align: "center", + }, + { + title: '操作人员', + dataIndex: 'operName', + key: 'operName', + width: 180, + align: "center", + }, + { + title: '主机', + dataIndex: 'operIp', + key: 'operIp', + width: 180, + align: "center", + }, + { + title: '操作地点', + dataIndex: 'operAddress', + key: 'operAddress', + width: 180, + align: "center", + }, + { + title: '操作状态', + dataIndex: 'status', + key: 'status', + width: 100, + align: "center", + render: (text, record) => ( + + {operatorStatus[text]} + + ) + }, + { + title: '操作日期', + dataIndex: 'operTime', + key: 'operTime', + width: 150, + align: "center", + }, + { + title: '操作', key: 'action', dataIndex: 'action', width: 150, align: "center", + render: (v, r) => ( + + command("view")(r)}>查看 + + ) + }, + ] + const [searchVal, setSearchVal] = useState(false) + const width = useMemo(() => columns.reduce((total, cur) => total + (cur.width), 0), [columns]); + + const { tableProps, search, refresh } = usePageTable(createCrudService(apiurl.ptjs.czdbl).xyt_find_noCode); + + const getData = async (params) => { + try { + const res = await xyt_httpget2(apiurl.ptjs.czdbl,params) + // debugger + } catch (error) { + console.log(error); + } + } + const command = (type) => (row) => { + refModal.current.showView(row) + } + useEffect(() => { + if (searchVal) { + const params = { + ...searchVal + }; + getData(params) + } + }, [searchVal]) + + return ( +
+
+ + + + + + + ) +} diff --git a/src/views/Ptjs/Czdbl/toolbar.js b/src/views/Ptjs/Czdbl/toolbar.js new file mode 100644 index 0000000..5f51dde --- /dev/null +++ b/src/views/Ptjs/Czdbl/toolbar.js @@ -0,0 +1,67 @@ +import React, { useEffect,useState } from 'react'; +import { Form, Input, Button, DatePicker } from 'antd'; +import NormalSelect from '../../../components/Form/NormalSelect'; +import dayjs from 'dayjs'; +const { RangePicker } = DatePicker; + +const ToolBar = ({ setToolVal }) => { + const types = [ + // { label: '其它', value: 0 }, + { label: '新增', value: 1 }, + { label: '修改', value: 2 }, + { label: '删除', value: 3 }, + { label: '授权', value: 4 }, + { label: '导出', value: 5 }, + { label: '导入', value: 6 }, + { label: '强退', value: 7 }, + { label: '生成代码', value: 8 }, + { label: '清空数据', value: 9 }, + ]; + + const Stypes = [ + { label: '正常', value: 0 }, + { label: '异常', value: 1 }, + ]; + const [form] = Form.useForm(); + + const onFinish = (values) => { + if (values.operTime) { + values.stm = values.operTime[0] ? dayjs(values.operTime[0]).format('YYYY-MM-DD') : ""; + values.etm = values.operTime[1] ? dayjs(values.operTime[1]).format('YYYY-MM-DD') : ""; + delete values.operTime + } + setToolVal(values); + } + + useEffect(() => { + const defaultValue = [ + dayjs().subtract(10, 'days'), + dayjs().subtract(1, 'days') + ] + form.setFieldsValue({ operTime: defaultValue }) + setToolVal({stm:defaultValue[0].format('YYYY-MM-DD'), etm:defaultValue[1].format('YYYY-MM-DD')}) + }, []); + + return ( +
+
+ + + + + + + + + + + +
+ ); +} + +export default ToolBar; \ No newline at end of file diff --git a/src/views/Ptjs/Czrz/form.js b/src/views/Ptjs/Czrz/form.js new file mode 100644 index 0000000..603d17b --- /dev/null +++ b/src/views/Ptjs/Czrz/form.js @@ -0,0 +1,59 @@ +import React, { useEffect, useState } from 'react'; +import { Form, Descriptions, Input, Row, Col, message, Select, Switch } from 'antd'; + + +const ModalForm = ({ mode, record }) => { + const [form] = Form.useForm(); + const businessType = { + 0: "其它", + 1: "新增", + 2: "修改", + 3: "删除", + 4: "授权", + 5: "导出", + 6: "导入", + 7: "强退", + 8: "生成代码", + 9: "清空数据", + } + const operatorStatus = { + 0: '正常', + 1: '异常' + } + + return ( + <> + + + {record?.title}/{businessType[record?.businessType]} + + + {record?.operUrl} + + + {record?.operName}/{record?.operIp}/ + + + {record?.requestMethod} + + + {record?.method} + + + {record?.operParam} + + + {record?.jsonResult} + + + {operatorStatus[record?.status]} + + + {record?.operTime} + + + + ); +} + +export default ModalForm; diff --git a/src/views/Ptjs/Czrz/index.js b/src/views/Ptjs/Czrz/index.js new file mode 100644 index 0000000..4e9a899 --- /dev/null +++ b/src/views/Ptjs/Czrz/index.js @@ -0,0 +1,150 @@ +import React, { useEffect, useState, useMemo, useRef } from 'react'; +import { Card, message, Table, Space, Button } from 'antd'; +import ToolBar from './toolbar.js'; +import usePageTable from '../../../components/Crud/usePageTable.js' +import apiurl from '../../../models/apiurl' +import { createCrudService } from '../../../components/Crud/_'; +import BasicCrudModal from '../../../components/Crud/BasicCrudModal.js'; +import ModalForm from './form.js'; +export default function Czrz() { + const refModal = useRef(); + + const businessType = { + // 0: "其它", + 1: "新增", + 2: "修改", + 3: "删除", + 4: "授权", + 5: "导出", + 6: "导入", + 7: "强退", + 8: "生成代码", + 9: "清空数据", + } + const operatorStatus = { + 0: '正常', + 1: '异常' + } + const columns = [ + { + title: '日志编号', + dataIndex: 'operId', + key: 'operId', + width: 100, + align: "center", + }, + { + title: '系统模块', + dataIndex: 'title', + key: 'title', + width: 120, + align: "center", + }, + { + title: '操作类型', + dataIndex: 'businessType', + key: 'businessType', + width: 100, + align: "center", + render: (text, record) => ( + + {businessType[text]} + + ) + }, + { + title: '请求方式', + dataIndex: 'requestMethod', + key: 'requestMethod', + width: 100, + align: "center", + }, + { + title: '操作人员', + dataIndex: 'operName', + key: 'operName', + width: 180, + align: "center", + }, + { + title: '主机', + dataIndex: 'operIp', + key: 'operIp', + width: 180, + align: "center", + }, + { + title: '操作地点', + dataIndex: 'operAddress', + key: 'operAddress', + width: 180, + align: "center", + }, + { + title: '操作状态', + dataIndex: 'status', + key: 'status', + width: 100, + align: "center", + render: (text, record) => ( + + {operatorStatus[text]} + + ) + }, + { + title: '操作日期', + dataIndex: 'operTime', + key: 'operTime', + width: 150, + align: "center", + }, + { + title: '操作', key: 'action', dataIndex: 'action', width: 150, align: "center", + render: (v, r) => ( + + command("view")(r)}>查看 + + ) + }, + ] + const [searchVal, setSearchVal] = useState({}) + const width = useMemo(() => columns.reduce((total, cur) => total + (cur.width), 0), [columns]); + + const { tableProps, search, refresh } = usePageTable(createCrudService(apiurl.ptjs.czrz).xyt_find_noCode); + const command = (type) => (row) => { + refModal.current.showView(row) + } + useEffect(() => { + if (searchVal) { + const params = { + ...searchVal + }; + search(params) + } + }, [searchVal]) + + return ( +
+
+ + +
+ + + + + ) +} diff --git a/src/views/Ptjs/Czrz/toolbar.js b/src/views/Ptjs/Czrz/toolbar.js new file mode 100644 index 0000000..0ba32db --- /dev/null +++ b/src/views/Ptjs/Czrz/toolbar.js @@ -0,0 +1,70 @@ +import React, { useEffect,useState } from 'react'; +import { Form, Input, Button, DatePicker } from 'antd'; +import NormalSelect from '../../../components/Form/NormalSelect'; +import dayjs from 'dayjs'; +const { RangePicker } = DatePicker; + +const ToolBar = ({ setToolVal }) => { + const types = [ + // { label: '其它', value: 0 }, + { label: '新增', value: 1 }, + { label: '修改', value: 2 }, + { label: '删除', value: 3 }, + { label: '授权', value: 4 }, + { label: '导出', value: 5 }, + { label: '导入', value: 6 }, + { label: '强退', value: 7 }, + { label: '生成代码', value: 8 }, + { label: '清空数据', value: 9 }, + ]; + + const Stypes = [ + { label: '正常', value: 0 }, + { label: '异常', value: 1 }, + ]; + const [form] = Form.useForm(); + + const onFinish = (values) => { + if (values.operTime) { + values.beginTime = values.operTime[0] ? dayjs(values.operTime[0]).format('YYYY-MM-DD') : ""; + values.endTime = values.operTime[1] ? dayjs(values.operTime[1]).format('YYYY-MM-DD') : ""; + delete values.operTime + } + setToolVal(values); + } + + return ( +
+
+ + + + + + + + + + + + + + + + + + + + + + + +
+ ); +} + +export default ToolBar; \ No newline at end of file