From 0e04d1b0acba5b389eca41bc1e5d5c8b4f27b134 Mon Sep 17 00:00:00 2001 From: zhangjiming Date: Wed, 2 Apr 2025 21:53:47 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8B=86=E5=88=86=E6=B5=8B=E9=87=8F=E8=AE=B0?= =?UTF-8?q?=E5=BD=95=E5=92=8C=E4=B8=8A=E4=BC=A0=E8=AE=B0=E5=BD=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/App.tsx | 2 +- src/index.tsx | 10 +- src/pages/MeasurementList.tsx | 84 +++++++++++++ src/pages/Mine2.tsx | 143 +++------------------ src/pages/UploadList.tsx | 65 ++++++++++ src/utils/bridge.ts | 32 ++--- src/utils/constant.ts | 282 ++++++++++++++++++++++++++++++------------ 7 files changed, 391 insertions(+), 227 deletions(-) create mode 100644 src/pages/MeasurementList.tsx create mode 100644 src/pages/UploadList.tsx diff --git a/src/App.tsx b/src/App.tsx index 7177710..3cb2ac2 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -29,7 +29,7 @@ const BottomBar = () => { const tabs = [ { key: '/home/measure', - title: '首页', + title: '测量', icon_s: icon_1_s, icon_n: icon_1_u, }, diff --git a/src/index.tsx b/src/index.tsx index 95741e6..f95831d 100644 --- a/src/index.tsx +++ b/src/index.tsx @@ -20,6 +20,8 @@ import Mine from './pages/Mine'; import Mine2 from './pages/Mine2'; import MeasureSave from './pages/MeasureSave'; import MeasureRecord from './pages/MeasureRecord'; +import MeasurementList from './pages/MeasurementList'; +import UploadList from './pages/UploadList'; const router = createHashRouter( createRoutesFromElements( @@ -33,6 +35,8 @@ const router = createHashRouter( }> + } /> + } /> }> @@ -42,9 +46,9 @@ const router = createHashRouter( const root = ReactDOM.createRoot(document.getElementById('root') as HTMLElement); root.render( // - - - + + + // ); diff --git a/src/pages/MeasurementList.tsx b/src/pages/MeasurementList.tsx new file mode 100644 index 0000000..b50184d --- /dev/null +++ b/src/pages/MeasurementList.tsx @@ -0,0 +1,84 @@ +import { NavBar } from 'antd-mobile'; +import { useNavigate } from 'react-router-dom'; +import MeasureGroups from '../components/MeasureGroups'; +import { useState } from 'react'; +import { Measurement } from '../services/apiTypes'; +import * as R from 'ramda'; +import { MoreOutline, UploadOutline } from 'antd-mobile-icons'; + +import { dataList } from '../utils/constant'; + +const PAGE_SIZE = 10; + +export default function MeasurementList() { + const navigate = useNavigate(); + + const [editMode, setEditMode] = useState(false); + const [selectedIds, setSelectedIds] = useState([]); + async function loadMoreRecords() {} + + const onItemSelect = (groupIdx: number, id: number) => { + if (selectedIds.includes(id)) { + setSelectedIds(R.reject((item) => item === id, selectedIds)); + } else { + setSelectedIds([...selectedIds, id]); + } + }; + + const onGroupSelect = (groupIdx: number) => { + const ids = dataList[groupIdx].list.map((item) => item.id); + if (R.intersection(selectedIds, ids).length === ids.length) { + setSelectedIds(R.difference(selectedIds, ids)); + } else { + setSelectedIds(R.union(selectedIds, ids)); + } + }; + + const onUploadClick = () => { + navigate("/measure/upload") + } + + const right = ( +
+ navigate("/measure/upload")} /> + setEditMode(!editMode)}/> +
+ ); + + const back = () => navigate(-1); + return ( +
+ + 测量记录 + +
+ +
+ + +
+
+
+ ); +} diff --git a/src/pages/Mine2.tsx b/src/pages/Mine2.tsx index f3025e1..581e2b3 100644 --- a/src/pages/Mine2.tsx +++ b/src/pages/Mine2.tsx @@ -1,138 +1,25 @@ -import { NavBar, Toast } from 'antd-mobile'; -import { useEffect, useRef, useState } from 'react'; -import { Measurement } from '../services/apiTypes'; -import Bridge from '../utils/bridge'; -import MeasureGroups from '../components/MeasureGroups'; -import { MoreOutline } from 'antd-mobile-icons'; -import * as R from 'ramda'; +import { List, NavBar } from 'antd-mobile'; -const PAGE_SIZE = 10; - -const dataList: Array<{ groupName: string; list: Measurement[] }> = [ - { - groupName: '2025-03-02', - list: [ - { - id: 1, - name: '测量名称1', - createAt: '2025-03-02 10:20', - line: '京沪线', - section: 'A段', - direction: '上行', - railId: 2, - leftPoints: '[]', - rightPoints: '[]', - bureau: '北京铁路局', - upload: false, - }, - { - id: 2, - name: '测量名称2', - createAt: '2025-03-02 12:22', - line: '京沪线', - section: 'B段', - direction: '下行', - railId: 2, - leftPoints: '[]', - rightPoints: '[]', - bureau: '北京铁路局', - upload: false, - }, - { - id: 3, - name: '测量名称3', - createAt: '2025-03-02 12:20', - line: '京沪线', - section: 'C段', - direction: '上行', - railId: 2, - leftPoints: '[]', - rightPoints: '[]', - bureau: '北京铁路局', - upload: false, - }, - ], - }, - { - groupName: '2025-02-01', - list: [ - { - id: 4, - name: '测量名称2', - createAt: '2025-03-02 10:20', - line: '京沪线', - section: 'D段', - direction: '下行', - railId: 2, - leftPoints: '[]', - rightPoints: '[]', - bureau: '北京铁路局', - upload: false, - }, - { - id: 5, - name: '测量名称2', - createAt: '2025-03-02 10:20', - line: '京沪线', - section: 'E段', - direction: '下行', - railId: 2, - leftPoints: '[]', - rightPoints: '[]', - bureau: '北京铁路局', - upload: false, - }, - ], - }, -]; +import { UnorderedListOutline, SetOutline } from 'antd-mobile-icons'; +import { useNavigate } from 'react-router-dom'; export default function Mine2() { - const [editMode, setEditMode] = useState(false); - const [selectedIds, setSelectedIds] = useState([]); - async function loadMoreRecords() {} - - const onItemSelect = (groupIdx: number, id: number) => { - if (selectedIds.includes(id)) { - setSelectedIds(R.reject((item) => item === id, selectedIds)); - } else { - setSelectedIds([...selectedIds, id]); - } - }; - - const onGroupSelect = (groupIdx: number) => { - const ids = dataList[groupIdx].list.map((item) => item.id); - if (R.intersection(selectedIds, ids).length === ids.length) { - setSelectedIds(R.difference(selectedIds, ids)); - } else { - setSelectedIds(R.union(selectedIds, ids)); - } - }; - - const right = ( -
setEditMode(!editMode)} - className="flex justify-end" - style={{ fontSize: 24 }} - > - -
- ); - + const navigate = useNavigate(); return (
- + 我的 -
- +
+ + } onClick={() => navigate('/measure/records')}> + 测量记录 + + + } onClick={() => {}}> + 设置 + +
); diff --git a/src/pages/UploadList.tsx b/src/pages/UploadList.tsx new file mode 100644 index 0000000..b889097 --- /dev/null +++ b/src/pages/UploadList.tsx @@ -0,0 +1,65 @@ +import { ActionSheet, InfiniteScroll, List, NavBar, Popup } from 'antd-mobile'; +import { useNavigate } from 'react-router-dom'; + +import { MoreOutline } from 'antd-mobile-icons'; +import { useState } from 'react'; + +import { dataListFlat } from '../utils/constant'; +import MeasureGroups from '../components/MeasureGroups'; +import MeasureItem from '../components/MeasureItem'; + + +export default function UploadList() { + const navigate = useNavigate(); + + const [showMenu, setShowMenu] = useState(false); + + const actions = [ + { text: '重试失败任务', key: 'retry' }, + { text: '清空列表', key: 'clear' }, + { text: '清空已完成任务', key: 'clearCompleted' }, + ] + + const back = () => navigate(-1); + + const right = ( +
setShowMenu(!showMenu)} + className="flex justify-end gap-x-2" + style={{ fontSize: 24 }} + > + +
+ ); + + return ( +
+ + 上传数据 + +
+
+ 剩余任务10个 + + 失败0个 +

上传中

+
+
+ + {dataListFlat.map((item) => ( + + navigate(`/measure/record/${item.id}`)} /> + + ))} + {/* */} + +
+
+ setShowMenu(false)} + /> +
+ ); +} diff --git a/src/utils/bridge.ts b/src/utils/bridge.ts index 02325aa..f75629b 100644 --- a/src/utils/bridge.ts +++ b/src/utils/bridge.ts @@ -161,7 +161,7 @@ export default class Bridge { return httpRequest>({ url: '/api/mobile/getUploadedRecords', method: 'GET', - params: param + params: param, }); } } @@ -176,7 +176,7 @@ export default class Bridge { return httpRequest>({ url: '/api/mobile/getUnuploadRecords', method: 'GET', - params: param + params: param, }); } } @@ -191,7 +191,7 @@ export default class Bridge { return httpRequest>({ url: '/api/mobile/searchHistoryRecords', method: 'GET', - params: param + params: param, }); } } @@ -206,23 +206,23 @@ export default class Bridge { return httpRequest>({ url: '/api/mobile/getMeasurementDetail', method: 'GET', - params: param + params: param, }); } } - static uploadRecords(param: {ids: number[]}) { + static uploadRecords(param: { ids: number[] }) { if (appWebview) { - return new Promise((resolve) => { - const res = window.SyncBridgeJS.call('uploadRecords', JSON.stringify(param)); - resolve(JSON.parse(res)); - }); - } else { - return httpRequest({ - url: '/api/mobile/uploadRecords', - method: 'POST', - params: param - }); - } + return new Promise((resolve) => { + const res = window.SyncBridgeJS.call('uploadRecords', JSON.stringify(param)); + resolve(JSON.parse(res)); + }); + } else { + return httpRequest({ + url: '/api/mobile/uploadRecords', + method: 'POST', + params: param, + }); + } } } diff --git a/src/utils/constant.ts b/src/utils/constant.ts index 613d9fb..a1b6f5a 100644 --- a/src/utils/constant.ts +++ b/src/utils/constant.ts @@ -1,89 +1,213 @@ +import { Measurement } from '../services/apiTypes'; + export const rail6001 = { - id: 1, - createTime: "2025-03-03 12:31:25", - updateTime: "2025-03-03 12:31:25", - name: "60型标准轨", - code: "6001", - points: "[{\"type\":\"arc\",\"start\": {\"x\": 0,\"y\": 0},\"end\": {\"x\": -9.949,\"y\": 0.165},\"radius\": 300,\"color\":\"#000000\",\"side\":\"right\"},{\"type\":\"arc\",\"start\": {\"x\": -9.949,\"y\": 0.165},\"end\": {\"x\": -25.35,\"y\": 2.185},\"radius\": 80,\"color\":\"#000000\",\"side\":\"right\"},{\"type\":\"arc\",\"start\": {\"x\": -25.35,\"y\": 2.185},\"end\": {\"x\": -35.4,\"y\": 14.2},\"radius\": 13,\"color\":\"#000000\",\"side\":\"right\"},{\"type\":\"line\",\"start\": {\"x\": -35.4,\"y\": 14.2},\"end\": {\"x\": -36.317,\"y\": 32.539},\"color\":\"#000000\"},{\"type\":\"arc\",\"start\": {\"x\": -36.317,\"y\": 32.539},\"end\": {\"x\": -32.904,\"y\": 37.532},\"radius\": 5,\"color\":\"#000000\",\"side\":\"right\"},{\"type\":\"line\",\"start\": {\"x\": -32.904,\"y\": 37.532},\"end\": {\"x\": -20,\"y\": 41.833},\"color\":\"#000000\"},{\"type\":\"arc\",\"start\": {\"x\": 0,\"y\": 0},\"end\": {\"x\": 9.949,\"y\": 0.165},\"radius\": 300,\"color\":\"#000000\",\"side\":\"right\"},{\"type\":\"arc\",\"start\": {\"x\": 9.949,\"y\": 0.165},\"end\": {\"x\": 25.35,\"y\": 2.185},\"radius\": 80,\"color\":\"#000000\",\"side\":\"left\"},{\"type\":\"arc\",\"start\": {\"x\": 25.35,\"y\": 2.185},\"end\": {\"x\": 35.4,\"y\": 14.2},\"radius\": 13,\"color\":\"#000000\",\"side\":\"left\"},{\"type\":\"line\",\"start\": {\"x\": 35.4,\"y\": 14.2},\"end\": {\"x\": 36.317,\"y\": 32.539},\"color\":\"#000000\"},{\"type\":\"arc\",\"start\": {\"x\": 36.317,\"y\": 32.539},\"end\": {\"x\": 32.904,\"y\": 37.532},\"radius\": 5,\"color\":\"#000000\",\"side\":\"left\"},{\"type\":\"line\",\"start\": {\"x\": 32.904,\"y\": 37.532},\"end\": {\"x\": 20,\"y\": 41.833},\"color\":\"#000000\"}]", - calPoints: "[{\"type\":\"arc\",\"start\": {\"x\": 0,\"y\": 0},\"end\": {\"x\": -9.949,\"y\": 0.165},\"radius\": 300,\"color\":\"#339900\",\"side\":\"right\"},{\"type\":\"arc\",\"start\": {\"x\": -9.949,\"y\": 0.165},\"end\": {\"x\": -25.35,\"y\": 2.185},\"radius\": 80,\"color\":\"#336699\",\"side\":\"right\"},{\"type\":\"arc\",\"start\": {\"x\": -25.35,\"y\": 2.185},\"end\": {\"x\": -35.4,\"y\": 14.2},\"radius\": 13,\"color\":\"#660000\",\"side\":\"right\"},{\"type\":\"arc\",\"start\": {\"x\": 0,\"y\": 0},\"end\": {\"x\": 9.949,\"y\": 0.165},\"radius\": 300,\"color\":\"#99CCCC\",\"side\":\"left\"},{\"type\":\"arc\",\"start\": {\"x\": 9.949,\"y\": 0.165},\"end\": {\"x\": 25.35,\"y\": 2.185},\"radius\": 80,\"color\":\"#CC0033\",\"side\":\"left\"},{\"type\":\"arc\",\"start\": {\"x\": 25.35,\"y\": 2.185},\"end\": {\"x\": 35.4,\"y\": 14.2},\"radius\": 13,\"color\":\"#CC6600\",\"side\":\"left\"}]" -} + id: 1, + createTime: '2025-03-03 12:31:25', + updateTime: '2025-03-03 12:31:25', + name: '60型标准轨', + code: '6001', + points: + '[{"type":"arc","start": {"x": 0,"y": 0},"end": {"x": -9.949,"y": 0.165},"radius": 300,"color":"#000000","side":"right"},{"type":"arc","start": {"x": -9.949,"y": 0.165},"end": {"x": -25.35,"y": 2.185},"radius": 80,"color":"#000000","side":"right"},{"type":"arc","start": {"x": -25.35,"y": 2.185},"end": {"x": -35.4,"y": 14.2},"radius": 13,"color":"#000000","side":"right"},{"type":"line","start": {"x": -35.4,"y": 14.2},"end": {"x": -36.317,"y": 32.539},"color":"#000000"},{"type":"arc","start": {"x": -36.317,"y": 32.539},"end": {"x": -32.904,"y": 37.532},"radius": 5,"color":"#000000","side":"right"},{"type":"line","start": {"x": -32.904,"y": 37.532},"end": {"x": -20,"y": 41.833},"color":"#000000"},{"type":"arc","start": {"x": 0,"y": 0},"end": {"x": 9.949,"y": 0.165},"radius": 300,"color":"#000000","side":"right"},{"type":"arc","start": {"x": 9.949,"y": 0.165},"end": {"x": 25.35,"y": 2.185},"radius": 80,"color":"#000000","side":"left"},{"type":"arc","start": {"x": 25.35,"y": 2.185},"end": {"x": 35.4,"y": 14.2},"radius": 13,"color":"#000000","side":"left"},{"type":"line","start": {"x": 35.4,"y": 14.2},"end": {"x": 36.317,"y": 32.539},"color":"#000000"},{"type":"arc","start": {"x": 36.317,"y": 32.539},"end": {"x": 32.904,"y": 37.532},"radius": 5,"color":"#000000","side":"left"},{"type":"line","start": {"x": 32.904,"y": 37.532},"end": {"x": 20,"y": 41.833},"color":"#000000"}]', + calPoints: + '[{"type":"arc","start": {"x": 0,"y": 0},"end": {"x": -9.949,"y": 0.165},"radius": 300,"color":"#339900","side":"right"},{"type":"arc","start": {"x": -9.949,"y": 0.165},"end": {"x": -25.35,"y": 2.185},"radius": 80,"color":"#336699","side":"right"},{"type":"arc","start": {"x": -25.35,"y": 2.185},"end": {"x": -35.4,"y": 14.2},"radius": 13,"color":"#660000","side":"right"},{"type":"arc","start": {"x": 0,"y": 0},"end": {"x": 9.949,"y": 0.165},"radius": 300,"color":"#99CCCC","side":"left"},{"type":"arc","start": {"x": 9.949,"y": 0.165},"end": {"x": 25.35,"y": 2.185},"radius": 80,"color":"#CC0033","side":"left"},{"type":"arc","start": {"x": 25.35,"y": 2.185},"end": {"x": 35.4,"y": 14.2},"radius": 13,"color":"#CC6600","side":"left"}]', +}; export const railTypes = [ - { - id: 1, - code: "1", - name: "60轨", - }, - { - id: 2, - code: "2", - name: "60N轨", - }, - { - id: 3, - code: "3", - name: "50轨", - }, - { - id: 4, - code: "4", - name: "43轨", - }, + { + id: 1, + code: '1', + name: '60轨', + }, + { + id: 2, + code: '2', + name: '60N轨', + }, + { + id: 3, + code: '3', + name: '50轨', + }, + { + id: 4, + code: '4', + name: '43轨', + }, ]; export const bureauList = [ - { - id: 1, - name: "北京铁路局" - }, - { - id: 2, - name: "南京铁路局" - }, - { - id: 3, - name: "上海铁路局" - }, - { - id: 4, - name: "广州铁路局" - } -] + { + id: 1, + name: '北京铁路局', + }, + { + id: 2, + name: '南京铁路局', + }, + { + id: 3, + name: '上海铁路局', + }, + { + id: 4, + name: '广州铁路局', + }, +]; export const lineList = [ - { - id: 1, - name: "京沪线" - }, - { - id: 2, - name: "京九线" - }, - { - id: 3, - name: "陇海线" - }, - { - id: 4, - name: "京广线" - } -] + { + id: 1, + name: '京沪线', + }, + { + id: 2, + name: '京九线', + }, + { + id: 3, + name: '陇海线', + }, + { + id: 4, + name: '京广线', + }, +]; export const sectionList = [ - { - id: 1, - name: "路段一" - }, - { - id: 2, - name: "路段二" - }, - { - id: 3, - name: "路段三" - }, - { - id: 4, - name: "路段四" - } -] + { + id: 1, + name: '路段一', + }, + { + id: 2, + name: '路段二', + }, + { + id: 3, + name: '路段三', + }, + { + id: 4, + name: '路段四', + }, +]; + +export const dataListFlat: Measurement[] = [ + { + id: 1, + name: '测量名称1', + createAt: '2025-03-02 10:20', + line: '京沪线', + section: 'A段', + direction: '上行', + railId: 2, + leftPoints: '[]', + rightPoints: '[]', + bureau: '北京铁路局', + upload: false, + }, + { + id: 2, + name: '测量名称2', + createAt: '2025-03-02 12:22', + line: '京沪线', + section: 'B段', + direction: '下行', + railId: 2, + leftPoints: '[]', + rightPoints: '[]', + bureau: '北京铁路局', + upload: false, + }, + { + id: 3, + name: '测量名称3', + createAt: '2025-03-02 12:20', + line: '京沪线', + section: 'C段', + direction: '上行', + railId: 2, + leftPoints: '[]', + rightPoints: '[]', + bureau: '北京铁路局', + upload: false, + }, +]; + +export const dataList: Array<{ groupName: string; list: Measurement[] }> = [ + { + groupName: '2025-03-02', + list: [ + { + id: 1, + name: '测量名称1', + createAt: '2025-03-02 10:20', + line: '京沪线', + section: 'A段', + direction: '上行', + railId: 2, + leftPoints: '[]', + rightPoints: '[]', + bureau: '北京铁路局', + upload: false, + }, + { + id: 2, + name: '测量名称2', + createAt: '2025-03-02 12:22', + line: '京沪线', + section: 'B段', + direction: '下行', + railId: 2, + leftPoints: '[]', + rightPoints: '[]', + bureau: '北京铁路局', + upload: false, + }, + { + id: 3, + name: '测量名称3', + createAt: '2025-03-02 12:20', + line: '京沪线', + section: 'C段', + direction: '上行', + railId: 2, + leftPoints: '[]', + rightPoints: '[]', + bureau: '北京铁路局', + upload: false, + }, + ], + }, + { + groupName: '2025-02-01', + list: [ + { + id: 4, + name: '测量名称2', + createAt: '2025-03-02 10:20', + line: '京沪线', + section: 'D段', + direction: '下行', + railId: 2, + leftPoints: '[]', + rightPoints: '[]', + bureau: '北京铁路局', + upload: false, + }, + { + id: 5, + name: '测量名称2', + createAt: '2025-03-02 10:20', + line: '京沪线', + section: 'E段', + direction: '下行', + railId: 2, + leftPoints: '[]', + rightPoints: '[]', + bureau: '北京铁路局', + upload: false, + }, + ], + }, +];