liting2017 6 years ago
parent
commit
b69de1a5d8

+ 1 - 1
js/component/administration/banner/banner.jsx

@@ -1,6 +1,6 @@
 import { Component } from 'react';
 import { Input, Select, Spin, Table, message, Button,Icon } from 'antd';
-import BannerFrom from '@/administration/banner/bannerForm.jsx';
+import BannerFrom from '@/administration/banner/bannerDes.jsx';
 import {  splitUrl} from '@/tools.js';
 
 class Banner extends Component {

+ 62 - 0
js/component/administration/banner/bannerDes.jsx

@@ -0,0 +1,62 @@
+import React from 'react';
+import { Modal, Spin } from 'antd';
+import BannerForm from '@/administration/banner/BannerForm';
+
+class DemandDesc extends React.Component {
+	constructor(props) {
+		super(props);
+		this.state = {
+			loading: false,
+			pictureUrl: [],
+			showState:false
+		};
+	}
+	handleCancel() {
+		this.setState({
+			visible: false,
+		});
+		this.props.closeDesc(false, false);
+	}
+	handOk() {
+		this.setState({
+			visible: false,
+		});
+		this.props.closeDesc(false, true);
+	}
+	componentWillReceiveProps(nextProps) {
+		this.state.visible = nextProps.showDesc;
+
+	}
+	render() {
+		let data = this.props.data || {releaseStatus:0};
+		return (
+			<div className="patent-desc">
+				<Modal
+					maskClosable={false}
+					visible={this.state.visible}
+					onOk={this.handOk.bind(this)}
+					onCancel={this.handleCancel.bind(this)}
+					width="600px"
+					title='需求详情'
+					footer=""
+					className="admin-desc-content"
+				>
+					<div>
+						<div>
+							<BannerForm
+							    examineState={this.props.examineState}
+								closeDesc={this.handleCancel.bind(this)}
+								data={this.props.data}
+								demandTypeOption={this.props.demandTypeOption}
+								visible={this.state.visible}
+								handOk={this.handOk.bind(this)}
+							/>
+						</div>
+					</div>
+				</Modal>
+			</div>
+		);
+	}
+}
+
+export default DemandDesc;

+ 83 - 106
js/component/administration/banner/bannerForm.jsx

@@ -36,9 +36,7 @@ const PicturesWall = React.createClass({
 		this.props.fileList(fileList);
     },
 	componentWillReceiveProps(nextProps) {
-        if(nextProps.pictureUrl.length){
-            this.state.fileList = nextProps.pictureUrl;
-        }
+        this.state.fileList = nextProps.pictureUrl;
 	},
 	render() {
 		const { previewVisible, previewImage, fileList } = this.state;
@@ -77,12 +75,9 @@ class BannerForm extends React.Component {
             visible:false
 		};
 	}
-	handleCancel() {
-		this.setState({
-			visible: false,
-		});
-		this.props.closeDesc(false, false);
-    }
+	cancelFun(){
+		this.props.closeDesc();
+	}
     loadData(id) {
         this.setState({
             loading: true
@@ -115,12 +110,7 @@ class BannerForm extends React.Component {
             });
         }.bind(this));
     }
-	handOk() {
-		this.setState({
-			visible: false,
-		});
-		this.props.closeDesc(false, true);
-    }
+	
     handleSubmit(e){
         e.preventDefault();
         this.props.form.validateFields((err, values) => {
@@ -166,7 +156,7 @@ class BannerForm extends React.Component {
                         this.setState({
                             visible: false
                         });
-                        this.handOk();
+                        this.props.handOk();
                     } else {
                         message.warning(data.error[0].message);
                     }
@@ -174,25 +164,27 @@ class BannerForm extends React.Component {
             }
         })
     }
-    componentWillMount(){
+    componentWillMount() {
         if (this.props.data&&this.props.data.id) {
             this.loadData(this.props.data.id);
         } else {
-            this.state.data = {};
+			this.state.data = {};
+			this.state.imgUrl = [];
+        };
+    }
+    componentWillReceiveProps(nextProps) {
+        if (!this.props.visible && nextProps.visible) {
+            this.state.textFileList = [];
+            this.state.videoFileList = [];
+            if (nextProps.data.id) {
+                this.loadData(nextProps.data.id);
+            } else {
+				this.state.data = {};
+				this.state.imgUrl = [];
+            };
+			this.props.form.resetFields();
         };
     }
-	componentWillReceiveProps(nextProps) {
-        this.state.visible = nextProps.showDesc;
-        if(nextProps.data&&nextProps.data.id){
-            this.loadData(nextProps.data.id);
-        }else{
-            this.setState({
-                data:{},
-                imgUrl:[]
-            })
-        }
-        this.props.form.resetFields();
-	}
 	render() {
         const { getFieldDecorator } = this.props.form;
         const FormItem = Form.Item;
@@ -203,82 +195,67 @@ class BannerForm extends React.Component {
         let theData = this.state.data||{};
 		return (
 			<div className="patent-desc">
-				<Modal
-					maskClosable={false}
-					visible={this.state.visible}
-					onOk={this.handOk.bind(this)}
-					onCancel={this.handleCancel.bind(this)}
-					width="600px"
-					title={!theData.id ? '新建轮播图' : '修改轮播图'}
-					footer=""
-					className="admin-desc-content"
-				>
-					<div>
-						<div>
-                            <Form layout="horizontal" onSubmit={this.handleSubmit.bind(this)} id="demand-form">
-                                <Spin spinning={this.state.loading}>
-                                    <div className="clearfix">
-                                        <FormItem  {...formItemLayout} label="轮播图描述">
-                                            {getFieldDecorator('text', {
-                                                rules: [ { required: true, message: '此项为必填项!' } ],
-                                                initialValue: theData.text
-                                            })(<Input placeholder="请输入轮播图名称"/>)}
-                                        </FormItem>
-                                    </div>
-                                    <div className="clearfix">
-                                        <FormItem {...formItemLayout} label="跳转地址">
-                                            {getFieldDecorator('forwardUrl', {
-                                                rules: [ { required: true, message: '此项为必填项!' } ],
-                                                initialValue: theData.forwardUrl
-                                            })(<Input placeholder="请输入跳转地址"/>)}
-                                        </FormItem>
-                                    </div>
-                                    <div className="clearfix">
-                                        <FormItem  {...formItemLayout} label="api">
-                                            {getFieldDecorator('apiUrl', {
-                                                rules: [ { required: true, message: '此项为必填项!' } ],
-                                                initialValue: theData.apiUrl
-                                            })(<Input placeholder="请输入api"/>)}
-                                        </FormItem>
-                                    </div>
-                                    <div className="clearfix">
-                                        <FormItem  {...formItemLayout} label="位置">
-                                            {getFieldDecorator('client', {
-                                                rules: [ { required: true, message: '此项为必填项!' } ],
-                                                initialValue: theData.client 
-                                            })(
-                                                <Radio.Group>
-                                                    <Radio value={0}>网站</Radio>
-                                                    <Radio value={1}>App</Radio>
-                                                </Radio.Group>
-                                                )
-                                            }
-                                        </FormItem>
-                                    </div>
-                                    <div className="clearfix">
-                                        <FormItem labelCol={{ span: 6 }} wrapperCol={{ span: 18 }} label={<span><strong style={{color:"#f00"}}> * </strong>轮播图</span>}>
-                                            <PicturesWall
-                                                fileList={(e)=>{this.setState({imgUrl:e})}}
-                                                pictureUrl={this.state.imgUrl}
-                                                visible={this.props.visible}
-                                            />
-                                        </FormItem>
-                                    </div>
-                                    <div className="clearfix">
-                                        <FormItem wrapperCol={{ span: 12, offset: 6 }}>
-                                            <Button className="set-submit" type="primary" htmlType="submit">
-                                                保存
-                                            </Button>
-                                            <Button className="set-submit" type="ghost" onClick={this.handleCancel.bind(this)}>
-                                                取消
-                                            </Button>
-                                        </FormItem>
-                                    </div>
-                                </Spin>
-                            </Form>    
-						</div>
-					</div>
-				</Modal>
+                <Form layout="horizontal" onSubmit={this.handleSubmit.bind(this)} id="demand-form">
+                    <Spin spinning={this.state.loading}>
+                        <div className="clearfix">
+                            <FormItem  {...formItemLayout} label="轮播图描述">
+                                {getFieldDecorator('text', {
+                                    rules: [ { required: true, message: '此项为必填项!' } ],
+                                    initialValue: theData.text
+                                })(<Input placeholder="请输入轮播图名称"/>)}
+                            </FormItem>
+                        </div>
+                        <div className="clearfix">
+                            <FormItem {...formItemLayout} label="跳转地址">
+                                {getFieldDecorator('forwardUrl', {
+                                    rules: [ { required: true, message: '此项为必填项!' } ],
+                                    initialValue: theData.forwardUrl
+                                })(<Input placeholder="请输入跳转地址"/>)}
+                            </FormItem>
+                        </div>
+                        <div className="clearfix">
+                            <FormItem  {...formItemLayout} label="api">
+                                {getFieldDecorator('apiUrl', {
+                                    rules: [ { required: true, message: '此项为必填项!' } ],
+                                    initialValue: theData.apiUrl
+                                })(<Input placeholder="请输入api"/>)}
+                            </FormItem>
+                        </div>
+                        <div className="clearfix">
+                            <FormItem  {...formItemLayout} label="位置">
+                                {getFieldDecorator('client', {
+                                    rules: [ { required: true, message: '此项为必填项!' } ],
+                                    initialValue: theData.client 
+                                })(
+                                    <Radio.Group>
+                                        <Radio value={0}>网站</Radio>
+                                        <Radio value={1}>App</Radio>
+                                    </Radio.Group>
+                                    )
+                                }
+                            </FormItem>
+                        </div>
+                        <div className="clearfix">
+                            <FormItem labelCol={{ span: 6 }} wrapperCol={{ span: 18 }} label={<span><strong style={{color:"#f00"}}> * </strong>轮播图</span>}>
+                                <PicturesWall
+                                    fileList={(e)=>{this.setState({imgUrl:e})}}
+                                    pictureUrl={this.state.imgUrl}
+                                    visible={this.props.visible}
+                                />
+                            </FormItem>
+                        </div>
+                        <div className="clearfix">
+                            <FormItem wrapperCol={{ span: 12, offset: 6 }}>
+                                <Button className="set-submit" type="primary" htmlType="submit">
+                                    保存
+                                </Button>
+                                <Button className="set-submit" type="ghost" onClick={this.cancelFun.bind(this)}>
+                                    取消
+                                </Button>
+                            </FormItem>
+                        </div>
+                    </Spin>
+                </Form>    
 			</div>
 		);
 	}