2024-03-11 19:13:42 +08:00
|
|
|
|
import './head.css'
|
2024-03-11 23:33:03 +08:00
|
|
|
|
import BalanceHead from '../../components/balance/BalanceHead.tsx';
|
|
|
|
|
import RechargeHead from '../../components/recharge/RechargeHead.tsx';
|
2024-03-26 21:09:41 +08:00
|
|
|
|
import {Divider, Dropdown, MenuProps, message, Modal, Space, Spin} from "antd";
|
2024-04-02 18:45:46 +08:00
|
|
|
|
import {DownOutlined, UserOutlined, KeyOutlined, LogoutOutlined, AccountBookOutlined} from "@ant-design/icons";
|
2024-03-26 21:09:41 +08:00
|
|
|
|
import {useContext, useEffect, useState} from "react";
|
2024-04-02 18:45:46 +08:00
|
|
|
|
import {put} from "../../util/AjaxUtils.ts";
|
|
|
|
|
import {GlobalContext, GlobalDispatchContext, reloadUser} from "../../context/GlobalContext.ts";
|
|
|
|
|
import UserEdit from "../../components/user/UserEdit.tsx";
|
|
|
|
|
import PasswordChange from "../../components/password/PasswordChange.tsx";
|
2024-04-01 20:39:22 +08:00
|
|
|
|
import headRightBg from '../../assets/head-right-bg.png';
|
2024-04-02 18:45:46 +08:00
|
|
|
|
import InvoiceList from "../../components/invoice/InvoiceList.tsx";
|
2024-04-01 20:39:22 +08:00
|
|
|
|
|
2024-03-11 19:13:42 +08:00
|
|
|
|
|
|
|
|
|
export default function Head() {
|
2024-03-26 21:09:41 +08:00
|
|
|
|
const globalContext = useContext(GlobalContext);
|
|
|
|
|
const globalDispatchContext = useContext(GlobalDispatchContext);
|
|
|
|
|
const [messageApi, contextHolder] = message.useMessage();
|
|
|
|
|
const [modal, modalHolder] = Modal.useModal();
|
|
|
|
|
const [loading, setLoading] = useState<boolean>(false);
|
|
|
|
|
const [isSelfModalOpen, setIsSelfModalOpen] = useState(false);
|
2024-03-27 11:04:38 +08:00
|
|
|
|
const [isPasswordModalOpen, setIsPasswordModalOpen] = useState(false);
|
2024-03-26 21:09:41 +08:00
|
|
|
|
|
|
|
|
|
useEffect(() => {
|
2024-04-02 18:45:46 +08:00
|
|
|
|
reloadUser(messageApi, globalDispatchContext).then((data) => {
|
|
|
|
|
if (!data.hasUserInfo) {
|
|
|
|
|
setIsSelfModalOpen(true);
|
2024-03-26 21:09:41 +08:00
|
|
|
|
}
|
2024-04-02 18:45:46 +08:00
|
|
|
|
});
|
2024-03-26 21:09:41 +08:00
|
|
|
|
}, [globalContext.user]);
|
2024-03-16 23:12:49 +08:00
|
|
|
|
|
|
|
|
|
const items: MenuProps['items'] = [
|
|
|
|
|
{
|
|
|
|
|
key: 'userinfo',
|
|
|
|
|
label: (
|
|
|
|
|
<div className="dropdown-item">
|
2024-04-02 18:45:46 +08:00
|
|
|
|
<UserOutlined/>
|
2024-03-16 23:12:49 +08:00
|
|
|
|
<span className="title">个人信息</span>
|
|
|
|
|
</div>
|
|
|
|
|
),
|
2024-03-26 21:09:41 +08:00
|
|
|
|
onClick: () => {
|
|
|
|
|
setIsSelfModalOpen(true);
|
|
|
|
|
}
|
2024-03-16 23:12:49 +08:00
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
key: 'changePass',
|
|
|
|
|
label: (
|
|
|
|
|
<div className="dropdown-item">
|
2024-04-02 18:45:46 +08:00
|
|
|
|
<KeyOutlined/>
|
2024-03-16 23:12:49 +08:00
|
|
|
|
<span className="title">修改密码</span>
|
|
|
|
|
</div>
|
|
|
|
|
),
|
2024-03-27 11:04:38 +08:00
|
|
|
|
onClick: () => {
|
|
|
|
|
setIsPasswordModalOpen(true);
|
|
|
|
|
}
|
2024-03-16 23:12:49 +08:00
|
|
|
|
},
|
2024-04-02 18:45:46 +08:00
|
|
|
|
{
|
|
|
|
|
key: 'invoice',
|
|
|
|
|
label: (
|
|
|
|
|
<div className="dropdown-item">
|
|
|
|
|
<AccountBookOutlined />
|
|
|
|
|
<span className="title">发票管理</span>
|
|
|
|
|
</div>
|
|
|
|
|
),
|
|
|
|
|
onClick: () => {
|
|
|
|
|
// nav('/invoice-list');
|
|
|
|
|
}
|
|
|
|
|
},
|
2024-03-16 23:12:49 +08:00
|
|
|
|
{
|
|
|
|
|
key: 'logout',
|
|
|
|
|
label: (
|
|
|
|
|
<div className="dropdown-item">
|
2024-04-02 18:45:46 +08:00
|
|
|
|
<LogoutOutlined/>
|
2024-03-16 23:12:49 +08:00
|
|
|
|
<span className="title">退出系统</span>
|
|
|
|
|
</div>
|
|
|
|
|
),
|
|
|
|
|
},
|
|
|
|
|
]
|
|
|
|
|
|
2024-03-11 19:13:42 +08:00
|
|
|
|
return (
|
2024-03-26 21:09:41 +08:00
|
|
|
|
<>
|
|
|
|
|
<div className="head">
|
|
|
|
|
<div className="center">
|
|
|
|
|
<div className="left">
|
|
|
|
|
<span className="sys-title">AI引擎软著</span>
|
|
|
|
|
<Divider type="vertical"/>
|
|
|
|
|
<span className="sys-title-sub">软件著作权一站式服务平台</span>
|
|
|
|
|
</div>
|
2024-04-01 20:39:22 +08:00
|
|
|
|
<div className="right" style={{backgroundImage: `url(${headRightBg})`}}>
|
2024-03-26 21:09:41 +08:00
|
|
|
|
<BalanceHead/>
|
|
|
|
|
<RechargeHead/>
|
|
|
|
|
{/*<MessageHead/>*/}
|
|
|
|
|
<div style={{display: 'flex', alignContent: 'center', padding: '0 10px', cursor: 'pointer'}}>
|
|
|
|
|
<Dropdown menu={{
|
|
|
|
|
items: items
|
|
|
|
|
}}>
|
|
|
|
|
<Space>
|
|
|
|
|
您好:{globalContext.user.nickname}
|
|
|
|
|
<DownOutlined/>
|
|
|
|
|
</Space>
|
|
|
|
|
</Dropdown>
|
|
|
|
|
</div>
|
2024-03-16 23:12:49 +08:00
|
|
|
|
</div>
|
2024-03-11 19:13:42 +08:00
|
|
|
|
</div>
|
|
|
|
|
</div>
|
2024-03-26 21:09:41 +08:00
|
|
|
|
<Modal open={isSelfModalOpen}
|
|
|
|
|
title="个人信息"
|
|
|
|
|
footer={false}
|
|
|
|
|
onCancel={() => {
|
2024-04-02 18:45:46 +08:00
|
|
|
|
if (!globalContext.user.hasUserInfo) {
|
2024-03-26 21:09:41 +08:00
|
|
|
|
messageApi.info('请完善个人信息');
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
setIsSelfModalOpen(false)
|
2024-04-02 18:45:46 +08:00
|
|
|
|
}}>
|
2024-03-26 21:09:41 +08:00
|
|
|
|
<UserEdit handleConfirm={(data) => {
|
|
|
|
|
modal.confirm({
|
2024-03-27 11:04:38 +08:00
|
|
|
|
title: '提示',
|
2024-03-26 21:09:41 +08:00
|
|
|
|
content: '确定保存吗?',
|
|
|
|
|
okText: '确认',
|
|
|
|
|
cancelText: '取消',
|
|
|
|
|
okButtonProps: {
|
|
|
|
|
style: {
|
|
|
|
|
backgroundColor: 'var(--color-primary)'
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
onOk: () => {
|
|
|
|
|
setIsSelfModalOpen(false);
|
|
|
|
|
put({
|
|
|
|
|
messageApi,
|
|
|
|
|
url: '/api/user-info/update-self',
|
|
|
|
|
body: data,
|
|
|
|
|
onBefore() {
|
|
|
|
|
setLoading(true);
|
|
|
|
|
},
|
|
|
|
|
onSuccess() {
|
|
|
|
|
messageApi.success('修改成功');
|
|
|
|
|
},
|
|
|
|
|
onFinally() {
|
|
|
|
|
setLoading(false);
|
|
|
|
|
}
|
|
|
|
|
})
|
2024-03-27 11:04:38 +08:00
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}}/>
|
|
|
|
|
</Modal>
|
|
|
|
|
<Modal open={isPasswordModalOpen}
|
|
|
|
|
title="修改密码"
|
|
|
|
|
footer={false}
|
|
|
|
|
onCancel={() => {
|
|
|
|
|
setIsPasswordModalOpen(false)
|
2024-04-02 18:45:46 +08:00
|
|
|
|
}}>
|
2024-03-27 11:04:38 +08:00
|
|
|
|
<PasswordChange handleConfirm={(data) => {
|
|
|
|
|
modal.confirm({
|
|
|
|
|
title: '提示',
|
|
|
|
|
content: '确定修改吗?',
|
|
|
|
|
okText: '确认',
|
|
|
|
|
cancelText: '取消',
|
|
|
|
|
okButtonProps: {
|
|
|
|
|
style: {
|
|
|
|
|
backgroundColor: 'var(--color-primary)'
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
onOk: () => {
|
|
|
|
|
put({
|
|
|
|
|
messageApi,
|
|
|
|
|
url: '/api/user/update-password',
|
|
|
|
|
body: data,
|
|
|
|
|
onBefore() {
|
|
|
|
|
setLoading(true);
|
|
|
|
|
},
|
|
|
|
|
onSuccess() {
|
|
|
|
|
setIsPasswordModalOpen(false);
|
|
|
|
|
messageApi.success('修改成功,重新登录生效');
|
|
|
|
|
},
|
|
|
|
|
onFinally() {
|
|
|
|
|
setLoading(false);
|
|
|
|
|
}
|
|
|
|
|
})
|
2024-03-26 21:09:41 +08:00
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}}/>
|
|
|
|
|
</Modal>
|
2024-04-01 20:39:22 +08:00
|
|
|
|
<Modal open={true}
|
2024-04-02 18:45:46 +08:00
|
|
|
|
title="发票管理"
|
|
|
|
|
width={1100}
|
2024-04-01 20:39:22 +08:00
|
|
|
|
footer={false}
|
|
|
|
|
>
|
2024-04-02 18:45:46 +08:00
|
|
|
|
<InvoiceList/>
|
2024-04-01 20:39:22 +08:00
|
|
|
|
</Modal>
|
2024-03-26 21:09:41 +08:00
|
|
|
|
<Spin tip="正在提交..." spinning={loading} fullscreen/>
|
|
|
|
|
{contextHolder}
|
|
|
|
|
{modalHolder}
|
|
|
|
|
</>
|
2024-03-11 19:13:42 +08:00
|
|
|
|
)
|
|
|
|
|
}
|