index.js 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  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. v.factamount = CNY(v.factamount)
  46. return v
  47. })
  48. this.setData({
  49. list: res.pageNumber == 1 ? res.data : this.data.list.concat(res.data),
  50. "content.pageNumber": res.pageNumber + 1,
  51. "content.pageTotal": res.pageTotal,
  52. "content.sort": res.sort,
  53. "content.total": res.total,
  54. loading: false
  55. })
  56. })
  57. },
  58. /* 去新增 */
  59. toAdd() {
  60. wx.navigateTo({
  61. url: '/packageA/invoice/update'
  62. })
  63. },
  64. /* 搜索 */
  65. onSearch({
  66. detail
  67. }) {
  68. this.setData({
  69. "content.where.condition": detail
  70. });
  71. this.getList(true)
  72. },
  73. /* 切换tabs */
  74. tabsChange(e) {
  75. this.setData({
  76. active: e.detail.name
  77. });
  78. this.getList(true);
  79. },
  80. onReady() {
  81. this.setListHeight()
  82. },
  83. /* 设置页面高度 */
  84. setListHeight() {
  85. this.selectComponent("#ListBox").setHeight(".total", this);
  86. },
  87. })