This commit is contained in:
mmc
2026-04-30 15:02:08 +08:00
parent b67133c202
commit 688883b0f5
4 changed files with 140 additions and 25 deletions

View File

@@ -10,6 +10,9 @@ import {
getStationList, saveSite, deleteSite,
getStationRegions, saveRegion, deleteRegion
} from '../api/stationManage';
import { getOrgList } from '../api/organization';
import { useSelector } from 'react-redux';
import { RootState } from '../store';
const { Option } = Select;
@@ -18,6 +21,12 @@ export default function StationManage() {
const [currentStation, setCurrentStation] = useState(null);
const [regionList, setRegionList] = useState([]);
// 组织列表
const [orgList, setOrgList] = useState([]);
// 获取当前登录用户信息
const { userInfo } = useSelector((state: RootState) => state.user);
// 场站弹窗
const [modalVisible, setModalVisible] = useState(false);
const [form] = Form.useForm();
@@ -39,6 +48,21 @@ export default function StationManage() {
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 params = {
@@ -66,8 +90,10 @@ export default function StationManage() {
});
};
// 初始化加载
useEffect(() => {
getStationData();
getOrgData(); // 进入页面就加载组织
}, [pagination.pageNum, pagination.pageSize]);
// ====================== 新增 / 编辑 场站 ======================
@@ -80,7 +106,10 @@ export default function StationManage() {
const handleEdit = (record) => {
setEditRecord(record);
form.setFieldsValue({ ...record, status: record.status === 1 });
form.setFieldsValue({
...record,
status: record.status === 1
});
setModalVisible(true);
};
@@ -244,8 +273,14 @@ export default function StationManage() {
</Col>
</Row>
<Form.Item name="orgId" label="所属组织ID">
<Input placeholder="选填" />
<Form.Item name="orgId" label="所属组织">
<Select placeholder="请选择所属组织" allowClear>
{orgList.map(item => (
<Select.Option key={item.id} value={item.orgId}>
{item.orgName}
</Select.Option>
))}
</Select>
</Form.Item>
<Row gutter={16}>