Browse Source

宣传视频模块

dev
yangsen 2 years ago
parent
commit
e36722161d
  1. 38
      web/client/src/components/Upload/index.js
  2. 72
      web/client/src/sections/fillion/components/infor/videoUpload.js
  3. 35
      web/client/src/sections/fillion/components/promotionalTable.js

38
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)
}
}

72
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 (
<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>

35
web/client/src/sections/fillion/components/promotionalTable.js

@ -14,11 +14,10 @@ const promotionalTable = (props) => {
const [counts, setCounts] = useState()//shuju
const [success, setSuccess] = useState()
const [delet, setDelet] = useState()
// console.log(record);
const ref = useRef()
useEffect(() => { ref.current.reload() }, [delet])
useEffect(() => { ref.current.reload() }, [delet, success])
const onClickEnable = (record) => {
@ -31,12 +30,11 @@ const promotionalTable = (props) => {
const data = ({ publicityId: id, name: name, video: video, enable: enable })
console.log(data);
dispatch(putEditPropagata(data)).then((res) => {
setSuccess(res.success)
console.log(data);
dispatch(getPropagata()).then((res) => {
setCounts(res.payload.data)
})
})
}
// const ref = useRef()
// useEffect(() => { ref.current.reload() }, [modalVisible, modalVisibleyilan, whichofits, delet])//刷新数据
@ -47,10 +45,8 @@ const promotionalTable = (props) => {
dataIndex: 'containers',
fixed: 'left',
width: 120,
render: (dom, record) => {
for (let i = 0; i < record.lenght; i += 1) {
return i
}
render: (dom, record, key) => {
return key + 1
}
},
{
@ -87,26 +83,21 @@ const promotionalTable = (props) => {
fixed: 'right',
render: (dom, record) => {
return <div style={{ position: 'relative', marginTop: '-30px' }}>
<VideoUpload record={record} />
<VideoUpload record={record} counts={counts} setCounts={setCounts} />
<Popconfirm
title="是否确定删除?"
arrowPointAtCenter={true}
showArrow={true}
position="topRight"
onConfirm={/* () => handleRemove(record) */
onConfirm={
() => {
const query = {
publicityId: record.id
}
dispatch(delPropagata(query)).then((res) => {
setDelet(res)
console.log(res);
// if (res.success) {
// message.success("记录删除成功");
// handelRefresh()
// } else {
// message.error("记录删除失败")
// }
dispatch(delPropagata(query)).then(() => {
dispatch(getPropagata()).then((res) => {
setCounts(res.payload.data)
})
})
}
}
@ -127,7 +118,7 @@ const promotionalTable = (props) => {
renderFormItem: (item, { type, defaultRender, ...rest }, form, record) => {
return (
<div>
<VideoUpload type_ys={1} record={counts} />
<VideoUpload type_ys={1} counts={counts} setCounts={setCounts} />
</div>
);
},

Loading…
Cancel
Save