Compare commits
merge into: zhangjiming:master
zhangjiming:dev
zhangjiming:feat_upload_server_url_0416
zhangjiming:feature/0607-opt
zhangjiming:feature/rail
zhangjiming:master
pull from: zhangjiming:dev
zhangjiming:dev
zhangjiming:feat_upload_server_url_0416
zhangjiming:feature/0607-opt
zhangjiming:feature/rail
zhangjiming:master
3 Commits
Author | SHA1 | Message | Date |
---|---|---|---|
|
b4cbc4bd36 |
添加删除轨型和核校的异步Action
|
5 months ago |
|
208d255329 |
轨型和核校做为基础数据,控件关联数据
|
5 months ago |
|
051f0d3798 |
添加轨型和核校选择静态组件
|
5 months ago |
18 changed files with 494 additions and 123 deletions
-
1src/assets/icon_arr_down_s.svg
-
1src/assets/icon_dest.svg
-
1src/assets/icon_selected.svg
-
1src/assets/icon_track.svg
-
1src/assets/icon_unselect.svg
-
6src/index.tsx
-
115src/pages/measure/components/MeasureAction.tsx
-
112src/pages/measure/components/MeasureConfig.tsx
-
13src/pages/measure/components/RadioItem.tsx
-
17src/pages/measure/components/SelectorBtn.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
-
121src/store/features/baseDataSlice.ts
-
36src/store/features/contextSlice.ts
-
4src/store/index.ts
@ -0,0 +1 @@ |
|||
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" fill="none" version="1.1" width="11.874804496765137" height="8" viewBox="0 0 11.874804496765137 8"><g><path d="M11.7502,0C11.7502,0,10.5783,0,10.5783,0C10.4986,0,10.4236,0.0390626,10.3768,0.103125C10.3768,0.103125,5.9377,6.22188,5.9377,6.22188C5.9377,6.22188,1.49864,0.103125,1.49864,0.103125C1.45176,0.0390626,1.37676,0,1.29707,0C1.29707,0,0.125198,0,0.125198,0C0.0236354,0,-0.0357396,0.115625,0.0236354,0.198438C0.0236354,0.198438,5.53301,7.79375,5.53301,7.79375C5.73301,8.06875,6.14239,8.06875,6.34082,7.79375C6.34082,7.79375,11.8502,0.198438,11.8502,0.198438C11.9111,0.115625,11.8518,0,11.7502,0C11.7502,0,11.7502,0,11.7502,0Z" fill="#000000" fill-opacity="0.25"/></g></svg> |
@ -0,0 +1 @@ |
|||
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" fill="none" version="1.1" width="30" height="30" viewBox="0 0 30 30"><defs><clipPath id="master_svg0_3_00832"><rect x="0" y="0" width="30" height="30" rx="0"/></clipPath></defs><g clip-path="url(#master_svg0_3_00832)"><g><path d="M17.522706562499998,15.976019921875L12.4769035625,15.976019921875C11.9401435625,15.976019921875,11.5009765625,15.536859921875,11.5009765625,15.000096921875C11.5009765625,14.463336921875,11.9401435625,14.024169921875,12.4769035625,14.024169921875L17.522706562499998,14.024169921875C18.0594665625,14.024169921875,18.4986365625,14.463336921875,18.4986365625,15.000096921875C18.4986365625,15.536859921875,18.0594665625,15.976019921875,17.522706562499998,15.976019921875Z" fill="#5F5F5F" fill-opacity="1" style="mix-blend-mode:passthrough"/></g><g><path d="M15.9759,12.4771L15.9759,17.5229C15.9759,18.0597,15.5368,18.4989,15,18.4989C14.4633,18.4989,14.0241,18.0597,14.0241,17.5229L14.0241,12.4771C14.0241,11.9403,14.4633,11.5011,15,11.5011C15.5368,11.5011,15.9759,11.9403,15.9759,12.4771ZM6.02305,15.9759L0.97718,15.9759C0.44042,15.9759,0.00125248,15.5368,0.00125248,15C0.00125248,14.4632,0.44042,14.0241,0.97718,14.0241L6.02302,14.0241C6.55978,14.0241,6.99894,14.4632,6.99894,15C6.99898,15.5368,6.55981,15.9759,6.02305,15.9759ZM29.0229,15.9759L23.977,15.9759C23.4402,15.9759,23.0011,15.5368,23.0011,15C23.0011,14.4632,23.4402,14.0241,23.977,14.0241L29.0229,14.0241C29.5596,14.0241,29.9988,14.4632,29.9988,15C29.9988,15.5368,29.5596,15.9759,29.0229,15.9759ZM16.021,0.975927L16.021,6.02183C16.021,6.55859,15.5818,6.99776,15.045,6.99776C14.5083,6.99776,14.0691,6.55859,14.0691,6.02183L14.0691,0.975927C14.0691,0.439167,14.5083,0,15.045,0C15.5818,0,16.021,0.439167,16.021,0.975927ZM16.021,23.9782L16.021,29.0241C16.021,29.5608,15.5818,30,15.045,30C14.5083,30,14.0691,29.5608,14.0691,29.0241L14.0691,23.9782C14.0691,23.4414,14.5083,23.0023,15.045,23.0023C15.5818,23.0023,16.021,23.4414,16.021,23.9782Z" fill="#5F5F5F" fill-opacity="1" style="mix-blend-mode:passthrough"/></g><g><path d="M15.04506640625,27.683050390625C13.34586640625,27.683050390625,11.69707640625,27.350050390625,10.144346406250001,26.693350390625C8.645096406250001,26.059150390625,7.29883640625,25.151550390625,6.14294640625,23.995650390625C4.98705640625,22.839850390625,4.07944640625,21.493550390625,3.44531940625,19.994250390625C2.78858540625,18.441550390625,2.45556640625,16.792750390625002,2.45556640625,15.093650390625C2.45556640625,13.394450390625,2.78855240625,11.745630390625,3.44531940625,10.192930390625001C4.07944640625,8.693680390625001,4.98708640625,7.347380390625,6.14294640625,6.191530390625C7.29879640625,5.035670390625,8.645096406250001,4.128030390625,10.144346406250001,3.493903390625C11.69707640625,2.837169390625,13.34586640625,2.504150390625,15.04506640625,2.504150390625C16.744166406250002,2.504150390625,18.39296640625,2.837136390625,19.94566640625,3.493903390625C21.44496640625,4.128030390625,22.79126640625,5.035640390625,23.94706640625,6.191530390625C25.10296640625,7.347420390625,26.01056640625,8.693680390625001,26.64476640625,10.192930390625001C27.30146640625,11.745630390625,27.63446640625,13.394450390625,27.63446640625,15.093650390625C27.63446640625,16.792750390625002,27.30146640625,18.441550390625,26.64476640625,19.994250390625C26.01056640625,21.493550390625,25.10296640625,22.839850390625,23.94706640625,23.995650390625C22.79126640625,25.151550390625,21.44496640625,26.059150390625,19.94566640625,26.693350390625C18.39296640625,27.350050390625,16.744166406250002,27.683050390625,15.04506640625,27.683050390625ZM15.04506640625,4.456000390625C9.179446406250001,4.456000390625,4.40741640625,9.228030390625001,4.40741640625,15.093650390625C4.40741640625,20.959250390625,9.179446406250001,25.731250390625,15.04506640625,25.731250390625C20.91066640625,25.731250390625,25.68266640625,20.959250390625,25.68266640625,15.093650390625C25.68266640625,9.228030390625001,20.91056640625,4.456000390625,15.04506640625,4.456000390625Z" fill="#5F5F5F" fill-opacity="1" style="mix-blend-mode:passthrough"/></g></g></svg> |
1
src/assets/icon_selected.svg
File diff suppressed because it is too large
View File
File diff suppressed because it is too large
View File
1
src/assets/icon_track.svg
File diff suppressed because it is too large
View File
File diff suppressed because it is too large
View File
1
src/assets/icon_unselect.svg
File diff suppressed because it is too large
View File
File diff suppressed because it is too large
View File
@ -0,0 +1,13 @@ |
|||
import icon_select from "../../../assets/icon_selected.svg"; |
|||
import icon_unselect from "../../../assets/icon_unselect.svg"; |
|||
|
|||
export default function RadioItem(props: { label: string; selected: boolean; onSelect?: () => void }) { |
|||
return ( |
|||
<div |
|||
className="h-10 border-b border-[#f7f7f7] flex justify-between items-center" |
|||
onClick={() => props.onSelect && props.onSelect()}> |
|||
<p className="text-sm text-text">{props.label}</p> |
|||
<img src={props.selected ? icon_select : icon_unselect} alt="icon" /> |
|||
</div> |
|||
); |
|||
} |
@ -0,0 +1,17 @@ |
|||
import { ReactNode } from "react"; |
|||
import icon_arr from "../../../assets/icon_arr_down_s.svg"; |
|||
|
|||
export default function SelectorBtn({ imgNode, text, onClick }: { imgNode: () => ReactNode; text: string; onClick: () => void }) { |
|||
return ( |
|||
<div className="flex items-center gap-2 cursor-pointer" onClick={onClick}> |
|||
<div className="w-[24px] h-[24px]"> |
|||
{imgNode()} |
|||
</div> |
|||
|
|||
<div className="flex items-center px-2 border border-[#e7e7e7] rounded h-7 min-w-[120px] gap-2 text-sm "> |
|||
<span>{text}</span> |
|||
<img src={icon_arr} alt="arr" className="w-2 ml-auto" /> |
|||
</div> |
|||
</div> |
|||
); |
|||
} |
@ -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 type { Device } from "../../services/measure/type"; |
|||
import type { Device } from "../measure/type"; |
|||
|
|||
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,121 @@ |
|||
// counterSlice.ts 文件
|
|||
|
|||
import { createAsyncThunk, createSlice, PayloadAction } from "@reduxjs/toolkit"; |
|||
import { Calibration, Rail } from "../../services/apiTypes"; |
|||
import { deleteRailTypes, getRailTypes } from "../../services/standardRail/standardRail"; |
|||
import { deleteCalibrationTypes, getCalibrationTypes } from "../../services/calibration/calibration"; |
|||
|
|||
export interface BaseDataState { |
|||
loading: boolean; |
|||
error: string; |
|||
railTypes: Rail[]; |
|||
calibrationTypes: Calibration[]; |
|||
} |
|||
const initialState: BaseDataState = { |
|||
loading: false, |
|||
error: "", |
|||
// 轨型列表
|
|||
railTypes: [], |
|||
// 核校类型列表
|
|||
calibrationTypes: [], |
|||
}; |
|||
|
|||
// 可以添加泛型参数,第一个是 成功返回类型,第二个是 入参类型,第三个是 reject返回类型
|
|||
// createAsyncThunk<Rail[], void, { rejectValue: { msg: string } }>
|
|||
export const fetchRailTypes = createAsyncThunk("fetchRailTypes", async (_, thunkAPI) => { |
|||
try { |
|||
const res = await getRailTypes(); |
|||
if (res.success) { |
|||
return res.data; |
|||
} else { |
|||
return thunkAPI.rejectWithValue({ msg: res.data.info }); |
|||
} |
|||
} catch (error: any) { |
|||
return thunkAPI.rejectWithValue({ msg: (error.message as string) || "请求失败" }); |
|||
} |
|||
}); |
|||
export const deleteRailType = createAsyncThunk("deleteRailType", async (ids: number[], thunkAPI) => { |
|||
try { |
|||
const res = await deleteRailTypes(ids); |
|||
if (res.success) { |
|||
thunkAPI.dispatch(fetchRailTypes()); |
|||
} else { |
|||
return thunkAPI.rejectWithValue({ msg: res.data.info }); |
|||
} |
|||
} catch (error: any) { |
|||
return thunkAPI.rejectWithValue({ msg: (error.message as string) || "请求失败" }); |
|||
} |
|||
}); |
|||
export const fetchCalibrationTypes = createAsyncThunk("fetchCalibrationTypes", async (_, thunkAPI) => { |
|||
try { |
|||
const res = await getCalibrationTypes(); |
|||
if (res.success) { |
|||
return res.data; |
|||
} else { |
|||
return thunkAPI.rejectWithValue({ msg: res.data.info }); |
|||
} |
|||
} catch (error: any) { |
|||
return thunkAPI.rejectWithValue({ msg: (error.message as string) || "请求失败" }); |
|||
} |
|||
}); |
|||
export const deleteCalibrationType = createAsyncThunk("deleteCalibrationType", async (ids: number[], thunkAPI) => { |
|||
try { |
|||
const res = await deleteCalibrationTypes(ids); |
|||
if (res.success) { |
|||
thunkAPI.dispatch(fetchCalibrationTypes()); |
|||
} else { |
|||
return thunkAPI.rejectWithValue({ msg: res.data.info }); |
|||
} |
|||
} catch (error: any) { |
|||
return thunkAPI.rejectWithValue({ msg: (error.message as string) || "请求失败" }); |
|||
} |
|||
}); |
|||
|
|||
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; |
|||
}); |
|||
|
|||
builder.addMatcher( |
|||
action => action.type.endsWith("/pending"), |
|||
state => { |
|||
state.loading = true; |
|||
state.error = ""; |
|||
} |
|||
); |
|||
builder.addMatcher( |
|||
action => action.type.endsWith("/fulfilled"), |
|||
state => { |
|||
state.loading = false; |
|||
state.error = ""; |
|||
} |
|||
); |
|||
builder.addMatcher( |
|||
action => action.type.endsWith("/rejected"), |
|||
(state, action: PayloadAction<{ msg: string }>) => { |
|||
state.loading = false; |
|||
state.error = action.payload?.msg || "请求失败"; |
|||
} |
|||
); |
|||
}, |
|||
}); |
|||
|
|||
// export const { updateRailTypes, updateCalibrationTypes } = baseDataSlice.actions;
|
|||
|
|||
export default baseDataSlice.reducer; |
Write
Preview
Loading…
Cancel
Save
Reference in new issue