Explorar el Código

Merge branch 'master' of http://git.ycjcjy.com/zhiyuxing/estateagents-admin-manager

魏超 hace 5 años
padre
commit
90fab0c4e5

+ 142
- 0
src/pages/customer/customerlist/components/attribution.jsx Ver fichero

@@ -0,0 +1,142 @@
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';
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
+
9
+const { Option } = Select;
10
+// eslint-disable-next-line @typescript-eslint/no-unused-vars
11
+const { Meta } = Card;
12
+
13
+/**
14
+ * 调整归属
15
+ *
16
+ * @param {*} props
17
+ * @returns
18
+ */
19
+class ModalAttribution extends React.Component {
20
+  constructor(props) {
21
+    super(props);
22
+    this.state = {
23
+       dataSource: { records: [] },
24
+       visibleData: { visible: false, customerId: '', realtyConsultant: '' },
25
+    }
26
+  }
27
+
28
+  // 挂载之后
29
+  componentDidMount() {
30
+    this.getList({ pageNumber: 1, pageSize: 5 })
31
+  }
32
+
33
+  componentDidUpdate(preProps, preState) {
34
+    if (this.props.visibleData.customerId !== preState.visibleData.customerId) {
35
+      this.getList({ pageNumber: 1, pageSize: 5 })
36
+      this.setState({ visibleData: this.props.visibleData });
37
+    }
38
+  }
39
+
40
+  // 弹框确定按钮
41
+  // eslint-disable-next-line react/sort-comp
42
+  handleOk() {
43
+    this.setState({ visibleData: { visible: false, customerId: '', realtyConsultant: '' } })
44
+  }
45
+
46
+  // 弹框取消按钮
47
+  handleCancel() {
48
+    this.setState({ visibleData: { visible: false, customerId: '', realtyConsultant: '' } })
49
+  }
50
+
51
+  getList(params) {
52
+    // 网路请求
53
+    request({ ...apis.customer.consultant, params: { ...params } }).then(res => {
54
+      this.setState({ dataSource: res })
55
+    }).catch(err => {
56
+      // eslint-disable-next-line no-unused-expressions
57
+      <Alert
58
+        style={{
59
+          marginBottom: 24,
60
+        }}
61
+        message={err}
62
+        type="error"
63
+        showIcon
64
+      />
65
+    })
66
+  }
67
+
68
+   // 分页
69
+  onChange(pageNum) {
70
+    this.getList({ pageNumber: pageNum, pageSize: 5 })
71
+  }
72
+
73
+  // 提交
74
+  submitGm() {
75
+    const { url, method } = apis.customer.recommendEdit
76
+    const tempUrl = url.substring(0, url.lastIndexOf('id')).concat(this.state.visibleData.customerId)
77
+
78
+    // 网路请求
79
+    request({ url: tempUrl, method, data: { ...this.state.visibleData } }).then(res => {
80
+      this.handleCancel()
81
+    }).catch(err => {
82
+      // eslint-disable-next-line no-unused-expressions
83
+      <Alert
84
+        style={{
85
+          marginBottom: 24,
86
+        }}
87
+        message={err}
88
+        type="error"
89
+        showIcon
90
+      />
91
+    })
92
+  }
93
+
94
+  render() {
95
+    const columns = [
96
+      {
97
+        title: '姓名',
98
+        dataIndex: 'name',
99
+        key: 'name',
100
+      },
101
+      {
102
+        title: '电话',
103
+        dataIndex: 'phone',
104
+        key: 'phone',
105
+      },
106
+      {
107
+        title: '部门',
108
+        dataIndex: 'department',
109
+        key: 'department',
110
+      },
111
+      {
112
+        title: '岗位',
113
+        dataIndex: 'post',
114
+        key: 'post',
115
+      },
116
+      {
117
+        title: '操作',
118
+        dataIndex: 'personId',
119
+        key: 'personId',
120
+        // eslint-disable-next-line no-nested-ternary
121
+        render: (_, record) => <><Button className={Styles.SubmitButton} onClick={() => this.submitGm()}>确定</Button></>,
122
+      },
123
+    ]
124
+    return (
125
+      <>
126
+        <Modal
127
+            title="选择置业顾问"
128
+            width={800}
129
+            destroyOnClose="true"
130
+            footer={null}
131
+            visible={this.state.visibleData.visible}
132
+            // onOk={() => this.handleOk()}
133
+            onCancel={(e) => this.handleCancel(e)}
134
+          >
135
+            <Table dataSource={this.state.dataSource.records} columns={columns} pagination={{ total: this.state.dataSource.total, onChange: e => this.onChange(e) }} />
136
+          </Modal>
137
+      </>
138
+    );
139
+  }
140
+}
141
+
142
+export default ModalAttribution

