From 01ae4f909d0efa62f9e2db8fe6427845e92539e1 Mon Sep 17 00:00:00 2001 From: Iamasoldier <1272745473@qq.com> Date: Thu, 10 Apr 2025 11:24:04 +0800 Subject: [PATCH] Please enter the commit message for your changes. Lines starting with '#' will be ignored, and an empty message aborts the commit. On branch develop Your branch is ahead of 'goflyapp/develop' by 1 commit. (use "git push" to publish your local commits) Changes to be committed: modified: zlt-web/react-web/src/main/frontend/src/pages/Welcome.less modified: zlt-web/react-web/src/main/frontend/src/pages/Welcome.tsx modified: zlt-web/react-web/src/main/frontend/src/pages/device/Device/components/UpdateForm.tsx modified: zlt-web/react-web/src/main/frontend/src/pages/device/Device/index.tsx modified: zlt-web/react-web/src/main/frontend/src/pages/orders/Qrcode/components/UpdateForm.tsx modified: zlt-web/react-web/src/main/frontend/src/pages/orders/Qrcode/index.tsx modified: zlt-web/react-web/src/main/frontend/src/pages/orders/TourismFile/components/UpdateForm.tsx modified: zlt-web/react-web/src/main/frontend/src/pages/orders/TourismFile/index.less modified: zlt-web/react-web/src/main/frontend/src/pages/orders/TourismFile/index.tsx modified: zlt-web/react-web/src/main/frontend/src/pages/system/Menu/index.less modified: zlt-web/react-web/src/main/frontend/src/pages/system/Menu/index.tsx modified: zlt-web/react-web/src/main/frontend/src/pages/user/Login/index.less modified: zlt-web/react-web/src/main/frontend/src/pages/user/Login/index.tsx modified: zlt-web/react-web/src/main/frontend/src/services/orders/api.ts --- .../src/main/frontend/src/pages/Welcome.less | 102 +++++ .../src/main/frontend/src/pages/Welcome.tsx | 370 +++++++++--------- .../device/Device/components/UpdateForm.tsx | 102 ++--- .../src/pages/device/Device/index.tsx | 242 +++--------- .../orders/Qrcode/components/UpdateForm.tsx | 60 +-- .../src/pages/orders/Qrcode/index.tsx | 80 ++-- .../TourismFile/components/UpdateForm.tsx | 7 +- .../src/pages/orders/TourismFile/index.less | 46 +++ .../src/pages/orders/TourismFile/index.tsx | 122 +++++- .../frontend/src/pages/system/Menu/index.less | 12 + .../frontend/src/pages/system/Menu/index.tsx | 355 ++++++++--------- .../frontend/src/pages/user/Login/index.less | 249 ++++++++++-- .../frontend/src/pages/user/Login/index.tsx | 136 +++---- .../main/frontend/src/services/orders/api.ts | 13 +- 14 files changed, 1099 insertions(+), 797 deletions(-) diff --git a/zlt-web/react-web/src/main/frontend/src/pages/Welcome.less b/zlt-web/react-web/src/main/frontend/src/pages/Welcome.less index d0010257..a3f41196 100644 --- a/zlt-web/react-web/src/main/frontend/src/pages/Welcome.less +++ b/zlt-web/react-web/src/main/frontend/src/pages/Welcome.less @@ -1,4 +1,5 @@ @import (reference) '~antd/es/style/themes/index'; +@import '~antd/es/style/themes/default.less'; .stat { margin-top: @margin-md; @@ -9,3 +10,104 @@ .pie { margin-top: @margin-md; } + +.chartCard { + margin: 24px 0; + background: #fff; + border-radius: 8px; + box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06); + + :global { + .ant-tabs-nav { + margin-bottom: 16px; + padding: 0 24px; + } + + .ant-tabs-tab { + padding: 12px 0; + font-size: 15px; + + &:hover { + color: @primary-color; + } + } + + .ant-tabs-tab-active { + .ant-tabs-tab-btn { + font-weight: 500; + } + } + + .ant-empty { + padding: 32px 0; + } + } +} + +.pieRow { + margin-bottom: 24px; +} + +.pieCard { + height: 100%; + border-radius: 8px; + box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06); + + :global { + .ant-card-head { + padding: 0 24px; + border-bottom: 1px solid @border-color-split; + + .ant-card-head-title { + padding: 16px 0; + font-size: 16px; + font-weight: 500; + } + } + + .ant-card-body { + padding: 24px; + } + + .ant-empty { + padding: 32px 0; + } + } +} + +:global { + .ant-pro-card { + border-radius: 8px; + box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06); + } + + .ant-statistic-title { + font-size: 15px; + margin-bottom: 8px; + } + + .ant-statistic-content { + font-size: 24px; + font-weight: 500; + + &-value { + color: @heading-color; + } + } + + .ant-pro-card-statistic-description { + margin-top: 8px; + } + + .ant-skeleton { + padding: 24px; + } +} + +@media screen and (max-width: @screen-md) { + .pieRow { + .pieCard { + margin-bottom: 16px; + } + } +} diff --git a/zlt-web/react-web/src/main/frontend/src/pages/Welcome.tsx b/zlt-web/react-web/src/main/frontend/src/pages/Welcome.tsx index c9d26202..9c5ab549 100644 --- a/zlt-web/react-web/src/main/frontend/src/pages/Welcome.tsx +++ b/zlt-web/react-web/src/main/frontend/src/pages/Welcome.tsx @@ -1,15 +1,23 @@ import { PageContainer, StatisticCard } from '@ant-design/pro-components'; -import { Card, Tag, Space, Tabs, Col, Row } from 'antd'; +import { Card, Tag, Space, Tabs, Col, Row, Skeleton, Empty } from 'antd'; import RcResizeObserver from 'rc-resize-observer'; -import React, { useState, useEffect } from 'react'; +import React, { useState, useEffect, useMemo } from 'react'; import { statistic } from '@/services/welcome/api'; import { Area, Pie } from '@ant-design/plots'; +import { + UserOutlined, + EyeOutlined, + TeamOutlined, + LineChartOutlined, + BarChartOutlined, +} from '@ant-design/icons'; import styles from './Welcome.less'; const { Divider } = StatisticCard; const Welcome: React.FC = () => { const [responsive, setResponsive] = useState(false); + const [loading, setLoading] = useState(true); const [statistics, setStatistics] = useState({}); const [weeks, setWeeks] = useState([]); const [days, setDays] = useState([]); @@ -17,15 +25,18 @@ const Welcome: React.FC = () => { const mapWeek = (result: WELCOME.Statistic) => { const { statWeek_items, statWeek_pv, statWeek_uv } = result; if (statWeek_items && statWeek_pv && statWeek_uv) { - const weekData = statWeek_pv - .map((pv, index) => { - return { type: '访问量(PV)', date: statWeek_items[index], value: pv }; - }) - .concat( - statWeek_uv.map((uv, index) => { - return { type: '独立用户(UV)', date: statWeek_items[index], value: uv }; - }), - ); + const weekData = [ + ...statWeek_pv.map((pv, index) => ({ + type: '访问量(PV)', + date: statWeek_items[index], + value: pv, + })), + ...statWeek_uv.map((uv, index) => ({ + type: '独立用户(UV)', + date: statWeek_items[index], + value: uv, + })), + ]; setWeeks(weekData); } }; @@ -33,195 +44,200 @@ const Welcome: React.FC = () => { const mapDay = (result: WELCOME.Statistic) => { const { statDate_items, statDate_pv, statDate_uv } = result; if (statDate_items && statDate_pv && statDate_uv) { - const dayData = statDate_pv - .map((pv, index) => { - return { type: '访问量(PV)', date: statDate_items[index], value: pv }; - }) - .concat( - statDate_uv.map((uv, index) => { - return { type: '独立用户(UV)', date: statDate_items[index], value: uv }; - }), - ); + const dayData = [ + ...statDate_pv.map((pv, index) => ({ + type: '访问量(PV)', + date: statDate_items[index], + value: pv, + })), + ...statDate_uv.map((uv, index) => ({ + type: '独立用户(UV)', + date: statDate_items[index], + value: uv, + })), + ]; setDays(dayData); } }; - useEffect(() => { - (async () => { + const fetchData = async () => { + try { + setLoading(true); const result = await statistic(); if (result) { setStatistics(result); mapWeek(result); mapDay(result); } - })(); + } catch (error) { + console.error('获取统计数据失败:', error); + } finally { + setLoading(false); + } + }; + + useEffect(() => { + fetchData(); + // 每5分钟刷新一次数据 + const timer = setInterval(fetchData, 5 * 60 * 1000); + return () => clearInterval(timer); }, []); + const areaConfig = useMemo(() => ({ + smooth: true, + height: 260, + animation: true, + legend: { + layout: 'horizontal', + position: 'top', + }, + xField: 'date', + yField: 'value', + seriesField: 'type', + color: ['#1890ff', '#52c41a'], + areaStyle: { + fillOpacity: 0.6, + }, + tooltip: { + shared: true, + showCrosshairs: true, + }, + }), []); + + const pieConfig = useMemo(() => ({ + height: 280, + angleField: 'value', + colorField: 'name', + appendPadding: 10, + radius: 0.75, + animation: true, + label: { + type: 'spider', + labelHeight: 28, + content: '{name}\n{percentage}', + }, + legend: { + layout: 'horizontal', + position: 'bottom', + }, + interactions: [ + { type: 'element-selected' }, + { type: 'element-active' }, + ], + }), []); + return ( + 简单 - 高效 - + 高效 + 可扩展 + } > { - setResponsive(offset.width < 596); - }} + onResize={(offset) => setResponsive(offset.width < 596)} > - - - 在线人数时 - - ), - value: statistics.currHour_uv, - }} - /> - - - PV天 - - ), - value: statistics.currDate_pv, - }} - /> - - - UV天 - - ), - value: statistics.currDate_uv, - }} - /> - - - 周访问量周 - - ), - value: statistics.currWeek_pv, - }} - /> - - - 月访问量月 - - ), - value: statistics.currMonth_pv, - }} - /> - + + + , + description: 实时, + }} + /> + + , + description: 今日, + }} + /> + + , + description: 今日, + }} + /> + + , + description: 本周, + }} + /> + + , + description: 本月, + }} + /> + + + + + + + {weeks.length > 0 ? ( + + ) : ( + + )} + + + {days.length > 0 ? ( + + ) : ( + + )} + + + + + + + + {statistics.browser_datas?.length ? ( + + ) : ( + + )} + + + + + {statistics.operatingSystem_datas?.length ? ( + + ) : ( + + )} + + + - - - - - - - - - - - - - - - - - - - - ); }; diff --git a/zlt-web/react-web/src/main/frontend/src/pages/device/Device/components/UpdateForm.tsx b/zlt-web/react-web/src/main/frontend/src/pages/device/Device/components/UpdateForm.tsx index 46cce167..c7e2c303 100644 --- a/zlt-web/react-web/src/main/frontend/src/pages/device/Device/components/UpdateForm.tsx +++ b/zlt-web/react-web/src/main/frontend/src/pages/device/Device/components/UpdateForm.tsx @@ -1,67 +1,51 @@ import { ModalForm, ProForm, - ProFormSelect, ProFormText, + ProFormSelect, ProFormTextArea, } from '@ant-design/pro-components'; -import React, { useEffect } from 'react'; +import React from 'react'; -interface UpdateFormProps { - onSubmit: (values: DEVICE.Device) => Promise; +// 设备类型常量 +const DEVICE_TYPE = { + DOCK: 1, + DRONE: 2, + REMOTE_CONTROL: 3, +} as const; + +export type FormValueType = { + id?: string; + deviceSn?: string; + deviceName?: string; + nickname?: string; + deviceType?: number; + firmwareVersion?: string; + deviceDesc?: string; +} & Partial; + +export type UpdateFormProps = { + onSubmit: (values: FormValueType) => Promise; onVisibleChange: (visible: boolean) => void; updateModalVisible: boolean; - values?: DEVICE.Device; - waylineOptions: any[]; - tourismOptions: any[]; -} + values: Partial; +}; const UpdateForm: React.FC = (props) => { - const { - onSubmit, - onVisibleChange, - updateModalVisible, - values, - waylineOptions, - tourismOptions, - } = props; - - useEffect(() => { - console.log('当前航线选项:', waylineOptions); - console.log('当前表单值:', values); - }, [waylineOptions, values]); + const { updateModalVisible, onVisibleChange, onSubmit, values } = props; return ( - - (option?.label ?? '').toLowerCase().includes(input.toLowerCase()), - }} - /> = (props) => { name="deviceName" label="设备名称" /> - - - - - = (props) => { name="firmwareVersion" label="固件版本" /> + - ); }; diff --git a/zlt-web/react-web/src/main/frontend/src/pages/device/Device/index.tsx b/zlt-web/react-web/src/main/frontend/src/pages/device/Device/index.tsx index be059179..739e5350 100644 --- a/zlt-web/react-web/src/main/frontend/src/pages/device/Device/index.tsx +++ b/zlt-web/react-web/src/main/frontend/src/pages/device/Device/index.tsx @@ -4,7 +4,6 @@ import { deleteDevice, updateDeviceBoundStatus, } from '@/services/device/api'; -import { request } from 'umi'; import { PlusOutlined, ExportOutlined, ImportOutlined, DownloadOutlined } from '@ant-design/icons'; import type { ActionType, ProColumns } from '@ant-design/pro-components'; import { @@ -17,27 +16,17 @@ import { ProTable, QueryFilter, } from '@ant-design/pro-components'; -import { Button, message, Popconfirm, Typography, Space, Switch, Upload } from 'antd'; -import type { RcFile } from 'antd/lib/upload'; -import React, { useRef, useState, useCallback, useEffect } from 'react'; +import { Button, message, Space, Switch, Upload } from 'antd'; +import React, { useRef, useState } from 'react'; import moment from 'moment'; import UpdateForm from './components/UpdateForm'; -import { getToken } from '@/utils/authority'; -const { Link } = Typography; - -// 定义常量对象而不是使用命名空间 const DEVICE_TYPE = { DOCK: 1, DRONE: 2, REMOTE_CONTROL: 3, } as const; -const BOUND_STATUS = { - UNBOUND: 0, - BOUND: 1, -} as const; - const COMPATIBLE_STATUS = { INCONSISTENT: 0, CONSISTENT: 1, @@ -48,9 +37,7 @@ const TableList: React.FC = () => { const actionRef = useRef(); const [createModalVisible, handleModalVisible] = useState(false); const [updateModalVisible, handleUpdateModalVisible] = useState(false); - const [currentRow, setCurrentRow] = useState(); - const [waylineOptions, setWaylineOptions] = useState([]); - const [tourismOptions, setTourismOptions] = useState([]); + const [currentRow, setCurrentRow] = useState(); // 统一的API请求处理函数 const handleRequest = async ( @@ -87,34 +74,18 @@ const TableList: React.FC = () => { } }; - // 获取认证token - const getAuthHeader = () => { - // 从sessionStorage中获取token - const token = sessionStorage.getItem('access_token') || localStorage.getItem('access_token'); - return token ? `Bearer ${token}` : ''; - }; - - // 打印token信息用于调试 - console.log('当前token:', { - sessionToken: sessionStorage.getItem('access_token'), - localToken: localStorage.getItem('access_token'), - authHeader: getAuthHeader() - }); - - // 修改导出处理函数 + // 导出处理函数 const handleExport = () => { - // 创建一个隐藏的表单 const form = document.createElement('form'); form.method = 'POST'; form.action = '/api-device/device/export'; form.style.display = 'none'; - - // 添加token到请求头 + const token = sessionStorage.getItem('access_token'); if (token) { const tokenInput = document.createElement('input'); tokenInput.type = 'hidden'; - tokenInput.name = '_token'; // 添加一个隐藏字段携带token + tokenInput.name = '_token'; tokenInput.value = token; form.appendChild(tokenInput); } @@ -124,70 +95,17 @@ const TableList: React.FC = () => { document.body.removeChild(form); }; - // 修改模板下载函数 + // 模板下载函数 const handleDownloadTemplate = () => { - // 直接通过链接下载模板 window.location.href = '/api-device/device/template'; }; - // 重写获取航线数据的函数 - const loadWaylineOptions = async () => { - try { - const result = await wayline({ - current: 1, - pageSize: 999 // 获取更多数据 - }); - - if (result?.data) { - const options = result.data.map((item: any) => ({ - label: item.name || item.waylineId, - value: item.waylineId - })); - setWaylineOptions(options); - console.log('加载的航线选项:', options); - } - } catch (error) { - console.error('加载航线失败:', error); - message.error('获取航线列表失败'); - } - }; - - // 组件挂载时加载数据 - useEffect(() => { - loadWaylineOptions(); - }, []); - - // 添加操作处理函数 - const handleTableAction = async ( - action: 'add' | 'edit' | 'delete', - record?: ORDERS.Qrcode, - values?: any - ) => { - try { - if (action === 'add') { - await addDevice(values); - message.success('添加成功'); - } else if (action === 'edit') { - await updateDevice({ ...values, id: record?.id }); - message.success('修改成功'); - } else if (action === 'delete') { - await deleteDevice({ id: record?.id }); - message.success('删除成功'); - } - actionRef.current?.reload(); - return true; - } catch (error) { - console.error('操作失败:', error); - message.error('操作失败'); - return false; - } - }; - - // 修改列定义,确保操作列正确显示 - const columns: ProColumns[] = [ + // 表格列定义 + const columns: ProColumns[] = [ { dataIndex: 'index', valueType: 'indexBorder', + width: 48, }, { title: '设备序列号', @@ -254,14 +172,14 @@ const TableList: React.FC = () => { title: '操作', dataIndex: 'option', valueType: 'option', + fixed: 'right', + width: 120, render: (_, record) => [ { setCurrentRow(record); handleUpdateModalVisible(true); - // 立即加载航线数据 - loadWaylineOptions(); }} > 修改 @@ -269,7 +187,15 @@ const TableList: React.FC = () => { { - handleTableAction('delete', record); + handleRequest( + () => deleteDevice(record.id), + '正在删除', + '删除成功' + ).then((success) => { + if (success && actionRef.current) { + actionRef.current.reload(); + } + }); }} > 删除 @@ -310,14 +236,6 @@ const TableList: React.FC = () => { { label: '遥控器', value: DEVICE_TYPE.REMOTE_CONTROL }, ]} /> - { label="设备描述" placeholder="请输入设备描述" /> - - (option?.label ?? '').toLowerCase().includes(input.toLowerCase()), - notFoundContent: waylineOptions.length === 0 ? '暂无数据' : undefined, - }} - /> ); @@ -351,7 +254,6 @@ const TableList: React.FC = () => { setSearchParams(values)} > { nickname: '昵称', }} /> - + - + + rowKey="deviceSn" headerTitle="设备管理" actionRef={actionRef} @@ -378,16 +281,10 @@ const TableList: React.FC = () => { showQuickJumper: true, }} toolBarRender={() => [ - , - , { action="/api-device/device/import" showUploadList={false} onChange={(info) => { - if (info.file.status === 'uploading') { - message.loading('正在导入...'); - } if (info.file.status === 'done') { if (info.file.response.resp_code === 0) { message.success('导入成功'); @@ -417,76 +311,52 @@ const TableList: React.FC = () => { 导入 , - , ]} /> + + { + const success = await handleRequest( + () => saveOrUpdateDevice(values), + '正在添加', + '添加成功' + ); + if (success) { + handleModalVisible(false); + actionRef.current?.reload(); + } + return success; + }} + > + {renderModalContent()} + + {updateModalVisible && ( { - const success = await handleTableAction('edit', currentRow, values); + const success = await handleRequest( + () => saveOrUpdateDevice({ ...values, id: currentRow?.id }), + '正在更新', + '更新成功' + ); if (success) { handleUpdateModalVisible(false); setCurrentRow(undefined); + actionRef.current?.reload(); } }} - onVisibleChange={(visible) => { - if (!visible) { - handleUpdateModalVisible(false); - setCurrentRow(undefined); - } - }} + onVisibleChange={handleUpdateModalVisible} updateModalVisible={updateModalVisible} values={currentRow} - waylineOptions={waylineOptions} - tourismOptions={tourismOptions} /> )} - {createModalVisible && ( - { - if (visible) { - loadWaylineOptions(); - } - handleModalVisible(visible); - }} - modalProps={{ destroyOnClose: true }} - onFinish={async (values) => { - const success = await handleTableAction('add', undefined, values); - if (success) { - handleModalVisible(false); - } - }} - > - - - (option?.label ?? '').toLowerCase().includes(input.toLowerCase()), - }} - /> - {renderModalContent()} - - - )} ); }; diff --git a/zlt-web/react-web/src/main/frontend/src/pages/orders/Qrcode/components/UpdateForm.tsx b/zlt-web/react-web/src/main/frontend/src/pages/orders/Qrcode/components/UpdateForm.tsx index 12e05cb6..d287facd 100644 --- a/zlt-web/react-web/src/main/frontend/src/pages/orders/Qrcode/components/UpdateForm.tsx +++ b/zlt-web/react-web/src/main/frontend/src/pages/orders/Qrcode/components/UpdateForm.tsx @@ -7,23 +7,27 @@ import { import React, { useEffect } from 'react'; import { STATUS_OPTIONS } from '../index'; -interface UpdateFormProps { - onSubmit: (values: any) => Promise; +export type UpdateFormProps = { + onSubmit: (values: ORDERS.Qrcode) => Promise; onVisibleChange: (visible: boolean) => void; updateModalVisible: boolean; - values?: ORDERS.Qrcode; - waylineOptions: any[]; // 从父组件接收航线选项 - tourismOptions: any[]; // 从父组件接收景区选项 -} + values: Partial; + waylineOptions: any[]; + tourismOptions: any[]; + deviceOptions: any[]; // 添加设备选项属性 +}; + +const UpdateForm: React.FC = (props) => { + const { + updateModalVisible, + onVisibleChange, + onSubmit, + values, + waylineOptions, + tourismOptions, + deviceOptions, // 解构设备选项 + } = props; -const UpdateForm: React.FC = ({ - onSubmit, - onVisibleChange, - updateModalVisible, - values, - waylineOptions, - tourismOptions, -}) => { useEffect(() => { console.log('UpdateForm values:', values); console.log('UpdateForm tourismOptions:', tourismOptions); @@ -36,23 +40,17 @@ const UpdateForm: React.FC = ({ visible={updateModalVisible} onVisibleChange={onVisibleChange} modalProps={{ destroyOnClose: true }} - initialValues={{ - ...values, - tourismId: Number(values?.tourismId), - waylineId: values?.waylineId, - }} onFinish={onSubmit} + initialValues={values} > (option?.label ?? '').toLowerCase().includes(input.toLowerCase()), @@ -62,7 +60,6 @@ const UpdateForm: React.FC = ({ width="md" name="tourismId" label="景区" - placeholder="请选择景区" options={tourismOptions} rules={[{ required: true, message: '请选择景区' }]} fieldProps={{ @@ -70,20 +67,33 @@ const UpdateForm: React.FC = ({ showSearch: true, filterOption: (input, option) => (option?.label ?? '').toLowerCase().includes(input.toLowerCase()), + notFoundContent: tourismOptions.length === 0 ? '暂无景区数据' : undefined, }} /> + + (option?.label ?? '').toLowerCase().includes(input.toLowerCase()), + notFoundContent: deviceOptions.length === 0 ? '暂无设备数据' : undefined, + }} /> diff --git a/zlt-web/react-web/src/main/frontend/src/pages/orders/Qrcode/index.tsx b/zlt-web/react-web/src/main/frontend/src/pages/orders/Qrcode/index.tsx index a6aaf243..f8b52075 100644 --- a/zlt-web/react-web/src/main/frontend/src/pages/orders/Qrcode/index.tsx +++ b/zlt-web/react-web/src/main/frontend/src/pages/orders/Qrcode/index.tsx @@ -1,4 +1,4 @@ -import { deleteQrcode, qrcode, saveOrUpdateQrcode, tourism } from '@/services/orders/api'; +import { deleteQrcode, qrcode, saveOrUpdateQrcode, getTourismList } from '@/services/orders/api'; import { PlusOutlined } from '@ant-design/icons'; import type { ActionType, ProColumns } from '@ant-design/pro-components'; import { @@ -13,7 +13,7 @@ import { import { Typography, Popconfirm, Space, message, Image, Button, Tag } from 'antd'; import React, { useRef, useState, useCallback, useEffect } from 'react'; import UpdateForm from './components/UpdateForm'; -import { wayline } from '@/services/device/api'; +import { wayline, device } from '@/services/device/api'; const { Link } = Typography; @@ -22,13 +22,6 @@ export const STATUS_OPTIONS = [ { label: '未启用', value: 1 }, ] as const; -export const TOURISM_OPTIONS = [ - { label: '北塘古镇', value: 33 }, - { label: '海丝首港', value: 32 }, - { label: '武汉东湖牡丹园', value: 35 }, - { label: '武汉东湖樱花园', value: 36 }, -] as const; - export const DEVICE_OPTIONS = [ { label: '7CTDM6F00B744S', value: '7CTDM6F00B744S' }, { label: '8UUXN2A00A00LR', value: '8UUXN2A00A00LR' }, @@ -106,6 +99,7 @@ const TableList: React.FC = () => { const [currentRow, setCurrentRow] = useState(); const [waylineOptions, setWaylineOptions] = useState([]); const [tourismOptions, setTourismOptions] = useState([]); + const [deviceOptions, setDeviceOptions] = useState([]); const formRef = useRef(); const handleTableAction = useCallback(async ( @@ -139,14 +133,14 @@ const TableList: React.FC = () => { const fetchTourismList = useCallback(async () => { try { - const result = await tourism({ - limit: 100, + const result = await getTourismList({ page: 1, + limit: 100, }); - if (result.data) { + if (result?.data) { const options = result.data.map(item => ({ - label: item.tourismName, + label: item.tourismName || item.name, value: item.id, info: item })); @@ -172,10 +166,31 @@ const TableList: React.FC = () => { } }, []); + const fetchDeviceList = useCallback(async () => { + try { + const result = await device({ + current: 1, + pageSize: 100, + }); + + if (result?.data) { + const options = result.data.map((item: DEVICE.Device) => ({ + label: `${item.deviceName}(${item.deviceSn})`, + value: item.deviceSn, + info: item + })); + setDeviceOptions(options); + } + } catch (error) { + message.error('获取设备列表失败'); + } + }, []); + useEffect(() => { fetchTourismList(); fetchWaylineOptions(); - }, [fetchTourismList, fetchWaylineOptions]); + fetchDeviceList(); + }, [fetchTourismList, fetchWaylineOptions, fetchDeviceList]); const columns: ProColumns[] = [ { @@ -289,7 +304,13 @@ const TableList: React.FC = () => { label="景区" placeholder="请选择景区" options={tourismOptions} - showSearch + fieldProps={{ + loading: !tourismOptions.length, + showSearch: true, + filterOption: (input, option) => + (option?.label ?? '').toLowerCase().includes(input.toLowerCase()), + notFoundContent: tourismOptions.length === 0 ? '暂无景区数据' : undefined, + }} /> { visible={createModalVisible} onVisibleChange={(visible) => { handleModalVisible(visible); - if (!visible) { - setWaylineOptions([]); - setTourismOptions([]); + if (visible) { + fetchDeviceList(); + fetchTourismList(); } }} modalProps={{ destroyOnClose: true }} @@ -367,6 +388,7 @@ const TableList: React.FC = () => { showSearch: true, filterOption: (input, option) => (option?.label ?? '').toLowerCase().includes(input.toLowerCase()), + notFoundContent: tourismOptions.length === 0 ? '暂无景区数据' : undefined, }} /> { width="md" name="deviceSn" label="设备编号" - placeholder="请选择设备编号" - options={DEVICE_OPTIONS} - rules={[{ required: true, message: '设备不为空' }]} + placeholder="请选择设备" + options={deviceOptions} + rules={[{ required: true, message: '设备不能为空' }]} + fieldProps={{ + loading: !deviceOptions.length, + showSearch: true, + filterOption: (input, option) => + (option?.label ?? '').toLowerCase().includes(input.toLowerCase()), + notFoundContent: deviceOptions.length === 0 ? '暂无设备数据' : undefined, + }} /> { { - console.log('提交的修改值:', values); return handleTableAction('edit', currentRow, values); }} onVisibleChange={(visible) => { - console.log('修改弹窗可见性变化:', visible); handleUpdateModalVisible(visible); + if (visible) { + fetchDeviceList(); + fetchTourismList(); + } if (!visible) { setCurrentRow(undefined); - setWaylineOptions([]); - setTourismOptions([]); } }} updateModalVisible={updateModalVisible} values={currentRow} waylineOptions={waylineOptions} tourismOptions={tourismOptions} + deviceOptions={deviceOptions} /> ); diff --git a/zlt-web/react-web/src/main/frontend/src/pages/orders/TourismFile/components/UpdateForm.tsx b/zlt-web/react-web/src/main/frontend/src/pages/orders/TourismFile/components/UpdateForm.tsx index c75c7598..b66283ef 100644 --- a/zlt-web/react-web/src/main/frontend/src/pages/orders/TourismFile/components/UpdateForm.tsx +++ b/zlt-web/react-web/src/main/frontend/src/pages/orders/TourismFile/components/UpdateForm.tsx @@ -8,10 +8,8 @@ import { } from '@ant-design/pro-components'; import { Button, Upload, Image, message, Form } from 'antd'; import type { RcFile } from 'antd/lib/upload'; -import React, { useState, useEffect, useCallback } from 'react'; -import { TOURISM_OPTIONS, TYPE_OPTIONS } from '../constants'; -import styles from '../index.less'; -import { tourism } from '@/services/orders/api'; +import React, { useState } from 'react'; +import { TYPE_OPTIONS } from '../constants'; interface UpdateFormProps { onSubmit: (values: any) => Promise; @@ -57,7 +55,6 @@ const UpdateForm: React.FC = (props) => { onVisibleChange={props.onVisibleChange} modalProps={{ destroyOnClose: true }} onFinish={async (values) => { - // 如果上传了新图片,使用新的图片路径 if (imagePath) { values.imageUrl = imagePath; } diff --git a/zlt-web/react-web/src/main/frontend/src/pages/orders/TourismFile/index.less b/zlt-web/react-web/src/main/frontend/src/pages/orders/TourismFile/index.less index 7ed5980a..9033e7ec 100644 --- a/zlt-web/react-web/src/main/frontend/src/pages/orders/TourismFile/index.less +++ b/zlt-web/react-web/src/main/frontend/src/pages/orders/TourismFile/index.less @@ -13,3 +13,49 @@ .button_view { margin-top: 16px; } + +.groupRow { + background-color: #fafafa; + font-weight: bold; + + &:hover { + background-color: #f5f5f5 !important; + } + + td { + padding: 16px 8px !important; + } +} + +// 优化表格样式 +:global { + .ant-table-row-expand-icon-cell { + width: 48px; + } + + .ant-table-expanded-row { + background-color: #fff; + } + + .ant-table-tbody { + > tr.ant-table-row:hover { + > td { + background-color: #f0f5ff; + } + } + } + + // 分组标题样式 + .group-title { + font-size: 16px; + color: @heading-color; + margin: 0; + + .group-count { + font-size: 14px; + color: @text-color-secondary; + margin-left: 8px; + font-weight: normal; + } + } +} diff --git a/zlt-web/react-web/src/main/frontend/src/pages/orders/TourismFile/index.tsx b/zlt-web/react-web/src/main/frontend/src/pages/orders/TourismFile/index.tsx index 4041f84b..67cf7579 100644 --- a/zlt-web/react-web/src/main/frontend/src/pages/orders/TourismFile/index.tsx +++ b/zlt-web/react-web/src/main/frontend/src/pages/orders/TourismFile/index.tsx @@ -11,7 +11,7 @@ import { ProTable, QueryFilter, } from '@ant-design/pro-components'; -import { Typography, Popconfirm, Space, message, Image, Button, Tag, Upload } from 'antd'; +import { Typography, Popconfirm, Space, message, Image, Button, Tag, Upload, Spin } from 'antd'; import type { RcFile } from 'antd/lib/upload'; import React, { useRef, useState, useCallback, useEffect } from 'react'; import { STATUS_CONFIG, TYPE_CONFIG } from './constants'; @@ -218,34 +218,110 @@ const TableList: React.FC = () => { } }, [createImagePath]); + // 修改请求处理函数 + const fetchTableData = async (params: any) => { + try { + // 先获取景区列表 + const tourismResult = await tourism({ + page: params.current || 1, + limit: params.pageSize || 10, + }); + + if (!tourismResult?.data) { + return { + data: [], + success: true, + total: 0, + }; + } + + // 获取所有景区的ID列表 + const tourismIds = tourismResult.data.map(item => item.id); + + // 获取这些景区的素材数据 + const fileResult = await tourismFile({ + page: 1, + limit: 1000, + tourismIds: tourismIds.join(','), + }); + + const fileList = fileResult?.data || []; + + // 按景区组织数据 + const groupedData = tourismResult.data.map(tourism => { + const tourismFiles = fileList.filter(file => file.tourismId === tourism.id); + return { + id: `tourism-${tourism.id}`, + tourismId: tourism.id, + tourismName: tourism.tourismName, + children: tourismFiles.map(file => ({ + ...file, + key: file.id, + })), + }; + }); + + return { + data: groupedData, + success: true, + total: tourismResult.total || 0, + }; + } catch (error) { + console.error('获取数据失败:', error); + message.error('获取数据失败,请稍后重试'); + return { + data: [], + success: false, + total: 0, + }; + } + }; + const columns: ProColumns[] = [ { title: '序号', dataIndex: 'index', valueType: 'indexBorder', width: 48, + render: (_, record, index) => { + // 如果是分组行,不显示序号 + if (record.children) { + return ''; + } + return index + 1; + }, }, { title: '景区名称', dataIndex: 'tourismId', ellipsis: true, render: (_, record) => { - const option = tourismOptions.find(item => item.value === record.tourismId); - return option?.label || '-'; + if (record.children) { + return {record.tourismName}; + } + // 对于子项,使用父级的景区名称 + const parentTourism = tourismOptions.find(item => item.value === record.tourismId); + return parentTourism?.label || record.tourismName || '-'; }, }, { - title: '素材预览', + title: '图片', dataIndex: 'imageUrl', + search: false, width: 120, - render: (imageUrl) => ( - - ), + render: (_, record) => { + if (record.children) { + return null; + } + return record.imageUrl ? ( + 素材图片 + ) : null; + }, }, { title: '页面链接', @@ -346,18 +422,34 @@ const TableList: React.FC = () => { - rowKey="id" + rowKey={(record) => record.id || `tourism-${record.tourismId}`} headerTitle="素材列表" - request={tourismFile} actionRef={actionRef} + request={fetchTableData} columns={columns} search={false} params={params} pagination={{ showSizeChanger: true, showQuickJumper: true, + pageSize: 10, defaultPageSize: 10, - pageSizeOptions: ['10', '20', '50'], + showTotal: (total) => `共 ${total} 个景区`, + }} + expandable={{ + defaultExpandAllRows: true, + }} + rowClassName={(record) => { + return record.children ? styles.groupRow : ''; + }} + // 添加表格滚动配置 + scroll={{ x: 'max-content' }} + // 添加表格大小设置 + size="middle" + // 添加表格工具栏配置 + toolbar={{ + title: '素材列表', + tooltip: '按景区展示所有素材信息', }} toolBarRender={() => [ - - - , + , + , + , + , ]} /> + + {/* 新增表单 */} { - const success = await handleAdd(values as SYSTEM.Menu); + const success = await handleMenuOperation('add', values); if (success) { handleModalVisible(false); - if (actionRef.current) { - actionRef.current.reload(); - } } }} > @@ -351,8 +322,6 @@ const Generator: React.FC = () => { fieldNames: { label: 'title', }, - // treeCheckable: true, - // showCheckedStrategy: TreeSelect.SHOW_PARENT, placeholder: '选择上级菜单名', }} /> @@ -438,20 +407,24 @@ const Generator: React.FC = () => { /> + + {/* 修改表单 */} { if (currentRow) { - const success = await handleEdit({ ...currentRow, ...values }); + const success = await handleMenuOperation('edit', values, currentRow); if (success) { handleUpdateModalVisible(false); - if (actionRef.current) { - actionRef.current.reload(); - } + setCurrentRow(undefined); } + } + }} + onVisibleChange={(visible) => { + handleUpdateModalVisible(visible); + if (!visible) { setCurrentRow(undefined); } }} - onVisibleChange={handleUpdateModalVisible} updateModalVisible={updateModalVisible} values={currentRow} /> @@ -459,4 +432,4 @@ const Generator: React.FC = () => { ); }; -export default Generator; +export default TableList; diff --git a/zlt-web/react-web/src/main/frontend/src/pages/user/Login/index.less b/zlt-web/react-web/src/main/frontend/src/pages/user/Login/index.less index f6ecf00d..5631390b 100644 --- a/zlt-web/react-web/src/main/frontend/src/pages/user/Login/index.less +++ b/zlt-web/react-web/src/main/frontend/src/pages/user/Login/index.less @@ -1,50 +1,247 @@ -@import (reference) '~antd/es/style/themes/index'; +@import '~antd/es/style/themes/default.less'; .container { + position: relative; display: flex; flex-direction: column; - height: 100vh; - overflow: auto; - background: @layout-body-background; + min-height: 100vh; + background: #f0f2f5; + overflow: hidden; + + &::before { + content: ''; + position: absolute; + top: -50%; + right: -50%; + width: 100%; + height: 100%; + background: linear-gradient(45deg, #1890ff20 0%, #722ed120 100%); + transform: rotate(45deg); + z-index: 0; + } } -.lang { - width: 100%; - height: 40px; - line-height: 44px; - text-align: right; - :global(.ant-dropdown-trigger) { - margin-right: 24px; +.timeBox { + position: absolute; + top: 48px; + left: 48px; + z-index: 1; + + .time { + display: block; + font-size: 48px; + font-weight: 300; + color: @heading-color; + line-height: 1; + margin-bottom: 8px; + } + + .date { + font-size: 16px; + color: @text-color-secondary; } } .content { flex: 1; - padding: 32px 0; + padding: 32px; + display: flex; + justify-content: flex-end; + align-items: center; + position: relative; + z-index: 1; } -@media (min-width: @screen-md-min) { - .container { - background-image: url('https://gw.alipayobjects.com/zos/rmsportal/TVYTbAXWheQpRcWDaDMu.svg'); - background-repeat: no-repeat; - background-position: center 110px; - background-size: 100%; - } +.loginBox { + width: 100%; + max-width: 420px; + margin-right: 10%; + padding: 40px; + background: white; + border-radius: 16px; + box-shadow: + 0 4px 6px rgba(0, 0, 0, 0.02), + 0 10px 20px rgba(0, 0, 0, 0.04); + transition: transform 0.3s ease; - .content { - padding: 32px 0 24px; + &:hover { + transform: translateY(-2px); } } -.icon { - margin-left: 8px; - color: rgba(0, 0, 0, 0.2); - font-size: 24px; - vertical-align: middle; +.welcome { + text-align: center; + margin-bottom: 40px; + + h2 { + margin-bottom: 8px; + } +} + +.errorMessage { + margin-bottom: 24px; + padding: 12px; + background: #fff2f0; + border-radius: 4px; + text-align: center; +} + +:global { + .ant-input-affix-wrapper { + border-radius: 8px; + border: 1px solid #e8e8e8; + transition: all 0.3s; + padding: 12px 16px; + + &:hover, &:focus { + border-color: @primary-color; + box-shadow: 0 0 0 2px rgba(24, 144, 255, 0.1); + } + + .ant-input { + font-size: 15px; + } + + .anticon { + color: @text-color-secondary; + } + } + + .ant-form-item { + margin-bottom: 24px; + } + + .ant-btn { + height: 48px; + font-size: 16px; + border-radius: 8px; + + &.ant-btn-primary { + background: @primary-color; + border: none; + transition: all 0.3s; + + &:hover { + background: lighten(@primary-color, 5%); + transform: translateY(-1px); + box-shadow: 0 4px 12px rgba(24, 144, 255, 0.25); + } + } + } +} + +.captchaContainer { + display: flex; + gap: 16px; + align-items: flex-start; + + .ant-form-item { + flex: 1; + margin-bottom: 0; + } +} + +.captchaImage { + height: 48px; + border-radius: 8px; + overflow: hidden; cursor: pointer; + transition: opacity 0.3s; + + &:hover { + opacity: 0.8; + } + + img { + height: 100%; + width: auto; + } +} + +.loginOptions { + display: flex; + justify-content: space-between; + align-items: center; + margin-top: 24px; +} + +.forgotPassword { + color: @text-color-secondary; transition: color 0.3s; &:hover { color: @primary-color; } } + +// 响应式设计 +@media screen and (max-width: @screen-md) { + .timeBox { + position: static; + text-align: center; + padding: 24px 0; + + .time { + font-size: 36px; + } + } + + .content { + justify-content: center; + padding: 16px; + } + + .loginBox { + margin-right: 0; + padding: 24px; + } +} + +@media screen and (max-width: @screen-xs) { + .loginBox { + padding: 20px; + } + + :global { + .ant-input-affix-wrapper { + padding: 8px 12px; + } + + .ant-btn { + height: 40px; + } + } + + .captchaImage { + height: 40px; + } +} + +// 暗色主题支持 +@media (prefers-color-scheme: dark) { + .container { + background: #141414; + + &::before { + background: linear-gradient(45deg, #1890ff10 0%, #722ed110 100%); + } + } + + .loginBox { + background: #1f1f1f; + box-shadow: + 0 4px 6px rgba(0, 0, 0, 0.1), + 0 10px 20px rgba(0, 0, 0, 0.2); + } + + .errorMessage { + background: #2a1f1f; + } + + :global { + .ant-input-affix-wrapper { + background: #141414; + border-color: #434343; + } + } +} diff --git a/zlt-web/react-web/src/main/frontend/src/pages/user/Login/index.tsx b/zlt-web/react-web/src/main/frontend/src/pages/user/Login/index.tsx index 0585a568..6cb6bfdd 100644 --- a/zlt-web/react-web/src/main/frontend/src/pages/user/Login/index.tsx +++ b/zlt-web/react-web/src/main/frontend/src/pages/user/Login/index.tsx @@ -1,8 +1,8 @@ import Footer from '@/components/Footer'; import { login } from '@/services/login/api'; import { InfoCircleOutlined, LockOutlined, UserOutlined } from '@ant-design/icons'; -import { LoginForm, ProFormCaptcha, ProFormText } from '@ant-design/pro-components'; -import { message, Tooltip } from 'antd'; +import { LoginForm, ProFormCaptcha, ProFormText, ProFormCheckbox } from '@ant-design/pro-components'; +import { message, Tooltip, Spin } from 'antd'; import React, { useState } from 'react'; import { FormattedMessage, history, useIntl, useModel } from 'umi'; import { v4 as uuidv4 } from 'uuid'; @@ -10,87 +10,75 @@ import styles from './index.less'; const Login: React.FC = () => { const [uuid, setUuid] = useState(uuidv4()); + const [loading, setLoading] = useState(false); const { initialState, setInitialState } = useModel('@@initialState'); - const intl = useIntl(); const fetchUserInfo = async () => { - const userInfo = await initialState?.fetchUserInfo?.(); - if (userInfo) { - await setInitialState((s) => ({ - ...s, - currentUser: userInfo, - })); + try { + const userInfo = await initialState?.fetchUserInfo?.(); + if (userInfo) { + await setInitialState((s) => ({ + ...s, + currentUser: userInfo, + })); + } + } catch (error) { + message.error('获取用户信息失败'); } }; const handleSubmit = async (values: API.LoginParams) => { try { - // 登录 - const msg = await login({ ...values }); - if (msg.resp_code === 0) { - const defaultLoginSuccessMessage = intl.formatMessage({ - id: 'pages.login.success', - defaultMessage: '登录成功!', - }); - const loginResult = msg.data; - if (loginResult && loginResult.access_token) - sessionStorage.setItem('access_token', loginResult.access_token); - message.success(defaultLoginSuccessMessage); + setLoading(true); + const msg = await login({ ...values, deviceId: uuid }); + + if (msg.resp_code === 0 && msg.data?.access_token) { + sessionStorage.setItem('access_token', msg.data.access_token); + message.success('登录成功!'); await fetchUserInfo(); - /** 此方法会跳转到 redirect 参数所在的位置 */ - if (!history) return; + const { query } = history.location; const { redirect } = query as { redirect: string }; history.push(redirect || '/'); return; } - - // 如果失败去设置用户错误信息 + + message.error(msg.resp_msg || '登录失败'); + setUuid(uuidv4()); } catch (error) { - const defaultLoginFailureMessage = intl.formatMessage({ - id: 'pages.login.failure', - defaultMessage: '登录失败,请重试!', - }); - message.error(defaultLoginFailureMessage); + message.error('登录失败,请重试!'); + } finally { + setLoading(false); } }; - const captchaUrl = `/api-uaa/validata/code/${uuid}`; return (
- } - title="microservices-platform" - subTitle={intl.formatMessage({ id: 'pages.layouts.userLayout.title' })} - initialValues={{ - autoLogin: true, - }} - onFinish={async (values) => { - await handleSubmit({ ...values, deviceId: uuid } as API.LoginParams); - }} - > - <> + + } + title="microservices-platform" + subTitle={intl.formatMessage({ id: 'pages.layouts.userLayout.title' })} + initialValues={{ autoLogin: true }} + onFinish={async (values) => { + if (!loading) { + await handleSubmit(values as API.LoginParams); + } + }} + > , }} - placeholder={intl.formatMessage({ - id: 'pages.login.username.placeholder', - defaultMessage: '账号', - })} + placeholder="请输入账号" rules={[ { required: true, - message: ( - - ), + message: '请输入账号!', }, ]} /> @@ -100,19 +88,11 @@ const Login: React.FC = () => { size: 'large', prefix: , }} - placeholder={intl.formatMessage({ - id: 'pages.login.password.placeholder', - defaultMessage: '密码', - })} + placeholder="请输入密码" rules={[ { required: true, - message: ( - - ), + message: '请输入密码!', }, ]} /> @@ -120,22 +100,19 @@ const Login: React.FC = () => { name="validCode" fieldProps={{ size: 'large', - prefix: , - suffix: ( - - - - ), + prefix: , }} captchaProps={{ size: 'large', - style: { padding: '0 2px' }, }} - placeholder={'验证码'} + placeholder="请输入验证码" captchaTextRender={() => ( - setUuid(uuidv4())}> - 验证码 - + 验证码 setUuid(uuidv4())} + /> )} rules={[ { @@ -143,10 +120,17 @@ const Login: React.FC = () => { message: '请输入验证码!', }, ]} - onGetCaptcha={async () => {}} /> - - + + +
diff --git a/zlt-web/react-web/src/main/frontend/src/services/orders/api.ts b/zlt-web/react-web/src/main/frontend/src/services/orders/api.ts index 2c0a800d..3ccc6739 100644 --- a/zlt-web/react-web/src/main/frontend/src/services/orders/api.ts +++ b/zlt-web/react-web/src/main/frontend/src/services/orders/api.ts @@ -154,13 +154,14 @@ export async function updateRefund(data: ORDERS.Refund): Promise>('/api-order/tourism', { +/** 获取景区列表 */ +export async function getTourismList(params: { + page: number; + limit: number; +}) { + return request>('/api-order/tourism', { method: 'GET', - params: { - pageSize: params?.pageSize || 100, - current: params?.current || 1, - }, + params, }); }