diff --git a/web/client/src/components/Upload/index.js b/web/client/src/components/Upload/index.js index b8ebed84..d9eea797 100644 --- a/web/client/src/components/Upload/index.js +++ b/web/client/src/components/Upload/index.js @@ -20,6 +20,7 @@ class Uploads extends Component { } dealName = (uploaded) => { + console.log(uploaded) let realName = uploaded.split('/')[2] let x1 = realName.split('.') let x2 = x1[0].split('_') @@ -27,28 +28,29 @@ class Uploads extends Component { return showName } - // setFileList = (value) => { - // let defaultFileList = []; - // defaultFileList = value.map((u, index) => { - // let fileUrl = `${this.ApiRoot}/${u.url}`; - // return { - // uid: -index - 1, - // name: this.dealName(u.url), - // status: 'done', - // storageUrl: u.url, - // url: fileUrl - // }; - // }); - // onChange(defaultFileList) - // this.setState({ - // fileList: defaultFileList - // }); - // }; + setFileList = (value) => { + let defaultFileList = []; + defaultFileList = value.map((u, index) => { + let fileUrl = `${this.ApiRoot}/${u.url}`; + return { + uid: -index - 1, + name: this.dealName(u.url), + status: 'done', + storageUrl: u.url, + url: fileUrl + }; + }); + // onChange(defaultFileList) + this.setState({ + fileList: defaultFileList + }); + }; componentDidMount () { const { value } = this.props; if (value) { - this.setState(value); + // this.setState(value); + this.setFileList(value) } } diff --git a/web/client/src/sections/fillion/components/infor/videoUpload.js b/web/client/src/sections/fillion/components/infor/videoUpload.js index 40df283c..b3fecd8d 100644 --- a/web/client/src/sections/fillion/components/infor/videoUpload.js +++ b/web/client/src/sections/fillion/components/infor/videoUpload.js @@ -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 (