+ 154
- 0
src/pages/customer/customerlist/components/integralRecord.jsx Ver fichero

@@ -0,0 +1,154 @@
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';
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
+
9
+const { Option } = Select;
10
+// eslint-disable-next-line @typescript-eslint/no-unused-vars
11
+const { Meta } = Card;
12
+
13
+/**
14
+ * 积分记录
15
+ *
16
+ * @param {*} props
17
+ * @returns
18
+ */
19
+class ModalIntegralRecord extends React.Component {
20
+  constructor(props) {
21
+    super(props);
22
+    this.state = {
23
+       dataSource: { result: { records: [] }, totalPoints: 0 },
24
+       visibleData: { visible: false, customerId: '' },
25
+    }
26
+  }
27
+
28
+  // 挂载之后
29
+  componentDidMount() {
30
+    this.getList({ pageNumber: 1, pageSize: 5 })
31
+  }
32
+
33
+  componentDidUpdate(preProps, preState) {
34
+    console.log(this.props.visibleData)
35
+    if (this.props.visibleData.customerId !== preState.visibleData.customerId) {
36
+      this.getList({ pageNumber: 1, pageSize: 5 })
37
+      this.setState({ visibleData: this.props.visibleData });
38
+    }
39
+  }
40
+
41
+  // 弹框确定按钮
42
+  // eslint-disable-next-line react/sort-comp
43
+  handleOk() {
44
+    this.setState({ visibleData: { visible: false, customerId: '', realtyConsultant: '' } })
45
+  }
46
+
47
+  // 弹框取消按钮
48
+  handleCancel() {
49
+    this.setState({ visibleData: { visible: false, customerId: '', realtyConsultant: '' } })
50
+  }
51
+
52
+  getList(params) {
53
+    const { customerId } = this.state.visibleData
54
+    if (customerId === '' || customerId === undefined) {
55
+      return
56
+    }
57
+    // 网路请求
58
+    const { url, method } = apis.customer.taPointsRecords
59
+    const tempUrl = url.substring(0, url.lastIndexOf('id')).concat(customerId)
60
+
61
+    // 网路请求
62
+    request({ url: tempUrl, method, params: { ...params } }).then(res => {
63
+      this.setState({ dataSource: res })
64
+    }).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
+      />
74
+    })
75
+  }
76
+
77
+   // 分页
78
+  onChange(pageNum) {
79
+    this.getList({ pageNumber: pageNum, pageSize: 5 })
80
+  }
81
+
82
+  // 积分类型
83
+  showChangeType(str) { 
84
+
85
+    switch (str) {
86
+      case 'goods':
87
+        return '兑换商品'
88
+      case 'checkin':
89
+        return '签到'
90
+      case 'share-poster':
91
+        return '分享'
92
+      case 'signup-agent':
93
+        return '注册经纪人'
94
+      case 'recommend-customer':
95
+        return '推荐客户'
96
+      default:
97
+        return '未知类型'
98
+    }
99
+  }
100
+  
101
+  // 判断是否是 - 开头
102
+  subPoints(points) { 
103
+    let subStr = points.toString().substring(0, 1)
104
+    if (subStr === '-') {
105
+      return true
106
+    }
107
+    return false
108
+  }
109
+
110
+  render() {
111
+    const columns = [
112
+      {
113
+        title: '序号',
114
+        dataIndex: 'index',
115
+        key: 'index',
116
+      },
117
+      {
118
+        title: '积分类型',
119
+        dataIndex: 'changeType',
120
+        key: 'changeType',
121
+        render: (_, record) => { this.showChangeType(record.changeType) },
122
+      },
123
+      {
124
+        title: '积分变化',
125
+        dataIndex: 'pointsAmount',
126
+        key: 'pointsAmount',
127
+        render: (_, record) => { <span style={this.subPoints(record.pointsAmount) && {color: 'red'}}>{ record.pointsAmount }</span> },
128
+      },
129
+      {
130
+        title: '发生时间',
131
+        dataIndex: 'createDate',
132
+        key: 'createDate',
133
+        render: (_, record) => { moment(record.createDate).format('YYYY-MM-DD') },
134
+      },
135
+    ]
136
+    return (
137
+      <>
138
+        <Modal
139
+            title={ "当前可用积分:" + this.state.dataSource.totalPoints }
140
+            width={800}
141
+            destroyOnClose="true"
142
+            footer={null}
143
+            visible={this.state.visibleData.visible}
144
+            // onOk={() => this.handleOk()}
145
+            onCancel={(e) => this.handleCancel(e)}
146
+          >
147
+            <Table dataSource={this.state.dataSource.result.records} columns={columns} pagination={{ total: this.state.dataSource.result.total, onChange: e => this.onChange(e) }} />
148
+          </Modal>
149
+      </>
150
+    );
151
+  }
152
+}
153
+
154
+export default ModalIntegralRecord

