Commit e1d11319 authored by Ylg's avatar Ylg

resove conflict

parents 221fce5b 5208b584
...@@ -17,7 +17,7 @@ export default defineConfig({ ...@@ -17,7 +17,7 @@ export default defineConfig({
layout: { layout: {
// https://umijs.org/zh-CN/plugins/plugin-layout // https://umijs.org/zh-CN/plugins/plugin-layout
locale: true, locale: true,
siderWidth: 208, siderWidth: 240,
...defaultSettings, ...defaultSettings,
}, },
// https://umijs.org/zh-CN/plugins/plugin-locale // https://umijs.org/zh-CN/plugins/plugin-locale
...@@ -42,6 +42,14 @@ export default defineConfig({ ...@@ -42,6 +42,14 @@ export default defineConfig({
// 如果不想要 configProvide 动态设置主题需要把这个设置为 default // 如果不想要 configProvide 动态设置主题需要把这个设置为 default
// 只有设置为 variable, 才能使用 configProvide 动态设置主色调 // 只有设置为 variable, 才能使用 configProvide 动态设置主色调
// https://ant.design/docs/react/customize-theme-variable-cn // https://ant.design/docs/react/customize-theme-variable-cn
'@primary-color': '#009b95', // 全局主色
'@link-color': '#009b95', // 链接色
'@heading-color': 'rgba(0, 0, 0, 0.85)', // 标题色
'@text-color': 'rgba(0, 0, 0, 0.65)', // 主文本色
'@text-color-secondary': 'rgba(0, 0, 0, 0.45)', // 次文本色
'@disabled-color': 'rgba(0, 0, 0, 0.25)', // 失效色
'@border-radius-base': '4px', // 组件/浮层圆角
'@box-shadow-base': '0 2px 8px rgba(0, 0, 0, 0.15)', // 浮层阴影
'root-entry-name': 'variable', 'root-entry-name': 'variable',
}, },
// esbuild is father build tools // esbuild is father build tools
......
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
"description": "An out-of-box UI solution for enterprise applications", "description": "An out-of-box UI solution for enterprise applications",
"scripts": { "scripts": {
"analyze": "cross-env ANALYZE=1 umi build", "analyze": "cross-env ANALYZE=1 umi build",
"build": "umi build", "build": "SET NODE_OPTIONS=--openssl-legacy-provider && umi build",
"deploy": "npm run build && npm run gh-pages", "deploy": "npm run build && npm run gh-pages",
"dev": "npm run start:dev", "dev": "npm run start:dev",
"gh-pages": "gh-pages -d dist", "gh-pages": "gh-pages -d dist",
......
...@@ -29,7 +29,6 @@ export const layout = ({ initialState, setInitialState }) => { ...@@ -29,7 +29,6 @@ export const layout = ({ initialState, setInitialState }) => {
return { return {
rightContentRender: () => <RightContent />, rightContentRender: () => <RightContent />,
disableContentMargin: false, disableContentMargin: false,
footerRender: () => <Footer />, footerRender: () => <Footer />,
menuHeaderRender: undefined, menuHeaderRender: undefined,
// 自定义 403 页面 // 自定义 403 页面
......
import { Form, Modal, Select } from "antd"; import { Form, Modal, Select } from 'antd';
import TextArea from "antd/lib/input/TextArea"; import TextArea from 'antd/lib/input/TextArea';
import { useEffect, useState } from "react"; import { useEffect, useState } from 'react';
import styles from './index.less'; import styles from './index.less';
import { IFormValue } from "@/pages/PromptWord"; import type { IFormValue } from '@/pages/PromptWord';
interface IEditPromptModalProps { interface IEditPromptModalProps {
open: boolean; open: boolean;
...@@ -16,34 +16,35 @@ interface IEditPromptModalProps { ...@@ -16,34 +16,35 @@ interface IEditPromptModalProps {
} }
const EditPromptModal = (props: IEditPromptModalProps) => { const EditPromptModal = (props: IEditPromptModalProps) => {
const { open, setOpen, types, modalType, handleEditPrompt, loading, oldRow, handleCreatePrompt } = props; const { open, setOpen, types, modalType, handleEditPrompt, loading, oldRow, handleCreatePrompt } =
props;
const [currentSelectValue, setCurrentSelectValue] = useState<string | null>("请选择"); const [currentSelectValue, setCurrentSelectValue] = useState<string | null>('请选择');
const [textAreaValue, setTextAreaValue] = useState(''); const [textAreaValue, setTextAreaValue] = useState('');
useEffect(() => { useEffect(() => {
if(modalType === 'create') { if (modalType === 'create') {
setTextAreaValue(''); setTextAreaValue('');
setCurrentSelectValue(''); setCurrentSelectValue('');
} else { } else {
setTextAreaValue(oldRow.content); setTextAreaValue(oldRow.content);
setCurrentSelectValue(oldRow.type || '请选择'); setCurrentSelectValue(oldRow.type || '请选择');
} }
}, [open]) }, [open]);
const handleSavePrompt = async () => { const handleSavePrompt = async () => {
if(modalType === 'create') { if (modalType === 'create') {
await handleCreatePrompt({ await handleCreatePrompt({
type: currentSelectValue, type: currentSelectValue,
content: textAreaValue, content: textAreaValue,
}); });
} }
if(modalType === 'edit') { if (modalType === 'edit') {
await handleEditPrompt({ await handleEditPrompt({
type: currentSelectValue, type: currentSelectValue,
content: textAreaValue, content: textAreaValue,
}) });
} }
setOpen(false); setOpen(false);
...@@ -60,39 +61,36 @@ const EditPromptModal = (props: IEditPromptModalProps) => { ...@@ -60,39 +61,36 @@ const EditPromptModal = (props: IEditPromptModalProps) => {
confirmLoading={loading} confirmLoading={loading}
wrapClassName={styles.modal} wrapClassName={styles.modal}
title={modalType === 'create' ? '新增提示用语' : '编辑提示用语'} title={modalType === 'create' ? '新增提示用语' : '编辑提示用语'}
okText='保存' okText="保存"
onOk={handleSavePrompt} onOk={handleSavePrompt}
onCancel={() => { onCancel={() => {
setCurrentSelectValue('请选择'); setCurrentSelectValue('请选择');
setOpen(false); setOpen(false);
}} }}
width={574} width={574}
bodyStyle={{ bodyStyle={{
padding: '20px' padding: '20px',
}} }}
> >
<Form <Form labelAlign="right" {...layout}>
labelAlign="right" <Form.Item label="类型:">
{...layout}
>
<Form.Item
label="类型:"
>
<Select <Select
onChange={(value: string) => { onChange={(value: string) => {
setCurrentSelectValue(value); setCurrentSelectValue(value);
}} }}
value={currentSelectValue} value={currentSelectValue}
> >
{types.map(item => <Select.Option value={item} key={item}>{item}</Select.Option>)} {types.map((item) => (
<Select.Option value={item} key={item}>
{item}
</Select.Option>
))}
</Select> </Select>
</Form.Item> </Form.Item>
<Form.Item <Form.Item label="提示词语">
label="提示词语" <TextArea
>
<TextArea
style={{ style={{
height: '200px' height: '200px',
}} }}
value={textAreaValue} value={textAreaValue}
onChange={(e) => { onChange={(e) => {
...@@ -102,7 +100,7 @@ const EditPromptModal = (props: IEditPromptModalProps) => { ...@@ -102,7 +100,7 @@ const EditPromptModal = (props: IEditPromptModalProps) => {
</Form.Item> </Form.Item>
</Form> </Form>
</Modal> </Modal>
) );
} };
export default EditPromptModal; export default EditPromptModal;
\ No newline at end of file
import { Modal } from "antd"; import { Modal } from 'antd';
import styles from './index.less'; import styles from './index.less';
import { Exclamtion } from "../Icons/Icons"; import { Exclamtion } from '../Icons/Icons';
interface IDeletePromptModalProps { interface IDeletePromptModalProps {
title: string; title: string;
open: boolean; open: boolean;
...@@ -12,25 +12,17 @@ interface IDeletePromptModalProps { ...@@ -12,25 +12,17 @@ interface IDeletePromptModalProps {
} }
const DeletePromptModal = (props: IDeletePromptModalProps) => { const DeletePromptModal = (props: IDeletePromptModalProps) => {
const { const { title, open, setOpen, tip, content, loading, handleDeletePrompt } = props;
title,
open,
setOpen,
tip,
content,
loading,
handleDeletePrompt,
} = props;
const handleSavePrompt = async () => { const handleSavePrompt = async () => {
await handleDeletePrompt(); await handleDeletePrompt();
setOpen(false); setOpen(false);
} };
return ( return (
<Modal <Modal
title={title} title={title}
okText='确认' okText="确认"
open={open} open={open}
onOk={handleSavePrompt} onOk={handleSavePrompt}
onCancel={() => { onCancel={() => {
...@@ -41,11 +33,9 @@ const DeletePromptModal = (props: IDeletePromptModalProps) => { ...@@ -41,11 +33,9 @@ const DeletePromptModal = (props: IDeletePromptModalProps) => {
<div className={styles.deleteTitle}> <div className={styles.deleteTitle}>
<Exclamtion /> {tip} <Exclamtion /> {tip}
</div> </div>
<div className={styles.deleteContent}> <div className={styles.deleteContent}>{content}</div>
{content}
</div>
</Modal> </Modal>
) );
} };
export default DeletePromptModal; export default DeletePromptModal;
\ No newline at end of file
...@@ -97,3 +97,14 @@ ol { ...@@ -97,3 +97,14 @@ ol {
font-size: 12px !important; font-size: 12px !important;
} }
} }
.ant-btn:active,
.ant-btn:focus {
background-color: #009b95 !important;
border-color: #009b95 !important;
}
.ant-btn:hover {
background-color: #009b95 !important;
border-color: #009b95 !important;
}
...@@ -81,6 +81,7 @@ ...@@ -81,6 +81,7 @@
color: #ffffff; color: #ffffff;
font-size: 18px; font-size: 18px;
line-height: 25px; line-height: 25px;
cursor: pointer;
} }
.footer { .footer {
......
...@@ -133,7 +133,7 @@ const Chat: React.FC = () => { ...@@ -133,7 +133,7 @@ const Chat: React.FC = () => {
/> />
</Col> </Col>
<Col>AI改变世界</Col> <Col>AI改变世界</Col>
<Col pull={1}></Col> <Col pull={1} />
</Row> </Row>
); );
}; };
...@@ -162,13 +162,11 @@ const Chat: React.FC = () => { ...@@ -162,13 +162,11 @@ const Chat: React.FC = () => {
span={24} span={24}
className={styles.chatFooterItem} className={styles.chatFooterItem}
hidden={!access.roles?.find((x) => ['管理员', 'admin'].includes(x))} hidden={!access.roles?.find((x) => ['管理员', 'admin'].includes(x))}
onClick={() => {
history.push('/');
}}
> >
<Space <Space wrap>
wrap
onClick={() => {
history.push('/');
}}
>
<SettingOutlined /> <SettingOutlined />
后台管理 后台管理
</Space> </Space>
...@@ -219,7 +217,7 @@ const Chat: React.FC = () => { ...@@ -219,7 +217,7 @@ const Chat: React.FC = () => {
</Col> </Col>
{promptLoading && ( {promptLoading && (
<Col span={24}> <Col span={24}>
<PageLoading></PageLoading> <PageLoading />
</Col> </Col>
)} )}
<Col span={'24'} style={{ padding: isMobile ? '' : '0 100px' }}> <Col span={'24'} style={{ padding: isMobile ? '' : '0 100px' }}>
......
import { DeleteOutlined, EditOutlined, PlusOutlined } from '@ant-design/icons'; import { DeleteOutlined, EditOutlined, PlusOutlined } from '@ant-design/icons';
import { ActionType, PageContainer } from '@ant-design/pro-components'; import { ActionType, PageContainer } from '@ant-design/pro-components';
import { ProTable } from '@ant-design/pro-components'; import { ProTable } from '@ant-design/pro-components';
import { Button, message } from 'antd'; import { Button, Space, message } from 'antd';
import { isEmpty } from 'lodash'; import { isEmpty } from 'lodash';
import { useEffect, useRef, useState } from 'react'; import { useEffect, useRef, useState } from 'react';
import styles from './index.less'; import styles from './index.less';
import EditPromptModal from '@/components/EditAndAddPromptModal'; import EditPromptModal from '@/components/EditAndAddPromptModal';
import DeletePromptModal from '@/components/DeletePromptModal'; import DeletePromptModal from '@/components/DeletePromptModal';
import { pagePromptWords, createPromptWords, updatePromptWords, deletePromptWords, typePromptWords } from '@/services/chatGLM/api'; import {
pagePromptWords,
createPromptWords,
updatePromptWords,
deletePromptWords,
typePromptWords,
} from '@/services/chatGLM/api';
interface IPromptList { interface IPromptList {
id: string; id: string;
...@@ -31,14 +37,13 @@ interface ILoading { ...@@ -31,14 +37,13 @@ interface ILoading {
} }
const PromptWord = () => { const PromptWord = () => {
const actionRef = useRef<ActionType>(); const actionRef = useRef<ActionType>();
const [allLoading, setAllLoading] = useState<ILoading>({ const [allLoading, setAllLoading] = useState<ILoading>({
editModalLoading: false, editModalLoading: false,
createModalLoading: false, createModalLoading: false,
deleteModalLoading: false, deleteModalLoading: false,
listLoading: false listLoading: false,
}); });
const [editAndAddModalOpen, setEditAndDeleteModalOpen] = useState(false); const [editAndAddModalOpen, setEditAndDeleteModalOpen] = useState(false);
const [deleteModalOpen, setDeleteModalOpen] = useState(false); const [deleteModalOpen, setDeleteModalOpen] = useState(false);
...@@ -48,8 +53,7 @@ const PromptWord = () => { ...@@ -48,8 +53,7 @@ const PromptWord = () => {
const columns: any[] = [ const columns: any[] = [
{ {
title: '类型', title: '提示类型',
width: '20%',
key: 'type', key: 'type',
dataIndex: 'type', dataIndex: 'type',
valueType: 'select', valueType: 'select',
...@@ -58,10 +62,10 @@ const PromptWord = () => { ...@@ -58,10 +62,10 @@ const PromptWord = () => {
options: types.map((type) => { options: types.map((type) => {
return { return {
label: type, label: type,
value: type value: type,
} };
}) }),
} },
}, },
{ {
title: '提示词语', title: '提示词语',
...@@ -70,7 +74,7 @@ const PromptWord = () => { ...@@ -70,7 +74,7 @@ const PromptWord = () => {
dataIndex: 'content', dataIndex: 'content',
ellipsis: true, ellipsis: true,
search: true, search: true,
order: 2 order: 2,
}, },
{ {
title: '创建时间', title: '创建时间',
...@@ -86,28 +90,31 @@ const PromptWord = () => { ...@@ -86,28 +90,31 @@ const PromptWord = () => {
key: 'option', key: 'option',
render: (_: unknown, record: IPromptList) => ( render: (_: unknown, record: IPromptList) => (
<div className={styles.table_action}> <div className={styles.table_action}>
<div <Space wrap>
className={styles.table_action_edit} <div
onClick={() => { className={styles.table_action_edit}
setCurrentRaw(record); onClick={() => {
setEditAndDeleteModalOpen(true); setCurrentRaw(record);
setModalType('edit'); setEditAndDeleteModalOpen(true);
}} setModalType('edit');
> }}
<EditOutlined /> >
<span>编辑</span> <Button size="small" type="link">
</div> 编辑
<span style={{ margin: '0 9px' }}>|</span> </Button>
<div </div>
className={styles.table_action_delete} <div
onClick={() => { className={styles.table_action_delete}
setDeleteModalOpen(true); onClick={() => {
setCurrentRaw(record); setDeleteModalOpen(true);
}} setCurrentRaw(record);
> }}
<DeleteOutlined /> >
<span>删除</span> <Button size="small" type="link" danger>
</div> 删除
</Button>
</div>
</Space>
</div> </div>
), ),
}, },
...@@ -117,7 +124,7 @@ const PromptWord = () => { ...@@ -117,7 +124,7 @@ const PromptWord = () => {
const data = await typePromptWords(); const data = await typePromptWords();
setTypes(data); setTypes(data);
}; };
useEffect(() => { useEffect(() => {
fetchTypes(); fetchTypes();
}, []); }, []);
...@@ -128,13 +135,13 @@ const PromptWord = () => { ...@@ -128,13 +135,13 @@ const PromptWord = () => {
await updatePromptWords({ await updatePromptWords({
id: currentRow.id, id: currentRow.id,
content: editValue.content, content: editValue.content,
type: editValue.type type: editValue.type,
}); });
setAllLoading({ ...allLoading, editModalLoading: false }); setAllLoading({ ...allLoading, editModalLoading: false });
actionRef.current?.reload(); actionRef.current?.reload();
} catch(error) { } catch (error) {
setAllLoading({ ...allLoading, editModalLoading: false }); setAllLoading({ ...allLoading, editModalLoading: false });
message.error('编辑提示用语失败,请重试!') message.error('编辑提示用语失败,请重试!');
} }
}; };
...@@ -143,13 +150,13 @@ const PromptWord = () => { ...@@ -143,13 +150,13 @@ const PromptWord = () => {
try { try {
await createPromptWords({ await createPromptWords({
content: createValue.content, content: createValue.content,
type: createValue.type type: createValue.type,
}) });
setAllLoading({ ...allLoading, createModalLoading: false }); setAllLoading({ ...allLoading, createModalLoading: false });
actionRef.current?.reload(); actionRef.current?.reload();
} catch(error) { } catch (error) {
setAllLoading({ ...allLoading, createModalLoading: false }); setAllLoading({ ...allLoading, createModalLoading: false });
message.error('新增提示用语失败,请重试!') message.error('新增提示用语失败,请重试!');
} }
}; };
...@@ -158,28 +165,28 @@ const PromptWord = () => { ...@@ -158,28 +165,28 @@ const PromptWord = () => {
try { try {
await deletePromptWords({ await deletePromptWords({
id: currentRow.id id: currentRow.id,
}); });
setAllLoading({ ...allLoading, deleteModalLoading: false }); setAllLoading({ ...allLoading, deleteModalLoading: false });
actionRef.current?.reload(); actionRef.current?.reload();
} catch(error) { } catch (error) {
setAllLoading({ ...allLoading, deleteModalLoading: false }); setAllLoading({ ...allLoading, deleteModalLoading: false });
message.error('删除提示用语失败,请重试!') message.error('删除提示用语失败,请重试!');
} }
}; };
return ( return (
<PageContainer> <PageContainer>
<DeletePromptModal <DeletePromptModal
open={deleteModalOpen} open={deleteModalOpen}
setOpen={setDeleteModalOpen} setOpen={setDeleteModalOpen}
title='删除提示用语' title="删除提示用语"
tip='确定要删除这段提示词语吗?' tip="确定要删除这段提示词语吗?"
content='一旦删除后,用户无法看到这一条提示词,建议谨慎操作。' content="一旦删除后,用户无法看到这一条提示词,建议谨慎操作。"
handleDeletePrompt={handleDeletePrompt} handleDeletePrompt={handleDeletePrompt}
loading={allLoading.deleteModalLoading} loading={allLoading.deleteModalLoading}
/> />
<EditPromptModal <EditPromptModal
open={editAndAddModalOpen} open={editAndAddModalOpen}
setOpen={setEditAndDeleteModalOpen} setOpen={setEditAndDeleteModalOpen}
types={types} types={types}
...@@ -187,7 +194,9 @@ const PromptWord = () => { ...@@ -187,7 +194,9 @@ const PromptWord = () => {
handleEditPrompt={handleEditPrompt} handleEditPrompt={handleEditPrompt}
oldRow={currentRow} oldRow={currentRow}
handleCreatePrompt={handleCreatePrompt} handleCreatePrompt={handleCreatePrompt}
loading={modalType === 'create' ? allLoading.createModalLoading : allLoading.editModalLoading} loading={
modalType === 'create' ? allLoading.createModalLoading : allLoading.editModalLoading
}
/> />
<ProTable <ProTable
request={async (params = { pageSize: 10, current: 0 }) => { request={async (params = { pageSize: 10, current: 0 }) => {
...@@ -195,9 +204,9 @@ const PromptWord = () => { ...@@ -195,9 +204,9 @@ const PromptWord = () => {
const promptListParams = { const promptListParams = {
filter: params?.promptWord || '', filter: params?.promptWord || '',
type: params?.type || '', type: params?.type || '',
pageIndex: params?.current as number - 1, pageIndex: (params?.current as number) - 1,
pageSize: params?.pageSize, pageSize: params?.pageSize,
} };
try { try {
const response = await pagePromptWords(promptListParams); const response = await pagePromptWords(promptListParams);
setAllLoading({ ...allLoading, listLoading: false }); setAllLoading({ ...allLoading, listLoading: false });
...@@ -205,15 +214,15 @@ const PromptWord = () => { ...@@ -205,15 +214,15 @@ const PromptWord = () => {
data: response.items, data: response.items,
total: response.totalCount, total: response.totalCount,
success: !isEmpty(response), success: !isEmpty(response),
} };
} catch(error) { } catch (error) {
setAllLoading({ ...allLoading, listLoading: false }); setAllLoading({ ...allLoading, listLoading: false });
message.error('请求列表失败,请重试!'); message.error('请求列表失败,请重试!');
return { return {
data: [], data: [],
total: 0, total: 0,
success: false, success: false,
} };
} }
}} }}
actionRef={actionRef} actionRef={actionRef}
...@@ -224,7 +233,6 @@ const PromptWord = () => { ...@@ -224,7 +233,6 @@ const PromptWord = () => {
pageSize: 10, pageSize: 10,
}} }}
options={false} options={false}
dateFormatter="string"
headerTitle="账号列表" headerTitle="账号列表"
toolBarRender={() => [ toolBarRender={() => [
<Button <Button
......
...@@ -13,7 +13,7 @@ import { ProTable } from '@ant-design/pro-components'; ...@@ -13,7 +13,7 @@ import { ProTable } from '@ant-design/pro-components';
import { Button, Col, Divider, Form, Input, Modal, Radio, Row, Switch, message } from 'antd'; import { Button, Col, Divider, Form, Input, Modal, Radio, Row, Switch, message } from 'antd';
import classNames from 'classnames'; import classNames from 'classnames';
import { isEmpty } from 'lodash'; import { isEmpty } from 'lodash';
import { useRef, useState } from 'react'; import { useRef, useState, useEffect } from 'react';
import styles from './index.less'; import styles from './index.less';
import { Exclamtion } from '@/components/Icons/Icons'; import { Exclamtion } from '@/components/Icons/Icons';
...@@ -51,20 +51,26 @@ const UserManage = () => { ...@@ -51,20 +51,26 @@ const UserManage = () => {
const [accountForm] = Form.useForm(); const [accountForm] = Form.useForm();
const [resetPasswordForm] = Form.useForm(); const [resetPasswordForm] = Form.useForm();
const showModal = () => { useEffect(() => {
getRole().then((res) => { getRole().then((res) => {
if (!isEmpty(res)) { if (!isEmpty(res)) {
setRoles(res); setRoles(res);
setIsModalAccountOpen(true);
} }
}); });
}, []);
const showModal = () => {
if (!isEmpty(roles)) {
setIsModalAccountOpen(true);
}
}; };
const columns: any[] = [ const columns: any[] = [
{ {
title: '用户', title: '用户账号',
dataIndex: 'name', dataIndex: 'name',
ellipsis: true, ellipsis: true,
width: '20%',
}, },
{ {
title: '用户账号', title: '用户账号',
...@@ -92,11 +98,11 @@ const UserManage = () => { ...@@ -92,11 +98,11 @@ const UserManage = () => {
status: 'Error', status: 'Error',
}, },
}, },
render(text, record) { render(_text, record) {
return ( return (
<div className={styles.isActive}> <div className={styles.isActive}>
<span className={classNames(styles.dot, record.isActive ? styles.green : styles.red)} /> <span className={classNames(styles.dot, record.isActive ? styles.green : styles.red)} />
<div>{record.isActive ? '启' : '禁用'}</div> <div>{record.isActive ? '启' : '禁用'}</div>
</div> </div>
); );
}, },
...@@ -105,58 +111,61 @@ const UserManage = () => { ...@@ -105,58 +111,61 @@ const UserManage = () => {
title: '创建时间', title: '创建时间',
dataIndex: 'creationTime', dataIndex: 'creationTime',
hideInSearch: true, hideInSearch: true,
valueType: 'date',
},
{
title: '备注',
hideInSearch: true,
dataIndex: 'creationTime',
valueType: 'date',
}, },
{ {
title: '操作', title: '操作',
valueType: 'option', valueType: 'option',
key: 'option', key: 'option',
render: (_text, record, _, _action) => [ width: '20%',
<a render: (_text, record, _, _action) => (
key="editable" <>
onClick={() => { <Button
setAccountModalName('编辑账号'); size="small"
setEditMessage({ id: record.id }); type="link"
const data = { key="edit"
id: record.id, onClick={() => {
Name: record.name, setAccountModalName('编辑账号');
UserName: record.userName, setEditMessage({ id: record.id });
Role: record.roles, const data = {
isActive: record.isActive, id: record.id,
}; Name: record.name,
accountForm.setFieldsValue(data); UserName: record.userName,
showModal(); Role: record.roles,
}} isActive: record.isActive,
> };
编辑 accountForm.setFieldsValue(data);
</a>, showModal();
<a }}
onClick={() => { >
setResetPassword({ 编辑
id: record.id, </Button>
}); <Button
setIsModalResetPassword(true); size="small"
}} type="link"
key="reset" onClick={() => {
> setResetPassword({
重置 id: record.id,
</a>, });
<a setIsModalResetPassword(true);
key="remove" }}
onClick={() => { key="reset"
setDeleteMessage(record); >
setIsModalDeleteAccountOpen(true); 重置
}} </Button>
> <Button
删除 size="small"
</a>, type="link"
], danger
key="remove"
onClick={() => {
setDeleteMessage(record);
setIsModalDeleteAccountOpen(true);
}}
>
删除
</Button>
</>
),
}, },
]; ];
...@@ -171,19 +180,14 @@ const UserManage = () => { ...@@ -171,19 +180,14 @@ const UserManage = () => {
const createdAccount = (values: any) => { const createdAccount = (values: any) => {
setLoading(true); setLoading(true);
const data = {
role: values.roles,
Phone: values.phoneNumber,
Password: values,
};
CreatedAccount(values) CreatedAccount(values)
.then((res) => { .then(() => {
setLoading(false); setLoading(false);
setIsModalAccountOpen(false); setIsModalAccountOpen(false);
accountForm.resetFields(); accountForm.resetFields();
actionRef.current?.reload(); actionRef.current?.reload();
}) })
.catch((error) => { .catch(() => {
setLoading(false); setLoading(false);
}); });
}; };
...@@ -195,14 +199,14 @@ const UserManage = () => { ...@@ -195,14 +199,14 @@ const UserManage = () => {
id: editMessage.id, id: editMessage.id,
}; };
postEditUser(data) postEditUser(data)
.then((res) => { .then(() => {
setLoading(false); setLoading(false);
setIsModalAccountOpen(false); setIsModalAccountOpen(false);
message.success('编辑成功'); message.success('编辑成功');
accountForm.resetFields(); accountForm.resetFields();
actionRef.current?.reload(); actionRef.current?.reload();
}) })
.catch((error) => { .catch(() => {
setLoading(false); setLoading(false);
}); });
}; };
...@@ -244,12 +248,12 @@ const UserManage = () => { ...@@ -244,12 +248,12 @@ const UserManage = () => {
postDeleteUser({ postDeleteUser({
id: deleteMessage.id, id: deleteMessage.id,
}) })
.then((res) => { .then(() => {
setIsModalDeleteAccountOpen(false); setIsModalDeleteAccountOpen(false);
actionRef.current?.reload(); actionRef.current?.reload();
message.success('删除成功'); message.success('删除成功');
}) })
.catch((err) => { .catch(() => {
setIsModalDeleteAccountOpen(false); setIsModalDeleteAccountOpen(false);
}); });
}; };
...@@ -261,14 +265,14 @@ const UserManage = () => { ...@@ -261,14 +265,14 @@ const UserManage = () => {
Password: values?.newPassword, Password: values?.newPassword,
}; };
postResetUser(data) postResetUser(data)
.then((res) => { .then(() => {
setResetLoading(false); setResetLoading(false);
setIsModalResetPassword(false); setIsModalResetPassword(false);
actionRef.current?.reload(); actionRef.current?.reload();
resetPasswordForm.resetFields(); resetPasswordForm.resetFields();
message.success('重置成功'); message.success('重置成功');
}) })
.catch((err) => { .catch(() => {
setResetLoading(false); setResetLoading(false);
}); });
}; };
...@@ -422,9 +426,6 @@ const UserManage = () => { ...@@ -422,9 +426,6 @@ const UserManage = () => {
</Form> </Form>
</Modal> </Modal>
<ProTable <ProTable
columns={columns}
actionRef={actionRef}
cardBordered
request={async (params = { pageSize: 10, current: 0 }, sort, filter) => { request={async (params = { pageSize: 10, current: 0 }, sort, filter) => {
console.log(sort, filter, params); console.log(sort, filter, params);
const defaultParams = { const defaultParams = {
...@@ -440,13 +441,14 @@ const UserManage = () => { ...@@ -440,13 +441,14 @@ const UserManage = () => {
success: !isEmpty(response), success: !isEmpty(response),
}; };
}} }}
actionRef={actionRef}
columns={columns}
cardBordered
rowKey="id" rowKey="id"
pagination={{ pagination={{
pageSize: 9, pageSize: 10,
onChange: (page) => {},
}} }}
options={false} options={false}
dateFormatter="string"
headerTitle="账号列表" headerTitle="账号列表"
toolBarRender={() => [ toolBarRender={() => [
<Button <Button
......
...@@ -23,7 +23,11 @@ ...@@ -23,7 +23,11 @@
content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0"
/> />
<title>Ant Design Pro</title> <title>Ant Design Pro</title>
<link rel="icon" href="<%= context.config.publicPath +'favicon.ico'%>" type="image/x-icon" /> <link
rel="icon"
href="https://baibaomen.oss-cn-hangzhou.aliyuncs.com/zhensheng/favicon.ico"
type="image/x-icon"
/>
</head> </head>
<body> <body>
<noscript> <noscript>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment