index.js 5.5 KB

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