detail.js 5.3 KB

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