import * as dd from 'dingtalk-jsapi'; import store from '@/store/index' let showAlert=true let message = { error: function (msg) { //进入项目初始化配置 uni.showToast({ title: msg, icon: "none" }); }, alert:function (message) { return new Promise((resolve, reject) => { if (showAlert){ dd.device.notification.alert({ message: message, title: "提示", buttonName: "收到", onSuccess : function(res) { // 调用成功时回调 console.log(res) }, onFail : function(err) { // 调用失败时回调 console.log(err) } }); } }) } } let selectD = { selectPeo: function (option) { return new Promise((resolve, reject) => { dd.biz.contact.complexPicker({ title: option.title ? option.title : "选择人员", //标题 corpId: store.state.corpId, //企业的corpId multiple: option.multiple ? option.multiple : true, //是否多选 limitTips: option.limitTips ? option.limitTips : "超出了", //超过限定人数返回提示 maxUsers: option.maxUsers ? option.maxUsers : 100, //最大可选人数 pickedUsers: option.pickedUsers ? option.pickedUsers : [], //已选用户 pickedDepartments: option.pickedDepartments ? option.pickedDepartments :[], //已选部门 disabledUsers: option.disabledUsers ? option.disabledUsers :[], //不可选用户 disabledDepartments: option.disabledDepartments ? option.disabledDepartments :[], //不可选部门 requiredUsers: option.requiredUsers ? option.requiredUsers :[], //必选用户(不可取消选中状态) requiredDepartments: option.requiredDepartments ? option.requiredDepartments :[], //必选部门(不可取消选中状态) appId: store.state.agentId, //微应用Id,企业内部应用查看AgentId permissionType: "GLOBAL", //可添加权限校验,选人权限,目前只有GLOBAL这个参数 responseUserOnly: true, //返回人,或者返回人和部门 startWithDepartmentId: 0, //仅支持0和-1 onSuccess: function (result) { // alert(JSON.stringify(result)) resolve(result); /** { selectedCount:1, //选择人数 users:[{"name":"","avatar":"","emplId ":""}],//返回选人的列表,列表中的对象包含name(用户名),avatar(用户头像),emplId(用户工号)三个字段 departments:[{"id":,"name":"","number":}]//返回已选部门列表,列表中每个对象包含id(部门id)、name(部门名称)、number(部门人数) } */ }, onFail: function (err) { alert("唤起联系人失败"); reject(err) } }); }) }, selectDept: function (option) { return new Promise((resolve, reject) => { dd.biz.contact.departmentsPicker({ title: option.title ? option.title : "选择部门", //标题 corpId: store.state.corpId, //企业的corpId multiple: option.multiple ? option.multiple : true, //是否多选 limitTips: option.limitTips ? option.limitTips : "超出了", //超过限定人数返回提示 maxDepartments: option.maxDepartments ? option.maxDepartments : 100, //最大可选部门 pickedDepartments: option.pickedDepartments ? option.pickedDepartments :[], //已选部门 disabledDepartments: option.disabledDepartments ? option.disabledDepartments :[], //不可选部门 requiredDepartments: option.requiredDepartments ? option.requiredDepartments :[], //必选部门(不可取消选中状态) appId: store.state.agentId, //微应用Id,企业内部应用查看AgentId permissionType: "GLOBAL", //可添加权限校验,选人权限,目前只有GLOBAL这个参数 onSuccess: function (result) { resolve(result); /** { "userCount":10, //选择人数。 "departments":[ { "number":10, "name":"班车2", "id":405921063 } ], //返回已选部门列表,列表中每个对象包含id (部门id)、name (部门名称)、number (部门人数)。 "departmentsCount":1 //选择的部门数。 } */ }, onFail: function (err) { alert("唤起部门失败"); reject(err) } }); }) }, } export default { message, selectD }