From 310471c1bbe1b981fcd5378b0921d9b4c2dab018 Mon Sep 17 00:00:00 2001 From: JINGYJ <1458671527@qq.com> Date: Tue, 23 Jan 2024 09:35:20 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E5=89=8D=E7=AB=AF=E9=A1=B5=E9=9D=A2?= =?UTF-8?q?=E5=BC=80=E5=8F=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- config/config.ts | 1 + config/proxy.ts | 9 + config/routes.ts | 10 + mock/meau.ts | 130 +++++ mock/user.ts | 33 +- src/app.tsx | 10 +- .../RightContent/AvatarDropdown.tsx | 16 +- src/components/TableActionCard/isDelete.tsx | 4 +- src/enums/status.ts | 29 +- src/locales/zh-CN/alarm.ts | 15 +- src/locales/zh-CN/device.ts | 10 + src/pages/Alarm/AlarmList/index.tsx | 516 +++++++++++++----- .../alarmRules/components/UpdateForm.tsx | 228 ++++++++ .../alarmRules/components/updateForm.less | 8 + src/pages/Alarm/alarmRules/index.tsx | 233 ++++++++ .../interfaceManage/components/CreateForm.tsx | 191 +++++++ .../interfaceManage/components/UpdateForm.tsx | 169 ++++++ src/pages/Setting/interfaceManage/index.tsx | 240 ++++++++ src/pages/User/Login/index1.tsx | 5 +- src/services/ant-design-pro/api.ts | 4 +- src/services/ant-design-pro/typings.d.ts | 12 +- src/services/system/Menu.ts | 3 +- src/utils/FixMenuItemIcon.tsx | 8 +- 23 files changed, 1713 insertions(+), 171 deletions(-) create mode 100644 mock/meau.ts create mode 100644 src/pages/Alarm/alarmRules/components/UpdateForm.tsx create mode 100644 src/pages/Alarm/alarmRules/components/updateForm.less create mode 100644 src/pages/Alarm/alarmRules/index.tsx create mode 100644 src/pages/Setting/interfaceManage/components/CreateForm.tsx create mode 100644 src/pages/Setting/interfaceManage/components/UpdateForm.tsx create mode 100644 src/pages/Setting/interfaceManage/index.tsx diff --git a/config/config.ts b/config/config.ts index 3fb1056..a4564b1 100644 --- a/config/config.ts +++ b/config/config.ts @@ -183,5 +183,6 @@ export default defineConfig({ mfsu: { strategy: 'normal', }, + esbuildMinifyIIFE: true, requestRecord: {}, }); diff --git a/config/proxy.ts b/config/proxy.ts index d8784aa..eefe421 100644 --- a/config/proxy.ts +++ b/config/proxy.ts @@ -32,6 +32,15 @@ export default { changeOrigin: true, secure: false, }, + // '/api/': { + // // 要代理的地址 + // target: 'http://192.168.10.22:8000/', + // // target: 'https://www.baidu.com', + // // 配置了这个可以从 http 代理到 https + // // 依赖 origin 的功能可能需要这个,比如 cookie + // changeOrigin: true, + // secure: false, + // }, // '/video_save_path/': { // // 要代理的地址 // target: 'http://192.168.10.96/', diff --git a/config/routes.ts b/config/routes.ts index e3ed45e..657aad8 100644 --- a/config/routes.ts +++ b/config/routes.ts @@ -348,4 +348,14 @@ export default [ }, ], }, + { + name: 'alarm_rules', + path: '/alarm_rules', + component: 'Alarm/alarmRules', + }, + { + name: 'interfaceManage', + path: '/interfaceManage', + component: 'Setting/interfaceManage', + } ]; diff --git a/mock/meau.ts b/mock/meau.ts new file mode 100644 index 0000000..d98318a --- /dev/null +++ b/mock/meau.ts @@ -0,0 +1,130 @@ +import { Request, Response } from 'express'; + +const getMenus = (req: Request, res: Response) => { + const result = { + code: 0, + success: true, + data: { + routes: [ + { + "path": "/welcome", + "key": "", + "name": "welcome", + "icon": "HomeOutlined", + "access": "", + "component": "Welcome", + "title": "首页", + "routes": [] + }, + { + "path": "/device", + "key": "", + "name": "device", + "icon": "DesktopOutlined", + "access": "", + "component": "", + "title": "设备管理", + "routes": [ + { + "path": "/device/device-list", + "key": "12", + "name": "device-list", + "icon": "", + "access": "", + "component": "Device/DeviceList", + "title": "设备列表", + "routes": [] + }, + { + "path": "/device/device-category-list", + "key": "13", + "name": "device-category-list", + "icon": "", + "access": "", + "component": "Device/DeviceCategoryList", + "title": "设备类别", + "routes": [] + }, + { + "path": "/device/device-group-list", + "key": "14", + "name": "device-group-list", + "icon": "", + "access": "", + "component": "Device/DeviceGroupList", + "title": "设备组", + "routes": [] + } + ] + }, + { + "path": "/alarm", + "key": "", + "name": "alarm", + "icon": "WarningOutlined", + "access": "", + "component": "", + "title": "告警管理", + "routes": [ + { + "path": "/alarm/alarm-list", + "key": "50", + "name": "alarm-list", + "icon": "", + "access": "", + "component": "Alarm/AlarmList", + "title": "告警列表", + "routes": [] + }, + { + "path": "/alarm/alarm-setting", + "key": "51", + "name": "alarm-setting", + "icon": "", + "access": "", + "component": "Alarm/AlarmSetting", + "title": "告警设置", + "routes": [] + }, + { + "path": "/alarm/alarm-ways", + "key": "55", + "name": "alarm-ways", + "icon": "", + "access": "", + "component": "Alarm/AlarmWays", + "title": "告警方式", + "routes": [] + } + ] + }, + { + "path": "alarm_rules", + "key": "", + "name": "alarm_rules", + "icon": "OrderedListOutlined", + "access": "", + "component": "Hidden", + "title": "告警规则", + "routes": [] + }, + { + "path": "interfaceManage", + "key": "", + "name": "interfaceManage", + "icon": "BranchesOutlined", + "access": "", + "component": "Hidden", + "title": "接口管理", + "routes": [] + } + ] + }, + msg: "获取成功" + } + return res.json(result); +}; + +export default { + 'POST /api/mock/getMenus': getMenus, +}; diff --git a/mock/user.ts b/mock/user.ts index 75edd34..96a1650 100644 --- a/mock/user.ts +++ b/mock/user.ts @@ -120,11 +120,36 @@ export default { 'POST /api/login/account': async (req: Request, res: Response) => { const { password, username, type } = req.body; await waitTime(2000); - if (password === 'ant.design' && username === 'admin') { + if (password === '123456' && username === 'admin') { res.send({ - status: 'ok', - type, - currentAuthority: 'admin', + // status: 'ok', + // type, + // currentAuthority: 'admin', + code: 0, + success: true, + data: { + "user": { + "id": 1, + "createTime": "2023-10-08T08:02:30.775742Z", + "updateTime": "2024-01-19T07:56:46.185333Z", + "userName": "admin", + "nickName": "管理员", + "phone": "", + "email": "", + "avatarId": 1, + "roleId": 1, + "postId": null, + "deptId": null, + "roleIds": "1", + "postIds": "", + "remark": "", + "enable": null, + "lastLoginTime": "2024-01-19T08:57:42.191149854Z" + }, + "token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJJZCI6MSwiVXNlcm5hbWUiOiJhZG1pbiIsIk5pY2tOYW1lIjoi566h55CG5ZGYIiwiUm9sZUlkIjoxLCJCdWZmZXJUaW1lIjo4NjQwMCwiaXNzIjoicW1QbHVzIiwiYXVkIjpbIkdWQSJdLCJleHAiOjE3MDYyNTk0NjIsIm5iZiI6MTcwNTY1NDY2Mn0.Iyc74dPDLCc-J3AA_V-KEmVP4vihYzmasXok_jlvOvE", + "expiresAt": 1706259462000 + }, + msg: "登录成功" }); access = 'admin'; return; diff --git a/src/app.tsx b/src/app.tsx index 5141e14..9a76f7d 100644 --- a/src/app.tsx +++ b/src/app.tsx @@ -79,10 +79,10 @@ export const layout: RunTimeLayoutConfig = ({ initialState, setInitialState }) = return { actionsRender: () => [ - , - , - , - + // , + // , + // , + // ], avatarProps: { src: SERVER_HOST + initialState?.currentUser?.avatarUrl, @@ -118,7 +118,7 @@ export const layout: RunTimeLayoutConfig = ({ initialState, setInitialState }) = userId: initialState?.currentUser?.id, }, request: async () => { - // console.log(initialState?.menuData,'initialState_menuData') + console.log(initialState?.menuData,'initialState_menuData') return initialState?.menuData || []; }, }, diff --git a/src/components/RightContent/AvatarDropdown.tsx b/src/components/RightContent/AvatarDropdown.tsx index f041e03..60953ec 100644 --- a/src/components/RightContent/AvatarDropdown.tsx +++ b/src/components/RightContent/AvatarDropdown.tsx @@ -104,19 +104,19 @@ export const AvatarDropdown: React.FC = ({ menu, childre const menuItems = [ ...(menu ? [ - { - key: 'center', - icon: , - label: '个人中心', - }, + // { + // key: 'center', + // icon: , + // label: '个人中心', + // }, // { // key: 'settings', // icon: , // label: '个人设置', // }, - { - type: 'divider' as const, - }, + // { + // type: 'divider' as const, + // }, ] : []), { diff --git a/src/components/TableActionCard/isDelete.tsx b/src/components/TableActionCard/isDelete.tsx index b200168..2692b4c 100644 --- a/src/components/TableActionCard/isDelete.tsx +++ b/src/components/TableActionCard/isDelete.tsx @@ -45,7 +45,9 @@ const IsDelete: React.FC = (props) => { }} /> > ) : ( - + }> )} diff --git a/src/enums/status.ts b/src/enums/status.ts index ace5bad..603238f 100644 --- a/src/enums/status.ts +++ b/src/enums/status.ts @@ -1,14 +1,25 @@ -/* - * @Author: zhoux zhouxia@supervision.ltd - * @Date: 2023-12-08 14:50:08 - * @LastEditors: zhoux zhouxia@supervision.ltd - * @LastEditTime: 2023-12-22 16:45:22 - * @FilePath: \general-ai-platform-web\src\enums\status.ts - * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE - */ - import { DownOutlined } from "@ant-design/icons"; +// 告警规则 +export const alarmRulesEnums: Record[] = [ + { + label: '单人徘徊告警', + key: '0', + }, + { + label: '多人聚集告警', + key: '1', + }, + { + label: '敏感时间段告警', + key: '2', + }, + { + label: '已忽略', + key: '3', + }, +]; + // 分布式设备状态 export const deviceStatusEnums: Record = { allStatus: { diff --git a/src/locales/zh-CN/alarm.ts b/src/locales/zh-CN/alarm.ts index 274fe31..42558a6 100644 --- a/src/locales/zh-CN/alarm.ts +++ b/src/locales/zh-CN/alarm.ts @@ -42,9 +42,18 @@ export const alarm_ways: { [key: string]: string } = { 'alarm.ways.page.form.serviceName': '第三方服务商', 'alarm.ways.page.form.params': '服务商参数', 'alarm.ways.page.form.template': '通知模板', - - 'alarm.ways.page.model.rule.required.name': '请填写告警方式名称', - +} +// 告警规则 +export const alarm_rules: { [key: string]: string } = { + 'alarm_rules.page.name': '告警规则', + 'alarm_rules.page.id': '规则ID', + 'alarm_rules.page.status': '规则状态', + 'alarm_rules.page.updateTime': '修改时间', + 'alarm_rules.page.form.title': '编辑单人徘徊告警', + 'alarm_rules.page.form.isEnabled': '启用单人徘徊告警', + 'alarm_rules.page.form.name': '告警名称', + 'alarm_rules.page.form.triggerConditions': '触发条件', + 'alarm_rules.page.rule.required.name': '请填写告警名称' } \ No newline at end of file diff --git a/src/locales/zh-CN/device.ts b/src/locales/zh-CN/device.ts index 7fff0ab..f5b5f25 100644 --- a/src/locales/zh-CN/device.ts +++ b/src/locales/zh-CN/device.ts @@ -69,3 +69,13 @@ export const device_relation: { [key: string]: string } = { 'device.device_relation.table.rule.required.deviceParentFkId': '设备父节点为必填项', 'device.device_relation.table.rule.required.deviceSonFkId': '设备父节点为必填项', }; +// 接口管理 +export const interface_manage: { [key: string]: string } = { + 'device.interface_manage.table.list.id': 'ID', + 'device.interface_manage.table.list.name': '接口名称', + 'device.interface_manage.table.list.address': '接口地址', + 'device.interface_manage.table.list.createTime': '创建时间', + 'device.interface_manage.table.list.remark': '备注', + 'device.interface_manage.table.rule.required.name': '接口名称为必填项', + 'device.interface_manage.table.rule.required.address': '接口地址为必填项', +}; diff --git a/src/pages/Alarm/AlarmList/index.tsx b/src/pages/Alarm/AlarmList/index.tsx index e48fa0d..c914c7a 100644 --- a/src/pages/Alarm/AlarmList/index.tsx +++ b/src/pages/Alarm/AlarmList/index.tsx @@ -1,155 +1,407 @@ -import AlarmLevelBox from '@/components/DictionaryBox/alarmLevel'; import TableActionCard from '@/components/TableActionCard'; -import IsDelete from '@/components/TableActionCard/isDelete'; -import { alarmLevelStatusEnum } from '@/enums/status'; -import { - deleteDeviceCategoryDeleteDeviceCategory, - postDeviceCategoryGetDeviceCategoryList, -} from '@/services/device/DeviceCategory'; -import type { ActionType, ProColumns } from '@ant-design/pro-components'; -import { PageContainer, ProTable } from '@ant-design/pro-components'; +import { alarmRulesEnums } from '@/enums/status'; +import { ActionType, PageContainer, ProCard, ProList } from '@ant-design/pro-components'; import { FormattedMessage, useIntl } from '@umijs/max'; -import { Space, message } from 'antd'; -import React, { useRef, useState } from 'react'; -import { proTablePaginationOptions } from '../../../../config/defaultTable'; -const DeviceCategoryList: React.FC = () => { +import { Button, Modal, Tabs, Image } from 'antd'; +import React, { useEffect, useRef, useState } from 'react'; +import { proTableCommonOptions, proTablePaginationOptions } from '../../../../config/defaultTable'; +// import DeviceStatusCard from './components/DeviceStatusCard'; +// import CreateForm from './components/CreateForm'; +// import UpdateForm from './components/UpdateForm'; +import { QuestionCircleFilled } from '@ant-design/icons'; + +/** + * @交互说明 + * 1、列表分页展示服务器状态 + */ +const tabOptions: Record = { + singlePersonHoveringAlarm: 90, + multiplePersonGatheringAlarm: 20, + sensitiveTimePeriodAlarm: 20, + ignored: 2 + // processingStatus: 10, + // errorStatus: 20, +}; +export type DeleteBoxProps = { + modalOpen: boolean; + handleModal: () => void; + values: any + reload: any; +}; + +const AlarmList: React.FC = () => { + const [cardActionProps, setCardActionProps] = useState<'actions' | 'extra'>('extra'); + /** + * @en-US Pop-up window of new window + * @zh-CN 新建窗口的弹窗 + * */ + const [createModalOpen, setCreateModalOpen] = useState(false); + /** + * @en-US The pop-up window of the distribution update window + * @zh-CN 更新窗口的弹窗 + * */ + const [updateModalOpen, setUpdateModalOpen] = useState(false); + /** + * @en-US The pop-up window of the distribution update window + * @zh-CN 删除窗口 + * */ + const [modalOpen, setModalOpen] = useState(false); + const [currentRow, setCurrentRow] = useState>({}); /** * @en-US International configuration * @zh-CN 国际化配置 * */ - const intl = useIntl(); + // const access = useAccess(); + // const intl = useIntl(); const actionRef = useRef(); // 动态设置每页数量 - const [currentPageSize, setCurrentPageSize] = useState(10); + const [currentPageSize, setCurrentPageSize] = useState(8); + + const [activeTabIndex, setActiveTabIndex] = useState(0); - const handleDestroy = async (selectedRow: API.DeviceCategory) => { - deleteDeviceCategoryDeleteDeviceCategory({ id: selectedRow.id }) - .then(() => { - message.success(intl.formatMessage({ id: 'common.success', defaultMessage: '$$$' })); - actionRef.current?.reload(); - }) - .catch(() => { - message.error(intl.formatMessage({ id: 'common.failure', defaultMessage: '$$$' })); - }); + const [tab, setTab] = useState(''); + const [tabs, setTabs] = useState([]); + const changeProjectTab = (key: React.SetStateAction) => { + setTab(key) + console.log(key); + } + const getTabs = () => { + if (alarmRulesEnums.length) { + setTab(alarmRulesEnums[0].key); + } + setTabs(alarmRulesEnums) + } + useEffect(() => { + getTabs() + }, []); + const handleCreateModal = () => { + if (createModalOpen) { + setCreateModalOpen(false); + setCurrentRow(undefined); + } else { + setCreateModalOpen(true); + } }; - const columns: ProColumns[] = [ - { - title: , - dataIndex: 'name', - hideInSearch: true, - }, + const handleUpdateModal = () => { + if (updateModalOpen) { + setUpdateModalOpen(false); + setCurrentRow(undefined); + } else { + setUpdateModalOpen(true); + } + }; - { - title: , - dataIndex: 'code', - hideInSearch: true, - }, - { - title: , - dataIndex: 'level', - hideInSearch: true, - render: (text, record, index) => { - console.log(text, record, index, 'level_record'); - const currVal = index % 6; - const currLevel = alarmLevelStatusEnum[currVal]; - return ( - - - {currLevel.label} - - ); + const handleDestroy = async () => { + if (modalOpen) { + setModalOpen(false); + setCurrentRow(undefined); + } else { + setModalOpen(true); + } + // deleteBusinessImageDeleteBusinessImage({ id: selectedRow.id }) + // .then(() => { + // message.success(intl.formatMessage({ id: 'common.success', defaultMessage: '$$$' })); + // actionRef.current?.reload(); + // }) + // .catch(() => { + // message.error(intl.formatMessage({ id: 'common.failure', defaultMessage: '$$$' })); + // }); + }; + + const { confirm } = Modal; + const showConfirm = (record: any) => { + confirm({ + title: `确定删除${record.name}吗`, + icon: , + content: '确定删除服务器1吗?删除后将找不到此服务器,请谨慎操作.', + okText: '确认', + cancelText: '取消', + width: 560, + onOk() { + console.log('OK'); }, + onCancel() { + console.log('Cancel'); + }, + }); + }; + + const dataTestList = [ + { + status: '在线' , + name: '服务器1' }, - { - title: , - dataIndex: 'deviceGroup', - sorter: true, - hideInSearch: true, - valueType: 'dateTime', + { + status: '在线' , + name: '服务器2' }, - { - title: , - dataIndex: 'createTime', - sorter: true, - hideInSearch: true, - valueType: 'dateTime', + { + status: '在线' , + name: '服务器3' }, - - { - title: , - dataIndex: 'option', - valueType: 'option', - fixed: 'right', - render: (_, record) => [ - { - handleDestroy(record).then(() => {}); - }} - > - ), - }, - ]} - >, - ], + { + status: '在线' , + name: '服务器4' + }, + { + status: '在线' , + name: '服务器5' + }, + { + status: '在线' , + name: '服务器6' }, - ]; + { + status: '在线' , + name: '服务器7' + }, + { + status: '在线' , + name: '服务器8' + }, + ].map((record, index) => { + let currColor = 'default'; + switch (record.status) { + case '在线': + currColor = 'success'; + break; + case '故障': + currColor = 'error'; + break; + case '运行中': + currColor = 'warning'; + break; + default: + // eslint-disable-next-line @typescript-eslint/no-unused-vars + currColor = 'default'; + break; + } + return { + content: ( + + { + console.log(index,'index'); + }} + > + + + 告警名称: 单人徘徊告警 + 来源设备: 北广场检票口1#摄像头 + 触发时间: 2023-01-15 22:00:03 + + + + ), + }; + }); + return ( - - - cardProps={{ - bodyStyle: { - padding: 20 - } - }} - options={{ fullScreen: false, setting: false, density: false, reload: false }} - actionRef={actionRef} - rowKey="key" - search={false} - pagination={{ - ...proTablePaginationOptions, - pageSize: currentPageSize, - onChange: (page, pageSize) => setCurrentPageSize(pageSize), - }} - columnsState={{ - persistenceKey: 'device_category_list', - persistenceType: 'localStorage', - }} - request={async (params = {}, sort) => { - const { current, ...rest } = params; - const reqParams = { - page: current, - desc: false, - orderKey: '', - ...rest, - }; - if (sort && Object.keys(sort).length) { - reqParams.orderKey = Object.keys(sort)[0]; - let sort_select = sort[reqParams.orderKey]; - reqParams.desc = sort_select === 'descend'; - } - let resp = await postDeviceCategoryGetDeviceCategoryList({ ...reqParams }); - return { - data: resp.data.list.map((v: API.DeviceCategory) => { - return { ...v, key: v.id }; - }), - success: resp.success, - total: resp.data.total, - current: resp.data.page, - pageSize: resp.data.pageSize, - }; - }} - columns={columns} + + 服务器状态 + + } + > + + { + changeProjectTab(key); + }} + > + + className="gn" + ghost={true} + itemCardProps={{ + ghost: true, + bodyStyle: { padding: 0, margin: 0}, + style: { + width: '100%', + border: 0 + // padding: 0, margin: 0 + } + }} + // search={{ + // labelWidth: proTableCommonOptions.searchLabelWidth, + // }} + // headerTitle={ + // <> + // + // {Object.keys(tabOptions).map((item, index) => { + // // eslint-disable-next-line react/jsx-key + // return ( + // { + // setActiveTabIndex(index); + // }} + // > + // {Object.keys(alarmRulesEnums).includes(item) + // ? alarmRulesEnums[item].miniName + // : ''} + // {"("+tabOptions[item]+ ')'} + // + // ); + // })} + // + // > + // } + cardProps={{ + bodyStyle: { + padding: '8px 16px 16px', + borderRadius: 8 + }, + }} + pagination={{ + ...proTablePaginationOptions, + pageSize: currentPageSize, + onChange: (page, pageSize) => setCurrentPageSize(pageSize), + }} + showActions="hover" + rowSelection={false} + grid={{ gutter: 16, xs: 1, md: 2, lg: 2, xl: 4, xxl: 3 }} + metas={{ + type: { + // 不展示在筛选项 + hideInSearch: true, + }, + content: { + hideInSearch: true, + }, + actions: { + cardActionProps, + }, + // status1: { + // // 自己扩展的字段,主要用于筛选,不在列表中显示 + // title: '设备组', + // valueType: 'select', + // valueEnum: { + // '0': { text: '全部设备分组', status: '0' }, + // '1': { + // text: '设备分组1', + // status: '1', + // }, + // '2': { + // text: '设备分组2', + // status: '2', + // }, + // '3': { + // text: '设备分组3', + // status: '3', + // }, + // }, + // }, + // status2: { + // // 自己扩展的字段,主要用于筛选,不在列表中显示 + // title: '分类', + // valueType: 'select', + // valueEnum: { + // '0': { text: '全部分类', status: '0' }, + // '1': { + // text: '外围监控', + // status: '1', + // }, + // '2': { + // text: '室内监控', + // status: '2', + // }, + // '3': { + // text: '违规监控', + // status: '3', + // }, + // }, + // }, + }} + request={async (params = {}, sort) => { + const { current, ...rest } = params; + const reqParams = { + page: current, + desc: false, + orderKey: '', + ...rest, + }; + if (sort && Object.keys(sort).length) { + reqParams.orderKey = Object.keys(sort)[0]; + let sort_select = sort[reqParams.orderKey]; + reqParams.desc = sort_select === 'descend'; + } + // TODO 联调查询设备状态接口 + // let resps = await postDeviceGroupGetDeviceGroupList({ ...reqParams }); + let resp = { + success: true, + data: { + list: dataTestList, + total: 8, + page: 1, + pageSize: 8, + }, + }; + return { + data: resp.data.list, + success: resp.success, + total: resp.data.total, + current: resp.data.page, + pageSize: resp.data.pageSize, + }; + }} + /> + + + {/* + */} ); }; -export default DeviceCategoryList; +export default AlarmList; diff --git a/src/pages/Alarm/alarmRules/components/UpdateForm.tsx b/src/pages/Alarm/alarmRules/components/UpdateForm.tsx new file mode 100644 index 0000000..ec00a93 --- /dev/null +++ b/src/pages/Alarm/alarmRules/components/UpdateForm.tsx @@ -0,0 +1,228 @@ +/* + * @Author: zhoux zhouxia@supervision.ltd + * @Date: 2023-11-01 13:56:33 + * @LastEditors: zhoux zhouxia@supervision.ltd + * @LastEditTime: 2023-12-26 15:01:08 + * @FilePath: \general-ai-platform-web\src\pages\Device\DeviceCategoryList\components\UpdateForm.tsx + * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE + */ +import { putDeviceCategoryUpdateDeviceCategory } from '@/services/device/DeviceCategory'; +import { postDeviceGroupGetDeviceGroupFkSelect } from '@/services/device/DeviceGroup'; +import { ModalForm, ProForm, ProFormFieldSet, ProFormSelect, ProFormSwitch, ProFormText } from '@ant-design/pro-components'; +import { FormattedMessage, useIntl } from '@umijs/max'; +import { Form, message } from 'antd'; +import React from 'react'; +import { + proFormSmallItemStyleProps, + proFormSmallModelWidth, +} from '../../../../../config/defaultForm'; +import styles from './updateForm.less' +export type FormValueType = { + target?: string; + template?: string; + type?: string; + time?: string; + frequency?: string; +} & Partial; + +export type UpdateFormProps = { + updateModalOpen: boolean; + handleModal: () => void; + values: Partial; + reload: any; +}; +const UpdateForm: React.FC = (props) => { + const intl = useIntl(); + const [form] = Form.useForm(); + + return ( + + width={proFormSmallModelWidth} + title={intl.formatMessage({ + id: 'alarm_rules.page.form.title', + defaultMessage: `编辑${props.values.name}`, + })} + open={props.updateModalOpen} + form={form} + autoFocusFirstInput + modalProps={{ + destroyOnClose: true, + onCancel: () => props.handleModal(), + }} + submitTimeout={2000} + onFinish={async (values) => { + console.log(values); + // putDeviceCategoryUpdateDeviceCategory(values) + // .then(() => { + // message.success(intl.formatMessage({ id: 'common.success', defaultMessage: '$$$' })); + // props.reload(); + // }) + // .catch(() => { + // message.error(intl.formatMessage({ id: 'common.failure', defaultMessage: '$$$' })); + // }); + + // props.handleModal(); + // return true; + }} + > + + {/* } + placeholder={`${intl.formatMessage({ + id: 'common.please_input', + defaultMessage: '$$$', + })}${intl.formatMessage({ + id: 'alarm_rules.page.form.enabled', + defaultMessage: '$$$', + })}`} + required={false} + initialValue={props.values.enabled} + disabled={false} + /> */} + + } + checkedChildren="启用" + unCheckedChildren="关闭" + initialValue={props.values.isEnabled} + disabled={false} + /> + } + placeholder={`${intl.formatMessage({ + id: 'common.please_input', + defaultMessage: '$$$', + })}${intl.formatMessage({ + id: 'alarm_rules.page.form.name', + defaultMessage: '$$$', + })}`} + required={true} + initialValue={props.values.name} + disabled={false} + rules={[ + { + required: true, + message: ( + + ), + }, + ]} + /> + {/* } + placeholder={`${intl.formatMessage({ + id: 'common.please_select', + defaultMessage: '$$$', + })}${intl.formatMessage({ + id: 'alarm.setting.table.list.level', + defaultMessage: '$$$', + })}`} + required={false} + // TODO 在types中增加类型注释 + initialValue={props.values?.level} + debounceTime={1000} + request={async () => { + // TODO 此处需要使用告警级别接口联调 + const resp = await postDeviceGroupGetDeviceGroupFkSelect({}); + return resp.data.list.map((v: any) => { + return { + label: v.name, + value: v.id, + }; + }); + }} + /> */} + {/* } + placeholder={`${intl.formatMessage({ + id: 'common.please_input', + defaultMessage: '$$$', + })}${intl.formatMessage({ + id: 'alarm_rules.page.form.triggerConditions', + defaultMessage: '$$$', + })}`} + required={false} + initialValue={props.values.triggerConditions} + disabled={false} + /> */} + ({ + list: value, + startTime: value[0], + endTime: value[1], + })} + className={styles} + > + 当检测到风险人员单人,于} + placeholder={`${intl.formatMessage({ + id: 'common.please_input', + defaultMessage: '$$$', + })}${intl.formatMessage({ + id: 'alarm_rules.page.form.triggerConditions', + defaultMessage: '$$$', + })}`} + required={false} + initialValue={props.values.time1} + disabled={false} + />小时内,间隔 + } + placeholder={`${intl.formatMessage({ + id: 'common.please_input', + defaultMessage: '$$$', + })}${intl.formatMessage({ + id: 'alarm_rules.page.form.triggerConditions', + defaultMessage: '$$$', + })}`} + required={false} + initialValue={props.values.time2} + disabled={false} + />小时,重复出现 + } + placeholder={`${intl.formatMessage({ + id: 'common.please_input', + defaultMessage: '$$$', + })}${intl.formatMessage({ + id: 'alarm_rules.page.form.triggerConditions', + defaultMessage: '$$$', + })}`} + required={false} + initialValue={props.values.time3} + disabled={false} + /> + 次,则触发警告。 + + + + + ); +}; +export default UpdateForm; diff --git a/src/pages/Alarm/alarmRules/components/updateForm.less b/src/pages/Alarm/alarmRules/components/updateForm.less new file mode 100644 index 0000000..8152d29 --- /dev/null +++ b/src/pages/Alarm/alarmRules/components/updateForm.less @@ -0,0 +1,8 @@ +:global { + .ant-form-item-control-input-content { + .ant-space-gap-col-small { + align-items: center; + } + + } +} diff --git a/src/pages/Alarm/alarmRules/index.tsx b/src/pages/Alarm/alarmRules/index.tsx new file mode 100644 index 0000000..6ff3fb5 --- /dev/null +++ b/src/pages/Alarm/alarmRules/index.tsx @@ -0,0 +1,233 @@ +import AlarmLevelBox from '@/components/DictionaryBox/alarmLevel'; +import TableActionCard from '@/components/TableActionCard'; +import IsDelete from '@/components/TableActionCard/isDelete'; +import { alarmLevelStatusEnum } from '@/enums/status'; +import { + deleteDeviceCategoryDeleteDeviceCategory, + postDeviceCategoryGetDeviceCategoryList, +} from '@/services/device/DeviceCategory'; +import type { ActionType, ProColumns } from '@ant-design/pro-components'; +import { PageContainer, ProTable } from '@ant-design/pro-components'; +import { FormattedMessage, useIntl } from '@umijs/max'; +import { Button, Space, Tag, message } from 'antd'; +import React, { useRef, useState } from 'react'; +import { proTablePaginationOptions } from '../../../../config/defaultTable'; +import { proIconForTableActionStyle } from '../../../../config/defaultIcon'; +import { EditOutlined } from '@ant-design/icons'; +import UpdateForm from './components/UpdateForm'; +const AlarmRulesList: React.FC = () => { + /** + * @en-US International configuration + * @zh-CN 国际化配置 + * */ + const intl = useIntl(); + const actionRef = useRef(); + // 动态设置每页数量 + const [currentPageSize, setCurrentPageSize] = useState(10); + + const handleDestroy = async (selectedRow: API.DeviceCategory) => { + deleteDeviceCategoryDeleteDeviceCategory({ id: selectedRow.id }) + .then(() => { + message.success(intl.formatMessage({ id: 'common.success', defaultMessage: '$$$' })); + actionRef.current?.reload(); + }) + .catch(() => { + message.error(intl.formatMessage({ id: 'common.failure', defaultMessage: '$$$' })); + }); + }; + + const [currentRow, setCurrentRow] = useState(); + // 编辑弹框 + const [updateModalOpen, setUpdateModalOpen] = useState(false); + + const handleUpdateModal = () => { + if (updateModalOpen) { + setUpdateModalOpen(false); + setCurrentRow(undefined); + } else { + setUpdateModalOpen(true); + } + }; + + const getAlarmRulesList = async () => { + return { + code: 0, + success: true, + data: { + "list": [ + { + "id": 1, + "createTime": "2023-10-17T02:35:41.14308Z", + "updateTime": "2023-10-17T02:35:41.14308Z", + "name": "单人徘徊告警", + "status": "已启用", + "isEnabled": true, + "remark": "" + }, + { + "id": 2, + "createTime": "2023-10-17T02:40:28.292883Z", + "updateTime": "2023-10-26T03:02:51.356036Z", + "name": "多人聚集告警", + "status": "未启用", + "isEnabled": false, + "remark": "" + }, + { + "id": 4, + "createTime": "2023-12-12T02:54:52.204957Z", + "updateTime": "2023-12-12T02:54:52.204957Z", + "name": "敏感时间段告警", + "status": "未启用", + "isEnabled": false, + "remark": "" + } + ], + "total": 3, + "page": 1, + "pageSize": 10 + }, + msg: "获取成功" + } + } + + const columns: ProColumns[] = [ + { + title: , + dataIndex: 'name', + hideInSearch: true, + }, + + { + title: , + dataIndex: 'id', + hideInSearch: true, + }, + { + title: , + dataIndex: 'status', + hideInSearch: true, + render: (dom) => { + return ( + + {dom} + + ); + }, + }, + { + title: , + dataIndex: 'updateTime', + sorter: true, + hideInSearch: true, + valueType: 'dateTime', + }, + + { + title: , + dataIndex: 'option', + valueType: 'option', + fixed: 'right', + render: (_, record) => [ + } + onClick={() => { + setUpdateModalOpen(true); + setCurrentRow(record); + }} + > + + + ), + }, + { + key: 'destroy', + renderDom: ( + { + handleDestroy(record).then(() => {}); + }} + > + ), + }, + ]} + >, + ], + }, + ]; + return ( + + + cardProps={{ + bodyStyle: { + padding: 20 + } + }} + options={{ fullScreen: false, setting: false, density: false, reload: false }} + actionRef={actionRef} + rowKey="key" + search={false} + pagination={{ + ...proTablePaginationOptions, + pageSize: currentPageSize, + onChange: (page, pageSize) => setCurrentPageSize(pageSize), + }} + columnsState={{ + persistenceKey: 'device_category_list', + persistenceType: 'localStorage', + }} + request={async (params = {}, sort) => { + const { current, ...rest } = params; + const reqParams = { + page: current, + desc: false, + orderKey: '', + ...rest, + }; + if (sort && Object.keys(sort).length) { + reqParams.orderKey = Object.keys(sort)[0]; + let sort_select = sort[reqParams.orderKey]; + reqParams.desc = sort_select === 'descend'; + } + // let resp = await postDeviceCategoryGetDeviceCategoryList({ ...reqParams }); + let resp = await getAlarmRulesList(); + return { + data: resp.data.list.map((v: API.DeviceCategory) => { + return { ...v, key: v.id }; + }), + success: resp.success, + total: resp.data.total, + current: resp.data.page, + pageSize: resp.data.pageSize, + }; + }} + columns={columns} + /> + + + ); +}; + +export default AlarmRulesList; diff --git a/src/pages/Setting/interfaceManage/components/CreateForm.tsx b/src/pages/Setting/interfaceManage/components/CreateForm.tsx new file mode 100644 index 0000000..52496b8 --- /dev/null +++ b/src/pages/Setting/interfaceManage/components/CreateForm.tsx @@ -0,0 +1,191 @@ +/** + * 接口管理新建弹框 + * + */ +import { postBusinessImageCreateBusinessImage } from '@/services/resource/BusinessImage'; +import { ModalForm, ProForm, ProFormText, ProFormTextArea } from '@ant-design/pro-components'; +import { FormattedMessage, useIntl } from '@umijs/max'; +import { Button, Form, message } from 'antd'; +import { proFormItemStyleProps, proFormModelWidth } from '../../../../../config/defaultForm'; +import React from 'react'; +export type FormValueType = { + target?: string; + template?: string; + type?: string; + time?: string; + frequency?: string; +} & Partial; + +export type CreateFormProps = { + createModalOpen: boolean; + handleModal: () => void; + values: Partial; + reload: any; +}; +const CreateForm: React.FC = (props) => { + const intl = useIntl(); + const [form] = Form.useForm(); + + return ( + + width={proFormModelWidth} + title={intl.formatMessage({ + id: 'resource.server_status.table.list.add', + defaultMessage: '$$$', + })} + open={props.createModalOpen} + form={form} + autoFocusFirstInput + modalProps={{ + destroyOnClose: true, + onCancel: () => props.handleModal(), + }} + submitTimeout={2000} + onFinish={async (values) => { + postBusinessImageCreateBusinessImage(values) + .then(() => { + message.success(intl.formatMessage({ id: 'common.success', defaultMessage: '$$$' })); + props.reload(); + }) + .catch(() => { + message.error(intl.formatMessage({ id: 'common.failure', defaultMessage: '$$$' })); + }); + props.handleModal(); + return true; + }} + > + + + + + + } + placeholder={`${intl.formatMessage({ + id: 'common.please_input', + defaultMessage: '$$$', + })}${intl.formatMessage({ + id: 'resource.server_status.table.list.name', + defaultMessage: '$$$', + })}`} + required={false} + rules={[ + { + required: true, + message: ( + + ), + }, + ]} + /> + + } + placeholder={`${intl.formatMessage({ + id: 'common.please_input', + defaultMessage: '$$$', + })}${intl.formatMessage({ + id: 'resource.server_status.table.list.userName', + defaultMessage: '$$$', + })}`} + required={false} + rules={[ + { + required: true, + message: ( + + ), + }, + ]} + /> + + } + placeholder={`${intl.formatMessage({ + id: 'common.please_input', + defaultMessage: '$$$', + })}${intl.formatMessage({ + id: 'resource.server_status.table.list.ip', + defaultMessage: '$$$', + })}`} + required={false} + /> + + } + placeholder={`${intl.formatMessage({ + id: 'common.please_input', + defaultMessage: '$$$', + })}${intl.formatMessage({ + id: 'resource.server_status.table.list.password', + defaultMessage: '$$$', + })}`} + required={false} + /> + + } + placeholder={`${intl.formatMessage({ + id: 'common.please_input', + defaultMessage: '$$$', + })}${intl.formatMessage({ + id: 'resource.server_status.table.list.defaultPort', + defaultMessage: '$$$', + })}`} + required={false} + /> + + } + placeholder={`${intl.formatMessage({ + id: 'common.please_input', + defaultMessage: '$$$', + })}${intl.formatMessage({ + id: 'resource.server_status.table.list.publicKeyString', + defaultMessage: '$$$', + })}`} + required={false} + /> + + + + ); +}; +export default CreateForm; diff --git a/src/pages/Setting/interfaceManage/components/UpdateForm.tsx b/src/pages/Setting/interfaceManage/components/UpdateForm.tsx new file mode 100644 index 0000000..84889ed --- /dev/null +++ b/src/pages/Setting/interfaceManage/components/UpdateForm.tsx @@ -0,0 +1,169 @@ +/* + * @Author: zhoux zhouxia@supervision.ltd + * @Date: 2023-11-01 13:56:33 + * @LastEditors: zhoux zhouxia@supervision.ltd + * @LastEditTime: 2023-12-26 15:01:08 + * @FilePath: \general-ai-platform-web\src\pages\Device\DeviceCategoryList\components\UpdateForm.tsx + * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE + */ +import { putDeviceCategoryUpdateDeviceCategory } from '@/services/device/DeviceCategory'; +import { postDeviceGroupGetDeviceGroupFkSelect } from '@/services/device/DeviceGroup'; +import { ModalForm, ProForm, ProFormFieldSet, ProFormSelect, ProFormSwitch, ProFormText } from '@ant-design/pro-components'; +import { FormattedMessage, useIntl } from '@umijs/max'; +import { Form, message } from 'antd'; +import React from 'react'; +import { + proFormSmallItemStyleProps, + proFormSmallModelWidth, +} from '../../../../../config/defaultForm'; +export type FormValueType = { + target?: string; + template?: string; + type?: string; + time?: string; + frequency?: string; +} & Partial; + +export type UpdateFormProps = { + updateModalOpen: boolean; + handleModal: () => void; + values: Partial; + reload: any; +}; +const UpdateForm: React.FC = (props) => { + const intl = useIntl(); + const [form] = Form.useForm(); + + return ( + + width={proFormSmallModelWidth} + title={intl.formatMessage({ + id: 'alarm_rules.page.form.title', + defaultMessage: `编辑${props.values.name}`, + })} + open={props.updateModalOpen} + form={form} + autoFocusFirstInput + modalProps={{ + destroyOnClose: true, + onCancel: () => props.handleModal(), + }} + submitTimeout={2000} + onFinish={async (values) => { + console.log(values); + // putDeviceCategoryUpdateDeviceCategory(values) + // .then(() => { + // message.success(intl.formatMessage({ id: 'common.success', defaultMessage: '$$$' })); + // props.reload(); + // }) + // .catch(() => { + // message.error(intl.formatMessage({ id: 'common.failure', defaultMessage: '$$$' })); + // }); + + // props.handleModal(); + // return true; + }} + > + + {/* } + placeholder={`${intl.formatMessage({ + id: 'common.please_input', + defaultMessage: '$$$', + })}${intl.formatMessage({ + id: 'alarm_rules.page.form.enabled', + defaultMessage: '$$$', + })}`} + required={false} + initialValue={props.values.enabled} + disabled={false} + /> */} + + } + checkedChildren="启用" + unCheckedChildren="关闭" + initialValue={props.values.isEnabled} + disabled={false} + /> + } + placeholder={`${intl.formatMessage({ + id: 'common.please_input', + defaultMessage: '$$$', + })}${intl.formatMessage({ + id: 'alarm_rules.page.form.name', + defaultMessage: '$$$', + })}`} + required={true} + initialValue={props.values.name} + disabled={false} + rules={[ + { + required: true, + message: ( + + ), + }, + ]} + /> + {/* } + placeholder={`${intl.formatMessage({ + id: 'common.please_select', + defaultMessage: '$$$', + })}${intl.formatMessage({ + id: 'alarm.setting.table.list.level', + defaultMessage: '$$$', + })}`} + required={false} + // TODO 在types中增加类型注释 + initialValue={props.values?.level} + debounceTime={1000} + request={async () => { + // TODO 此处需要使用告警级别接口联调 + const resp = await postDeviceGroupGetDeviceGroupFkSelect({}); + return resp.data.list.map((v: any) => { + return { + label: v.name, + value: v.id, + }; + }); + }} + /> */} + {/* } + placeholder={`${intl.formatMessage({ + id: 'common.please_input', + defaultMessage: '$$$', + })}${intl.formatMessage({ + id: 'alarm_rules.page.form.triggerConditions', + defaultMessage: '$$$', + })}`} + required={false} + initialValue={props.values.triggerConditions} + disabled={false} + /> */} + + + + ); +}; +export default UpdateForm; diff --git a/src/pages/Setting/interfaceManage/index.tsx b/src/pages/Setting/interfaceManage/index.tsx new file mode 100644 index 0000000..66c3de4 --- /dev/null +++ b/src/pages/Setting/interfaceManage/index.tsx @@ -0,0 +1,240 @@ +import AlarmLevelBox from '@/components/DictionaryBox/alarmLevel'; +import TableActionCard from '@/components/TableActionCard'; +import IsDelete from '@/components/TableActionCard/isDelete'; +import { alarmLevelStatusEnum } from '@/enums/status'; +import { + deleteDeviceCategoryDeleteDeviceCategory, + postDeviceCategoryGetDeviceCategoryList, +} from '@/services/device/DeviceCategory'; +import type { ActionType, ProColumns } from '@ant-design/pro-components'; +import { PageContainer, ProTable } from '@ant-design/pro-components'; +import { FormattedMessage, useIntl } from '@umijs/max'; +import { Button, Space, Tag, message } from 'antd'; +import React, { useRef, useState } from 'react'; +import { proTablePaginationOptions } from '../../../../config/defaultTable'; +import { proIconForTableActionStyle } from '../../../../config/defaultIcon'; +import { EditOutlined } from '@ant-design/icons'; +import UpdateForm from './components/UpdateForm'; +const InterfaceManageList: React.FC = () => { + /** + * @en-US International configuration + * @zh-CN 国际化配置 + * */ + const intl = useIntl(); + const actionRef = useRef(); + // 动态设置每页数量 + const [currentPageSize, setCurrentPageSize] = useState(10); + + const handleDestroy = async (selectedRow: API.DeviceCategory) => { + deleteDeviceCategoryDeleteDeviceCategory({ id: selectedRow.id }) + .then(() => { + message.success(intl.formatMessage({ id: 'common.success', defaultMessage: '$$$' })); + actionRef.current?.reload(); + }) + .catch(() => { + message.error(intl.formatMessage({ id: 'common.failure', defaultMessage: '$$$' })); + }); + }; + + const [currentRow, setCurrentRow] = useState(); + // 编辑弹框 + const [updateModalOpen, setUpdateModalOpen] = useState(false); + + const handleUpdateModal = () => { + if (updateModalOpen) { + setUpdateModalOpen(false); + setCurrentRow(undefined); + } else { + setUpdateModalOpen(true); + } + }; + + const getAlarmRulesList = async () => { + return { + code: 0, + success: true, + data: { + "list": [ + { + "id": 1, + "createTime": "2023-10-17T02:35:41.14308Z", + "updateTime": "2023-10-17T02:35:41.14308Z", + "name": "单人徘徊告警", + "address": "https://xxxx%E5%BC%80%E5%85%B3", + "isEnabled": true, + "remark": "" + }, + { + "id": 2, + "createTime": "2023-10-17T02:40:28.292883Z", + "updateTime": "2023-10-26T03:02:51.356036Z", + "name": "多人聚集告警", + "address": "https://xxxx%E5%BC%80%E5%85%B3", + "isEnabled": false, + "remark": "" + }, + { + "id": 4, + "createTime": "2023-12-12T02:54:52.204957Z", + "updateTime": "2023-12-12T02:54:52.204957Z", + "name": "敏感时间段告警", + "address": "https://xxxx%E5%BC%80%E5%85%B3", + "isEnabled": false, + "remark": "" + } + ], + "total": 3, + "page": 1, + "pageSize": 10 + }, + msg: "获取成功" + } + } + + const columns: ProColumns[] = [ + { + title: , + dataIndex: 'name', + hideInSearch: true, + }, + + { + title: , + dataIndex: 'address', + hideInSearch: true, + }, + { + title: , + dataIndex: 'createTime', + sorter: true, + hideInSearch: true, + valueType: 'dateTime', + }, + + { + title: , + dataIndex: 'option', + valueType: 'option', + fixed: 'right', + render: (_, record) => [ + } + onClick={() => { + setUpdateModalOpen(true); + setCurrentRow(record); + }} + > + + + ), + }, + { + key: 'destroy', + renderDom: ( + { + handleDestroy(record).then(() => {}); + }} + > + ), + }, + ]} + >, + ], + }, + ]; + return ( + + 接口管理 + { + // setCreateModalOpen(true); + }} + > + + + + } + > + + cardProps={{ + bodyStyle: { + padding: 20 + } + }} + options={{ fullScreen: false, setting: false, density: false, reload: false }} + actionRef={actionRef} + rowKey="key" + search={false} + pagination={{ + ...proTablePaginationOptions, + pageSize: currentPageSize, + onChange: (page, pageSize) => setCurrentPageSize(pageSize), + }} + columnsState={{ + persistenceKey: 'device_category_list', + persistenceType: 'localStorage', + }} + request={async (params = {}, sort) => { + const { current, ...rest } = params; + const reqParams = { + page: current, + desc: false, + orderKey: '', + ...rest, + }; + if (sort && Object.keys(sort).length) { + reqParams.orderKey = Object.keys(sort)[0]; + let sort_select = sort[reqParams.orderKey]; + reqParams.desc = sort_select === 'descend'; + } + // let resp = await postDeviceCategoryGetDeviceCategoryList({ ...reqParams }); + let resp = await getAlarmRulesList(); + return { + data: resp.data.list.map((v: API.DeviceCategory) => { + return { ...v, key: v.id }; + }), + success: resp.success, + total: resp.data.total, + current: resp.data.page, + pageSize: resp.data.pageSize, + }; + }} + columns={columns} + /> + + + ); +}; + +export default InterfaceManageList; diff --git a/src/pages/User/Login/index1.tsx b/src/pages/User/Login/index1.tsx index 9c1739e..94f4639 100644 --- a/src/pages/User/Login/index1.tsx +++ b/src/pages/User/Login/index1.tsx @@ -158,9 +158,10 @@ const Login: React.FC = () => { try { // 登录 //{username: "admin", password: "123456", captcha: "5531", captchaId: "GMeC0be8js61jFfbBaXz"} - const msg = await postBaseLogin({...values, captchaId: captchaId}) + // const msg = await postBaseLogin({...values, captchaId: captchaId}) - // const msg = await login({ ...values, type }); + const msg = await login({ ...values, type }); + console.log(msg); if (msg.success === true) { const defaultLoginSuccessMessage = intl.formatMessage({ id: 'pages.login.success', diff --git a/src/services/ant-design-pro/api.ts b/src/services/ant-design-pro/api.ts index cbd5961..94241db 100644 --- a/src/services/ant-design-pro/api.ts +++ b/src/services/ant-design-pro/api.ts @@ -25,7 +25,9 @@ export async function login(body: API.LoginParams, options?: { [key: string]: an return request('/api/login/account', { method: 'POST', headers: { - 'Content-Type': 'application/json', + Accept: "application/json, text/plain, */*", + "Content-Type": "application/json", + "X-Requested-With": "XMLHttpRequest" }, data: body, ...(options || {}), diff --git a/src/services/ant-design-pro/typings.d.ts b/src/services/ant-design-pro/typings.d.ts index 13e5a68..1b673c3 100644 --- a/src/services/ant-design-pro/typings.d.ts +++ b/src/services/ant-design-pro/typings.d.ts @@ -23,10 +23,16 @@ declare namespace API { phone?: string; }; + // type LoginResult = { + // status?: string; + // type?: string; + // currentAuthority?: string; + // }; type LoginResult = { - status?: string; - type?: string; - currentAuthority?: string; + code?: number; + success?: boolean; + data?: {}; + msg?: string; }; type PageParams = { diff --git a/src/services/system/Menu.ts b/src/services/system/Menu.ts index 3f92a06..326c540 100644 --- a/src/services/system/Menu.ts +++ b/src/services/system/Menu.ts @@ -29,7 +29,8 @@ export async function deleteMenuDeleteMenu(body: API.GetById, options?: { [key: /** 获取用户动态路由 POST /menu/getMenu */ export async function postMenuGetMenu(options?: { [key: string]: any }) { return request( - `/api/v1/menu/getMenu`, + // `/api/v1/menu/getMenu`, + `/api/mock/getMenus`, { method: 'POST', ...(options || {}), diff --git a/src/utils/FixMenuItemIcon.tsx b/src/utils/FixMenuItemIcon.tsx index 2917ca3..8e1e299 100644 --- a/src/utils/FixMenuItemIcon.tsx +++ b/src/utils/FixMenuItemIcon.tsx @@ -11,7 +11,9 @@ import {CarOutlined, UserOutlined, TableOutlined, BlockOutlined, DesktopOutlined, DatabaseOutlined, WarningOutlined, CalendarOutlined, ExperimentOutlined, ThunderboltOutlined, BugOutlined, AreaChartOutlined,ContactsOutlined, GatewayOutlined, BellOutlined, - PictureOutlined + PictureOutlined, + OrderedListOutlined, + BranchesOutlined } from '@ant-design/icons'; const iconMap:any = { @@ -37,7 +39,9 @@ const iconMap:any = { 'ContactsOutlined': , 'GatewayOutlined': , 'BellOutlined': , - 'PictureOutlined': + 'PictureOutlined': , + 'OrderedListOutlined':, + 'BranchesOutlined': } // FIX从接口获取菜单时icon为string类型 const fixMenuItemIcon = (menus: MenuDataItem[], iconType = 'Outlined'): MenuDataItem[] => {