index.js 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. const _Http = getApp().globalData.http;
  2. Page({
  3. data: {
  4. loading: true,
  5. active: "新建",
  6. "content": {
  7. nocache: true,
  8. "pageNumber": 1,
  9. "pageTotal": 1,
  10. "pageSize": 20,
  11. total: 0,
  12. "where": {
  13. "condition": "",
  14. },
  15. sort: []
  16. }
  17. },
  18. onLoad(options) {
  19. this.getList(true)
  20. this.setData({
  21. userrole: wx.getStorageSync('userrole')
  22. })
  23. },
  24. getList(init = false) {
  25. if (init.detail != undefined) init = init.detail;
  26. let content = this.data.content;
  27. if (init) content.pageNumber = 1;
  28. if (content.pageNumber > content.pageTotal) return;
  29. content.where.status = this.data.active;
  30. _Http.basic({
  31. "id": 20221216143103, //20221216143103
  32. "version": 1,
  33. content
  34. }).then(res => {
  35. console.log("开票申请列表", res)
  36. this.selectComponent('#ListBox').RefreshToComplete();
  37. this.setData({
  38. list: res.pageNumber == 1 ? res.data : this.data.list.concat(res.data),
  39. "content.pageNumber": res.pageNumber + 1,
  40. "content.pageTotal": res.pageTotal,
  41. "content.sort": res.sort,
  42. "content.total": res.total,
  43. loading: false
  44. })
  45. })
  46. },
  47. /* 去新增 */
  48. toAdd() {
  49. wx.navigateTo({
  50. url: '/packageA/invoice/update'
  51. })
  52. },
  53. /* 搜索 */
  54. onSearch({
  55. detail
  56. }) {
  57. this.setData({
  58. "content.where.condition": detail
  59. });
  60. this.getList(true)
  61. },
  62. /* 切换tabs */
  63. tabsChange(e) {
  64. this.setData({
  65. active: e.detail.name
  66. });
  67. this.getList(true);
  68. },
  69. onReady() {
  70. this.setListHeight()
  71. },
  72. /* 设置页面高度 */
  73. setListHeight() {
  74. this.selectComponent("#ListBox").setHeight(".total", this);
  75. },
  76. })