Kaynağa Gözat

客户列表 变更状态

魏熙美 5 yıl önce
ebeveyn
işleme
955c82d6b4

+ 11
- 17
src/pages/building/type/edi.jsx Dosyayı Görüntüle

@@ -1,5 +1,5 @@
1 1
 import React, { useState, useEffect } from 'react';
2
-import { Input, Button, Row, Col, Form, Alert } from 'antd';
2
+import { Input, Button, Row, Col, Form, Alert, notification } from 'antd';
3 3
 import router from 'umi/router';
4 4
 import Styles from './style.less';
5 5
 import request from '../../../utils/request';
@@ -40,6 +40,14 @@ function body(props) {
40 40
     })
41 41
   }
42 42
 
43
+  const openNotificationWithIcon = (type, message) => {
44
+    notification[type]({
45
+      message,
46
+      description:
47
+        '',
48
+    });
49
+  }
50
+
43 51
   function submitData(dataSources) {
44 52
     if (id !== '') {
45 53
       // 修改
@@ -51,25 +59,11 @@ function body(props) {
51 59
     dataSources.createDate = new Date()
52 60
     request({ ...apis.buildingType.add, data: { ...dataSources } }).then(() => {
53 61
       // eslint-disable-next-line no-unused-expressions
54
-      <Alert
55
-        style={{
56
-          marginBottom: 24,
57
-        }}
58
-        message="操作成功"
59
-        type="success"
60
-        showIcon
61
-      />
62
+      this.openNotificationWithIcon('success', '操作成功')
62 63
       router.go(-1)
63 64
     }).catch(err => {
64 65
       // eslint-disable-next-line no-unused-expressions
65
-      <Alert
66
-        style={{
67
-          marginBottom: 24,
68
-        }}
69
-        message={ err }
70
-        type="err"
71
-        showIcon
72
-      />
66
+      this.openNotificationWithIcon('error', err)
73 67
     })
74 68
   }
75 69
 

+ 21
- 12
src/pages/customer/customerlist/components/attribution.jsx Dosyayı Görüntüle

@@ -1,5 +1,5 @@
1 1
 import React, { useState, useEffect } from 'react';
2
-import { Form, Icon, Input, Button, DatePicker, Select, Card, Row, Col, Pagination, Alert, Table, Avatar, Radio, Modal, Descriptions } from 'antd';
2
+import { Form, Icon, Input, Button, DatePicker, Select, Card, Row, Col, Pagination, Alert, Table, Avatar, Radio, Modal, Descriptions, notification } from 'antd';
3 3
 import moment from 'moment';
4 4
 import request from '../../../../utils/request';
5 5
 import apis from '../../../../services/apis';
@@ -31,6 +31,7 @@ class ModalAttribution extends React.Component {
31 31
   }
32 32
 
33 33
   componentDidUpdate(preProps, preState) {
34
+    console.log(this.props.visibleData.realtyConsultant)
34 35
     if (this.props.visibleData.customerId !== preState.visibleData.customerId) {
35 36
       this.getList({ pageNumber: 1, pageSize: 5 })
36 37
       this.setState({ visibleData: this.props.visibleData });
@@ -65,34 +66,42 @@ class ModalAttribution extends React.Component {
65 66
     })
66 67
   }
67 68
 
69
+  openNotificationWithIcon = (type, message) => {
70
+    notification[type]({
71
+      message,
72
+      description:
73
+        '',
74
+    });
75
+  };
76
+
68 77
    // 分页
69 78
   onChange(pageNum) {
70 79
     this.getList({ pageNumber: pageNum, pageSize: 5 })
71 80
   }
72 81
 
73 82
   // 提交
74
-  submitGm() {
83
+  submitGm(record) {
75 84
     const { url, method } = apis.customer.recommendEdit
76 85
     const tempUrl = url.substring(0, url.lastIndexOf('id')).concat(this.state.visibleData.customerId)
77 86
 
78 87
     // 网路请求
79
-    request({ url: tempUrl, method, data: { ...this.state.visibleData } }).then(res => {
88
+    request({ url: tempUrl, method, data: { customerId: this.state.visibleData.customerId, realtyConsultant: record.personId } }).then(res => {
89
+      // eslint-disable-next-line no-unused-expressions
90
+      this.openNotificationWithIcon('success', '操作成功')
80 91
       this.handleCancel()
81 92
     }).catch(err => {
82 93
       // eslint-disable-next-line no-unused-expressions
83
-      <Alert
84
-        style={{
85
-          marginBottom: 24,
86
-        }}
87
-        message={err}
88
-        type="error"
89
-        showIcon
90
-      />
94
+      this.openNotificationWithIcon('error', err)
91 95
     })
92 96
   }
93 97
 
94 98
   render() {
95 99
     const columns = [
100
+      // {
101
+      //   title: '编号',
102
+      //   dataIndex: 'personId',
103
+      //   key: 'personId',
104
+      // },
96 105
       {
97 106
         title: '姓名',
98 107
         dataIndex: 'name',
@@ -118,7 +127,7 @@ class ModalAttribution extends React.Component {
118 127
         dataIndex: 'personId',
119 128
         key: 'personId',
120 129
         // eslint-disable-next-line no-nested-ternary
121
-        render: (_, record) => <><Button className={Styles.SubmitButton} onClick={() => this.submitGm()}>确定</Button></>,
130
+        render: (_, record) => <>{ this.props.visibleData.realtyConsultant !== record.personId && <Button type="danger" onClick={() => this.submitGm(record)}>确定</Button>}</>,
122 131
       },
123 132
     ]
124 133
     return (

+ 84
- 0
src/pages/customer/customerlist/components/changeStatus.jsx Dosyayı Görüntüle

@@ -0,0 +1,84 @@
1
+import React, { useState, useEffect } from 'react';
2
+import { Form, Icon, Input, Button, DatePicker, Select, Card, Row, Col, Pagination, Alert, Table, Avatar, Radio, Modal, Descriptions, notification } from 'antd';
3
+import moment from 'moment';
4
+import request from '../../../../utils/request';
5
+import apis from '../../../../services/apis';
6
+import Styles from '../style.less';
7
+
8
+class ChangeStatus extends React.Component {
9
+  constructor(props) {
10
+    super(props)
11
+    this.state = {
12
+      value: '',
13
+      visibleData: { visible: false, customerId: '' },
14
+    }
15
+  }
16
+
17
+  componentDidUpdate(preProps, preState) {
18
+    if (this.props.visibleData.customerId !== preState.visibleData.customerId) {
19
+      this.setState({ visibleData: { ...this.props.visibleData } })
20
+      this.setState({ value: this.props.visibleData.status })
21
+    }
22
+  }
23
+
24
+  // 弹框取消按钮
25
+  handleCancel() {
26
+    this.setState({ visibleData: { visible: false, customerId: '' } })
27
+  }
28
+
29
+  onChange = e => {
30
+    this.setState({
31
+      value: e.target.value,
32
+    });
33
+  };
34
+
35
+  openNotificationWithIcon = (type, message) => {
36
+    notification[type]({
37
+      message,
38
+      description:
39
+        '',
40
+    });
41
+  };
42
+
43
+  submitButton = e => {
44
+    const { url, method } = apis.customer.recommendEdit
45
+    const tempUrl = url.substring(0, url.lastIndexOf('id')).concat(this.state.visibleData.customerId)
46
+
47
+    // 网路请求
48
+    request({ url: tempUrl, method, data: { customerId: this.state.visibleData.customerId, status: this.state.value } }).then(res => {
49
+      // eslint-disable-next-line no-unused-expressions
50
+      this.openNotificationWithIcon('success', '操作成功')
51
+      this.handleCancel()
52
+    }).catch(err => {
53
+      // eslint-disable-next-line no-unused-expressions
54
+      this.openNotificationWithIcon('error', err)
55
+    })
56
+  }
57
+
58
+  render() {
59
+    return (
60
+      <>
61
+          <Modal
62
+            title="变更状态"
63
+            width={800}
64
+            destroyOnClose="true"
65
+            footer={null}
66
+            visible={this.state.visibleData.visible}
67
+            // onOk={() => this.handleOk()}
68
+            onCancel={(e) => this.handleCancel(e)}
69
+          >
70
+            <Radio.Group onChange={this.onChange} value={this.state.value}>
71
+              <Radio value={1}>客户报备</Radio>
72
+              <Radio value={2}>客户到访</Radio>
73
+              <Radio value={3}>客户认购</Radio>
74
+              <Radio value={4}>客户签约</Radio>
75
+            </Radio.Group>
76
+
77
+            <Button type="danger" onClick={this.submitButton}>确定</Button>
78
+          </Modal>
79
+      </>
80
+    )
81
+  }
82
+}
83
+
84
+export default ChangeStatus

+ 10
- 11
src/pages/customer/customerlist/components/integralRecord.jsx Dosyayı Görüntüle

@@ -1,5 +1,5 @@
1 1
 import React, { useState, useEffect } from 'react';
2
-import { Form, Icon, Input, Button, DatePicker, Select, Card, Row, Col, Pagination, Alert, Table, Avatar, Radio, Modal, Descriptions } from 'antd';
2
+import { Form, Icon, Input, Button, DatePicker, Select, Card, Row, Col, Pagination, Alert, Table, Avatar, Radio, Modal, Descriptions, notification } from 'antd';
3 3
 import moment from 'moment';
4 4
 import request from '../../../../utils/request';
5 5
 import apis from '../../../../services/apis';
@@ -31,7 +31,6 @@ class ModalIntegralRecord extends React.Component {
31 31
   }
32 32
 
33 33
   componentDidUpdate(preProps, preState) {
34
-    console.log(this.props.visibleData)
35 34
     if (this.props.visibleData.customerId !== preState.visibleData.customerId) {
36 35
       this.getList({ pageNumber: 1, pageSize: 5 })
37 36
       this.setState({ visibleData: this.props.visibleData });
@@ -49,6 +48,14 @@ class ModalIntegralRecord extends React.Component {
49 48
     this.setState({ visibleData: { visible: false, customerId: '' } })
50 49
   }
51 50
 
51
+  openNotificationWithIcon = (type, message) => {
52
+    notification[type]({
53
+      message,
54
+      description:
55
+        '',
56
+    });
57
+  }
58
+
52 59
   getList(params) {
53 60
     const { customerId } = this.state.visibleData
54 61
     if (customerId === '' || customerId === undefined) {
@@ -62,15 +69,7 @@ class ModalIntegralRecord extends React.Component {
62 69
     request({ url: tempUrl, method, params: { ...params } }).then(res => {
63 70
       this.setState({ dataSource: res })
64 71
     }).catch(err => {
65
-      // eslint-disable-next-line no-unused-expressions
66
-      <Alert
67
-        style={{
68
-          marginBottom: 24,
69
-        }}
70
-        message={err}
71
-        type="error"
72
-        showIcon
73
-      />
72
+      this.openNotificationWithIcon('error', err)
74 73
     })
75 74
   }
76 75
 

+ 31
- 3
src/pages/customer/customerlist/index.jsx Dosyayı Görüntüle

@@ -7,6 +7,7 @@ import Styles from './style.less';
7 7
 
8 8
 import Attribution from './components/attribution'
9 9
 import IntegralRecord from './components/integralRecord'
10
+import ChangeStatus from './components/changeStatus'
10 11
 
11 12
 
12 13
 const { Option } = Select;
@@ -39,6 +40,11 @@ function body(props) {
39 40
   const [recordVisibleData, setRecordVisibleData] = useState({ visible: false, customerId: '' })
40 41
   // 积分记录 ============= end
41 42
 
43
+  // 变更状态 ============  start
44
+  // eslint-disable-next-line react-hooks/rules-of-hooks
45
+  const [statusVisibleData, setStatusVisibleData] = useState({ visible: false, customerId: '', status: '' })
46
+  // 变更状态 ============= end
47
+
42 48
   // eslint-disable-next-line react-hooks/rules-of-hooks
43 49
   useEffect(() => {
44 50
     getList({ pageNumber: 1, pageSize: 10, customerType })
@@ -61,8 +67,17 @@ function body(props) {
61 67
     })
62 68
   }
63 69
 
70
+  function displayNone() {
71
+    setRecordVisibleData({ visible: false, customerId: '' })
72
+    setGVisibleData({ visible: false, customerId: '', realtyConsultant: '' })
73
+    setStatusVisibleData({ visible: false, customerId: '', status: '' })
74
+  }
75
+
64 76
   // 提交事件
65 77
   function handleSubmit(e) {
78
+    displayNone()
79
+
80
+
66 81
     e.preventDefault();
67 82
     props.form.validateFields((err, values) => {
68 83
       if (!err) {
@@ -85,6 +100,8 @@ function body(props) {
85 100
 
86 101
   // 私客/公客切换
87 102
   function radioButtonHandleSizeChange(e) {
103
+    displayNone()
104
+
88 105
     const { value } = e.target
89 106
     setCustomerType(value)
90 107
     getList({ pageNumber: 1, pageSize: 10, customerType: value })
@@ -93,14 +110,22 @@ function body(props) {
93 110
   // 这里有个 Bug, 就是 Modal 弹框,会联动出现, 比如 我点击 调整归属的Model弹框, 那么 积分记录的Model弹框莫名其妙的也显示了
94 111
   // 所有这里临时解决方法是,弹出一个Modal对话框的时候,把其他的对话框给隐藏
95 112
 
96
-function showGM(record) {
113
+  function showGM(record) {
97 114
     setGVisibleData({ visible: true, customerId: record.customerId, realtyConsultant: record.realtyConsultant })
98 115
     setRecordVisibleData({ visible: false, customerId: '' })
116
+    setStatusVisibleData({ visible: false, customerId: '' })
99 117
   }
100 118
 
101 119
   function showRecord(record) {
102 120
     setRecordVisibleData({ visible: true, customerId: record.customerId })
103 121
     setGVisibleData({ visible: false, customerId: '', realtyConsultant: '' })
122
+    setStatusVisibleData({ visible: false, customerId: '' })
123
+  }
124
+
125
+  function showStatus(record) {
126
+    setRecordVisibleData({ visible: false, customerId: '' })
127
+    setGVisibleData({ visible: false, customerId: '', realtyConsultant: '' })
128
+    setStatusVisibleData({ visible: true, customerId: record.customerId, status: record.status })
104 129
   }
105 130
 
106 131
   const columns = [
@@ -156,7 +181,7 @@ function showGM(record) {
156 181
       // eslint-disable-next-line no-nested-ternary
157 182
       render: (_, record) => (
158 183
         <>
159
-          <Button className={ customerType === 'private' ? Styles.text : Styles.displayS } type="link">变更状态</Button>
184
+          <Button className={ customerType === 'private' ? Styles.text : Styles.displayS } type="link" onClick={() => showStatus(record)}>变更状态</Button>
160 185
           &nbsp;&nbsp;
161 186
           <Button className={ customerType === 'private' ? Styles.text : Styles.displayS } type="link" onClick={() => showGM(record)}>调整归属</Button>
162 187
           <br/>
@@ -214,7 +239,7 @@ function showGM(record) {
214 239
           )}
215 240
         </Form.Item>
216 241
         <Form.Item>
217
-          <Button type="primary" htmlType="submit" className={Styles.SubmitButton}>
242
+          <Button type="danger" htmlType="submit" >
218 243
             搜索
219 244
           </Button>
220 245
         </Form.Item>
@@ -233,6 +258,9 @@ function showGM(record) {
233 258
 
234 259
         {/* 积分记录 */}
235 260
         <IntegralRecord visibleData={recordVisibleData} />
261
+
262
+        {/* 变更状态 */}
263
+        <ChangeStatus visibleData={statusVisibleData} />
236 264
     </>
237 265
   );
238 266
 }