index.js 5.1 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. getApp().globalData.Language.getLanguagePackage(this, '项目成交预测');
  64. let classActions = wx.getStorageSync('templetList').filter(v => v.templetid != '5').map((v, i) => {
  65. return {
  66. name: v.templetname,
  67. index: v.templetid,
  68. color: i == 0 ? '#3874F6' : '',
  69. i: i,
  70. }
  71. });
  72. if (wx.getStorageSync('userMsg').usertype != 0) classActions = classActions.filter(v => v.index != '99');
  73. this.setData({
  74. classActions,
  75. 'navList[0].label': classActions[0].name,
  76. "content.type": classActions[0].index,
  77. })
  78. this.getList();
  79. },
  80. /* 获取列表 */
  81. getList(init = false) {
  82. if (init.detail != undefined) init = init.detail;
  83. let content = this.data.content;
  84. if (init) content.pageNumber = 1;
  85. if (content.pageNumber > content.pageTotal) return;
  86. _Http.basic({
  87. "id": 20230706092304,
  88. content
  89. }).then(res => {
  90. console.log("项目成交预测", res)
  91. this.selectComponent('#ListBox').RefreshToComplete();
  92. if (res.code != '1') return wx.showToast({
  93. title: res.data,
  94. icon: "none"
  95. })
  96. res.data = res.data.map(v => {
  97. v.showAmount = CNY(v.projectamount)
  98. return v
  99. })
  100. this.setData({
  101. 'content.pageNumber': res.pageNumber + 1,
  102. 'content.pageTotal': res.pageTotal,
  103. 'content.total': res.total,
  104. 'content.sort': res.sort,
  105. list: res.pageNumber == 1 ? res.data : this.data.list.concat(res.data)
  106. });
  107. })
  108. },
  109. /* 处理搜索 */
  110. onSearch({
  111. detail
  112. }) {
  113. this.setData({
  114. "content.where.condition": detail
  115. });
  116. this.getList(true);
  117. },
  118. /* 顶部条件导航回调 */
  119. navClick({
  120. detail
  121. }) {
  122. switch (detail.id) {
  123. case '1':
  124. this.setData({
  125. classShow: true
  126. })
  127. break;
  128. case '2':
  129. this.setData({
  130. showFiltrate: true
  131. })
  132. break;
  133. }
  134. },
  135. classClose() {
  136. this.setData({
  137. classShow: false
  138. })
  139. },
  140. classSelect({
  141. detail
  142. }) {
  143. if (this.data.content.type == detail.index) return this.classClose();
  144. this.setData({
  145. "content.type": detail.index,
  146. 'navList[0].label': detail.name,
  147. classActions: this.data.classActions.map(v => {
  148. v.color = detail.i == v.i ? '#3874F6' : ''
  149. return v
  150. })
  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. })