xx
This commit is contained in:
@@ -7,7 +7,7 @@ const API_BASE_URL = envConfig.baseURL;
|
|||||||
|
|
||||||
const api = axios.create({
|
const api = axios.create({
|
||||||
baseURL: API_BASE_URL,
|
baseURL: API_BASE_URL,
|
||||||
timeout: 20000,
|
timeout: 50000,
|
||||||
headers: {
|
headers: {
|
||||||
'Content-Type': 'application/json',
|
'Content-Type': 'application/json',
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -59,6 +59,16 @@ export function deleteRegion(data) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//根据组织id查询场站 /system/site/selectByOrgId
|
||||||
|
|
||||||
|
export function getSiteByOrgId(params) {
|
||||||
|
return request({
|
||||||
|
url: '/system/site/selectByOrgId',
|
||||||
|
method: 'get',
|
||||||
|
params
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -10,6 +10,9 @@ import {
|
|||||||
getStationList, saveSite, deleteSite,
|
getStationList, saveSite, deleteSite,
|
||||||
getStationRegions, saveRegion, deleteRegion
|
getStationRegions, saveRegion, deleteRegion
|
||||||
} from '../api/stationManage';
|
} from '../api/stationManage';
|
||||||
|
import { getOrgList } from '../api/organization';
|
||||||
|
import { useSelector } from 'react-redux';
|
||||||
|
import { RootState } from '../store';
|
||||||
|
|
||||||
const { Option } = Select;
|
const { Option } = Select;
|
||||||
|
|
||||||
@@ -18,6 +21,12 @@ export default function StationManage() {
|
|||||||
const [currentStation, setCurrentStation] = useState(null);
|
const [currentStation, setCurrentStation] = useState(null);
|
||||||
const [regionList, setRegionList] = useState([]);
|
const [regionList, setRegionList] = useState([]);
|
||||||
|
|
||||||
|
// 组织列表
|
||||||
|
const [orgList, setOrgList] = useState([]);
|
||||||
|
|
||||||
|
// 获取当前登录用户信息
|
||||||
|
const { userInfo } = useSelector((state: RootState) => state.user);
|
||||||
|
|
||||||
// 场站弹窗
|
// 场站弹窗
|
||||||
const [modalVisible, setModalVisible] = useState(false);
|
const [modalVisible, setModalVisible] = useState(false);
|
||||||
const [form] = Form.useForm();
|
const [form] = Form.useForm();
|
||||||
@@ -39,6 +48,21 @@ export default function StationManage() {
|
|||||||
total: 0
|
total: 0
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// ====================== 获取组织列表(根据 userId 过滤) ======================
|
||||||
|
const getOrgData = () => {
|
||||||
|
console.log(userInfo, "userInfo")
|
||||||
|
const params = {
|
||||||
|
pageNum: 1,
|
||||||
|
pageSize: 9999,
|
||||||
|
userId: userInfo?.userId
|
||||||
|
};
|
||||||
|
getOrgList(params).then(res => {
|
||||||
|
if (res.code === 200) {
|
||||||
|
setOrgList(res.rows || []);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
// ====================== 获取场站列表(分页) ======================
|
// ====================== 获取场站列表(分页) ======================
|
||||||
const getStationData = () => {
|
const getStationData = () => {
|
||||||
const params = {
|
const params = {
|
||||||
@@ -66,8 +90,10 @@ export default function StationManage() {
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// 初始化加载
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
getStationData();
|
getStationData();
|
||||||
|
getOrgData(); // 进入页面就加载组织
|
||||||
}, [pagination.pageNum, pagination.pageSize]);
|
}, [pagination.pageNum, pagination.pageSize]);
|
||||||
|
|
||||||
// ====================== 新增 / 编辑 场站 ======================
|
// ====================== 新增 / 编辑 场站 ======================
|
||||||
@@ -80,7 +106,10 @@ export default function StationManage() {
|
|||||||
|
|
||||||
const handleEdit = (record) => {
|
const handleEdit = (record) => {
|
||||||
setEditRecord(record);
|
setEditRecord(record);
|
||||||
form.setFieldsValue({ ...record, status: record.status === 1 });
|
form.setFieldsValue({
|
||||||
|
...record,
|
||||||
|
status: record.status === 1
|
||||||
|
});
|
||||||
setModalVisible(true);
|
setModalVisible(true);
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -244,8 +273,14 @@ export default function StationManage() {
|
|||||||
</Col>
|
</Col>
|
||||||
</Row>
|
</Row>
|
||||||
|
|
||||||
<Form.Item name="orgId" label="所属组织ID">
|
<Form.Item name="orgId" label="所属组织">
|
||||||
<Input placeholder="选填" />
|
<Select placeholder="请选择所属组织" allowClear>
|
||||||
|
{orgList.map(item => (
|
||||||
|
<Select.Option key={item.id} value={item.orgId}>
|
||||||
|
{item.orgName}
|
||||||
|
</Select.Option>
|
||||||
|
))}
|
||||||
|
</Select>
|
||||||
</Form.Item>
|
</Form.Item>
|
||||||
|
|
||||||
<Row gutter={16}>
|
<Row gutter={16}>
|
||||||
|
|||||||
@@ -14,6 +14,9 @@ import { addUser, deleteUser, editUser, getUser } from '../api/user';
|
|||||||
import EmptyData from '../components/Empty';
|
import EmptyData from '../components/Empty';
|
||||||
import { useSelector } from 'react-redux';
|
import { useSelector } from 'react-redux';
|
||||||
import { RootState } from '../store';
|
import { RootState } from '../store';
|
||||||
|
import { getOrgList } from '../api/organization';
|
||||||
|
import { getSiteByOrgId } from '../api/stationManage';
|
||||||
|
|
||||||
|
|
||||||
const { Text } = Typography;
|
const { Text } = Typography;
|
||||||
const { TabPane } = Tabs;
|
const { TabPane } = Tabs;
|
||||||
@@ -41,6 +44,8 @@ export default function UserRolePage() {
|
|||||||
const [selectedUserIds, setSelectedUserIds] = useState<number[]>([]);
|
const [selectedUserIds, setSelectedUserIds] = useState<number[]>([]);
|
||||||
const { userInfo } = useSelector((state: RootState) => state.user);
|
const { userInfo } = useSelector((state: RootState) => state.user);
|
||||||
const [roleDetail, setRoleDetail] = useState(null);
|
const [roleDetail, setRoleDetail] = useState(null);
|
||||||
|
const [orgList, setOrgList] = useState([]);
|
||||||
|
const [siteList, setSiteList] = useState([]);
|
||||||
|
|
||||||
// ====================== 统一分页 ======================
|
// ====================== 统一分页 ======================
|
||||||
const [rolePagination, setRolePagination] = useState({
|
const [rolePagination, setRolePagination] = useState({
|
||||||
@@ -50,6 +55,24 @@ export default function UserRolePage() {
|
|||||||
pageNum: 1, pageSize: 10, total: 0
|
pageNum: 1, pageSize: 10, total: 0
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// 获取组织列表
|
||||||
|
const getOrgData = () => {
|
||||||
|
getOrgList({ pageNum: 1, pageSize: 9999 }).then(res => {
|
||||||
|
if (res.code === 200) setOrgList(res.rows || []);
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
// 根据组织ID获取场站
|
||||||
|
const getSiteByOrg = (orgId) => {
|
||||||
|
if (!orgId) {
|
||||||
|
setSiteList([]);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
getSiteByOrgId({ id: orgId }).then(res => {
|
||||||
|
if (res.code === 200) setSiteList(res.data || res.rows || []);
|
||||||
|
}).catch(() => setSiteList([]));
|
||||||
|
};
|
||||||
|
|
||||||
// ====================== 获取角色列表 ======================
|
// ====================== 获取角色列表 ======================
|
||||||
const getRoleData = () => {
|
const getRoleData = () => {
|
||||||
const params = {
|
const params = {
|
||||||
@@ -106,24 +129,22 @@ export default function UserRolePage() {
|
|||||||
|
|
||||||
// ====================== 获取当前角色详情 ======================
|
// ====================== 获取当前角色详情 ======================
|
||||||
const getRoleById = () => {
|
const getRoleById = () => {
|
||||||
if (!userInfo?.roleId) return; // 无 roleId 不请求
|
if (!userInfo?.roleId) return;
|
||||||
getRoleDetailById(userInfo.roleId).then(res => {
|
getRoleDetailById(userInfo.roleId).then(res => {
|
||||||
if (res.code == 200) setRoleDetail(res.data);
|
if (res.code == 200) setRoleDetail(res.data);
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
// ====================== 【核心优化】只在首次加载请求 ======================
|
// ====================== 初始化加载 ======================
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
getMenuData(); // 菜单树只请求一次
|
getMenuData();
|
||||||
getRoleById(); // 角色详情只请求一次
|
getRoleById();
|
||||||
}, []); // 空依赖 → 只执行一次
|
}, []);
|
||||||
|
|
||||||
// ====================== 角色分页变化 ======================
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
getRoleData();
|
getRoleData();
|
||||||
}, [rolePagination.pageNum, rolePagination.pageSize]);
|
}, [rolePagination.pageNum, rolePagination.pageSize]);
|
||||||
|
|
||||||
// ====================== 用户分页变化 ======================
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
getUserData();
|
getUserData();
|
||||||
getRoleForSelect();
|
getRoleForSelect();
|
||||||
@@ -226,7 +247,6 @@ export default function UserRolePage() {
|
|||||||
messageApi.success(editRole ? '编辑成功' : '新增成功');
|
messageApi.success(editRole ? '编辑成功' : '新增成功');
|
||||||
setRoleModalVisible(false);
|
setRoleModalVisible(false);
|
||||||
getRoleById();
|
getRoleById();
|
||||||
|
|
||||||
getRoleData();
|
getRoleData();
|
||||||
getRoleForSelect();
|
getRoleForSelect();
|
||||||
} else messageApi.error(res.msg || '保存失败');
|
} else messageApi.error(res.msg || '保存失败');
|
||||||
@@ -236,14 +256,30 @@ export default function UserRolePage() {
|
|||||||
|
|
||||||
// ====================== 用户操作 ======================
|
// ====================== 用户操作 ======================
|
||||||
const handleAddUser = () => {
|
const handleAddUser = () => {
|
||||||
form.resetFields();
|
|
||||||
setCurrentUser(null);
|
setCurrentUser(null);
|
||||||
|
setSiteList([]);
|
||||||
|
setOrgList([]);
|
||||||
|
form.resetFields();
|
||||||
|
if (userInfo?.userId == 1) {
|
||||||
|
getOrgData();
|
||||||
|
}
|
||||||
|
|
||||||
setModalVisible(true);
|
setModalVisible(true);
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleEditUser = (record) => {
|
const handleEditUser = (record) => {
|
||||||
setCurrentUser(record);
|
setCurrentUser(record);
|
||||||
form.setFieldsValue({ ...record, roleIds: record.roles?.map(i => i.roleId) || [] });
|
form.setFieldsValue({
|
||||||
|
...record,
|
||||||
|
roleIds: record.roles?.map(i => i.roleId) || []
|
||||||
|
});
|
||||||
|
|
||||||
|
setSiteList([]);
|
||||||
|
if (userInfo?.userId === 1) {
|
||||||
|
getOrgData();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
setModalVisible(true);
|
setModalVisible(true);
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -276,7 +312,9 @@ export default function UserRolePage() {
|
|||||||
|
|
||||||
const handleSaveUser = () => {
|
const handleSaveUser = () => {
|
||||||
form.validateFields().then(values => {
|
form.validateFields().then(values => {
|
||||||
const params = { ...values, roleIds: values.roleIds || [] };
|
const params = {
|
||||||
|
...values, roleIds: values.roleIds ? [values.roleIds] : []
|
||||||
|
};
|
||||||
if (currentUser) params.userId = currentUser.userId;
|
if (currentUser) params.userId = currentUser.userId;
|
||||||
|
|
||||||
const api = currentUser ? editUser : addUser;
|
const api = currentUser ? editUser : addUser;
|
||||||
@@ -436,7 +474,6 @@ export default function UserRolePage() {
|
|||||||
width={560}
|
width={560}
|
||||||
>
|
>
|
||||||
<Form form={roleForm} layout="vertical">
|
<Form form={roleForm} layout="vertical">
|
||||||
{/* 一行两个:角色名称 + 权限标识 */}
|
|
||||||
<Row gutter={16}>
|
<Row gutter={16}>
|
||||||
<Col span={12}>
|
<Col span={12}>
|
||||||
<Form.Item name="roleName" label="角色名称" rules={[{ required: true }]}>
|
<Form.Item name="roleName" label="角色名称" rules={[{ required: true }]}>
|
||||||
@@ -450,7 +487,6 @@ export default function UserRolePage() {
|
|||||||
</Col>
|
</Col>
|
||||||
</Row>
|
</Row>
|
||||||
|
|
||||||
{/* 一行两个:排序 + 状态 */}
|
|
||||||
<Row gutter={16}>
|
<Row gutter={16}>
|
||||||
<Col span={12}>
|
<Col span={12}>
|
||||||
<Form.Item name="roleSort" label="排序">
|
<Form.Item name="roleSort" label="排序">
|
||||||
@@ -464,7 +500,6 @@ export default function UserRolePage() {
|
|||||||
</Col>
|
</Col>
|
||||||
</Row>
|
</Row>
|
||||||
|
|
||||||
{/* 场站权限 */}
|
|
||||||
<Row gutter={16}>
|
<Row gutter={16}>
|
||||||
<Col span={12}>
|
<Col span={12}>
|
||||||
<Form.Item name="siteAccess" label="是否有场站权限" valuePropName="checked">
|
<Form.Item name="siteAccess" label="是否有场站权限" valuePropName="checked">
|
||||||
@@ -474,7 +509,6 @@ export default function UserRolePage() {
|
|||||||
<Col span={12}></Col>
|
<Col span={12}></Col>
|
||||||
</Row>
|
</Row>
|
||||||
|
|
||||||
{/* 菜单权限 */}
|
|
||||||
{userInfo?.roleId == 23 && (
|
{userInfo?.roleId == 23 && (
|
||||||
<>
|
<>
|
||||||
<Divider>菜单权限</Divider>
|
<Divider>菜单权限</Divider>
|
||||||
@@ -530,6 +564,7 @@ export default function UserRolePage() {
|
|||||||
</Form.Item>
|
</Form.Item>
|
||||||
</Col>
|
</Col>
|
||||||
</Row>
|
</Row>
|
||||||
|
|
||||||
<Row gutter={16}>
|
<Row gutter={16}>
|
||||||
<Col span={12}>
|
<Col span={12}>
|
||||||
<Form.Item name="sex" label="性别" initialValue="2">
|
<Form.Item name="sex" label="性别" initialValue="2">
|
||||||
@@ -540,12 +575,47 @@ export default function UserRolePage() {
|
|||||||
</Select>
|
</Select>
|
||||||
</Form.Item>
|
</Form.Item>
|
||||||
</Col>
|
</Col>
|
||||||
{roleDetail?.siteAccess && (
|
|
||||||
|
{/* 管理员:组织 + 场站 */}
|
||||||
|
{userInfo?.userId == 1 ? (
|
||||||
|
<>
|
||||||
|
<Col span={12}>
|
||||||
|
<Form.Item name="orgId" label="所属组织">
|
||||||
|
<Select
|
||||||
|
placeholder="请选择组织"
|
||||||
|
allowClear
|
||||||
|
onChange={(val) => {
|
||||||
|
getSiteByOrg(val);
|
||||||
|
form.setFieldsValue({ siteId: null });
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
{orgList.map(item => (
|
||||||
|
<Select.Option key={item.id} value={item.id}>{item.orgName}</Select.Option>
|
||||||
|
))}
|
||||||
|
</Select>
|
||||||
|
</Form.Item>
|
||||||
|
</Col>
|
||||||
|
|
||||||
|
{siteList.length > 0 && (
|
||||||
|
<Col span={12}>
|
||||||
|
<Form.Item name="siteId" label="所属场站">
|
||||||
|
<Select placeholder="请选择场站" allowClear>
|
||||||
|
{siteList.map(item => (
|
||||||
|
<Select.Option key={item.id} value={item.id}>{item.siteName}</Select.Option>
|
||||||
|
))}
|
||||||
|
</Select>
|
||||||
|
</Form.Item>
|
||||||
|
</Col>
|
||||||
|
)}
|
||||||
|
</>
|
||||||
|
) : (
|
||||||
|
roleDetail?.siteAccess && (
|
||||||
<Col span={12}>
|
<Col span={12}>
|
||||||
<Form.Item name="siteId" label="场站ID">
|
<Form.Item name="siteId" label="场站ID">
|
||||||
<Input />
|
<Input />
|
||||||
</Form.Item>
|
</Form.Item>
|
||||||
</Col>
|
</Col>
|
||||||
|
)
|
||||||
)}
|
)}
|
||||||
</Row>
|
</Row>
|
||||||
</Form>
|
</Form>
|
||||||
|
|||||||
Reference in New Issue
Block a user