个人中心和工单接口

This commit is contained in:
mmc
2026-05-15 16:23:55 +08:00
parent 864368edfd
commit b18d293268
3 changed files with 99 additions and 7 deletions

View File

@@ -523,8 +523,8 @@ export default function UserRolePage() {
title={<strong>{r.roleName}</strong>}
description={
<Space direction="vertical" size={2}>
<Text type="secondary">权限:{r.roleKey}</Text>
<Text type="secondary">等级:{r.roleLevel || '-'}</Text>
<span>权限:{r.roleKey}</span>
<span>等级:{r.roleLevel || '-'}</span>
{/*{r.roleKey == "admin1" && <Tag color="red">超级管理员</Tag>}*/}
</Space>
}

View File

@@ -13,6 +13,7 @@ import {
Divider,
Typography,
Space,
Radio,
} from 'antd';
import {
UserOutlined,
@@ -22,6 +23,8 @@ import {
MailOutlined,
SafetyOutlined,
EditOutlined,
ManOutlined,
WomanOutlined,
} from '@ant-design/icons';
import { useSelector } from 'react-redux';
import { RootState, useAppDispatch } from '../store';
@@ -59,7 +62,12 @@ const Profile: React.FC = () => {
const handleUpdateProfile = async (values: any) => {
setLoading(true);
try {
const res: any = await updateUserProfile(values);
// 构建完整的个人信息对象,包含用户 ID 等必要字段
const updateData = {
...profileData,
...values,
};
const res: any = await updateUserProfile(updateData);
if (res.code === 200) {
message.success('修改成功');
const newUserInfo = { ...userInfo, ...values };
@@ -232,6 +240,17 @@ const Profile: React.FC = () => {
initialValues={profileData}
size="large"
>
<Form.Item
label="用户名称"
name="userName"
>
<Input
prefix={<UserOutlined />}
disabled
style={{ borderRadius: 6 }}
/>
</Form.Item>
<Form.Item
label="用户昵称"
name="nickName"
@@ -244,6 +263,16 @@ const Profile: React.FC = () => {
/>
</Form.Item>
<Form.Item
label="性别"
name="sex"
>
<Radio.Group>
<Radio value="0"><ManOutlined /> 男</Radio>
<Radio value="1"><WomanOutlined /> 女</Radio>
</Radio.Group>
</Form.Item>
<Form.Item
label="手机号码"
name="phonenumber"
@@ -268,6 +297,17 @@ const Profile: React.FC = () => {
/>
</Form.Item>
<Form.Item
label="备注"
name="remark"
>
<Input.TextArea
placeholder="请输入备注"
style={{ borderRadius: 6 }}
rows={3}
/>
</Form.Item>
<Form.Item style={{ marginTop: 28 }}>
<Button
type="primary"

View File

@@ -41,6 +41,10 @@ import {
import { UniversalLineChart } from '../components/recharts';
import { orderTypeConfig, sourceTypeMap } from '../constants';
import { useSelector } from 'react-redux';
import { RootState } from '../store';
import { getUser } from '../api/user';
const { Option } = Select;
const { Search } = Input;
const { Text, Title } = Typography;
@@ -73,6 +77,14 @@ const WorkOrderPage = () => {
const [workOrderList, setWorkOrderList] = useState([]);
const [workOrderTotal, setWorkOrderTotal] = useState(0);
const [currentDetail, setCurrentDetail] = useState(null);
const [userList, setUserList] = useState([]); // 用户列表
// 从 redux 获取用户信息
const { userInfo } = useSelector((state: RootState) => state.user);
// 判断是否为管理员 (具有 admin 角色或 roleLevel 为 1)
const isAdmin = true;
// 弹窗表单
const [form] = Form.useForm();
const [editModalVisible, setEditModalVisible] = useState(false);
@@ -82,6 +94,22 @@ const WorkOrderPage = () => {
const [completeForm] = Form.useForm(); // 完成工单表单
const [messageApi, contextHolder] = message.useMessage();
// 获取用户列表 (用于负责人选择)
const fetchUserList = async () => {
try {
const res: any = await getUser({
pageNum: 1, pageSize: 10000, orgId: userInfo?.orgId,
siteId: userInfo?.siteId,
});
if (res.code == 200) {
setUserList(res.rows || []);
}
} catch (error) {
console.error('获取用户列表失败', error);
}
};
// 统计数据
const stats = [
{ title: '今日新增工单', value: 18, subValue: '+3', subText: '较昨日', icon: <ClipboardList size={24} color="#1890ff" />, bg: '#e6f7ff' },
@@ -197,8 +225,13 @@ const WorkOrderPage = () => {
// 打开派发工单弹窗
const openDispatchModal = () => {
if (!selectedRowKey) return messageApi.warning('请先选择一条工单');
if (!isAdmin) return messageApi.error('只有管理员才可以派发工单');
fetchUserList(); // 获取可选负责人列表
form.setFieldsValue({
orderId: selectedRowKey,
assigneeId: currentDetail?.assigneeId || "",
assigneeName: currentDetail?.assigneeName || '',
planStartTime: currentDetail?.planStartTime ? dayjs(currentDetail.planStartTime) : null,
planEndTime: currentDetail?.planEndTime ? dayjs(currentDetail.planEndTime) : null,
@@ -591,7 +624,18 @@ const WorkOrderPage = () => {
</div>
<Row gutter={12}>
<Col span={6}><Button type="primary" block onClick={openDispatchModal} style={{ borderRadius: 8, height: 36, fontWeight: 600 }}>派发工单</Button></Col>
<Col span={6}>
<Button
type="primary"
block
onClick={openDispatchModal}
style={{ borderRadius: 8, height: 36, fontWeight: 600 }}
disabled={!isAdmin}
title={!isAdmin ? "只有管理员可以派发工单" : ""}
>
派发工单
</Button>
</Col>
<Col span={6}><Button icon={<EditOutlined />} block onClick={openEditModal} style={{ borderRadius: 8, height: 36, fontWeight: 600 }}>修改</Button></Col>
<Col span={6}><Popconfirm title="确定挂起?" onConfirm={handleSuspend}><Button icon={<PauseOutlined />} danger ghost block style={{ borderRadius: 8, height: 36, fontWeight: 600 }}>挂起</Button></Popconfirm></Col>
<Col span={6}><Button
@@ -705,9 +749,17 @@ const WorkOrderPage = () => {
<Modal title="派发工单" open={dispatchModalVisible} onCancel={() => setDispatchModalVisible(false)} footer={null} width={550}>
<Form form={form} layout="vertical" onFinish={submitDispatch}>
<FormItem name="orderId" label="工单ID" hidden><Input /></FormItem>
<FormItem name="assigneeName" label="负责人" rules={[{ required: true, message: '请选择负责人' }]}>
<Select placeholder="请选择负责人">
<Option value="王工">王工</Option><Option value="李工">李工</Option><Option value="张工">张工</Option><Option value="陈工">陈工</Option>
<FormItem name="assigneeName" label="负责人姓名" hidden><Input /></FormItem>
<FormItem name="assigneeId" label="负责人" rules={[{ required: true, message: '请选择负责人' }]}>
<Select
placeholder="请选择负责人"
onChange={(val, option: any) => {
form.setFieldsValue({ assigneeName: option.children });
}}
>
{userList.map(user => (
<Option key={user.userId} value={user.userId}>{user.nickName || user.userName}</Option>
))}
</Select>
</FormItem>
<FormItem name="collaboratorNames" label="协同人员"><Select mode="tags" placeholder="可输入多个,回车确认" /></FormItem>