feat: 1:优化token查询页 2:用户管理页面新增修改密码功能 3:调整景区与二维码关系

This commit is contained in:
2025-10-23 18:02:39 +08:00
parent 1a0669e385
commit 7aa0e6a32f
4 changed files with 148 additions and 16 deletions
@@ -1,8 +1,8 @@
import React, { useMemo, useRef, useState } from 'react';
import { Modal, Popconfirm, Space, Tag, message } from 'antd';
import { Modal, Popconfirm, Space, Tag, message, Button } from 'antd';
import { ProTable, type ActionType } from '@ant-design/pro-components';
import { GradientButton } from '@/components/ui';
import { PlusOutlined } from '@ant-design/icons';
import { PlusOutlined, CopyOutlined } from '@ant-design/icons';
import { ordersApi } from '@/services/orders';
import QrcodeForm, { QrcodeItem } from '../../Qrcode/components/QrcodeForm';
@@ -18,6 +18,8 @@ const QrcodeListModal: React.FC<QrcodeListModalProps> = ({ open, onOpenChange, t
const [createOpen, setCreateOpen] = useState(false);
const [editOpen, setEditOpen] = useState(false);
const [current, setCurrent] = useState<QrcodeItem | undefined>(undefined);
const [previewOpen, setPreviewOpen] = useState(false);
const [previewImage, setPreviewImage] = useState<string>('');
const title = useMemo(
() => `打卡点二维码列表${tourismName ? `(${tourismName})` : ''}`,
@@ -25,21 +27,113 @@ const QrcodeListModal: React.FC<QrcodeListModalProps> = ({ open, onOpenChange, t
);
const columns: any[] = [
{ dataIndex: 'index', valueType: 'indexBorder', width: 56 },
{ title: '名称', dataIndex: 'name' },
{ title: '链接', dataIndex: 'url', ellipsis: true },
{ title: '类型', dataIndex: 'type' },
{ dataIndex: 'index', valueType: 'indexBorder', width: 48 },
{ title: 'ID', dataIndex: 'id', width: 80 },
{ title: '名称', dataIndex: 'name', width: 120 },
{
title: 'Code',
dataIndex: 'codeId',
width: 200,
render: (codeId: string) => {
if (!codeId) return '-';
return (
<div style={{ display: 'flex', alignItems: 'center', gap: '8px' }}>
<span style={{ flex: 1, overflow: 'hidden', textOverflow: 'ellipsis', whiteSpace: 'nowrap' }}>
{codeId}
</span>
<Button
type="text"
size="small"
icon={<CopyOutlined />}
onClick={(e) => {
e.stopPropagation();
navigator.clipboard.writeText(codeId).then(() => {
message.success('Code已复制');
}).catch(() => {
message.error('复制失败');
});
}}
style={{ flexShrink: 0 }}
/>
</div>
);
},
},
{
title: '航线ID',
dataIndex: 'waylineId',
width: 200,
render: (waylineId: string) => {
if (!waylineId) return '-';
return (
<div style={{ display: 'flex', alignItems: 'center', gap: '8px' }}>
<span style={{ flex: 1, overflow: 'hidden', textOverflow: 'ellipsis', whiteSpace: 'nowrap' }}>
{waylineId}
</span>
<Button
type="text"
size="small"
icon={<CopyOutlined />}
onClick={(e) => {
e.stopPropagation();
navigator.clipboard.writeText(waylineId).then(() => {
message.success('航线ID已复制');
}).catch(() => {
message.error('复制失败');
});
}}
style={{ flexShrink: 0 }}
/>
</div>
);
},
},
{
title: '二维码',
dataIndex: 'viewUrl',
width: 100,
render: (url: string) => {
if (!url) return '-';
return (
<img
src={url}
alt="二维码"
style={{ width: 60, height: 60, cursor: 'pointer', objectFit: 'contain' }}
onClick={() => {
setPreviewImage(url);
setPreviewOpen(true);
}}
/>
);
},
},
{ title: '设备SN', dataIndex: 'deviceSn', width: 150 },
{
title: '价格',
dataIndex: 'price',
width: 100,
render: (price: string | number) => {
if (!price) return '-';
const priceNum = typeof price === 'string' ? parseFloat(price) : price;
return `¥${(priceNum / 100).toFixed(2)}`;
},
},
{
title: '状态',
dataIndex: 'status',
width: 80,
render: (v: number) => (
<Tag color={v === 1 ? 'green' : 'default'}>{v === 1 ? '启用' : '禁用'}</Tag>
<Tag color={v === 1 ? 'success' : 'default'}>
{v === 1 ? '开启' : '关闭'}
</Tag>
),
},
{ title: '创建时间', dataIndex: 'createTime', valueType: 'dateTime', width: 160 },
{
title: '操作',
key: 'action',
width: 160,
width: 140,
fixed: 'right',
render: (_: any, record: QrcodeItem) => (
<Space>
<a
@@ -79,7 +173,7 @@ const QrcodeListModal: React.FC<QrcodeListModalProps> = ({ open, onOpenChange, t
open={open}
onCancel={() => onOpenChange(false)}
footer={null}
width={1000}
width={1400}
destroyOnClose
>
<div style={{ marginBottom: 12 }}>
@@ -101,6 +195,7 @@ const QrcodeListModal: React.FC<QrcodeListModalProps> = ({ open, onOpenChange, t
search={false}
pagination={{ showSizeChanger: true, showQuickJumper: true }}
toolBarRender={false}
scroll={{ x: 1200 }}
/>
</Modal>
@@ -146,6 +241,25 @@ const QrcodeListModal: React.FC<QrcodeListModalProps> = ({ open, onOpenChange, t
}
}}
/>
{/* 二维码预览 */}
<Modal
title="二维码预览"
open={previewOpen}
onCancel={() => setPreviewOpen(false)}
footer={null}
width={600}
centered
destroyOnClose
>
<div style={{ display: 'flex', justifyContent: 'center', padding: '20px 0' }}>
<img
src={previewImage}
alt="二维码预览"
style={{ maxWidth: '100%', maxHeight: '70vh', objectFit: 'contain' }}
/>
</div>
</Modal>
</>
);
};
@@ -1,5 +1,5 @@
import React, { useEffect, useState } from 'react';
import { PageContainer, ProFormText, ProTable } from '@ant-design/pro-components';
import React, { useEffect, useRef, useState } from 'react';
import { PageContainer, ProFormText, ProTable, type ActionType } from '@ant-design/pro-components';
import { Popconfirm, Space, Tag, message } from 'antd';
import { ActionBar, GlassCard, GradientButton, SearchBarPlus } from '@/components/ui';
import { PlusOutlined } from '@ant-design/icons';
@@ -15,6 +15,7 @@ const TourismPage: React.FC = () => {
const [params, setParams] = useState<Record<string, any>>({});
const [qrcodeOpen, setQrcodeOpen] = useState(false);
const [qrcodeTourism, setQrcodeTourism] = useState<TourismItem | undefined>(undefined);
const actionRef = useRef<ActionType>();
// 首次进入时,默认按“当前租户 + 包含下级租户”查询,避免全量数据
useEffect(() => {
@@ -36,7 +37,7 @@ const TourismPage: React.FC = () => {
const columns: any[] = [
{ dataIndex: 'index', valueType: 'indexBorder', width: 48 },
{ title: '旅游项目', dataIndex: 'tourismName' },
{ title: '景区名称', dataIndex: 'tourismName' },
{ title: '地址', dataIndex: 'tourismAddress' },
{ title: '经度', dataIndex: 'longitude' },
{ title: '纬度', dataIndex: 'latitude' },
@@ -57,7 +58,7 @@ const TourismPage: React.FC = () => {
key: 'action',
render: (_: any, record: TourismItem) => (
<Space>
<a onClick={() => { setQrcodeTourism(record); setQrcodeOpen(true); }}>打卡点</a>
<a onClick={() => { setQrcodeTourism(record); setQrcodeOpen(true); }}>二维码</a>
<a onClick={() => { setCurrent(record); setEditOpen(true); }}>编辑</a>
<Popconfirm
title={`确认删除项目[${record.tourismName}]?`}
@@ -66,6 +67,7 @@ const TourismPage: React.FC = () => {
try {
await ordersApi.deleteTourism(record.id!);
message.success('删除成功');
actionRef.current?.reload();
} catch {
message.error('删除失败');
} finally { hide(); }
@@ -79,15 +81,22 @@ const TourismPage: React.FC = () => {
];
return (
<PageContainer header={{ title: '旅游项目' }}>
<PageContainer header={{ title: '景区列表' }}>
<SearchBarPlus
defaultCollapsed
split
span={8}
hideReset
onTenantChanged={(tenantId, includeChildren) => {
setParams((prev) => ({ ...(prev || {}), tenantId, includeChildren }));
// 强制刷新表格
actionRef.current?.reload();
}}
onFinish={async (values) => {
setParams((prev) => ({ ...(prev || {}), ...values }));
// 即使查询条件未变化也再次请求
actionRef.current?.reload();
}}
onFinish={async (values) => setParams((prev) => ({ ...(prev || {}), ...values }))}
>
<ProFormText name="tourismName" label="景区名称" placeholder="请输入景区名称" />
</SearchBarPlus>
@@ -104,6 +113,7 @@ const TourismPage: React.FC = () => {
{params?.tenantId ? (
<ProTable<TourismItem>
rowKey="id"
actionRef={actionRef}
params={params}
request={(p) => ordersApi.tourism({ ...(p as any), ...params })}
columns={columns}
@@ -123,6 +133,8 @@ const TourismPage: React.FC = () => {
try {
await ordersApi.saveOrUpdateTourism(values);
message.success('新增成功');
// 新增成功后刷新表格
actionRef.current?.reload();
return true;
} catch {
message.error('新增失败');
@@ -141,6 +153,7 @@ const TourismPage: React.FC = () => {
try {
await ordersApi.saveOrUpdateTourism({ ...(current as any), ...values });
message.success('修改成功');
actionRef.current?.reload();
return true;
} catch {
message.error('修改失败');
@@ -162,3 +175,4 @@ const TourismPage: React.FC = () => {
};
export default TourismPage;