场站更新优化
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import React, { useEffect, useRef, useState, useMemo, useImperativeHandle, forwardRef, useCallback } from 'react';
|
||||
import React, { useEffect, useRef, useState, useMemo, useImperativeHandle, forwardRef, useCallback } from 'react';
|
||||
import carImg from '../assets/images/carplane.png';
|
||||
import inspectImg from "../assets/images/inspectCar.png"
|
||||
import planeImg from '../assets/images/planeicon.png';
|
||||
|
||||
@@ -14,7 +14,8 @@ import {
|
||||
import { getOrgList } from '../../api/organization';
|
||||
import { fetchPublishedLayers } from '../../lib/geoServer';
|
||||
import { useSelector } from 'react-redux';
|
||||
import { RootState } from '../../store';
|
||||
import { useAppDispatch, RootState } from '../../store';
|
||||
import { setCurrentStation as setStoreStation } from '../../store/stationSlice';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
|
||||
const { Option } = Select;
|
||||
@@ -35,6 +36,8 @@ export default function StationManage() {
|
||||
|
||||
// 获取当前登录用户信息
|
||||
const { userInfo } = useSelector((state: RootState) => state.user);
|
||||
const dispatch = useAppDispatch();
|
||||
const { currentStation: storeStation } = useSelector((state: RootState) => state.station);
|
||||
|
||||
// 场站弹窗
|
||||
const [modalVisible, setModalVisible] = useState(false);
|
||||
@@ -94,6 +97,7 @@ export default function StationManage() {
|
||||
getStationList(params).then(res => {
|
||||
if (res.code === 200) {
|
||||
setStationList(res.rows || []);
|
||||
|
||||
setPagination({
|
||||
...pagination,
|
||||
total: res.total || res.rows?.length || 0
|
||||
@@ -190,6 +194,10 @@ export default function StationManage() {
|
||||
if (res.code === 200) {
|
||||
messageApi.success(editRecord ? t('common.editSuccess') : t('common.addSuccess'));
|
||||
getStationData();
|
||||
// 编辑的场站若正是当前选中场站,则同步更新到 store(尤其 siteMapName)
|
||||
if (editRecord && storeStation && editRecord.id === storeStation.id) {
|
||||
dispatch(setStoreStation({ ...storeStation, ...params }));
|
||||
}
|
||||
setModalVisible(false);
|
||||
} else {
|
||||
messageApi.error(res.msg || t('common.saveFail'));
|
||||
|
||||
Reference in New Issue
Block a user