Browse Source

前端客户和私有客户增加客户性质级联选择

dev01 1 week ago
parent
commit
18daf360bf

+ 144 - 7
js/component/common/enterpriseNameChange/inforChange.jsx

@@ -23,6 +23,17 @@ const Option = Select.Option;
 class InforChange extends Component {
   constructor(props) {
     super(props);
+    let nature = [];
+    if (props.data.nature !== undefined || props.data.nature !== null) {
+      nature.push(props.data.nature);
+    }
+    if (props.data.enterpriseNature !== undefined || props.data.enterpriseNature !== null) {
+      nature.push(props.data.enterpriseNature);
+    }
+    if (props.data.listedNature !== undefined || props.data.listedNature !== null) {
+      nature.push(props.data.listedNature);
+    }
+
     this.state = {
       visible: false,
       changeType: 0,
@@ -68,8 +79,80 @@ class InforChange extends Component {
       businessScope: props.data.businessScope,
       intendedProject: props.data.intendedProject,
       industryName: props.data.industry,
-      nature: props.data.nature,
+      nature: nature,
+      natureText: "",
       natureOther: props.data.natureOther,
+
+      natureOptions: [{
+        value: 1,
+        label: "政府机构"
+      }, {
+        value: 2,
+        label: "科研院所"
+      }, {
+        value: 3,
+        label: "高等院校"
+      }, {
+        value: 4,
+        label: "社会团体"
+      }, {
+        value: 5,
+        label: "企业",
+        children: [{
+          value: 1,
+          label: "国企",
+          children: [{
+            value: 1,
+            label: "上市公司",
+          }, {
+            value: 0,
+            label: "非上市公司",
+          }]
+        }, {
+          value: 2,
+          label: "央企",
+          children: [{
+            value: 1,
+            label: "上市公司",
+          }, {
+            value: 0,
+            label: "非上市公司",
+          }]
+        }, {
+          value: 3,
+          label: "私企",
+          children: [{
+            value: 1,
+            label: "上市公司",
+          }, {
+            value: 0,
+            label: "非上市公司",
+          }]
+        }, {
+          value: 4,
+          label: "合资企业(含港澳台)",
+          children: [{
+            value: 1,
+            label: "上市公司",
+          }, {
+            value: 0,
+            label: "非上市公司",
+          }]
+        }, {
+          value: 5,
+          label: "外资控股",
+          children: [{
+            value: 1,
+            label: "上市公司",
+          }, {
+            value: 0,
+            label: "非上市公司",
+          }]
+        }]
+      }, {
+        value: 0,
+        label: "其他组织"
+      }]
     }
     this.onChange = this.onChange.bind(this);
     this.onCancel = this.onCancel.bind(this);
@@ -83,6 +166,11 @@ class InforChange extends Component {
     this.onSelect = this.onSelect.bind(this);
   }
 
+  componentDidMount() {
+    let natureText = this.getNatureText(this.state.nature);
+    this.setState({ natureText });
+  }
+
   onChange(type) {
     if (!this.props.data.level && this.props.data.level != 0) {
       Modal.warning({
@@ -206,8 +294,18 @@ class InforChange extends Component {
       data.industry = dataArrar
     }
     if (this.state.changeType === 5) {
-      data.nature = dataArrar
-      data.natureOther = this.state.natureOther
+      let enterpriseNature = undefined; // 企业性质 0=其他,1=国企,2=央企,3=私企,4=合资企业(含港澳台),5=外资控股
+      let listedNature = undefined; // 上市 0=否,1=是
+      if (dataArrar.length >= 2) {
+        enterpriseNature = dataArrar[1];
+      }
+      if (dataArrar.length >= 3) {
+        listedNature = dataArrar[2];
+      }
+      data.nature = dataArrar[0];
+      data.enterpriseNature = enterpriseNature;
+      data.listedNature = listedNature;
+      data.natureOther = this.state.natureOther;
     }
     $.ajax({
       url: globalConfig.context + "/api/admin/customer/updateUserDate",
@@ -252,10 +350,11 @@ class InforChange extends Component {
           }
           if (this.state.changeType === 5) {
             this.setState({
-              natureText: getNatureType(dataArrar, this.state.natureOther)
+              natureText: this.getNatureText(dataArrar)
             })
           }
           this.onCancel();
+          
         } else {
           message.warning(data.error[0].message);
         }
@@ -263,6 +362,39 @@ class InforChange extends Component {
     )
   }
 
+  /**
+   * 转译客户性质
+   * @param {*} value 
+   * @returns 
+   */
+  getNatureText(value) {
+    if (value.length === 1 && value[0] === 0) {
+      // 其他
+      return `其他(${this.state.natureOther})`;
+    } else {
+      let text = [];
+      let level = 0;
+      const loopData = (data) => {
+        for (let i=0; i<data.length; i++) {
+          let item = data[i];
+          if (item.value === value[level]) {
+            text.push(item.label);
+            if (item.children) {
+              level += 1;
+              loopData(item.children)
+            }
+            break;
+          }
+        }
+      }
+  
+  
+      loopData(this.state.natureOptions);
+  
+      return text.join("/");
+    }
+  }
+
   showInput() {
     let str = this.state.dataArrar.join('/')
     this.setState({
@@ -598,7 +730,7 @@ class InforChange extends Component {
                                 : this.state.changeType === 5 ?
                                   <div>
                                     <div>
-                                      <Select
+                                      {/* <Select
                                         style={{ width: 200 }}
                                         placeholder="请选择客户性质"
                                         onChange={e => {
@@ -612,10 +744,15 @@ class InforChange extends Component {
                                             return <Option key={item.value} value={item.value}>{item.key}</Option>
                                           })
                                         }
-                                      </Select>
+                                      </Select> */}
+                                      <Cascader
+                                        options={this.state.natureOptions}
+                                        placeholder="请选择客户性质"
+                                        onChange={e => { this.setState({ dataArrar: e }) }}
+                                      />
                                     </div>
                                     {
-                                      this.state.dataArrar === '0' &&
+                                      !!this.state.dataArrar && this.state.dataArrar[0] == 0 &&
                                       <div>
                                         <TextArea
                                           style={{ width: '300px', height: '100px' }}

+ 92 - 5
js/component/manageCenter/customer/NEW/intentionCustomer/addIntention.jsx

@@ -16,7 +16,77 @@ const AchievementDetailForm = Form.create()(React.createClass({
       businessScope: [],
       inputVisible: false,
       cooperationProjects: [],
-      selectCooperationProjects: []
+      selectCooperationProjects: [],
+      natureOptions: [{
+        value: 1,
+        label: "政府机构"
+      }, {
+        value: 2,
+        label: "科研院所"
+      }, {
+        value: 3,
+        label: "高等院校"
+      }, {
+        value: 4,
+        label: "社会团体"
+      }, {
+        value: 5,
+        label: "企业",
+        children: [{
+          value: 1,
+          label: "国企",
+          children: [{
+            value: 1,
+            label: "上市公司",
+          }, {
+            value: 0,
+            label: "非上市公司",
+          }]
+        }, {
+          value: 2,
+          label: "央企",
+          children: [{
+            value: 1,
+            label: "上市公司",
+          }, {
+            value: 0,
+            label: "非上市公司",
+          }]
+        }, {
+          value: 3,
+          label: "私企",
+          children: [{
+            value: 1,
+            label: "上市公司",
+          }, {
+            value: 0,
+            label: "非上市公司",
+          }]
+        }, {
+          value: 4,
+          label: "合资企业(含港澳台)",
+          children: [{
+            value: 1,
+            label: "上市公司",
+          }, {
+            value: 0,
+            label: "非上市公司",
+          }]
+        }, {
+          value: 5,
+          label: "外资控股",
+          children: [{
+            value: 1,
+            label: "上市公司",
+          }, {
+            value: 0,
+            label: "非上市公司",
+          }]
+        }]
+      }, {
+        value: 0,
+        label: "其他组织"
+      }]
     };
   },
   handleSubmit(e) {
@@ -95,6 +165,16 @@ const AchievementDetailForm = Form.create()(React.createClass({
       for (let i of this.state.selectCooperationProjects) {
         arr.push(i.label)
       }
+
+      let enterpriseNature = undefined; // 企业性质 0=其他,1=国企,2=央企,3=私企,4=合资企业(含港澳台),5=外资控股
+      let listedNature = undefined; // 上市 0=否,1=是
+      if (this.state.nature.length >= 2) {
+        enterpriseNature = this.state.nature[1];
+      }
+      if (this.state.nature.length >= 3) {
+        listedNature = this.state.nature[2];
+      }
+
       if (!err) {
         this.setState({
           loading: true
@@ -119,8 +199,10 @@ const AchievementDetailForm = Form.create()(React.createClass({
             businessScope: this.state.businessScope.join(','),
             position: values.position,
             level: this.state.level,
-            nature: this.state.nature,
+            nature: this.state.nature[0],
             natureOther: this.state.natureOther,
+            enterpriseNature,
+            listedNature,
           }
         }).done(function (data) {
           this.setState({
@@ -532,7 +614,7 @@ const AchievementDetailForm = Form.create()(React.createClass({
                   {...formItemLayout}
                   required
                   label="客户性质" >
-                  <Select
+                  {/* <Select
                     placeholder="请选择客户性质"
                     value={this.state.nature}
                     onChange={(e) => {
@@ -546,11 +628,16 @@ const AchievementDetailForm = Form.create()(React.createClass({
                     <Option value={5}>民营企业</Option>
                     <Option value={6}>社会团体</Option>
                     <Option value={0}>其他(请注明)</Option>
-                  </Select>
+                  </Select> */}
+                   <Cascader
+                      options={this.state.natureOptions}
+                      placeholder="请选择客户性质"
+                      onChange={e => { this.setState({ nature: e }) }}
+                    />
                 </FormItem>
               </div>
               {
-                this.state.nature == 0 &&
+                !!this.state.nature && this.state.nature[0] === 0 &&
                 <div className="clearfix">
                   <FormItem
                     className="mid-item"

+ 139 - 17
js/component/manageCenter/customer/NEW/intentionCustomer/intentionCustomer.jsx

@@ -46,6 +46,16 @@ const IntentionCustomer = Form.create()(
         modalVisible: false,
       });
       let api = apiUrl ? apiUrl : this.props.ApiUrl;
+
+      let enterpriseNature = undefined; // 企业性质 0=其他,1=国企,2=央企,3=私企,4=合资企业(含港澳台),5=外资控股
+      let listedNature = undefined; // 上市 0=否,1=是
+      if (this.state.nature && this.state.nature.length >= 2) {
+        enterpriseNature = this.state.nature[1];
+      }
+      if (this.state.nature && this.state.nature.length >= 3) {
+        listedNature = this.state.nature[2];
+      }
+
       $.ajax({
         method: "post",
         dataType: "json",
@@ -64,7 +74,9 @@ const IntentionCustomer = Form.create()(
             : this.state.addressSearch[1],
           startDate: this.state.releaseDate[0],
           endDate: this.state.releaseDate[1],
-          nature: this.state.nature,
+          nature: this.state.nature ? this.state.nature[0] : undefined,
+          enterpriseNature,
+          listedNature,
         },
         success: function (data) {
           ShowModal(this);
@@ -235,18 +247,17 @@ const IntentionCustomer = Form.create()(
             dataIndex: "nature",
             key: "nature",
             render: (text, record) => {
-              return <div>
-                {
-                  text == 0
-                    ? `其他(${record.natureOther})` : text == 1
-                      ? '政府机构' : text == 2
-                        ? '科研院所' : text == 3
-                          ? '高等院校' : text == 4
-                            ? '国有企业' : text == 5
-                              ? '民营企业' : text == 6
-                                ? '社会团体' : ''
-                }
-              </div>;
+              let natureArr = [];
+              if (record.nature !== undefined || record.nature !== null) {
+                natureArr.push(record.nature);
+              }
+              if (record.enterpriseNature !== undefined || record.enterpriseNature !== null) {
+                natureArr.push(record.enterpriseNature);
+              }
+              if (record.listedNature !== undefined || record.listedNature !== null) {
+                natureArr.push(record.listedNature);
+              }
+              return this.getNatureText(natureArr, record.natureOther);
             },
           },
           {
@@ -432,9 +443,112 @@ const IntentionCustomer = Form.create()(
         visitArrList: [],
         searchTime: [,],
         selList: [],
+        natureOptions: [{
+          value: 1,
+          label: "政府机构"
+        }, {
+          value: 2,
+          label: "科研院所"
+        }, {
+          value: 3,
+          label: "高等院校"
+        }, {
+          value: 4,
+          label: "社会团体"
+        }, {
+          value: 5,
+          label: "企业",
+          children: [{
+            value: 1,
+            label: "国企",
+            children: [{
+              value: 1,
+              label: "上市公司",
+            }, {
+              value: 0,
+              label: "非上市公司",
+            }]
+          }, {
+            value: 2,
+            label: "央企",
+            children: [{
+              value: 1,
+              label: "上市公司",
+            }, {
+              value: 0,
+              label: "非上市公司",
+            }]
+          }, {
+            value: 3,
+            label: "私企",
+            children: [{
+              value: 1,
+              label: "上市公司",
+            }, {
+              value: 0,
+              label: "非上市公司",
+            }]
+          }, {
+            value: 4,
+            label: "合资企业(含港澳台)",
+            children: [{
+              value: 1,
+              label: "上市公司",
+            }, {
+              value: 0,
+              label: "非上市公司",
+            }]
+          }, {
+            value: 5,
+            label: "外资控股",
+            children: [{
+              value: 1,
+              label: "上市公司",
+            }, {
+              value: 0,
+              label: "非上市公司",
+            }]
+          }]
+        }, {
+          value: 0,
+          label: "其他组织"
+        }]
       };
     },
 
+    /**
+     * 转译客户性质
+     * @param {*} value 
+     * @returns 
+     */
+    getNatureText(value, otherText) {
+      if (value.length && value[0] === 0) {
+        // 其他
+        return `其他组织(${otherText})`;
+      } else {
+        let text = [];
+        let level = 0;
+        const loopData = (data) => {
+          for (let i=0; i<data.length; i++) {
+            let item = data[i];
+            if (item.value === value[level]) {
+              text.push(item.label);
+              if (item.children) {
+                level += 1;
+                loopData(item.children)
+              }
+              break;
+            }
+          }
+        }
+    
+    
+        loopData(this.state.natureOptions);
+    
+        return text.join("/");
+      }
+    },
+
     //已读指导记录
     guidanceRead(id) {
       return new Promise((resolve, reject) => {
@@ -655,8 +769,10 @@ const IntentionCustomer = Form.create()(
       this.state.citySearch = undefined;
       this.state.releaseDate[0] = undefined;
       this.state.releaseDate[1] = undefined;
-      this.state.nature = undefined;
-      this.loadData();
+      this.setState({ nature: [] }, () => {
+        this.loadData();
+      });
+      
     },
     searchSwitch() {
       this.setState({
@@ -1077,7 +1193,7 @@ const IntentionCustomer = Form.create()(
                   }}
                 />
                 <span style={{ marginLeft: "10px" }}>
-                  <Select
+                  {/* <Select
                     placeholder="客户性质"
                     style={{ width: 110 }}
                     value={this.state.nature}
@@ -1092,7 +1208,13 @@ const IntentionCustomer = Form.create()(
                     <Option value={5}>民营企业</Option>
                     <Option value={6}>社会团体</Option>
                     <Option value={0}>其他</Option>
-                  </Select>
+                  </Select> */}
+                  <Cascader
+                    options={this.state.natureOptions}
+                    placeholder="请选择客户性质"
+                    value={this.state.nature}
+                    onChange={e => { this.setState({ nature: e }) }}
+                  />
                 </span>
                 <Button
                   type="primary"

+ 138 - 16
js/component/manageCenter/customer/NEW/signCustomer/signCustomer.jsx

@@ -41,6 +41,15 @@ const IntentionCustomer = Form.create()(React.createClass({
       modalVisible: false
     });
     let api = apiUrl ? apiUrl : this.props.ApiUrl;
+
+    let enterpriseNature = undefined; // 企业性质 0=其他,1=国企,2=央企,3=私企,4=合资企业(含港澳台),5=外资控股
+    let listedNature = undefined; // 上市 0=否,1=是
+    if (this.state.nature && this.state.nature.length >= 2) {
+      enterpriseNature = this.state.nature[1];
+    }
+    if (this.state.nature && this.state.nature.length >= 3) {
+      listedNature = this.state.nature[2];
+    }
     $.ajax({
       method: "post",
       dataType: "json",
@@ -55,7 +64,9 @@ const IntentionCustomer = Form.create()(React.createClass({
         city: !(this.state.addressSearch).length ? '' : this.state.addressSearch[1],
         startDate: this.state.releaseDate[0],
         endDate: this.state.releaseDate[1],
-        nature: this.state.nature,
+        nature: this.state.nature ? this.state.nature[0] : undefined,
+        enterpriseNature,
+        listedNature,
       },
       success: function (data) {
         ShowModal(this);
@@ -206,18 +217,17 @@ const IntentionCustomer = Form.create()(React.createClass({
           dataIndex: "nature",
           key: "nature",
           render: (text, record) => {
-            return <div>
-              {
-                text == 0
-                  ? `其他(${record.natureOther})` : text == 1
-                    ? '政府机构' : text == 2
-                      ? '科研院所' : text == 3
-                        ? '高等院校' : text == 4
-                          ? '国有企业' : text == 5
-                            ? '民营企业' : text == 6
-                              ? '社会团体' : ''
-              }
-            </div>;
+            let natureArr = [];
+            if (record.nature !== undefined || record.nature !== null) {
+              natureArr.push(record.nature);
+            }
+            if (record.enterpriseNature !== undefined || record.enterpriseNature !== null) {
+              natureArr.push(record.enterpriseNature);
+            }
+            if (record.listedNature !== undefined || record.listedNature !== null) {
+              natureArr.push(record.listedNature);
+            }
+            return this.getNatureText(natureArr, record.natureOther);
           },
         },
         {
@@ -338,8 +348,111 @@ const IntentionCustomer = Form.create()(React.createClass({
       data: [],
       dataSource: [],
       selList: [],
+      natureOptions: [{
+        value: 1,
+        label: "政府机构"
+      }, {
+        value: 2,
+        label: "科研院所"
+      }, {
+        value: 3,
+        label: "高等院校"
+      }, {
+        value: 4,
+        label: "社会团体"
+      }, {
+        value: 5,
+        label: "企业",
+        children: [{
+          value: 1,
+          label: "国企",
+          children: [{
+            value: 1,
+            label: "上市公司",
+          }, {
+            value: 0,
+            label: "非上市公司",
+          }]
+        }, {
+          value: 2,
+          label: "央企",
+          children: [{
+            value: 1,
+            label: "上市公司",
+          }, {
+            value: 0,
+            label: "非上市公司",
+          }]
+        }, {
+          value: 3,
+          label: "私企",
+          children: [{
+            value: 1,
+            label: "上市公司",
+          }, {
+            value: 0,
+            label: "非上市公司",
+          }]
+        }, {
+          value: 4,
+          label: "合资企业(含港澳台)",
+          children: [{
+            value: 1,
+            label: "上市公司",
+          }, {
+            value: 0,
+            label: "非上市公司",
+          }]
+        }, {
+          value: 5,
+          label: "外资控股",
+          children: [{
+            value: 1,
+            label: "上市公司",
+          }, {
+            value: 0,
+            label: "非上市公司",
+          }]
+        }]
+      }, {
+        value: 0,
+        label: "其他组织"
+      }]
     };
   },
+  
+  /**
+   * 转译客户性质
+   * @param {*} value 
+   * @returns 
+   */
+  getNatureText(value, otherText) {
+    if (value.length && value[0] === 0) {
+      // 其他
+      return `其他组织(${otherText})`;
+    } else {
+      let text = [];
+      let level = 0;
+      const loopData = (data) => {
+        for (let i=0; i<data.length; i++) {
+          let item = data[i];
+          if (item.value === value[level]) {
+            text.push(item.label);
+            if (item.children) {
+              level += 1;
+              loopData(item.children)
+            }
+            break;
+          }
+        }
+      }
+  
+  
+      loopData(this.state.natureOptions);
+  
+      return text.join("/");
+    }
+  },
   zhuanjiaoDetail(record) {
     this.setState({
       zhuanjiaoVisible: true,
@@ -439,7 +552,10 @@ const IntentionCustomer = Form.create()(React.createClass({
     this.state.releaseDate[0] = undefined;
     this.state.releaseDate[1] = undefined;
     this.state.nature = undefined;
-    this.loadData();
+
+    this.setState({ nature: []}, () => {
+      this.loadData();
+    });
   },
   searchSwitch() {
     this.setState({
@@ -754,7 +870,7 @@ const IntentionCustomer = Form.create()(React.createClass({
                 }}
               />
               <span style={{ marginLeft: "10px" }}>
-                <Select
+                {/* <Select
                   placeholder="客户性质"
                   style={{ width: 110 }}
                   value={this.state.nature}
@@ -769,7 +885,13 @@ const IntentionCustomer = Form.create()(React.createClass({
                   <Option value={5}>民营企业</Option>
                   <Option value={6}>社会团体</Option>
                   <Option value={0}>其他</Option>
-                </Select>
+                </Select> */}
+                 <Cascader
+                    options={this.state.natureOptions}
+                    placeholder="请选择客户性质"
+                    value={this.state.nature}
+                    onChange={e => { this.setState({ nature: e }) }}
+                  />
               </span>
               <Button
                 type="primary"