feat: 企业管理模块接口对接完成

develop2
donghao 9 months ago
parent 8bc9c4ff8e
commit e74a0739ac

@ -2,7 +2,7 @@
* @Author: donghao donghao@supervision.ltd
* @Date: 2024-03-27 14:56:27
* @LastEditors: donghao donghao@supervision.ltd
* @LastEditTime: 2024-04-19 16:51:36
* @LastEditTime: 2024-05-23 15:03:24
* @FilePath: \general-ai-manage\config\proxy.ts
* @Description:
*/
@ -31,7 +31,6 @@ export default {
// },
dev: {
// localhost:8000/api/** -> https://preview.pro.ant.design/api/**
'/api/v1/': {
// 要代理的地址
target: 'http://192.168.10.94:8999/',

@ -16,11 +16,11 @@ export default {
// 企业业务模型列表
'GET /api/businessModel/list': async (req: Request, res: Response) => {
// get 使用 query 读取参数
const { page, pageSize } = req.query;
const { pageNo, pageSize } = req.query;
const resData: successMockApiProps = {
...fetchCurrPageByList({
...mockGetBusinessModelListData,
data: { ...mockGetBusinessModelListData.data, page, pageSize: pageSize || 10 },
data: { ...mockGetBusinessModelListData.data, pageNo, pageSize: pageSize || 10 },
}),
};
res.json(resData);
@ -28,11 +28,11 @@ export default {
// 企业基础业务模型列表
'GET /api/businessModel/base/list': async (req: Request, res: Response) => {
// get 使用 query 读取参数
const { page, pageSize } = req.query;
const { pageNo, pageSize } = req.query;
const resData: successMockApiProps = {
...fetchCurrPageByList({
...mockGetBaseBusinessModelListData,
data: { ...mockGetBaseBusinessModelListData.data, page, pageSize: pageSize || 10 },
data: { ...mockGetBaseBusinessModelListData.data, pageNo, pageSize: pageSize || 10 },
}),
};
res.json(resData);

@ -1,28 +1,45 @@
/*
* @Author: donghao donghao@supervision.ltd
* @Date: 2024-04-19 17:10:21
* @LastEditors: donghao donghao@supervision.ltd
* @LastEditTime: 2024-05-24 13:41:34
* @FilePath: \general-ai-platform-web\mock\businessProject.ts
* @Description: ,`customMade`, koroFileHeader : https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
*/
import {
mockGetBusinessAlgorithmData,
mockGetBusinessBaseCountData,
mockGetBusinessProjectData,
} from './pools/businessProjectData';
import { successMockApiProps } from './typing';
import { fetchCurrPageByList, fetchMockSuccessFullByOther } from './utils/apiMock';
export default {
// 企业列表
'GET /api/businessProject/list': async (req: Request, res: Response) => {
'POST /api/v1/enterprise/entity/index': async (req: Request, res: Response) => {
// get 使用 query 读取参数
const { page, pageSize } = req.query;
const { pageNo, pageSize } = req.body;
const resData: successMockApiProps = {
...fetchCurrPageByList({
...mockGetBusinessProjectData,
data: { ...mockGetBusinessProjectData.data, page, pageSize: pageSize || 10 },
data: { ...mockGetBusinessProjectData.data, pageNo, pageSize: pageSize || 10 },
}),
};
res.json(resData);
res.send(resData);
},
//
'POST /api/v1/enterprise/entity/index/basecount': async (req: Request, res: Response) => {
const resData: successMockApiProps = {
...fetchMockSuccessFullByOther(mockGetBusinessBaseCountData),
};
res.send(resData);
},
// 企业详情
'GET /api/businessProject/detail': async (req: Request, res: Response) => {
// get 使用 query 读取参数
const { id } = req.query;
let finalData = {};
mockGetBusinessProjectData.data.results.forEach((item) => {
mockGetBusinessProjectData.data.data.forEach((item) => {
if (Number(item.id) === Number(id)) {
finalData = item;
// break;
@ -36,11 +53,11 @@ export default {
// 企业算法列表
'GET /api/businessProject/algorithm': async (req: Request, res: Response) => {
// get 使用 query 读取参数
const { page, pageSize } = req.query;
const { pageNo, pageSize } = req.query;
const resData: successMockApiProps = {
...fetchCurrPageByList({
...mockGetBusinessAlgorithmData,
data: { ...mockGetBusinessAlgorithmData.data, page, pageSize: pageSize || 10 },
data: { ...mockGetBusinessAlgorithmData.data, pageNo, pageSize: pageSize || 10 },
}),
};
res.json(resData);

@ -18,14 +18,14 @@ export default {
// 服务器列表
'GET /api/business/serverState/list': async (req: Request, res: Response) => {
// get 使用 query 读取参数
const { page, pageSize, status } = req.query;
const { pageNo, pageSize, status } = req.query;
let finalData = serverListData;
let { onlineCount, outlineCount } = serverListData.data;
if (status && ['1', '2'].includes(status)) {
onlineCount = 0;
outlineCount = 0;
let newArr = [];
serverListData.data.results.forEach((item) => {
serverListData.data.data.forEach((item) => {
if (status === item.state) {
newArr.push(item);
}
@ -41,14 +41,14 @@ export default {
...serverListData.data,
onlineCount,
outlineCount,
results: newArr,
data: newArr,
},
};
}
const resData: successMockApiProps = {
...fetchCurrPageByList({
...finalData,
data: { ...finalData.data, page, pageSize: pageSize || 10 },
data: { ...finalData.data, pageNo, pageSize: pageSize || 10 },
}),
};
res.json(resData);
@ -57,11 +57,11 @@ export default {
// 服务器日志分页列表
'GET /api/business/serverState/logList': async (req: Request, res: Response) => {
// get 使用 query 读取参数
const { page, pageSize } = req.query;
const { pageNo, pageSize } = req.query;
const resData: successMockApiProps = {
...fetchCurrPageByList({
...serverStateLogListData,
data: { ...serverStateLogListData.data, page, pageSize: pageSize || 10 },
data: { ...serverStateLogListData.data, pageNo, pageSize: pageSize || 10 },
}),
};
res.json(resData);
@ -70,7 +70,7 @@ export default {
// 设备列表
'GET /api/business/deviceState/list': async (req: Request, res: Response) => {
// get 使用 query 读取参数
const { page, pageSize, status } = req.query;
const { pageNo, pageSize, status } = req.query;
let finalData = deviceListData;
let { onlineCount, outlineCount, processCount, errorCount } = deviceListData.data;
if (status && ['1', '2', '3', '4'].includes(status)) {
@ -79,7 +79,7 @@ export default {
processCount = 0;
errorCount = 0;
let newArr = [];
deviceListData.data.results.forEach((item) => {
deviceListData.data.data.forEach((item) => {
if (status === item.state) {
newArr.push(item);
}
@ -106,14 +106,14 @@ export default {
outlineCount,
processCount,
errorCount,
results: newArr,
data: newArr,
},
};
}
const resData: successMockApiProps = {
...fetchCurrPageByList({
...finalData,
data: { ...finalData.data, page, pageSize: pageSize || 10 },
data: { ...finalData.data, pageNo, pageSize: pageSize || 10 },
}),
};
res.json(resData);
@ -122,11 +122,11 @@ export default {
// 服务器日志分页列表
'GET /api/business/deviceState/logList': async (req: Request, res: Response) => {
// get 使用 query 读取参数
const { page, pageSize } = req.query;
const { pageNo, pageSize } = req.query;
const resData: successMockApiProps = {
...fetchCurrPageByList({
...deviceStateLogListData,
data: { ...deviceStateLogListData.data, page, pageSize: pageSize || 10 },
data: { ...deviceStateLogListData.data, pageNo, pageSize: pageSize || 10 },
}),
};
res.json(resData);
@ -138,7 +138,7 @@ export default {
// // get 使用 query 读取参数
// const { id } = req.query;
// let finalData = {};
// serverListData.data.results.forEach((item) => {
// serverListData.data.data.forEach((item) => {
// if (Number(item.id) === Number(id)) {
// finalData = item;
// // break;

@ -14,11 +14,11 @@ import { fetchCurrPageByList, fetchMockSuccessFullByOther } from './utils/apiMoc
export default {
// 设备列表
'GET /api/device/listByGroup': async (req: Request, res: Response) => {
const { page, pageSize } = req.query;
const { pageNo, pageSize } = req.query;
const resData: successMockApiProps = {
...fetchCurrPageByList({
...mockGetDeviceListByGroup,
data: { ...mockGetDeviceListByGroup.data, page, pageSize: pageSize || 10 },
data: { ...mockGetDeviceListByGroup.data, pageNo, pageSize: pageSize || 10 },
}),
};
res.json(resData);

@ -20,11 +20,11 @@ import { fetchCurrPageByList, fetchMockSuccessFullByOther } from './utils/apiMoc
export default {
// 设备组列表分页
'GET /api/device_group/getDeviceGroupList': async (req: Request, res: Response) => {
const { page, pageSize } = req.query;
const { pageNo, pageSize } = req.query;
const resData: successMockApiProps = {
...fetchCurrPageByList({
...mockGetDeviceGroupListData,
data: { ...mockGetDeviceGroupListData.data, page, pageSize: pageSize || 10 },
data: { ...mockGetDeviceGroupListData.data, pageNo, pageSize: pageSize || 10 },
}),
};
res.json(resData);

@ -13,7 +13,7 @@ import { fetchMockSuccessFullByOther } from './utils/apiMock';
export default {
// 行业类别
'GET /api/dict/industry': async (req: Request, res: Response) => {
'GET /api/v1/dict/industry': async (req: Request, res: Response) => {
const resData: successMockApiProps = {
...fetchMockSuccessFullByOther(mockGetIndustryDictData),
};

@ -21,11 +21,11 @@ export default {
// 模型列表分页
'GET /api/model/list': async (req: Request, res: Response) => {
// get 使用 query 读取参数
const { page, pageSize } = req.query;
const { pageNo, pageSize } = req.query;
const resData: successMockApiProps = {
...fetchCurrPageByList({
...mockGetModelListData,
data: { ...mockGetModelListData.data, page, pageSize: pageSize || 10 },
data: { ...mockGetModelListData.data, pageNo, pageSize: pageSize || 10 },
}),
};
res.json(resData);
@ -35,7 +35,7 @@ export default {
// get 使用 query 读取参数
const { id } = req.query;
let finalData = {};
mockGetModelListData.data.results.forEach((item) => {
mockGetModelListData.data.data.forEach((item) => {
if (item.id === Number(id)) {
finalData = item;
// break;
@ -50,11 +50,11 @@ export default {
// 模型版本列表
'GET /api/model/versions/list': async (req: Request, res: Response) => {
// get 使用 query 读取参数
const { page, pageSize } = req.query;
const { pageNo, pageSize } = req.query;
const resData: successMockApiProps = {
...fetchCurrPageByList({
...mockGetModelVersionListData,
data: { ...mockGetModelVersionListData.data, page, pageSize: pageSize || 10 },
data: { ...mockGetModelVersionListData.data, pageNo, pageSize: pageSize || 10 },
}),
};
res.json(resData);
@ -63,11 +63,11 @@ export default {
// 模型运行库列表分页
'GET /api/model/runtimeLib/list': async (req: Request, res: Response) => {
// get 使用 query 读取参数
const { page, pageSize } = req.query;
const { pageNo, pageSize } = req.query;
const resData: successMockApiProps = {
...fetchCurrPageByList({
...mockGetModelRuntimeLibListData,
data: { ...mockGetModelRuntimeLibListData.data, page, pageSize: pageSize || 10 },
data: { ...mockGetModelRuntimeLibListData.data, pageNo, pageSize: pageSize || 10 },
}),
};
res.json(resData);

@ -2,7 +2,7 @@
* @Author: donghao donghao@supervision.ltd
* @Date: 2024-04-24 17:51:07
* @LastEditors: donghao donghao@supervision.ltd
* @LastEditTime: 2024-05-10 16:45:05
* @LastEditTime: 2024-05-23 16:14:57
* @FilePath: \general-ai-platform-web\mock\pools\businessModelData.ts
* @Description: mock
*/
@ -50,7 +50,7 @@ const startBusinessModelList = () => {
}
return {
count,
results: currList,
data: currList,
};
};
@ -79,7 +79,7 @@ const startBaseBusinessModelList = () => {
}
return {
count,
results: currList,
data: currList,
};
};

@ -2,7 +2,7 @@
* @Author: donghao donghao@supervision.ltd
* @Date: 2024-04-19 17:10:21
* @LastEditors: donghao donghao@supervision.ltd
* @LastEditTime: 2024-05-16 15:24:29
* @LastEditTime: 2024-05-24 13:41:44
* @FilePath: \general-ai-platform-web\mock\pools\businessProjectData.ts
* @Description:
*/
@ -14,7 +14,7 @@ export const mockGetBusinessProjectData = {
count: 7,
next: null,
previous: null,
results: [
data: [
{
id: '1',
name: '一名科技有限公司', // 公司名称
@ -106,19 +106,15 @@ export const mockGetBusinessProjectData = {
},
],
},
msg: null,
success: true,
status: 200,
};
/**@企业项目信息模块 */
// 企业算法列表
export const mockGetBusinessAlgorithmData = {
data: {
count: 5,
next: null,
previous: null,
results: [
data: [
{
id: '1',
name: '气泡缺陷检测', // 公司名称
@ -180,3 +176,14 @@ export const mockGetBusinessAlgorithmData = {
success: true,
status: 200,
};
// 企业基础数据统计
export const mockGetBusinessBaseCountData = {
data: {
data: {
entity: 123,
model: 456,
device: 789,
},
},
};

@ -93,7 +93,7 @@ const fetchServerList = () => {
}
return {
count,
results: currList,
data: currList,
onlineCount,
outlineCount,
};
@ -152,7 +152,7 @@ const fetchDeviceList = () => {
}
return {
count,
results: currList,
data: currList,
onlineCount,
outlineCount,
processCount,
@ -180,7 +180,7 @@ const fetchServerStateLogList = () => {
}
return {
count: currList.length,
results: currList,
data: currList,
};
};
@ -205,7 +205,7 @@ const fetchDeviceStateLogList = () => {
}
return {
count: currList.length,
results: currList,
data: currList,
};
};
/**服务器 */
@ -217,7 +217,7 @@ export const serverListData = {
export const serverParamsListData = {
data: {
results: progressData(),
data: progressData(),
},
};

@ -55,7 +55,7 @@ const fetchAllDeviceListByGroup = () => {
}
return {
count: currList.length,
results: currList,
data: currList,
};
};
@ -68,7 +68,7 @@ export const mockGetAllDeviceList = {
export const mockGetDeviceListByGroup = {
data: {
count: 2,
results: [
data: [
{
id: '10001',
name: '海康威视环球摄像头', // 设备名称
@ -96,7 +96,7 @@ export const mockGetDeviceListByGroup = {
remark: '精确定位装配部件的中心位置并检测可能的缺陷,确保装配精度。',
},
],
page: 1,
pageNo: 1,
pageSize: 10,
},
};

@ -289,7 +289,7 @@ export const mockGetDeviceGroupTreeData = {
// 设备组列表分页
export const mockGetDeviceGroupListData = {
data: {
results: [
data: [
{
level: 1,
id: '0001',
@ -363,7 +363,7 @@ export const mockGetDeviceGroupListData = {
},
],
count: 2,
page: 1,
pageNo: 1,
pageSize: 10,
},
};

@ -10,7 +10,7 @@
// 行业类别
export const mockGetIndustryDictData = {
data: {
results: [
data: [
{
id: 1001,
name: 'IT服务',
@ -191,7 +191,7 @@ export const mockGetIndustryDictData = {
// 设备分类
export const mockGetDeviceTypeDictData = {
data: {
results: [
data: [
{ id: 1002000, name: '摄像头' },
{ id: 1002002, name: '控制器' },
],

@ -24,7 +24,7 @@ const generatrModelRuntimeLib = () => {
}
return {
count,
results: currList,
data: currList,
};
};
@ -34,7 +34,7 @@ export const mockGetModelListData = {
count: 257,
next: null,
previous: null,
results: [
data: [
{
id: 1,
industry: '通用',
@ -3184,7 +3184,7 @@ export const mockGetModelRuntimeLibListData = {
// 模型运行库文件
export const mockGetModelRuntimeLibFilesListData = {
data: {
results: [
data: [
{
name: '2024011014302001.zip',
id: '001',
@ -3220,7 +3220,7 @@ const startModelVersionList = () => {
}
return {
count,
results: currList,
data: currList,
};
};
@ -3270,7 +3270,7 @@ const startGroupBaseModelList = () => {
}
return {
count,
results: currList,
data: currList,
};
};

@ -69,8 +69,15 @@ export default {
res.send(failData as failMockApiProps);
access = 'guest';
},
'POST /api/v1/logout': (req: Request, res: Response) => {
access = '';
res.send({ data: {}, success: true });
},
// TODO 以下未使用
// 获取用户信息
'GET /api/user/getUserInfo': async (req: Request, res: Response) => {
'GET /api/v1/userInfo': async (req: Request, res: Response) => {
const adminData: successMockApiProps = {
...fetchMockSuccessFullByOther(mockGetUserInfoData),
};
@ -91,11 +98,7 @@ export default {
};
res.send(resData);
},
// TODO 以下未使用
'POST /api/login/outLogin': (req: Request, res: Response) => {
access = '';
res.send({ data: {}, success: true });
},
// 支持值为 Object 和 Array
'GET /api/currentUser': (req: Request, res: Response) => {
if (!getAccess()) {

@ -2,7 +2,7 @@
* @Author: donghao donghao@supervision.ltd
* @Date: 2024-01-24 15:08:23
* @LastEditors: donghao donghao@supervision.ltd
* @LastEditTime: 2024-04-24 11:25:48
* @LastEditTime: 2024-05-23 15:42:03
* @FilePath: \general-ai-platform-web\mock\utils\apiMock.ts
* @Description: ,`customMade`, koroFileHeader : https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
*/
@ -31,11 +31,11 @@ export function fetchMockFailFullByOther({ data, msg }): failMockApiProps {
// 分页展示
export function fetchCurrPageByList({ data }): successMockApiProps {
console.log('fetchCurrPageByList_data', data);
const { page, pageSize } = data;
const prevPage = page - 1;
const { pageNo, pageSize } = data;
const prevPage = pageNo - 1;
const currPageData = {
...data,
results: data.results.slice(prevPage * pageSize, page * pageSize),
data: data.data.slice(prevPage * pageSize, pageNo * pageSize),
};
return fetchMockSuccessFullByOther({ data: currPageData });
}

@ -1,5 +1,4 @@
import { AvatarDropdown, AvatarName, MenuBar } from '@/components';
import { getUserGetUserInfo } from '@/services/system/User';
import fixMenuItemIcon from '@/utils/FixMenuItemIcon';
import { getAllRouteNameTile, replaceMenuWithRoutesData } from '@/utils/common';
import { addLocale } from '@@/plugin-locale';
@ -34,14 +33,41 @@ export async function getInitialState(): Promise<{
fetchUserInfo?: any;
menuData?: MenuDataItem[];
}> {
const fetchUserInfo = async () => {
try {
const msg = await getUserGetUserInfo();
return msg.data.userInfo;
} catch (error) {
history.push(loginPath);
}
return undefined;
// TODO userInfo 暂时定死,后续从接口获取
const fetchUserInfo = () => {
return {
id: 1,
createTime: '2023-10-08T16:02:30.775742+08:00',
updateTime: '2024-01-24T14:56:32.620573+08:00',
userName: 'admin',
nickName: '管理员1',
phone: '',
email: '',
avatarId: 1,
roleId: 1,
postId: null,
deptId: null,
access: 'admin',
roleIds: '1',
postIds: '',
remark: '',
enable: null,
lastLoginTime: '2024-01-24T14:56:32.620513+08:00',
roles: [
{
label: '管理员1',
value: 1,
},
],
avatarUrl: 'uploads/image/user/avatar/39c63ddb96a31b9610cd976b896ad4f0_20231016113731.jpg',
};
// try {
// const msg = await getUserGetUserInfo();
// return msg.data.userInfo;
// } catch (error) {
// history.push(loginPath);
// }
// return undefined;
};
// 如果不是登录页面,执行
const { location } = history;
@ -65,7 +91,7 @@ export async function getInitialState(): Promise<{
return {
fetchUserInfo,
currentUser: await fetchUserInfo(),
currentUser: fetchUserInfo(),
settings: {
...(defaultSettings as Partial<LayoutSettings>),
// menuData: replaceMenuWithRoutesData(menusData),

@ -317,7 +317,7 @@
}
/* Descriptions 描述展示 */
.gn_descriptions {
padding: 16px 16px 0;
padding: 16px 16px 4px;
background: #ffffff;
border: 1px solid rgba(21, 77, 221, 0.1);
border-radius: 4px;
@ -329,6 +329,10 @@
.gn_descriptions .ant-descriptions-item-content {
color: #333333;
}
.gn_descriptions .ant-descriptions .ant-descriptions-row > th,
.gn_descriptions .ant-descriptions .ant-descriptions-row > td {
padding-bottom: 12px;
}
.gn_active_descriptions {
background: #ebf3ff;
}
@ -348,7 +352,7 @@
color: #666666;
}
.gn_tabs.ant-tabs-top > .ant-tabs-nav::before {
border-bottom: 1px solid #E0E0E0;
border-bottom: 1px solid #e0e0e0;
}
/* table [ProTable ProList] */
.gn_pro_table .ant-table-wrapper .ant-table-thead > tr > th,
@ -409,11 +413,7 @@
background: transparent;
}
.ant-modal .ant-modal-content {
background-color: #fff;
background-image: url('../public/images/common/head.svg');
background-repeat: no-repeat;
background-position: top;
background-size: 100%;
background: url('../public/images/common/head.svg') no-repeat left top / cover, linear-gradient(180deg, #dde7ff 0%, #ffffff 24%);
}
.ant-modal .ant-pro-card {
background: transparent;

@ -389,7 +389,7 @@
/* Descriptions 描述展示 */
.gn_descriptions {
padding: 16px 16px 0;
padding: 16px 16px 4px;
background: #ffffff;
border: 1px solid rgba(21, 77, 221, 0.1);
border-radius: 4px;
@ -400,6 +400,10 @@
.ant-descriptions-item-content {
color: @text_color_1;
}
.ant-descriptions .ant-descriptions-row > th,
.ant-descriptions .ant-descriptions-row > td {
padding-bottom: 12px;
}
}
.gn_active_descriptions {
@ -501,11 +505,8 @@
background: transparent;
}
.ant-modal-content {
background-color: #fff;
background-image: url('../public/images/common/head.svg');
background-repeat: no-repeat;
background-position: top;
background-size: 100%;
background: url('../public/images/common/head.svg') no-repeat left top / cover,
linear-gradient(180deg, #dde7ff 0%, #ffffff 24%);
}
.ant-pro-card {
background: transparent;

@ -46,7 +46,7 @@ const CategorizeUpdate: React.FC<CategorizeUpdateProps> = (props) => {
async function loadData() {
const { data } = await props.apiSource();
const finalList = [];
data?.results?.forEach((v: Record<string, any>) => {
data?.data?.forEach((v: Record<string, any>) => {
finalList.push(v.name);
});
setTags(finalList);

@ -1,4 +1,4 @@
import { outLogin } from '@/services/ant-design-pro/api';
import { apiLoginOut } from '@/services/business/user';
import { LogoutOutlined } from '@ant-design/icons';
import { history, useModel } from '@umijs/max';
import { Spin } from 'antd';
@ -43,7 +43,7 @@ export const AvatarDropdown: React.FC<GlobalHeaderRightProps> = ({ children }) =
* 退 url
*/
const loginOut = async () => {
await outLogin();
await apiLoginOut();
const { search, pathname } = window.location;
const urlParams = new URL(window.location.href).searchParams;
/** 此方法会跳转到 redirect 参数所在的位置 */

@ -2,7 +2,7 @@
* @Author: donghao donghao@supervision.ltd
* @Date: 2024-04-19 17:10:21
* @LastEditors: donghao donghao@supervision.ltd
* @LastEditTime: 2024-04-24 15:05:21
* @LastEditTime: 2024-05-24 17:39:02
* @FilePath: \general-ai-platform-web\src\hooks\useCity.tsx
* @Description:
*/
@ -12,6 +12,9 @@ export type useCityProps = {
formatCityByProvinceData: (
arg1: Record<string, any>,
) => { label: string; value: string; children?: Record<string, any>[] }[];
formatCityByProvince: (
arg1: string,
) => { label: string; value: string; children?: Record<string, any>[] }[];
};
export const useCity: useCityProps = () => {
function formatProvinceByData() {
@ -33,8 +36,21 @@ export const useCity: useCityProps = () => {
return cityData;
}
function formatCityByProvince(arg1) {
const startData = formatProvinceByData();
let finalItem = startData[0];
startData.forEach((item) => {
if (item.value === arg1) {
finalItem = item;
}
});
const cityData = formatCityByProvinceData(finalItem);
return cityData;
}
return {
formatProvinceByData,
formatCityByProvinceData,
formatCityByProvince,
};
};

@ -0,0 +1,26 @@
/*
* @Author: donghao donghao@supervision.ltd
* @Date: 2024-05-24 10:22:49
* @LastEditors: donghao donghao@supervision.ltd
* @LastEditTime: 2024-05-24 11:37:29
* @FilePath: \general-ai-platform-web\src\hooks\useUploadFile.tsx
* @Description:
*/
export type useUploadFileProps = {
getBase64: (arg1: any) => Promise;
};
export const useUploadFile: useUploadFileProps = () => {
// 将文件转换为Base64编码
const getBase64 = (file) => {
return new Promise((resolve, reject) => {
const reader = new FileReader();
reader.readAsDataURL(file);
reader.onload = () => resolve(reader.result);
reader.onerror = (error) => reject(error);
});
};
return {
getBase64,
};
};

@ -11,7 +11,7 @@ export default {
'layout.user.link.help': 'Help',
'layout.user.link.privacy': 'Privacy',
'layout.user.link.terms': 'Terms',
'app.preview.down.block': 'Download this page to your local project',
'app.preview.down.block': 'Download this pageNo to your local project',
'app.welcome.link.fetch-blocks': 'Get all block',
'app.welcome.link.block-list': 'Quickly build standard, pages based on `block` development',
...globalHeader,

@ -2,13 +2,15 @@
* @Author: donghao donghao@supervision.ltd
* @Date: 2024-04-09 15:08:13
* @LastEditors: donghao donghao@supervision.ltd
* @LastEditTime: 2024-05-14 10:08:24
* @LastEditTime: 2024-05-24 15:04:05
* @FilePath: \general-ai-manage\src\locales\zh-CN\businessProject.ts
* @Description:
*/
// 企业项目列表
export const business_list: { [key: string]: string } = {
'business.list.table.createForm.add': '新建企业项目',
'business.list.table.createForm.title': '新建企业项目',
'business.list.table.editForm.title': '编辑企业项目',
'business.list.table.form.name': '公司全称',
'business.list.table.form.rule.required.name': '请填写公司全称',
'business.list.table.form.province': '省份',

@ -2,7 +2,7 @@
* @Author: zhoux zhouxia@supervision.ltd
* @Date: 2023-11-01 13:56:33
* @LastEditors: donghao donghao@supervision.ltd
* @LastEditTime: 2024-05-21 14:53:14
* @LastEditTime: 2024-05-24 14:50:03
* @FilePath: \general-ai-platform-web\src\locales\zh-CN\common.ts
* @Description: ,`customMade`, koroFileHeader : https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
*/
@ -17,8 +17,10 @@ export default {
'common.yes': '是',
'common.no': '否',
'common.success': '成功',
'common.action.success': '操作成功',
'common.error': '错误',
'common.failure': '失败',
'common.action.failure': '操作失败',
'common.permission.no_permission': '无权',
'common.permission.query': '查询',
'common.permission.update': '更改',

@ -10,7 +10,7 @@ const Admin: React.FC = () => {
<PageContainer
content={intl.formatMessage({
id: 'pages.admin.subPage.title',
defaultMessage: 'This page can only be viewed by admin',
defaultMessage: 'This pageNo can only be viewed by admin',
})}
>
<Card>

@ -95,9 +95,9 @@ const CreateForm: React.FC<CreateFormProps> = (props) => {
// todo disabled: !v?.defaultVersionFkId,设置 暂时设置为false 创建成功后报error
const getModelData = () => {
getBaseBusinessModelList({ keyword: '', page: 1, pageSize: 100 }).then((res) => {
getBaseBusinessModelList({ keyword: '', pageNo: 1, pageSize: 100 }).then((res) => {
console.log(66666, res.data);
let result = (res.data?.results || []).map((v: any) => {
let result = (res.data?.data || []).map((v: any) => {
console.log(v);
return {
key: v.id,
@ -362,13 +362,13 @@ const CreateForm: React.FC<CreateFormProps> = (props) => {
// postModelVersionCreateModelVersion(formData)
// .then(() => {
// message.success(
// intl.formatMessage({ id: 'common.success', defaultMessage: '$$$' }),
// intl.formatMessage({ id: 'common.action.success', defaultMessage: '$$$' }),
// );
// props.handleModal();
// props.reload();
// })
// .catch(() => {
// message.error(intl.formatMessage({ id: 'common.failure', defaultMessage: '$$$' }));
// message.error(intl.formatMessage({ id: 'common.action.failure', defaultMessage: '$$$' }));
// return false;
// });
}

@ -173,7 +173,7 @@ const BusinessModel: React.FC = () => {
pagination={{
...proTablePaginationOptions,
pageSize: currentPageSize,
onChange: (page, pageSize) => setCurrentPageSize(pageSize),
onChange: (pageNo, pageSize) => setCurrentPageSize(pageSize),
}}
columnsState={{
persistenceKey: 'algorithm_model_list',
@ -182,13 +182,13 @@ const BusinessModel: React.FC = () => {
request={async (params = {}) => {
const { current, ...rest } = params;
const reqParams = {
page: current,
pageNo: current,
...rest,
};
let resp = await getBusinessModelList({ ...reqParams });
console.log(resp, 'getModelVersionList_resp');
return {
data: resp.data?.results,
data: resp.data?.data,
success: resp.success,
total: resp.data.count,
current: current,

@ -227,7 +227,7 @@ const DetailDeviceState: React.FC<DetailDeviceStateProps> = ({ info, detailOpen,
async function fetchData() {
const resp = await getModelGroupBaseModelList();
if (isSuccessApi(resp)) {
toListDomByData(resp.data.results);
toListDomByData(resp.data.data);
}
}

@ -66,7 +66,7 @@ const DetailDeviceStateLog: React.FC = () => {
pagination={{
...proTablePaginationOptions,
pageSize: currentPageSize,
onChange: (page, pageSize) => setCurrentPageSize(pageSize),
onChange: (pageNo, pageSize) => setCurrentPageSize(pageSize),
}}
columnsState={{
persistenceKey: 'bs_server_log_list',
@ -75,13 +75,13 @@ const DetailDeviceStateLog: React.FC = () => {
request={async (params = {}) => {
const { current, ...rest } = params;
const reqParams = {
page: current,
pageNo: current,
...rest,
};
let resp = await getDeviceStateLogList({ ...reqParams });
console.log(resp, 'getDeviceStateLogList_resp');
return {
data: resp.data?.results,
data: resp.data?.data,
success: resp.success,
total: resp.data.count,
current: current,

@ -236,7 +236,7 @@ const DetailServerState: React.FC<DetailServerStateProps> = ({ info, detailOpen,
async function fetchData() {
const resp = await getModelGroupBaseModelList();
if (isSuccessApi(resp)) {
toListDomByData(resp.data.results);
toListDomByData(resp.data.data);
}
}

@ -65,7 +65,7 @@ const DetailServerStateLog: React.FC = () => {
pagination={{
...proTablePaginationOptions,
pageSize: currentPageSize,
onChange: (page, pageSize) => setCurrentPageSize(pageSize),
onChange: (pageNo, pageSize) => setCurrentPageSize(pageSize),
}}
columnsState={{
persistenceKey: 'bs_server_log_list',
@ -74,13 +74,13 @@ const DetailServerStateLog: React.FC = () => {
request={async (params = {}) => {
const { current, ...rest } = params;
const reqParams = {
page: current,
pageNo: current,
...rest,
};
let resp = await getServerStateLogList({ ...reqParams });
console.log(resp, 'getServerStateLogList_resp');
return {
data: resp.data?.results,
data: resp.data?.data,
success: resp.success,
total: resp.data.count,
current: current,

@ -108,13 +108,13 @@ const DeviceSate: React.FC = () => {
// 企业列表数据api
async function fetchData() {
const resp = await getDeviceStateList({
page: currentPage,
pageNo: currentPage,
pageSize: currentPageSize,
status: tabKey,
...querysData,
});
if (isSuccessApi(resp)) {
toListDomByData(resp.data.results);
toListDomByData(resp.data.data);
setTabs(() => {
const finalArr = [];
JSON.parse(JSON.stringify(deviceStateEnums)).forEach((item) => {
@ -232,7 +232,7 @@ const DeviceSate: React.FC = () => {
debounceTime={500}
request={async () => {
const { data } = await getDictDeviceType();
return data?.results?.map((v: Record<string, any>) => {
return data?.data?.map((v: Record<string, any>) => {
return { ...v, label: v.name, value: v.id };
});
}}
@ -267,12 +267,12 @@ const DeviceSate: React.FC = () => {
}}
pagination={{
...proTablePaginationOptions,
page: currentPage,
pageNo: currentPage,
pageSize: currentPageSize,
total: total || 0, // 指定总条目数
onChange: (page, pageSize) => {
onChange: (pageNo, pageSize) => {
setCurrentPageSize(pageSize);
setCurrentPage(page);
setCurrentPage(pageNo);
},
}}
rowSelection={false}

@ -112,12 +112,12 @@ const BusinessState: React.FC = () => {
// 企业列表数据api
async function fetchData() {
const resp = await getServerStateList({
page: currentPage,
pageNo: currentPage,
pageSize: currentPageSize,
status: tabKey,
});
if (isSuccessApi(resp)) {
toListDomByData(resp.data.results);
toListDomByData(resp.data.data);
setTabs(() => {
const finalArr = [];
JSON.parse(JSON.stringify(serverStateEnums)).forEach((item) => {
@ -204,12 +204,12 @@ const BusinessState: React.FC = () => {
}}
pagination={{
...proTablePaginationOptions,
page: currentPage,
pageNo: currentPage,
pageSize: currentPageSize,
total: total || 0, // 指定总条目数
onChange: (page, pageSize) => {
onChange: (pageNo, pageSize) => {
setCurrentPageSize(pageSize);
setCurrentPage(page);
setCurrentPage(pageNo);
},
}}
rowSelection={false}

@ -2,7 +2,7 @@
* @Author: donghao donghao@supervision.ltd
* @Date: 2024-04-30 10:02:29
* @LastEditors: donghao donghao@supervision.ltd
* @LastEditTime: 2024-05-21 16:12:06
* @LastEditTime: 2024-05-24 14:37:22
* @FilePath: \general-ai-platform-web\src\pages\Business\DeviceGroup\components\alarmSetForm.tsx
* @Description:
* @
@ -48,11 +48,11 @@ const AlarmSetForm: React.FC<AlarmSetFormProps> = (props) => {
console.log('onFinish_values', values);
// postProjectCreateProject(values)
// .then(() => {
// message.success(intl.formatMessage({ id: 'common.success', defaultMessage: '$$$' }));
// message.success(intl.formatMessage({ id: 'common.action.success', defaultMessage: '$$$' }));
// props.reload();
// })
// .catch(() => {
// message.error(intl.formatMessage({ id: 'common.failure', defaultMessage: '$$$' }));
// message.error(intl.formatMessage({ id: 'common.action.failure', defaultMessage: '$$$' }));
// });
// props.reload();
return true;

@ -46,11 +46,11 @@ const CreateDeviceForm: React.FC<CreateDeviceFormProps> = (props) => {
// TODO 对接新增接口
// postModelCategoryCreateModelCategory(values)
// .then(() => {
// message.success(intl.formatMessage({ id: 'common.success', defaultMessage: '$$$' }));
// message.success(intl.formatMessage({ id: 'common.action.success', defaultMessage: '$$$' }));
// props.reload();
// })
// .catch(() => {
// message.error(intl.formatMessage({ id: 'common.failure', defaultMessage: '$$$' }));
// message.error(intl.formatMessage({ id: 'common.action.failure', defaultMessage: '$$$' }));
// });
props.handleModal();
return true;
@ -121,7 +121,7 @@ const CreateDeviceForm: React.FC<CreateDeviceFormProps> = (props) => {
debounceTime={500}
request={async () => {
const { data } = await getDictDeviceType();
return data?.results?.map((v: Record<string, any>) => {
return data?.data?.map((v: Record<string, any>) => {
return { ...v, label: v.name, value: v.id };
});
}}

@ -41,11 +41,11 @@ const CreateForm: React.FC<CreateFormProps> = (props) => {
// TODO 对接新增接口
// postModelCategoryCreateModelCategory(values)
// .then(() => {
// message.success(intl.formatMessage({ id: 'common.success', defaultMessage: '$$$' }));
// message.success(intl.formatMessage({ id: 'common.action.success', defaultMessage: '$$$' }));
// props.reload();
// })
// .catch(() => {
// message.error(intl.formatMessage({ id: 'common.failure', defaultMessage: '$$$' }));
// message.error(intl.formatMessage({ id: 'common.action.failure', defaultMessage: '$$$' }));
// });
props.handleModal();
return true;

@ -160,13 +160,13 @@ const CreateModelParams: React.FC<CreateModelParamsProps> = (props) => {
// postModelVersionCreateModelVersion(formData)
// .then(() => {
// message.success(
// intl.formatMessage({ id: 'common.success', defaultMessage: '$$$' }),
// intl.formatMessage({ id: 'common.action.success', defaultMessage: '$$$' }),
// );
// props.handleModal();
// props.reload();
// })
// .catch(() => {
// message.error(intl.formatMessage({ id: 'common.failure', defaultMessage: '$$$' }));
// message.error(intl.formatMessage({ id: 'common.action.failure', defaultMessage: '$$$' }));
// return false;
// });
}
@ -382,7 +382,7 @@ const CreateModelParams: React.FC<CreateModelParamsProps> = (props) => {
debounceTime={500}
request={async () => {
const { data } = await getModelRuntimeLibFilesList();
return data?.results?.map((v: Record<string, any>) => {
return data?.data?.map((v: Record<string, any>) => {
return { ...v, label: v.name, value: v.id };
});
}}
@ -429,13 +429,13 @@ const CreateModelParams: React.FC<CreateModelParamsProps> = (props) => {
// postModelVersionCreateModelVersion(formData)
// .then(() => {
// message.success(
// intl.formatMessage({ id: 'common.success', defaultMessage: '$$$' }),
// intl.formatMessage({ id: 'common.action.success', defaultMessage: '$$$' }),
// );
// props.handleModal();
// props.reload();
// })
// .catch(() => {
// message.error(intl.formatMessage({ id: 'common.failure', defaultMessage: '$$$' }));
// message.error(intl.formatMessage({ id: 'common.action.failure', defaultMessage: '$$$' }));
// return false;
// });
}

@ -242,7 +242,7 @@ const DeviceList: React.FC<DeviceListProps> = () => {
pagination={{
...proTablePaginationOptions,
pageSize: currentPageSize,
onChange: (page, pageSize) => setCurrentPageSize(pageSize),
onChange: (pageNo, pageSize) => setCurrentPageSize(pageSize),
}}
columnsState={{
persistenceKey: 'algorithm_model_list',
@ -251,13 +251,13 @@ const DeviceList: React.FC<DeviceListProps> = () => {
request={async (params = {}) => {
const { current, ...rest } = params;
const reqParams = {
page: current,
pageNo: current,
...rest,
};
let resp = await getDeviceListByGroup({ ...reqParams });
console.log(resp, 'getDeviceListByGroup_resp');
return {
data: resp.data?.results,
data: resp.data?.data,
success: resp.success,
total: resp.data.count,
current: current,

@ -156,7 +156,7 @@ const ModelDeploy: React.FC = () => {
pagination={{
...proTablePaginationOptions,
pageSize: currentPageSize,
onChange: (page, pageSize) => setCurrentPageSize(pageSize),
onChange: (pageNo, pageSize) => setCurrentPageSize(pageSize),
}}
columnsState={{
persistenceKey: 'algorithm_model_list',
@ -165,13 +165,13 @@ const ModelDeploy: React.FC = () => {
request={async (params = {}) => {
const { current, ...rest } = params;
const reqParams = {
page: current,
pageNo: current,
...rest,
};
let resp = await getBusinessModelList({ ...reqParams });
console.log(resp, 'getModelVersionList_resp');
return {
data: resp.data?.results,
data: resp.data?.data,
success: resp.success,
total: resp.data.count,
current: current,

@ -162,7 +162,7 @@ const ModelDeployConfig: React.FC<ModelDeployConfigProps> = ({ info, detailOpen,
let resp = await getAllDeviceList();
console.log(resp, 'getAllDeviceList_resp');
return {
data: resp.data?.results,
data: resp.data?.data,
success: resp.success,
};
}}

@ -163,7 +163,7 @@ const ModelSetting: React.FC<ModelSettingProps> = () => {
async function fetchData() {
const resp = await getModelGroupBaseModelList();
if (isSuccessApi(resp)) {
toListDomByData(resp.data.results);
toListDomByData(resp.data.data);
}
}

@ -45,10 +45,10 @@ const DeviceGroup: React.FC = () => {
/**节点列表 */
// 设备节点树
async function loadDeviceTree() {
const resp = await getDeviceGroupList({ page: 1, pageSize: 100 });
const resp = await getDeviceGroupList({ pageNo: 1, pageSize: 100 });
console.log(resp.data, 'loadDeviceTree');
setDeviceTreeList(resp?.data.results);
setNodeInfo(resp?.data.results[0]);
setDeviceTreeList(resp?.data.data);
setNodeInfo(resp?.data.data[0]);
}
// 新增

@ -317,13 +317,13 @@ const CreateForm: React.FC<CreateFormProps> = (props) => {
// postModelVersionCreateModelVersion(formData)
// .then(() => {
// message.success(
// intl.formatMessage({ id: 'common.success', defaultMessage: '$$$' }),
// intl.formatMessage({ id: 'common.action.success', defaultMessage: '$$$' }),
// );
// props.handleModal();
// props.reload();
// })
// .catch(() => {
// message.error(intl.formatMessage({ id: 'common.failure', defaultMessage: '$$$' }));
// message.error(intl.formatMessage({ id: 'common.action.failure', defaultMessage: '$$$' }));
// return false;
// });
}

@ -288,7 +288,7 @@ const ModelDetail: React.FC = () => {
pagination={{
...proTablePaginationOptions,
pageSize: currentPageSize,
onChange: (page, pageSize) => setCurrentPageSize(pageSize),
onChange: (pageNo, pageSize) => setCurrentPageSize(pageSize),
}}
columnsState={{
persistenceKey: 'algorithm_model_list',
@ -297,13 +297,13 @@ const ModelDetail: React.FC = () => {
request={async (params = {}) => {
const { current, ...rest } = params;
const reqParams = {
page: current,
pageNo: current,
...rest,
};
let resp = await getModelVersionList({ ...reqParams });
console.log(resp, 'getModelVersionList_resp');
return {
data: resp.data?.results,
data: resp.data?.data,
success: resp.success,
total: resp.data.count,
current: current,

@ -54,11 +54,11 @@ const CreateForm: React.FC<CreateFormProps> = (props) => {
// TODO 对接新增接口
// postModelCategoryCreateModelCategory(values)
// .then(() => {
// message.success(intl.formatMessage({ id: 'common.success', defaultMessage: '$$$' }));
// message.success(intl.formatMessage({ id: 'common.action.success', defaultMessage: '$$$' }));
// props.reload();
// })
// .catch(() => {
// message.error(intl.formatMessage({ id: 'common.failure', defaultMessage: '$$$' }));
// message.error(intl.formatMessage({ id: 'common.action.failure', defaultMessage: '$$$' }));
// });
props.handleModal();
return true;
@ -113,7 +113,7 @@ const CreateForm: React.FC<CreateFormProps> = (props) => {
debounceTime={500}
request={async () => {
const { data } = await getDictIndustry();
return data?.results?.map((v: Record<string, any>) => {
return data?.data?.map((v: Record<string, any>) => {
return { ...v, label: v.name, value: v.id };
});
}}

@ -2,7 +2,7 @@
* @Author: donghao donghao@supervision.ltd
* @Date: 2024-04-07 14:02:00
* @LastEditors: donghao donghao@supervision.ltd
* @LastEditTime: 2024-05-20 13:25:17
* @LastEditTime: 2024-05-23 16:10:47
* @FilePath: \general-ai-manage\src\pages\ModelIndex\ModelIndex.tsx
* @Description:
* @
@ -291,7 +291,7 @@ const ModelIndex: React.FC = () => {
pagination={{
...proTablePaginationOptions,
pageSize: currentPageSize,
onChange: (page, pageSize) => setCurrentPageSize(pageSize),
onChange: (pageNo, pageSize) => setCurrentPageSize(pageSize),
}}
columnsState={{
persistenceKey: 'algorithm_model_list',
@ -300,7 +300,7 @@ const ModelIndex: React.FC = () => {
request={async (params = {}, sort) => {
const { current, ...rest } = params;
const reqParams = {
page: current,
pageNo: current,
desc: false,
orderKey: '',
...rest,
@ -312,7 +312,7 @@ const ModelIndex: React.FC = () => {
}
let resp = await getModelList({ ...reqParams, ...querysData });
return {
data: resp.data.results,
data: resp.data.data,
success: resp.success,
total: resp.data.count,
current: current,

@ -56,11 +56,11 @@ const CreateForm: React.FC<CreateFormProps> = (props) => {
// TODO 对接新增接口
// postModelCategoryCreateModelCategory(values)
// .then(() => {
// message.success(intl.formatMessage({ id: 'common.success', defaultMessage: '$$$' }));
// message.success(intl.formatMessage({ id: 'common.action.success', defaultMessage: '$$$' }));
// props.reload();
// })
// .catch(() => {
// message.error(intl.formatMessage({ id: 'common.failure', defaultMessage: '$$$' }));
// message.error(intl.formatMessage({ id: 'common.action.failure', defaultMessage: '$$$' }));
// });
props.handleModal();
return true;
@ -189,7 +189,7 @@ const CreateForm: React.FC<CreateFormProps> = (props) => {
debounceTime={500}
request={async () => {
const { data } = await getModelRuntimeLibFilesList();
return data?.results?.map((v: Record<string, any>) => {
return data?.data?.map((v: Record<string, any>) => {
return { ...v, label: v.name, value: v.id };
});
}}

@ -258,7 +258,7 @@ const ModelRuntimeLib: React.FC = () => {
pagination={{
...proTablePaginationOptions,
pageSize: currentPageSize,
onChange: (page, pageSize) => setCurrentPageSize(pageSize),
onChange: (pageNo, pageSize) => setCurrentPageSize(pageSize),
}}
columnsState={{
persistenceKey: 'algorithm_model_list',
@ -267,7 +267,7 @@ const ModelRuntimeLib: React.FC = () => {
request={async (params = {}, sort) => {
const { current, ...rest } = params;
const reqParams = {
page: current,
pageNo: current,
desc: false,
orderKey: '',
...rest,
@ -279,7 +279,7 @@ const ModelRuntimeLib: React.FC = () => {
}
let resp = await getModelRuntimeLibList({ ...reqParams, ...querysData });
return {
data: resp.data.results,
data: resp.data.data,
success: resp.success,
total: resp.data.count,
current: current,

@ -56,7 +56,7 @@ const UpdateForm: React.FC<UpdateFormProps> = (props) => {
className="gn_form gn_modal_form"
width={proFormSmallModelWidth}
title={intl.formatMessage({
id: 'business.list.table.createForm.add',
id: 'business.list.table.createForm.title',
defaultMessage: '新建',
})}
open={props.updateModalOpen}
@ -72,11 +72,11 @@ const UpdateForm: React.FC<UpdateFormProps> = (props) => {
// TODO 对接更新接口
// postModelCategoryCreateModelCategory(values)
// .then(() => {
// message.success(intl.formatMessage({ id: 'common.success', defaultMessage: '$$$' }));
// message.success(intl.formatMessage({ id: 'common.action.success', defaultMessage: '$$$' }));
// props.reload();
// })
// .catch(() => {
// message.error(intl.formatMessage({ id: 'common.failure', defaultMessage: '$$$' }));
// message.error(intl.formatMessage({ id: 'common.action.failure', defaultMessage: '$$$' }));
// });
props.handleModal();
return true;

@ -82,7 +82,7 @@ const BusinessInfo: React.FC = () => {
// 算法列表
async function initList(tabId: string) {
const reqParams = {
page: currentPage,
pageNo: currentPage,
pageSize: currentPageSize,
// desc: false,
warning_type: tabId,
@ -92,7 +92,7 @@ const BusinessInfo: React.FC = () => {
// console.log(resp,'resp');
// setCurrentPageSize(resp?.data?.count)
setTotal(resp?.data?.count);
loadList(resp?.data?.results);
loadList(resp?.data?.data);
}
useEffect(() => {
@ -175,9 +175,9 @@ const BusinessInfo: React.FC = () => {
current: currentPage,
pageSize: currentPageSize,
showSizeChanger: true,
onChange: (page, pageSize) => {
console.log(page, pageSize);
setCurrentPage(page);
onChange: (pageNo, pageSize) => {
console.log(pageNo, pageSize);
setCurrentPage(pageNo);
setCurrentPageSize(pageSize);
},
}}

@ -2,7 +2,7 @@
* @Author: donghao donghao@supervision.ltd
* @Date: 2024-04-08 16:57:30
* @LastEditors: donghao donghao@supervision.ltd
* @LastEditTime: 2024-05-16 14:44:05
* @LastEditTime: 2024-05-24 14:21:10
* @FilePath: \general-ai-manage\src\pages\Project\BusinessProject\components\businessCard.tsx
* @Description:
*/
@ -10,7 +10,7 @@ import TableActionCard, { actionsProps } from '@/components/TableActionCard';
import { useBusinessInfo } from '@/hooks/useBusinessInfo';
import { useMoment } from '@/hooks/useMoment';
import { history } from '@umijs/max';
import { ReactComponent as BusinessLogoIcon } from '/public/home/business_logo.svg';
import businessLogoIcon from '/public/home/business_logo.svg';
import { ReactComponent as DeviceCountIcon } from '/public/home/device_count_icon.svg';
import { ReactComponent as ModelCountIcon } from '/public/home/model_count_icon.svg';
import { ReactComponent as TimeIcon } from '/public/home/time_icon.svg';
@ -34,7 +34,7 @@ const BusinessCard: React.FC<BusinessCardProps> = ({ info, renderActions }) => {
>
<div className="bp_card_body">
<div className="tag_box">
<div className="bg_tag_info single_line">{info?.industryName}</div>
<div className="bg_tag_info single_line">{info?.industry}</div>
</div>
<div className="flex justify-end items-center pt-[8px]">
<span className="pr-[14px]">
@ -44,7 +44,8 @@ const BusinessCard: React.FC<BusinessCardProps> = ({ info, renderActions }) => {
<div className="px-[12px] pt-[12px]">
<div className="flex items-center logo_name">
<span className="icon_logo mr-[4px]">
<BusinessLogoIcon></BusinessLogoIcon>
{/* 空值使用默认图标 */}
<img src={info.logo || businessLogoIcon} alt="" />
</span>
<span className="single_line">{info.name}</span>
</div>

@ -1,8 +1,20 @@
// import { postModelCategoryCreateModelCategory } from '@/services/resource/ModelCategory';
/*
* @Author: donghao donghao@supervision.ltd
* @Date: 2024-04-07 14:02:00
* @LastEditors: donghao donghao@supervision.ltd
* @LastEditTime: 2024-05-24 17:26:18
* @FilePath: \general-ai-manage\src\pages\BusinessProject\components\createForm.tsx
* @Description:
* @
* 1.
* 2. logo使base64
* 3.
*/
import { useCity } from '@/hooks/useCity';
import { getDictIndustry } from '@/services/testApi/dict';
import { beforeUploadImage } from '@/utils/common';
import { useUploadFile } from '@/hooks/useUploadFile';
import { apiIndustrymap } from '@/services/business/dict';
import { apiEntityAdd } from '@/services/business/entity';
import { transformDictByMap } from '@/utils/dict';
import {
ModalForm,
ProForm,
@ -13,14 +25,14 @@ import {
ProFormUploadButton,
} from '@ant-design/pro-components';
import { FormattedMessage, useIntl } from '@umijs/max';
import { Form } from 'antd';
import React, { useState } from 'react';
import { Form, message } from 'antd';
import React, { useEffect, useState } from 'react';
import {
proFormSmallItemStyleProps,
proFormSmallModelWidth,
} from '../../../../../config/defaultForm';
// @ts-ignore
import cookie from 'react-cookies';
// import cookie from 'react-cookies';
export type FormValueType = {
target?: string;
template?: string;
@ -32,7 +44,6 @@ export type FormValueType = {
export type CreateFormProps = {
createModalOpen: boolean;
handleModal: () => void;
values: Partial<API.ModelCategory>;
reload: any;
};
const CreateForm: React.FC<CreateFormProps> = (props) => {
@ -40,18 +51,59 @@ const CreateForm: React.FC<CreateFormProps> = (props) => {
// const [isAuto, setIsAuto] = useState(true);
const [form] = Form.useForm<API.ModelCategory>();
const [cityOptions, setCityOptions] = useState<Record<string, any>[]>([]);
const [fileList, setFileList] = useState([]);
const { formatProvinceByData, formatCityByProvinceData } = useCity();
function changeCity(record1, record2) {
// 汇总城市数据到表单
console.log(record1, record2, 'changeProvince_record');
}
const { getBase64 } = useUploadFile();
// 文件上传处理函数
const handleUpload = async (file) => {
try {
const base64 = await getBase64(file);
console.log('Base64 File:', base64);
// 假设上传成功将文件添加到fileList 并 给表单赋值
form.setFieldValue('logo', base64);
} catch (error) {
// message.error('文件转换失败');
}
};
// 文件选择变化处理函数
const handleChangeFile = ({ file, fileList }) => {
// 检查文件状态
if (file.status === 'removed') {
// 删除文件
setFileList(fileList.filter((item) => item.uid !== file.uid));
// message.success(`${file.name} 删除成功`);
} else {
// 处理上传
handleUpload(file);
}
setFileList(fileList);
return false; // 阻止自动上传
};
function resetForm() {
setFileList([]);
form.resetFields();
}
useEffect(() => {
if (props.createModalOpen) {
} else {
resetForm();
}
}, [props.createModalOpen]);
return (
<ModalForm<API.ModelCategory>
className="gn_form gn_modal_form"
width={proFormSmallModelWidth}
title={intl.formatMessage({
id: 'business.list.table.createForm.add',
id: 'business.list.table.createForm.title',
defaultMessage: '新建',
})}
open={props.createModalOpen}
@ -64,16 +116,19 @@ const CreateForm: React.FC<CreateFormProps> = (props) => {
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();
apiEntityAdd(values)
.then(() => {
message.success(
intl.formatMessage({ id: 'common.action.success', defaultMessage: '$$$' }),
);
props.reload();
props.handleModal();
})
.catch(() => {
message.error(
intl.formatMessage({ id: 'common.action.failure', defaultMessage: '$$$' }),
);
});
return true;
}}
>
@ -121,7 +176,7 @@ const CreateForm: React.FC<CreateFormProps> = (props) => {
const respDataList = formatProvinceByData();
return respDataList;
}}
onChange={(_, record2) => {
onChange={(record, record2) => {
form.setFieldValue('city', null); // 先清空城市
setCityOptions(() => formatCityByProvinceData(record2));
}}
@ -167,7 +222,7 @@ const CreateForm: React.FC<CreateFormProps> = (props) => {
/>
<ProFormText
width={proFormSmallItemStyleProps.column2Width}
name="address"
name="addr"
label={<FormattedMessage id="business.list.table.form.address" defaultMessage="地址" />}
placeholder={`${intl.formatMessage({
id: 'common.please_input',
@ -204,10 +259,9 @@ const CreateForm: React.FC<CreateFormProps> = (props) => {
showSearch
debounceTime={500}
request={async () => {
const { data } = await getDictIndustry();
return data?.results?.map((v: Record<string, any>) => {
return { ...v, label: v.name, value: v.id };
});
const { data } = await apiIndustrymap();
// console.log(data,'apiIndustrymap_data')
return transformDictByMap(data);
}}
rules={[
{
@ -221,33 +275,9 @@ const CreateForm: React.FC<CreateFormProps> = (props) => {
},
]}
/>
{/* <ProFormText
width={proFormSmallItemStyleProps.width}
name="industry"
label={<FormattedMessage id="business.list.table.form.industry" defaultMessage="行业" />}
placeholder={`${intl.formatMessage({
id: 'common.please_input',
defaultMessage: '$$$',
})}${intl.formatMessage({
id: 'business.list.table.form.industry',
defaultMessage: '$$$',
})}`}
required={true}
rules={[
{
required: true,
message: (
<FormattedMessage
id="business.list.table.form.rule.required.industry"
defaultMessage="name is required"
/>
),
},
]}
/> */}
<ProFormText
width={proFormSmallItemStyleProps.width}
name="contacts"
name="contact"
label={
<FormattedMessage id="business.list.table.form.contacts" defaultMessage="联系人" />
}
@ -273,7 +303,7 @@ const CreateForm: React.FC<CreateFormProps> = (props) => {
/>
<ProFormText
width={proFormSmallItemStyleProps.width}
name="contactWay"
name="phone"
label={
<FormattedMessage id="business.list.table.form.contactWay" defaultMessage="联系方式" />
}
@ -299,7 +329,7 @@ const CreateForm: React.FC<CreateFormProps> = (props) => {
/>
<ProFormTextArea
width={proFormSmallItemStyleProps.width}
name="remark"
name="summary"
label={<FormattedMessage id="business.list.table.form.remark" defaultMessage="简介" />}
placeholder={`${intl.formatMessage({
id: 'common.please_input',
@ -322,23 +352,24 @@ const CreateForm: React.FC<CreateFormProps> = (props) => {
]}
disabled={false}
/>
{/* // TODO level3 按UI实际效果调整上传logo & 改用上传base64格式编码 换手动上传 */}
<ProFormUploadButton
width={proFormSmallItemStyleProps.width}
max={1}
action="/api/v1/file/uploadImage"
// action="/api/v1/file/uploadImage"
name="logo"
label={<FormattedMessage id="business.list.table.form.logo" defaultMessage="logo" />}
fileList={fileList}
onChange={handleChangeFile}
fieldProps={{
name: 'file',
listType: 'picture-card',
beforeUpload: beforeUploadImage,
data: { path: 'user/avatar' },
headers: {
'X-CSRFToken': cookie.load('csrftoken'),
'X-Token': `${localStorage.getItem('access') || ''}`,
beforeUpload: (file) => {
handleUpload(file);
return false; // 阻止自动上传
},
}}
icon={<i className="iconfont icon-xinjian text-[20px] text-[#DCDCDC]"></i>} // 自定义图标
title="" // 自定义文字
required={true}
rules={[
{

@ -0,0 +1,412 @@
/*
* @Author: donghao donghao@supervision.ltd
* @Date: 2024-04-07 14:02:00
* @LastEditors: donghao donghao@supervision.ltd
* @LastEditTime: 2024-05-24 17:32:23
* @FilePath: \general-ai-manage\src\pages\BusinessProject\components\updateForm.tsx
* @Description:
* @
* 1.
* 2. logo使base64
* 3.
*/
import { useCity } from '@/hooks/useCity';
import { useUploadFile } from '@/hooks/useUploadFile';
import { apiIndustrymap } from '@/services/business/dict';
import { apiEntityEdit } from '@/services/business/entity';
import { transformDictByMap } from '@/utils/dict';
import {
ModalForm,
ProForm,
ProFormSelect,
ProFormText,
ProFormTextArea,
// ProFormDependency,
ProFormUploadButton,
} from '@ant-design/pro-components';
import { FormattedMessage, useIntl } from '@umijs/max';
import { Form, message } from 'antd';
import React, { useEffect, useState } from 'react';
import {
proFormSmallItemStyleProps,
proFormSmallModelWidth,
} from '../../../../../config/defaultForm';
// @ts-ignore
// import cookie from 'react-cookies';
export type FormValueType = {
target?: string;
template?: string;
type?: string;
time?: string;
frequency?: string;
} & Partial<API.ModelCategory>;
export type UpdateFormProps = {
updateModalOpen: boolean;
handleModal: () => void;
values: Partial<API.ModelCategory>;
reload: any;
};
const UpdateForm: React.FC<UpdateFormProps> = (props) => {
const intl = useIntl();
// const [isAuto, setIsAuto] = useState(true);
const [form] = Form.useForm<API.ModelCategory>();
const [cityOptions, setCityOptions] = useState<Record<string, any>[]>([]);
const [fileList, setFileList] = useState([]);
const { formatProvinceByData, formatCityByProvinceData, formatCityByProvince } = useCity();
function changeCity(record1, record2) {
// 汇总城市数据到表单
console.log(record1, record2, 'changeProvince_record');
}
const { getBase64 } = useUploadFile();
// 文件上传处理函数
const handleUpload = async (file) => {
try {
const base64 = await getBase64(file);
console.log('Base64 File:', base64);
// 假设上传成功将文件添加到fileList 并 给表单赋值
form.setFieldValue('logo', base64);
} catch (error) {
// message.error('文件转换失败');
}
};
// 文件选择变化处理函数
const handleChangeFile = ({ file, fileList }) => {
// 检查文件状态
if (file.status === 'removed') {
// 删除文件
setFileList(fileList.filter((item) => item.uid !== file.uid));
// message.success(`${file.name} 删除成功`);
} else {
// 处理上传
handleUpload(file);
}
setFileList(fileList);
return false; // 阻止自动上传
};
function resetForm() {
setFileList([]);
form.resetFields();
}
useEffect(() => {
if (props.updateModalOpen && props.values?.id) {
form.setFieldsValue(props.values);
console.log(props.values, 'useEffect_values');
setFileList(() => [
{
uid: 'test001',
name: 'test001',
status: 'done',
url: props.values?.logo, // 将Base64作为URL回显
},
]);
} else {
resetForm();
}
}, [props.updateModalOpen, props.values]);
return (
<ModalForm<API.ModelCategory>
className="gn_form gn_modal_form"
width={proFormSmallModelWidth}
title={intl.formatMessage({
id: 'business.list.table.editForm.title',
defaultMessage: '编辑',
})}
initialValues={props.values}
open={props.updateModalOpen}
form={form}
autoFocusFirstInput
modalProps={{
destroyOnClose: true,
onCancel: () => props.handleModal(),
}}
submitTimeout={2000}
onFinish={async (values) => {
console.log(values, 'add_finish_values');
apiEntityEdit({ ...values, id: props.values?.id })
.then(() => {
message.success(
intl.formatMessage({ id: 'common.action.success', defaultMessage: '$$$' }),
);
props.reload();
props.handleModal();
})
.catch(() => {
message.error(
intl.formatMessage({ id: 'common.action.failure', defaultMessage: '$$$' }),
);
});
return true;
}}
>
<ProForm.Group>
<ProFormText
width={proFormSmallItemStyleProps.width}
name="name"
label={<FormattedMessage id="business.list.table.form.name" defaultMessage="名称" />}
placeholder={`${intl.formatMessage({
id: 'common.please_input',
defaultMessage: '$$$',
})}${intl.formatMessage({
id: 'business.list.table.form.name',
defaultMessage: '$$$',
})}`}
required={true}
rules={[
{
required: true,
message: (
<FormattedMessage
id="business.list.table.form.rule.required.name"
defaultMessage="name is required"
/>
),
},
]}
/>
<ProFormSelect
width={proFormSmallItemStyleProps.column2Width / 2 - 8}
name="province"
label={<FormattedMessage id="business.list.table.form.province" defaultMessage="省份" />}
placeholder={`${intl.formatMessage({
id: 'common.please_select',
defaultMessage: '$$$',
})}${intl.formatMessage({
id: 'business.list.table.form.province',
defaultMessage: '$$$',
})}`}
required={true}
showSearch
debounceTime={500}
request={() => {
const respDataList = formatProvinceByData();
return respDataList;
}}
onChange={(_, record2) => {
form.setFieldValue('city', null); // 先清空城市
console.log(record2, 'onDropdownVisibleChange');
setCityOptions(() => formatCityByProvinceData(record2));
}}
rules={[
{
required: true,
message: (
<FormattedMessage
id="business.list.table.form.rule.required.province"
defaultMessage="name is required"
/>
),
},
]}
/>
<ProFormSelect
width={proFormSmallItemStyleProps.column2Width / 2 - 8}
name="city"
label={<FormattedMessage id="business.list.table.form.city" defaultMessage="城市" />}
placeholder={`${intl.formatMessage({
id: 'common.please_select',
defaultMessage: '$$$',
})}${intl.formatMessage({
id: 'business.list.table.form.city',
defaultMessage: '$$$',
})}`}
required={true}
showSearch
debounceTime={500}
options={cityOptions}
onChange={changeCity}
fieldProps={{
onDropdownVisibleChange: (open) => {
if (open) {
setCityOptions(() => formatCityByProvince(form.getFieldValue('province')));
}
console.log(open, 'onDropdownVisibleChange', form.getFieldValue('province'));
},
}}
rules={[
{
required: true,
message: (
<FormattedMessage
id="business.list.table.form.rule.required.city"
defaultMessage="name is required"
/>
),
},
]}
/>
<ProFormText
width={proFormSmallItemStyleProps.column2Width}
name="addr"
label={<FormattedMessage id="business.list.table.form.address" defaultMessage="地址" />}
placeholder={`${intl.formatMessage({
id: 'common.please_input',
defaultMessage: '$$$',
})}${intl.formatMessage({
id: 'business.list.table.form.address',
defaultMessage: '$$$',
})}`}
required={true}
rules={[
{
required: true,
message: (
<FormattedMessage
id="business.list.table.form.rule.required.address"
defaultMessage="name is required"
/>
),
},
]}
/>
<ProFormSelect
width={proFormSmallItemStyleProps.width}
name="industry"
label={<FormattedMessage id="model_index.create.form.industry" defaultMessage="行业" />}
placeholder={`${intl.formatMessage({
id: 'common.please_select',
defaultMessage: '$$$',
})}${intl.formatMessage({
id: 'model_index.create.form.industry',
defaultMessage: '$$$',
})}`}
required={true}
showSearch
debounceTime={500}
request={async () => {
const { data } = await apiIndustrymap();
// console.log(data,'apiIndustrymap_data')
return transformDictByMap(data);
}}
rules={[
{
required: true,
message: (
<FormattedMessage
id="model_index.create.form.rule.required.industry"
defaultMessage="name is required"
/>
),
},
]}
/>
<ProFormText
width={proFormSmallItemStyleProps.width}
name="contact"
label={
<FormattedMessage id="business.list.table.form.contacts" defaultMessage="联系人" />
}
placeholder={`${intl.formatMessage({
id: 'common.please_input',
defaultMessage: '$$$',
})}${intl.formatMessage({
id: 'business.list.table.form.contacts',
defaultMessage: '$$$',
})}`}
required={true}
rules={[
{
required: true,
message: (
<FormattedMessage
id="business.list.table.form.rule.required.contacts"
defaultMessage="name is required"
/>
),
},
]}
/>
<ProFormText
width={proFormSmallItemStyleProps.width}
name="phone"
label={
<FormattedMessage id="business.list.table.form.contactWay" defaultMessage="联系方式" />
}
placeholder={`${intl.formatMessage({
id: 'common.please_input',
defaultMessage: '$$$',
})}${intl.formatMessage({
id: 'business.list.table.form.contactWay',
defaultMessage: '$$$',
})}`}
required={true}
rules={[
{
required: true,
message: (
<FormattedMessage
id="business.list.table.form.rule.required.contactWay"
defaultMessage="name is required"
/>
),
},
]}
/>
<ProFormTextArea
width={proFormSmallItemStyleProps.width}
name="summary"
label={<FormattedMessage id="business.list.table.form.remark" defaultMessage="简介" />}
placeholder={`${intl.formatMessage({
id: 'common.please_input',
defaultMessage: '$$$',
})}${intl.formatMessage({
id: 'business.list.table.form.remark',
defaultMessage: '$$$',
})}`}
required={true}
rules={[
{
required: true,
message: (
<FormattedMessage
id="business.list.table.form.rule.required.remark"
defaultMessage="name is required"
/>
),
},
]}
disabled={false}
/>
<ProFormUploadButton
width={proFormSmallItemStyleProps.width}
max={1}
// action="/api/v1/file/uploadImage"
name="logo"
label={<FormattedMessage id="business.list.table.form.logo" defaultMessage="logo" />}
fileList={fileList}
onChange={handleChangeFile}
fieldProps={{
name: 'file',
listType: 'picture-card',
beforeUpload: (file) => {
handleUpload(file);
return false; // 阻止自动上传
},
}}
icon={<i className="iconfont icon-xinjian text-[20px] text-[#DCDCDC]"></i>} // 自定义图标
title="" // 自定义文字
required={true}
rules={[
{
required: true,
message: (
<FormattedMessage
id="business.list.table.form.rule.required.logo"
defaultMessage="name is required"
/>
),
},
]}
/>
</ProForm.Group>
</ModalForm>
);
};
export default UpdateForm;

@ -2,7 +2,7 @@
* @Author: donghao donghao@supervision.ltd
* @Date: 2024-04-07 14:02:00
* @LastEditors: donghao donghao@supervision.ltd
* @LastEditTime: 2024-05-22 10:07:55
* @LastEditTime: 2024-05-24 18:00:02
* @FilePath: \general-ai-manage\src\pages\BusinessProject\BusinessProject.tsx
* @Description:
* @
@ -11,7 +11,7 @@
* 3.
* # 使city
* # logobase64
*
* // TODO 本页有警告需要解决
*/
import { CommButton, TextButton } from '@/components/Button';
import { isSuccessApi } from '@/utils/forApi';
@ -24,60 +24,82 @@ import { ReactComponent as SearchIcon } from '/public/home/search_icon.svg';
// device_count_icon model_count_icon
import IsConfirmModal from '@/components/TableActionCard/isConfirmModal';
import { getBusinessProject } from '@/services/testApi/businessProject';
import {
apiEntityBaseCount,
apiEntityDelete,
apiEntityIndex,
apiEntityInfo,
} from '@/services/business/entity';
import { SearchOutlined } from '@ant-design/icons';
import { ProCard, ProForm, ProFormText, ProList } from '@ant-design/pro-components';
import { FormattedMessage, useIntl } from '@umijs/max';
import React, { useEffect, useState } from 'react';
import BusinessCard from './components/businessCard';
import CreateForm from './components/createForm';
import UpdateForm from './components/updateForm';
import { message } from 'antd';
import './index.less';
type headerItemsProps = {
title: string;
name: 'entity' | 'model' | 'device';
count: number;
icon: string | React.ReactNode;
};
// TODO 本页有警告需要解决
const headerItems: headerItemsProps[] = [
{
title: '企业总数',
count: 26,
icon: <BusinessHeader1></BusinessHeader1>,
},
{
title: '模型应用',
count: 32,
icon: <BusinessHeader2></BusinessHeader2>,
},
{
title: '设备总量',
count: 53,
icon: <BusinessHeader3></BusinessHeader3>,
},
];
const BusinessProject: React.FC = () => {
/**state */
const intl = useIntl();
const [businessProjectList, setBusinessProjectList] = useState<Record<string, any>[]>([]); // 列表数据
const [querysData, setQuerysData] = useState<Record<string, any>>({}); // 列表查询参数
const [createModalOpen, setCreateModalOpen] = useState<boolean>(false); // 创建新增窗口是否打开
// const [updateModalOpen, setUpdateModalOpen] = useState<boolean>(false); // 更新窗口是否打开
const [updateModalOpen, setUpdateModalOpen] = useState<boolean>(false); // 更新窗口是否打开
const [currentRow, setCurrentRow] = useState<Record<string, any>>();
const [form] = ProForm.useForm(); // form 对象
const [headerItems, setHeaderItems] = useState<headerItemsProps[]>([
{
title: '企业总数',
name: 'entity',
count: 0,
icon: <BusinessHeader1></BusinessHeader1>,
},
{
title: '模型应用',
name: 'model',
count: 0,
icon: <BusinessHeader2></BusinessHeader2>,
},
{
title: '设备总量',
name: 'device',
count: 0,
icon: <BusinessHeader3></BusinessHeader3>,
},
]); // 列表数据
/**新增 编辑 删除 */
// 新增
const handleCreateModal = () => {
if (createModalOpen) {
setCreateModalOpen(false);
setCreateModalOpen(() => !createModalOpen);
};
// 编辑
const handleUpdateModal = () => {
setUpdateModalOpen(!updateModalOpen);
if (updateModalOpen) {
setCurrentRow(undefined);
} else {
setCreateModalOpen(true);
}
};
// 详情信息
async function fetchDetailInfo(record) {
const resp = await apiEntityInfo({ id: record?.id });
console.log(resp, 'fetchDetailInfo_resp');
if (isSuccessApi(resp)) {
setCurrentRow({ ...resp.data, id: record?.id });
}
}
// 将数据组装成reactDom
function toListDomByData(record) {
let startList = [
@ -90,14 +112,16 @@ const BusinessProject: React.FC = () => {
content: item?.isAdd ? (
<div className="w-full bp_card_box">
<div
onClick={handleCreateModal}
onClick={() => {
setCreateModalOpen(true);
}}
className="flex flex-col items-center justify-center w-full text_primary bp_card_body text-[16px]"
>
<span className="plus_icon ">
<i className="iconfont icon-tianjiafenlei"></i>
</span>
<p>
{<FormattedMessage id="business.list.table.createForm.add" defaultMessage="新建" />}
{<FormattedMessage id="business.list.table.createForm.title" defaultMessage="新建" />}
</p>
</div>
</div>
@ -112,8 +136,8 @@ const BusinessProject: React.FC = () => {
className="action_item_box"
onClick={(e) => {
e.stopPropagation();
// setUpdateModalOpen(true);
setCurrentRow(record);
setUpdateModalOpen(true);
fetchDetailInfo(item);
}}
>
<TextButton
@ -140,7 +164,25 @@ const BusinessProject: React.FC = () => {
.`,
onOk: () => {
console.log('删除成功');
// TODO 调用删除接口
apiEntityDelete({ id: item.id })
.then(() => {
message.success(
intl.formatMessage({
id: 'common.action.success',
defaultMessage: '$$$',
}),
);
// eslint-disable-next-line @typescript-eslint/no-use-before-define
reloadList();
})
.catch(() => {
message.error(
intl.formatMessage({
id: 'common.action.failure',
defaultMessage: '$$$',
}),
);
});
},
}}
confirmButton={
@ -169,19 +211,35 @@ const BusinessProject: React.FC = () => {
}
// 企业列表数据api
async function fetchData() {
const resp = await getBusinessProject({ page: 1, pageSize: 100, ...querysData });
const resp = await apiEntityIndex({ pageNo: 1, pageSize: 100, ...querysData });
if (isSuccessApi(resp)) {
toListDomByData(resp.data.results);
toListDomByData(resp.data.data);
}
}
// 企业基础数据统计api
async function fetchBaseCount() {
const resp = await apiEntityBaseCount();
if (isSuccessApi(resp)) {
console.log('fetchBaseCount_resp', resp);
setHeaderItems((data) => {
return data.map((item) => {
if (item.name in resp?.data) {
item['count'] = resp?.data[item['name']];
}
return item;
});
});
}
}
function reloadList() {
fetchData();
fetchBaseCount();
}
// 初始化加载 & 筛选查询
useEffect(() => {
fetchData();
reloadList();
}, [querysData]);
return (
@ -294,10 +352,16 @@ const BusinessProject: React.FC = () => {
</ProCard>
<CreateForm
createModalOpen={createModalOpen}
values={currentRow || {}}
handleModal={handleCreateModal}
reload={reloadList}
/>
{/* updateForm */}
<UpdateForm
updateModalOpen={updateModalOpen}
values={currentRow || {}}
handleModal={handleUpdateModal}
reload={reloadList}
/>
</div>
);
};

@ -1,6 +1,6 @@
// import Footer from '@/components/Footer';
import zhCN from '@/locales/zh-CN';
import { postBaseLogin } from '@/services/system/Base';
import { apiLogin } from '@/services/business/user';
import { getAllRouteNameTile, replaceMenuWithRoutesData } from '@/utils/common';
import { getLocale } from '@@/exports';
import { addLocale } from '@@/plugin-locale';
@ -149,7 +149,7 @@ const Login: React.FC = () => {
const handleSubmit = async (values: API.Login) => {
try {
// 登录
const resp = await postBaseLogin({ ...values });
const resp = await apiLogin({ ...values });
// const resp = await login({ ...values, type });
if (isSuccessApi(resp)) {
// const defaultLoginSuccessMessage = intl.formatMessage({
@ -352,7 +352,7 @@ const Login: React.FC = () => {
marginBlockEnd: 24,
}}
>
<ProFormCheckbox noStyle></ProFormCheckbox>
<ProFormCheckbox noStyle></ProFormCheckbox>
<a
style={{
float: 'right',

@ -0,0 +1,27 @@
/*
* @Author: donghao donghao@supervision.ltd
* @Date: 2024-05-24 14:22:45
* @LastEditors: donghao donghao@supervision.ltd
* @LastEditTime: 2024-05-24 14:23:55
* @FilePath: \general-ai-platform-web\src\services\business\dict.ts
* @Description: api
*/
// @ts-ignore
/* eslint-disable */
import { request } from '@umijs/max';
// 行业字典
export async function apiIndustrymap(body: any, options?: { [key: string]: any }) {
return request<API.Response & { data?: API.INDUSTRY_MAP_DATA; msg?: string }>(
`/api/v1/enterprise/industrymap`,
{
method: 'POST',
headers: {
// 'Content-Type': 'application/json',
// "Content-Type": "application/x-www-form-urlencoded; charset=UTF-8"
},
data: body,
...(options || {}),
},
);
}

@ -0,0 +1,108 @@
/*
* @Author: donghao donghao@supervision.ltd
* @Date: 2024-05-23 13:50:50
* @LastEditors: donghao donghao@supervision.ltd
* @LastEditTime: 2024-05-24 16:19:57
* @FilePath: \general-ai-platform-web\src\services\Business\entity.ts
* @Description: api
*/
// @ts-ignore
/* eslint-disable */
import { request } from '@umijs/max';
/** 首页企业管理 /entity/index */
// 首页企业列表
export async function apiEntityIndex(body: API.Login, options?: { [key: string]: any }) {
return request<API.Response & { data?: API.ENTITY_INDEX_DATA; msg?: string }>(
`/api/v1/enterprise/entity/index`,
{
method: 'POST',
headers: {
// 'Content-Type': 'application/json',
// "Content-Type": "application/x-www-form-urlencoded; charset=UTF-8"
},
data: body,
...(options || {}),
},
);
}
// 首页企业,基础数据统计
export async function apiEntityBaseCount(body: any, options?: { [key: string]: any }) {
return request<API.Response & { data?: API.ENTITY_BASECOUNT_DATA; msg?: string }>(
`/api/v1/enterprise/entity/index/basecount`,
{
method: 'POST',
headers: {
// 'Content-Type': 'application/json',
// "Content-Type": "application/x-www-form-urlencoded; charset=UTF-8"
},
data: body,
...(options || {}),
},
);
}
// 新建企业
export async function apiEntityAdd(body: API.Login, options?: { [key: string]: any }) {
return request<API.Response & { data?: API.ENTITY_INDEX_DATA; msg?: string }>(
`/api/v1/enterprise/entity/add`,
{
method: 'POST',
headers: {
// 'Content-Type': 'application/json',
// "Content-Type": "application/x-www-form-urlencoded; charset=UTF-8"
},
data: body,
...(options || {}),
},
);
}
// 企业信息
export async function apiEntityInfo(body: API.Login, options?: { [key: string]: any }) {
return request<API.Response & { data?: API.ENTITY_INDEX_DATA; msg?: string }>(
`/api/v1/enterprise/entity/info`,
{
method: 'POST',
headers: {
// 'Content-Type': 'application/json',
// "Content-Type": "application/x-www-form-urlencoded; charset=UTF-8"
},
data: body,
...(options || {}),
},
);
}
// 编辑企业信息
export async function apiEntityEdit(body: API.Login, options?: { [key: string]: any }) {
return request<API.Response & { data?: API.ENTITY_INDEX_DATA; msg?: string }>(
`/api/v1/enterprise/entity/edit`,
{
method: 'POST',
headers: {
// 'Content-Type': 'application/json',
// "Content-Type": "application/x-www-form-urlencoded; charset=UTF-8"
},
data: body,
...(options || {}),
},
);
}
// 编辑企业信息
export async function apiEntityDelete(body: API.Login, options?: { [key: string]: any }) {
return request<API.Response & { data?: API.ENTITY_INDEX_DATA; msg?: string }>(
`/api/v1/enterprise/entity/delete`,
{
method: 'POST',
headers: {
// 'Content-Type': 'application/json',
// "Content-Type": "application/x-www-form-urlencoded; charset=UTF-8"
},
data: body,
...(options || {}),
},
);
}

@ -0,0 +1,39 @@
/*
* @Author: donghao donghao@supervision.ltd
* @Date: 2024-05-23 13:56:02
* @LastEditors: donghao donghao@supervision.ltd
* @LastEditTime: 2024-05-23 16:28:52
* @FilePath: \general-ai-platform-web\src\services\Business\user.ts
* @Description: api
*/
// @ts-ignore
/* eslint-disable */
import { request } from '@umijs/max';
/** 用户登录 /base/login */
export async function apiLogin(body: API.Login, options?: { [key: string]: any }) {
return request<API.Response & { data?: LOGIN_DATA; msg?: string }>(`/api/v1/login`, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
data: body,
...(options || {}),
});
}
/** 退出登录接口 POST /api/v1/logout */
export async function apiLoginOut(options?: { [key: string]: any }) {
return request<Record<string, any>>('/api/v1/logout', {
method: 'POST',
...(options || {}),
});
}
/** 获取用户信息 GET /user/getUserInfo */
export async function getUserGetUserInfo(options?: { [key: string]: any }) {
return request<API.Response & { data?: API.UserView; msg?: string }>(`/api/v1/userInfo`, {
method: 'GET',
...(options || {}),
});
}

@ -1,4 +1,32 @@
declare namespace API {
/**basemodel api */
/**device api */
/**dict api */
type INDUSTRY_MAP_DATA = {
data: any; // 业务层数据
};
/**entity api */
type ENTITY_INDEX_DATA = {
data: any; // 业务层数据
};
type ENTITY_BASECOUNT_DATA = {
data: any; // 业务层数据
};
/**file api */
/**model api */
/**user api */
type LOGIN_DATA = {
expiresAt?: number;
token?: string;
user?: User;
};
type AliyunOSS = {
'access-key-id'?: string;
'access-key-secret'?: string;
@ -246,7 +274,7 @@ declare namespace API {
/** 展示值 */
label?: string;
/** 页码 */
page?: number;
pageNo?: number;
/** 每页大小 */
pageSize?: number;
/** 排序标记 */
@ -284,7 +312,7 @@ declare namespace API {
/** 字典名(中) */
name?: string;
/** 页码 */
page?: number;
pageNo?: number;
/** 每页大小 */
pageSize?: number;
/** 状态 */
@ -338,7 +366,7 @@ declare namespace API {
/** 请求方法 */
method?: string;
/** 页码 */
page?: number;
pageNo?: number;
/** 每页大小 */
pageSize?: number;
/** 请求路径 */
@ -411,12 +439,6 @@ declare namespace API {
username?: string;
};
type LoginResponse = {
expiresAt?: number;
token?: string;
user?: User;
};
type Menu = {
children?: Menu[];
component?: string;
@ -561,14 +583,14 @@ declare namespace API {
/** 关键字 */
keyword?: string;
/** 页码 */
page?: number;
pageNo?: number;
/** 每页大小 */
pageSize?: number;
};
type PageResult = {
list?: any;
page?: number;
pageNo?: number;
pageSize?: number;
total?: number;
};
@ -735,7 +757,7 @@ declare namespace API {
/** 排序 */
orderKey?: string;
/** 页码 */
page?: number;
pageNo?: number;
/** 每页大小 */
pageSize?: number;
/** api路径 */
@ -755,7 +777,7 @@ declare namespace API {
/** 排序 */
orderKey?: string;
/** 页码 */
page?: number;
pageNo?: number;
/** 每页大小 */
pageSize?: number;
remark?: string;

@ -2,7 +2,7 @@
* @Author: donghao donghao@supervision.ltd
* @Date: 2024-04-09 13:46:44
* @LastEditors: donghao donghao@supervision.ltd
* @LastEditTime: 2024-04-28 14:24:40
* @LastEditTime: 2024-05-24 09:52:07
* @FilePath: \general-ai-manage\src\services\testApi\businessProject.ts
* @Description: mock
*/
@ -15,7 +15,7 @@ export async function getDictIndustry(
body: Record<string, any>, //
options?: { [key: string]: any },
) {
return request<API.Response & { data?: API.PageResult; msg?: string }>(`/api/dict/industry`, {
return request<API.Response & { data?: API.PageResult; msg?: string }>(`/api/v1/dict/industry`, {
method: 'GET',
headers: {
'Content-Type': 'application/json',

@ -1,7 +1,7 @@
declare namespace API {
type PageResult = {
list?: any;
page?: number;
pageNo?: number;
pageSize?: number;
total?: number;
};
@ -14,6 +14,6 @@ declare namespace API {
// count?: number,
// next?: any,
// previous?: any,
// results?:any
// data?:any
};
}

@ -0,0 +1,13 @@
export function transformDictByMap(obj) {
// 判断是否是对象且不为空
if (obj && typeof obj === 'object' && Object.keys(obj).length > 0) {
// 遍历对象的键值对并转换格式
return Object.keys(obj).map((key) => ({
label: obj[key],
value: Number(key),
}));
} else {
// 对象为空或不是对象时返回空数组
return [];
}
}

2
types/index.d.ts vendored

@ -84,7 +84,7 @@ export namespace API {
current: number;
};
/** POST /api/login/outLogin */
/** POST /api/v1/logout */
export type POST_API_LOGIN_OUT_LOGIN_QUERY = {
/** example: 123 */
token: string;

Loading…
Cancel
Save