clientList.js
4.34 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
import React, { Component } from 'react';
import { connect } from 'dva';
import { routerRedux } from 'dva/router'
import { ActionSheet, Toast } from 'antd-mobile';
import shareHide from "../../utils/shareHide";
import { dataFilter } from '../../utils/dataFilter';
import MemberList from '../../components/MemberList/MemberList';
import css from './css.less'
// fix touch to scroll background page on iOS
const isIPhone = new RegExp('\\biPhone\\b|\\biPod\\b', 'i').test(window.navigator.userAgent);
let wrapProps;
if (isIPhone) {
wrapProps = {
onTouchStart: e => e.preventDefault(),
};
}
class ClientList extends Component {
constructor(props){
super(props)
this.state={
managerList: [],
storeManagerList: [],
show: false
}
}
showActionSheet = () => {
const BUTTONS = ['新增', '取消'];
ActionSheet.showActionSheetWithOptions({
options: BUTTONS,
cancelButtonIndex: BUTTONS.length - 1,
maskClosable: true,
'data-seed': 'logId',
wrapProps,
},
(buttonIndex) => {
// if (BUTTONS[buttonIndex] === '选择客户经理') {
// this.props.history.push('/governortraining/chooseclient');
// }
if (BUTTONS[buttonIndex] === '新增') {
window.localStorage.setItem('governortrainingClient', null);
this.props.history.push('/governortraining/addclient');
}
});
}
getManagerList() {
this.props.dispatch({
type: "governortraining/getManagerList",
payload: {
superiorid: window.localStorage.getItem("id")
},
callback: (res) => {
if (res.status) {
Toast.hide();
this.setState({
show:true,
managerList: res.data,
storeManagerList: res.data
})
}
}
})
}
componentDidMount() {
document.title = '我的客户经理';
shareHide();
Toast.loading('loading...', 99);
this.getManagerList();
}
componentWillUnmount(){
ActionSheet.close();
}
render() {
const _this = this;
return (
<div className={css.box}>
{this.state.managerList.length === 0 && this.state.show && <div className={css.clientless}>
<img src={require('../../assets/image/clientless.png')} alt="" className={css.client} />
<p>
您当前并无客户经理
</p>
<p>点击下方按钮添加</p>
<img src={require('../../assets/image/addUsers2.png')} alt="" className={css.add} onClick={() => {
this.showActionSheet()
}} />
</div>}
{
(this.state.managerList.length > 0) && this.state.show && < MemberList
height="74vh"
dataList={this.state.storeManagerList}
renderType={['name']}
filterData={(keywords) => {
this.setState({
storeManagerList: dataFilter(this.state.managerList, ['name'], keywords)
})
}}
renderItem={item => {
return <div className={css.managerItem} onClick={()=>{
let governortrainingClient = {...item ,disabled2:true};
localStorage.setItem('governortrainingClient', JSON.stringify(governortrainingClient));
this.props.dispatch(routerRedux.push('/governortraining/addclient'));
}}>
<span className={css.name}>{item.name}</span><span className={css.time}>{item.number}</span>
</div>
}}
handleEdit={(item) => {
window.localStorage.setItem('governortrainingClient', JSON.stringify(item));
this.props.dispatch(routerRedux.push('/governortraining/addclient'))
}}
handleAction={item => {
this.props.dispatch({
type: "governortraining/updateManager",
payload: {
id: item.id,
superiorid: -1
},
callback: (res) => {
if(res.status)
_this.getManagerList();
else
Toast.info(res.message,3)
}
})
}}
showActionSheet = {this.showActionSheet}
pTitle='客户经理' />
}
</div>
)
}
}
export default connect()(ClientList)