feat: 二维码新增或者编辑绑定景区素材
This commit is contained in:
@@ -51,7 +51,7 @@ const QrcodeForm: React.FC<QrcodeFormProps> = ({ open, title, initialValues, onO
|
|||||||
<ProFormText name="name" label="名称" rules={[{ required: true, message: '请输入名称' }]} />
|
<ProFormText name="name" label="名称" rules={[{ required: true, message: '请输入名称' }]} />
|
||||||
<ProFormText name="url" label="地址" />
|
<ProFormText name="url" label="地址" />
|
||||||
<ProFormSelect name="type" label="类型" valueEnum={{ 1: '类型一', 2: '类型二' }} />
|
<ProFormSelect name="type" label="类型" valueEnum={{ 1: '类型一', 2: '类型二' }} />
|
||||||
<ProFormSelect name="status" label="状态" valueEnum={{ 1: '启用', 0: '禁用' }} initialValue={1} />
|
<ProFormSelect name="status" label="状态" valueEnum={{ 1: '禁用', 0: '启用' }} initialValue={1} />
|
||||||
</ModalForm>
|
</ModalForm>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import React, { useMemo, useRef, useState } from 'react';
|
import React, { useMemo, useRef, useState } from 'react';
|
||||||
import { Modal, Popconfirm, Space, Tag, message, Button } from 'antd';
|
import { Modal, Popconfirm, Space, Tag, message, Button } from 'antd';
|
||||||
import { ProTable, type ActionType } from '@ant-design/pro-components';
|
import { ProTable, type ActionType } from '@ant-design/pro-components';
|
||||||
import { GradientButton } from '@/components/ui';
|
import { GradientButton } from '@/components/ui';
|
||||||
@@ -23,11 +23,10 @@ const QrcodeListModal: React.FC<QrcodeListModalProps> = ({ open, onOpenChange, t
|
|||||||
const [previewImage, setPreviewImage] = useState<string>('');
|
const [previewImage, setPreviewImage] = useState<string>('');
|
||||||
|
|
||||||
// 模板ID -> 模板名称(通过接口懒加载)
|
// 模板ID -> 模板名称(通过接口懒加载)
|
||||||
const templateNameMapRef = useRef<Record<string, string>>({});
|
const templateNameMapRef = useRef<Record<string, string>>({});
|
||||||
const templateInflightRef = useRef<Record<string, Promise<any>>>({});
|
const templateInflightRef = useRef<Record<string, Promise<any>>>({});
|
||||||
const [tplTick, setTplTick] = useState(0); // 用于触发渲染
|
const [tplTick, setTplTick] = useState(0); // 用于触发渲染
|
||||||
|
const title = useMemo(() => `打卡点二维码列表${tourismName ? `(${tourismName})` : ''}`, [tourismName]);
|
||||||
const title = useMemo(() => `打卡点二维码列表${tourismName ? `(${tourismName})` : ''}`, [tourismName]);
|
|
||||||
|
|
||||||
const ensureTemplateName = (tplId?: string) => {
|
const ensureTemplateName = (tplId?: string) => {
|
||||||
if (!tplId) return '-';
|
if (!tplId) return '-';
|
||||||
@@ -117,8 +116,7 @@ const QrcodeListModal: React.FC<QrcodeListModalProps> = ({ open, onOpenChange, t
|
|||||||
return (
|
return (
|
||||||
<img
|
<img
|
||||||
src={url}
|
src={url}
|
||||||
alt="二维码"
|
alt="二维码" style={{ width: 60, height: 60, cursor: 'pointer', objectFit: 'contain' }}
|
||||||
style={{ width: 60, height: 60, cursor: 'pointer', objectFit: 'contain' }}
|
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
setPreviewImage(url);
|
setPreviewImage(url);
|
||||||
setPreviewOpen(true);
|
setPreviewOpen(true);
|
||||||
@@ -143,7 +141,7 @@ const QrcodeListModal: React.FC<QrcodeListModalProps> = ({ open, onOpenChange, t
|
|||||||
title: '状态',
|
title: '状态',
|
||||||
dataIndex: 'status',
|
dataIndex: 'status',
|
||||||
width: 90,
|
width: 90,
|
||||||
render: (v: number) => <Tag color={v === 1 ? 'green' : 'red'}>{v === 1 ? '启用' : '禁用'}</Tag>,
|
render: (v: number) => <Tag color={v === 0 ? 'green' : 'red'}>{v === 0 ? '启用' : '禁用'}</Tag>,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: '模板名称',
|
title: '模板名称',
|
||||||
@@ -188,13 +186,20 @@ const QrcodeListModal: React.FC<QrcodeListModalProps> = ({ open, onOpenChange, t
|
|||||||
render: (_: any, record: QrcodeItem) => (
|
render: (_: any, record: QrcodeItem) => (
|
||||||
<Space>
|
<Space>
|
||||||
<a
|
<a
|
||||||
onClick={() => {
|
onClick={async () => {
|
||||||
setCurrent(record);
|
try {
|
||||||
setEditOpen(true);
|
const plans = await ordersApi.getPackagePlanByCode(record.codeId as any);
|
||||||
}}
|
const plan: any = Array.isArray(plans) && plans.length > 0 ? plans[0] : {};
|
||||||
|
const tourismFileIds = plan.tourismFileIds ? String(plan.tourismFileIds).split(',').filter(Boolean).map((x: any) => Number(x)) : [];
|
||||||
|
setCurrent({ ...record, vlogCount: plan.vlogCount, videoCount: plan.videoCount, photoCount: plan.photoCount, tourismFileIds });
|
||||||
|
} catch {
|
||||||
|
setCurrent(record);
|
||||||
|
}
|
||||||
|
setEditOpen(true);
|
||||||
|
}}
|
||||||
>
|
>
|
||||||
编辑
|
编辑
|
||||||
</a>
|
</a>
|
||||||
<Popconfirm
|
<Popconfirm
|
||||||
title={`确认删除二维码【${record.name}】?`}
|
title={`确认删除二维码【${record.name}】?`}
|
||||||
onConfirm={async () => {
|
onConfirm={async () => {
|
||||||
@@ -241,8 +246,7 @@ const QrcodeListModal: React.FC<QrcodeListModalProps> = ({ open, onOpenChange, t
|
|||||||
{/* 新增/编辑表单:仅在打开时才挂载,避免列表页触发内部副作用 */}
|
{/* 新增/编辑表单:仅在打开时才挂载,避免列表页触发内部副作用 */}
|
||||||
{createOpen && (
|
{createOpen && (
|
||||||
<QrcodeTourismForm
|
<QrcodeTourismForm
|
||||||
title="新增二维码"
|
title="新增二维码" open={createOpen}
|
||||||
open={createOpen}
|
|
||||||
onOpenChange={setCreateOpen}
|
onOpenChange={setCreateOpen}
|
||||||
onFinish={async (values) => {
|
onFinish={async (values) => {
|
||||||
const hide = message.loading('提交中...');
|
const hide = message.loading('提交中...');
|
||||||
@@ -271,8 +275,7 @@ const QrcodeListModal: React.FC<QrcodeListModalProps> = ({ open, onOpenChange, t
|
|||||||
|
|
||||||
{editOpen && (
|
{editOpen && (
|
||||||
<QrcodeTourismForm
|
<QrcodeTourismForm
|
||||||
title="编辑二维码"
|
title="编辑二维码" open={editOpen}
|
||||||
open={editOpen}
|
|
||||||
onOpenChange={setEditOpen}
|
onOpenChange={setEditOpen}
|
||||||
onFinish={async (values) => {
|
onFinish={async (values) => {
|
||||||
const hide = message.loading('提交中...');
|
const hide = message.loading('提交中...');
|
||||||
@@ -296,6 +299,7 @@ const QrcodeListModal: React.FC<QrcodeListModalProps> = ({ open, onOpenChange, t
|
|||||||
hide();
|
hide();
|
||||||
}
|
}
|
||||||
}}
|
}}
|
||||||
|
defaultTourismId={tourismId}
|
||||||
initialValues={current}
|
initialValues={current}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
@@ -310,4 +314,6 @@ const QrcodeListModal: React.FC<QrcodeListModalProps> = ({ open, onOpenChange, t
|
|||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
export default QrcodeListModal;
|
export default QrcodeListModal;
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ export interface QrcodeTourismFormProps {
|
|||||||
const QrcodeTourismForm: React.FC<QrcodeTourismFormProps> = ({ open, title, initialValues, onOpenChange, onFinish, defaultTourismId }) => {
|
const QrcodeTourismForm: React.FC<QrcodeTourismFormProps> = ({ open, title, initialValues, onOpenChange, onFinish, defaultTourismId }) => {
|
||||||
// 统一默认值,解决新增/编辑缺省字段问题
|
// 统一默认值,解决新增/编辑缺省字段问题
|
||||||
const DEFAULTS: Partial<QrcodeItem> = {
|
const DEFAULTS: Partial<QrcodeItem> = {
|
||||||
status: 0, // 状态:0=禁用 1=启用
|
status: 0, // 状态:0=启用1=禁用
|
||||||
enableVideoEdit: 0, // 是否开启一键成片:0=否 1=是
|
enableVideoEdit: 0, // 是否开启一键成片:0=否 1=是
|
||||||
isTest: 0, // 是否测试二维码:0=否 1=是
|
isTest: 0, // 是否测试二维码:0=否 1=是
|
||||||
qrcodeType: 1, // 二维码类型:1=游客扫码 2=临时扫码 3=自定义
|
qrcodeType: 1, // 二维码类型:1=游客扫码 2=临时扫码 3=自定义
|
||||||
@@ -157,7 +157,7 @@ const QrcodeTourismForm: React.FC<QrcodeTourismFormProps> = ({ open, title, init
|
|||||||
|
|
||||||
<ProFormDigit
|
<ProFormDigit
|
||||||
name="price"
|
name="price"
|
||||||
label="价格(元)"
|
label="价格(分)"
|
||||||
min={0}
|
min={0}
|
||||||
rules={[{ required: true, message: '请输入价格' }]}
|
rules={[{ required: true, message: '请输入价格' }]}
|
||||||
fieldProps={{ precision: 0 }}
|
fieldProps={{ precision: 0 }}
|
||||||
@@ -170,8 +170,8 @@ const QrcodeTourismForm: React.FC<QrcodeTourismFormProps> = ({ open, title, init
|
|||||||
label="状态"
|
label="状态"
|
||||||
rules={[{ required: true, message: '请选择状态' }]}
|
rules={[{ required: true, message: '请选择状态' }]}
|
||||||
options={[
|
options={[
|
||||||
{ label: '禁用', value: 0 },
|
{ label: '启用', value: 0 },
|
||||||
{ label: '启用', value: 1 },
|
{ label: '禁用', value: 1 },
|
||||||
]}
|
]}
|
||||||
colProps={{ span: 12 }}
|
colProps={{ span: 12 }}
|
||||||
/>
|
/>
|
||||||
@@ -344,3 +344,4 @@ const QrcodeTourismForm: React.FC<QrcodeTourismFormProps> = ({ open, title, init
|
|||||||
};
|
};
|
||||||
|
|
||||||
export default QrcodeTourismForm;
|
export default QrcodeTourismForm;
|
||||||
|
|
||||||
|
|||||||
@@ -277,17 +277,11 @@ export const ordersApi = {
|
|||||||
const res = await request('/api-order/coupon/update-expired', { method: 'POST' });
|
const res = await request('/api-order/coupon/update-expired', { method: 'POST' });
|
||||||
return (res as any).data || res;
|
return (res as any).data || res;
|
||||||
},
|
},
|
||||||
|
getPackagePlanByCode: async (codeId: string) => {
|
||||||
|
const res = await request('/api-order/package/byCode/' + codeId, { method: 'GET' });
|
||||||
|
const list = ((res as any)?.data ?? (res as any)) as any[];
|
||||||
|
return Array.isArray(list) ? list : [];
|
||||||
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user