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] =?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; +