index.js 6.0 KB

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