index.js 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  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. getApp().globalData.Language.getLanguagePackage(this, 'E-订单');
  29. },
  30. getList(init = false) {
  31. if (init.detail != undefined) init = init.detail;
  32. let content = this.data.content;
  33. if (init) content.pageNumber = 1;
  34. if (content.pageNumber > content.pageTotal) return;
  35. content.where.status = this.data.active;
  36. _Http.basic({
  37. "id": 20221216143103, //20221216143103
  38. "version": 1,
  39. content
  40. }).then(res => {
  41. console.log("开票申请列表", res)
  42. this.selectComponent('#ListBox').RefreshToComplete();
  43. res.data = res.data.map(v => {
  44. v.redamount = CNY(v.redamount)
  45. return v
  46. })
  47. this.setData({
  48. list: res.pageNumber == 1 ? res.data : this.data.list.concat(res.data),
  49. "content.pageNumber": res.pageNumber + 1,
  50. "content.pageTotal": res.pageTotal,
  51. "content.sort": res.sort,
  52. "content.total": res.total,
  53. loading: false
  54. })
  55. })
  56. },
  57. /* 去新增 */
  58. toAdd() {
  59. wx.navigateTo({
  60. url: '/packageA/invoice/update'
  61. })
  62. },
  63. /* 搜索 */
  64. onSearch({
  65. detail
  66. }) {
  67. this.setData({
  68. "content.where.condition": detail
  69. });
  70. this.getList(true)
  71. },
  72. /* 切换tabs */
  73. tabsChange(e) {
  74. this.setData({
  75. active: e.detail.name
  76. });
  77. this.getList(true);
  78. },
  79. onReady() {
  80. this.setListHeight()
  81. },
  82. /* 设置页面高度 */
  83. setListHeight() {
  84. this.selectComponent("#ListBox").setHeight(".total", this);
  85. },
  86. })