feat: 登录相关问题修复

develop2
donghao 11 months ago
parent a00eeb2ffd
commit b4e53f8544

@ -41,25 +41,6 @@ export default {
access = 'admin'; access = 'admin';
return; return;
} }
// TODO 以下未做任何处理
// if (pwd === 'ant.design' && username === 'user') {
// res.send({
// status: 'ok',
// type,
// currentAuthority: 'user',
// });
// access = 'user';
// return;
// }
// if (type === 'mobile') {
// res.send({
// status: 'ok',
// type,
// currentAuthority: 'admin',
// });
// access = 'admin';
// return;
// }
const failData: failMockApiProps = { const failData: failMockApiProps = {
...fetchMockFailFullByOther({ ...fetchMockFailFullByOther({
data: {}, data: {},
@ -74,8 +55,6 @@ export default {
access = ''; access = '';
res.send({ data: {}, success: true }); res.send({ data: {}, success: true });
}, },
// TODO 以下未使用
// 获取用户信息 // 获取用户信息
'GET /api/v1/userInfo': async (req: Request, res: Response) => { 'GET /api/v1/userInfo': async (req: Request, res: Response) => {
const adminData: successMockApiProps = { const adminData: successMockApiProps = {

@ -18,6 +18,8 @@ import './app.less';
import './base.less'; import './base.less';
import './iconfont.less'; import './iconfont.less';
import { errorConfig } from './requestErrorConfig'; import { errorConfig } from './requestErrorConfig';
import { apiUserInfo } from './services/business/user';
import { isSuccessApi } from './utils/forApi';
const isDev = true; const isDev = true;
const loginPath = '/user/login'; const loginPath = '/user/login';
@ -33,41 +35,54 @@ export async function getInitialState(): Promise<{
fetchUserInfo?: any; fetchUserInfo?: any;
menuData?: MenuDataItem[]; menuData?: MenuDataItem[];
}> { }> {
// TODO userInfo 暂时定死,后续从接口获取 const fetchUserInfo = async () => {
const fetchUserInfo = () => { // return {
return { // id: 1,
id: 1, // createTime: '2023-10-08T16:02:30.775742+08:00',
createTime: '2023-10-08T16:02:30.775742+08:00', // updateTime: '2024-01-24T14:56:32.620573+08:00',
updateTime: '2024-01-24T14:56:32.620573+08:00', // userName: 'admin123',
userName: 'admin', // nickName: '管理员1',
nickName: '管理员1', // phone: '',
phone: '', // email: '',
email: '', // avatarId: 1,
avatarId: 1, // roleId: 1,
roleId: 1, // postId: null,
postId: null, // deptId: null,
deptId: null, // access: 'admin1',
access: 'admin', // roleIds: '1',
roleIds: '1', // postIds: '',
postIds: '', // remark: '',
remark: '', // enable: null,
enable: null, // lastLoginTime: '2024-01-24T14:56:32.620513+08:00',
lastLoginTime: '2024-01-24T14:56:32.620513+08:00', // roles: [
roles: [ // {
{ // label: '管理员1',
label: '管理员1', // value: 1,
value: 1, // },
}, // ],
], // userName: 'resp.data?.name',
avatarUrl: 'uploads/image/user/avatar/39c63ddb96a31b9610cd976b896ad4f0_20231016113731.jpg', // avatarUrl: 'uploads/image/user/avatar/39c63ddb96a31b9610cd976b896ad4f0_20231016113731.jpg',
// };
try {
const resp = await apiUserInfo();
console.log(resp, 'apiUserInfo_resp');
if (isSuccessApi(resp)) {
const currUserInfo = {
...resp?.data,
userName: resp.data?.name,
// update 接口没有返回avtar, 使用默认头像
avatarUrl:
resp.data?.avtar ||
'https://img2.baidu.com/it/u=1374514083,943518806&fm=253&fmt=auto&app=138&f=PNG?w=500&h=500',
}; };
// try { localStorage.setItem('userInfo', JSON.stringify(currUserInfo));
// const msg = await getUserGetUserInfo(); return currUserInfo;
// return msg.data.userInfo; }
// } catch (error) { return undefined;
// history.push(loginPath); } catch (error) {
// } history.push(loginPath);
// return undefined; return undefined;
}
}; };
// 如果不是登录页面,执行 // 如果不是登录页面,执行
const { location } = history; const { location } = history;
@ -185,19 +200,20 @@ export const layout: RunTimeLayoutConfig = ({ initialState, setInitialState }) =
intl.formatMessage({ id: `menu.${currMenu?.name}`, defaultMessage: '首页' })} intl.formatMessage({ id: `menu.${currMenu?.name}`, defaultMessage: '首页' })}
</span> </span>
<div> <div>
{initialState?.currentUser?.userName ? (
<AvatarDropdown menu={true}> <AvatarDropdown menu={true}>
<div className="flex items-center cursor-pointer avatar_box"> <div className="flex items-center cursor-pointer avatar_box">
<img <AvatarName></AvatarName>
className="mr-[8px]" </div>
src="https://img2.baidu.com/it/u=1374514083,943518806&fm=253&fmt=auto&app=138&f=PNG?w=500&h=500" </AvatarDropdown>
/> {/* {initialState?.currentUser?.userName ? (
<AvatarDropdown menu={true}>
<div className="flex items-center cursor-pointer avatar_box">
<AvatarName></AvatarName> <AvatarName></AvatarName>
</div> </div>
</AvatarDropdown> </AvatarDropdown>
) : ( ) : (
<></> <></>
)} )} */}
</div> </div>
</div> </div>
<div className="body_content"> <div className="body_content">

@ -21,6 +21,7 @@ export type HeaderDropdownProps = {
const HeaderDropdown: React.FC<HeaderDropdownProps> = ({ overlayClassName: cls, ...restProps }) => { const HeaderDropdown: React.FC<HeaderDropdownProps> = ({ overlayClassName: cls, ...restProps }) => {
const { styles } = useStyles(); const { styles } = useStyles();
console.log('HeaderDropdown_restProps', restProps);
return <Dropdown overlayClassName={classNames(styles.dropdown, cls)} {...restProps} />; return <Dropdown overlayClassName={classNames(styles.dropdown, cls)} {...restProps} />;
}; };

@ -1,11 +1,11 @@
import { apiLoginOut } from '@/services/business/user'; import { apiLoginOut } from '@/services/business/user';
import { LogoutOutlined } from '@ant-design/icons'; import { LogoutOutlined } from '@ant-design/icons';
import { history, useModel } from '@umijs/max'; import { history, useModel } from '@umijs/max';
import { Spin } from 'antd'; // import { Spin } from 'antd';
import { createStyles } from 'antd-style'; // import { createStyles } from 'antd-style';
import { stringify } from 'querystring'; import { stringify } from 'querystring';
import type { MenuInfo } from 'rc-menu/lib/interface'; import type { MenuInfo } from 'rc-menu/lib/interface';
import React, { useCallback } from 'react'; import React, { useCallback, useEffect } from 'react';
import { flushSync } from 'react-dom'; import { flushSync } from 'react-dom';
import HeaderDropdown from '../HeaderDropdown'; import HeaderDropdown from '../HeaderDropdown';
@ -15,28 +15,36 @@ export type GlobalHeaderRightProps = {
}; };
export const AvatarName = () => { export const AvatarName = () => {
const { initialState } = useModel('@@initialState'); // const { initialState } = useModel('@@initialState');
const { currentUser } = initialState || {}; // const { currentUser } = initialState || {};
return <span className="anticon">{currentUser?.userName}</span>; const userInfo = localStorage.getItem('userInfo');
console.log(userInfo, JSON.parse(userInfo), 'AvatarName_userInfo');
const currUserInfo = JSON.parse(userInfo);
return (
<div className="flex items-center cursor-pointer">
<img className="mr-[8px] h-[40px]" src={currUserInfo?.avatarUrl} />
<span className="anticon">{currUserInfo?.userName}</span>
</div>
);
}; };
const useStyles = createStyles(({ token }) => { // const useStyles = createStyles(({ token }) => {
return { // return {
action: { // action: {
display: 'flex', // display: 'flex',
height: '48px', // height: '48px',
marginLeft: 'auto', // marginLeft: 'auto',
overflow: 'hidden', // overflow: 'hidden',
alignItems: 'center', // alignItems: 'center',
padding: '0 8px', // padding: '0 8px',
cursor: 'pointer', // cursor: 'pointer',
borderRadius: token.borderRadius, // borderRadius: token.borderRadius,
'&:hover': { // '&:hover': {
backgroundColor: token.colorBgTextHover, // backgroundColor: token.colorBgTextHover,
}, // },
}, // },
}; // };
}); // });
export const AvatarDropdown: React.FC<GlobalHeaderRightProps> = ({ children }) => { export const AvatarDropdown: React.FC<GlobalHeaderRightProps> = ({ children }) => {
/** /**
@ -58,7 +66,7 @@ export const AvatarDropdown: React.FC<GlobalHeaderRightProps> = ({ children }) =
}); });
} }
}; };
const { styles } = useStyles(); // const { styles } = useStyles();
const { initialState, setInitialState } = useModel('@@initialState'); const { initialState, setInitialState } = useModel('@@initialState');
@ -66,38 +74,45 @@ export const AvatarDropdown: React.FC<GlobalHeaderRightProps> = ({ children }) =
(event: MenuInfo) => { (event: MenuInfo) => {
const { key } = event; const { key } = event;
if (key === 'logout') { if (key === 'logout') {
console.log(initialState, 'logout_initialState');
flushSync(() => { flushSync(() => {
localStorage.removeItem('access');
localStorage.removeItem('userInfo');
setInitialState((s) => ({ ...s, currentUser: undefined })); setInitialState((s) => ({ ...s, currentUser: undefined }));
}); });
loginOut(); loginOut();
return; return;
} }
history.push(`/account/${key}`); // history.push(`/account/${key}`);
}, },
[setInitialState], [setInitialState],
); );
const loading = ( useEffect(() => {
<span className={styles.action}> console.log(initialState, 'useEffect_initialState');
<Spin }, [initialState]);
size="small"
style={{
marginLeft: 8,
marginRight: 8,
}}
/>
</span>
);
if (!initialState) { // const loading = (
return loading; // <span className={styles.action}>
} // <Spin
// size="small"
// style={{
// marginLeft: 8,
// marginRight: 8,
// }}
// />
// </span>
// );
const { currentUser } = initialState; // if (!initialState) {
// return loading;
// }
if (!currentUser || !currentUser.userName) { // const { currentUser } = initialState;
return loading;
} // if (!currentUser || !currentUser.userName) {
// return loading;
// }
const menuItems = [ const menuItems = [
// ...(menu // ...(menu

@ -2,7 +2,7 @@
* @Author: zhoux zhouxia@supervision.ltd * @Author: zhoux zhouxia@supervision.ltd
* @Date: 2023-11-14 15:49:36 * @Date: 2023-11-14 15:49:36
* @LastEditors: donghao donghao@supervision.ltd * @LastEditors: donghao donghao@supervision.ltd
* @LastEditTime: 2024-05-17 11:04:28 * @LastEditTime: 2024-06-24 14:07:20
* @FilePath: \general-ai-platform-web\src\components\TableActionCard\index.tsx * @FilePath: \general-ai-platform-web\src\components\TableActionCard\index.tsx
* @Description: ,`customMade`, koroFileHeader : https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE * @Description: ,`customMade`, koroFileHeader : https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
*/ */
@ -11,7 +11,6 @@ import { Divider, Dropdown } from 'antd';
import React, { useEffect, useState } from 'react'; import React, { useEffect, useState } from 'react';
import { ReactComponent as MoreIcon } from '/public/home/more_icon.svg'; import { ReactComponent as MoreIcon } from '/public/home/more_icon.svg';
//TODO 表单的操作按钮集合 key的报错未解决
export type actionsProps = { export type actionsProps = {
key: string; key: string;
renderDom: any; renderDom: any;

@ -161,10 +161,6 @@ const HomeLayout: React.FC = () => {
<div className="home_nav_action"> <div className="home_nav_action">
<AvatarDropdown menu={true}> <AvatarDropdown menu={true}>
<div className="flex items-center cursor-pointer avatar_box"> <div className="flex items-center cursor-pointer avatar_box">
<img
className="mr-[8px] h-[40px]"
src="https://img2.baidu.com/it/u=1374514083,943518806&fm=253&fmt=auto&app=138&f=PNG?w=500&h=500"
/>
<AvatarName></AvatarName> <AvatarName></AvatarName>
</div> </div>
</AvatarDropdown> </AvatarDropdown>

@ -255,7 +255,7 @@ const CreateForm: React.FC<CreateFormProps> = (props) => {
return true; return true;
}} }}
> >
{/* //TODO 此项校验必填 与UI确定调整尺寸布局 */} {/* //TODO 062501 此项校验必填 与UI确定调整尺寸布局 */}
<Transfer <Transfer
dataSource={modalData} dataSource={modalData}
titles={['基础模型库', '已选模型']} titles={['基础模型库', '已选模型']}
@ -317,6 +317,7 @@ const CreateForm: React.FC<CreateFormProps> = (props) => {
return { ...data, business_logic: '' }; return { ...data, business_logic: '' };
}); });
}} }}
openPreviewFile={true}
/> />
</StepsForm.StepForm> </StepsForm.StepForm>
{/* 参数配置 */} {/* 参数配置 */}
@ -368,10 +369,8 @@ const CreateForm: React.FC<CreateFormProps> = (props) => {
return { ...data, business_conf_file: '' }; return { ...data, business_conf_file: '' };
}); });
}} }}
openPreviewFile={true}
/> />
{/* //TODO json
*/}
</StepsForm.StepForm> </StepsForm.StepForm>
{/* 关联节点 */} {/* 关联节点 */}
<StepsForm.StepForm<{ <StepsForm.StepForm<{

@ -2,7 +2,7 @@
* @Author: donghao donghao@supervision.ltd * @Author: donghao donghao@supervision.ltd
* @Date: 2024-04-22 15:23:36 * @Date: 2024-04-22 15:23:36
* @LastEditors: donghao donghao@supervision.ltd * @LastEditors: donghao donghao@supervision.ltd
* @LastEditTime: 2024-06-11 14:18:34 * @LastEditTime: 2024-06-25 10:00:13
* @FilePath: \general-ai-platform-web\src\pages\Node\BusinessModel\index.tsx * @FilePath: \general-ai-platform-web\src\pages\Node\BusinessModel\index.tsx
* @Description: * @Description:
* @ * @
@ -117,7 +117,7 @@ const BusinessModel: React.FC = () => {
</Button> </Button>
), ),
}, },
// TODO 编辑接口在新建交互完善后对接 // TODO 062502 编辑接口在新建交互完善后对接
{ {
key: 'destroy', key: 'destroy',
renderDom: ( renderDom: (

@ -2,7 +2,7 @@
* @Author: donghao donghao@supervision.ltd * @Author: donghao donghao@supervision.ltd
* @Date: 2024-05-10 10:47:45 * @Date: 2024-05-10 10:47:45
* @LastEditors: donghao donghao@supervision.ltd * @LastEditors: donghao donghao@supervision.ltd
* @LastEditTime: 2024-06-20 14:33:07 * @LastEditTime: 2024-06-25 10:06:05
* @FilePath: \general-ai-platform-web\src\pages\Business\BusinessState\deviceSate.tsx * @FilePath: \general-ai-platform-web\src\pages\Business\BusinessState\deviceSate.tsx
* @Description: * @Description:
* @ * @
@ -11,7 +11,6 @@
*/ */
import { CommButton, TextButton } from '@/components/Button'; import { CommButton, TextButton } from '@/components/Button';
import IsConfirmAction from '@/components/TableActionCard/isConfirmAction';
import { deviceStateEnums } from '@/enums/device'; import { deviceStateEnums } from '@/enums/device';
import { useBusinessInfo } from '@/hooks/useBusinessInfo'; import { useBusinessInfo } from '@/hooks/useBusinessInfo';
import { import {
@ -141,31 +140,30 @@ const DeviceSate: React.FC = () => {
</span> </span>
), ),
}, },
{ // 待开发
key: 'destroy', // {
renderDom: ( // key: 'destroy',
<span> // renderDom: (
<IsConfirmAction // <span>
title={`${intl.formatMessage({ // <IsConfirmAction
id: 'pages.searchTable.reOpen', // title={`${intl.formatMessage({
defaultMessage: '重启', // id: 'pages.searchTable.reOpen',
})}`} // defaultMessage: '重启',
buttonRender={ // })}`}
<TextButton // buttonRender={
fontSize={12} // <TextButton
buttonLabel={ // fontSize={12}
<FormattedMessage id="pages.searchTable.reOpen" defaultMessage="重启" /> // buttonLabel={
} // <FormattedMessage id="pages.searchTable.reOpen" defaultMessage="重启" />
buttonType="danger" // }
></TextButton> // buttonType="danger"
} // ></TextButton>
confirmAction={() => { // }
// TODO 调用重启接口 // confirmAction={() => {}}
}} // />
/> // </span>
</span> // ),
), // },
},
]} ]}
></DeviceStateCard> ></DeviceStateCard>
), ),

