index.js 2.3 KB

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