import React, { useState } from 'react'; import { connect } from 'react-redux'; import { Modal, Form, Button, Input, Switch } from 'antd'; import Uploads from "../../../../components/Upload/index" import { putAddPropagata } from '../../actions/infor'; import { putEditPropagata } from '../../actions/infor'; import { getPropagata } from '../../actions/infor'; const VideoUpload = (props) => { const { dispatch, record, counts, setCounts } = props const [form] = Form.useForm(); //弹窗 const [isModalVisible, setIsModalVisible] = useState(false); const showModal = () => { setIsModalVisible(true); } const showModalEdit = () => { setIsModalVisible(true); }; //新增 const handleOkAdd = () => { form.validateFields().then((values) => { const videoAddress = values.video.map((item) => { return item.storageUrl }) const videoname = values.videoname const enable = values.show const data = { name: videoname, video: videoAddress, enable: enable } dispatch(putAddPropagata(data)).then(() => { dispatch(getPropagata()).then((res) => { setCounts(res.payload.data) }) }) setIsModalVisible(false); } ); }; //编辑 const handleOkEdit = (record) => { form.validateFields().then((values) => { const videoname = values.username const id = record.id const newVideoAddress = values.video.map((item) => { return item.storageUrl }) const data = { publicityId: id, name: videoname, video: newVideoAddress } dispatch(putEditPropagata(data)).then(() => { dispatch(getPropagata()).then((res) => { setCounts(res.payload.data) console.log(data); }) }) setIsModalVisible(false); } ); }; const handleCancel = () => { setIsModalVisible(false); }; const handleCancelEdit = () => { setIsModalVisible(false); form.resetFields() }; const onFinish = (values) => { console.log('Success:', values); }; const onFinishFailed = (errorInfo) => { console.log('Failed:', errorInfo); }; return (
{ props.type_ys ?
:
handleOkEdit(record)} onCancel={handleCancel}>
{ return { url: item } }) }} onFinish={onFinish} onFinishFailed={onFinishFailed} autoComplete="off" >
}
) } function mapStateToProps (state) { const { depMessage } = state; const pakData = (dep) => { return dep.map((d) => { return { title: d.name, value: d.id, children: pakData(d.subordinate) } }) } let depData = pakData(depMessage.data || []) return { loading: depMessage.isRequesting, depData, }; } export default connect(mapStateToProps)(VideoUpload);