index.js 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177
  1. const _Http = getApp().globalData.http;
  2. Component({
  3. options: {
  4. addGlobalClass: true
  5. },
  6. properties: {
  7. ownertable: {
  8. type: String
  9. },
  10. ownerid: {
  11. type: String
  12. },
  13. disabled: {
  14. type: Boolean,
  15. value: true
  16. }
  17. },
  18. lifetimes: {
  19. attached: function () {
  20. _Http.traceHandleDelete = this.handleDelete.bind(this);
  21. getApp().globalData.Language.getLanguagePackage(this)
  22. },
  23. detached: function () {
  24. delete _Http.traceHandleDelete
  25. },
  26. },
  27. data: {
  28. content: {
  29. nocache: true,
  30. pageNumber: 1,
  31. pageSize: 10,
  32. pageTotal: 1,
  33. total: null,
  34. where: {
  35. condition: ""
  36. }
  37. },
  38. list: [],
  39. showSearch: false,
  40. focus: false,
  41. condition: ""
  42. },
  43. methods: {
  44. toSearch() {
  45. if (this.data.showSearch && this.data.content.where.condition) {
  46. this.data.content.where.condition = '';
  47. this.getList("", true);
  48. } else if (this.data.condition) {
  49. this.data.content.where.condition = this.data.condition;
  50. this.setData({
  51. condition: this.data.condition
  52. })
  53. this.getList("", true);
  54. }
  55. this.setData({
  56. showSearch: !this.data.showSearch
  57. })
  58. setTimeout(() => {
  59. this.setData({
  60. focus: this.data.showSearch
  61. })
  62. }, 300)
  63. },
  64. onChange({
  65. detail
  66. }) {
  67. this.data.condition = detail;
  68. },
  69. onSearch({
  70. detail
  71. }) {
  72. this.data.content.where.condition = detail;
  73. this.getList("", true)
  74. },
  75. getList(id, init = false) {
  76. let content = {
  77. ...this.data.content,
  78. "ownertable": this.data.ownertable,
  79. "ownerid": this.data.ownerid,
  80. };
  81. if (init) {
  82. content.pageNumber = 1
  83. content.pageTotal = 1
  84. }
  85. _Http.basic({
  86. "id": 20220930121501,
  87. content
  88. }).then(res => {
  89. console.log("跟进动态", res)
  90. if (res.code != '1') return wx.showToast({
  91. title: res.data,
  92. icon: "none"
  93. });
  94. let deleteList = res.data.filter(v => v.content == "" && v.type == ""),
  95. list = res.data.filter(v => v.content != "" || !v.type == "");
  96. this.handleDeleteList(deleteList);
  97. this.setData({
  98. "content.pageNumber": res.pageNumber + 1,
  99. "content.pageTotal": res.pageTotal,
  100. "content.total": res.total - deleteList.length,
  101. list: res.pageNumber == 1 ? list : this.data.list.concat(list)
  102. })
  103. })
  104. },
  105. /* 批量删除空模板 */
  106. handleDeleteList(list) {
  107. list.forEach(v => {
  108. _Http.basic({
  109. "id": 20220930121701,
  110. "content": {
  111. "sys_datafollowupid": v.sys_datafollowupid,
  112. "deletereason": "系统删除空模板"
  113. }
  114. }, false).then(res => {
  115. console.log(res)
  116. })
  117. })
  118. },
  119. /* 去添加 */
  120. toAdd() {
  121. wx.navigateTo({
  122. url: `/packageA/setclient/modules/trace/add/index?ownertable=${this.data.ownertable}&ownerid=${this.data.ownerid}`,
  123. })
  124. },
  125. //跟进组件设置删除
  126. setDelete(id) {
  127. this.setData({
  128. list: this.data.list.filter(v => v.sys_datafollowupid != id)
  129. });
  130. wx.showToast({
  131. title: getApp().globalData.Language.getMapText('作废成功') + '!',
  132. icon: "none"
  133. })
  134. this.changeTotal()
  135. },
  136. changeTotal() {
  137. this.setData({
  138. "content.total": this.data.content.total - 1
  139. })
  140. },
  141. handleDelete(item) {
  142. let that = this;
  143. return new Promise((resolve) => {
  144. wx.showModal({
  145. title: getApp().globalData.Language.getMapText('提示'),
  146. content: getApp().globalData.Language.getMapText('是否确定删除该跟进动态'),
  147. complete: ({
  148. confirm
  149. }) => {
  150. if (confirm) {
  151. _Http.basic({
  152. "id": 20220930121701,
  153. "content": {
  154. "sys_datafollowupid": item.sys_datafollowupid,
  155. "ownertable": that.data.ownertable,
  156. "ownerid": that.data.ownerid,
  157. deletereason: ""
  158. }
  159. }).then(res => {
  160. console.log("删除", res);
  161. getApp().globalData.Language.showToast( res.code != 1 ? res.msg : "删除成功")
  162. resolve(res.code)
  163. if (res.msg != '成功') return;
  164. that.setData({
  165. list: that.data.list.filter(v => v.sys_datafollowupid != item.sys_datafollowupid),
  166. 'content.total': that.data.content.total - 1
  167. })
  168. })
  169. } else {
  170. resolve(0)
  171. }
  172. }
  173. })
  174. })
  175. },
  176. }
  177. })