tb.js 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. var app = getApp();
  2. var that;
  3. var animation;
  4. Page({
  5. data: {
  6. tbList: [{
  7. id: 4,
  8. name: '仅同步指定部门内的人员信息(可多选)',
  9. kam: '该选择不会包含子部门人员,请确保选中需要同步的人员的直属部门',
  10. checked: true
  11. },
  12. {
  13. id: 3,
  14. name: '仅同步部门信息和上下级关系',
  15. kam: '仅同步所有部门名称和上下级所属关系,但不同步人员信息'
  16. },
  17. {
  18. id: 1,
  19. name: '同步全部部门和人员信息 ',
  20. kam: '同步全部信息所需时间较长,请关注同步成功后推送的工作通知'
  21. },
  22. ],
  23. defaultSection:[],
  24. popupCx: '',
  25. dept_ids:[],
  26. selectTbIndex:4,
  27. },
  28. onLoad(e) {
  29. that = this;
  30. dd.setNavigationBar({
  31. title: "钉钉通讯录同步"
  32. });
  33. },
  34. onShow() {
  35. animation = dd.createAnimation({
  36. duration: 200,
  37. timeFunction: "linear",
  38. });
  39. },
  40. //抢任务
  41. formSubmit() {
  42. let data={
  43. type:this.data.selectTbIndex,
  44. dept_list:this.data.dept_ids.toString(),
  45. }
  46. if(this.data.selectTbIndex==4&&this.data.dept_ids.length==0){
  47. app.globalData.showToast('请选择指定部门');
  48. return false
  49. }
  50. this.setData({ disabled: true })
  51. app.$post("api/ding/site_sync", data).then((res) => {
  52. app.globalData.showToast('同步中,成功后将发送工作通知');
  53. setTimeout(() => {
  54. dd.navigateBack({ delta: 1 })
  55. }, 500);
  56. }).finally(() => {
  57. that.setData({ disabled: false })
  58. });
  59. },
  60. radioChange(e) {
  61. this.setData({
  62. selectTbIndex:e.detail.value
  63. })
  64. },
  65. //选择弹窗
  66. openSelect(e) {
  67. if(this.data.selectTbIndex!=4){
  68. return false
  69. }
  70. animation.translateY(0).step();
  71. that.setData({
  72. isShowType: 1,
  73. popupCx: 'container__mask',
  74. animationInfo: animation.export()
  75. });
  76. },
  77. //关闭规则
  78. onClose() {
  79. animation.translateY(1200).step();
  80. that.setData({
  81. isShowType: '',
  82. popupCx: '',
  83. animationInfo: animation.export()
  84. });
  85. },
  86. //选择部门
  87. onSelectSection(e) {
  88. var arr = [];
  89. if (e.length > 0) {
  90. let names='';
  91. e.forEach(user => {
  92. arr.push(user.id);
  93. names+=(user.name+',')
  94. })
  95. that.setData({
  96. defaultSection: e,
  97. dept_ids: arr,
  98. deptNames:names
  99. })
  100. } else {
  101. that.setData({
  102. defaultSection: [],
  103. dept_ids: [],
  104. deptNames:''
  105. })
  106. }
  107. },
  108. });