From 84db79fb226a64a1f54ae610a252a7359964df91 Mon Sep 17 00:00:00 2001 From: duzhichao <1098974448@qq.com> Date: Thu, 23 Oct 2025 12:12:39 +0800 Subject: [PATCH 1/8] =?UTF-8?q?feat:=201=EF=BC=9A=E4=BC=98=E5=8C=96token?= =?UTF-8?q?=E6=9F=A5=E8=AF=A2=E9=A1=B5=202=EF=BC=9A=E7=94=A8=E6=88=B7?= =?UTF-8?q?=E7=AE=A1=E7=90=86=E9=A1=B5=E9=9D=A2=E6=96=B0=E5=A2=9E=E4=BF=AE?= =?UTF-8?q?=E6=94=B9=E5=AF=86=E7=A0=81=E5=8A=9F=E8=83=BD=203=EF=BC=9A?= =?UTF-8?q?=E8=B0=83=E6=95=B4=E6=99=AF=E5=8C=BA=E4=B8=8E=E4=BA=8C=E7=BB=B4?= =?UTF-8?q?=E7=A0=81=E5=85=B3=E7=B3=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/components/ui/SearchBarPlus/index.tsx | 19 +++++- .../src/pages/orders/Tourism/index.tsx | 13 ++++ .../src/pages/system/Token/index.tsx | 60 ++++++------------- .../system/User/components/UserTable.tsx | 10 ++-- .../src/pages/system/User/index.tsx | 59 +++++++++++++++--- zlt-web/react-web-next/src/services/orders.ts | 7 +++ zlt-web/react-web-next/src/services/system.ts | 14 +++++ zlt-web/react-web-next/src/services/token.ts | 9 ++- 8 files changed, 133 insertions(+), 58 deletions(-) diff --git a/zlt-web/react-web-next/src/components/ui/SearchBarPlus/index.tsx b/zlt-web/react-web-next/src/components/ui/SearchBarPlus/index.tsx index 3c7acd32..94bd5191 100644 --- a/zlt-web/react-web-next/src/components/ui/SearchBarPlus/index.tsx +++ b/zlt-web/react-web-next/src/components/ui/SearchBarPlus/index.tsx @@ -1,10 +1,11 @@ import React from 'react'; import { QueryFilter } from '@ant-design/pro-components'; +import { Button } from 'antd'; import TenantSelector from '@/components/ui/TenantSelector'; import { tenantApi } from '@/services/tenant'; export interface SearchBarPlusProps { - // QueryFilter 透传属性(常用) + // QueryFilter 常用属性 defaultCollapsed?: boolean; split?: boolean; span?: number | { xs?: number; sm?: number; md?: number; lg?: number; xl?: number; xxl?: number }; @@ -14,12 +15,14 @@ export interface SearchBarPlusProps { children?: React.ReactNode; // 是否显示租户筛选(默认显示) showTenant?: boolean; - // 租户变化回调:用于触发表格 reload 等 + // 租户变化回调:用于触发表格 reload onTenantChanged?: (tenantId: string, includeChildren: boolean) => void; // 租户筛选放置位置:start 放在最前,end 放在最后(默认 start) tenantPosition?: 'start' | 'end'; // 是否调用后端“切换查询租户”接口(默认不调用,避免跨页面副作用) useSwitchTenant?: boolean; + // 是否隐藏重置按钮(默认 false) + hideReset?: boolean; } const SearchBarPlus: React.FC = ({ @@ -33,6 +36,7 @@ const SearchBarPlus: React.FC = ({ onTenantChanged, tenantPosition = 'start', useSwitchTenant = false, + hideReset = false, }) => { const handleFinish = async (values: Record) => { try { @@ -52,6 +56,17 @@ const SearchBarPlus: React.FC = ({ span={span as any} form={form} onFinish={handleFinish} + submitter={ + hideReset + ? { + render: (props: any) => [ + , + ], + } + : undefined + } > {showTenant && tenantPosition === 'start' ? : null} {children} diff --git a/zlt-web/react-web-next/src/pages/orders/Tourism/index.tsx b/zlt-web/react-web-next/src/pages/orders/Tourism/index.tsx index f7b583e1..c99cb701 100644 --- a/zlt-web/react-web-next/src/pages/orders/Tourism/index.tsx +++ b/zlt-web/react-web-next/src/pages/orders/Tourism/index.tsx @@ -5,6 +5,7 @@ import { ActionBar, GlassCard, GradientButton, SearchBarPlus } from '@/component import { PlusOutlined } from '@ant-design/icons'; import { ordersApi } from '@/services/orders'; import TourismForm, { TourismItem } from './components/TourismForm'; +import QrcodeListModal from './components/QrcodeListModal'; import { tenantApi } from '@/services/tenant'; const TourismPage: React.FC = () => { @@ -12,6 +13,8 @@ const TourismPage: React.FC = () => { const [editOpen, setEditOpen] = useState(false); const [current, setCurrent] = useState(undefined); const [params, setParams] = useState>({}); + const [qrcodeOpen, setQrcodeOpen] = useState(false); + const [qrcodeTourism, setQrcodeTourism] = useState(undefined); // 首次进入时,默认按“当前租户 + 包含下级租户”查询,避免全量数据 useEffect(() => { @@ -54,6 +57,7 @@ const TourismPage: React.FC = () => { key: 'action', render: (_: any, record: TourismItem) => ( + { setQrcodeTourism(record); setQrcodeOpen(true); }}>打卡点 { setCurrent(record); setEditOpen(true); }}>编辑 { } finally { hide(); } }} /> + + {qrcodeOpen && qrcodeTourism?.id ? ( + + ) : null} ); }; diff --git a/zlt-web/react-web-next/src/pages/system/Token/index.tsx b/zlt-web/react-web-next/src/pages/system/Token/index.tsx index bb1d2978..b5fa9b47 100644 --- a/zlt-web/react-web-next/src/pages/system/Token/index.tsx +++ b/zlt-web/react-web-next/src/pages/system/Token/index.tsx @@ -1,30 +1,14 @@ -import React, { useEffect, useRef, useState } from 'react'; -import { PageContainer, ProFormSelect, ProFormText, ProTable } from '@ant-design/pro-components'; -import type { ActionType } from '@ant-design/pro-components'; -import { Popconfirm, Form, message } from 'antd'; -import { roleApi } from '@/services/role'; +import React, { useRef } from 'react'; +import { PageContainer, ProTable } from '@ant-design/pro-components'; +import type { ActionType, ProColumns } from '@ant-design/pro-components'; +import { Popconfirm, message, Button } from 'antd'; import { tokenApi, TokenItem } from '@/services/token'; -import { GlassCard, SearchBarPlus } from '@/components/ui'; +import { GlassCard } from '@/components/ui'; const TokenPage: React.FC = () => { - const [apps, setApps] = useState([]); - const [params, setParams] = useState<{ tenantId?: string; username?: string }>({}); - const [form] = Form.useForm(); const actionRef = useRef(); - useEffect(() => { - (async () => { - const appData = (await roleApi.apps()) || []; - setApps(appData); - if (appData.length > 0) { - const tenantId = appData[0].clientId; - setParams({ tenantId }); - form.setFieldsValue({ tenantId }); - } - })(); - }, []); - - const columns = [ + const columns: ProColumns[] = [ { dataIndex: 'index', valueType: 'indexBorder' }, { title: 'Token', dataIndex: 'tokenValue', width: 200 }, { title: '过期时间', dataIndex: 'expiration', valueType: 'dateTime' }, @@ -33,7 +17,8 @@ const TokenPage: React.FC = () => { { title: '所属应用', dataIndex: 'clientId' }, { title: '账号类型', dataIndex: 'accountType' }, { - title: '操作', key: 'action', + title: '操作', + key: 'action', render: (_: any, entity: TokenItem) => ( { actionRef.current?.reload(); } catch (e) { message.error('删除失败'); - } finally { hide(); } + } finally { + hide(); + } }} > 删除 - ) + ), }, ]; return ( - actionRef.current?.reload?.()} - onFinish={async (values) => setParams(values)} - > - ({ label: item.clientId, value: item.clientId }))} - /> - - - rowKey="tokenValue" headerTitle="Token 列表" actionRef={actionRef} - request={async (p) => tokenApi.page({ ...p, ...params } as any)} + request={async (p) => tokenApi.page({ ...p } as any)} columns={columns as any} + toolBarRender={() => [ + , + ]} search={false} pagination={{ showSizeChanger: true, showQuickJumper: true }} /> diff --git a/zlt-web/react-web-next/src/pages/system/User/components/UserTable.tsx b/zlt-web/react-web-next/src/pages/system/User/components/UserTable.tsx index 2f7b790f..78287bb0 100644 --- a/zlt-web/react-web-next/src/pages/system/User/components/UserTable.tsx +++ b/zlt-web/react-web-next/src/pages/system/User/components/UserTable.tsx @@ -11,12 +11,13 @@ export interface UserTableRef { export interface UserTableProps { onEdit: (record: UserItem) => void; onResetPassword: (record: UserItem) => void; + onChangePassword: (record: UserItem) => void; onDelete: (record: UserItem) => void; // 额外查询参数(由外部查询条件统一注入) extraParams?: Record; } -const UserTable = forwardRef(({ onEdit, onResetPassword, onDelete, extraParams }, ref) => { +const UserTable = forwardRef(({ onEdit, onResetPassword, onChangePassword, onDelete, extraParams }, ref) => { const actionRef = useRef(); useImperativeHandle(ref, () => ({ @@ -35,7 +36,7 @@ const UserTable = forwardRef(({ onEdit, onResetPas { title: '用户名', dataIndex: 'username' }, { title: '用户昵称', dataIndex: 'nickname' }, { title: '手机号', dataIndex: 'mobile' }, - { title: '性别', dataIndex: 'sex', valueType: 'select', valueEnum: { 0: { text: '男' }, 1: { text: '女' } }, width: 80 }, + { title: '性别', dataIndex: 'sex', valueType: 'select', valueEnum: { 0: { text: '女' }, 1: { text: '男' } }, width: 80 }, { title: '创建时间', dataIndex: 'createTime', valueType: 'dateTime', search: false }, { title: '状态', dataIndex: 'enabled', search: false, @@ -44,10 +45,11 @@ const UserTable = forwardRef(({ onEdit, onResetPas ) }, { - title: '操作', valueType: 'option', width: 220, + title: '操作', valueType: 'option', width: 280, render: (_, entity) => ( onEdit(entity)}>编辑 + onChangePassword(entity)}>修改密码 onResetPassword(entity)}>重置密码 onDelete(entity)}> 删除 @@ -71,7 +73,7 @@ const UserTable = forwardRef(({ onEdit, onResetPas const { data, total } = await systemApi.users({ ...(safeP as any), ...(safeExtra as any) } as any); return { data, total, success: true }; }} - pagination={{ pageSize: 10 }} + pagination={{ pageSize: 20 }} // 统一关闭 ProTable 自带搜索,由 SearchBarPlus 统一驱动 search={false} toolBarRender={false} diff --git a/zlt-web/react-web-next/src/pages/system/User/index.tsx b/zlt-web/react-web-next/src/pages/system/User/index.tsx index e3995198..5d9c0c9d 100644 --- a/zlt-web/react-web-next/src/pages/system/User/index.tsx +++ b/zlt-web/react-web-next/src/pages/system/User/index.tsx @@ -6,6 +6,7 @@ import { systemApi, UserItem } from '@/services/system'; import UserTable, { UserTableRef } from './components/UserTable'; import Toolbar from './components/Toolbar'; import UserForm from './components/UserForm'; +import ChangePasswordModal from './components/ChangePasswordModal'; const UsersPage: React.FC = () => { const tableRef = useRef(null); @@ -15,18 +16,27 @@ const UsersPage: React.FC = () => { const [createVisible, setCreateVisible] = useState(false); const [editVisible, setEditVisible] = useState(false); const [currentRow, setCurrentRow] = useState(undefined); + const [pwdVisible, setPwdVisible] = useState(false); + const [pwdUser, setPwdUser] = useState(undefined); const addUser = async (values: UserItem & { company?: string; type?: string }) => { const hide = message.loading('正在添加'); try { - await systemApi.saveOrUpdateUser({ ...(values as any), roleId: (values as any)?.roleIds ? (values as any).roleIds.join(',') : (values as any)?.roleId } as any); + const res: any = await systemApi.saveOrUpdateUserRaw({ + ...(values as any), + roleId: (values as any)?.roleIds ? (values as any).roleIds.join(',') : (values as any)?.roleId, + } as any); + const code = res?.resp_code ?? res?.code; + if (typeof code === 'number' && code !== 0) { + throw new Error(res?.resp_msg || res?.message || '添加用户失败'); + } hide(); message.success('添加用户成功'); tableRef.current?.reload(); return true; - } catch (e) { + } catch (e: any) { hide(); - message.error('添加用户失败'); + message.error(e?.message || '添加用户失败'); return false; } }; @@ -34,14 +44,22 @@ const UsersPage: React.FC = () => { const editUser = async (values: UserItem & { company?: string; type?: string }) => { const hide = message.loading('正在更新'); try { - await systemApi.saveOrUpdateUser({ ...(currentRow as any), ...(values as any), roleId: (values as any)?.roleIds ? (values as any).roleIds.join(',') : (values as any)?.roleId } as any); + const res: any = await systemApi.saveOrUpdateUserRaw({ + ...(currentRow as any), + ...(values as any), + roleId: (values as any)?.roleIds ? (values as any).roleIds.join(',') : (values as any)?.roleId, + } as any); + const code = res?.resp_code ?? res?.code; + if (typeof code === 'number' && code !== 0) { + throw new Error(res?.resp_msg || res?.message || '修改用户失败'); + } hide(); message.success('修改用户成功'); tableRef.current?.reload(); return true; - } catch (e) { + } catch (e: any) { hide(); - message.error('修改用户失败'); + message.error(e?.message || '修改用户失败'); return false; } }; @@ -58,6 +76,28 @@ const UsersPage: React.FC = () => { } }; + const openChangePwd = (record: UserItem) => { + setPwdUser(record); + setPwdVisible(true); + }; + + const submitChangePwd = async (values: { newPassword: string; confirmPassword: string }) => { + const hide = message.loading('正在修改密码'); + try { + await systemApi.changePassword(pwdUser!.id!, values.newPassword); + hide(); + message.success('修改密码成功'); + setPwdVisible(false); + setPwdUser(undefined); + tableRef.current?.reload(); + return true; + } catch (e) { + hide(); + message.error('修改密码失败'); + return false; + } + }; + const delUser = async (record: UserItem) => { const hide = message.loading('正在删除'); try { @@ -83,6 +123,7 @@ const UsersPage: React.FC = () => { defaultCollapsed={false} split span={6} + hideReset showTenant={!isAppType} onTenantChanged={(tenantId, includeChildren) => { // 租户切换时,直接更新查询参数,ProTable 会因 params 变更自动请求 @@ -106,6 +147,7 @@ const UsersPage: React.FC = () => { { setCurrentRow(r); setEditVisible(true); }} + onChangePassword={(r) => openChangePwd(r)} onResetPassword={(r) => resetPwd(r)} onDelete={(r) => delUser(r)} // 通过 __refresh 强制区分每次点击 @@ -113,11 +155,14 @@ const UsersPage: React.FC = () => { /> - {/* 新建(仅系统用户) */} + {/* 新建(仅系统用户)*/} {/* 编辑 */} + + {/* 修改密码 */} + ); }; diff --git a/zlt-web/react-web-next/src/services/orders.ts b/zlt-web/react-web-next/src/services/orders.ts index 41a38fd3..0124ecf4 100644 --- a/zlt-web/react-web-next/src/services/orders.ts +++ b/zlt-web/react-web-next/src/services/orders.ts @@ -49,6 +49,13 @@ export const ordersApi = { return (res as any).data || res; }, + // 按景区ID查询二维码列表 + qrcodeListByTourism: async (params: { current?: number; pageSize?: number; tourismId: number; [k: string]: any }) => { + const { current, pageSize, ...rest } = params || {}; + const res = await request('/api-order/qrcode', { method: 'GET', params: { page: current, limit: pageSize, ...rest } }); + return { data: (res as any).data, total: (res as any).count }; + }, + // 旅游景区 tourism: async (params: { current?: number; pageSize?: number; [k: string]: any }) => { const { current, pageSize, ...rest } = params || {}; diff --git a/zlt-web/react-web-next/src/services/system.ts b/zlt-web/react-web-next/src/services/system.ts index 193566eb..88febec3 100644 --- a/zlt-web/react-web-next/src/services/system.ts +++ b/zlt-web/react-web-next/src/services/system.ts @@ -40,6 +40,11 @@ export const systemApi = { const res = await request('/api-user/users/saveOrUpdate', { method: 'POST', data }); return (res as any).data || res; }, + // 原样返回后端包装,便于上层拿到 resp_code/resp_msg 做精确提示 + saveOrUpdateUserRaw: async (data: Partial) => { + const res = await request('/api-user/users/saveOrUpdate', { method: 'POST', data }); + return res as any; + }, // 启用/禁用 updateEnabled: async (id: number, enabled: boolean) => { @@ -52,6 +57,15 @@ export const systemApi = { const res = await request(`/api-user/users/${id}/password`, { method: 'PUT' }); return (res as any).data || res; }, + // 修改密码(支持管理员为指定用户设置自定义密码,或用户自助修改) + // 后端签名:PUT /users/password,Body: { id, oldPassword?, newPassword } + changePassword: async (id: number, newPassword: string, oldPassword?: string) => { + const res = await request('/api-user/users/password', { + method: 'PUT', + data: { id, newPassword, oldPassword }, + }); + return (res as any).data || res; + }, // 删除用户 deleteUser: async (id: number) => { diff --git a/zlt-web/react-web-next/src/services/token.ts b/zlt-web/react-web-next/src/services/token.ts index cf54aea3..3092d593 100644 --- a/zlt-web/react-web-next/src/services/token.ts +++ b/zlt-web/react-web-next/src/services/token.ts @@ -10,9 +10,12 @@ export interface TokenItem { } export const tokenApi = { - page: async (params: { current?: number; pageSize?: number; tenantId: string; username?: string }) => { - if (!params?.tenantId) return { data: [], total: 0 }; - const res = await request('/api-uaa/tokens', { method: 'GET', params: { page: params.current, limit: params.pageSize, ...params } }); + page: async (params: { current?: number; pageSize?: number; tenantId?: string; username?: string }) => { + const p2 = { tenantId: 'webApp', ...params }; + const res = await request('/api-uaa/tokens', { + method: 'GET', + params: { page: p2.current, limit: p2.pageSize, ...p2 }, + }); const data = (res as any).data; const total = (res as any).count ?? data?.length ?? 0; return { data, total } as { data: TokenItem[]; total: number }; From 1a0669e385b4687bb921feb517ec2d104122085d Mon Sep 17 00:00:00 2001 From: duzhichao <1098974448@qq.com> Date: Thu, 23 Oct 2025 12:13:03 +0800 Subject: [PATCH 2/8] =?UTF-8?q?feat:=201=EF=BC=9A=E4=BC=98=E5=8C=96token?= =?UTF-8?q?=E6=9F=A5=E8=AF=A2=E9=A1=B5=202=EF=BC=9A=E7=94=A8=E6=88=B7?= =?UTF-8?q?=E7=AE=A1=E7=90=86=E9=A1=B5=E9=9D=A2=E6=96=B0=E5=A2=9E=E4=BF=AE?= =?UTF-8?q?=E6=94=B9=E5=AF=86=E7=A0=81=E5=8A=9F=E8=83=BD=203=EF=BC=9A?= =?UTF-8?q?=E8=B0=83=E6=95=B4=E6=99=AF=E5=8C=BA=E4=B8=8E=E4=BA=8C=E7=BB=B4?= =?UTF-8?q?=E7=A0=81=E5=85=B3=E7=B3=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Tourism/components/QrcodeListModal.tsx | 154 ++++++++++++++++++ .../User/components/ChangePasswordModal.tsx | 54 ++++++ 2 files changed, 208 insertions(+) create mode 100644 zlt-web/react-web-next/src/pages/orders/Tourism/components/QrcodeListModal.tsx create mode 100644 zlt-web/react-web-next/src/pages/system/User/components/ChangePasswordModal.tsx diff --git a/zlt-web/react-web-next/src/pages/orders/Tourism/components/QrcodeListModal.tsx b/zlt-web/react-web-next/src/pages/orders/Tourism/components/QrcodeListModal.tsx new file mode 100644 index 00000000..4a7b57f1 --- /dev/null +++ b/zlt-web/react-web-next/src/pages/orders/Tourism/components/QrcodeListModal.tsx @@ -0,0 +1,154 @@ +import React, { useMemo, useRef, useState } from 'react'; +import { Modal, Popconfirm, Space, Tag, message } from 'antd'; +import { ProTable, type ActionType } from '@ant-design/pro-components'; +import { GradientButton } from '@/components/ui'; +import { PlusOutlined } from '@ant-design/icons'; +import { ordersApi } from '@/services/orders'; +import QrcodeForm, { QrcodeItem } from '../../Qrcode/components/QrcodeForm'; + +export interface QrcodeListModalProps { + open: boolean; + onOpenChange: (v: boolean) => void; + tourismId: number; + tourismName?: string; +} + +const QrcodeListModal: React.FC = ({ open, onOpenChange, tourismId, tourismName }) => { + const actionRef = useRef(); + const [createOpen, setCreateOpen] = useState(false); + const [editOpen, setEditOpen] = useState(false); + const [current, setCurrent] = useState(undefined); + + const title = useMemo( + () => `打卡点二维码列表${tourismName ? `(${tourismName})` : ''}`, + [tourismName], + ); + + const columns: any[] = [ + { dataIndex: 'index', valueType: 'indexBorder', width: 56 }, + { title: '名称', dataIndex: 'name' }, + { title: '链接', dataIndex: 'url', ellipsis: true }, + { title: '类型', dataIndex: 'type' }, + { + title: '状态', + dataIndex: 'status', + render: (v: number) => ( + {v === 1 ? '启用' : '禁用'} + ), + }, + { + title: '操作', + key: 'action', + width: 160, + render: (_: any, record: QrcodeItem) => ( + + { + setCurrent(record); + setEditOpen(true); + }} + > + 编辑 + + { + const hide = message.loading('正在删除...'); + try { + await ordersApi.deleteQrcode(record.id!); + message.success('删除成功'); + actionRef.current?.reload(); + } catch (e) { + message.error('删除失败'); + } finally { + hide(); + } + }} + > + 删除 + + + ), + }, + ]; + + return ( + <> + onOpenChange(false)} + footer={null} + width={1000} + destroyOnClose + > +
+ } + onClick={() => setCreateOpen(true)} + > + 新增 + +
+ + + rowKey="id" + actionRef={actionRef} + request={(p) => ordersApi.qrcodeListByTourism({ ...(p as any), tourismId })} + columns={columns} + search={false} + pagination={{ showSizeChanger: true, showQuickJumper: true }} + toolBarRender={false} + /> +
+ + {/* 新增二维码 */} + { + const hide = message.loading('保存中...'); + try { + await ordersApi.saveOrUpdateQrcode({ ...values, tourismId }); + message.success('新增成功'); + actionRef.current?.reload(); + return true; + } catch (e) { + message.error('保存失败'); + return false; + } finally { + hide(); + } + }} + /> + + {/* 编辑二维码 */} + { + const hide = message.loading('保存中...'); + try { + await ordersApi.saveOrUpdateQrcode({ ...(current as any), ...values }); + message.success('修改成功'); + actionRef.current?.reload(); + return true; + } catch (e) { + message.error('修改失败'); + return false; + } finally { + hide(); + } + }} + /> + + ); +}; + +export default QrcodeListModal; + diff --git a/zlt-web/react-web-next/src/pages/system/User/components/ChangePasswordModal.tsx b/zlt-web/react-web-next/src/pages/system/User/components/ChangePasswordModal.tsx new file mode 100644 index 00000000..81846b40 --- /dev/null +++ b/zlt-web/react-web-next/src/pages/system/User/components/ChangePasswordModal.tsx @@ -0,0 +1,54 @@ +import React from 'react'; +import { ModalForm, ProFormText } from '@ant-design/pro-components'; +import type { UserItem } from '@/services/system'; + +export interface ChangePasswordModalProps { + visible: boolean; + user?: UserItem; + onVisibleChange: (v: boolean) => void; + onFinish: (values: { newPassword: string; confirmPassword: string }) => Promise; +} + +/** + * 修改密码弹窗(支持管理员为任意用户设置新密码) + */ +const ChangePasswordModal: React.FC = ({ visible, user, onVisibleChange, onFinish }) => { + return ( + + title={`修改密码${user?.username ? ` - ${user.username}` : ''}`} + visible={visible} + onVisibleChange={onVisibleChange} + modalProps={{ destroyOnClose: true }} + onFinish={onFinish} + > + + ({ + validator(_, value) { + if (!value || getFieldValue('newPassword') === value) { + return Promise.resolve(); + } + return Promise.reject(new Error('两次输入的密码不一致')); + }, + }), + ]} + /> + + ); +}; + +export default ChangePasswordModal; + From 7aa0e6a32fb4a63a178a37f4c424537d321f8566 Mon Sep 17 00:00:00 2001 From: duzhichao <1098974448@qq.com> Date: Thu, 23 Oct 2025 18:02:39 +0800 Subject: [PATCH 3/8] =?UTF-8?q?feat:=201=EF=BC=9A=E4=BC=98=E5=8C=96token?= =?UTF-8?q?=E6=9F=A5=E8=AF=A2=E9=A1=B5=202=EF=BC=9A=E7=94=A8=E6=88=B7?= =?UTF-8?q?=E7=AE=A1=E7=90=86=E9=A1=B5=E9=9D=A2=E6=96=B0=E5=A2=9E=E4=BF=AE?= =?UTF-8?q?=E6=94=B9=E5=AF=86=E7=A0=81=E5=8A=9F=E8=83=BD=203=EF=BC=9A?= =?UTF-8?q?=E8=B0=83=E6=95=B4=E6=99=AF=E5=8C=BA=E4=B8=8E=E4=BA=8C=E7=BB=B4?= =?UTF-8?q?=E7=A0=81=E5=85=B3=E7=B3=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/resources/mapper/TourismMapper.xml | 3 + .../Tourism/components/QrcodeListModal.tsx | 132 ++++++++++++++++-- .../src/pages/orders/Tourism/index.tsx | 26 +++- zlt-web/react-web-next/src/services/orders.ts | 3 +- 4 files changed, 148 insertions(+), 16 deletions(-) diff --git a/zlt-business/order-center/src/main/resources/mapper/TourismMapper.xml b/zlt-business/order-center/src/main/resources/mapper/TourismMapper.xml index 651499a2..1df4b60a 100644 --- a/zlt-business/order-center/src/main/resources/mapper/TourismMapper.xml +++ b/zlt-business/order-center/src/main/resources/mapper/TourismMapper.xml @@ -16,6 +16,9 @@ AND t.tenant_id = #{p.tenantId} + + AND t.tourism_name LIKE CONCAT('%', #{p.tourismName}, '%') + ORDER BY t.id DESC diff --git a/zlt-web/react-web-next/src/pages/orders/Tourism/components/QrcodeListModal.tsx b/zlt-web/react-web-next/src/pages/orders/Tourism/components/QrcodeListModal.tsx index 4a7b57f1..351a52bc 100644 --- a/zlt-web/react-web-next/src/pages/orders/Tourism/components/QrcodeListModal.tsx +++ b/zlt-web/react-web-next/src/pages/orders/Tourism/components/QrcodeListModal.tsx @@ -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 = ({ open, onOpenChange, t const [createOpen, setCreateOpen] = useState(false); const [editOpen, setEditOpen] = useState(false); const [current, setCurrent] = useState(undefined); + const [previewOpen, setPreviewOpen] = useState(false); + const [previewImage, setPreviewImage] = useState(''); const title = useMemo( () => `打卡点二维码列表${tourismName ? `(${tourismName})` : ''}`, @@ -25,21 +27,113 @@ const QrcodeListModal: React.FC = ({ 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 ( +
+ + {codeId} + +
+ ); + }, + }, + { + title: '航线ID', + dataIndex: 'waylineId', + width: 200, + render: (waylineId: string) => { + if (!waylineId) return '-'; + return ( +
+ + {waylineId} + +
+ ); + }, + }, + { + title: '二维码', + dataIndex: 'viewUrl', + width: 100, + render: (url: string) => { + if (!url) return '-'; + return ( + 二维码 { + 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) => ( - {v === 1 ? '启用' : '禁用'} + + {v === 1 ? '开启' : '关闭'} + ), }, + { title: '创建时间', dataIndex: 'createTime', valueType: 'dateTime', width: 160 }, { title: '操作', key: 'action', - width: 160, + width: 140, + fixed: 'right', render: (_: any, record: QrcodeItem) => ( = ({ open, onOpenChange, t open={open} onCancel={() => onOpenChange(false)} footer={null} - width={1000} + width={1400} destroyOnClose >
@@ -101,6 +195,7 @@ const QrcodeListModal: React.FC = ({ open, onOpenChange, t search={false} pagination={{ showSizeChanger: true, showQuickJumper: true }} toolBarRender={false} + scroll={{ x: 1200 }} /> @@ -146,6 +241,25 @@ const QrcodeListModal: React.FC = ({ open, onOpenChange, t } }} /> + + {/* 二维码预览 */} + setPreviewOpen(false)} + footer={null} + width={600} + centered + destroyOnClose + > +
+ 二维码预览 +
+
); }; diff --git a/zlt-web/react-web-next/src/pages/orders/Tourism/index.tsx b/zlt-web/react-web-next/src/pages/orders/Tourism/index.tsx index c99cb701..fe613861 100644 --- a/zlt-web/react-web-next/src/pages/orders/Tourism/index.tsx +++ b/zlt-web/react-web-next/src/pages/orders/Tourism/index.tsx @@ -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>({}); const [qrcodeOpen, setQrcodeOpen] = useState(false); const [qrcodeTourism, setQrcodeTourism] = useState(undefined); + const actionRef = useRef(); // 首次进入时,默认按“当前租户 + 包含下级租户”查询,避免全量数据 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) => ( -
{ setQrcodeTourism(record); setQrcodeOpen(true); }}>打卡点 + { setQrcodeTourism(record); setQrcodeOpen(true); }}>二维码 { setCurrent(record); setEditOpen(true); }}>编辑 { 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 ( - + { 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 }))} > @@ -104,6 +113,7 @@ const TourismPage: React.FC = () => { {params?.tenantId ? ( 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; + diff --git a/zlt-web/react-web-next/src/services/orders.ts b/zlt-web/react-web-next/src/services/orders.ts index 0124ecf4..be502b0c 100644 --- a/zlt-web/react-web-next/src/services/orders.ts +++ b/zlt-web/react-web-next/src/services/orders.ts @@ -67,7 +67,8 @@ export const ordersApi = { return (res as any).data || res; }, deleteTourism: async (id: number) => { - const res = await request(`/api-order/tourism/${id}`, { method: 'DELETE' }); + // 后端删除接口为 DELETE /tourism(从请求体读取 id),不支持 path 变量 + const res = await request('/api-order/tourism', { method: 'DELETE', data: { id } }); return (res as any).data || res; }, From 839f682ca858bc66f5f484da19aa42e50d72365d Mon Sep 17 00:00:00 2001 From: duzhichao <1098974448@qq.com> Date: Sat, 25 Oct 2025 11:09:56 +0800 Subject: [PATCH 4/8] =?UTF-8?q?feat:=201=EF=BC=9A=E6=99=AF=E5=8C=BA?= =?UTF-8?q?=E4=BA=8C=E7=BB=B4=E7=A0=81=E5=88=97=E8=A1=A8=E5=A2=9E=E5=88=A0?= =?UTF-8?q?=E6=94=B9=E6=9F=A5=E4=BF=AE=E6=94=B9=EF=BC=8C=E5=8E=BB=E6=8E=89?= =?UTF-8?q?=E5=8D=95=E7=8B=AC=E7=9A=84=E4=BA=8C=E7=BB=B4=E7=A0=81=E5=88=97?= =?UTF-8?q?=E8=A1=A8=E7=AE=A1=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../order/controller/QrCodeController.java | 3 +- .../controller/VideoTemplateController.java | 17 +- zlt-register/zlt-register.iml | 56 ----- .../orders/Qrcode/components/QrcodeForm.tsx | 21 ++ .../Tourism/components/QrcodeListModal.tsx | 158 +++++++------ .../Tourism/components/QrcodeTourismForm.tsx | 209 ++++++++++++++++++ zlt-web/react-web-next/src/services/orders.ts | 25 ++- 7 files changed, 359 insertions(+), 130 deletions(-) delete mode 100644 zlt-register/zlt-register.iml create mode 100644 zlt-web/react-web-next/src/pages/orders/Tourism/components/QrcodeTourismForm.tsx diff --git a/zlt-business/order-center/src/main/java/com/central/order/controller/QrCodeController.java b/zlt-business/order-center/src/main/java/com/central/order/controller/QrCodeController.java index e14ed2af..64f0c6c2 100644 --- a/zlt-business/order-center/src/main/java/com/central/order/controller/QrCodeController.java +++ b/zlt-business/order-center/src/main/java/com/central/order/controller/QrCodeController.java @@ -89,7 +89,8 @@ public class QrCodeController { if (result.getResp_code() == 0){ Tourism tourism = tourismService.getTourismById(qrCode.getTourismId()); Assert.notNull(tourism, "请选择景区数据"); - qrCode.setTenantId(tourism.getTenantId()); + // qrCode.setTenantId(tourism.getTenantId()); + qrCode.setTenantId(qrCode.getTenantId()); qrCode.setCodeId(codeId); qrCode.setFilePath(result.getData().get("filePath").toString()); qrCode.setFileId(result.getData().get("fileId").toString()); diff --git a/zlt-business/order-center/src/main/java/com/central/order/controller/VideoTemplateController.java b/zlt-business/order-center/src/main/java/com/central/order/controller/VideoTemplateController.java index 70c14cd4..73b38cf5 100644 --- a/zlt-business/order-center/src/main/java/com/central/order/controller/VideoTemplateController.java +++ b/zlt-business/order-center/src/main/java/com/central/order/controller/VideoTemplateController.java @@ -92,4 +92,19 @@ public class VideoTemplateController { return Result.failed("获取失败"); } } -} \ No newline at end of file + + @Operation(summary = "根据模板ID(templateId)获取模板信息") + @GetMapping("/templateId/{templateId}") + public Result getByTemplateId(@PathVariable String templateId) { + try { + VideoTemplate template = videoTemplateService.lambdaQuery() + .eq(VideoTemplate::getTemplateId, templateId) + .last("limit 1") + .one(); + return Result.succeed(template); + } catch (Exception e) { + log.error("根据模板ID查询模板失败, templateId={}", templateId, e); + return Result.failed("查询失败"); + } + } +} diff --git a/zlt-register/zlt-register.iml b/zlt-register/zlt-register.iml deleted file mode 100644 index 195579d4..00000000 --- a/zlt-register/zlt-register.iml +++ /dev/null @@ -1,56 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/zlt-web/react-web-next/src/pages/orders/Qrcode/components/QrcodeForm.tsx b/zlt-web/react-web-next/src/pages/orders/Qrcode/components/QrcodeForm.tsx index c946bbc3..963ebe32 100644 --- a/zlt-web/react-web-next/src/pages/orders/Qrcode/components/QrcodeForm.tsx +++ b/zlt-web/react-web-next/src/pages/orders/Qrcode/components/QrcodeForm.tsx @@ -7,6 +7,27 @@ export interface QrcodeItem { type?: number; url?: string; status?: number; + // 以下为景区二维码列表中使用到的扩展字段(仅类型声明,不影响表单) + tourismId?: number; + codeId?: string; + waylineId?: string; + viewUrl?: string; + deviceSn?: string; + price?: number | string; + templateId?: string; + enableVideoEdit?: number; // 0: 否 1: 开启 + isTest?: number; // 0: 否 1: 是 + qrcodeType?: number; // 1: 游客下单 2: 定时巡查 其他: 其他 + showVideoEditOnly?: number; // 0: 否 1: 是 + materialCount?: number; + enableProfit?: number; // 0: 否 1: 是 + payeeAccount?: string; + payeeType?: 'MERCHANT_ID' | 'PERSONAL_OPENID' | string; + profitRate?: number; + appId?: string; + vlogCount?: number; + videoCount?: number; + photoCount?: number; } export interface QrcodeFormProps { diff --git a/zlt-web/react-web-next/src/pages/orders/Tourism/components/QrcodeListModal.tsx b/zlt-web/react-web-next/src/pages/orders/Tourism/components/QrcodeListModal.tsx index 351a52bc..43cc2ea5 100644 --- a/zlt-web/react-web-next/src/pages/orders/Tourism/components/QrcodeListModal.tsx +++ b/zlt-web/react-web-next/src/pages/orders/Tourism/components/QrcodeListModal.tsx @@ -4,7 +4,8 @@ import { ProTable, type ActionType } from '@ant-design/pro-components'; import { GradientButton } from '@/components/ui'; import { PlusOutlined, CopyOutlined } from '@ant-design/icons'; import { ordersApi } from '@/services/orders'; -import QrcodeForm, { QrcodeItem } from '../../Qrcode/components/QrcodeForm'; +import { QrcodeItem } from '../../Qrcode/components/QrcodeForm'; +import QrcodeTourismForm from './QrcodeTourismForm'; export interface QrcodeListModalProps { open: boolean; @@ -21,37 +22,59 @@ const QrcodeListModal: React.FC = ({ open, onOpenChange, t const [previewOpen, setPreviewOpen] = useState(false); const [previewImage, setPreviewImage] = useState(''); - const title = useMemo( - () => `打卡点二维码列表${tourismName ? `(${tourismName})` : ''}`, - [tourismName], - ); + // 模板ID(templateId 字符串) -> 模板名称(通过接口懒加载) + const templateNameMapRef = useRef>({}); + const templateInflightRef = useRef>>({}); + const [tplTick, setTplTick] = useState(0); // 用于触发渲染 + + const title = useMemo(() => `打卡点二维码列表${tourismName ? `(${tourismName})` : ''}`, [tourismName]); + + const ensureTemplateName = (tplId?: string) => { + if (!tplId) return '-'; + const map = templateNameMapRef.current; + if (map[tplId]) return map[tplId]; + if (!templateInflightRef.current[tplId]) { + templateInflightRef.current[tplId] = ordersApi + .getVideoTemplateByTemplateId(tplId) + .then((tpl: any) => { + const name = tpl?.templateName || tpl?.name || '-'; + map[tplId] = name; + setTplTick((v) => v + 1); + }) + .catch(() => { + map[tplId] = '-'; + setTplTick((v) => v + 1); + }) + .finally(() => { + delete templateInflightRef.current[tplId]; + }); + } + return '-'; + }; const columns: any[] = [ { dataIndex: 'index', valueType: 'indexBorder', width: 48 }, { title: 'ID', dataIndex: 'id', width: 80 }, - { title: '名称', dataIndex: 'name', width: 120 }, + { title: '名称', dataIndex: 'name', width: 140 }, { title: 'Code', dataIndex: 'codeId', - width: 200, + width: 220, render: (codeId: string) => { if (!codeId) return '-'; return ( -
- - {codeId} - +
+ {codeId} + + + + + {(uploadPreviewUrl || initialValues?.imageUrl) && ( + +
+ +
+ + )} + + + ); +}; + +export default TourismFileForm; diff --git a/zlt-web/react-web-next/src/pages/orders/TourismFile/index.tsx b/zlt-web/react-web-next/src/pages/orders/TourismFile/index.tsx index a875f1db..ef5f1e9b 100644 --- a/zlt-web/react-web-next/src/pages/orders/TourismFile/index.tsx +++ b/zlt-web/react-web-next/src/pages/orders/TourismFile/index.tsx @@ -1,24 +1,18 @@ -import React, { useEffect, useRef, useState } from 'react'; -import type { ActionType } from '@ant-design/pro-components'; +import React, { useEffect, useRef, useState } from 'react'; import { ActionBar, GlassCard, SearchBarPlus } from '@/components/ui'; -import { - ModalForm, - PageContainer, - ProForm, - ProFormSelect, - ProFormText, - ProTable, -} from '@ant-design/pro-components'; -import { Button, Image, Popconfirm, Space, Tag, Upload, message, Form } from 'antd'; -import { PlusOutlined, UploadOutlined } from '@ant-design/icons'; +import { PageContainer, ProFormSelect } from '@ant-design/pro-components'; +import { Button, Image, Popconfirm, Space, Tag, message, Pagination } from 'antd'; +import { PlusOutlined } from '@ant-design/icons'; import { ordersApi } from '@/services/orders'; +import TourismFileForm, { TourismFileItem } from './components/TourismFileForm'; +// 资源类型枚举(用于卡片展示的颜色) const TYPE_OPTIONS = [ { label: '视频', value: 5, color: '#f5222d' }, { label: '首页 Banner', value: 6, color: '#2f54eb' }, - { label: '展示封面', value: 4, color: '#52c41a' }, - { label: '入口引导', value: 3, color: '#722ed1' }, - { label: '服务小结展示', value: 2, color: '#13c2c2' }, + { label: '展示图片', value: 4, color: '#52c41a' }, + { label: '景区详情', value: 3, color: '#722ed1' }, + { label: '景区小图展示', value: 2, color: '#13c2c2' }, { label: '活动', value: 1, color: '#1890ff' }, ] as const; @@ -28,218 +22,197 @@ const STATUS_OPTIONS = [ ] as const; const TourismFilePage: React.FC = () => { - const actionRef = useRef(); const [query, setQuery] = useState>({}); const [tourismOptions, setTourismOptions] = useState>([]); + const [createOpen, setCreateOpen] = useState(false); const [editOpen, setEditOpen] = useState(false); const [current, setCurrent] = useState(); - const [uploadPreviewUrl, setUploadPreviewUrl] = useState(); - const [uploadPath, setUploadPath] = useState(); - const [editUploadPreviewUrl, setEditUploadPreviewUrl] = useState(); - const [editUploadPath, setEditUploadPath] = useState(); + // 分组数据(按项目分组)与分页 + const [groups, setGroups] = useState>([]); + const [loading, setLoading] = useState(false); + const fetchingRef = useRef(false); + const [pagination, setPagination] = useState<{ current: number; pageSize: number; total: number }>({ current: 1, pageSize: 10, total: 0 }); + + // 加载可选项目列表(用于筛选与表单下拉) useEffect(() => { (async () => { try { - const res = await ordersApi.tourism({ page: 1, limit: 1000 }); - const list: Array<{ id: number; tourismName: string }> = (res as any).data || res?.data || []; - setTourismOptions(list.map((it) => ({ label: (it as any).tourismName, value: (it as any).id }))); - } catch (e) { - // 忽略错误以不影响页面 - } + const res = await ordersApi.tourism({ page: 1, limit: 1000, tenantId: query?.tenantId, includeChildren: query?.includeChildren }); + const list: Array<{ id: number; tourismName: string }> = (res as any)?.data || []; + setTourismOptions(list.map((it: any) => ({ label: it.tourismName, value: it.id }))); + } catch {} })(); - }, []); + // 租户切换时刷新 + }, [query?.tenantId, query?.includeChildren]); - const columns: any[] = [ - { dataIndex: 'index', valueType: 'indexBorder', width: 48 }, - { - title: '旅游项目', - dataIndex: 'tourismId', - render: (_: any, record: any) => tourismOptions.find((o) => o.value === record.tourismId)?.label || record.tourismName || '-', - }, - { - title: '图片/预览', - dataIndex: 'imageUrl', - search: false, - width: 140, - render: (_: any, record: any) => - record.type === 5 ? ( -