index.js 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159
  1. const _Http = getApp().globalData.http;
  2. Page({
  3. data: {
  4. navList: [{
  5. label: "我负责的",
  6. icon: "icon-webxialaxuanxiangjiantou",
  7. color: "",
  8. width: "",
  9. id: "1"
  10. }, {
  11. label: "排序",
  12. icon: "icon-jiangxu1",
  13. color: "",
  14. width: "",
  15. id: "sort"
  16. }, {
  17. label: "筛选",
  18. icon: "icon-shaixuan",
  19. color: "",
  20. width: "",
  21. id: "2"
  22. }],
  23. content: {
  24. "pageNumber": 1,
  25. "pageSize": 20,
  26. "where": {
  27. "condition": "",
  28. "activityformat": "",
  29. "begindate": "",
  30. "enddate": ""
  31. },
  32. "type": 99,
  33. "isAll": 0
  34. },
  35. },
  36. async onLoad() {
  37. getApp().globalData.Language.getLanguagePackage(this);
  38. let templetList = wx.getStorageSync('templetList')
  39. this.setData({
  40. insert: wx.getStorageSync('auth').wdepartment.options.some(v => v == 'insert'), //查询新增权限
  41. classActions: templetList.map((v, i) => {
  42. return {
  43. name: v.templetname,
  44. index: v.templetid,
  45. color: i == 0 ? '#3874F6' : '',
  46. i: i,
  47. }
  48. }),
  49. 'navList[0].label': templetList[0].templetname,
  50. "content.type": templetList[0].templetid,
  51. });
  52. this.getList(true)
  53. let filtratelist = [{
  54. label: "活动类型",
  55. index: null,
  56. showName: "value", //显示字段
  57. valueKey: "activityformat", //返回Key
  58. selectKey: "value", //传参 代表选着字段 不传参返回整个选择对象
  59. value: "", //选中值
  60. list: await _Http.getTypes('activityformat', _Http)
  61. }]
  62. this.setData({
  63. filtratelist
  64. })
  65. },
  66. getList(init = false) {
  67. _Http.init(this.data.content, init).then(content => {
  68. _Http.basic({
  69. "id": 20221101095102,
  70. content
  71. }).then(res => {
  72. console.log("活动列表", res)
  73. this.selectComponent('#ListBox').RefreshToComplete();
  74. if (res.code != '1') return wx.showToast({
  75. title: res.msg,
  76. icon: "none"
  77. })
  78. res.data = res.data.map(v => {
  79. v.amount = _Http.formatMoney(v.amount)
  80. v.actualAmount = _Http.formatMoney(v.actualAmount)
  81. return v
  82. })
  83. this.setData({
  84. content: _Http.paging(content, res),
  85. list: res.pageNumber == 1 ? res.data : this.data.list.concat(res.data)
  86. })
  87. })
  88. })
  89. },
  90. toAdd() {
  91. wx.navigateTo({
  92. url: '/prsx/activity/insert'
  93. })
  94. },
  95. /* 处理筛选 */
  96. handleFilter({
  97. detail
  98. }) {
  99. detail.condition = this.data.content.where.condition;
  100. if (detail.startdate) {
  101. detail.begindate = detail.startdate
  102. delete detail.startdate
  103. }
  104. this.data.content.where = detail;
  105. this.getList(true);
  106. },
  107. /* 顶部条件导航回调 */
  108. navClick({
  109. detail
  110. }) {
  111. switch (detail.id) {
  112. case '1':
  113. this.setData({
  114. classShow: true
  115. })
  116. break;
  117. case '2':
  118. this.setData({
  119. 'filterShow': true
  120. })
  121. break;
  122. case '3':
  123. this.setData({
  124. 'content.sort[0].reversed': this.data.content.sort[0].reversed == 0 ? 1 : 0
  125. });
  126. this.getList(true)
  127. break;
  128. }
  129. },
  130. /* 处理搜索 */
  131. onSearch({
  132. detail
  133. }) {
  134. this.data.content.where.condition = detail;
  135. this.getList(true);
  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. classActions: this.data.classActions.map(v => {
  150. v.color = detail.i == v.i ? '#3874F6' : ''
  151. return v
  152. })
  153. })
  154. this.classClose();
  155. this.getList(true)
  156. }
  157. })