From c825f53982a418b2e32eb556f2abb9f7a91e0c2a Mon Sep 17 00:00:00 2001 From: donghao Date: Tue, 28 May 2024 13:18:14 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E5=88=86=E7=B1=BB=E6=A8=A1=E5=9D=97?= =?UTF-8?q?=E8=81=94=E8=B0=83=E5=88=9D=E5=A7=8B=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/CategorizeUpdate/index.tsx | 49 +++-- .../DeviceGroup/components/deviceList.tsx | 45 +++- src/pages/Business/DeviceGroup/index.tsx | 10 +- src/pages/Model/ModelIndex/index.tsx | 38 +++- .../BusinessInfo/components/accountPsw.tsx | 16 +- .../BusinessInfo/components/baseInfo.tsx | 14 +- src/pages/Project/BusinessInfo/index.tsx | 38 ++-- src/services/business/basemodel.ts | 199 ++++++++++++++++++ src/services/business/device.ts | 60 ++++++ src/services/business/entity.ts | 112 +++++++++- src/utils/forApi.ts | 10 +- 11 files changed, 521 insertions(+), 70 deletions(-) diff --git a/src/components/CategorizeUpdate/index.tsx b/src/components/CategorizeUpdate/index.tsx index c2f78a8..2169877 100644 --- a/src/components/CategorizeUpdate/index.tsx +++ b/src/components/CategorizeUpdate/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-05-21 15:22:05 + * @LastEditTime: 2024-05-28 10:51:37 * @FilePath: \general-ai-manage\src\components\CategorizeUpdate\index.tsx * @Description: 分类更新弹窗 * @交互说明 @@ -14,13 +14,16 @@ import { PlusOutlined } from '@ant-design/icons'; import { ModalForm, ProForm } from '@ant-design/pro-components'; import type { InputRef } from 'antd'; -import { Flex, Form, Input, Tag, Tooltip } from 'antd'; +import { Flex, Form, Input, Tag, Tooltip, message } from 'antd'; import React, { useEffect, useRef, useState } from 'react'; import { proFormSmallModelWidth } from '../../../config/defaultForm'; + type CategorizeUpdateProps = { visible: boolean; values: Record; - apiSource: () => any; + beforeCloseRequest: (arg1: any, arg2: () => void) => void; + beforeAddRequest: (arg1: any, arg2: () => void) => void; + apiRequest: () => any; handleModal: (arg1: any) => void; modalFormProps: Record; // {categorizeFormProps , categorizeModelProps} }; @@ -36,6 +39,8 @@ const tagInputStyle: React.CSSProperties = { const CategorizeUpdate: React.FC = (props) => { const [form] = Form.useForm>(); const [tags, setTags] = useState([]); + const [fullData, setFullData] = useState[]>([]); + const [inputVisible, setInputVisible] = useState(false); const [inputValue, setInputValue] = useState(''); const [editInputIndex, setEditInputIndex] = useState(-1); @@ -44,8 +49,9 @@ const CategorizeUpdate: React.FC = (props) => { const editInputRef = useRef(null); async function loadData() { - const { data } = await props.apiSource(); + const { data } = await props.apiRequest(); const finalList = []; + setFullData(data?.data); data?.data?.forEach((v: Record) => { finalList.push(v.name); }); @@ -68,10 +74,14 @@ const CategorizeUpdate: React.FC = (props) => { } }, [props.visible]); - const handleClose = (removedTag: string) => { - const newTags = tags.filter((tag) => tag !== removedTag); - console.log(newTags); - setTags(newTags); + const handleClose = (removedTag: string, removedIndex: number) => { + props.beforeCloseRequest(fullData[removedIndex], (resp) => { + console.log(resp, 'beforeCloseRequest_resp'); + // 接口调用成功,同步删除 + const newTags = tags.filter((tag) => tag !== removedTag); + console.log(newTags); + setTags(newTags); + }); }; const showInput = () => { @@ -83,11 +93,24 @@ const CategorizeUpdate: React.FC = (props) => { }; const handleInputConfirm = () => { - if (inputValue && !tags.includes(inputValue)) { - setTags([...tags, inputValue]); + if (inputValue && inputValue.trim() && !tags.includes(inputValue)) { + props.beforeAddRequest(inputValue, (resp) => { + console.log(resp, 'beforeAddRequest_resp'); + // 接口调用成功,同步添加 + setTags([...tags, inputValue]); + setFullData([ + ...fullData, + { + name: inputValue, + ...resp.data, + }, + ]); + setInputVisible(false); + setInputValue(''); + }); + } else { + message.warning('名称为空或者已存在'); } - setInputVisible(false); - setInputValue(''); }; const handleEditInputChange = (e: React.ChangeEvent) => { @@ -152,7 +175,7 @@ const CategorizeUpdate: React.FC = (props) => { key={tag} closable={true} style={{ userSelect: 'none' }} - onClose={() => handleClose(tag)} + onClose={() => handleClose(tag, index)} > { diff --git a/src/pages/Business/DeviceGroup/components/deviceList.tsx b/src/pages/Business/DeviceGroup/components/deviceList.tsx index 9fb437c..6ecb9f4 100644 --- a/src/pages/Business/DeviceGroup/components/deviceList.tsx +++ b/src/pages/Business/DeviceGroup/components/deviceList.tsx @@ -2,22 +2,31 @@ * @Author: donghao donghao@supervision.ltd * @Date: 2024-04-22 15:23:36 * @LastEditors: donghao donghao@supervision.ltd - * @LastEditTime: 2024-05-21 15:24:53 + * @LastEditTime: 2024-05-28 11:45:44 * @FilePath: \general-ai-platform-web\src\pages\Business\DeviceGroup\components\deviceList.tsx * @Description: 设备节点设置 关键词 deviceGroup(dg) * @交互说明 - * 3、设备列表分页查看、新建、编辑、删除、设备分类、基础模型配置 - * 4、业务模型部 - * 5、企业告警设置122 + * 1、设备列表分页查看、新建、编辑、删除、设备分类、基础模型配置 + * 2、业务模型部署 + * 3、企业告警设置 + * 4、分类标记不可删除 + * 待定 + * 是否需要编辑 */ import InnerPageBack from '@/components/Back/innerPageBack'; -import { getDictDeviceType } from '@/services/testApi/dict'; +import { isSuccessApi } from '@/utils/forApi'; + +import { + apiDeviceClassification, + apiDeviceClassificationAdd, + apiDeviceClassificationDelete, +} from '@/services/business/device'; import TableActionCard from '@/components/TableActionCard'; import { getDeviceListByGroup } from '@/services/testApi/device'; import { ProTable } from '@ant-design/pro-components'; import { Access, FormattedMessage, history, useAccess, useIntl } from '@umijs/max'; -import { Button } from 'antd'; +import { Button, message } from 'antd'; import { useRef, useState } from 'react'; import { proTablePaginationOptions } from '../../../../../config/defaultTable'; @@ -183,6 +192,7 @@ const DeviceList: React.FC = () => { }, ]; + /**设备分类 */ return (
= () => { visible={deviceTypeOpen} handleModal={handleSetDeviceType} values={{ deviceType: [{ name: '', value: '' }] }} - apiSource={getDictDeviceType} + apiRequest={async () => { + let resp = await apiDeviceClassification(); + return { + data: resp.data, + }; + }} + beforeCloseRequest={async (params, successRes) => { + let resp = await apiDeviceClassificationDelete({ id: params.id }); + if (isSuccessApi(resp)) { + successRes(resp); + } else { + message.error(resp.meta.message); + } + }} + beforeAddRequest={async (params, successRes) => { + let resp = await apiDeviceClassificationAdd({ name: params }); + if (isSuccessApi(resp)) { + successRes(resp); + } else { + message.error(resp.meta.message); + } + }} modalFormProps={{ categorizeFormProps: { label: ( diff --git a/src/pages/Business/DeviceGroup/index.tsx b/src/pages/Business/DeviceGroup/index.tsx index 2937290..570e597 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-05-15 11:44:01 + * @LastEditTime: 2024-05-27 13:47:38 * @FilePath: \general-ai-platform-web\src\pages\Business\DeviceGroup\index.tsx * @Description: 设备节点设置 关键词 deviceGroup(dg) * @交互说明 @@ -14,6 +14,8 @@ */ import { DeviceGroupTree } from '@/components/Tree'; import { deviceGroupEnums } from '@/enums/device'; +import { isSuccessApi } from '@/utils/forApi'; + import { getDeviceGroupList } from '@/services/testApi/deviceGroup'; import { ProCard } from '@ant-design/pro-components'; import { Button, Tabs } from 'antd'; @@ -47,8 +49,10 @@ const DeviceGroup: React.FC = () => { async function loadDeviceTree() { const resp = await getDeviceGroupList({ pageNo: 1, pageSize: 100 }); console.log(resp.data, 'loadDeviceTree'); - setDeviceTreeList(resp?.data.data); - setNodeInfo(resp?.data.data[0]); + if (isSuccessApi(resp)) { + setDeviceTreeList(resp?.data.data); + setNodeInfo(resp?.data.data[0]); + } } // 新增 diff --git a/src/pages/Model/ModelIndex/index.tsx b/src/pages/Model/ModelIndex/index.tsx index e8c9955..0e0bd20 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-05-23 16:10:47 + * @LastEditTime: 2024-05-28 11:10:35 * @FilePath: \general-ai-manage\src\pages\ModelIndex\ModelIndex.tsx * @Description: 模型列表首页 * @交互说明 @@ -13,14 +13,19 @@ * */ 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 { + apiBasemodelClassificationAdd, + apiBasemodelClassificationDelete, + apiBasemodelClassificationList, + apiBasemodelList, +} from '@/services/business/basemodel'; +import { isSuccessApi } from '@/utils/forApi'; +import { ReactComponent as ResetIcon } from '/public/home/reset_icon.svg'; +import { ReactComponent as SearchIcon } from '/public/home/search_icon.svg'; + 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'; @@ -310,7 +315,7 @@ const ModelIndex: React.FC = () => { let sort_select = sort[reqParams.orderKey]; reqParams.desc = sort_select === 'descend'; } - let resp = await getModelList({ ...reqParams, ...querysData }); + let resp = await apiBasemodelList({ ...reqParams, ...querysData }); return { data: resp.data.data, success: resp.success, @@ -331,7 +336,24 @@ const ModelIndex: React.FC = () => { visible={industryOpen} handleModal={handleSetIndustry} values={{ industry: [{ name: '', value: '' }] }} - apiSource={getDictIndustry} + apiRequest={async () => { + let resp = await apiBasemodelClassificationList(); + return { + data: resp.data, + }; + }} + beforeCloseRequest={async (params, successRes) => { + let resp = await apiBasemodelClassificationDelete({ id: params.id }); + if (isSuccessApi(resp)) { + successRes(resp); + } + }} + beforeAddRequest={async (params, successRes) => { + let resp = await apiBasemodelClassificationAdd({ name: params }); + if (isSuccessApi(resp)) { + successRes(resp); + } + }} modalFormProps={{ categorizeFormProps: { label: ( diff --git a/src/pages/Project/BusinessInfo/components/accountPsw.tsx b/src/pages/Project/BusinessInfo/components/accountPsw.tsx index 96149f7..2d8786f 100644 --- a/src/pages/Project/BusinessInfo/components/accountPsw.tsx +++ b/src/pages/Project/BusinessInfo/components/accountPsw.tsx @@ -2,22 +2,28 @@ * @Author: donghao donghao@supervision.ltd * @Date: 2024-04-23 17:46:47 * @LastEditors: donghao donghao@supervision.ltd - * @LastEditTime: 2024-04-24 16:46:44 + * @LastEditTime: 2024-05-27 13:39:11 * @FilePath: \general-ai-platform-web\src\pages\Project\BusinessInfo\components\accountPsw.tsx * @Description: 账号密码 */ import { ProForm, ProFormText } from '@ant-design/pro-components'; import { FormattedMessage, useIntl } from '@umijs/max'; -import React from 'react'; +import React, { useEffect } from 'react'; type AccountPswProps = { info: Record; }; - -const AccountPsw: React.FC = () => { +// TODO 企业账号未获取到 +const AccountPsw: React.FC = (props) => { const [form] = ProForm.useForm(); // form 对象 const intl = useIntl(); + useEffect(() => { + if (props.info) { + form.setFieldsValue(props.info); + } + }, [props.info]); + return ( = () => { id: 'common.please_input', defaultMessage: '$$$', })}${intl.formatMessage({ - id: 'business.list.table.form.name', + id: 'business_info.list.table.form.name', defaultMessage: '$$$', })}`} required={true} diff --git a/src/pages/Project/BusinessInfo/components/baseInfo.tsx b/src/pages/Project/BusinessInfo/components/baseInfo.tsx index e1ec3d8..1078519 100644 --- a/src/pages/Project/BusinessInfo/components/baseInfo.tsx +++ b/src/pages/Project/BusinessInfo/components/baseInfo.tsx @@ -2,7 +2,7 @@ * @Author: donghao donghao@supervision.ltd * @Date: 2024-04-23 17:00:00 * @LastEditors: donghao donghao@supervision.ltd - * @LastEditTime: 2024-05-14 10:20:13 + * @LastEditTime: 2024-05-27 13:33:14 * @FilePath: \general-ai-platform-web\src\pages\Project\BusinessInfo\components\baseInfo.tsx * @Description: 基本信息展示 * @@ -14,23 +14,23 @@ import { FormattedMessage } from '@umijs/max'; type BaseInfoProps = { info: Record; }; - +// TODO 行业信息、服务有效期未从接口获取到 const BaseInfo: React.FC = ({ info }) => { // 模型基本信息 const ModelDetailColumns = [ { title: , - dataIndex: 'industryName', + dataIndex: 'industry', }, { title: , - dataIndex: 'contacts', + dataIndex: 'contact', }, { title: ( ), - dataIndex: 'contactWay', + dataIndex: 'phone', }, { title: ( @@ -45,13 +45,13 @@ const BaseInfo: React.FC = ({ info }) => { title: , dataIndex: 'address', render: (_, record) => { - return record?.province + record?.city + record.address; + return record?.province + record?.city + record.addr; }, span: 4, }, { title: , - dataIndex: 'remark', + dataIndex: 'summary', span: 4, }, ]; diff --git a/src/pages/Project/BusinessInfo/index.tsx b/src/pages/Project/BusinessInfo/index.tsx index fadb095..0a98577 100644 --- a/src/pages/Project/BusinessInfo/index.tsx +++ b/src/pages/Project/BusinessInfo/index.tsx @@ -9,7 +9,9 @@ import { useBusinessInfo } from '@/hooks/useBusinessInfo'; import { useMoment } from '@/hooks/useMoment'; -import { getBusinessAlgorithmList, getBusinessDetail } from '@/services/testApi/businessProject'; +import { apiEntityInfo, apiEntityPwdcheck } from '@/services/business/entity'; +import { getBusinessAlgorithmList } from '@/services/testApi/businessProject'; + import { isSuccessApi } from '@/utils/forApi'; import { ProCard, ProList } from '@ant-design/pro-components'; import { Button } from 'antd'; @@ -31,16 +33,10 @@ const { formatTimeByDateType } = useMoment(); const BusinessInfo: React.FC = () => { //state const [detailInfo, setDetailInfo] = useState>({}); + const [pwdInfo, setPwdInfo] = useState>({}); + const { getStoreBusinessInfo } = useBusinessInfo(); const [updateModalOpen, setUpdateModalOpen] = useState(false); - // 未启用 - /** - * @en-US International configuration - * @zh-CN 国际化配置 - * */ - // const access = useAccess(); - // const intl = useIntl(); - // const actionRef = useRef(); // 动态设置每页数量 const [currentPageSize, setCurrentPageSize] = useState(10); const [currentPage, setCurrentPage] = useState(1); @@ -73,12 +69,21 @@ const BusinessInfo: React.FC = () => { // 初始化加载 async function loadDetailData() { const { id } = getStoreBusinessInfo(); - const resp = await getBusinessDetail({ id }); + const resp = await apiEntityInfo({ id }); if (isSuccessApi(resp)) { setDetailInfo(resp?.data); } } + // 登录密码信息 + async function loadPwdInfo() { + const { id } = getStoreBusinessInfo(); + const resp = await apiEntityPwdcheck({ id }); + if (isSuccessApi(resp)) { + setPwdInfo(resp?.data); + } + } + // 算法列表 async function initList(tabId: string) { const reqParams = { @@ -89,10 +94,12 @@ const BusinessInfo: React.FC = () => { // ...rest, }; const resp = await getBusinessAlgorithmList({ ...reqParams }); - // console.log(resp,'resp'); - // setCurrentPageSize(resp?.data?.count) - setTotal(resp?.data?.count); - loadList(resp?.data?.data); + if (isSuccessApi(resp)) { + // console.log(resp,'resp'); + // setCurrentPageSize(resp?.data?.count) + setTotal(resp?.data?.count); + loadList(resp?.data?.data); + } } useEffect(() => { @@ -101,6 +108,7 @@ const BusinessInfo: React.FC = () => { useEffect(() => { loadDetailData(); + loadPwdInfo(); }, []); return (
@@ -137,7 +145,7 @@ const BusinessInfo: React.FC = () => {
账号信息}> - +
diff --git a/src/services/business/basemodel.ts b/src/services/business/basemodel.ts index e69de29..0439f03 100644 --- a/src/services/business/basemodel.ts +++ b/src/services/business/basemodel.ts @@ -0,0 +1,199 @@ +/* + * @Author: donghao donghao@supervision.ltd + * @Date: 2024-05-24 17:57:19 + * @LastEditors: donghao donghao@supervision.ltd + * @LastEditTime: 2024-05-28 11:03:42 + * @FilePath: \general-ai-platform-web\src\services\business\basemodel.ts + * @Description: 基础模型 + */ +// @ts-ignore +/* eslint-disable */ +import { request } from '@umijs/max'; + +/** 基础模型管理 */ +// 添加模型分类 +export async function apiBasemodelClassificationAdd(body: any, options?: { [key: string]: any }) { + return request( + `/api/v1/basemodel/classification/add`, + { + method: 'POST', + headers: { + // 'Content-Type': 'application/json', + // "Content-Type": "application/x-www-form-urlencoded; charset=UTF-8" + }, + data: body, + ...(options || {}), + }, + ); +} +// 模型分类列表 +export async function apiBasemodelClassificationList(body: any, options?: { [key: string]: any }) { + return request( + `/api/v1/basemodel/classification/list`, + { + method: 'POST', + headers: { + // 'Content-Type': 'application/json', + // "Content-Type": "application/x-www-form-urlencoded; charset=UTF-8" + }, + data: body, + ...(options || {}), + }, + ); +} +// 删除模型分类 +export async function apiBasemodelClassificationDelete( + body: any, + options?: { [key: string]: any }, +) { + return request( + `/api/v1/basemodel/classification/delete`, + { + method: 'POST', + headers: { + // 'Content-Type': 'application/json', + // "Content-Type": "application/x-www-form-urlencoded; charset=UTF-8" + }, + data: body, + ...(options || {}), + }, + ); +} +// 添加模型 +export async function apiBasemodelAdd(body: any, options?: { [key: string]: any }) { + return request( + `/api/v1/basemodel/add`, + { + method: 'POST', + headers: { + // 'Content-Type': 'application/json', + // "Content-Type": "application/x-www-form-urlencoded; charset=UTF-8" + }, + data: body, + ...(options || {}), + }, + ); +} +// 模型列表 +export async function apiBasemodelList(body: any, options?: { [key: string]: any }) { + return request( + `/api/v1/basemodel/list`, + { + method: 'POST', + headers: { + // 'Content-Type': 'application/json', + // "Content-Type": "application/x-www-form-urlencoded; charset=UTF-8" + }, + data: body, + ...(options || {}), + }, + ); +} +// 删除模型 +export async function apiBasemodelDelete(body: any, options?: { [key: string]: any }) { + return request( + `/api/v1/basemodel/delete`, + { + method: 'POST', + headers: { + // 'Content-Type': 'application/json', + // "Content-Type": "application/x-www-form-urlencoded; charset=UTF-8" + }, + data: body, + ...(options || {}), + }, + ); +} + +// 编辑模型 +export async function apiBasemodelEdit(body: any, options?: { [key: string]: any }) { + return request( + `/api/v1/basemodel/edit`, + { + method: 'POST', + headers: { + // 'Content-Type': 'application/json', + // "Content-Type": "application/x-www-form-urlencoded; charset=UTF-8" + }, + data: body, + ...(options || {}), + }, + ); +} +// 模型信息 +export async function apiBasemodelInfo(body: any, options?: { [key: string]: any }) { + return request( + `/api/v1/basemodel/info`, + { + method: 'POST', + headers: { + // 'Content-Type': 'application/json', + // "Content-Type": "application/x-www-form-urlencoded; charset=UTF-8" + }, + data: body, + ...(options || {}), + }, + ); +} + +// 添加模型版本 +export async function apiBasemodelVersionAdd(body: any, options?: { [key: string]: any }) { + return request( + `/api/v1/basemodel/version/add`, + { + method: 'POST', + headers: { + // 'Content-Type': 'application/json', + // "Content-Type": "application/x-www-form-urlencoded; charset=UTF-8" + }, + data: body, + ...(options || {}), + }, + ); +} +// 模型版本列表 +export async function apiBasemodelVersionList(body: any, options?: { [key: string]: any }) { + return request( + `/api/v1/basemodel/version/list`, + { + method: 'POST', + headers: { + // 'Content-Type': 'application/json', + // "Content-Type": "application/x-www-form-urlencoded; charset=UTF-8" + }, + data: body, + ...(options || {}), + }, + ); +} +// 删除模型版本 +export async function apiBasemodelVersionDelete(body: any, options?: { [key: string]: any }) { + return request( + `/api/v1/basemodel/version/delete`, + { + method: 'POST', + headers: { + // 'Content-Type': 'application/json', + // "Content-Type": "application/x-www-form-urlencoded; charset=UTF-8" + }, + data: body, + ...(options || {}), + }, + ); +} + +// 模型版本信息 +export async function apiBasemodelVersionInfo(body: any, options?: { [key: string]: any }) { + return request( + `/api/v1/basemodel/version/info`, + { + method: 'POST', + headers: { + // 'Content-Type': 'application/json', + // "Content-Type": "application/x-www-form-urlencoded; charset=UTF-8" + }, + data: body, + ...(options || {}), + }, + ); +} diff --git a/src/services/business/device.ts b/src/services/business/device.ts index e69de29..e90cdb3 100644 --- a/src/services/business/device.ts +++ b/src/services/business/device.ts @@ -0,0 +1,60 @@ +/* + * @Author: donghao donghao@supervision.ltd + * @Date: 2024-05-24 17:57:19 + * @LastEditors: donghao donghao@supervision.ltd + * @LastEditTime: 2024-05-27 14:54:19 + * @FilePath: \general-ai-platform-web\src\services\business\device.ts + * @Description: 设备 + */ +// @ts-ignore +/* eslint-disable */ +import { request } from '@umijs/max'; + +/** 企业设备 */ +// 添加设备分类 +export async function apiDeviceClassificationAdd(body: any, options?: { [key: string]: any }) { + return request( + `/api/v1/enterprise/device/classification/add`, + { + method: 'POST', + headers: { + // 'Content-Type': 'application/json', + // "Content-Type": "application/x-www-form-urlencoded; charset=UTF-8" + }, + data: body, + ...(options || {}), + }, + ); +} + +// 设备分类列表 +export async function apiDeviceClassification(body: any, options?: { [key: string]: any }) { + return request( + `/api/v1/enterprise/device/classification`, + { + method: 'POST', + headers: { + // 'Content-Type': 'application/json', + // "Content-Type": "application/x-www-form-urlencoded; charset=UTF-8" + }, + data: body, + ...(options || {}), + }, + ); +} + +// 删除设备分类 +export async function apiDeviceClassificationDelete(body: any, options?: { [key: string]: any }) { + return request( + `/api/v1/enterprise/device/classification/delete`, + { + method: 'POST', + headers: { + // 'Content-Type': 'application/json', + // "Content-Type": "application/x-www-form-urlencoded; charset=UTF-8" + }, + data: body, + ...(options || {}), + }, + ); +} diff --git a/src/services/business/entity.ts b/src/services/business/entity.ts index cee30db..9f94819 100644 --- a/src/services/business/entity.ts +++ b/src/services/business/entity.ts @@ -2,7 +2,7 @@ * @Author: donghao donghao@supervision.ltd * @Date: 2024-05-23 13:50:50 * @LastEditors: donghao donghao@supervision.ltd - * @LastEditTime: 2024-05-24 16:19:57 + * @LastEditTime: 2024-05-28 10:09:31 * @FilePath: \general-ai-platform-web\src\services\Business\entity.ts * @Description: api 实体 */ @@ -10,9 +10,9 @@ /* eslint-disable */ import { request } from '@umijs/max'; -/** 首页企业管理 /entity/index */ +/** 首页企业管理 & 企业详情 */ // 首页企业列表 -export async function apiEntityIndex(body: API.Login, options?: { [key: string]: any }) { +export async function apiEntityIndex(body: any, options?: { [key: string]: any }) { return request( `/api/v1/enterprise/entity/index`, { @@ -44,7 +44,7 @@ export async function apiEntityBaseCount(body: any, options?: { [key: string]: a } // 新建企业 -export async function apiEntityAdd(body: API.Login, options?: { [key: string]: any }) { +export async function apiEntityAdd(body: any, options?: { [key: string]: any }) { return request( `/api/v1/enterprise/entity/add`, { @@ -60,7 +60,7 @@ export async function apiEntityAdd(body: API.Login, options?: { [key: string]: a } // 企业信息 -export async function apiEntityInfo(body: API.Login, options?: { [key: string]: any }) { +export async function apiEntityInfo(body: any, options?: { [key: string]: any }) { return request( `/api/v1/enterprise/entity/info`, { @@ -76,7 +76,7 @@ export async function apiEntityInfo(body: API.Login, options?: { [key: string]: } // 编辑企业信息 -export async function apiEntityEdit(body: API.Login, options?: { [key: string]: any }) { +export async function apiEntityEdit(body: any, options?: { [key: string]: any }) { return request( `/api/v1/enterprise/entity/edit`, { @@ -91,8 +91,8 @@ export async function apiEntityEdit(body: API.Login, options?: { [key: string]: ); } -// 编辑企业信息 -export async function apiEntityDelete(body: API.Login, options?: { [key: string]: any }) { +// 删除企业信息 +export async function apiEntityDelete(body: any, options?: { [key: string]: any }) { return request( `/api/v1/enterprise/entity/delete`, { @@ -106,3 +106,99 @@ export async function apiEntityDelete(body: API.Login, options?: { [key: string] }, ); } + +// 企业登录密码信息 +export async function apiEntityPwdcheck(body: any, options?: { [key: string]: any }) { + return request( + `/api/v1/enterprise/entity/pwdcheck`, + { + method: 'POST', + headers: { + // 'Content-Type': 'application/json', + // "Content-Type": "application/x-www-form-urlencoded; charset=UTF-8" + }, + data: body, + ...(options || {}), + }, + ); +} +/** 企业节点设置 */ +// 添加企业节点 +export async function apiEntityNodesAdd(body: any, options?: { [key: string]: any }) { + return request( + `/api/v1/enterprise/entity/nodes/add`, + { + method: 'POST', + headers: { + // 'Content-Type': 'application/json', + // "Content-Type": "application/x-www-form-urlencoded; charset=UTF-8" + }, + data: body, + ...(options || {}), + }, + ); +} + +// 修改企业节点 +export async function apiEntityNodesEdit(body: any, options?: { [key: string]: any }) { + return request( + `/api/v1/enterprise/entity/nodes/edit`, + { + method: 'POST', + headers: { + // 'Content-Type': 'application/json', + // "Content-Type": "application/x-www-form-urlencoded; charset=UTF-8" + }, + data: body, + ...(options || {}), + }, + ); +} + +// 企业节点树 +export async function apiEntityNodes(body: any, options?: { [key: string]: any }) { + return request( + `/api/v1/enterprise/entity/nodes`, + { + method: 'POST', + headers: { + // 'Content-Type': 'application/json', + // "Content-Type": "application/x-www-form-urlencoded; charset=UTF-8" + }, + data: body, + ...(options || {}), + }, + ); +} + +// 删除企业节点树 +export async function apiEntityNodesDelete(body: any, options?: { [key: string]: any }) { + return request( + `/api/v1/enterprise/entity/nodes/delete`, + { + method: 'POST', + headers: { + // 'Content-Type': 'application/json', + // "Content-Type": "application/x-www-form-urlencoded; charset=UTF-8" + }, + data: body, + ...(options || {}), + }, + ); +} + +// 企业节点信息 +export async function apiEntityNodesInfo(body: any, options?: { [key: string]: any }) { + return request( + `/api/v1/enterprise/entity/nodes/info`, + { + method: 'POST', + headers: { + // 'Content-Type': 'application/json', + // "Content-Type": "application/x-www-form-urlencoded; charset=UTF-8" + }, + data: body, + ...(options || {}), + }, + ); +} diff --git a/src/utils/forApi.ts b/src/utils/forApi.ts index c660ed7..1e32668 100644 --- a/src/utils/forApi.ts +++ b/src/utils/forApi.ts @@ -2,7 +2,7 @@ * @Author: donghao donghao@supervision.ltd * @Date: 2024-04-24 10:11:48 * @LastEditors: donghao donghao@supervision.ltd - * @LastEditTime: 2024-04-24 10:17:21 + * @LastEditTime: 2024-05-27 14:00:45 * @FilePath: \general-ai-platform-web\src\utils\forApi.ts * @Description: 这是接口层和业务层的转换工具方法集 */ @@ -13,9 +13,11 @@ * @returns boolean */ export function isSuccessApi(result: API.API_COMMON_DATA): boolean { - const { meta } = result; - if (meta.code < 300 && meta.code >= 200) { - return true; + if (result && result?.meta) { + const { meta } = result; + if (meta.code < 300 && meta.code >= 200) { + return true; + } } return false; }