detail.js 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178
  1. const _Http = getApp().globalData.http;
  2. Page({
  3. /**
  4. * 页面的初始数据
  5. */
  6. data: {
  7. myProject: false,
  8. list: [],
  9. total: null,
  10. projectList: null,
  11. sa_salesforecastmodelid: null,
  12. "content": {
  13. "nocache": true,
  14. "sa_salesforecastbillid": null,
  15. "pageNumber": 1,
  16. "pageSize": 20,
  17. "pageTotal": 1,
  18. "where": {
  19. "condition": ""
  20. }
  21. },
  22. },
  23. onLoad(options) {
  24. this.setData({
  25. 'content.sa_salesforecastbillid': options.id,
  26. 'sa_salesforecastmodelid': options.mId
  27. })
  28. this.getList();
  29. if (options.my) this.setData({
  30. myProject: true
  31. })
  32. },
  33. /* 添加项目 */
  34. addProjece() {
  35. _Http.basic({
  36. "id": 20220906154803,
  37. "version": 1,
  38. "content": {
  39. "nocache": true,
  40. pageSize: 9999,
  41. "sa_salesforecastbillid": this.data.content.sa_salesforecastbillid,
  42. "where": {
  43. "condition": ""
  44. }
  45. }
  46. }).then(res => {
  47. if (res.msg != '成功') return wx.showToast({
  48. title: res.data,
  49. icon: "none"
  50. })
  51. this.setData({
  52. projectList: res.data
  53. });
  54. this.selectComponent("#Plist").setData({
  55. show: true
  56. })
  57. })
  58. },
  59. getList(init = false) {
  60. if (init.detail != undefined) init = init.detail;
  61. if (init) this.setData({
  62. ['content.pageNumber']: 1
  63. })
  64. if (this.data.content.pageNumber > this.data.content.pageTotal) return;
  65. return _Http.basic({
  66. "id": 20220916115203,
  67. "version": 1,
  68. content: this.data.content
  69. }).then(res => {
  70. console.log("列表", res)
  71. this.selectComponent('#ListBox').RefreshToComplete();
  72. if (res.msg != '成功') return wx.showToast({
  73. title: res.data,
  74. icon: "none"
  75. })
  76. const list = res.data.filter(v => v.sa_projectid != 0);
  77. this.setData({
  78. 'content.pageNumber': res.pageNumber + 1,
  79. 'content.pageTotal': res.pageTotal,
  80. list: res.pageNumber == 1 ? list : this.data.list.concat(list),
  81. total: res.total - 1
  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. this.selectComponent("#ListBox").setHeight("#Search", this);
  123. },
  124. onClose(event) {
  125. const {
  126. instance
  127. } = event.detail;
  128. instance.close();
  129. },
  130. /* 删除提报 */
  131. deleteProject(e) {
  132. const {
  133. item
  134. } = e.currentTarget.dataset, that = this;
  135. wx.showModal({
  136. title: "提示",
  137. content: `是否确认删除${item.projectname}`,
  138. success({
  139. confirm
  140. }) {
  141. if (confirm) _Http.basic({
  142. "id": 20220908134803,
  143. "version": 1,
  144. "content": {
  145. "sa_salesforecastbillid": item.sa_salesforecastbillid
  146. }
  147. }).then(res => {
  148. console.log(res)
  149. if (res.msg != '成功') return wx.showToast({
  150. title: res.data,
  151. icon: "none"
  152. })
  153. let arr = that.data.list.filter(v => v.sa_salesforecastbillid != item.sa_salesforecastbillid);
  154. that.setData({
  155. list: arr
  156. })
  157. wx.showToast({
  158. title: '删除成功',
  159. icon: 'none'
  160. })
  161. })
  162. }
  163. })
  164. },
  165. toReportForms(e) {
  166. const {
  167. item
  168. } = e.currentTarget.dataset;
  169. let isEdit = this.data.myProject;
  170. item.sa_salesforecastmodelid = this.data.sa_salesforecastmodelid;
  171. wx.navigateTo({
  172. url: `./reportForms?item=${JSON.stringify(item)}&isEdit=${isEdit}`,
  173. })
  174. },
  175. onShareAppMessage() {}
  176. })