|
|
@ -5,17 +5,25 @@ import { labeledKtjOrgs } from '../../utils/helper'; |
|
|
|
import { ktjOrgs } from '../../utils/constant'; |
|
|
|
import Bridge from '../../utils/bridge'; |
|
|
|
import { RootState } from '..'; |
|
|
|
import { SyncBaseStatus } from '../../services/mobileWsType'; |
|
|
|
|
|
|
|
interface BaseDataState { |
|
|
|
ktjOrgs: KTJOrg[]; |
|
|
|
railTypes: RailType[]; |
|
|
|
syncingBaseData: boolean; |
|
|
|
// syncingBaseData: boolean;
|
|
|
|
syncBaseProgress: SyncBaseStatus['data']; |
|
|
|
} |
|
|
|
|
|
|
|
const initialState: BaseDataState = { |
|
|
|
ktjOrgs: ktjOrgs as KTJOrg[], |
|
|
|
railTypes: [], |
|
|
|
syncingBaseData: false, |
|
|
|
// syncingBaseData: false,
|
|
|
|
syncBaseProgress: { |
|
|
|
msg: '', |
|
|
|
progress: 0, |
|
|
|
finish: true, |
|
|
|
error: false, |
|
|
|
}, |
|
|
|
}; |
|
|
|
|
|
|
|
export const fetchRailTypes = createAsyncThunk('base/fetchRailTypes', async (_, thunkAPI) => { |
|
|
@ -45,17 +53,20 @@ export const baseDataSlice = createSlice({ |
|
|
|
r.calPoints = action.payload.calPoints; |
|
|
|
} |
|
|
|
}, |
|
|
|
updateSyncBaseProgress: (state, action: PayloadAction<SyncBaseStatus['data']>) => { |
|
|
|
state.syncBaseProgress = action.payload; |
|
|
|
}, |
|
|
|
}, |
|
|
|
extraReducers: (builder) => { |
|
|
|
builder.addCase(fetchRailTypes.fulfilled, (state, action) => { |
|
|
|
state.railTypes = action.payload || []; |
|
|
|
}); |
|
|
|
builder.addCase(syncBaseData.pending, (state) => { |
|
|
|
state.syncingBaseData = true; |
|
|
|
}); |
|
|
|
builder.addCase(syncBaseData.fulfilled, (state) => { |
|
|
|
state.syncingBaseData = false; |
|
|
|
}); |
|
|
|
// builder.addCase(syncBaseData.pending, (state) => {
|
|
|
|
// state.syncingBaseData = true;
|
|
|
|
// });
|
|
|
|
// builder.addCase(syncBaseData.fulfilled, (state) => {
|
|
|
|
// state.syncingBaseData = false;
|
|
|
|
// });
|
|
|
|
builder.addCase(fetchOrgTree.fulfilled, (state, action) => { |
|
|
|
if (action.payload.success) { |
|
|
|
state.ktjOrgs = action.payload.data; |
|
|
@ -64,7 +75,7 @@ export const baseDataSlice = createSlice({ |
|
|
|
}, |
|
|
|
}); |
|
|
|
|
|
|
|
export const { updateRailPoints } = baseDataSlice.actions; |
|
|
|
export const { updateRailPoints, updateSyncBaseProgress } = baseDataSlice.actions; |
|
|
|
export default baseDataSlice.reducer; |
|
|
|
|
|
|
|
export const selectKtjOrgs = (state: RootState) => state.baseData.ktjOrgs; |
|
|
|