detail.js 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181
  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. const list = res.data.filter(v => v.sa_projectid != 0);
  78. this.setData({
  79. 'content.pageNumber': res.pageNumber + 1,
  80. 'content.pageTotal': res.pageTotal,
  81. list: res.pageNumber == 1 ? list : this.data.list.concat(list),
  82. total: res.total
  83. })
  84. })
  85. },
  86. /* 得到结果创建项目 */
  87. getResult({
  88. detail
  89. }) {
  90. _Http.basic({
  91. "id": 20220916134103,
  92. "version": 1,
  93. "content": {
  94. "sa_salesforecastmodelid": this.data.sa_salesforecastmodelid,
  95. "sa_salesforecastbillid": this.data.content.sa_salesforecastbillid,
  96. "sa_projectids": detail
  97. }
  98. }).then(res => {
  99. if (res.msg != '成功') return wx.showToast({
  100. title: res.data,
  101. icon: "none"
  102. })
  103. this.getList(true)
  104. })
  105. },
  106. /* 开始搜索 */
  107. startSearch({
  108. detail
  109. }) {
  110. this.setData({
  111. 'content.where.condition': detail.trim()
  112. });
  113. this.getList(true);
  114. },
  115. cancelSearch() {
  116. this.setData({
  117. 'content.where.condition': ""
  118. });
  119. this.getList(true);
  120. },
  121. onReady() {
  122. //滚动区域高度
  123. getHeight.getHeight('#Search', this).then(res => this.setData({
  124. scrollHeight: res
  125. }))
  126. },
  127. onClose(event) {
  128. const {
  129. instance
  130. } = event.detail;
  131. instance.close();
  132. },
  133. /* 删除提报 */
  134. deleteProject(e) {
  135. const {
  136. item
  137. } = e.currentTarget.dataset, that = this;
  138. wx.showModal({
  139. title: "提示",
  140. content: `是否确认删除${item.projectname}`,
  141. success({
  142. confirm
  143. }) {
  144. if (confirm) _Http.basic({
  145. "id": 20220908134803,
  146. "version": 1,
  147. "content": {
  148. "sa_salesforecastbillid": item.sa_salesforecastbillid
  149. }
  150. }).then(res => {
  151. console.log(res)
  152. if (res.msg != '成功') return wx.showToast({
  153. title: res.data,
  154. icon: "none"
  155. })
  156. let arr = that.data.list.filter(v => v.sa_salesforecastbillid != item.sa_salesforecastbillid);
  157. that.setData({
  158. list: arr
  159. })
  160. wx.showToast({
  161. title: '删除成功',
  162. icon: 'none'
  163. })
  164. })
  165. }
  166. })
  167. },
  168. toReportForms(e) {
  169. const {
  170. item
  171. } = e.currentTarget.dataset;
  172. let isEdit = this.data.myProject;
  173. item.sa_salesforecastmodelid = this.data.sa_salesforecastmodelid;
  174. wx.navigateTo({
  175. url: `./reportForms?item=${JSON.stringify(item)}&isEdit=${isEdit}`,
  176. })
  177. },
  178. onShareAppMessage() {}
  179. })