caipin 5 years ago
parent
commit
ea51d4f3c6

+ 3 - 4
src/common/axios_auth.js

@@ -16,10 +16,9 @@ axios.interceptors.request.use(config => {
     
     
 
-    // if(config.method === 'post'){
-    //     config.headers.csrf_token = 'xxx';
-    //     config.headers['Content-Type']='application/x-www-form-urlencoded';
-    // }
+    if(config.method === 'post'){
+        config.headers['Content-Type']='application/x-www-form-urlencoded';
+    }
     //console.log(config);
     //let requestName = config.method === 'post'?config.data.requestName :config.params.requestName
     //console.log(requestName);

+ 31 - 36
src/common/popups/company.js

@@ -1,44 +1,17 @@
 import React, { PureComponent, Fragment } from 'react';
 import { connect } from 'react-redux';
 import { Input, Cascader } from 'antd';
+import { actionCreators } from './store';
 
-
-const options = [
-    {
-        value: 'zhejiang',
-        label: '浙江',
-        children: [{
-            value: 'hangzhou',
-            label: '杭州',
-            children: [{
-                value: 'xihu',
-                label: '西湖',
-            }],
-        }],
-    },
-    {
-        value: 'jiangsu',
-        label: '江苏',
-        children: [{
-            value: 'nanjing',
-            label: '南京',
-            children: [{
-                value: 'zhonghuamen',
-                label: '中华门',
-            }],
-        }],
-    }
-];
+import options from './districtOptions.json';
 
 class company extends PureComponent {
 
-
-
-
     render() {
-        const { companyDetail } = this.props;
+        const { companyDetail,natureOptions,handleModifyCompany } = this.props;
         let companyDetail2 = companyDetail.toJS();
-
+        let natureOptions2 = natureOptions.toJS();
+      
         return (
             <Fragment>
 
@@ -78,10 +51,18 @@ class company extends PureComponent {
                             <div className="cldform-item">
                                 <div className="cldform-label">公司全称</div>
                                 <div className="cldform-control">
-                                    <Input id="2"
+
+                                {/* {false ?(<Input id="2"
                                         value={companyDetail2.companyname}
                                         onClick={() => console.log('false')}
                                         onChange={() => console.log('sdf')}
+                                    />):(<div onClick={() => console.log('false')} className="cldform-contarl-box cldform-contarl-textareabox"><span>张三</span></div>)} */}
+
+                                
+
+                                    <Input id="2"
+                                        value={companyDetail2.companyname}
+                                        onChange={(e) => handleModifyCompany('companyname',e)}
                                     />
                                 </div>
                             </div>
@@ -89,7 +70,8 @@ class company extends PureComponent {
                             <div className="cldform-item cldform-item-wauto">
                                 <div className="cldform-label">公司地区</div>
                                 <div className="cldform-control">
-                                    <Cascader options={options} defaultValue={['zhejiang', 'hangzhou', 'xihu']} placeholder="公司地区" />
+                                {/* {["19","292","3066"]} */}
+                                    <Cascader options={options} value={companyDetail2.district} style={{ width: '100%' }} placeholder="公司地区" />
 
                                 </div>
                             </div>
@@ -97,7 +79,7 @@ class company extends PureComponent {
                             <div className="cldform-item cldform-item-wauto">
                                 <div className="cldform-label">公司性质</div>
                                 <div className="cldform-control">
-                                    <Cascader options={options} placeholder="公司性质" />
+                                    <Cascader options={natureOptions2} value={[companyDetail2.nature]} placeholder="公司性质" style={{ width: '100%' }} />
                                 </div>
                             </div>
                             <div className="cldform-line"></div>
@@ -171,14 +153,27 @@ class company extends PureComponent {
     }
 }
 
+let delaySwitch = null;//延迟检索开关
+
 const mapStateToProps = (state) => {
     return {
         companyDetail: state.getIn(['popups', 'companyDetail']),
+        natureOptions: state.getIn(['popups', 'natureOptions']),
     }
 }
 
 const mapDispathToProps = (dispatch) => {
-    return {}
+    return {
+        handleModifyCompany(name, e) {
+            let value=e.target.value;
+            if (delaySwitch != null) {
+                clearTimeout(delaySwitch);
+              }
+              delaySwitch = setTimeout(() => {
+                dispatch(actionCreators.modifyCompany(name, value));
+              }, 350);
+          },
+    }
 }
 
 export default connect(mapStateToProps, mapDispathToProps)(company);

File diff suppressed because it is too large
+ 16949 - 0
src/common/popups/districtOptions.json


+ 1 - 1
src/common/popups/index.js

@@ -41,7 +41,7 @@ class popups extends PureComponent {
 
                     {mainView === 'client' && <Client />}
                     {mainView === 'company' && <Company />}
-
+                    {mainView === 'lockDetail' && <LockDetail />}
 
 
 

+ 3 - 0
src/common/popups/popups.css

@@ -0,0 +1,3 @@
+.zindex {
+    z-index: 99999999;
+  }

+ 25 - 1
src/common/popups/store/actionCreators.js

@@ -3,6 +3,7 @@ import { fromJS } from 'immutable';
 import * as config from '../../../common/config.js';
 import axios from '../../../common/axios_auth.js';
 
+//获得公司详情
 export const getCompanyDetail = (key,error) => {
     return (dispatch) => {
         axios.get(config.CLD2API + '/contact/companyDetail/'+key).then((res) => {
@@ -20,7 +21,6 @@ export const getCompanyDetail = (key,error) => {
         })
     }
 };
-
 //loading
 export const changeLoading = () => {
     return (dispatch) => {
@@ -30,6 +30,30 @@ export const changeLoading = () => {
         });
     }
 }
+//
+export const modifyCompany = (name,value) => {
+    return (dispatch) => {
+
+        let data = {
+            'username': name,
+            'password': value,
+        };
+        console.log(name+value);
+        axios.post(config.CLD2API + '/contact/modifyCompany/', qs.stringify(data)).then((res) => {
+            const data = res.data;
+            if (data.code === 200) {
+                // dispatch({
+                //     type: constants.CHANGE_COMPANY_DETAIL,
+                //     data: data.data,
+                // });
+            } else {
+                error('公司详情更新失败');
+            }
+        }).catch((e) => {
+            error('公司详情更新失败');
+        })
+    }
+}
 
 
 

+ 19 - 3
src/common/popups/store/reducer.js

@@ -4,12 +4,28 @@ import { fromJS } from 'immutable';
 
 const defaultState = fromJS({
 	popupsClientId: '',
-	companyDetail: {staffDetial:{}},
+	companyDetail: { staffDetial: {} },
 	loading: true,
-	districtOptions:[],
+	districtOptions: [],
+	natureOptions: [
+		{ "value": '设计', "label": "设计" }, 
+		{ "value": '造价管理', "label": "造价管理" }, 
+		{ "value": '业主', "label": "业主" }, 
+		{ "value": '交通局', "label": "交通局" }, 
+		{ "value": '公路局', "label": "公路局" }, 
+		{ "value": '审计', "label": "审计" }, 
+		{ "value": '财政', "label": "财政" }, 
+		{ "value": '审核', "label": "审核" }, 
+		{ "value": '施工', "label": "施工" }, 
+		{ "value": '咨询', "label": "咨询" }, 
+		{ "value": '招标代理', "label": "招标代理" }, 
+		{ "value": '监理', "label": "监理" }, 
+		{ "value": '学校', "label": "学校" }, 
+		{ "value": '个人', "label": "个人" }, 
+		{ "value": '合作伙伴', "label": "合作伙伴" }, 
+	],
 });
 
-
 export default (state = defaultState, action) => {
 
 	switch (action.type) {

+ 0 - 1
src/contact/company/index.js

@@ -187,7 +187,6 @@ const mapStateToProps = (state) => {
     sortField: state.getIn(['company', 'sortField']),
     sort: state.getIn(['company', 'sort']),
     searchValue: state.getIn(['company', 'searchValue']),
-
     companyDetail: state.getIn(['popups', 'companyDetail']),
   }
 }

+ 1 - 1
src/login/store/actionCreators.js

@@ -29,7 +29,7 @@ export const login = (parameter) => {
         let csrftoken = cookie.load('csrfToken');
         axios.post(config.CLD2API + '/login', qs.stringify(data), {
             headers: {
-                'Content-Type': 'application/x-www-form-urlencoded',
+                //'Content-Type': 'application/x-www-form-urlencoded',
                 'x-csrf-token': csrftoken,
             },
         }).then((res) => {