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; +