index.js 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221
  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. getApp().globalData.Language.getLanguagePackage(this, 'E-订单');
  17. },
  18. getList() {
  19. _Http.basic({
  20. "id": 2022093010350 + id,
  21. content: {
  22. ownertable,
  23. ownerid,
  24. }
  25. }).then(res => {
  26. console.log(`数据团队${ownertable+ownerid}`, res)
  27. if (res.code != '1') {
  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. cancelText: getApp().globalData.Language.getMapText('取消'),
  77. confirmText: getApp().globalData.Language.getMapText('确定'),
  78. title: getApp().globalData.Language.getMapText('提示'),
  79. content: getApp().globalData.Language.joint([{
  80. t: 1,
  81. v: '是否确认添加',
  82. }, {
  83. v: value[0].length,
  84. f: "“",
  85. r: "”"
  86. }, {
  87. t: 1,
  88. v: '位成员',
  89. r: "?"
  90. }]),
  91. complete: ({
  92. confirm
  93. }) => {
  94. if (confirm) _Http.basic({
  95. "accesstoken": "7eb155cb0a9ed5895056afc151af7d7f",
  96. "id": 20220930103601,
  97. "content": {
  98. ownertable,
  99. ownerid,
  100. "userids": value[1],
  101. "justuserids": 1
  102. }
  103. }).then(res => {
  104. console.log("添加成员", res)
  105. wx.showToast({
  106. title: res.code == '1' ? getApp().globalData.Language.getMapText('添加成功') : res.msg,
  107. icon: "none",
  108. mask: true
  109. });
  110. if (res.code == '1') {
  111. that.getList()
  112. setTimeout(wx.navigateBack, 1000)
  113. }
  114. })
  115. }
  116. })
  117. },
  118. /* 设置负责人 */
  119. setLeader(e) {
  120. const {
  121. item
  122. } = e.currentTarget.dataset,
  123. that = this;
  124. wx.showModal({
  125. cancelText: getApp().globalData.Language.getMapText('取消'),
  126. confirmText: getApp().globalData.Language.getMapText('确定'),
  127. title: getApp().globalData.Language.getMapText('提示'),
  128. content: getApp().globalData.Language.joint([{
  129. t: 1,
  130. v: '是否确认将负责人转让到',
  131. }, {
  132. v: item.name,
  133. f: "“",
  134. r: "”"
  135. }]),
  136. complete: ({
  137. confirm
  138. }) => {
  139. if (confirm) _Http.basic({
  140. "id": 2022093010370 + id,
  141. "content": {
  142. ownertable,
  143. ownerid,
  144. "userid": item.userid
  145. }
  146. }).then(res => {
  147. wx.showToast({
  148. title: res.code == '1' ? getApp().globalData.Language.getMapText('转让成功') : res.msg,
  149. icon: "none",
  150. mask: true
  151. });
  152. if (res.code == '1') that.getList()
  153. })
  154. }
  155. })
  156. },
  157. /* 开启设置 */
  158. setTeam() {
  159. this.setData({
  160. manage: this.data.manage == '管理' ? '取消' : "管理"
  161. })
  162. },
  163. /* 选中成员 */
  164. toggle(event) {
  165. const {
  166. name
  167. } = event.currentTarget.dataset;
  168. let result = this.data.result;
  169. result.some(v => v == name) ? result = result.filter(v => v != name) : result.push(name);
  170. this.setData({
  171. result
  172. })
  173. },
  174. /* 移除成员 */
  175. onRemove() {
  176. let result = this.data.result,
  177. that = this;
  178. wx.showModal({
  179. cancelText: getApp().globalData.Language.getMapText('取消'),
  180. confirmText: getApp().globalData.Language.getMapText('确定'),
  181. title: getApp().globalData.Language.getMapText('提示'),
  182. content: getApp().globalData.Language.joint([{
  183. t: 1,
  184. v: '是否确认移除',
  185. }, {
  186. v: result.length,
  187. f: "“",
  188. r: "”"
  189. }, {
  190. t: 1,
  191. v: '位成员',
  192. r: "?"
  193. }]),
  194. complete: ({
  195. confirm
  196. }) => {
  197. if (confirm) _Http.basic({
  198. "id": 2022093010380 + id,
  199. "content": {
  200. ownertable,
  201. ownerid,
  202. "userids": result
  203. }
  204. }).then(res => {
  205. wx.showToast({
  206. title: res.code == '1' ? getApp().globalData.Language.getMapText('移除成功') : res.msg,
  207. icon: "none",
  208. mask: true
  209. });
  210. if (res.code == '1') {
  211. that.setData({
  212. result: []
  213. });
  214. that.getList()
  215. }
  216. })
  217. }
  218. })
  219. }
  220. })