diff --git a/src/pages/Model/ModelIndex/components/industryUpdate.tsx b/src/components/CategorizeUpdate/index.tsx similarity index 77% rename from src/pages/Model/ModelIndex/components/industryUpdate.tsx rename to src/components/CategorizeUpdate/index.tsx index 31928a9..4f52c72 100644 --- a/src/pages/Model/ModelIndex/components/industryUpdate.tsx +++ b/src/components/CategorizeUpdate/index.tsx @@ -1,14 +1,28 @@ -import { getDictIndustry } from '@/services/testApi/dict'; +/* + * @Author: donghao donghao@supervision.ltd + * @Date: 2024-04-07 14:02:00 + * @LastEditors: donghao donghao@supervision.ltd + * @LastEditTime: 2024-04-30 14:57:45 + * @FilePath: \general-ai-manage\src\components\CategorizeUpdate\index.tsx + * @Description: 分类更新弹窗 + * @交互说明 + * 1. 分类展示 + * 2. 新增、删除(分类)功能 + * + */ + import { PlusOutlined } from '@ant-design/icons'; import { ModalForm, ProForm } from '@ant-design/pro-components'; -import { FormattedMessage, useIntl } from '@umijs/max'; import type { InputRef } from 'antd'; import { Flex, Form, Input, Tag, Tooltip } from 'antd'; import React, { useEffect, useRef, useState } from 'react'; -import { proFormSmallModelWidth } from '../../../../../config/defaultForm'; -type IndustryUpdateProps = { - industryOpen: boolean; - handleModal: () => void; +import { proFormSmallModelWidth } from '../../../config/defaultForm'; +type CategorizeUpdateProps = { + visible: boolean; + values: Record; + apiSource: () => any; + handleModal: (arg1: any) => void; + modalFormProps: Record; // {categorizeFormProps , categorizeModelProps} }; const tagInputStyle: React.CSSProperties = { @@ -19,8 +33,7 @@ const tagInputStyle: React.CSSProperties = { }; // TODO 整体样式需要按UI图调整 交互在确认时要把tags赋值给form -const IndustryUpdate: React.FC = (props) => { - const intl = useIntl(); +const CategorizeUpdate: React.FC = (props) => { const [form] = Form.useForm>(); const [tags, setTags] = useState([]); const [inputVisible, setInputVisible] = useState(false); @@ -31,7 +44,7 @@ const IndustryUpdate: React.FC = (props) => { const editInputRef = useRef(null); async function loadData() { - const { data } = await getDictIndustry(); + const { data } = await props.apiSource(); const finalList = []; data?.results?.forEach((v: Record) => { finalList.push(v.name); @@ -50,10 +63,10 @@ const IndustryUpdate: React.FC = (props) => { }, [editInputValue]); useEffect(() => { - if (props.industryOpen) { + if (props.visible) { loadData(); } - }, [props.industryOpen]); + }, [props.visible]); const handleClose = (removedTag: string) => { const newTags = tags.filter((tag) => tag !== removedTag); @@ -99,39 +112,24 @@ const IndustryUpdate: React.FC = (props) => { return ( > - className="gn_form mi_industry_update" + className="gn_form" width={proFormSmallModelWidth} - title={intl.formatMessage({ - id: 'model_index.table.list.setIndustry', - defaultMessage: '新建', - })} - open={props.industryOpen} + {...props?.modalFormProps?.categorizeModelProps} + open={props.visible} form={form} modalProps={{ destroyOnClose: true, onCancel: () => props.handleModal(), }} - initialValues={{ industry: [{ name: '', value: '' }] }} + initialValues={props.values} submitTimeout={2000} onFinish={async (values) => { console.log(values, 'add_finish_values'); - // TODO 对接新增接口 - // postModelCategoryCreateModelCategory(values) - // .then(() => { - // message.success(intl.formatMessage({ id: 'common.success', defaultMessage: '$$$' })); - // props.reload(); - // }) - // .catch(() => { - // message.error(intl.formatMessage({ id: 'common.failure', defaultMessage: '$$$' })); - // }); - props.handleModal(); + props.handleModal(form.getFieldsValue()); return true; }} > - } - name="industry" - > + {tags.map((tag, index) => { if (editInputIndex === index) { @@ -190,7 +188,7 @@ const IndustryUpdate: React.FC = (props) => { /> ) : ( } onClick={showInput}> - New Tag + 添加分类 )} @@ -199,4 +197,4 @@ const IndustryUpdate: React.FC = (props) => { ); }; -export default IndustryUpdate; +export default CategorizeUpdate; diff --git a/src/locales/zh-CN/device.ts b/src/locales/zh-CN/device.ts index 36647e9..b67e444 100644 --- a/src/locales/zh-CN/device.ts +++ b/src/locales/zh-CN/device.ts @@ -2,7 +2,7 @@ * @Author: zhoux zhouxia@supervision.ltd * @Date: 2023-11-01 13:56:33 * @LastEditors: donghao donghao@supervision.ltd - * @LastEditTime: 2024-04-29 17:37:55 + * @LastEditTime: 2024-04-30 14:50:56 * @FilePath: \general-ai-platform-web\src\locales\zh-CN\device.ts * @Description: 设备相关 */ @@ -20,7 +20,6 @@ export const device_group: { [key: string]: string } = { 'device_group.tree_node.remark': '简介', 'device_group.tree_node.createForm.add': '新建节点', // 未启用 - 'device_group.table.list.id': 'ID', 'device_group.table.list.name': '分组名称', 'device_group.table.list.code': '分组代码', @@ -47,13 +46,20 @@ export const device_group: { [key: string]: string } = { export const device_group_list: { [key: string]: string } = { 'device_group_list.table.list.name': '设备名称', - 'device_group_list.table.list.deviceType': '设备类型', + 'device_group_list.table.list.rule.required.name': '请填写设备名称', + 'device_group_list.table.list.deviceSite': '设备位置', + 'device_group_list.table.list.deviceType': '设备分类', + 'device_group_list.table.list.deviceModel': '设备型号', + 'device_group_list.table.list.deviceParams': '设备参数', + 'device_group_list.table.list.remark': '备注', 'device_group_list.table.list.isEnable': '模型部署', 'device_group_list.table.list.deployed.isEnable': '已部署', 'device_group_list.table.list.undeployed.isEnable': '未部署', 'device_group_list.table.list.action.setModel': '基础模型配置', 'device_group_list.table.list.action.new': '新建设备', - 'device_group_list.table.list.action.modelType': '设备分类', + 'device_group_list.table.list.action.deviceType': '设备分类', + 'device_group_list.table.list.add': '新建设备', + 'device_group_list.table.list.action.setDeviceType': '新建设备分类', // 未启用 'device_group_list.table.list.code': '设备代码', @@ -62,12 +68,10 @@ export const device_group_list: { [key: string]: string } = { 'device_group_list.table.list.spec': '设备规格', 'device_group_list.table.list.categoryFkId': '设备类别', 'device_group_list.table.list.groupFkId': '设备分组', - 'device_group_list.table.list.remark': '备注', 'device_group_list.table.list.createTime': '创建时间', 'device_group_list.table.list.updateTime': '更新时间', 'device_group_list.table.rule.required.name': '设备名称为必填项', 'device_group_list.table.rule.required.code': '设备代码为必填项', - 'device_group_list.table.list.add': '新建设备', 'device_group_list.table.list.update': '更新设备', }; export const device_category: { [key: string]: string } = { diff --git a/src/pages/Business/DeviceGroup/components/alarmSetForm.tsx b/src/pages/Business/DeviceGroup/components/alarmSetForm.tsx new file mode 100644 index 0000000..46a2486 --- /dev/null +++ b/src/pages/Business/DeviceGroup/components/alarmSetForm.tsx @@ -0,0 +1,159 @@ +/* + * @Author: donghao donghao@supervision.ltd + * @Date: 2024-04-30 10:02:29 + * @LastEditors: donghao donghao@supervision.ltd + * @LastEditTime: 2024-04-30 10:37:48 + * @FilePath: \general-ai-platform-web\src\pages\Business\DeviceGroup\components\alarmSetForm.tsx + * @Description: 告警设置 + * @交互说明 + * 1、通知方式选择 + * 2、通知频次选择 + */ +import { + ProForm, + ProFormCheckbox, + ProFormDependency, + ProFormGroup, + ProFormList, + ProFormRadio, + ProFormSelect, +} from '@ant-design/pro-components'; +import { Form } from 'antd'; +import { useEffect } from 'react'; +type AlarmSetFormProps = { + currentRow: Record; +}; +const AlarmSetForm: React.FC = (props) => { + const [form] = Form.useForm(); + + // const [initialValues, setInitialValues] = useState>({}); + + function fetchInitialValues() { + // setInitialValues({ + // type: '2', + // ways: [ + // { + // label: '短信', + // value: [], + // isChecked: [], + // }, + // { + // label: '邮件', + // value: [], + // isChecked: [], + // }, + // ] + // }); + } + useEffect(() => { + fetchInitialValues(); + }, []); + return ( + { + // TODO 提交告警设置调用api + console.log('onFinish_values', values); + // postProjectCreateProject(values) + // .then(() => { + // message.success(intl.formatMessage({ id: 'common.success', defaultMessage: '$$$' })); + // props.reload(); + // }) + // .catch(() => { + // message.error(intl.formatMessage({ id: 'common.failure', defaultMessage: '$$$' })); + // }); + // props.reload(); + return true; + }} + > + + + + {(f, index, action) => { + console.log('isChecked_value', f, index, action); + return ( +
+ + + + {({ isChecked }) => { + console.log(isChecked, 'isChecked'); + return ( + { + // const resp = await postCurrentIP(); + const resp = ['test001', 'test002', 'test003']; + return resp?.map((v: any) => { + return { + label: v, + value: v, + }; + }); + }} + /> + ); + }} + + +
+ ); + }} +
+
+
+ + + +
+ ); +}; + +export default AlarmSetForm; diff --git a/src/pages/Business/DeviceGroup/components/createDeviceForm.tsx b/src/pages/Business/DeviceGroup/components/createDeviceForm.tsx index 4e8ecad..8cdb58d 100644 --- a/src/pages/Business/DeviceGroup/components/createDeviceForm.tsx +++ b/src/pages/Business/DeviceGroup/components/createDeviceForm.tsx @@ -1,5 +1,11 @@ -// import { postModelCategoryCreateModelCategory } from '@/services/resource/ModelCategory'; -import { ModalForm, ProForm, ProFormText, ProFormTextArea } from '@ant-design/pro-components'; +import { getDictDeviceType } from '@/services/testApi/dict'; +import { + ModalForm, + ProForm, + ProFormSelect, + ProFormText, + ProFormTextArea, +} from '@ant-design/pro-components'; import { FormattedMessage, useIntl } from '@umijs/max'; import { Form } from 'antd'; import React from 'react'; @@ -24,7 +30,7 @@ const CreateDeviceForm: React.FC = (props) => { className="gn_modal_form gn_form" width={proFormSmallModelWidth} title={intl.formatMessage({ - id: 'device_group.tree_node.CreateDeviceForm.add', + id: 'device_group_list.table.list.add', defaultMessage: '新建', })} open={props.createModalOpen} @@ -54,12 +60,14 @@ const CreateDeviceForm: React.FC = (props) => { } + label={ + + } placeholder={`${intl.formatMessage({ id: 'common.please_input', defaultMessage: '$$$', })}${intl.formatMessage({ - id: 'device_group.tree_node.name', + id: 'device_group_list.table.list.name', defaultMessage: '$$$', })}`} required={true} @@ -68,7 +76,7 @@ const CreateDeviceForm: React.FC = (props) => { required: true, message: ( ), @@ -77,94 +85,94 @@ const CreateDeviceForm: React.FC = (props) => { /> + } placeholder={`${intl.formatMessage({ id: 'common.please_input', defaultMessage: '$$$', })}${intl.formatMessage({ - id: 'device_group.tree_node.fatherName', - defaultMessage: '$$$', - })}`} - disabled - /> - } - placeholder={`${intl.formatMessage({ - id: 'common.please_input', - defaultMessage: '$$$', - })}${intl.formatMessage({ - id: 'device_group.tree_node.address', + id: 'device_group_list.table.list.deviceSite', defaultMessage: '$$$', })}`} /> - } - placeholder={`${intl.formatMessage({ - id: 'common.please_input', - defaultMessage: '$$$', - })}${intl.formatMessage({ - id: 'device_group.tree_node.lon', - defaultMessage: '$$$', - })}`} - /> - } + name="deviceType" + label={ + + } placeholder={`${intl.formatMessage({ - id: 'common.please_input', + id: 'common.please_select', defaultMessage: '$$$', })}${intl.formatMessage({ - id: 'device_group.tree_node.lat', + id: 'device_group_list.table.list.deviceType', defaultMessage: '$$$', })}`} + showSearch + debounceTime={500} + request={async () => { + const { data } = await getDictDeviceType(); + return data?.results?.map((v: Record) => { + return { ...v, label: v.name, value: v.id }; + }); + }} /> - + } placeholder={`${intl.formatMessage({ id: 'common.please_input', defaultMessage: '$$$', })}${intl.formatMessage({ - id: 'device_group.tree_node.managerName', + id: 'device_group_list.table.list.deviceModel', defaultMessage: '$$$', })}`} /> + + } placeholder={`${intl.formatMessage({ id: 'common.please_input', defaultMessage: '$$$', })}${intl.formatMessage({ - id: 'device_group.tree_node.managerPhone', + id: 'device_group_list.table.list.deviceParams', defaultMessage: '$$$', })}`} /> + } + label={ + + } placeholder={`${intl.formatMessage({ id: 'common.please_input', defaultMessage: '$$$', })}${intl.formatMessage({ - id: 'device_group.tree_node.remark', + id: 'device_group_list.table.list.remark', defaultMessage: '$$$', })}`} /> diff --git a/src/pages/Business/DeviceGroup/components/deviceList.tsx b/src/pages/Business/DeviceGroup/components/deviceList.tsx index 6e412ba..9875d57 100644 --- a/src/pages/Business/DeviceGroup/components/deviceList.tsx +++ b/src/pages/Business/DeviceGroup/components/deviceList.tsx @@ -1,12 +1,27 @@ +/* + * @Author: donghao donghao@supervision.ltd + * @Date: 2024-04-22 15:23:36 + * @LastEditors: donghao donghao@supervision.ltd + * @LastEditTime: 2024-04-30 15:00:07 + * @FilePath: \general-ai-platform-web\src\pages\Business\DeviceGroup\components\deviceList.tsx + * @Description: 设备节点设置 关键词 deviceGroup(dg) + * @交互说明 + * 3、设备列表分页查看、新建、编辑、删除、设备分类、基础模型配置 + * 4、业务模型部 + * 5、企业告警设置122 + */ +import { getDictDeviceType } from '@/services/testApi/dict'; + import TableActionCard from '@/components/TableActionCard'; import { getDeviceListByGroup } from '@/services/testApi/device'; import { ProTable } from '@ant-design/pro-components'; -import { Access, FormattedMessage, history, useAccess } from '@umijs/max'; +import { Access, FormattedMessage, history, useAccess, useIntl } from '@umijs/max'; import { Button } from 'antd'; import { useRef, useState } from 'react'; import { proTablePaginationOptions } from '../../../../../config/defaultTable'; +import CategorizeUpdate from '@/components/CategorizeUpdate'; import IsDelete from '@/components/TableActionCard/isDelete'; import CreateDeviceForm from './createDeviceForm'; @@ -16,14 +31,21 @@ type DeviceListProps = { const DeviceList: React.FC = () => { const access = useAccess(); - // const intl = useIntl(); + // eslint-disable-next-line react-hooks/rules-of-hooks + const intl = useIntl(); const actionRef = useRef(); const [createModalOpen, setCreateModalOpen] = useState(false); // const [categoryFkIdIds, setCategoryFkIdIds] = useState([]); // 动态设置每页数量 const [currentPageSize, setCurrentPageSize] = useState(10); + // 设置分类 + const [deviceTypeOpen, setDeviceTypeOpen] = useState(false); + // 设置行业分类 + const handleSetDeviceType = () => { + setDeviceTypeOpen(!deviceTypeOpen); + }; /**新增 编辑 删除 */ // 新增 const handleCreateModal = () => { @@ -180,13 +202,13 @@ const DeviceList: React.FC = () => { /> @@ -239,6 +261,29 @@ const DeviceList: React.FC = () => { handleModal={handleCreateModal} reload={reloadList} /> + + ), + name: 'deviceType', + }, + categorizeModelProps: { + title: intl.formatMessage({ + id: 'device_group_list.table.list.action.setDeviceType', + defaultMessage: '新建', + }), + }, + }} + /> ); }; diff --git a/src/pages/Business/DeviceGroup/components/modelSetting.tsx b/src/pages/Business/DeviceGroup/components/modelSetting.tsx new file mode 100644 index 0000000..ac15ded --- /dev/null +++ b/src/pages/Business/DeviceGroup/components/modelSetting.tsx @@ -0,0 +1,158 @@ +/* + * @Author: donghao donghao@supervision.ltd + * @Date: 2024-04-30 10:02:29 + * @LastEditors: donghao donghao@supervision.ltd + * @LastEditTime: 2024-04-30 17:01:59 + * @FilePath: \general-ai-platform-web\src\pages\Business\DeviceGroup\components\modelSetting.tsx + * @Description: 业务模型部署 + * @交互说明 + * 1、业务模型部署列表的分页展示 + * 2、配置参数功能 + */ +import TableActionCard from '@/components/TableActionCard'; +import { getBusinessModelList } from '@/services/testApi/businessModel'; +import { ExclamationCircleFilled } from '@ant-design/icons'; +import type { ActionType, ProColumns } from '@ant-design/pro-components'; +import { ProTable } from '@ant-design/pro-components'; +import { FormattedMessage } from '@umijs/max'; +import { Button } from 'antd'; +import { useRef, useState } from 'react'; +import { + proTableCommonOptions, + proTablePaginationOptions, +} from '../../../../../config/defaultTable'; +// import CreateForm from './components/createForm'; + +const ModelSetting: React.FC = () => { + // const intl = useIntl(); + const actionRef = useRef(); + + // const [createModalOpen, setCreateModalOpen] = useState(false); + // const [categoryFkIdIds, setCategoryFkIdIds] = useState([]); + // 动态设置每页数量 + const [currentPageSize, setCurrentPageSize] = useState(10); + // const [currentRow, setCurrentRow] = useState>({}); + + /**配置参数 */ + + // function reloadList() { + // actionRef.current?.reload(); + // } + + // 业务模型列表信息 + const columns: ProColumns>[] = [ + { + title: , + dataIndex: 'name', + hideInSearch: true, + key: 'fixedName', + fixed: 'left', + }, + { + title: , + dataIndex: 'status', + hideInSearch: true, + }, + { + title: ( + + ), + dataIndex: 'createTime', + hideInSearch: true, + valueType: 'dateTime', + }, + + { + title: , + dataIndex: 'option', + valueType: 'option', + fixed: 'right', + key: 'option', + render: () => [ + { + // TODO 编辑在新增联调后实现 + // setCurrentRow(record); + }} + > + + + ), + }, + ]} + >, + ], + }, + ]; + return ( +
+
+ + 配置参数需关联具体设备请先至设备列表添加设备后再进行配置 +
+ { + console.log(data, 'onDataSourceChange_data'); + // let CategoryFkIdIds: any = data.map((v) => { + // return v.categoryFkId; + // }); + // setCategoryFkIdIds(CategoryFkIdIds); + }} + pagination={{ + ...proTablePaginationOptions, + pageSize: currentPageSize, + onChange: (page, pageSize) => setCurrentPageSize(pageSize), + }} + columnsState={{ + persistenceKey: 'algorithm_model_list', + persistenceType: 'localStorage', + }} + request={async (params = {}) => { + const { current, ...rest } = params; + const reqParams = { + page: current, + ...rest, + }; + let resp = await getBusinessModelList({ ...reqParams }); + console.log(resp, 'getModelVersionList_resp'); + return { + data: resp.data?.results.map((v: Record) => { + return { ...v, key: v.id }; + }), + success: resp.success, + total: resp.data.count, + current: current, + pageSize: currentPageSize, + }; + }} + columns={columns} + /> +
+ ); +}; + +export default ModelSetting; diff --git a/src/pages/Business/DeviceGroup/index.tsx b/src/pages/Business/DeviceGroup/index.tsx index e59db12..da3dc72 100644 --- a/src/pages/Business/DeviceGroup/index.tsx +++ b/src/pages/Business/DeviceGroup/index.tsx @@ -2,7 +2,7 @@ * @Author: donghao donghao@supervision.ltd * @Date: 2024-04-22 15:23:36 * @LastEditors: donghao donghao@supervision.ltd - * @LastEditTime: 2024-04-29 16:50:22 + * @LastEditTime: 2024-04-30 14:01:32 * @FilePath: \general-ai-platform-web\src\pages\Business\DeviceGroup\index.tsx * @Description: 设备节点设置 关键词 deviceGroup(dg) * @交互说明 @@ -18,9 +18,11 @@ import { getDeviceGroupList } from '@/services/testApi/deviceGroup'; import { ProCard } from '@ant-design/pro-components'; import { Button, Tabs } from 'antd'; import { useEffect, useState } from 'react'; +import AlarmSetForm from './components/alarmSetForm'; import BaseInfo from './components/baseInfo'; import CreateForm from './components/createForm'; import DeviceList from './components/deviceList'; +import ModelSetting from './components/modelSetting'; import './index.less'; @@ -117,6 +119,26 @@ const DeviceGroup: React.FC = () => { }} > {tabKey === '1' && } + {tabKey === '2' && } + {tabKey === '3' && ( + + )} diff --git a/src/pages/Model/ModelIndex/index.tsx b/src/pages/Model/ModelIndex/index.tsx index 799b7dc..71d1879 100644 --- a/src/pages/Model/ModelIndex/index.tsx +++ b/src/pages/Model/ModelIndex/index.tsx @@ -2,7 +2,7 @@ * @Author: donghao donghao@supervision.ltd * @Date: 2024-04-07 14:02:00 * @LastEditors: donghao donghao@supervision.ltd - * @LastEditTime: 2024-04-18 10:09:20 + * @LastEditTime: 2024-04-30 15:01:14 * @FilePath: \general-ai-manage\src\pages\ModelIndex\ModelIndex.tsx * @Description: 模型列表首页 * @交互说明 @@ -13,29 +13,32 @@ * */ import { CommButton } from '@/components/Button'; +import { getDictIndustry } from '@/services/testApi/dict'; import { ReactComponent as ResetIcon } from '/public/home/reset_icon.svg'; import { ReactComponent as SearchIcon } from '/public/home/search_icon.svg'; +import CategorizeUpdate from '@/components/CategorizeUpdate'; import TableActionCard from '@/components/TableActionCard'; import IsDelete from '@/components/TableActionCard/isDelete'; import { getModelList } from '@/services/testApi/model'; import { SearchOutlined } from '@ant-design/icons'; import type { ActionType, ProColumns } from '@ant-design/pro-components'; import { ProCard, ProForm, ProFormText, ProTable } from '@ant-design/pro-components'; -import { Access, FormattedMessage, history, useAccess } from '@umijs/max'; +import { Access, FormattedMessage, history, useAccess, useIntl } from '@umijs/max'; import { Button } from 'antd'; import React, { useEffect, useRef, useState } from 'react'; import { proTableCommonOptions, proTablePaginationOptions } from '../../../../config/defaultTable'; import CreateForm from './components/createForm'; -import IndustryUpdate from './components/industryUpdate'; import './index.less'; const ModelIndex: React.FC = () => { const access = useAccess(); - // const intl = useIntl(); + // eslint-disable-next-line react-hooks/rules-of-hooks + const intl = useIntl(); const actionRef = useRef(); const [querysData, setQuerysData] = useState>({}); // 列表查询参数 const [createModalOpen, setCreateModalOpen] = useState(false); + // 设置分类 const [industryOpen, setIndustryOpen] = useState(false); // const [categoryFkIdIds, setCategoryFkIdIds] = useState([]); @@ -54,11 +57,7 @@ const ModelIndex: React.FC = () => { }; // 设置行业分类 const handleSetIndustry = () => { - if (industryOpen) { - setIndustryOpen(false); - } else { - setIndustryOpen(true); - } + setIndustryOpen(!industryOpen); }; /** * @en-US The pop-up window of the distribution update window @@ -327,7 +326,26 @@ const ModelIndex: React.FC = () => { handleModal={handleCreateModal} reload={reloadList} /> - + + ), + name: 'industry', + }, + categorizeModelProps: { + title: intl.formatMessage({ + id: 'model_index.table.list.setIndustry', + defaultMessage: '新建', + }), + }, + }} + /> ); };