|
|
@ -1,6 +1,6 @@ |
|
|
|
import React, { useState, useEffect } from 'react'; |
|
|
|
import { connect } from 'react-redux'; |
|
|
|
import { Modal, Form, Button, Input } from 'antd'; |
|
|
|
import { Modal, Form, Button, Input, Card, List } from 'antd'; |
|
|
|
import Uploads from "../../../../components/Upload/index" |
|
|
|
import { putAddPropagata } from '../../actions/infor'; |
|
|
|
import { putEditPropagata } from '../../actions/infor'; |
|
|
@ -8,42 +8,38 @@ import { getPropagata } from '../../actions/infor'; |
|
|
|
|
|
|
|
|
|
|
|
const VideoUpload = (props) => { |
|
|
|
const [counts, setCounts] = useState()//shuju
|
|
|
|
|
|
|
|
//获取数据
|
|
|
|
// useEffect(() => {
|
|
|
|
// const vedio = dispatch(getPropagata()).then((res) => {
|
|
|
|
// setCounts(res.payload.data)
|
|
|
|
// console.log(res.payload.data)
|
|
|
|
// })
|
|
|
|
// }, [])
|
|
|
|
|
|
|
|
const { dispatch, record } = props |
|
|
|
// console.log(record);
|
|
|
|
// const [counts, setCounts] = useState()//shuju
|
|
|
|
|
|
|
|
|
|
|
|
const { dispatch, record, counts, setCounts } = props |
|
|
|
const [success, setSuccess] = useState() //状态
|
|
|
|
const [form] = Form.useForm(); |
|
|
|
|
|
|
|
//弹窗
|
|
|
|
const [isModalVisible, setIsModalVisible] = useState(false); |
|
|
|
// const [video1, videoAddress] = useState()
|
|
|
|
const showModal = () => { |
|
|
|
setIsModalVisible(true); |
|
|
|
|
|
|
|
} |
|
|
|
const showModalEdit = () => { |
|
|
|
|
|
|
|
setIsModalVisible(true); |
|
|
|
}; |
|
|
|
|
|
|
|
// const idArr = record.map((item) => { item.id })
|
|
|
|
// console.log(idArr);
|
|
|
|
|
|
|
|
//新增
|
|
|
|
const handleOkAdd = () => { |
|
|
|
form.validateFields().then((values) => { |
|
|
|
const videoAddress = values.video.map((item) => { |
|
|
|
return item.storageUrl.concat() |
|
|
|
return item.storageUrl |
|
|
|
}) |
|
|
|
console.log(videoAddress); |
|
|
|
const videoname = values.videoname |
|
|
|
const data = { name: videoname, video: videoAddress } |
|
|
|
dispatch(putAddPropagata(data)).then((res) => { |
|
|
|
setSuccess(res.success) |
|
|
|
console.log(data); |
|
|
|
dispatch(putAddPropagata(data)).then(() => { |
|
|
|
dispatch(getPropagata()).then((res) => { |
|
|
|
setCounts(res.payload.data) |
|
|
|
}) |
|
|
|
}) |
|
|
|
setIsModalVisible(false); |
|
|
|
} |
|
|
@ -51,23 +47,24 @@ const VideoUpload = (props) => { |
|
|
|
}; |
|
|
|
//编辑
|
|
|
|
const handleOkEdit = (record) => { |
|
|
|
console.log(record); |
|
|
|
console.log(record.id); |
|
|
|
|
|
|
|
form.validateFields().then((values) => { |
|
|
|
console.log(values); |
|
|
|
const videoAddress = values.video.map((item) => { |
|
|
|
return item.storageUrl.concat() |
|
|
|
return item.storageUrl |
|
|
|
}) |
|
|
|
// const videoname = form.getFieldsValue('videoname')
|
|
|
|
const videoname = values.username ? (!values.username) : record.name |
|
|
|
const videoname = values.username |
|
|
|
const id = record.id |
|
|
|
const video = record.video |
|
|
|
|
|
|
|
const data = { publicityId: id, name: videoname, video: videoAddress } |
|
|
|
dispatch(putEditPropagata(data)).then((res) => { |
|
|
|
setSuccess(res.success) |
|
|
|
const data = { publicityId: id, name: videoname, video: video } |
|
|
|
dispatch(putEditPropagata(data)).then(() => { |
|
|
|
dispatch(getPropagata()).then((res) => { |
|
|
|
setCounts(res.payload.data) |
|
|
|
|
|
|
|
}) |
|
|
|
console.log(data); |
|
|
|
}) |
|
|
|
|
|
|
|
} |
|
|
|
); |
|
|
|
setIsModalVisible(false); |
|
|
@ -88,6 +85,7 @@ const VideoUpload = (props) => { |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return ( |
|
|
|
<div > |
|
|
|
{ |
|
|
@ -138,7 +136,7 @@ const VideoUpload = (props) => { |
|
|
|
</Modal> |
|
|
|
</div> |
|
|
|
: |
|
|
|
<div><Button type='link' onClick={showModal} style={{ Position: "absolute", left: "-50px", top: "32px" }}>编辑</Button> |
|
|
|
<div><Button type='link' onClick={showModalEdit} style={{ Position: "absolute", left: "-50px", top: "32px" }}>编辑</Button> |
|
|
|
<Modal visible={isModalVisible} onOk={() => handleOkEdit(record)} onCancel={handleCancel}> |
|
|
|
<Form |
|
|
|
form={form} |
|
|
@ -149,10 +147,13 @@ const VideoUpload = (props) => { |
|
|
|
wrapperCol={{ |
|
|
|
span: 16, |
|
|
|
}} |
|
|
|
// initialValues={{
|
|
|
|
// remember: true,
|
|
|
|
// }}
|
|
|
|
initialValues={true} |
|
|
|
initialValues={{ |
|
|
|
username: record.name, video: record.video.map((item) => { |
|
|
|
console.log(record.video); |
|
|
|
|
|
|
|
return { url: item } |
|
|
|
}) |
|
|
|
}} |
|
|
|
onFinish={onFinish} |
|
|
|
onFinishFailed={onFinishFailed} |
|
|
|
autoComplete="off" |
|
|
@ -171,7 +172,6 @@ const VideoUpload = (props) => { |
|
|
|
> |
|
|
|
<Input |
|
|
|
placeholder="请输入视频名称" |
|
|
|
defaultValue={record.name} |
|
|
|
/> |
|
|
|
|
|
|
|
</Form.Item> |
|
|
@ -184,6 +184,8 @@ const VideoUpload = (props) => { |
|
|
|
fileTypes={['mp4']} |
|
|
|
maxFileSize={200} |
|
|
|
/> |
|
|
|
|
|
|
|
|
|
|
|
</Form.Item> |
|
|
|
</Form> |
|
|
|
</Modal> |
|
|
|