@ -2,7 +2,7 @@
* @Author: donghao donghao@supervision.ltd * @Author: donghao donghao@supervision.ltd
* @Date: 2024-05-07 13:38:03 * @Date: 2024-05-07 13:38:03
* @LastEditors: donghao donghao@supervision.ltd * @LastEditors: donghao donghao@supervision.ltd
* @LastEditTime: 2024-06-20 15:29:43 * @LastEditTime: 2024-06-25 10:02:48
* @FilePath: \general-ai-platform-web\src\pages\Business\BusinessState\index.tsx * @FilePath: \general-ai-platform-web\src\pages\Business\BusinessState\index.tsx
* @Description: businessStatebs * @Description: businessStatebs
* @ * @
@ -226,7 +226,6 @@ const BusinessState: React.FC = () => {
}); });
} }
} }
// TODO 切换时页码没有显示第一页
const changeTabMode = (key: string) => { const changeTabMode = (key: string) => {
setTabKey(key); setTabKey(key);
setCurrentPage(1); setCurrentPage(1);

@ -1,23 +1,25 @@
/* eslint-disable eqeqeq */ /* eslint-disable eqeqeq */
/* eslint-disable react/no-unknown-property */ /* eslint-disable react/no-unknown-property */
import { isSuccessApi } from '@/utils/forApi'; // import { isSuccessApi } from '@/utils/forApi';
import { ProCard, ProList } from '@ant-design/pro-components'; import { ProCard, ProList } from '@ant-design/pro-components';
import { Image } from 'antd'; import { Image } from 'antd';
import React, { useEffect, useState } from 'react'; import React, { useEffect, useState } from 'react';
// type // type
import { postPowerGroup, postPowerPoolsList } from '@/services/testApi/computePower'; // import { postPowerGroup, postPowerPoolsList } from '@/services/testApi/computePower';
import { isArrayAndNotEmpty } from '@/utils/is'; import { isArrayAndNotEmpty } from '@/utils/is';
import ComputePowerCube from './components/computePowerCube'; import ComputePowerCube from './components/computePowerCube';
import ComputePowerType from './components/computePowerType'; import ComputePowerType from './components/computePowerType';
import './index.less'; import './index.less';
// eslint-disable-next-line @typescript-eslint/no-unused-vars
import { ComputePowerPoolItem, testGroupList, testPoolsData } from './testData/computePowerData';
/** /**
* @ * @
* @returns * @returns
*/ */
const ComputePowerAllocation: React.FC = () => { const ComputePowerAllocation: React.FC = () => {
const [poolsData, setPoolsData] = useState([]); const [poolsData] = useState<ComputePowerPoolItem[]>(testPoolsData);
const [groupList, setGroupList] = useState([]); const [groupList, setGroupList] = useState([]);
// const [showEdit, setShowEdit] = useState(false); // const [showEdit, setShowEdit] = useState(false);
@ -39,21 +41,21 @@ const ComputePowerAllocation: React.FC = () => {
console.log(finalList, 'toListDomByData_finalList'); console.log(finalList, 'toListDomByData_finalList');
} }
async function fetchPowerData() { // async function fetchPowerData() {
const resp = await postPowerPoolsList(); // const resp = await postPowerPoolsList();
if (isSuccessApi(resp) && resp?.data) { // if (isSuccessApi(resp) && resp?.data) {
console.log('fetchPowerData_res', resp); // console.log('fetchPowerData_res', resp);
setPoolsData(resp.data); // setPoolsData(resp.data);
} // }
} // }
async function fetchGroupData() { // async function fetchGroupData() {
const resp = await postPowerGroup(); // const resp = await postPowerGroup();
if (isSuccessApi(resp) && resp?.data) { // if (isSuccessApi(resp) && resp?.data) {
console.log('fetchGroupData_res', resp); // console.log('fetchGroupData_res', resp);
toListDomByData(resp.data.splice(0, 5)); // toListDomByData(resp.data.splice(0, 5));
} // }
} // }
// 算力配置 // 算力配置
// function editComputePower() { // function editComputePower() {
@ -62,8 +64,9 @@ const ComputePowerAllocation: React.FC = () => {
// } // }
useEffect(() => { useEffect(() => {
fetchGroupData(); // fetchGroupData();
fetchPowerData(); // fetchPowerData();
toListDomByData(testGroupList);
}, []); }, []);
return ( return (

@ -0,0 +1,122 @@
export type ComputePowerPoolItem = {
name: string;
type: number; // 类别
color?: string; //
proportion: number;
pretreatmentEfficiency?: number;
bgColor?: string;
};
export const testGroupList: Record<string, any>[] = [
{
label: 'NVIDIA GeForce 4090',
type: 1,
},
{
label: '瑞芯微 RK3566',
type: 0,
},
{
label: '瑞芯微 RK3566',
type: 0,
},
{
label: 'NVIDIA GeForce 4090',
type: 1,
},
{
label: 'NVIDIA GeForce 4090',
type: 1,
},
];
export const testPoolsData: ComputePowerPoolItem[] = [
{
name: '焊线颜色检测',
type: 9,
proportion: 7,
pretreatmentEfficiency: 20,
color: '#014BE6',
bgColor: 'linear-gradient(180deg, #015DE6 0%, #4881F6 100%)',
},
{
name: '螺纹缺陷检测',
type: 8,
proportion: 8,
pretreatmentEfficiency: 20,
color: '#FAA90B',
bgColor: 'linear-gradient(180deg, #E64601 0%, #F6A648 100%)',
},
{
name: 'PIN间距测量',
type: 7,
proportion: 4,
pretreatmentEfficiency: 15,
color: '#EA1281',
bgColor: 'linear-gradient(180deg, #E60161 0%, #F648E5 100%)',
},
{
name: '螺纹无牙缺陷检测',
type: 6,
proportion: 7,
pretreatmentEfficiency: 20,
color: '#FA8616',
bgColor: 'linear-gradient(180deg, #FA8316 0%, #FAAD16 100%)',
},
{
name: '压板缺陷检测',
type: 5,
proportion: 32,
pretreatmentEfficiency: 38,
color: '#F9DB18',
bgColor: 'linear-gradient(180deg, #FFC56F 0%, #F9E006 100%)',
},
{
name: '划伤缺陷检测',
type: 4,
proportion: 8,
pretreatmentEfficiency: 38,
color: '#1CCCFA',
bgColor: 'linear-gradient(180deg, #6FFFFF 0%, #06BEF9 100%)',
},
{
name: '披锋(毛刺)缺陷检测',
type: 3,
proportion: 12,
pretreatmentEfficiency: 38,
color: '#9E26EE',
bgColor: 'linear-gradient(180deg, #FF2494 0%, #8D27FF 100%)',
},
{
name: '工件尺寸测量',
type: 2,
proportion: 7,
pretreatmentEfficiency: 38,
color: '#6F50F6',
bgColor: 'linear-gradient(180deg, #6B55F6 0%, #8C38F8 100%)',
},
{
name: '打孔不良检测',
type: 1,
proportion: 5,
pretreatmentEfficiency: 38,
color: '#24ED75',
bgColor: 'linear-gradient(180deg, #43EA80 0%, #38F8D4 100%)',
},
{
name: '空闲算力',
type: 0,
proportion: 10,
pretreatmentEfficiency: 0,
color: '#DCDCDC',
bgColor: 'linear-gradient(90deg, #7B7979 0%, #C1C1C1 100%)',
},
];
// export const powerGroupListData = {
// data: groupList,
// };
// export const powerPoolsListData = {
// data: poolsData,
// };

@ -381,8 +381,6 @@ const CreateForm: React.FC<CreateFormProps> = (props) => {
<div style={{ color: '#666666', marginTop: '-8px', marginBottom: '16px' }}> <div style={{ color: '#666666', marginTop: '-8px', marginBottom: '16px' }}>
.json.yaml.yml .json.yaml.yml
</div> */} </div> */}
{/* // TODO label字重与上面统一, 操作按钮需要与输入框对齐 此处改为预览 */}
{/* <ProFormList {/* <ProFormList
name="config_str_arr" name="config_str_arr"
label={ label={

@ -1,350 +0,0 @@
/*
* @Author: donghao donghao@supervision.ltd
* @Date: 2024-04-23 17:46:28
* @LastEditors: donghao donghao@supervision.ltd
* @LastEditTime: 2024-05-16 15:28:12
* @FilePath: \general-ai-platform-web\src\pages\Project\BusinessInfo\components\updateForm.tsx
* @Description:
*/
import { useCity } from '@/hooks/useCity';
import { beforeUploadImage } from '@/utils/common';
import {
ModalForm,
ProForm,
ProFormSelect,
ProFormText,
ProFormTextArea,
// ProFormDependency,
ProFormUploadButton,
} from '@ant-design/pro-components';
import { FormattedMessage, useIntl } from '@umijs/max';
import { Form } from 'antd';
import React, { 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 { formatProvinceByData, formatCityByProvinceData } = useCity();
function changeCity(record1, record2) {
// 汇总城市数据到表单
console.log(record1, record2, 'changeProvince_record');
}
return (
<ModalForm<API.ModelCategory>
className="gn_form gn_modal_form"
width={proFormSmallModelWidth}
title={intl.formatMessage({
id: 'business.list.table.createForm.title',
defaultMessage: '新建',
})}
open={props.updateModalOpen}
form={form}
autoFocusFirstInput
modalProps={{
destroyOnClose: true,
onCancel: () => props.handleModal(),
}}
submitTimeout={2000}
onFinish={async (values) => {
console.log(values, 'add_finish_values');
// TODO 对接更新接口
// postModelCategoryCreateModelCategory(values)
// .then(() => {
// message.success(intl.formatMessage({ id: 'common.action.success', defaultMessage: '$$$' }));
// props.reload();
// })
// .catch(() => {
// message.error(intl.formatMessage({ id: 'common.action.failure', defaultMessage: '$$$' }));
// });
props.handleModal();
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: '$$$',
})}`}
initialValue={props.values.name}
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: '$$$',
})}`}
initialValue={props.values.province}
required={true}
showSearch
debounceTime={500}
request={() => {
const respDataList = formatProvinceByData();
// 初始化有省份数据,默认加载当前省份的城市数据
if (props.values.province) {
respDataList.forEach((item) => {
if (props.values.province === item.value) {
setCityOptions(() => formatCityByProvinceData(item));
}
});
}
return respDataList;
}}
onChange={(_, record2) => {
form.setFieldValue('city', null); // 先清空城市
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: '$$$',
})}`}
initialValue={props.values.city}
required={true}
showSearch
debounceTime={500}
options={cityOptions}
onChange={changeCity}
rules={[
{
required: true,
message: (
<FormattedMessage
id="business.list.table.form.rule.required.city"
defaultMessage="name is required"
/>
),
},
]}
/>
<ProFormText
width={proFormSmallItemStyleProps.column2Width}
name="address"
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: '$$$',
})}`}
initialValue={props.values.address}
required={true}
rules={[
{
required: true,
message: (
<FormattedMessage
id="business.list.table.form.rule.required.address"
defaultMessage="name is required"
/>
),
},
]}
/>
<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: '$$$',
})}`}
initialValue={props.values.industry}
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"
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: '$$$',
})}`}
initialValue={props.values.contacts}
required={true}
rules={[
{
required: true,
message: (
<FormattedMessage
id="business.list.table.form.rule.required.contacts"
defaultMessage="name is required"
/>
),
},
]}
/>
<ProFormText
width={proFormSmallItemStyleProps.width}
name="contactWay"
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: '$$$',
})}`}
initialValue={props.values.contactWay}
required={true}
rules={[
{
required: true,
message: (
<FormattedMessage
id="business.list.table.form.rule.required.contactWay"
defaultMessage="name is required"
/>
),
},
]}
/>
<ProFormTextArea
width={proFormSmallItemStyleProps.width}
name="remark"
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: '$$$',
})}`}
initialValue={props.values.remark}
required={true}
rules={[
{
required: true,
message: (
<FormattedMessage
id="business.list.table.form.rule.required.remark"
defaultMessage="name is required"
/>
),
},
]}
disabled={false}
/>
{/* // TODO level3 按UI实际效果调整上传logo & 改用上传base64格式编码 换手动上传 */}
<ProFormUploadButton
width={proFormSmallItemStyleProps.width}
max={1}
action="/api/v1/file/uploadImage"
name="logo"
label={<FormattedMessage id="business.list.table.form.logo" defaultMessage="logo" />}
fieldProps={{
name: 'file',
listType: 'picture-card',
beforeUpload: beforeUploadImage,
data: { path: 'user/avatar' },
headers: {
'X-CSRFToken': cookie.load('csrftoken'),
'X-Token': `${localStorage.getItem('access') || ''}`,
},
}}
initialValue={props.values.logo}
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;

