index.js 2.4 KB

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