index.js 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192
  1. const _Http = getApp().globalData.http;
  2. Component({
  3. options: {
  4. addGlobalClass: true
  5. },
  6. properties: {
  7. disabled: {
  8. type: Boolean,
  9. value: true
  10. }
  11. },
  12. lifetimes: {
  13. attached: function () {
  14. getApp().globalData.Language.getLanguagePackage(this)
  15. },
  16. },
  17. data: {
  18. content: {
  19. nocache: true,
  20. pageNumber: 1,
  21. pageSize: 10,
  22. pageTotal: 1,
  23. total: null,
  24. where: {
  25. condition: ""
  26. }
  27. },
  28. list: [],
  29. showSearch: false,
  30. focus: false,
  31. condition: "",
  32. sa_competitor_advid: 0
  33. },
  34. methods: {
  35. toSearch() {
  36. if (this.data.showSearch && this.data.content.where.condition) {
  37. this.data.content.where.condition = '';
  38. this.getList("", true);
  39. } else if (this.data.condition) {
  40. this.data.content.where.condition = this.data.condition;
  41. this.setData({
  42. condition: this.data.condition
  43. })
  44. this.getList("", true);
  45. }
  46. this.setData({
  47. showSearch: !this.data.showSearch
  48. })
  49. setTimeout(() => {
  50. this.setData({
  51. focus: this.data.showSearch
  52. })
  53. }, 300)
  54. },
  55. onChange({
  56. detail
  57. }) {
  58. this.data.condition = detail;
  59. },
  60. onSearch({
  61. detail
  62. }) {
  63. this.data.content.where.condition = detail;
  64. this.getList("", true)
  65. },
  66. getList(id, init = false) {
  67. let content = this.data.content
  68. content.sa_competitorid = id || content.sa_competitorid;
  69. if (init) {
  70. content.pageNumber = 1
  71. content.pageTotal = 1
  72. }
  73. _Http.basic({
  74. "id": 2025031809222102,
  75. content
  76. }).then(res => {
  77. console.log("优劣势列表", res)
  78. if (res.code != '1') return wx.showToast({
  79. title: res.data,
  80. icon: "none"
  81. });
  82. content.pageNumber = res.pageNumber + 1
  83. content.pageTotal = res.pageTotal
  84. content.total = res.total
  85. let defaultItem = res.data.find(v => v.isdefault)
  86. if (defaultItem) this.setData({
  87. sa_competitor_advid: defaultItem.sa_competitor_advid
  88. })
  89. this.setData({
  90. list: res.pageNumber == 1 ? res.data : this.data.list.concat(res.data),
  91. content
  92. })
  93. })
  94. },
  95. /* 去添加 */
  96. toAdd() {
  97. wx.navigateTo({
  98. url: `/packageA/opponent/modules/aAD/insert?id=` + this.data.content.sa_competitorid,
  99. })
  100. },
  101. handleDelete(item) {
  102. let that = this;
  103. return new Promise((resolve) => {
  104. wx.showModal({
  105. title: getApp().globalData.Language.getMapText('提示'),
  106. content: getApp().globalData.Language.getMapText('是否确定删除该跟进动态'),
  107. complete: ({
  108. confirm
  109. }) => {
  110. if (confirm) {
  111. _Http.basic({
  112. "id": 20220930121701,
  113. "content": {
  114. "sys_datafollowupid": item.sys_datafollowupid,
  115. "ownertable": that.data.ownertable,
  116. "ownerid": that.data.ownerid,
  117. deletereason: ""
  118. }
  119. }).then(res => {
  120. console.log("删除", res);
  121. getApp().globalData.Language.showToast(res.code != 1 ? res.msg : "删除成功")
  122. resolve(res.code)
  123. if (res.msg != '成功') return;
  124. that.setData({
  125. list: that.data.list.filter(v => v.sys_datafollowupid != item.sys_datafollowupid),
  126. 'content.total': that.data.content.total - 1
  127. })
  128. })
  129. } else {
  130. resolve(0)
  131. }
  132. }
  133. })
  134. })
  135. },
  136. changeDefault({
  137. detail
  138. }) {
  139. _Http.basic({
  140. "content": {
  141. "sa_competitor_advid": detail
  142. },
  143. "id": 2025031809224302,
  144. }).then(res => {
  145. console.log("切换默认", res)
  146. this.updataDetail()
  147. })
  148. },
  149. handleItem(e) {
  150. console.log(e)
  151. const {
  152. item,
  153. name
  154. } = e.target.dataset,
  155. that = this;
  156. if (name == 'delete') {
  157. wx.showModal({
  158. content: getApp().globalData.Language.getMapText('是否确定删除') + '?',
  159. cancelText: getApp().globalData.Language.getMapText('取消'),
  160. confirmText: getApp().globalData.Language.getMapText('确定'),
  161. complete: ({
  162. confirm
  163. }) => {
  164. if (confirm) _Http.basic({
  165. "content": {
  166. "sa_competitor_advid": item.sa_competitor_advid
  167. },
  168. "id": 2025031809214002,
  169. }).then(res => {
  170. console.log("删除", res)
  171. getApp().globalData.Language.showToast(res.code != 1 ? res.msg : "删除成功")
  172. if (res.code == 1) {
  173. that.setData({
  174. list: that.data.list.filter(v => v.sa_competitor_advid != item.sa_competitor_advid),
  175. "content.total": that.data.content.total - 1
  176. })
  177. if (item.isdefault) this.updataDetail()
  178. }
  179. })
  180. }
  181. })
  182. } else {
  183. wx.navigateTo({
  184. url: `/packageA/opponent/modules/aAD/insert?id=` + that.data.content.sa_competitorid + '&data=' + JSON.stringify(item),
  185. })
  186. }
  187. },
  188. updataDetail() {
  189. getCurrentPages().find(v => v.__route__ == 'packageA/opponent/detail').getDetail()
  190. }
  191. }
  192. })