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: 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. getApp().globalData.Language.getLanguagePackage(this, '出货开票预测');
  61. let classActions = wx.getStorageSync('templetList').filter(v => v.templetid != '5').map((v, i) => {
  62. return {
  63. name: v.templetname,
  64. index: v.templetid,
  65. color: i == 0 ? '#3874F6' : '',
  66. i: i,
  67. }
  68. });
  69. if (wx.getStorageSync('userMsg').usertype != 0) classActions = classActions.filter(v => v.index != '99');
  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.code != '1') return wx.showToast({
  90. title: res.data,
  91. icon: "none"
  92. })
  93. res.data = res.data.map(v => {
  94. v.orderoutamount = CNY(v.orderoutamount)
  95. v.orderinvoamount = CNY(v.orderinvoamount)
  96. return v
  97. })
  98. this.setData({
  99. 'content.pageNumber': res.pageNumber + 1,
  100. 'content.pageTotal': res.pageTotal,
  101. 'content.total': res.total,
  102. 'content.sort': res.sort,
  103. list: res.pageNumber == 1 ? res.data : this.data.list.concat(res.data)
  104. });
  105. })
  106. },
  107. /* 处理搜索 */
  108. onSearch({
  109. detail
  110. }) {
  111. this.setData({
  112. "content.where.condition": detail
  113. });
  114. this.getList(true);
  115. },
  116. /* 顶部条件导航回调 */
  117. navClick({
  118. detail
  119. }) {
  120. switch (detail.id) {
  121. case '1':
  122. this.setData({
  123. classShow: true
  124. })
  125. break;
  126. case '2':
  127. this.setData({
  128. showFiltrate: true
  129. })
  130. break;
  131. }
  132. },
  133. classClose() {
  134. this.setData({
  135. classShow: false
  136. })
  137. },
  138. classSelect({
  139. detail
  140. }) {
  141. if (this.data.content.type == detail.index) return this.classClose();
  142. this.setData({
  143. "content.type": detail.index,
  144. 'navList[0].label': detail.name,
  145. classActions: this.data.classActions.map(v => {
  146. v.color = detail.i == v.i ? '#3874F6' : ''
  147. return v
  148. })
  149. })
  150. console.log("classActions", this.data.classActions)
  151. this.classClose();
  152. this.getList(true)
  153. },
  154. handleFilter({
  155. detail
  156. }) {
  157. console.log(detail)
  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. })