+ 16
- 134
src/pages/customer/customerlist/index.jsx Ver fichero

@@ -5,140 +5,14 @@ import request from '../../../utils/request';
5 5
 import apis from '../../../services/apis';
6 6
 import Styles from './style.less';
7 7
 
8
+import Attribution from './components/attribution'
9
+import IntegralRecord from './components/integralRecord'
10
+
8 11
 
9 12
 const { Option } = Select;
10 13
 // eslint-disable-next-line @typescript-eslint/no-unused-vars
11 14
 const { Meta } = Card;
12 15
 
13
-/**
14
- * 调整归属
15
- *  (废弃, 后面研究)
16
- *
17
- * @param {*} props
18
- * @returns
19
- */
20
-class ModalTable extends React.Component {
21
-  constructor(props) {
22
-    super(props);
23
-    this.state = {
24
-       dataSource: { records: [] },
25
-       visibleData: { visible: false, customerId: '', realtyConsultant: '' },
26
-    }
27
-  }
28
-
29
-  // 挂载之后
30
-  componentDidMount() {
31
-    this.getList({ pageNumber: 1, pageSize: 5 })
32
-  }
33
-
34
-  componentDidUpdate(preProps, preState) {
35
-    if (this.props.visibleData.customerId !== preState.visibleData.customerId) {
36
-      this.getList({ pageNumber: 1, pageSize: 5 })
37
-      this.setState({ visibleData: this.props.visibleData });
38
-    }
39
-  }
40
-
41
-  // 弹框确定按钮
42
-  // eslint-disable-next-line react/sort-comp
43
-  handleOk() {
44
-    this.setState({ visibleData: { visible: false, customerId: '', realtyConsultant: '' } })
45
-  }
46
-
47
-  // 弹框取消按钮
48
-  handleCancel() {
49
-    this.setState({ visibleData: { visible: false, customerId: '', realtyConsultant: '' } })
50
-  }
51
-
52
-  getList(params) {
53
-    // 网路请求
54
-    request({ ...apis.customer.consultant, params: { ...params } }).then(res => {
55
-      this.setState({ dataSource: res })
56
-    }).catch(err => {
57
-      // eslint-disable-next-line no-unused-expressions
58
-      <Alert
59
-        style={{
60
-          marginBottom: 24,
61
-        }}
62
-        message={err}
63
-        type="error"
64
-        showIcon
65
-      />
66
-    })
67
-  }
68
-
69
-   // 分页
70
-  onChange(pageNum) {
71
-    this.getList({ pageNumber: pageNum, pageSize: 5 })
72
-  }
73
-
74
-  // 提交
75
-  submitGm() {
76
-    const { url, method } = apis.customer.recommendEdit
77
-    const tempUrl = url.substring(0, url.lastIndexOf('id')).concat(this.state.visibleData.customerId)
78
-
79
-    // 网路请求
80
-    request({ url: tempUrl, method, data: { ...this.state.visibleData } }).then(res => {
81
-      this.handleCancel()
82
-    }).catch(err => {
83
-      // eslint-disable-next-line no-unused-expressions
84
-      <Alert
85
-        style={{
86
-          marginBottom: 24,
87
-        }}
88
-        message={err}
89
-        type="error"
90
-        showIcon
91
-      />
92
-    })
93
-  }
94
-
95
-  render() {
96
-    const columns = [
97
-      {
98
-        title: '姓名',
99
-        dataIndex: 'name',
100
-        key: 'name',
101
-      },
102
-      {
103
-        title: '电话',
104
-        dataIndex: 'phone',
105
-        key: 'phone',
106
-      },
107
-      {
108
-        title: '部门',
109
-        dataIndex: 'department',
110
-        key: 'department',
111
-      },
112
-      {
113
-        title: '岗位',
114
-        dataIndex: 'post',
115
-        key: 'post',
116
-      },
117
-      {
118
-        title: '操作',
119
-        dataIndex: 'personId',
120
-        key: 'personId',
121
-        // eslint-disable-next-line no-nested-ternary
122
-        render: (_, record) => <><Button className={Styles.SubmitButton} onClick={() => this.submitGm()}>确定</Button></>,
123
-      },
124
-    ]
125
-    return (
126
-      <>
127
-        <Modal
128
-            title="选择置业顾问"
129
-            destroyOnClose="true"
130
-            footer={null}
131
-            visible={this.state.visibleData.visible}
132
-            // onOk={() => this.handleOk()}
133
-            onCancel={(e) => this.handleCancel(e)}
134
-          >
135
-            <Table dataSource={this.state.dataSource.records} columns={columns} pagination={{ total: this.state.dataSource.total, onChange: e => this.onChange(e) }} />
136
-          </Modal>
137
-      </>
138
-    );
139
-  }
140
-}
141
-
142 16
 /**
143 17
  *
144 18
  *
@@ -161,6 +35,12 @@ function body(props) {
161 35
 
162 36
   // 调整归属 ============= end
163 37
 
38
+  // 积分记录 ============  start
39
+  // eslint-disable-next-line react-hooks/rules-of-hooks
40
+  const [recordVisibleData, setRecordVisibleData] = useState({ visible: false, personId: '' })
41
+
42
+  // 积分记录 ============= end
43
+
164 44
   // eslint-disable-next-line react-hooks/rules-of-hooks
165 45
   useEffect(() => {
166 46
     getList({ pageNumber: 1, pageSize: 10, customerType })
@@ -272,13 +152,13 @@ function body(props) {
272 152
       // eslint-disable-next-line no-nested-ternary
273 153
       render: (_, record) => (
274 154
         <>
275
-          <sapn className={ customerType === 'private' ? Styles.text : Styles.displayS }>变更状态</sapn>
155
+          <Button className={ customerType === 'private' ? Styles.text : Styles.displayS } type="link">变更状态</Button>
276 156
           &nbsp;&nbsp;
277
-          <sapn className={ customerType === 'private' ? Styles.text : Styles.displayS } onClick={() => gM(record)}>调整归属</sapn>
157
+          <Button className={ customerType === 'private' ? Styles.text : Styles.displayS } type="link" onClick={() => gM(record)}>调整归属</Button>
278 158
           <br/>
279
-          <sapn className={ Styles.text }>查看详情</sapn>
159
+          <Button className={ customerType === 'private' ? Styles.text : Styles.displayS } type="link">查看详情</Button>
280 160
           &nbsp;&nbsp;
281
-          <sapn className={ Styles.text }>积分记录</sapn>
161
+          <Button className={ customerType === 'private' ? Styles.text : Styles.displayS } type="link" onClick={ () => setRecordVisibleData({ visible: true, customerId: record.customerId }) }>积分记录</Button>
282 162
         </>
283 163
       ),
284 164
     },
@@ -345,8 +225,10 @@ function body(props) {
345 225
       <Table dataSource={dataSource.records} columns={columns} pagination={{ total: dataSource.total, onChange }} />
346 226
 
347 227
         {/* 调整归属 */}
348
-        <ModalTable visibleData={gVisibleData} />
228
+        <Attribution visibleData={gVisibleData} />
349 229
 
230
+        {/* 积分记录 */}
231
+        <IntegralRecord visibleData={recordVisibleData} />
350 232
     </>
351 233
   );
352 234
 }

+ 4
- 0
src/services/apis.js Ver fichero

@@ -88,5 +88,9 @@ export default {
88 88
       method: 'PUT',
89 89
       url: `${prefix}/customer/recommend/edit/id`,
90 90
     },
91
+    taPointsRecords: {
92
+      method: 'GET',
93
+      url: `${prefix}/mine/taPointsRecords/id`,
94
+    },
91 95
   },
92 96
 }