index.js 5.4 KB

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