index.js 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178
  1. let _Http = getApp().globalData.http,
  2. currency = require("../../utils/currency"),
  3. CNY = value => currency(value, {
  4. symbol: "¥",
  5. precision: 2
  6. }).format();
  7. Page({
  8. data: {
  9. classShow: false,
  10. admin: false,
  11. showFiltrate: false,
  12. content: {
  13. baseonproject: 1, //1项目预测,0出货开票预测
  14. pageNumber: 1,
  15. pageTotal: 1,
  16. pagesize: 20,
  17. sort: [],
  18. where: {
  19. condition: "",
  20. begindate: "",
  21. enddate: "",
  22. status: "",
  23. periodstart: "",
  24. periodend: ""
  25. }
  26. },
  27. navList: [{
  28. label: "我负责的",
  29. icon: "icon-webxialaxuanxiangjiantou",
  30. color: "",
  31. width: "",
  32. id: "1"
  33. }, {
  34. label: "排序",
  35. icon: "icon-jiangxu1",
  36. color: "",
  37. width: "",
  38. id: "sort"
  39. }, {
  40. label: "筛选",
  41. icon: "icon-shaixuan",
  42. color: "",
  43. width: "",
  44. id: "2"
  45. }],
  46. filtrateList: [{
  47. label: "状态",
  48. index: null,
  49. showName: "name", //显示字段
  50. valueKey: "status", //返回Key
  51. selectKey: "name", //传参 代表选着字段 不传参返回整个选择对象
  52. value: "", //选中值
  53. list: [{
  54. name: "进行中"
  55. },
  56. {
  57. name: "已截止"
  58. },
  59. ]
  60. }]
  61. },
  62. onLoad(options) {
  63. let classActions = wx.getStorageSync('templetList').map(v => {
  64. return {
  65. name: v.templetname,
  66. index: v.templetid
  67. }
  68. }).filter(v => v.name != '我创建的');
  69. if (wx.getStorageSync('userMsg').usertype != 0) classActions = classActions.filter(v => v.name != '站点全部');
  70. this.setData({
  71. classActions,
  72. 'navList[0].label': classActions[0].name,
  73. "content.type": classActions[0].index,
  74. })
  75. this.getList();
  76. },
  77. /* 获取列表 */
  78. getList(init = false) {
  79. if (init.detail != undefined) init = init.detail;
  80. let content = this.data.content;
  81. if (init) content.pageNumber = 1;
  82. if (content.pageNumber > content.pageTotal) return;
  83. _Http.basic({
  84. "id": 20230706092304,
  85. content
  86. }).then(res => {
  87. console.log("项目成交预测", res)
  88. this.selectComponent('#ListBox').RefreshToComplete();
  89. if (res.msg != '成功') return wx.showToast({
  90. title: res.data,
  91. icon: "none"
  92. })
  93. res.data = res.data.map(v => {
  94. v.showAmount = CNY(v.projectamount)
  95. return v
  96. })
  97. this.setData({
  98. 'content.pageNumber': res.pageNumber + 1,
  99. 'content.pageTotal': res.pageTotal,
  100. 'content.total': res.total,
  101. 'content.sort': res.sort,
  102. list: res.pageNumber == 1 ? res.data : this.data.list.concat(res.data)
  103. });
  104. this.setListHeight();
  105. })
  106. },
  107. /* 处理搜索 */
  108. onSearch({
  109. detail
  110. }) {
  111. this.setData({
  112. "content.where.condition": detail
  113. });
  114. this.getList(true);
  115. },
  116. onReady() {
  117. this.setListHeight();
  118. },
  119. setListHeight() {
  120. this.selectComponent("#ListBox").setHeight(".head", this);
  121. },
  122. /* 顶部条件导航回调 */
  123. navClick({
  124. detail
  125. }) {
  126. switch (detail.id) {
  127. case '1':
  128. this.setData({
  129. classShow: true
  130. })
  131. break;
  132. case '2':
  133. this.setData({
  134. showFiltrate: true
  135. })
  136. break;
  137. }
  138. },
  139. classClose() {
  140. this.setData({
  141. classShow: false
  142. })
  143. },
  144. classSelect({
  145. detail
  146. }) {
  147. if (this.data.content.type == detail.index) return this.classClose();
  148. this.setData({
  149. "content.type": detail.index,
  150. 'navList[0].label': detail.name
  151. })
  152. this.classClose();
  153. this.getList(true)
  154. },
  155. handleFilter({
  156. detail
  157. }) {
  158. if (detail.startdate) {
  159. this.setData({
  160. 'content.where.begindate': detail.startdate || "",
  161. 'content.where.enddate': detail.enddate || "",
  162. });
  163. } else {
  164. this.setData({
  165. 'content.where.begindate': "",
  166. 'content.where.enddate': "",
  167. });
  168. };
  169. this.setData({
  170. 'content.where.status': detail.status,
  171. 'content.where.periodstart': detail.periodstart,
  172. 'content.where.periodend': detail.periodend,
  173. });
  174. this.getList(true)
  175. }
  176. })