index.js 6.0 KB

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