index.js 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185
  1. const _Http = getApp().globalData.http;
  2. let ownertable = '',
  3. ownerid = '',
  4. id = "1";
  5. Page({
  6. data: {
  7. isleader: false,
  8. manage: "管理",
  9. result: []
  10. },
  11. onLoad(options) {
  12. ownertable = options.ownertable;
  13. ownerid = options.ownerid;
  14. if (options.ownertable == "sa_workorder") id = "3";
  15. this.getList();
  16. },
  17. getList() {
  18. _Http.basic({
  19. "id": 2022093010350 + id,
  20. content: {
  21. ownertable,
  22. ownerid,
  23. }
  24. }).then(res => {
  25. console.log(`数据团队${ownertable+ownerid}`, res)
  26. if (res.msg != '成功') {
  27. wx.showToast({
  28. title: res.msg,
  29. icon: "none",
  30. mask: true
  31. });
  32. return setTimeout(wx.navigateBack, 1500);
  33. } else {
  34. this.setData({
  35. list: res.data[0].team,
  36. isleader: res.data[0].teamleader[0].userid == wx.getStorageSync('userMsg').userid
  37. })
  38. }
  39. })
  40. },
  41. /* 添加成员 */
  42. insert() {
  43. let params = id == 3 ? {
  44. "id": "20230213143003",
  45. "version": 1,
  46. "content": {
  47. nocache: true,
  48. "where": {
  49. "condition": "",
  50. "isleader": 0
  51. }
  52. }
  53. } : {
  54. "id": 20221018122201,
  55. "content": {
  56. "ownertable": ownertable,
  57. "ownerid": ownerid,
  58. nocache: true,
  59. "where": {
  60. "condition": "",
  61. "withoutselect": 1
  62. }
  63. }
  64. };
  65. wx.navigateTo({
  66. url: `/select/contacts/index?params=${JSON.stringify(params)}`,
  67. })
  68. getApp().globalData.handleSelect = this.insertUser.bind(this);
  69. },
  70. insertUser({
  71. value
  72. }) {
  73. let that = this;
  74. wx.showModal({
  75. title: '提示',
  76. content: `是否确认添加${value[0]+value[0].length}位成员`,
  77. complete: ({
  78. confirm
  79. }) => {
  80. if (confirm) _Http.basic({
  81. "accesstoken": "7eb155cb0a9ed5895056afc151af7d7f",
  82. "id": 20220930103601,
  83. "content": {
  84. ownertable,
  85. ownerid,
  86. "userids": value[1],
  87. "justuserids": 1
  88. }
  89. }).then(res => {
  90. console.log("添加成员", res)
  91. wx.showToast({
  92. title: res.msg == '成功' ? '添加成功' : res.msg,
  93. icon: "none",
  94. mask: true
  95. });
  96. if (res.msg == '成功') {
  97. that.getList()
  98. setTimeout(wx.navigateBack, 1000)
  99. }
  100. })
  101. }
  102. })
  103. },
  104. /* 设置负责人 */
  105. setLeader(e) {
  106. const {
  107. item
  108. } = e.currentTarget.dataset,
  109. that = this;
  110. wx.showModal({
  111. title: '提示',
  112. content: `是否确认将负责人转让到“${item.name}”`,
  113. complete: ({
  114. confirm
  115. }) => {
  116. if (confirm) _Http.basic({
  117. "id": 2022093010370 + id,
  118. "content": {
  119. ownertable,
  120. ownerid,
  121. "userid": item.userid
  122. }
  123. }).then(res => {
  124. wx.showToast({
  125. title: res.msg == '成功' ? '转让成功' : res.msg,
  126. icon: "none",
  127. mask: true
  128. });
  129. if (res.msg == '成功') that.getList()
  130. })
  131. }
  132. })
  133. },
  134. /* 开启设置 */
  135. setTeam() {
  136. this.setData({
  137. manage: this.data.manage == '管理' ? '取消' : "管理"
  138. })
  139. },
  140. /* 选中成员 */
  141. toggle(event) {
  142. const {
  143. name
  144. } = event.currentTarget.dataset;
  145. let result = this.data.result;
  146. result.some(v => v == name) ? result = result.filter(v => v != name) : result.push(name);
  147. this.setData({
  148. result
  149. })
  150. },
  151. /* 移除成员 */
  152. onRemove() {
  153. let result = this.data.result,
  154. that = this;
  155. wx.showModal({
  156. title: '提示',
  157. content: `是否确认移除${result.length}位成员`,
  158. complete: ({
  159. confirm
  160. }) => {
  161. if (confirm) _Http.basic({
  162. "id": 2022093010380 + id,
  163. "content": {
  164. ownertable,
  165. ownerid,
  166. "userids": result
  167. }
  168. }).then(res => {
  169. wx.showToast({
  170. title: res.msg == '成功' ? '移除成功' : res.msg,
  171. icon: "none",
  172. mask: true
  173. });
  174. if (res.msg == '成功') {
  175. that.setData({
  176. result: []
  177. });
  178. that.getList()
  179. }
  180. })
  181. }
  182. })
  183. }
  184. })