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 { 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';
|
||||||
@@ -15,9 +15,9 @@ 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=自定义
|
||||||
@@ -60,6 +60,17 @@ const QrcodeTourismForm: React.FC<QrcodeTourismFormProps> = ({ open, title, init
|
|||||||
};
|
};
|
||||||
}, [open, tourismIdForFetch]);
|
}, [open, tourismIdForFetch]);
|
||||||
|
|
||||||
|
// 景区素材类型字典(按业务提供)
|
||||||
|
const TYPE_LABEL: Record<number, string> = {
|
||||||
|
5: '视频',
|
||||||
|
6: '首页 Banner',
|
||||||
|
4: '展示图片',
|
||||||
|
3: '景区详情',
|
||||||
|
2: '景区小图展示',
|
||||||
|
1: '活动',
|
||||||
|
};
|
||||||
|
const typeName = (t: any) => TYPE_LABEL[Number(t)] || '其他';
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<ModalForm<QrcodeItem>
|
<ModalForm<QrcodeItem>
|
||||||
title={title}
|
title={title}
|
||||||
@@ -224,7 +235,7 @@ 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 }} />
|
||||||
@@ -244,11 +255,10 @@ const QrcodeTourismForm: React.FC<QrcodeTourismFormProps> = ({ open, title, init
|
|||||||
<div />
|
<div />
|
||||||
</ProForm.Item>
|
</ProForm.Item>
|
||||||
|
|
||||||
{/* 景区素材(移除查询条件;支持多选;无上限;保留“全部选择/取消全选”) */}
|
{/* 景区素材(移除查询条件;支持多选;无上限;保留“全部选择/取消选择”) */}
|
||||||
<ProForm.Item label="景区素材" shouldUpdate>
|
<ProForm.Item label="景区素材" shouldUpdate>
|
||||||
{({ getFieldValue, setFieldsValue }) => {
|
{({ getFieldValue, setFieldsValue }) => {
|
||||||
const selected: number[] = getFieldValue('tourismFileIds') || [];
|
const selected: number[] = getFieldValue('tourismFileIds') || [];
|
||||||
const typeName = (t: any) => (t === 2 ? '视频' : t === 1 ? '图片' : '其他');
|
|
||||||
if (!tourismIdForFetch) {
|
if (!tourismIdForFetch) {
|
||||||
return <div style={{ color: '#999' }}>请选择景区后加载素材</div>;
|
return <div style={{ color: '#999' }}>请选择景区后加载素材</div>;
|
||||||
}
|
}
|
||||||
@@ -271,11 +281,10 @@ const QrcodeTourismForm: React.FC<QrcodeTourismFormProps> = ({ open, title, init
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
{/* 仅保留“全部选择 / 取消全选” */}
|
{/* 操作:全部选择 / 取消选择(左对齐,与“景区素材”同起点) */}
|
||||||
<div style={{ display: 'flex', gap: 12, alignItems: 'center', marginBottom: 8 }}>
|
<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 #52c41a', background: '#52c41a', color: '#fff', borderRadius: 4, cursor: 'pointer' }}>全部选择</button>
|
||||||
<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 #52c41a', background: '#fff', color: '#52c41a', 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>
|
||||||
|
|
||||||
{/* 统计信息 */}
|
{/* 统计信息 */}
|
||||||
@@ -297,11 +306,11 @@ const QrcodeTourismForm: React.FC<QrcodeTourismFormProps> = ({ open, title, init
|
|||||||
style={{
|
style={{
|
||||||
borderWidth: 2,
|
borderWidth: 2,
|
||||||
borderStyle: 'solid',
|
borderStyle: 'solid',
|
||||||
borderColor: isSel ? '#1677ff' : '#f0f0f0',
|
borderColor: isSel ? '#52c41a' : '#f0f0f0',
|
||||||
borderRadius: 6,
|
borderRadius: 6,
|
||||||
cursor: 'pointer',
|
cursor: 'pointer',
|
||||||
background: '#fff',
|
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',
|
overflow: 'hidden',
|
||||||
display: 'flex',
|
display: 'flex',
|
||||||
flexDirection: 'column',
|
flexDirection: 'column',
|
||||||
@@ -314,7 +323,7 @@ const QrcodeTourismForm: React.FC<QrcodeTourismFormProps> = ({ open, title, init
|
|||||||
<div style={{ fontSize: 12, color: '#999' }}>无图片</div>
|
<div style={{ fontSize: 12, color: '#999' }}>无图片</div>
|
||||||
)}
|
)}
|
||||||
{isSel ? (
|
{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}
|
) : null}
|
||||||
</div>
|
</div>
|
||||||
<div style={{ padding: '6px 8px', fontSize: 12, color: '#555', display: 'flex', justifyContent: 'space-between' }}>
|
<div style={{ padding: '6px 8px', fontSize: 12, color: '#555', display: 'flex', justifyContent: 'space-between' }}>
|
||||||
|
|||||||
Reference in New Issue
Block a user