|
@@ -7,6 +7,7 @@ import React, { useEffect, useState } from "react"
|
|
|
import { useModel } from "umi"
|
|
|
import styles from './index.less'
|
|
|
import { getVideoImgUrl } from "@/utils/utils"
|
|
|
+import VideoFrame from "@/pages/launchSystemNew/components/videoFrame"
|
|
|
|
|
|
interface Props {
|
|
|
value?: any[]
|
|
@@ -66,7 +67,7 @@ const Material: React.FC<Props> = (props) => {
|
|
|
|
|
|
const getVideoCapture = useAjax((params) => get_tools_video_capture(params))
|
|
|
/**************************/
|
|
|
-
|
|
|
+
|
|
|
// 回填
|
|
|
useEffect(() => {
|
|
|
if (visible) {
|
|
@@ -143,6 +144,21 @@ const Material: React.FC<Props> = (props) => {
|
|
|
})
|
|
|
}
|
|
|
|
|
|
+ const setFrame = (url: string, num: number, field: string) => {
|
|
|
+ materials = materials?.map((item: any, index: number) => {
|
|
|
+ if (num === index) {
|
|
|
+ if (item) {
|
|
|
+ item[field] = url
|
|
|
+ return { ...item }
|
|
|
+ } else {
|
|
|
+ return { [field]: url }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return item
|
|
|
+ })
|
|
|
+ form.setFieldsValue({ materials })
|
|
|
+ }
|
|
|
+
|
|
|
return <>
|
|
|
<span onClick={() => { setVisible(true) }}>{value && value?.length > 0 ? '编辑' : '添加'}</span>
|
|
|
{visible && <Modal
|
|
@@ -192,7 +208,7 @@ const Material: React.FC<Props> = (props) => {
|
|
|
}}
|
|
|
onOk={handleOk}
|
|
|
>
|
|
|
- <Form name="dynamic_form_item" form={form} labelAlign='left' >
|
|
|
+ <Form name="dynamic_form_item" form={form} labelAlign='left'>
|
|
|
<Form.List name="materials">
|
|
|
{(fields, { add, remove }) => (<>
|
|
|
{fields.map((field, num) => (<div key={field.key}>
|
|
@@ -236,26 +252,31 @@ const Material: React.FC<Props> = (props) => {
|
|
|
name={[field.name, item.name]}
|
|
|
key={index}
|
|
|
>
|
|
|
- <div className={`${styles.box} ${styles.image}`} style={{ width: 300, height: 160 }} onClick={() => {
|
|
|
- init({ mediaType: 'IMG', cloudSize: [[{ relation: '=', width: item.restriction.imageRestriction.width, height: item.restriction.imageRestriction.height }]], maxSize: item.restriction.imageRestriction.fileSize * 1024 })
|
|
|
- setMaterialConfig({
|
|
|
- ...materialConfig,
|
|
|
- type: item.name,
|
|
|
- max: 1,
|
|
|
- index: num,
|
|
|
- adcreativeTemplateId
|
|
|
- })
|
|
|
- setTimeout(() => {
|
|
|
- set_selectVideoVisible(true)
|
|
|
- }, 100)
|
|
|
- }}>
|
|
|
- <p>
|
|
|
- {materials?.length > 0 && materials[num] && Object.keys(materials[num])?.includes(item.name) ? <img src={materials[num][item.name]} /> : <>
|
|
|
- <span>{`推荐尺寸(${item.restriction.imageRestriction.width} x ${item.restriction.imageRestriction.height})`}</span>
|
|
|
- <span>{`${item.restriction.imageRestriction.fileFormat?.map((str: any) => str?.replace('IMAGE_TYPE_', ''))};小于 ${item.restriction.imageRestriction.fileSize}KB`}</span>
|
|
|
- </>}
|
|
|
- </p>
|
|
|
- </div>
|
|
|
+ <Space align="end">
|
|
|
+ <div className={`${styles.box} ${styles.image}`} style={{ width: 300, height: 160 }} onClick={() => {
|
|
|
+ init({ mediaType: 'IMG', cloudSize: [[{ relation: '=', width: item.restriction.imageRestriction.width, height: item.restriction.imageRestriction.height }]], maxSize: item.restriction.imageRestriction.fileSize * 1024 })
|
|
|
+ setMaterialConfig({
|
|
|
+ ...materialConfig,
|
|
|
+ type: item.name,
|
|
|
+ max: 1,
|
|
|
+ index: num,
|
|
|
+ adcreativeTemplateId
|
|
|
+ })
|
|
|
+ setTimeout(() => {
|
|
|
+ set_selectVideoVisible(true)
|
|
|
+ }, 100)
|
|
|
+ }}>
|
|
|
+ <p>
|
|
|
+ {materials?.length > 0 && materials[num] && Object.keys(materials[num])?.includes(item.name) ? <img src={materials[num][item.name]} /> : <>
|
|
|
+ <span>{`推荐尺寸(${item.restriction.imageRestriction.width} x ${item.restriction.imageRestriction.height})`}</span>
|
|
|
+ <span>{`${item.restriction.imageRestriction.fileFormat?.map((str: any) => str?.replace('IMAGE_TYPE_', ''))};小于 ${item.restriction.imageRestriction.fileSize}KB`}</span>
|
|
|
+ </>}
|
|
|
+ </p>
|
|
|
+ </div>
|
|
|
+ {videoUploads && Object.keys(videoUploads)?.length > 0 && <div style={{ width: 32 }}>
|
|
|
+ {materials?.length > 0 && materials[num] && (Object.keys(materials[num])?.includes('video') || Object.keys(materials[num])?.includes('short_video1')) && <VideoFrame onChange={(e) => setFrame(e, num, item.name)} url={materials[num]?.video || materials[num]?.short_video1}/>}
|
|
|
+ </div>}
|
|
|
+ </Space>
|
|
|
</Form.Item>
|
|
|
}
|
|
|
if (item.name === 'image_list') {
|