32 |
33 |
部门列表
34 | (
38 |
39 |
40 | {item.name}
41 |
42 |
43 | )}
44 | />
45 |
46 |
47 | )
48 | }
49 | }
50 |
51 | export default H5AppQSContacts
52 |
--------------------------------------------------------------------------------
/frontend/src/components/deplist.js:
--------------------------------------------------------------------------------
1 | import React from 'react';
2 | import { List, Spin, Avatar, Button } from 'antd';
3 | import * as dd from 'dingtalk-jsapi';
4 | import config from '../config.js'
5 |
6 | const host = config.host
7 | class H5AppQSDeplist extends React.Component {
8 | constructor(props) {
9 | super(props)
10 |
11 | this.state = {
12 | loading: false,
13 | users: [
14 | ],
15 | }
16 |
17 | this.openChat = this.openChat.bind(this);
18 | }
19 |
20 | componentDidMount() {
21 | this.setState({loading: true});
22 | // 单页应用使用首页地址做jsAPI鉴权
23 | dd.config({
24 | ...this.props.config,
25 | jsApiList: [
26 | 'biz.chat.openSingleChat'
27 | ]
28 | })
29 | dd.error(err => {
30 | alert('dd.config error: ' + JSON.stringify(err));
31 | });
32 |
33 | fetch(host + '/user/simplelist?department_id='+ this.props.deptId)
34 | .then(res => res.json())
35 | .then(result => {
36 | this.setState({
37 | users: result.result,
38 | loading: false
39 | })
40 | })
41 | }
42 |
43 | openChat(e, userid) {
44 | //alert(JSON.stringify(this.props.config));
45 | dd.biz.chat.openSingleChat({
46 | corpId: this.props.config.corpId, // 企业id,必须是用户所属的企业的corpid
47 | userId: userid, // 用户的工号
48 | onSuccess : function() {},
49 | onFail : function(err) {alert("fail:" + JSON.stringify(err));}
50 | }).catch(err => alert("exp:" + JSON.stringify(err) + JSON.stringify(this.props.config)))
51 | }
52 |
53 | render() {
54 | return (
55 |