@ -20,10 +20,10 @@ import businessLogoIcon from '/public/home/business_logo.svg';
import React, { useEffect, useState } from 'react'; import React, { useEffect, useState } from 'react';
import { proTablePaginationOptions } from '../../../../config/defaultTable'; import { proTablePaginationOptions } from '../../../../config/defaultTable';
// import AlarmDetails from './components/AlarmDetails'; // import AlarmDetails from './components/AlarmDetails';
import UpdateForm from '../BusinessProject/components/updateForm';
import AccountPsw from './components/accountPsw'; import AccountPsw from './components/accountPsw';
import AlgorithmCard from './components/algorithmCard'; import AlgorithmCard from './components/algorithmCard';
import BaseInfo from './components/baseInfo'; import BaseInfo from './components/baseInfo';
import UpdateForm from './components/updateForm';
import './index.less'; import './index.less';
@ -45,11 +45,7 @@ const BusinessInfo: React.FC = () => {
// 更新 // 更新
const handleUpdateModal = () => { const handleUpdateModal = () => {
if (updateModalOpen) { setUpdateModalOpen(!updateModalOpen);
setUpdateModalOpen(false);
} else {
setUpdateModalOpen(true);
}
}; };
// 处理初始值 // 处理初始值
@ -207,11 +203,17 @@ const BusinessInfo: React.FC = () => {
dataSource={list} dataSource={list}
/> />
</ProCard> </ProCard>
<UpdateForm {/* <UpdateForm
updateModalOpen={updateModalOpen} updateModalOpen={updateModalOpen}
values={detailInfo || {}} values={detailInfo || {}}
handleModal={handleUpdateModal} handleModal={handleUpdateModal}
reload={loadDetailData} reload={loadDetailData}
/> */}
<UpdateForm
updateModalOpen={updateModalOpen}
values={{ ...detailInfo, id: getStoreBusinessInfo()?.id }}
handleModal={handleUpdateModal}
reload={loadDetailData}
/> />
</div> </div>
</div> </div>

@ -2,7 +2,7 @@
* @Author: donghao donghao@supervision.ltd * @Author: donghao donghao@supervision.ltd
* @Date: 2024-04-07 14:02:00 * @Date: 2024-04-07 14:02:00
* @LastEditors: donghao donghao@supervision.ltd * @LastEditors: donghao donghao@supervision.ltd
* @LastEditTime: 2024-05-24 18:00:02 * @LastEditTime: 2024-06-24 14:36:52
* @FilePath: \general-ai-manage\src\pages\BusinessProject\BusinessProject.tsx * @FilePath: \general-ai-manage\src\pages\BusinessProject\BusinessProject.tsx
* @Description: * @Description:
* @ * @
@ -355,7 +355,7 @@ const BusinessProject: React.FC = () => {
handleModal={handleCreateModal} handleModal={handleCreateModal}
reload={reloadList} reload={reloadList}
/> />
{/* updateForm */} {/* 与企业项目首页的编辑相同 */}
<UpdateForm <UpdateForm
updateModalOpen={updateModalOpen} updateModalOpen={updateModalOpen}
values={currentRow || {}} values={currentRow || {}}

@ -46,6 +46,8 @@ export const errorConfig: RequestConfig = {
errorHandler: (error: any, opts: any) => { errorHandler: (error: any, opts: any) => {
if (opts?.skipErrorHandler) throw error; if (opts?.skipErrorHandler) throw error;
// 我们的 errorThrower 抛出的错误。 // 我们的 errorThrower 抛出的错误。
console.log(error, 'errorInfo');
if (error.name === 'BizError') { if (error.name === 'BizError') {
const errorInfo: ResponseStructure | undefined = error.info; const errorInfo: ResponseStructure | undefined = error.info;
if (errorInfo) { if (errorInfo) {
@ -106,7 +108,7 @@ export const errorConfig: RequestConfig = {
(response) => { (response) => {
// 拦截响应数据,进行个性化处理 // 拦截响应数据,进行个性化处理
const { data } = response as unknown as ResponseStructure; const { data } = response as unknown as ResponseStructure;
console.log(response, 'responseInterceptors');
if (data?.meta?.code >= 400) { if (data?.meta?.code >= 400) {
message.error('请求失败!'); message.error('请求失败!');
} }

@ -2,7 +2,7 @@
* @Author: donghao donghao@supervision.ltd * @Author: donghao donghao@supervision.ltd
* @Date: 2024-05-23 13:56:02 * @Date: 2024-05-23 13:56:02
* @LastEditors: donghao donghao@supervision.ltd * @LastEditors: donghao donghao@supervision.ltd
* @LastEditTime: 2024-05-23 16:28:52 * @LastEditTime: 2024-06-24 09:57:24
* @FilePath: \general-ai-platform-web\src\services\Business\user.ts * @FilePath: \general-ai-platform-web\src\services\Business\user.ts
* @Description: api * @Description: api
*/ */
@ -31,9 +31,9 @@ export async function apiLoginOut(options?: { [key: string]: any }) {
} }
/** 获取用户信息 GET /user/getUserInfo */ /** 获取用户信息 GET /user/getUserInfo */
export async function getUserGetUserInfo(options?: { [key: string]: any }) { export async function apiUserInfo(options?: { [key: string]: any }) {
return request<API.Response & { data?: API.UserView; msg?: string }>(`/api/v1/userInfo`, { return request<API.Response & { data?: API.UserView; msg?: string }>(`/api/v1/user/info`, {
method: 'GET', method: 'POST',
...(options || {}), ...(options || {}),
}); });
} }

@ -2,10 +2,14 @@
* @Author: donghao donghao@supervision.ltd * @Author: donghao donghao@supervision.ltd
* @Date: 2024-04-24 10:11:48 * @Date: 2024-04-24 10:11:48
* @LastEditors: donghao donghao@supervision.ltd * @LastEditors: donghao donghao@supervision.ltd
* @LastEditTime: 2024-06-05 10:47:32 * @LastEditTime: 2024-06-24 13:36:36
* @FilePath: \general-ai-platform-web\src\utils\forApi.ts * @FilePath: \general-ai-platform-web\src\utils\forApi.ts
* @Description: * @Description:
*/ */
import { history } from '@umijs/max';
// import { flushSync } from 'react-dom';
const loginPath = '/user/login';
/** /**
* @ * @
@ -13,8 +17,19 @@
* @returns boolean * @returns boolean
*/ */
export function isSuccessApi(result: API.API_COMMON_DATA): boolean { export function isSuccessApi(result: API.API_COMMON_DATA): boolean {
// eslint-disable-next-line react-hooks/rules-of-hooks
// const { initialState, setInitialState } = useModel('@@initialState');
if (result && result?.meta) { if (result && result?.meta) {
const { meta } = result; const { meta } = result;
if ([401, 403, 405].includes(meta.code)) {
// 登录失效,统一处理
localStorage.removeItem('access');
localStorage.removeItem('userInfo');
history.push(loginPath);
return false;
}
if (meta.code < 300 && meta.code >= 200) { if (meta.code < 300 && meta.code >= 200) {
return true; return true;
} }

Loading…
Cancel
Save