index.js 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  1. const _Http = getApp().globalData.http,
  2. currency = require("../../utils/currency"),
  3. CNY = (value, symbol = "¥", precision = 2) => currency(value, {
  4. symbol,
  5. precision
  6. }).format();
  7. Component({
  8. properties: {},
  9. options: {
  10. addGlobalClass: true,
  11. },
  12. lifetimes: {
  13. attached: function () {
  14. getApp().globalData.Language.getLanguagePackage(this)
  15. }
  16. },
  17. data: {
  18. active: 0,
  19. "id": 20231010133804,
  20. tabs: ['订单', '出货', '开票', '回款'],
  21. dateTypes: ["本年", "本季", "本月"],
  22. "content": {
  23. pageNumber: 1,
  24. pageTotal: 1,
  25. dateType: "本年",
  26. dataid: wx.getStorageSync('userMsg').userid,
  27. username: wx.getStorageSync('userMsg').name,
  28. sequence: "订单",
  29. type: 0,
  30. where: {
  31. begdate: "",
  32. enddate: "",
  33. isleave: "1",
  34. }
  35. },
  36. },
  37. methods: {
  38. async getList(init = false) {
  39. if (init.detail != undefined) init = init.detail;
  40. let content = this.data.content
  41. const {
  42. dataid,
  43. type,
  44. username,
  45. isleave
  46. } = getCurrentPages()[getCurrentPages().length - 1].data;
  47. if (content.dataid != dataid || content.type != type || isleave != isleave) init = true
  48. content.dataid = dataid;
  49. content.type = type;
  50. content.username = username;
  51. content.where.isleave = isleave;
  52. const dividend = wx.getStorageSync('languagecode') == 'ZH' ? 10000 : 1000,
  53. getMapText = getApp().globalData.Language.getMapText;
  54. if (init) {
  55. content.pageNumber = 1;
  56. content.pageTotal = 1;
  57. }
  58. if (content.pageNumber > content.pageTotal) return;
  59. _Http.basic({
  60. id: this.data.id,
  61. content
  62. }).then(res => {
  63. this.selectComponent('#ListBox').RefreshToComplete();
  64. console.log(this.data.id, res)
  65. if (res.code != '1') return wx.showToast({
  66. title: res.data,
  67. icon: "none"
  68. })
  69. res.data = res.data.map(v => {
  70. const colors = ['#F56C6C', '#EF8E51', '#FFC148', '#999999'];
  71. v.color = colors[v.rowindex - 1] || colors[3];
  72. v.amount = CNY(v.amount)
  73. v.outamount = CNY(v.outamount)
  74. v.taxincludedamount = CNY(v.taxincludedamount)
  75. v.writeoffamount = CNY(v.writeoffamount)
  76. return v
  77. })
  78. this.setData({
  79. list: res.pageNumber == 1 ? res.data : this.data.list.concat(res.data),
  80. "content.pageNumber": res.pageNumber + 1,
  81. "content.pageSize": res.pageSize,
  82. })
  83. try {
  84. this.selectComponent("#TimeRange").onCancel()
  85. } catch (error) {
  86. }
  87. })
  88. },
  89. changeDate({
  90. detail
  91. }) {
  92. this.setData({
  93. "content.dateType": detail.dateType,
  94. "content.where.begdate": detail.begdate || "",
  95. "content.where.enddate": detail.enddate || ""
  96. })
  97. this.getList(true)
  98. },
  99. changeSequence(e) {
  100. const {
  101. name
  102. } = e.currentTarget.dataset;
  103. if (this.data.content.sequence == name) return;
  104. this.setData({
  105. "content.sequence": name
  106. })
  107. this.getList(true)
  108. },
  109. tabsOnChange(e) {
  110. let name = e.detail.name
  111. if (name == this.data.id) return;
  112. this.setData({
  113. id: name,
  114. active: e.detail.index
  115. })
  116. this.getList(true);
  117. }
  118. }
  119. })