|
@@ -12,7 +12,7 @@ import {
|
|
|
Select
|
|
|
} from 'antd';
|
|
|
import { videoType } from '@/dataDic.js';
|
|
|
-import { getVideoType} from '@/tools.js';
|
|
|
+import { getVideoType,getReleaseStateList,splitUrl} from '@/tools.js';
|
|
|
import VideoComponent from '@/crop/video';
|
|
|
import Crop from '@/crop/cropBlock';
|
|
|
|
|
@@ -21,7 +21,8 @@ const NewDetailForm = Form.create()(React.createClass({
|
|
|
return {
|
|
|
visible: false,
|
|
|
loading: false,
|
|
|
- auditStatus: 0,
|
|
|
+ auditStatus: 0,
|
|
|
+ fileList:[],
|
|
|
textFileList: [],
|
|
|
videoImg: [],
|
|
|
vedioUrl:[]
|
|
@@ -35,7 +36,7 @@ const NewDetailForm = Form.create()(React.createClass({
|
|
|
method: "get",
|
|
|
dataType: "json",
|
|
|
crossDomain: false,
|
|
|
- url: globalConfig.context + '/api/admin/policy/detail' ,
|
|
|
+ url: globalConfig.context + '/api/admin/video/getVideoById' ,
|
|
|
data: {
|
|
|
id: id
|
|
|
},
|
|
@@ -48,12 +49,14 @@ const NewDetailForm = Form.create()(React.createClass({
|
|
|
thisData = {};
|
|
|
};
|
|
|
let proArr=[];
|
|
|
+ let fileList =thisData.url ? splitUrl(thisData.url, ',','http://118.190.205.7:8000') : [];
|
|
|
+ fileList[0].url='javascript:;';
|
|
|
+ fileList[0].name=(thisData.url).split('/').pop();
|
|
|
this.setState({
|
|
|
id:thisData.id,
|
|
|
data: thisData,
|
|
|
- auditStatus:thisData.auditStatus,
|
|
|
- videoUrl:[],
|
|
|
- videoImg: thisData.titleImg ? splitUrl(thisData.titleImg, ',', globalConfig.avatarHost + '/upload') : []
|
|
|
+ fileList:fileList,
|
|
|
+ videoImg: thisData.coverUrl ? thisData.coverUrl.split(',') : []
|
|
|
});
|
|
|
}.bind(this),
|
|
|
}).always(function () {
|
|
@@ -62,23 +65,28 @@ const NewDetailForm = Form.create()(React.createClass({
|
|
|
});
|
|
|
}.bind(this));
|
|
|
},
|
|
|
- getPictureUrl(e) {
|
|
|
- this.setState({ pictureUrl: e });
|
|
|
- },
|
|
|
handleSubmit(e,index) {
|
|
|
e.preventDefault();
|
|
|
this.props.form.validateFields((err, values) => {
|
|
|
//url转化
|
|
|
- let thePictureUrl = [];
|
|
|
- if (this.state.pictureUrl.length) {
|
|
|
+ let theVideoUrl = [];
|
|
|
+ if (this.state.fileList.length) {
|
|
|
let picArr = [];
|
|
|
- this.state.pictureUrl.map(function (item) {
|
|
|
+ this.state.fileList.map(function (item) {
|
|
|
if ( item.response && item.response.data && item.response.data.length ){
|
|
|
picArr.push(item.response.data);
|
|
|
}
|
|
|
});
|
|
|
- thePictureUrl = picArr.join(",");
|
|
|
+ theVideoUrl = picArr.join(",");
|
|
|
+ }else{
|
|
|
+ message.warning('请上传视频文件!');
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ if (!this.state.videoImg.length) {
|
|
|
+ message.warning('请上传视频封面图片!');
|
|
|
+ return false;
|
|
|
};
|
|
|
+
|
|
|
if (!err) {
|
|
|
this.setState({
|
|
|
loading: true
|
|
@@ -87,26 +95,20 @@ const NewDetailForm = Form.create()(React.createClass({
|
|
|
method: "post",
|
|
|
dataType: "json",
|
|
|
async:true,
|
|
|
- url: this.props.data.id ? globalConfig.context + '/api/admin/policy/update' : globalConfig.context + '/api/admin/policy/apply',
|
|
|
+ url: this.props.data.id ? globalConfig.context + '/api/admin/video/updateVideo' : globalConfig.context + '/api/admin/video/insertVideo',
|
|
|
data: {
|
|
|
id: this.props.data.id,
|
|
|
- type:0,
|
|
|
- title: values.title,
|
|
|
- author: values.author,
|
|
|
- titleImg: thePictureUrl.length?thePictureUrl:'',
|
|
|
- content:this.state.edit.content,
|
|
|
- hot:values.hot,
|
|
|
- source:values.source,
|
|
|
- sourceUrl:values.sourceUrl,
|
|
|
- keyword:values.keyword,
|
|
|
- auditStatus:index,
|
|
|
- summary: values.summary,
|
|
|
+ type:values.type,
|
|
|
+ name: values.name,
|
|
|
+ url: theVideoUrl.length?theVideoUrl:'',
|
|
|
+ summary:values.summary,
|
|
|
+ coverUrl:this.state.videoImg.join(','),
|
|
|
+ status:index?index:0
|
|
|
}
|
|
|
}).done(function (data) {
|
|
|
this.setState({
|
|
|
loading: false
|
|
|
});
|
|
|
-
|
|
|
if (!data.error.length) {
|
|
|
message.success('操作成功!');
|
|
|
this.setState({
|
|
@@ -132,7 +134,7 @@ const NewDetailForm = Form.create()(React.createClass({
|
|
|
this.state.videoImg = [];
|
|
|
this.state.videoUrl=[];
|
|
|
};
|
|
|
- },
|
|
|
+ },
|
|
|
componentWillReceiveProps(nextProps) {
|
|
|
if (!this.props.visible && nextProps.visible) {
|
|
|
if (nextProps.data.id) {
|
|
@@ -145,34 +147,78 @@ const NewDetailForm = Form.create()(React.createClass({
|
|
|
};
|
|
|
this.props.form.resetFields();
|
|
|
};
|
|
|
- },
|
|
|
+ },
|
|
|
+ //视频上传
|
|
|
+ handleChange(info) {
|
|
|
+ let fileList = info.fileList;
|
|
|
+ this.setState({ fileList,loading:true });
|
|
|
+ if (info.file.status !== 'uploading') {
|
|
|
+ }
|
|
|
+ if (info.file.status === 'done') {
|
|
|
+ message.success(`上传成功`);
|
|
|
+ fileList[0].url='javascript:;';
|
|
|
+ fileList[0].name=(fileList[0].response.data).split('/').pop();
|
|
|
+ this.setState({
|
|
|
+ fileList:fileList
|
|
|
+ })
|
|
|
+ this.setState({
|
|
|
+ loading:false,
|
|
|
+ })
|
|
|
+ } else if (info.file.status === 'error') {
|
|
|
+ message.error(`上传失败`);
|
|
|
+ this.setState({
|
|
|
+ loading:false,
|
|
|
+ })
|
|
|
+ }
|
|
|
+ },
|
|
|
+ beforeUpload(info){
|
|
|
+ if(info.type.indexOf('video')<0){
|
|
|
+ message.warning('请上传MP4格式视频文件.');
|
|
|
+ return false;
|
|
|
+ };
|
|
|
+ let sizeMb = info.size/(1024*1024),size=100;
|
|
|
+ if(sizeMb>size){ //100Mb之内
|
|
|
+ message.warning(`视频大小不超过${size}`);
|
|
|
+ return false;
|
|
|
+ };
|
|
|
+ },
|
|
|
+ videoRemove(file){
|
|
|
+ let fileList = this.state.fileList;
|
|
|
+ this.setState(({ fileList }) => {
|
|
|
+ const index = (fileList).indexOf(file);
|
|
|
+ const newFileList = fileList.slice();
|
|
|
+ newFileList.splice(index, 1);
|
|
|
+ return {
|
|
|
+ fileList: newFileList,
|
|
|
+ loading:false,
|
|
|
+ };
|
|
|
+ });
|
|
|
+ },
|
|
|
render() {
|
|
|
const theData = this.state.data || {};
|
|
|
const { getFieldDecorator } = this.props.form;
|
|
|
- const FormItem = Form.Item
|
|
|
+ const FormItem = Form.Item;
|
|
|
const formItemLayout = {
|
|
|
labelCol: { span: 6 },
|
|
|
wrapperCol: { span: 12 },
|
|
|
};
|
|
|
- const formItemLayouts = {
|
|
|
- labelCol: { span: 3 },
|
|
|
- wrapperCol: { span: 18 },
|
|
|
- };
|
|
|
+ const fileList= this.state.fileList||[];
|
|
|
+ console.log(fileList)
|
|
|
return (
|
|
|
<div className='login'>
|
|
|
<Form layout="horizontal" onSubmit={(e)=>{this.handleSubmit(e,0)}} id="demand-form">
|
|
|
<Spin spinning={this.state.loading}>
|
|
|
<div className="clearfix">
|
|
|
<FormItem className="half-item" {...formItemLayout} label="视频名称">
|
|
|
- {getFieldDecorator('title', {
|
|
|
+ {getFieldDecorator('name', {
|
|
|
rules: [ { required: true, message: '此项为必填项!' } ],
|
|
|
- initialValue: theData.title
|
|
|
+ initialValue: theData.name
|
|
|
})(<Input placeholder="请输入视频的名称" />)}
|
|
|
</FormItem>
|
|
|
<FormItem className="half-item" {...formItemLayout} label="视频类型">
|
|
|
- {getFieldDecorator('title1', {
|
|
|
+ {getFieldDecorator('type', {
|
|
|
rules: [ { required: true, message: '此项为必填项!' } ],
|
|
|
- initialValue: theData.title1
|
|
|
+ initialValue: theData.type||theData.type=='0'?String(theData.type):theData.type
|
|
|
})(<Select placeholder="请选择视频类型">
|
|
|
{videoType.map(item=>{
|
|
|
return <Select.Option value={item.value}>{item.key}</Select.Option>
|
|
@@ -181,26 +227,36 @@ const NewDetailForm = Form.create()(React.createClass({
|
|
|
</FormItem>
|
|
|
</div>
|
|
|
<div className="clearfix">
|
|
|
- <FormItem className="half-item" {...formItemLayout} label="视频文件">
|
|
|
- < VideoComponent
|
|
|
- fileList={(e)=>{this.setState({videoUrl:e})}}
|
|
|
- dataUrl={{
|
|
|
- url:'/api/user/demand/uploadPicture',
|
|
|
- keyWord:'demand_picture',
|
|
|
- type:'video',
|
|
|
- page:1
|
|
|
- }}
|
|
|
- videoUrl={this.state.videoUrl}
|
|
|
- visible={this.props.visible}
|
|
|
- />
|
|
|
+ <FormItem
|
|
|
+ className="half-item"
|
|
|
+ {...formItemLayout}
|
|
|
+ label={<span><strong style={{color:'#f00',fontSize:12}}>* </strong>视频文件</span>}
|
|
|
+ >
|
|
|
+ <Upload
|
|
|
+ action={globalConfig.context +'/api/admin/video/upload' }
|
|
|
+ data={{ sign:'video' }}
|
|
|
+ fileList={this.state.fileList}
|
|
|
+ listType="text"
|
|
|
+ beforeUpload={this.beforeUpload.bind(this)}
|
|
|
+ onChange={this.handleChange.bind(this)}
|
|
|
+ onRemove ={this.videoRemove}
|
|
|
+ >
|
|
|
+ {fileList.length >= 1 ? null : <div>
|
|
|
+ <Button type="primary">点击上传</Button>
|
|
|
+ </div>}
|
|
|
+ </Upload>
|
|
|
</FormItem>
|
|
|
- <FormItem className="half-item" {...formItemLayout} label="封面图片">
|
|
|
+ <FormItem
|
|
|
+ className="half-item"
|
|
|
+ {...formItemLayout}
|
|
|
+ label={<span><strong style={{color:'#f00',fontSize:12}}>* </strong>封面图片</span>}
|
|
|
+ >
|
|
|
<Crop
|
|
|
getAllImg={(e)=>{this.setState({videoImg:e})}}
|
|
|
number = {1}
|
|
|
aspectRatio = {1/1}
|
|
|
- url ={globalConfig.context + '/api/user/uploadPicture64'}
|
|
|
- uploadData = {{sign:'user_picture'}}
|
|
|
+ url ={globalConfig.context + '/api/admin/video/upload'}
|
|
|
+ uploadData = {{sign:'video_cover'}}
|
|
|
urlArr = {this.state.videoImg}
|
|
|
/>
|
|
|
</FormItem>
|
|
@@ -214,10 +270,10 @@ const NewDetailForm = Form.create()(React.createClass({
|
|
|
</div>
|
|
|
<div className="clearfix">
|
|
|
<FormItem className="half-item" {...formItemLayout} label="发布人">
|
|
|
- <span>{theData.releaseStatus?'已发布':'管理员'}</span>
|
|
|
+ <span>{theData.owner?theData.owner:'管理员'}</span>
|
|
|
</FormItem>
|
|
|
{theData.createTime&&<FormItem className="half-item" {...formItemLayout} label="发布状态">
|
|
|
- <span>{theData.releaseStatus?'已发布':'未发布'}</span>
|
|
|
+ <span>{getReleaseStateList(theData.status)}</span>
|
|
|
</FormItem>}
|
|
|
</div>
|
|
|
<div className="clearfix">
|
|
@@ -229,7 +285,7 @@ const NewDetailForm = Form.create()(React.createClass({
|
|
|
className="set-submit"
|
|
|
type="ghost"
|
|
|
onClick={(e) => {
|
|
|
- this.handleSubmit(e,2)
|
|
|
+ this.handleSubmit(e,1)
|
|
|
}}
|
|
|
>
|
|
|
发布视频
|