12 changed files with 335 additions and 137 deletions
-
6src/index.tsx
-
78src/pages/measure/components/MeasureAction.tsx
-
101src/pages/measure/components/MeasureConfig.tsx
-
4src/pages/measure/components/RadioItem.tsx
-
10src/services/apiTypes.ts
-
16src/services/calibration/calibration.ts
-
12src/services/device/deviceState.ts
-
134src/services/measure/analysis.ts
-
16src/services/standardRail/standardRail.ts
-
55src/store/features/baseDataSlice.ts
-
36src/store/features/contextSlice.ts
-
4src/store/index.ts
@ -0,0 +1,10 @@ |
|||||
|
export interface Rail { |
||||
|
id: number; |
||||
|
code: string; |
||||
|
name: string; |
||||
|
} |
||||
|
|
||||
|
export interface Calibration { |
||||
|
id: number; |
||||
|
name: string; |
||||
|
} |
@ -0,0 +1,16 @@ |
|||||
|
import { Calibration } from "../apiTypes"; |
||||
|
import httpRequest, { BaseResponse } from "../httpRequest"; |
||||
|
|
||||
|
export function getCalibrationTypes() { |
||||
|
return httpRequest<BaseResponse<Calibration[]>>({ |
||||
|
url: "/api/calibration/list", |
||||
|
method: "POST", |
||||
|
}); |
||||
|
} |
||||
|
|
||||
|
export function deleteCalibrationTypes(ids: number[]) { |
||||
|
return httpRequest<BaseResponse>({ |
||||
|
url: `/api/calibration/delete/${ids.join(",")}`, |
||||
|
method: "POST", |
||||
|
}); |
||||
|
} |
@ -1,9 +1,9 @@ |
|||||
import httpRequest, { type BaseResponse } from "../httpRequest"; |
import httpRequest, { type BaseResponse } from "../httpRequest"; |
||||
import type { Device } from "../../services/measure/type"; |
|
||||
|
import type { Device } from "../measure/type"; |
||||
|
|
||||
export function getDeviceInfo() { |
export function getDeviceInfo() { |
||||
return httpRequest<BaseResponse<{list:Device[]}>>({ |
|
||||
url: "/api/measurement-data/getDevice", |
|
||||
method: "POST", |
|
||||
}); |
|
||||
} |
|
||||
|
return httpRequest<BaseResponse<{ list: Device[] }>>({ |
||||
|
url: "/api/measurement-data/getDevice", |
||||
|
method: "POST", |
||||
|
}); |
||||
|
} |
@ -0,0 +1,16 @@ |
|||||
|
import { Rail } from "../apiTypes"; |
||||
|
import httpRequest, { BaseResponse } from "../httpRequest"; |
||||
|
|
||||
|
export function getRailTypes() { |
||||
|
return httpRequest<BaseResponse<Rail[]>>({ |
||||
|
url: "/api/standard-rail/list", |
||||
|
method: "POST", |
||||
|
}); |
||||
|
} |
||||
|
|
||||
|
export function deleteRailTypes(ids: number[]) { |
||||
|
return httpRequest<BaseResponse>({ |
||||
|
url: `/api/standard-rail/delete/${ids.join(",")}`, |
||||
|
method: "POST", |
||||
|
}); |
||||
|
} |
@ -0,0 +1,55 @@ |
|||||
|
// counterSlice.ts 文件
|
||||
|
|
||||
|
import { createAsyncThunk, createSlice, PayloadAction } from "@reduxjs/toolkit"; |
||||
|
import { Calibration, Rail } from "../../services/apiTypes"; |
||||
|
import { getRailTypes } from "../../services/standardRail/standardRail"; |
||||
|
import { getCalibrationTypes } from "../../services/calibration/calibration"; |
||||
|
|
||||
|
export interface BaseDataState { |
||||
|
railTypes: Rail[]; |
||||
|
calibrationTypes: Calibration[]; |
||||
|
} |
||||
|
const initialState: BaseDataState = { |
||||
|
// 轨型列表
|
||||
|
railTypes: [], |
||||
|
// 核校类型列表
|
||||
|
calibrationTypes: [], |
||||
|
}; |
||||
|
|
||||
|
export const fetchRailTypes = createAsyncThunk("fetchRailTypes", async () => { |
||||
|
const res = await getRailTypes(); |
||||
|
return res.success ? res.data : []; |
||||
|
}); |
||||
|
export const fetchCalibrationTypes = createAsyncThunk("fetchCalibrationTypes", async () => { |
||||
|
const res = await getCalibrationTypes(); |
||||
|
return res.success ? res.data : []; |
||||
|
}); |
||||
|
|
||||
|
export const baseDataSlice = createSlice({ |
||||
|
name: "baseData", |
||||
|
initialState, |
||||
|
|
||||
|
reducers: { |
||||
|
updateRailTypes: (state, action: PayloadAction<Rail[]>) => { |
||||
|
state.railTypes = action.payload; |
||||
|
}, |
||||
|
updateCalibrationTypes: (state, action: PayloadAction<Calibration[]>) => { |
||||
|
state.calibrationTypes = action.payload; |
||||
|
}, |
||||
|
}, |
||||
|
|
||||
|
extraReducers: builder => { |
||||
|
builder.addCase(fetchRailTypes.fulfilled, (state, action) => { |
||||
|
state.railTypes = action.payload; |
||||
|
}); |
||||
|
builder.addCase(fetchCalibrationTypes.fulfilled, (state, action) => { |
||||
|
state.calibrationTypes = action.payload; |
||||
|
}); |
||||
|
}, |
||||
|
}); |
||||
|
|
||||
|
// 导出加减的方法
|
||||
|
export const { updateRailTypes, updateCalibrationTypes } = baseDataSlice.actions; |
||||
|
|
||||
|
// 默认导出
|
||||
|
export default baseDataSlice.reducer; |
Write
Preview
Loading…
Cancel
Save
Reference in new issue