feat: 二维码新增或者编辑绑定景区素材
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import React, { useEffect, useState } from 'react';
|
||||
import React, { useEffect, useState } from 'react';
|
||||
import { ModalForm, ProForm, ProFormDigit, ProFormSelect, ProFormText } from '@ant-design/pro-components';
|
||||
import { ordersApi } from '@/services/orders';
|
||||
import { deviceApi } from '@/services/device';
|
||||
@@ -15,9 +15,9 @@ export interface QrcodeTourismFormProps {
|
||||
}
|
||||
|
||||
const QrcodeTourismForm: React.FC<QrcodeTourismFormProps> = ({ open, title, initialValues, onOpenChange, onFinish, defaultTourismId }) => {
|
||||
// 统一默认值,解决新增/编辑缺省字段的问题
|
||||
// 统一默认值,解决新增/编辑缺省字段问题
|
||||
const DEFAULTS: Partial<QrcodeItem> = {
|
||||
status: 0, // 状态:0=禁用,1=启用
|
||||
status: 0, // 状态:0=禁用 1=启用
|
||||
enableVideoEdit: 0, // 是否开启一键成片:0=否 1=是
|
||||
isTest: 0, // 是否测试二维码:0=否 1=是
|
||||
qrcodeType: 1, // 二维码类型:1=游客扫码 2=临时扫码 3=自定义
|
||||
@@ -60,6 +60,17 @@ const QrcodeTourismForm: React.FC<QrcodeTourismFormProps> = ({ open, title, init
|
||||
};
|
||||
}, [open, tourismIdForFetch]);
|
||||
|
||||
// 景区素材类型字典(按业务提供)
|
||||
const TYPE_LABEL: Record<number, string> = {
|
||||
5: '视频',
|
||||
6: '首页 Banner',
|
||||
4: '展示图片',
|
||||
3: '景区详情',
|
||||
2: '景区小图展示',
|
||||
1: '活动',
|
||||
};
|
||||
const typeName = (t: any) => TYPE_LABEL[Number(t)] || '其他';
|
||||
|
||||
return (
|
||||
<ModalForm<QrcodeItem>
|
||||
title={title}
|
||||
@@ -91,7 +102,7 @@ const QrcodeTourismForm: React.FC<QrcodeTourismFormProps> = ({ open, title, init
|
||||
labelWrap
|
||||
colProps={{ span: 12 }}
|
||||
>
|
||||
{/* 小程序商户(仅显示支持支付的类型) */}
|
||||
{/* 小程序商户(仅显示支持支付的类型)*/}
|
||||
<ProFormSelect
|
||||
name="tenantId"
|
||||
label="小程序商户"
|
||||
@@ -224,7 +235,7 @@ const QrcodeTourismForm: React.FC<QrcodeTourismFormProps> = ({ open, title, init
|
||||
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="photoCount" label="图片数量" min={0} fieldProps={{ precision: 0 }} colProps={{ span: 12 }} />
|
||||
@@ -244,11 +255,10 @@ const QrcodeTourismForm: React.FC<QrcodeTourismFormProps> = ({ open, title, init
|
||||
<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>;
|
||||
}
|
||||
@@ -271,16 +281,15 @@ const QrcodeTourismForm: React.FC<QrcodeTourismFormProps> = ({ open, title, init
|
||||
|
||||
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>
|
||||
<button type="button" onClick={selectAll} style={{ padding: '4px 10px', border: '1px solid #52c41a', background: '#52c41a', color: '#fff', borderRadius: 4, cursor: 'pointer' }}>全部选择</button>
|
||||
<button type="button" onClick={clearAll} style={{ padding: '4px 10px', border: '1px solid #52c41a', background: '#fff', color: '#52c41a', borderRadius: 4, cursor: 'pointer' }}>取消选择</button>
|
||||
</div>
|
||||
|
||||
{/* 统计信息 */}
|
||||
<div style={{ marginBottom: 8, fontSize: 12, color: '#666' }}>
|
||||
已选 {selected.length} 个;共 {list.length} 个
|
||||
已选{selected.length} 个;共{list.length} 个
|
||||
</div>
|
||||
|
||||
{/* 网格容器:自适应列 + 滚动 */}
|
||||
@@ -297,11 +306,11 @@ const QrcodeTourismForm: React.FC<QrcodeTourismFormProps> = ({ open, title, init
|
||||
style={{
|
||||
borderWidth: 2,
|
||||
borderStyle: 'solid',
|
||||
borderColor: isSel ? '#1677ff' : '#f0f0f0',
|
||||
borderColor: isSel ? '#52c41a' : '#f0f0f0',
|
||||
borderRadius: 6,
|
||||
cursor: 'pointer',
|
||||
background: '#fff',
|
||||
boxShadow: isSel ? '0 0 0 2px rgba(22,119,255,0.1) inset' : 'none',
|
||||
boxShadow: isSel ? '0 0 0 2px rgba(82,196,26,0.12) inset' : 'none',
|
||||
overflow: 'hidden',
|
||||
display: 'flex',
|
||||
flexDirection: 'column',
|
||||
@@ -314,7 +323,7 @@ const QrcodeTourismForm: React.FC<QrcodeTourismFormProps> = ({ open, title, init
|
||||
<div style={{ fontSize: 12, color: '#999' }}>无图片</div>
|
||||
)}
|
||||
{isSel ? (
|
||||
<div style={{ position: 'absolute', top: 6, right: 6, width: 18, height: 18, borderRadius: '50%', background: '#1677ff' }} />
|
||||
<div style={{ position: 'absolute', top: 6, right: 6, width: 18, height: 18, borderRadius: '50%', background: '#52c41a' }} />
|
||||
) : null}
|
||||
</div>
|
||||
<div style={{ padding: '6px 8px', fontSize: 12, color: '#555', display: 'flex', justifyContent: 'space-between' }}>
|
||||
|
||||
Reference in New Issue
Block a user