index.js 5.0 KB

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