feat: 登录相关问题修复

develop2
donghao 10 months ago
parent a00eeb2ffd
commit b4e53f8544

@ -41,25 +41,6 @@ export default {
access = 'admin';
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 = {
...fetchMockFailFullByOther({
data: {},
@ -74,8 +55,6 @@ export default {
access = '';
res.send({ data: {}, success: true });
},
// TODO 以下未使用
// 获取用户信息
'GET /api/v1/userInfo': async (req: Request, res: Response) => {
const adminData: successMockApiProps = {

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

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

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

@ -2,7 +2,7 @@
* @Author: zhoux zhouxia@supervision.ltd
* @Date: 2023-11-14 15:49:36
* @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
* @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 { ReactComponent as MoreIcon } from '/public/home/more_icon.svg';
//TODO 表单的操作按钮集合 key的报错未解决
export type actionsProps = {
key: string;
renderDom: any;

@ -161,10 +161,6 @@ const HomeLayout: React.FC = () => {
<div className="home_nav_action">
<AvatarDropdown menu={true}>
<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>
</div>
</AvatarDropdown>

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

@ -2,7 +2,7 @@
* @Author: donghao donghao@supervision.ltd
* @Date: 2024-04-22 15:23:36
* @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
* @Description:
* @
@ -117,7 +117,7 @@ const BusinessModel: React.FC = () => {
</Button>
),
},
// TODO 编辑接口在新建交互完善后对接
// TODO 062502 编辑接口在新建交互完善后对接
{
key: 'destroy',
renderDom: (

@ -2,7 +2,7 @@
* @Author: donghao donghao@supervision.ltd
* @Date: 2024-05-10 10:47:45
* @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
* @Description:
* @
@ -11,7 +11,6 @@
*/
import { CommButton, TextButton } from '@/components/Button';
import IsConfirmAction from '@/components/TableActionCard/isConfirmAction';
import { deviceStateEnums } from '@/enums/device';
import { useBusinessInfo } from '@/hooks/useBusinessInfo';
import {
@ -141,31 +140,30 @@ const DeviceSate: React.FC = () => {
</span>
),
},
{
key: 'destroy',
renderDom: (
<span>
<IsConfirmAction
title={`${intl.formatMessage({
id: 'pages.searchTable.reOpen',
defaultMessage: '重启',
})}`}
buttonRender={
<TextButton
fontSize={12}
buttonLabel={
<FormattedMessage id="pages.searchTable.reOpen" defaultMessage="重启" />
}
buttonType="danger"
></TextButton>
}
confirmAction={() => {
// TODO 调用重启接口
}}
/>
</span>
),
},
// 待开发
// {
// key: 'destroy',
// renderDom: (
// <span>
// <IsConfirmAction
// title={`${intl.formatMessage({
// id: 'pages.searchTable.reOpen',
// defaultMessage: '重启',
// })}`}
// buttonRender={
// <TextButton
// fontSize={12}
// buttonLabel={
// <FormattedMessage id="pages.searchTable.reOpen" defaultMessage="重启" />
// }
// buttonType="danger"
// ></TextButton>
// }
// confirmAction={() => {}}
// />
// </span>
// ),
// },
]}
></DeviceStateCard>
),

@ -2,7 +2,7 @@
* @Author: donghao donghao@supervision.ltd
* @Date: 2024-05-07 13:38:03
* @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
* @Description: businessStatebs
* @
@ -226,7 +226,6 @@ const BusinessState: React.FC = () => {
});
}
}
// TODO 切换时页码没有显示第一页
const changeTabMode = (key: string) => {
setTabKey(key);
setCurrentPage(1);

@ -1,23 +1,25 @@
/* eslint-disable eqeqeq */
/* 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 { Image } from 'antd';
import React, { useEffect, useState } from 'react';
// type
import { postPowerGroup, postPowerPoolsList } from '@/services/testApi/computePower';
// import { postPowerGroup, postPowerPoolsList } from '@/services/testApi/computePower';
import { isArrayAndNotEmpty } from '@/utils/is';
import ComputePowerCube from './components/computePowerCube';
import ComputePowerType from './components/computePowerType';
import './index.less';
// eslint-disable-next-line @typescript-eslint/no-unused-vars
import { ComputePowerPoolItem, testGroupList, testPoolsData } from './testData/computePowerData';
/**
* @
* @returns
*/
const ComputePowerAllocation: React.FC = () => {
const [poolsData, setPoolsData] = useState([]);
const [poolsData] = useState<ComputePowerPoolItem[]>(testPoolsData);
const [groupList, setGroupList] = useState([]);
// const [showEdit, setShowEdit] = useState(false);
@ -39,21 +41,21 @@ const ComputePowerAllocation: React.FC = () => {
console.log(finalList, 'toListDomByData_finalList');
}
async function fetchPowerData() {
const resp = await postPowerPoolsList();
if (isSuccessApi(resp) && resp?.data) {
console.log('fetchPowerData_res', resp);
setPoolsData(resp.data);
}
}
// async function fetchPowerData() {
// const resp = await postPowerPoolsList();
// if (isSuccessApi(resp) && resp?.data) {
// console.log('fetchPowerData_res', resp);
// setPoolsData(resp.data);
// }
// }
async function fetchGroupData() {
const resp = await postPowerGroup();
if (isSuccessApi(resp) && resp?.data) {
console.log('fetchGroupData_res', resp);
toListDomByData(resp.data.splice(0, 5));
}
}
// async function fetchGroupData() {
// const resp = await postPowerGroup();
// if (isSuccessApi(resp) && resp?.data) {
// console.log('fetchGroupData_res', resp);
// toListDomByData(resp.data.splice(0, 5));
// }
// }
// 算力配置
// function editComputePower() {
@ -62,8 +64,9 @@ const ComputePowerAllocation: React.FC = () => {
// }
useEffect(() => {
fetchGroupData();
fetchPowerData();
// fetchGroupData();
// fetchPowerData();
toListDomByData(testGroupList);
}, []);
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' }}>
.json.yaml.yml
</div> */}
{/* // TODO label字重与上面统一, 操作按钮需要与输入框对齐 此处改为预览 */}
{/* <ProFormList
name="config_str_arr"
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 { proTablePaginationOptions } from '../../../../config/defaultTable';
// import AlarmDetails from './components/AlarmDetails';
import UpdateForm from '../BusinessProject/components/updateForm';
import AccountPsw from './components/accountPsw';
import AlgorithmCard from './components/algorithmCard';
import BaseInfo from './components/baseInfo';
import UpdateForm from './components/updateForm';
import './index.less';
@ -45,11 +45,7 @@ const BusinessInfo: React.FC = () => {
// 更新
const handleUpdateModal = () => {
if (updateModalOpen) {
setUpdateModalOpen(false);
} else {
setUpdateModalOpen(true);
}
setUpdateModalOpen(!updateModalOpen);
};
// 处理初始值
@ -207,11 +203,17 @@ const BusinessInfo: React.FC = () => {
dataSource={list}
/>
</ProCard>
<UpdateForm
{/* <UpdateForm
updateModalOpen={updateModalOpen}
values={detailInfo || {}}
handleModal={handleUpdateModal}
reload={loadDetailData}
/> */}
<UpdateForm
updateModalOpen={updateModalOpen}
values={{ ...detailInfo, id: getStoreBusinessInfo()?.id }}
handleModal={handleUpdateModal}
reload={loadDetailData}
/>
</div>
</div>

@ -2,7 +2,7 @@
* @Author: donghao donghao@supervision.ltd
* @Date: 2024-04-07 14:02:00
* @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
* @Description:
* @
@ -355,7 +355,7 @@ const BusinessProject: React.FC = () => {
handleModal={handleCreateModal}
reload={reloadList}
/>
{/* updateForm */}
{/* 与企业项目首页的编辑相同 */}
<UpdateForm
updateModalOpen={updateModalOpen}
values={currentRow || {}}

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

@ -2,7 +2,7 @@
* @Author: donghao donghao@supervision.ltd
* @Date: 2024-05-23 13:56:02
* @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
* @Description: api
*/
@ -31,9 +31,9 @@ export async function apiLoginOut(options?: { [key: string]: any }) {
}
/** 获取用户信息 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',
export async function apiUserInfo(options?: { [key: string]: any }) {
return request<API.Response & { data?: API.UserView; msg?: string }>(`/api/v1/user/info`, {
method: 'POST',
...(options || {}),
});
}

@ -2,10 +2,14 @@
* @Author: donghao donghao@supervision.ltd
* @Date: 2024-04-24 10:11:48
* @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
* @Description:
*/
import { history } from '@umijs/max';
// import { flushSync } from 'react-dom';
const loginPath = '/user/login';
/**
* @
@ -13,8 +17,19 @@
* @returns 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) {
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) {
return true;
}

Loading…
Cancel
Save