index.js 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184
  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').filter(v => v.templetid != '5').map((v, i) => {
  64. return {
  65. name: v.templetname,
  66. index: v.templetid,
  67. color: i == 0 ? '#3874F6' : '',
  68. i: i,
  69. }
  70. });
  71. if (wx.getStorageSync('userMsg').usertype != 0) classActions = classActions.filter(v => v.index != '99');
  72. this.setData({
  73. classActions,
  74. 'navList[0].label': classActions[0].name,
  75. "content.type": classActions[0].index,
  76. })
  77. this.getList();
  78. },
  79. /* 获取列表 */
  80. getList(init = false) {
  81. if (init.detail != undefined) init = init.detail;
  82. let content = this.data.content;
  83. if (init) content.pageNumber = 1;
  84. if (content.pageNumber > content.pageTotal) return;
  85. _Http.basic({
  86. "id": 20230706092304,
  87. content
  88. }).then(res => {
  89. console.log("项目成交预测", res)
  90. this.selectComponent('#ListBox').RefreshToComplete();
  91. if (res.msg != '成功') return wx.showToast({
  92. title: res.data,
  93. icon: "none"
  94. })
  95. res.data = res.data.map(v => {
  96. v.showAmount = CNY(v.projectamount)
  97. return v
  98. })
  99. this.setData({
  100. 'content.pageNumber': res.pageNumber + 1,
  101. 'content.pageTotal': res.pageTotal,
  102. 'content.total': res.total,
  103. 'content.sort': res.sort,
  104. list: res.pageNumber == 1 ? res.data : this.data.list.concat(res.data)
  105. });
  106. this.setListHeight();
  107. })
  108. },
  109. /* 处理搜索 */
  110. onSearch({
  111. detail
  112. }) {
  113. this.setData({
  114. "content.where.condition": detail
  115. });
  116. this.getList(true);
  117. },
  118. onReady() {
  119. this.setListHeight();
  120. },
  121. setListHeight() {
  122. this.selectComponent("#ListBox").setHeight(".head", this);
  123. },
  124. /* 顶部条件导航回调 */
  125. navClick({
  126. detail
  127. }) {
  128. switch (detail.id) {
  129. case '1':
  130. this.setData({
  131. classShow: true
  132. })
  133. break;
  134. case '2':
  135. this.setData({
  136. showFiltrate: true
  137. })
  138. break;
  139. }
  140. },
  141. classClose() {
  142. this.setData({
  143. classShow: false
  144. })
  145. },
  146. classSelect({
  147. detail
  148. }) {
  149. if (this.data.content.type == detail.index) return this.classClose();
  150. this.setData({
  151. "content.type": detail.index,
  152. 'navList[0].label': detail.name,
  153. classActions: this.data.classActions.map(v => {
  154. v.color = detail.i == v.i ? '#3874F6' : ''
  155. return v
  156. })
  157. })
  158. this.classClose();
  159. this.getList(true)
  160. },
  161. handleFilter({
  162. detail
  163. }) {
  164. if (detail.startdate) {
  165. this.setData({
  166. 'content.where.begindate': detail.startdate || "",
  167. 'content.where.enddate': detail.enddate || "",
  168. });
  169. } else {
  170. this.setData({
  171. 'content.where.begindate': "",
  172. 'content.where.enddate': "",
  173. });
  174. };
  175. this.setData({
  176. 'content.where.status': detail.status,
  177. 'content.where.periodstart': detail.periodstart,
  178. 'content.where.periodend': detail.periodend,
  179. });
  180. this.getList(true)
  181. }
  182. })