feat: 二维码新增或者编辑绑定景区素材
This commit is contained in:
@@ -9,6 +9,7 @@ CREATE TABLE IF NOT EXISTS `packages` (
|
|||||||
`vlog_count` INT DEFAULT 0 COMMENT 'Vlog数量',
|
`vlog_count` INT DEFAULT 0 COMMENT 'Vlog数量',
|
||||||
`video_count` INT DEFAULT 0 COMMENT '视频数量',
|
`video_count` INT DEFAULT 0 COMMENT '视频数量',
|
||||||
`photo_count` INT DEFAULT 0 COMMENT '照片数量',
|
`photo_count` INT DEFAULT 0 COMMENT '照片数量',
|
||||||
|
`tourism_file_ids` VARCHAR(2048) DEFAULT NULL COMMENT '景区素材ID集合(逗号分隔)',
|
||||||
`tenant_id` VARCHAR(64) DEFAULT NULL COMMENT '租户ID',
|
`tenant_id` VARCHAR(64) DEFAULT NULL COMMENT '租户ID',
|
||||||
`company` VARCHAR(128) DEFAULT NULL COMMENT '所属公司',
|
`company` VARCHAR(128) DEFAULT NULL COMMENT '所属公司',
|
||||||
`is_del` TINYINT(1) DEFAULT 0 COMMENT '是否删除 0-否 1-是',
|
`is_del` TINYINT(1) DEFAULT 0 COMMENT '是否删除 0-否 1-是',
|
||||||
|
|||||||
+10
@@ -29,6 +29,8 @@ import java.util.HashMap;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
import java.util.Objects;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* qrcode information
|
* qrcode information
|
||||||
@@ -222,6 +224,14 @@ public class QrCodeController {
|
|||||||
if (vlogCount != null) plan.setVlogCount(vlogCount);
|
if (vlogCount != null) plan.setVlogCount(vlogCount);
|
||||||
if (videoCount != null) plan.setVideoCount(videoCount);
|
if (videoCount != null) plan.setVideoCount(videoCount);
|
||||||
if (photoCount != null) plan.setPhotoCount(photoCount);
|
if (photoCount != null) plan.setPhotoCount(photoCount);
|
||||||
|
// 景区素材ID集合存储到套餐表
|
||||||
|
if (body.getTourismFileIds() != null && !body.getTourismFileIds().isEmpty()) {
|
||||||
|
String idsStr = body.getTourismFileIds().stream()
|
||||||
|
.filter(Objects::nonNull)
|
||||||
|
.map(String::valueOf)
|
||||||
|
.collect(Collectors.joining(","));
|
||||||
|
plan.setTourismFileIds(idsStr);
|
||||||
|
}
|
||||||
packagePlanService.saveOrUpdate(plan);
|
packagePlanService.saveOrUpdate(plan);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+18
@@ -89,4 +89,22 @@ public class TourismFileController {
|
|||||||
return PageResult.<TourismFileGroupVO>builder().data(java.util.Collections.emptyList()).resp_code(1).count(0L).build();
|
return PageResult.<TourismFileGroupVO>builder().data(java.util.Collections.emptyList()).resp_code(1).count(0L).build();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
/**
|
||||||
|
* 按景区ID获取资源列表
|
||||||
|
*/
|
||||||
|
@Operation(summary = "按景区ID获取资源列表")
|
||||||
|
@GetMapping("/byTourism/{tourismId}")
|
||||||
|
public Result listByTourismId(@PathVariable("tourismId") Long tourismId) {
|
||||||
|
java.util.List<TourismFile> list = tourismFileService.getByTourismId(tourismId);
|
||||||
|
if (list != null) {
|
||||||
|
for (TourismFile f : list) {
|
||||||
|
try {
|
||||||
|
if (f != null && f.getImageUrl() != null) {
|
||||||
|
f.setImageUrl(fileCenterService.getViewUrlByPath(f.getImageUrl()));
|
||||||
|
}
|
||||||
|
} catch (Exception ignored) {}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return Result.succeed(list, "操作成功");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -33,6 +33,10 @@ public class PackagePlan extends SuperEntity {
|
|||||||
@Schema(description = "照片数量")
|
@Schema(description = "照片数量")
|
||||||
private Integer photoCount;
|
private Integer photoCount;
|
||||||
|
|
||||||
|
@Schema(description = "景区素材ID集合(逗号分隔)")
|
||||||
|
private String tourismFileIds;
|
||||||
|
|
||||||
|
|
||||||
@Schema(description = "租户ID")
|
@Schema(description = "租户ID")
|
||||||
private String tenantId;
|
private String tenantId;
|
||||||
|
|
||||||
|
|||||||
+5
@@ -4,6 +4,8 @@ import com.central.order.model.QrCode;
|
|||||||
import io.swagger.v3.oas.annotations.media.Schema;
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
@Data
|
@Data
|
||||||
@Schema(description = "二维码与套餐创建/修改请求体")
|
@Schema(description = "二维码与套餐创建/修改请求体")
|
||||||
public class QrcodeWithPlanDTO {
|
public class QrcodeWithPlanDTO {
|
||||||
@@ -18,5 +20,8 @@ public class QrcodeWithPlanDTO {
|
|||||||
|
|
||||||
@Schema(description = "照片数量")
|
@Schema(description = "照片数量")
|
||||||
private Integer photoCount;
|
private Integer photoCount;
|
||||||
|
|
||||||
|
@Schema(description = "景区素材ID集合(ID 数组)")
|
||||||
|
private List<Long> tourismFileIds;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -22,7 +22,6 @@ export default [
|
|||||||
routes: [
|
routes: [
|
||||||
{ path: '/orders/order.html', component: '@/pages/orders/Order' },
|
{ path: '/orders/order.html', component: '@/pages/orders/Order' },
|
||||||
{ path: '/orders/orderFiles.html', component: '@/pages/orders/OrderFile' },
|
{ path: '/orders/orderFiles.html', component: '@/pages/orders/OrderFile' },
|
||||||
{ path: '/orders/qrcode.html', component: '@/pages/orders/Qrcode' },
|
|
||||||
{ path: '/orders/tourism.html', component: '@/pages/orders/Tourism' },
|
{ path: '/orders/tourism.html', component: '@/pages/orders/Tourism' },
|
||||||
{ path: '/orders/tourismFile.html', component: '@/pages/orders/TourismFile' },
|
{ path: '/orders/tourismFile.html', component: '@/pages/orders/TourismFile' },
|
||||||
{ path: '/orders/homeCarousel.html', component: '@/pages/orders/HomeCarousel' },
|
{ path: '/orders/homeCarousel.html', component: '@/pages/orders/HomeCarousel' },
|
||||||
|
|||||||
@@ -1,101 +0,0 @@
|
|||||||
import React, { useState } from 'react';
|
|
||||||
import { PageContainer, ProTable } 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';
|
|
||||||
import { ordersApi } from '@/services/orders';
|
|
||||||
import QrcodeForm, { QrcodeItem } from './components/QrcodeForm';
|
|
||||||
|
|
||||||
const QrcodePage: React.FC = () => {
|
|
||||||
const [createOpen, setCreateOpen] = useState(false);
|
|
||||||
const [editOpen, setEditOpen] = useState(false);
|
|
||||||
const [current, setCurrent] = useState<QrcodeItem | undefined>(undefined);
|
|
||||||
const [params, setParams] = useState<Record<string, any>>({});
|
|
||||||
|
|
||||||
const columns: any[] = [
|
|
||||||
{ dataIndex: 'index', valueType: 'indexBorder', width: 48 },
|
|
||||||
{ title: '名称', dataIndex: 'name' },
|
|
||||||
{ title: '链接', dataIndex: 'url', ellipsis: true },
|
|
||||||
{ title: '类型', dataIndex: 'type' },
|
|
||||||
{ title: '状态', dataIndex: 'status', render: (v: number) => <Tag color={v === 1 ? 'green' : 'default'}>{v === 1 ? '启用' : '禁用'}</Tag> },
|
|
||||||
{
|
|
||||||
title: '操作', key: 'action',
|
|
||||||
render: (_: any, record: QrcodeItem) => (
|
|
||||||
<Space>
|
|
||||||
<a onClick={() => { setCurrent(record); setEditOpen(true); }}>编辑</a>
|
|
||||||
<Popconfirm title={`确认删除二维码[${record.name}]?`} onConfirm={async () => {
|
|
||||||
const hide = message.loading('删除中...');
|
|
||||||
try {
|
|
||||||
await ordersApi.deleteQrcode(record.id!);
|
|
||||||
message.success('删除成功');
|
|
||||||
} catch (e) {
|
|
||||||
message.error('删除失败');
|
|
||||||
} finally { hide(); }
|
|
||||||
}}>
|
|
||||||
<a style={{ color: '#1677ff' }}>删除</a>
|
|
||||||
</Popconfirm>
|
|
||||||
</Space>
|
|
||||||
)
|
|
||||||
},
|
|
||||||
];
|
|
||||||
|
|
||||||
return (
|
|
||||||
<PageContainer header={{ title: '二维码管理' }}>
|
|
||||||
<SearchBarPlus
|
|
||||||
defaultCollapsed
|
|
||||||
split
|
|
||||||
span={8}
|
|
||||||
onTenantChanged={() => { /* 仅触发表格刷新 */ }}
|
|
||||||
onFinish={async (values) => setParams(values)}
|
|
||||||
/>
|
|
||||||
<ActionBar left={<GradientButton size="middle" type="primary" icon={<PlusOutlined />} onClick={() => setCreateOpen(true)}>新增</GradientButton>} />
|
|
||||||
<GlassCard>
|
|
||||||
<ProTable<QrcodeItem>
|
|
||||||
rowKey="id"
|
|
||||||
request={(p) => ordersApi.qrcodeList({ ...(p as any), ...params })}
|
|
||||||
columns={columns}
|
|
||||||
search={false}
|
|
||||||
pagination={{ showSizeChanger: true, showQuickJumper: true }}
|
|
||||||
/>
|
|
||||||
</GlassCard>
|
|
||||||
|
|
||||||
<QrcodeForm
|
|
||||||
title="新增二维码"
|
|
||||||
open={createOpen}
|
|
||||||
onOpenChange={setCreateOpen}
|
|
||||||
onFinish={async (values) => {
|
|
||||||
const hide = message.loading('保存中...');
|
|
||||||
try {
|
|
||||||
await ordersApi.saveOrUpdateQrcode(values);
|
|
||||||
message.success('新增成功');
|
|
||||||
return true;
|
|
||||||
} catch (e) {
|
|
||||||
message.error('保存失败');
|
|
||||||
return false;
|
|
||||||
} finally { hide(); }
|
|
||||||
}}
|
|
||||||
/>
|
|
||||||
|
|
||||||
<QrcodeForm
|
|
||||||
title="编辑二维码"
|
|
||||||
open={editOpen}
|
|
||||||
initialValues={current}
|
|
||||||
onOpenChange={setEditOpen}
|
|
||||||
onFinish={async (values) => {
|
|
||||||
const hide = message.loading('保存中...');
|
|
||||||
try {
|
|
||||||
await ordersApi.saveOrUpdateQrcode({ ...(current as any), ...values });
|
|
||||||
message.success('修改成功');
|
|
||||||
return true;
|
|
||||||
} catch (e) {
|
|
||||||
message.error('修改失败');
|
|
||||||
return false;
|
|
||||||
} finally { hide(); }
|
|
||||||
}}
|
|
||||||
/>
|
|
||||||
</PageContainer>
|
|
||||||
);
|
|
||||||
};
|
|
||||||
|
|
||||||
export default QrcodePage;
|
|
||||||
|
|
||||||
+4
-3
@@ -28,9 +28,9 @@ export interface QrcodeItem {
|
|||||||
vlogCount?: number;
|
vlogCount?: number;
|
||||||
videoCount?: number;
|
videoCount?: number;
|
||||||
photoCount?: number;
|
photoCount?: number;
|
||||||
|
tourismFileIds?: number[];
|
||||||
}
|
}
|
||||||
|
export interface QrcodeFormProps {
|
||||||
export interface QrcodeFormProps {
|
|
||||||
open: boolean;
|
open: boolean;
|
||||||
title: string;
|
title: string;
|
||||||
initialValues?: Partial<QrcodeItem>;
|
initialValues?: Partial<QrcodeItem>;
|
||||||
@@ -56,4 +56,5 @@ const QrcodeForm: React.FC<QrcodeFormProps> = ({ open, title, initialValues, onO
|
|||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
export default QrcodeForm;
|
export default QrcodeItem;
|
||||||
|
|
||||||
@@ -4,7 +4,7 @@ import { ProTable, type ActionType } from '@ant-design/pro-components';
|
|||||||
import { GradientButton } from '@/components/ui';
|
import { GradientButton } from '@/components/ui';
|
||||||
import { PlusOutlined, CopyOutlined } from '@ant-design/icons';
|
import { PlusOutlined, CopyOutlined } from '@ant-design/icons';
|
||||||
import { ordersApi } from '@/services/orders';
|
import { ordersApi } from '@/services/orders';
|
||||||
import { QrcodeItem } from '../../Qrcode/components/QrcodeForm';
|
import { QrcodeItem } from './QrcodeItem';
|
||||||
import QrcodeTourismForm from './QrcodeTourismForm';
|
import QrcodeTourismForm from './QrcodeTourismForm';
|
||||||
|
|
||||||
export interface QrcodeListModalProps {
|
export interface QrcodeListModalProps {
|
||||||
@@ -22,7 +22,7 @@ const QrcodeListModal: React.FC<QrcodeListModalProps> = ({ open, onOpenChange, t
|
|||||||
const [previewOpen, setPreviewOpen] = useState(false);
|
const [previewOpen, setPreviewOpen] = useState(false);
|
||||||
const [previewImage, setPreviewImage] = useState<string>('');
|
const [previewImage, setPreviewImage] = useState<string>('');
|
||||||
|
|
||||||
// 模板ID(templateId 字符串) -> 模板名称(通过接口懒加载)
|
// 模板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); // 用于触发渲染
|
||||||
@@ -143,7 +143,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 === 0 ? 'green' : 'red'}>{v === 0 ? '启用' : '未启用'}</Tag>,
|
render: (v: number) => <Tag color={v === 1 ? 'green' : 'red'}>{v === 1 ? '启用' : '禁用'}</Tag>,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: '模板名称',
|
title: '模板名称',
|
||||||
@@ -155,7 +155,7 @@ const QrcodeListModal: React.FC<QrcodeListModalProps> = ({ open, onOpenChange, t
|
|||||||
title: '一键成片',
|
title: '一键成片',
|
||||||
dataIndex: 'enableVideoEdit',
|
dataIndex: 'enableVideoEdit',
|
||||||
width: 100,
|
width: 100,
|
||||||
render: (v: number) => <Tag color={v === 1 ? 'green' : 'red'}>{v === 1 ? '开启' : '否'}</Tag>,
|
render: (v: number) => <Tag color={v === 1 ? 'green' : 'red'}>{v === 1 ? '是' : '否'}</Tag>,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: '测试二维码',
|
title: '测试二维码',
|
||||||
@@ -168,13 +168,13 @@ const QrcodeListModal: React.FC<QrcodeListModalProps> = ({ open, onOpenChange, t
|
|||||||
dataIndex: 'qrcodeType',
|
dataIndex: 'qrcodeType',
|
||||||
width: 120,
|
width: 120,
|
||||||
render: (v: number) => {
|
render: (v: number) => {
|
||||||
if (v === 1) return <Tag color="blue">游客下单</Tag>;
|
if (v === 1) return <Tag color="blue">游客扫码</Tag>;
|
||||||
if (v === 2) return <Tag color="green">定时巡查</Tag>;
|
if (v === 2) return <Tag color="green">临时扫码</Tag>;
|
||||||
return <Tag color="#000000">其他</Tag>;
|
return <Tag color="#000000">自定义</Tag>;
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: '仅显一键成片',
|
title: '仅显示一键成片',
|
||||||
dataIndex: 'showVideoEditOnly',
|
dataIndex: 'showVideoEditOnly',
|
||||||
width: 130,
|
width: 130,
|
||||||
render: (v: number) => <Tag color={v === 1 ? 'green' : 'red'}>{v === 1 ? '是' : '否'}</Tag>,
|
render: (v: number) => <Tag color={v === 1 ? 'green' : 'red'}>{v === 1 ? '是' : '否'}</Tag>,
|
||||||
@@ -238,38 +238,23 @@ const QrcodeListModal: React.FC<QrcodeListModalProps> = ({ open, onOpenChange, t
|
|||||||
/>
|
/>
|
||||||
</Modal>
|
</Modal>
|
||||||
|
|
||||||
{/* 新增二维码 */}
|
{/* 新增/编辑表单:仅在打开时才挂载,避免列表页触发内部副作用 */}
|
||||||
|
{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('提交中...');
|
||||||
try {
|
try {
|
||||||
await ordersApi.saveOrUpdateQrcode({ ...values, tourismId });
|
const { vlogCount, videoCount, photoCount, tourismFileIds, ...qrRest } = values as any;
|
||||||
message.success('新增成功');
|
await ordersApi.saveOrUpdateQrcodePlan({
|
||||||
actionRef.current?.reload();
|
qrCode: { ...qrRest, tourismId },
|
||||||
return true;
|
vlogCount,
|
||||||
} catch (e) {
|
videoCount,
|
||||||
message.error('保存失败');
|
photoCount,
|
||||||
return false;
|
tourismFileIds,
|
||||||
} finally {
|
});
|
||||||
hide();
|
|
||||||
}
|
|
||||||
}}
|
|
||||||
defaultTourismId={tourismId}
|
|
||||||
/>
|
|
||||||
|
|
||||||
{/* 编辑二维码 */}
|
|
||||||
<QrcodeTourismForm
|
|
||||||
title="编辑二维码"
|
|
||||||
open={editOpen}
|
|
||||||
initialValues={current}
|
|
||||||
onOpenChange={setEditOpen}
|
|
||||||
onFinish={async (values) => {
|
|
||||||
const hide = message.loading('保存中...');
|
|
||||||
try {
|
|
||||||
await ordersApi.saveOrUpdateQrcode({ ...(current as any), ...values });
|
|
||||||
message.success('修改成功');
|
message.success('修改成功');
|
||||||
actionRef.current?.reload();
|
actionRef.current?.reload();
|
||||||
return true;
|
return true;
|
||||||
@@ -280,7 +265,40 @@ const QrcodeListModal: React.FC<QrcodeListModalProps> = ({ open, onOpenChange, t
|
|||||||
hide();
|
hide();
|
||||||
}
|
}
|
||||||
}}
|
}}
|
||||||
|
defaultTourismId={tourismId}
|
||||||
/>
|
/>
|
||||||
|
)}
|
||||||
|
|
||||||
|
{editOpen && (
|
||||||
|
<QrcodeTourismForm
|
||||||
|
title="编辑二维码"
|
||||||
|
open={editOpen}
|
||||||
|
onOpenChange={setEditOpen}
|
||||||
|
onFinish={async (values) => {
|
||||||
|
const hide = message.loading('提交中...');
|
||||||
|
try {
|
||||||
|
const merged: any = { ...(current as any), ...values };
|
||||||
|
const { vlogCount, videoCount, photoCount, tourismFileIds, ...qrRest } = merged;
|
||||||
|
await ordersApi.saveOrUpdateQrcodePlan({
|
||||||
|
qrCode: qrRest,
|
||||||
|
vlogCount,
|
||||||
|
videoCount,
|
||||||
|
photoCount,
|
||||||
|
tourismFileIds,
|
||||||
|
});
|
||||||
|
message.success('修改成功');
|
||||||
|
actionRef.current?.reload();
|
||||||
|
return true;
|
||||||
|
} catch (e) {
|
||||||
|
message.error('修改失败');
|
||||||
|
return false;
|
||||||
|
} finally {
|
||||||
|
hide();
|
||||||
|
}
|
||||||
|
}}
|
||||||
|
initialValues={current}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
|
|
||||||
{/* 二维码预览 */}
|
{/* 二维码预览 */}
|
||||||
<Modal title="二维码预览" open={previewOpen} onCancel={() => setPreviewOpen(false)} footer={null} width={600} centered destroyOnClose>
|
<Modal title="二维码预览" open={previewOpen} onCancel={() => setPreviewOpen(false)} footer={null} width={600} centered destroyOnClose>
|
||||||
@@ -293,4 +311,3 @@ const QrcodeListModal: React.FC<QrcodeListModalProps> = ({ open, onOpenChange, t
|
|||||||
};
|
};
|
||||||
|
|
||||||
export default QrcodeListModal;
|
export default QrcodeListModal;
|
||||||
|
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
import React from 'react';
|
import React, { useEffect, useState } from 'react';
|
||||||
import { ModalForm, ProFormDigit, ProFormSelect, ProFormText } from '@ant-design/pro-components';
|
import { ModalForm, ProForm, ProFormDigit, ProFormSelect, ProFormText } from '@ant-design/pro-components';
|
||||||
import { ordersApi } from '@/services/orders';
|
import { ordersApi } from '@/services/orders';
|
||||||
import { deviceApi } from '@/services/device';
|
import { deviceApi } from '@/services/device';
|
||||||
import { miniAppApi } from '@/services/miniapp';
|
import { miniAppApi } from '@/services/miniapp';
|
||||||
import type { QrcodeItem } from '../../Qrcode/components/QrcodeForm';
|
import type { QrcodeItem } from './QrcodeItem';
|
||||||
|
|
||||||
export interface QrcodeTourismFormProps {
|
export interface QrcodeTourismFormProps {
|
||||||
open: boolean;
|
open: boolean;
|
||||||
@@ -15,13 +15,13 @@ 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=自定义
|
||||||
showVideoEditOnly: 0, // 只显示一键成片:否=0,是=1(默认:否)
|
showVideoEditOnly: 0, // 是否仅显示一键成片:0=否 1=是
|
||||||
materialCount: 1,
|
materialCount: 1,
|
||||||
vlogCount: 0,
|
vlogCount: 0,
|
||||||
videoCount: 0,
|
videoCount: 0,
|
||||||
@@ -30,9 +30,36 @@ const QrcodeTourismForm: React.FC<QrcodeTourismFormProps> = ({ open, title, init
|
|||||||
|
|
||||||
// 过滤 initialValues 中的 undefined,避免覆盖默认值
|
// 过滤 initialValues 中的 undefined,避免覆盖默认值
|
||||||
const sanitizedInitial: Partial<QrcodeItem> = initialValues
|
const sanitizedInitial: Partial<QrcodeItem> = initialValues
|
||||||
? Object.fromEntries(Object.entries(initialValues).filter(([, v]) => v !== undefined))
|
? (Object.fromEntries(Object.entries(initialValues).filter(([, v]) => v !== undefined)) as any)
|
||||||
: {};
|
: {};
|
||||||
|
|
||||||
|
// 景区ID,用于素材查询
|
||||||
|
const tourismIdForFetch = (sanitizedInitial as any)?.tourismId ?? defaultTourismId;
|
||||||
|
|
||||||
|
// 景区素材
|
||||||
|
const [tourismFiles, setTourismFiles] = useState<any[]>([]);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
// 仅在弹窗打开时才加载景区素材,避免在列表页无意义调用接口
|
||||||
|
if (!open) return;
|
||||||
|
if (!tourismIdForFetch) {
|
||||||
|
setTourismFiles([]);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
let canceled = false;
|
||||||
|
(async () => {
|
||||||
|
try {
|
||||||
|
const { data = [] } = await ordersApi.tourismFileByTourism(tourismIdForFetch as any);
|
||||||
|
if (!canceled) setTourismFiles(Array.isArray(data) ? data : []);
|
||||||
|
} catch {
|
||||||
|
if (!canceled) setTourismFiles([]);
|
||||||
|
}
|
||||||
|
})();
|
||||||
|
return () => {
|
||||||
|
canceled = true;
|
||||||
|
};
|
||||||
|
}, [open, tourismIdForFetch]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<ModalForm<QrcodeItem>
|
<ModalForm<QrcodeItem>
|
||||||
title={title}
|
title={title}
|
||||||
@@ -64,25 +91,30 @@ const QrcodeTourismForm: React.FC<QrcodeTourismFormProps> = ({ open, title, init
|
|||||||
labelWrap
|
labelWrap
|
||||||
colProps={{ span: 12 }}
|
colProps={{ span: 12 }}
|
||||||
>
|
>
|
||||||
{/* 收款商户(必填,置顶显示) */}
|
{/* 小程序商户(仅显示支持支付的类型) */}
|
||||||
<ProFormSelect
|
<ProFormSelect
|
||||||
name="tenantId"
|
name="tenantId"
|
||||||
label="收款商户"
|
label="小程序商户"
|
||||||
showSearch
|
showSearch
|
||||||
rules={[{ required: true, message: '请选择收款商户' }]}
|
rules={[{ required: true, message: '请选择小程序商户' }]}
|
||||||
placeholder="请选择收款商户"
|
placeholder="请选择小程序商户"
|
||||||
request={async () => {
|
request={async () => {
|
||||||
// 后端筛选不生效时,前端兜底过滤 type=PAY
|
// 只取 type=PAY 的商户
|
||||||
const { data = [] } = await miniAppApi.list({ page: 1, limit: 1000 });
|
const { data = [] } = await miniAppApi.list({ page: 1, limit: 1000 });
|
||||||
const filtered = (data || []).filter((m: any) => String(m?.type || '').toUpperCase() === 'PAY');
|
const filtered = (data || []).filter((m: any) => String(m?.type || '').toUpperCase() === 'PAY');
|
||||||
// 名称显示 subMchName(若无则回退到 tenantId)
|
|
||||||
return filtered.map((m: any) => ({ label: m.subMchName || m.tenantId, value: m.tenantId }));
|
return filtered.map((m: any) => ({ label: m.subMchName || m.tenantId, value: m.tenantId }));
|
||||||
}}
|
}}
|
||||||
colProps={{ span: 12 }}
|
colProps={{ span: 12 }}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
{/* 基础信息 */}
|
{/* 基本信息 */}
|
||||||
<ProFormText name="name" label="名称" rules={[{ required: true, message: '请输入二维码名称' }]} placeholder="请输入二维码名称" colProps={{ span: 12 }} />
|
<ProFormText
|
||||||
|
name="name"
|
||||||
|
label="名称"
|
||||||
|
rules={[{ required: true, message: '请输入二维码名称' }]}
|
||||||
|
placeholder="请输入二维码名称"
|
||||||
|
colProps={{ span: 12 }}
|
||||||
|
/>
|
||||||
|
|
||||||
<ProFormSelect
|
<ProFormSelect
|
||||||
name="waylineId"
|
name="waylineId"
|
||||||
@@ -114,11 +146,11 @@ 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 }}
|
||||||
placeholder="请输入价格(分)"
|
placeholder="请输入价格"
|
||||||
colProps={{ span: 12 }}
|
colProps={{ span: 12 }}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
@@ -127,42 +159,36 @@ 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 }}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
|
{/* 视频模板(可选) */}
|
||||||
<ProFormSelect
|
<ProFormSelect
|
||||||
name="templateId"
|
name="templateId"
|
||||||
label="视频模板"
|
label="视频模板"
|
||||||
showSearch
|
showSearch
|
||||||
rules={[{ required: true, message: '请选择视频模板' }]}
|
allowClear
|
||||||
placeholder="请选择视频模板"
|
placeholder="请选择视频模板"
|
||||||
request={async () => {
|
request={async () => {
|
||||||
const { data = [] } = await ordersApi.getVideoTemplateList({ current: 1, pageSize: 1000 });
|
try {
|
||||||
return (data || []).map((t: any) => ({
|
const api: any = ordersApi as any;
|
||||||
label: t?.templateName || t?.name || t?.templateId || String(t?.id ?? ''),
|
const resp = api.getVideoTemplateList ? await api.getVideoTemplateList({ current: 1, pageSize: 1000 }) : { data: [] };
|
||||||
value: String(t?.templateId ?? t?.id ?? ''),
|
const { data = [] } = (resp || {}) as any;
|
||||||
}));
|
return (data || []).map((t: any) => ({ label: t?.templateName || t?.name || String(t?.templateId ?? t?.id), value: String(t?.templateId ?? t?.id) }));
|
||||||
|
} catch {
|
||||||
|
return [];
|
||||||
|
}
|
||||||
}}
|
}}
|
||||||
colProps={{ span: 12 }}
|
colProps={{ span: 12 }}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<ProFormDigit
|
{/* 功能开关 */}
|
||||||
name="materialCount"
|
|
||||||
label="素材数量"
|
|
||||||
min={1}
|
|
||||||
rules={[{ required: true, message: '请输入素材数量' }]}
|
|
||||||
fieldProps={{ precision: 0 }}
|
|
||||||
placeholder="请输入素材数量"
|
|
||||||
colProps={{ span: 12 }}
|
|
||||||
/>
|
|
||||||
|
|
||||||
{/* 其他设置 */}
|
|
||||||
<ProFormSelect
|
<ProFormSelect
|
||||||
name="enableVideoEdit"
|
name="enableVideoEdit"
|
||||||
label="开启一键成片"
|
label="一键成片"
|
||||||
options={[
|
options={[
|
||||||
{ label: '否', value: 0 },
|
{ label: '否', value: 0 },
|
||||||
{ label: '是', value: 1 },
|
{ label: '是', value: 1 },
|
||||||
@@ -182,15 +208,15 @@ const QrcodeTourismForm: React.FC<QrcodeTourismFormProps> = ({ open, title, init
|
|||||||
name="qrcodeType"
|
name="qrcodeType"
|
||||||
label="二维码类型"
|
label="二维码类型"
|
||||||
options={[
|
options={[
|
||||||
{ label: '游客下单', value: 1 },
|
{ label: '游客扫码', value: 1 },
|
||||||
{ label: '定时巡查', value: 2 },
|
{ label: '临时扫码', value: 2 },
|
||||||
{ label: '其他', value: 3 },
|
{ label: '自定义', value: 3 },
|
||||||
]}
|
]}
|
||||||
colProps={{ span: 12 }}
|
colProps={{ span: 12 }}
|
||||||
/>
|
/>
|
||||||
<ProFormSelect
|
<ProFormSelect
|
||||||
name="showVideoEditOnly"
|
name="showVideoEditOnly"
|
||||||
label="只显示一键成片"
|
label="仅显示一键成片"
|
||||||
options={[
|
options={[
|
||||||
{ label: '否', value: 0 },
|
{ label: '否', value: 0 },
|
||||||
{ label: '是', value: 1 },
|
{ label: '是', value: 1 },
|
||||||
@@ -198,10 +224,112 @@ const QrcodeTourismForm: React.FC<QrcodeTourismFormProps> = ({ open, title, init
|
|||||||
colProps={{ span: 12 }}
|
colProps={{ span: 12 }}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
{/* 数量统计 */}
|
{/* 统计项 */}
|
||||||
<ProFormDigit name="vlogCount" label="Vlog数量" min={0} fieldProps={{ precision: 0 }} colProps={{ span: 12 }} />
|
<ProFormDigit name="vlogCount" label="Vlog数量" min={0} fieldProps={{ precision: 0 }} colProps={{ span: 12 }} />
|
||||||
<ProFormDigit name="videoCount" label="视频数量" min={0} fieldProps={{ precision: 0 }} colProps={{ span: 12 }} />
|
<ProFormDigit name="videoCount" label="视频数量" min={0} fieldProps={{ precision: 0 }} colProps={{ span: 12 }} />
|
||||||
<ProFormDigit name="photoCount" label="照片数量" min={0} fieldProps={{ precision: 0 }} colProps={{ span: 12 }} />
|
<ProFormDigit name="photoCount" label="图片数量" min={0} fieldProps={{ precision: 0 }} colProps={{ span: 12 }} />
|
||||||
|
|
||||||
|
<ProFormDigit
|
||||||
|
name="materialCount"
|
||||||
|
label="素材数量"
|
||||||
|
min={1}
|
||||||
|
rules={[{ required: true, message: '请输入素材数量' }]}
|
||||||
|
fieldProps={{ precision: 0 }}
|
||||||
|
placeholder="请输入素材数量"
|
||||||
|
colProps={{ span: 12 }}
|
||||||
|
/>
|
||||||
|
|
||||||
|
{/* 注册一个隐藏字段以提交素材ID数组 */}
|
||||||
|
<ProForm.Item name="tourismFileIds" hidden>
|
||||||
|
<div />
|
||||||
|
</ProForm.Item>
|
||||||
|
|
||||||
|
{/* 景区素材(移除查询条件;支持多选;无上限;保留“全部选择/取消全选”) */}
|
||||||
|
<ProForm.Item label="景区素材" shouldUpdate>
|
||||||
|
{({ getFieldValue, setFieldsValue }) => {
|
||||||
|
const selected: number[] = getFieldValue('tourismFileIds') || [];
|
||||||
|
const typeName = (t: any) => (t === 2 ? '视频' : t === 1 ? '图片' : '其他');
|
||||||
|
if (!tourismIdForFetch) {
|
||||||
|
return <div style={{ color: '#999' }}>请选择景区后加载素材</div>;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 不再提供筛选与上限;全量展示可选择
|
||||||
|
const list = tourismFiles || [];
|
||||||
|
|
||||||
|
const onToggle = (id: number) => {
|
||||||
|
const exists = selected.includes(id);
|
||||||
|
setFieldsValue?.({ tourismFileIds: exists ? selected.filter((x) => x !== id) : [...selected, id] });
|
||||||
|
};
|
||||||
|
|
||||||
|
const selectAll = () => {
|
||||||
|
const ids = (list.map((f: any) => f?.id).filter(Boolean) as number[]);
|
||||||
|
const next = Array.from(new Set(ids));
|
||||||
|
setFieldsValue?.({ tourismFileIds: next });
|
||||||
|
};
|
||||||
|
|
||||||
|
const clearAll = () => setFieldsValue?.({ tourismFileIds: [] });
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div>
|
||||||
|
{/* 仅保留“全部选择 / 取消全选” */}
|
||||||
|
<div style={{ display: 'flex', gap: 12, alignItems: 'center', marginBottom: 8 }}>
|
||||||
|
<div style={{ flex: 1 }} />
|
||||||
|
<button type="button" onClick={selectAll} style={{ padding: '4px 10px', border: '1px solid #1677ff', background: '#1677ff', color: '#fff', borderRadius: 4, cursor: 'pointer' }}>全部选择</button>
|
||||||
|
<button type="button" onClick={clearAll} style={{ padding: '4px 10px', border: '1px solid #d9d9d9', background: '#fff', color: '#333', borderRadius: 4, cursor: 'pointer' }}>取消全选</button>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{/* 统计信息 */}
|
||||||
|
<div style={{ marginBottom: 8, fontSize: 12, color: '#666' }}>
|
||||||
|
已选 {selected.length} 个;共 {list.length} 个
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{/* 网格容器:自适应列 + 滚动 */}
|
||||||
|
<div style={{ maxHeight: 420, overflow: 'auto', padding: 8, background: '#fafafa', border: '1px solid #f0f0f0', borderRadius: 6 }}>
|
||||||
|
<div style={{ display: 'grid', gridTemplateColumns: 'repeat(auto-fill, minmax(140px, 1fr))', gap: 12 }}>
|
||||||
|
{list.map((f: any) => {
|
||||||
|
const id = f?.id;
|
||||||
|
const url = f?.imageUrl || f?.linkUrl || f?.url;
|
||||||
|
const isSel = selected.includes(id);
|
||||||
|
return (
|
||||||
|
<div
|
||||||
|
key={id}
|
||||||
|
onClick={() => onToggle(id)}
|
||||||
|
style={{
|
||||||
|
borderWidth: 2,
|
||||||
|
borderStyle: 'solid',
|
||||||
|
borderColor: isSel ? '#1677ff' : '#f0f0f0',
|
||||||
|
borderRadius: 6,
|
||||||
|
cursor: 'pointer',
|
||||||
|
background: '#fff',
|
||||||
|
boxShadow: isSel ? '0 0 0 2px rgba(22,119,255,0.1) inset' : 'none',
|
||||||
|
overflow: 'hidden',
|
||||||
|
display: 'flex',
|
||||||
|
flexDirection: 'column',
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<div style={{ position: 'relative', width: '100%', aspectRatio: '4 / 3', background: '#fafafa', display: 'flex', alignItems: 'center', justifyContent: 'center' }}>
|
||||||
|
{url ? (
|
||||||
|
<img src={url} alt={'素材-' + id} style={{ width: '100%', height: '100%', objectFit: 'cover' }} />
|
||||||
|
) : (
|
||||||
|
<div style={{ fontSize: 12, color: '#999' }}>无图片</div>
|
||||||
|
)}
|
||||||
|
{isSel ? (
|
||||||
|
<div style={{ position: 'absolute', top: 6, right: 6, width: 18, height: 18, borderRadius: '50%', background: '#1677ff' }} />
|
||||||
|
) : null}
|
||||||
|
</div>
|
||||||
|
<div style={{ padding: '6px 8px', fontSize: 12, color: '#555', display: 'flex', justifyContent: 'space-between' }}>
|
||||||
|
<span>ID:{id}</span>
|
||||||
|
<span style={{ color: '#888' }}>{typeName(f?.type)}</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
})}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}}
|
||||||
|
</ProForm.Item>
|
||||||
</ModalForm>
|
</ModalForm>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -52,6 +52,10 @@ export const ordersApi = {
|
|||||||
saveOrUpdateQrcode: async (data: any) => {
|
saveOrUpdateQrcode: async (data: any) => {
|
||||||
const res = await request('/api-order/qrcode', { method: 'POST', data });
|
const res = await request('/api-order/qrcode', { method: 'POST', data });
|
||||||
return (res as any).data || res;
|
return (res as any).data || res;
|
||||||
|
},
|
||||||
|
saveOrUpdateQrcodePlan: async (payload: { qrCode: any; vlogCount?: number; videoCount?: number; photoCount?: number; tourismFileIds?: number[] }) => {
|
||||||
|
const res = await request('/api-order/qrcode/withPlan', { method: 'POST', data: payload });
|
||||||
|
return (res as any).data || res;
|
||||||
},
|
},
|
||||||
deleteQrcode: async (id: number) => {
|
deleteQrcode: async (id: number) => {
|
||||||
const res = await request(`/api-order/qrcode/${id}`, { method: 'DELETE' });
|
const res = await request(`/api-order/qrcode/${id}`, { method: 'DELETE' });
|
||||||
@@ -108,6 +112,11 @@ export const ordersApi = {
|
|||||||
deleteTourismFile: async (id: number) => {
|
deleteTourismFile: async (id: number) => {
|
||||||
const res = await request(`/api-order/tourism/files/${id}`, { method: 'DELETE' });
|
const res = await request(`/api-order/tourism/files/${id}`, { method: 'DELETE' });
|
||||||
return (res as any).data || res;
|
return (res as any).data || res;
|
||||||
|
}, // 按景区ID获取资源列表(非分页)
|
||||||
|
tourismFileByTourism: async (tourismId: number) => {
|
||||||
|
const res = await request('/api-order/tourism/files/byTourism/' + tourismId, { method: 'GET' });
|
||||||
|
const list = (res as any)?.data ?? [];
|
||||||
|
return { data: Array.isArray(list) ? list : [], total: Array.isArray(list) ? list.length : 0 } as { data: any[]; total: number };
|
||||||
},
|
},
|
||||||
|
|
||||||
// 退款
|
// 退款
|
||||||
@@ -270,3 +279,15 @@ export const ordersApi = {
|
|||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user