index.js 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182
  1. const _Http = getApp().globalData.http;
  2. Page({
  3. data: {
  4. timeRangeShow: false,
  5. activeIndex: 0,
  6. whereType: {
  7. value: "begdate",
  8. list: {
  9. "begdate": "",
  10. "enddate": ""
  11. }
  12. },
  13. option1: [{
  14. text: '所有日期',
  15. value: '所有日期'
  16. },
  17. {
  18. text: '查看范围',
  19. value: '查看范围'
  20. }
  21. ],
  22. option2: [{
  23. text: '按日期升序',
  24. value: '按日期升序'
  25. },
  26. {
  27. text: '按日期降序',
  28. value: '按日期降序'
  29. },
  30. ],
  31. value1: '所有日期',
  32. value2: '按日期升序',
  33. "content": {
  34. "onceonly": 1,
  35. "nocache": true,
  36. pageNumber: 1,
  37. pageSize: 20,
  38. pageTotal: 1,
  39. "where": {
  40. "begdate": "",
  41. "enddate": ""
  42. }
  43. },
  44. },
  45. onLoad(options) {
  46. this.getList();
  47. },
  48. getList(init = false) {
  49. if (init.detail != undefined) init = init.detail;
  50. if (init) this.setData({
  51. ['content.pageNumber']: 1
  52. })
  53. if (this.data.content.pageNumber > this.data.content.pageTotal) return;
  54. let content = JSON.parse(JSON.stringify(this.data.content));
  55. if (content.where.begdate == "" && content.where.enddate == "") delete content.where;
  56. if (this.data.sort != "") content.sort = this.data.sort;
  57. _Http.basic({
  58. id: this.data.activeIndex == 2 ? 20221102094802 : 20221102094702,
  59. content
  60. }).then(res => {
  61. console.log("提报列表", res)
  62. this.selectComponent('#ListBox').RefreshToComplete();
  63. if (res.msg != '成功') return wx.showToast({
  64. title: res.msg,
  65. icon: "none"
  66. })
  67. for (let i = 0; i < res.data.length; i++) {
  68. res.data[i].begdate = res.data[i].begdate.split(" ")[0];
  69. res.data[i].enddate = res.data[i].enddate.split(" ")[0];
  70. }
  71. this.setData({
  72. list: (res.pageNumber == 1) ? res.data : this.data.list.concat(res.data),
  73. ['content.pageNumber']: res.pageNumber + 1,
  74. ['content.pageTotal']: res.pageTotal,
  75. total: res.total,
  76. sort: res.sort
  77. })
  78. })
  79. },
  80. /* tabs切换 */
  81. tabsClick({
  82. detail
  83. }) {
  84. this.setData({
  85. activeIndex: detail.index,
  86. "content.onceonly": detail.index == 0 ? 1 : 0
  87. });
  88. this.getList(true)
  89. },
  90. /* 查看日期 */
  91. dropdownChange1({
  92. detail
  93. }) {
  94. this.setData({
  95. value1: detail
  96. })
  97. },
  98. Dateclick(e) {
  99. console.log(e)
  100. setTimeout(() => {
  101. if (this.data.value1 == '查看范围') {
  102. this.setData({
  103. timeRangeShow: true
  104. })
  105. } else {
  106. this.toSeeAll();
  107. }
  108. }, 100)
  109. },
  110. /* 排序 */
  111. dropdownChange2({
  112. detail
  113. }) {
  114. this.setData({
  115. value2: detail,
  116. "sort[0].reversed": detail == '按日期降序' ? 1 : 0
  117. })
  118. this.getList(true)
  119. },
  120. /* 关闭时间范围选择 */
  121. timeRangeClose() {
  122. this.setData({
  123. timeRangeShow: false,
  124. "content.where": {
  125. "begdate": "",
  126. "enddate": ""
  127. }
  128. })
  129. },
  130. /* 查看所有日期 */
  131. toSeeAll() {
  132. this.setData({
  133. value1: "所有日期"
  134. })
  135. this.timeRangeClose();
  136. this.getList(true);
  137. },
  138. /* 选择日期类型 */
  139. selectDateType(e) {
  140. const {
  141. name
  142. } = e.target.dataset;
  143. this.setData({
  144. "whereType.value": name
  145. })
  146. },
  147. /* 得到选择时间 */
  148. getDate({
  149. detail
  150. }) {
  151. let obj = this.data.whereType;
  152. obj.list[obj.value] = detail;
  153. this.setData({
  154. whereType: obj
  155. })
  156. },
  157. /* 确定时间范围 */
  158. determineScope() {
  159. this.setData({
  160. "content.where": this.data.whereType.list
  161. });
  162. this.getList(true);
  163. this.timeRangeClose();
  164. },
  165. /* 去详情 */
  166. toDetails(e) {
  167. const {
  168. item
  169. } = e.currentTarget.dataset;
  170. wx.navigateTo({
  171. url: `./details?type=开始提报&id=${item.sat_submiteditmodelid}&oneToOne=${this.data.activeIndex === 0}&ishistory=${item.ishistory}`,
  172. })
  173. },
  174. /**
  175. * 生命周期函数--监听页面初次渲染完成
  176. */
  177. onReady() {
  178. this.selectComponent("#ListBox").setHeight(".dropdown", this);
  179. },
  180. onShareAppMessage(res) {}
  181. })