index.js 5.6 KB

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