|
@@ -14,6 +14,7 @@ import { SortableContext, verticalListSortingStrategy, useSortable } from '@dnd-
|
|
|
import { CSS } from '@dnd-kit/utilities'
|
|
import { CSS } from '@dnd-kit/utilities'
|
|
|
import ZRichTextOne from '@/components/ZRichTextOne'
|
|
import ZRichTextOne from '@/components/ZRichTextOne'
|
|
|
import ImageLazy from '@/components/ImageLazy'
|
|
import ImageLazy from '@/components/ImageLazy'
|
|
|
|
|
+import classNames from 'classnames'
|
|
|
|
|
|
|
|
const sizeTxt: any = {
|
|
const sizeTxt: any = {
|
|
|
户外裸眼3D: '短屏侧2240*1920 长屏侧12800*1920',
|
|
户外裸眼3D: '短屏侧2240*1920 长屏侧12800*1920',
|
|
@@ -47,7 +48,7 @@ function A4set({ id, closeFu }: Props) {
|
|
|
const { active, over } = event
|
|
const { active, over } = event
|
|
|
if (!over || active.id === over.id) return
|
|
if (!over || active.id === over.id) return
|
|
|
|
|
|
|
|
- const fileList = info.file || []
|
|
|
|
|
|
|
+ const fileList = (info.file || []).filter(v => v.type === 'video')
|
|
|
const oldIndex = fileList.findIndex(i => i.id === active.id)
|
|
const oldIndex = fileList.findIndex(i => i.id === active.id)
|
|
|
const newIndex = fileList.findIndex(i => i.id === over.id)
|
|
const newIndex = fileList.findIndex(i => i.id === over.id)
|
|
|
|
|
|
|
@@ -103,6 +104,9 @@ function A4set({ id, closeFu }: Props) {
|
|
|
const txtObj = JSON.parse(info.rtf || '{}')
|
|
const txtObj = JSON.parse(info.rtf || '{}')
|
|
|
if (txtObj.html) txtRef.current.ritxtShowFu(txtObj.html)
|
|
if (txtObj.html) txtRef.current.ritxtShowFu(txtObj.html)
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+ // 回显底图选中
|
|
|
|
|
+ if (info.thumb && info.thumbPc) setImgAc({ thumb: info.thumbPc, thumbPc: info.thumbPc })
|
|
|
}
|
|
}
|
|
|
}, [id])
|
|
}, [id])
|
|
|
|
|
|
|
@@ -172,16 +176,16 @@ function A4set({ id, closeFu }: Props) {
|
|
|
// -----------------图文相关----------------------
|
|
// -----------------图文相关----------------------
|
|
|
const txtRef = useRef<any>(null)
|
|
const txtRef = useRef<any>(null)
|
|
|
|
|
|
|
|
- const [imgAc, setImgAc] = useState({ id: 0, thumb: '', thumbPc: '' })
|
|
|
|
|
|
|
+ const [imgAc, setImgAc] = useState({ thumb: '', thumbPc: '' })
|
|
|
|
|
|
|
|
// 上传文件成功
|
|
// 上传文件成功
|
|
|
const upFileFu = useCallback(
|
|
const upFileFu = useCallback(
|
|
|
- (val: any, type: 'img' | 'video') => {
|
|
|
|
|
- setInfo({ ...info, file: [val, ...(info.file || [])] })
|
|
|
|
|
|
|
+ (val: any[], type: 'img' | 'video') => {
|
|
|
|
|
+ setInfo({ ...info, file: [...val, ...(info.file || [])] })
|
|
|
|
|
|
|
|
if (type === 'img') {
|
|
if (type === 'img') {
|
|
|
if (!imgAc.thumb) {
|
|
if (!imgAc.thumb) {
|
|
|
- setImgAc({ id: val.id, thumb: val.thumb, thumbPc: val.filePath })
|
|
|
|
|
|
|
+ setImgAc({ thumb: val[0].thumb, thumbPc: val[0].filePath })
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
},
|
|
},
|
|
@@ -191,7 +195,7 @@ function A4set({ id, closeFu }: Props) {
|
|
|
// 点击提交
|
|
// 点击提交
|
|
|
const btnOk = useCallback(async () => {
|
|
const btnOk = useCallback(async () => {
|
|
|
if (info.type === 'video') {
|
|
if (info.type === 'video') {
|
|
|
- if (videlAc.length <= 0) return MessageFu.warning('至少选中一个视频')
|
|
|
|
|
|
|
+ if (videlAc.length <= 0) return MessageFu.warning('请上传视频,并至少选中一个')
|
|
|
} else if (info.type === 'img') {
|
|
} else if (info.type === 'img') {
|
|
|
if (!imgAc.thumb) return MessageFu.warning('请上传底图')
|
|
if (!imgAc.thumb) return MessageFu.warning('请上传底图')
|
|
|
}
|
|
}
|
|
@@ -205,6 +209,8 @@ function A4set({ id, closeFu }: Props) {
|
|
|
id: info.id,
|
|
id: info.id,
|
|
|
name: info.name,
|
|
name: info.name,
|
|
|
rtf: JSON.stringify(txtObj),
|
|
rtf: JSON.stringify(txtObj),
|
|
|
|
|
+ thumb: imgAc.thumb || '',
|
|
|
|
|
+ thumbPc: imgAc.thumbPc || '',
|
|
|
type: info.type
|
|
type: info.type
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -219,7 +225,7 @@ function A4set({ id, closeFu }: Props) {
|
|
|
MessageFu.success('提交成功')
|
|
MessageFu.success('提交成功')
|
|
|
closeFu()
|
|
closeFu()
|
|
|
}
|
|
}
|
|
|
- }, [closeFu, imgAc.thumb, info.file, info.id, info.name, info.type, videlAc])
|
|
|
|
|
|
|
+ }, [closeFu, imgAc.thumb, imgAc.thumbPc, info.file, info.id, info.name, info.type, videlAc])
|
|
|
|
|
|
|
|
return (
|
|
return (
|
|
|
<div className={styles.A4set}>
|
|
<div className={styles.A4set}>
|
|
@@ -257,33 +263,36 @@ function A4set({ id, closeFu }: Props) {
|
|
|
size={99999}
|
|
size={99999}
|
|
|
backFu={val => upFileFu(val, 'video')}
|
|
backFu={val => upFileFu(val, 'video')}
|
|
|
/>
|
|
/>
|
|
|
-  建议尺寸:{sizeTxt[info.name] || ''}
|
|
|
|
|
|
|
+  建议尺寸:{sizeTxt[info.name] || ''};只支持.mp4格式
|
|
|
</div>
|
|
</div>
|
|
|
</div>
|
|
</div>
|
|
|
|
|
|
|
|
{/* 拖动表格 */}
|
|
{/* 拖动表格 */}
|
|
|
- <DndContext
|
|
|
|
|
- sensors={sensors}
|
|
|
|
|
- collisionDetection={closestCenter}
|
|
|
|
|
- onDragEnd={handleDragEnd}
|
|
|
|
|
- >
|
|
|
|
|
- <SortableContext
|
|
|
|
|
- items={(info.file || []).map(i => i.id)}
|
|
|
|
|
- strategy={verticalListSortingStrategy}
|
|
|
|
|
|
|
+
|
|
|
|
|
+ {(info.file || []).filter(v => v.type === 'video').length ? (
|
|
|
|
|
+ <DndContext
|
|
|
|
|
+ sensors={sensors}
|
|
|
|
|
+ collisionDetection={closestCenter}
|
|
|
|
|
+ onDragEnd={handleDragEnd}
|
|
|
>
|
|
>
|
|
|
- <Table
|
|
|
|
|
- rowKey='id'
|
|
|
|
|
- scroll={{ y: 570 }}
|
|
|
|
|
- columns={tableLastBtn}
|
|
|
|
|
- dataSource={(info.file || []).filter(v => v.type === 'video')}
|
|
|
|
|
- pagination={false}
|
|
|
|
|
- size='small'
|
|
|
|
|
- components={{
|
|
|
|
|
- body: { row: DraggableRow }
|
|
|
|
|
- }}
|
|
|
|
|
- />
|
|
|
|
|
- </SortableContext>
|
|
|
|
|
- </DndContext>
|
|
|
|
|
|
|
+ <SortableContext
|
|
|
|
|
+ items={(info.file || []).filter(v => v.type === 'video').map(i => i.id)}
|
|
|
|
|
+ strategy={verticalListSortingStrategy}
|
|
|
|
|
+ >
|
|
|
|
|
+ <Table
|
|
|
|
|
+ rowKey='id'
|
|
|
|
|
+ scroll={{ y: 570 }}
|
|
|
|
|
+ columns={tableLastBtn}
|
|
|
|
|
+ dataSource={(info.file || []).filter(v => v.type === 'video')}
|
|
|
|
|
+ pagination={false}
|
|
|
|
|
+ size='small'
|
|
|
|
|
+ components={{
|
|
|
|
|
+ body: { row: DraggableRow }
|
|
|
|
|
+ }}
|
|
|
|
|
+ />
|
|
|
|
|
+ </SortableContext>
|
|
|
|
|
+ </DndContext>
|
|
|
|
|
+ ) : null}
|
|
|
</div>
|
|
</div>
|
|
|
|
|
|
|
|
{/* ----------------------图文-------------------- */}
|
|
{/* ----------------------图文-------------------- */}
|
|
@@ -308,22 +317,35 @@ function A4set({ id, closeFu }: Props) {
|
|
|
fileNum={(info.file || []).filter(v => v.type === 'img').length}
|
|
fileNum={(info.file || []).filter(v => v.type === 'img').length}
|
|
|
/>
|
|
/>
|
|
|
 建议尺寸:{sizeTxt[info.name] || ''}
|
|
 建议尺寸:{sizeTxt[info.name] || ''}
|
|
|
- ;图片最大为10m,最多10张;按住Cttrl+鼠标左键可一次选择多张图片上传
|
|
|
|
|
|
|
+ ;支持.jpg,.png,.gif格式,图片最大为10m,最多10张;按住Cttrl+鼠标左键可一次选择多张图片上传
|
|
|
</div>
|
|
</div>
|
|
|
</div>
|
|
</div>
|
|
|
<div className='A4Srow' hidden={info.type !== 'img'}>
|
|
<div className='A4Srow' hidden={info.type !== 'img'}>
|
|
|
<div className='A4Srow1'></div>
|
|
<div className='A4Srow1'></div>
|
|
|
- <div className='A4Srow2'>
|
|
|
|
|
|
|
+ <div className='A4Srow2 A4SimgBox'>
|
|
|
{(info.file || [])
|
|
{(info.file || [])
|
|
|
.filter(v => v.type === 'img')
|
|
.filter(v => v.type === 'img')
|
|
|
.map(item => (
|
|
.map(item => (
|
|
|
- <div key={item.id}>
|
|
|
|
|
|
|
+ <div key={item.id} className='A4SimgRow'>
|
|
|
<ImageLazy
|
|
<ImageLazy
|
|
|
- width={100}
|
|
|
|
|
- height={100}
|
|
|
|
|
|
|
+ width={120}
|
|
|
|
|
+ height={120}
|
|
|
srcBig={item.filePath || item.thumb}
|
|
srcBig={item.filePath || item.thumb}
|
|
|
src={item.thumb || item.filePath}
|
|
src={item.thumb || item.filePath}
|
|
|
/>
|
|
/>
|
|
|
|
|
+ <div
|
|
|
|
|
+ className={classNames(
|
|
|
|
|
+ 'A4SimgBtn',
|
|
|
|
|
+ imgAc.thumb === item.thumb ? 'A4SimgBtnAc' : ''
|
|
|
|
|
+ )}
|
|
|
|
|
+ >
|
|
|
|
|
+ <Button
|
|
|
|
|
+ type={imgAc.thumb === item.thumb ? 'primary' : 'default'}
|
|
|
|
|
+ onClick={() => setImgAc({ thumb: item.thumb, thumbPc: item.filePath })}
|
|
|
|
|
+ >
|
|
|
|
|
+ {imgAc.thumb === item.thumb ? '当前选中' : '设置为选中'}
|
|
|
|
|
+ </Button>
|
|
|
|
|
+ </div>
|
|
|
</div>
|
|
</div>
|
|
|
))}
|
|
))}
|
|
|
</div>
|
|
</div>
|
|
@@ -336,6 +358,15 @@ function A4set({ id, closeFu }: Props) {
|
|
|
</Button>
|
|
</Button>
|
|
|
 
|
|
 
|
|
|
<MyPopconfirm txtK='取消' onConfirm={closeFu} />
|
|
<MyPopconfirm txtK='取消' onConfirm={closeFu} />
|
|
|
|
|
+ {info.type === 'img' ? (
|
|
|
|
|
+ <>
|
|
|
|
|
+ {' '}
|
|
|
|
|
+  
|
|
|
|
|
+ <Button type='primary' disabled={!imgAc.thumb}>
|
|
|
|
|
+ 效果预览
|
|
|
|
|
+ </Button>
|
|
|
|
|
+ </>
|
|
|
|
|
+ ) : null}
|
|
|
</div>
|
|
</div>
|
|
|
</div>
|
|
</div>
|
|
|
)
|
|
)
|