detail.js 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170
  1. const getHeight = require("../../utils/getRheRemainingHeight"),
  2. _Http = getApp().globalData.http;
  3. Page({
  4. /**
  5. * 页面的初始数据
  6. */
  7. data: {
  8. myProject: false,
  9. list: [],
  10. total: null,
  11. projectList: null,
  12. sa_salesforecastmodelid: null,
  13. "content": {
  14. "nocache": true,
  15. "sa_salesforecastbillid": null,
  16. "pageNumber": 1,
  17. "pageSize": 20,
  18. "pageTotal": 1,
  19. "where": {
  20. "condition": ""
  21. }
  22. },
  23. },
  24. onLoad(options) {
  25. this.setData({
  26. 'content.sa_salesforecastbillid': options.id,
  27. 'sa_salesforecastmodelid': options.mId
  28. })
  29. this.getList();
  30. if (options.my) this.setData({
  31. myProject: true
  32. })
  33. },
  34. /* 添加项目 */
  35. addProjece() {
  36. _Http.basic({
  37. "id": 20220906154803,
  38. "version": 1,
  39. "content": {
  40. "nocache": true,
  41. pageSize: 9999,
  42. "sa_salesforecastbillid": this.data.content.sa_salesforecastbillid,
  43. "where": {
  44. "condition": ""
  45. }
  46. }
  47. }).then(res => {
  48. if (res.msg != '成功') return wx.showToast({
  49. title: res.data,
  50. icon: "none"
  51. })
  52. this.setData({
  53. projectList: res.data
  54. });
  55. this.selectComponent("#Plist").setData({
  56. show: true
  57. })
  58. })
  59. },
  60. getList(init = false) {
  61. if (init.detail != undefined) init = init.detail;
  62. if (init) this.setData({
  63. ['content.pageNumber']: 1
  64. })
  65. if (this.data.content.pageNumber > this.data.content.pageTotal) return;
  66. return _Http.basic({
  67. "id": 20220916115203,
  68. "version": 1,
  69. content: this.data.content
  70. }).then(res => {
  71. console.log("列表", res)
  72. this.selectComponent('#ListBox').RefreshToComplete();
  73. if (res.msg != '成功') return wx.showToast({
  74. title: res.data,
  75. icon: "none"
  76. })
  77. this.setData({
  78. 'content.pageNumber': res.pageNumber + 1,
  79. 'content.pageTotal': res.pageTotal,
  80. list: res.pageNumber == 1 ? res.data : this.data.list.concat(res.data),
  81. total: res.total
  82. })
  83. })
  84. },
  85. /* 得到结果创建项目 */
  86. getResult({
  87. detail
  88. }) {
  89. _Http.basic({
  90. "id": 20220916134103,
  91. "version": 1,
  92. "content": {
  93. "sa_salesforecastmodelid": this.data.sa_salesforecastmodelid,
  94. "sa_salesforecastbillid": this.data.content.sa_salesforecastbillid,
  95. "sa_projectids": detail
  96. }
  97. }).then(res => {
  98. if (res.msg != '成功') return wx.showToast({
  99. title: res.data,
  100. icon: "none"
  101. })
  102. this.getList(true)
  103. })
  104. },
  105. /* 开始搜索 */
  106. startSearch({
  107. detail
  108. }) {
  109. this.setData({
  110. 'content.where.condition': detail.trim()
  111. });
  112. this.getList(true);
  113. },
  114. cancelSearch() {
  115. this.setData({
  116. 'content.where.condition': ""
  117. });
  118. this.getList(true);
  119. },
  120. onReady() {
  121. //滚动区域高度
  122. getHeight.getHeight('#Search', this).then(res => this.setData({
  123. scrollHeight: res
  124. }))
  125. },
  126. onClose(event) {
  127. const {
  128. instance
  129. } = event.detail;
  130. instance.close();
  131. },
  132. /* 删除提报 */
  133. deleteProject(e) {
  134. const {
  135. item
  136. } = e.currentTarget.dataset, that = this;
  137. wx.showModal({
  138. title: "提示",
  139. content: `是否确认删除${item.projectname}`,
  140. success({
  141. confirm
  142. }) {
  143. if (confirm) _Http.basic({
  144. "id": 20220908134803,
  145. "version": 1,
  146. "content": {
  147. "sa_salesforecastbillid": item.sa_salesforecastbillid
  148. }
  149. }).then(res => {
  150. console.log(res)
  151. if (res.msg != '成功') return wx.showToast({
  152. title: res.data,
  153. icon: "none"
  154. })
  155. let arr = that.data.list.filter(v => v.sa_salesforecastbillid != item.sa_salesforecastbillid);
  156. that.setData({
  157. list: arr
  158. })
  159. wx.showToast({
  160. title: '删除成功',
  161. icon: 'none'
  162. })
  163. })
  164. }
  165. })
  166. },
  167. onShareAppMessage() {}
  168. })