Browse Source

公司名称不允许上传特殊字符

HW 4 years ago
parent
commit
404a47c8b5

+ 56 - 51
js/component/manageCenter/customer/NEW/intentionCustomer/addIntention.jsx

@@ -8,7 +8,7 @@ const AchievementDetailForm = Form.create()(React.createClass({
     getInitialState() {
         return {
             loading: false,
-            data: {},  
+            data: {},
             detailApi:''
         };
     },
@@ -19,11 +19,16 @@ const AchievementDetailForm = Form.create()(React.createClass({
         //   return;
         // }
     	e.preventDefault();
-        this.props.form.validateFields((err, values) => {   
+        this.props.form.validateFields((err, values) => {
         	if(values.name.length>64){
-    		message.warning('客户名称字数不超过64个')
+    		message.warning('公司名称字数不超过64个')
     		return false;
             };
+        	let regu = /[`~!#$%^&*'_[\]+=<>?:"{}|~!#¥%……&*=-@-!{}|/《》?:“”【】、;;‘’,,.。、\s+]/g;
+        	if(regu.test(values.name)){
+                message.warning('公司名称不能存在特殊符号!')
+                return false;
+            }
             if (/.*[\u4e00-\u9fa5]+.*$/.test(values.content)) {
             } else {
               message.error("请填写正确的联系人,且至少包含一个汉字");
@@ -51,7 +56,7 @@ const AchievementDetailForm = Form.create()(React.createClass({
                     crossDomain: false,
                     url: globalConfig.context + '/api/admin/customer/addCustomer',
                     data: {
-                        name: values.name, 
+                        name: values.name,
                         contacts:values.content,
                         contactMobile:values.telnum,
                         societyTag:values.societyTagt,
@@ -61,7 +66,7 @@ const AchievementDetailForm = Form.create()(React.createClass({
 						area:(values.ProvinceCity)[2],//区
                         type:'1'
                     }
-                }).done(function (data) { 
+                }).done(function (data) {
                     this.setState({
                         loading: false
                     });
@@ -88,10 +93,10 @@ const AchievementDetailForm = Form.create()(React.createClass({
 	    	this.state.content='';
 	    	this.state.telnum='';
 	    	this.state.societyTagt='0';
-            this.props.form.resetFields(); 
+            this.props.form.resetFields();
         };
     },
-    
+
     render() {
         const theData = this.state.data || {};
         const { getFieldDecorator } = this.props.form;
@@ -99,7 +104,7 @@ const AchievementDetailForm = Form.create()(React.createClass({
         const formItemLayout = {
             labelCol: { span: 6 },
             wrapperCol: { span: 14 },
-        };  
+        };
 
         return (
         <div>
@@ -120,10 +125,10 @@ const AchievementDetailForm = Form.create()(React.createClass({
 		                    </FormItem>
 	                    </div>
 	                    <div className="clearfix">
-	                    	<FormItem  
+	                    	<FormItem
 	                            {...formItemLayout}
 	                           label="省-市-区"
-	                          > 
+	                          >
 	                          {getFieldDecorator('ProvinceCity', {
 		                                rules: [{ required: true, message: '此项为必填项!' }],
 		                                initialValue: this.state.ProvinceCity
@@ -141,7 +146,7 @@ const AchievementDetailForm = Form.create()(React.createClass({
 		                                initialValue: this.state.content
 	                                })(
 	                                    <Input placeholder="联系人" />
-	                                )}     
+	                                )}
 		                    </FormItem>
 	                    </div>
 	                    <div className="clearfix">
@@ -153,19 +158,19 @@ const AchievementDetailForm = Form.create()(React.createClass({
 		                                initialValue: this.state.telnum
 	                                })(
 	                               		<Input placeholder="联系电话" />
-	                                )}        
+	                                )}
 		                    </FormItem>
 	                    </div>
 	                    <div className="clearfix">
-	                    	<FormItem className="mid-item" 
+	                    	<FormItem className="mid-item"
 	                          {...formItemLayout}
 	                           label="社会属性"
-	                         > 
+	                         >
 	                         {getFieldDecorator('societyTagt', {
 		                                rules: [{ required: true, message: '此项为必填项!' }],
 		                                initialValue: this.state.societyTagt
 	                                })(
-								  <Select placeholder="客户社会属性"> 
+								  <Select placeholder="客户社会属性">
 	                                {
 	                                    socialAttribute.map(function (item) {
 	                                        return <Select.Option key={item.value} >{item.key}</Select.Option>
@@ -175,11 +180,11 @@ const AchievementDetailForm = Form.create()(React.createClass({
 	                            )}
 	                   		 </FormItem>
 	                    </div>
-	                </div> 
+	                </div>
                     <FormItem wrapperCol={{ span: 12, offset: 6 }}>
-                        <Button type="primary" htmlType="submit" style={{marginRight:'50px'}}>保存</Button>  
+                        <Button type="primary" htmlType="submit" style={{marginRight:'50px'}}>保存</Button>
                         <Button type="ghost" onClick={this.props.closeDesc}>取消</Button>
-                    </FormItem> 
+                    </FormItem>
                 </Spin>
             </Form >
     	</div>
@@ -191,14 +196,14 @@ const AddPerson = Form.create()(React.createClass({
     getInitialState() {
         return {
             loading: false,
-            data: {},  
+            data: {},
             detailApi:''
         };
     },
 
     handleSubmit(e) {
         e.preventDefault();
-        this.props.form.validateFields((err, values) => { 
+        this.props.form.validateFields((err, values) => {
         	if(values.companyNamet.length>64){
     		message.warning('联系人字数不超过64个')
     		return false;
@@ -223,7 +228,7 @@ const AddPerson = Form.create()(React.createClass({
                     data: {
                         contacts:values.companyNamet,
                         societyTag:values.societyTagt,
-                        name: values.companyNamet, 
+                        name: values.companyNamet,
                         contactMobile: values.telnums,
                         source:values.customerSource,
                         province:(values.ProvinceCity)[0],//省
@@ -231,7 +236,7 @@ const AddPerson = Form.create()(React.createClass({
 						area:(values.ProvinceCity)[2],//区
                         type:'0'
                     }
-                }).done(function (data) { 
+                }).done(function (data) {
                     this.setState({
                         loading: false
                     });
@@ -257,10 +262,10 @@ const AddPerson = Form.create()(React.createClass({
 	    	this.state.telnum='';
 	    	this.state.societyTagt='0';
 	    	this.state.customerSource='0';
-            this.props.form.resetFields(); 
+            this.props.form.resetFields();
         };
     },
-    
+
     render() {
         const theData = this.state.data || {};
         const { getFieldDecorator } = this.props.form;
@@ -268,7 +273,7 @@ const AddPerson = Form.create()(React.createClass({
         const formItemLayout = {
             labelCol: { span: 6 },
             wrapperCol: { span: 14 },
-        };  
+        };
 
         return (
         <div>
@@ -278,20 +283,20 @@ const AddPerson = Form.create()(React.createClass({
 	                <div className="clearfix">
                     	<FormItem className="mid-item"
 	                            {...formItemLayout}
-	                            label="客户姓名" >   
+	                            label="客户姓名" >
 	                           {getFieldDecorator('companyNamet', {
 	                                rules: [{ required: true, message: '此项为必填项!' }],
 	                                initialValue: this.state.companyNamet
                                 })(
                                     <Input placeholder="客户姓名" />
-                                )} 
+                                )}
 	                    </FormItem>
 	                </div>
 	                <div className="clearfix">
-	                    	<FormItem  
+	                    	<FormItem
 	                            {...formItemLayout}
 	                           label="省-市-区"
-	                          > 
+	                          >
 	                          {getFieldDecorator('ProvinceCity', {
 		                                rules: [{ required: true, message: '此项为必填项!' }],
 		                                initialValue: this.state.ProvinceCity
@@ -309,19 +314,19 @@ const AddPerson = Form.create()(React.createClass({
 	                                initialValue: this.state.telnums
                                 })(
                                     <Input placeholder="联系电话" />
-                                )} 
+                                )}
 	                    </FormItem>
                     </div>
                     <div className="clearfix">
-                    	<FormItem className="mid-item" 
+                    	<FormItem className="mid-item"
                           {...formItemLayout}
                            label="社会属性"
-                         > 
+                         >
                          {getFieldDecorator('societyTagt', {
 	                                rules: [{ required: true, message: '此项为必填项!' }],
 	                                initialValue: this.state.societyTagt
                                 })(
-							  <Select placeholder="客户社会属性"> 
+							  <Select placeholder="客户社会属性">
                                 {
                                     socialAttribute.map(function (item) {
                                         return <Select.Option key={item.value} >{item.key}</Select.Option>
@@ -332,15 +337,15 @@ const AddPerson = Form.create()(React.createClass({
                    		 </FormItem>
                     </div>
                     <div className="clearfix">
-                    	<FormItem className="mid-item" 
+                    	<FormItem className="mid-item"
                           {...formItemLayout}
                            label="客户来源"
-                         > 
+                         >
                          {getFieldDecorator('customerSource', {
 	                                rules: [{ required: true, message: '此项为必填项!' }],
 	                                initialValue: this.state.customerSource
                                 })(
-							  <Select placeholder="客户来源"> 
+							  <Select placeholder="客户来源">
                                 {
                                     customerSource.map(function (item) {
                                         return <Select.Option key={item.value} >{item.key}</Select.Option>
@@ -351,9 +356,9 @@ const AddPerson = Form.create()(React.createClass({
                    		 </FormItem>
 	                </div>
                     <FormItem wrapperCol={{ span: 12, offset: 6 }}>
-                        <Button style={{marginRight:'50px'}} type="primary" htmlType="submit">保存</Button>  
+                        <Button style={{marginRight:'50px'}} type="primary" htmlType="submit">保存</Button>
                         <Button  type="ghost" onClick={this.props.closeDesc}>取消</Button>
-                    </FormItem> 
+                    </FormItem>
                 </Spin>
             </Form >
     	</div>
@@ -366,10 +371,10 @@ const AddIntention = React.createClass({
         return {
             visible: false,
             tabsKey: 1,
-            loading: false,           
+            loading: false,
             dataSource: [],
         };
-    },    
+    },
     handleCancel(e) {
         this.setState({
             visible: false,
@@ -382,32 +387,32 @@ const AddIntention = React.createClass({
         });
         this.props.closeDesc(false, true);
     },
-    
+
     componentWillReceiveProps(nextProps) {
         if (!this.state.visible && nextProps.showDesc) {
             this.state.tabsKey = "1";
         };
-        this.state.visible = nextProps.showDesc; 
-        
+        this.state.visible = nextProps.showDesc;
+
     },
     render() {
-        
+
             return (
                 <div className="patent-desc">
                     <Modal maskClosable={false} visible={this.state.visible}
                         onOk={this.checkPatentProcess} onCancel={this.handleCancel}
                         width='600px'
-                        title='新建客户'                       
+                        title='新建客户'
                         footer=''
                         className="admin-desc-content">
-                        <Spin spinning={this.state.loading}>               
+                        <Spin spinning={this.state.loading}>
                             {this.props.api.indexOf('Personal')<0?<AchievementDetailForm
-                                data={this.props.data} 
+                                data={this.props.data}
                                 newmodal={this.props.newmodal}
                                 closeDesc={this.handleCancel}
                                 visible={this.state.visible}
-                                handleOk={this.handleOk} />:<AddPerson 
-                                	data={this.props.data} 
+                                handleOk={this.handleOk} />:<AddPerson
+                                	data={this.props.data}
 	                                newmodal={this.props.newmodal}
 	                                closeDesc={this.handleCancel}
 	                                visible={this.state.visible}
@@ -416,9 +421,9 @@ const AddIntention = React.createClass({
                         </Spin>
                     </Modal>
                 </div>
-            );        
+            );
     },
 });
 
 
-export default AddIntention;
+export default AddIntention;