index.js 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144
  1. const _Http = getApp().globalData.http;
  2. Component({
  3. options: {
  4. addGlobalClass: true
  5. },
  6. properties: {
  7. list: {
  8. type: Array
  9. },
  10. disabled: {
  11. type: Boolean
  12. },
  13. sa_workorderid: {
  14. type: [String, Number]
  15. },
  16. projectleader: {
  17. type: [String, Number]
  18. }
  19. },
  20. lifetimes: {
  21. attached: function () {
  22. getApp().globalData.Language.getLanguagePackage(this)
  23. }
  24. },
  25. data: {
  26. showTeams: false
  27. },
  28. methods: {
  29. selectTeams(e) {
  30. const {
  31. userid
  32. } = e.currentTarget.dataset.item;
  33. let teams = this.data.teams;
  34. let i = teams.findIndex(v => v == userid);
  35. if (i != -1) {
  36. teams = teams.filter(v => v != userid)
  37. } else {
  38. teams.push(userid)
  39. }
  40. this.setData({
  41. teams
  42. })
  43. },
  44. addUser() {
  45. _Http.basic({
  46. "id": 20220930103603,
  47. "content": {
  48. ownertable: 'sa_workorder',
  49. ownerid: this.data.sa_workorderid,
  50. "userids": this.data.teams,
  51. "justuserids": 1
  52. }
  53. }).then(res => {
  54. console.log("添加成员", res)
  55. wx.showToast({
  56. title: res.code == '1' ? getApp().globalData.Language.getMapText('修改成功') : res.msg,
  57. icon: "none",
  58. mask: true
  59. });
  60. if (res.code == '1') {
  61. this.showTeamDialog()
  62. getCurrentPages().find(v => v.__route__ == 'E-service/workOrder/detail').getDetail()
  63. }
  64. })
  65. },
  66. showTeamDialog() {
  67. if (!this.data.workers) _Http.basic({
  68. "id": "20230213143003",
  69. "version": 1,
  70. "content": {
  71. "where": {
  72. "condition": ""
  73. }
  74. }
  75. }).then(res => {
  76. console.log(res)
  77. this.setData({
  78. workers: res.data
  79. })
  80. })
  81. this.setData({
  82. showTeams: !this.data.showTeams,
  83. teams: this.data.list.map(v => v.userid)
  84. })
  85. },
  86. callPhone(e) {
  87. wx.makePhoneCall({
  88. phoneNumber: e.currentTarget.dataset.number
  89. })
  90. },
  91. changeLeader(e) {
  92. const {
  93. detail
  94. } = e.currentTarget.dataset;
  95. wx.showModal({
  96. title: getApp().globalData.Language.getMapText('提示'),
  97. content: getApp().globalData.Language.getMapText(`是否确认选择`) + getApp().globalData.Language.getMapText(detail.name) + getApp().globalData.Language.getMapText(`执行工单`) + '?',
  98. confirmBtn: getApp().globalData.Language.getMapText('确定'),
  99. cancelBtn: getApp().globalData.Language.getMapText('取消'),
  100. complete: ({
  101. confirm
  102. }) => {
  103. if (confirm) _Http.basic({
  104. "content": {
  105. "sa_workorderid": this.data.sa_workorderid,
  106. "userid": detail.userid
  107. },
  108. "id": 2026012714183302,
  109. }).then(res => {
  110. getApp().globalData.Language.showToast(res.code == '1' ? "操作成功" : res.msg)
  111. if (res.code == 1) getCurrentPages().find(v => v.__route__ == 'E-service/workOrder/detail').getDetail()
  112. })
  113. }
  114. })
  115. },
  116. deleteUser(e) {
  117. const {
  118. item
  119. } = e.currentTarget.dataset;
  120. wx.showModal({
  121. title: getApp().globalData.Language.getMapText('提示'),
  122. content: getApp().globalData.Language.getMapText(`是否确认移除`) + '“' + item.name + '”' + getApp().globalData.Language.getMapText(`团队成员`) + '?',
  123. confirmBtn: getApp().globalData.Language.getMapText('确定'),
  124. cancelBtn: getApp().globalData.Language.getMapText('取消'),
  125. complete: ({
  126. confirm
  127. }) => {
  128. if (confirm) _Http.basic({
  129. "id": 20220930103803,
  130. "content": {
  131. "ownertable": "sa_workorder",
  132. "ownerid": this.data.sa_workorderid,
  133. "userids": [item.userid]
  134. },
  135. }).then(res => {
  136. getApp().globalData.Language.showToast(res.code == '1' ? "操作成功" : res.msg)
  137. if (res.code == 1) getCurrentPages().find(v => v.__route__ == 'E-service/workOrder/detail').getDetail()
  138. })
  139. }
  140. })
  141. }
  142. }
  143. })