index.js 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  1. const _Http = getApp().globalData.http;
  2. let pageNumber = 1,
  3. pageTotal = 1,
  4. currency = require("../../utils/currency"),
  5. CNY = value => currency(value, {
  6. symbol: "¥",
  7. precision: 2
  8. }).format();
  9. import {
  10. formatTime
  11. } from "../../utils/getTime";
  12. Page({
  13. data: {
  14. accountList: [],
  15. active: 0,
  16. dateEnd: "", //日期结束时间
  17. begindate: "",
  18. enddate: "",
  19. },
  20. onLoad(options) {
  21. this.setData({
  22. dateEnd: formatTime(new Date(), '-').split(" ")[0]
  23. });
  24. _Http.basic({
  25. id: 20221008145903,
  26. "content": {
  27. pageSize: 999,
  28. type: 1,
  29. nocache: true,
  30. "where": {
  31. "condition": ""
  32. }
  33. }
  34. }).then(res => {
  35. console.log("账户列表", res)
  36. this.setData({
  37. accountList: res.data.map(v => {
  38. v.creditquota = CNY(v.creditquota);
  39. v.freezamount = CNY(v.freezamount);
  40. v.discountamount = CNY(v.discountamount);
  41. v.usable = CNY(currency(v.creditquota).add(v.balance));
  42. v.balance = CNY(v.balance)
  43. return v
  44. })
  45. });
  46. this.getList(true);
  47. })
  48. try {
  49. let privacyFieldC = wx.getStorageSync('auth').worderform.forms.list.formcols.map(v => v.title);
  50. this.setData({
  51. privacyFieldC
  52. })
  53. console.log("privacyFieldC", privacyFieldC)
  54. } catch (error) {
  55. console.error(error)
  56. }
  57. },
  58. /* 切换查看账户 */
  59. changeAccount(e) {
  60. this.setData({
  61. active: e.detail.value || e.detail.current
  62. });
  63. this.getList(true);
  64. },
  65. /* 切换查看时间 */
  66. changeDate(e) {
  67. this.setData({
  68. [`${e.currentTarget.dataset.name}`]: e.detail.value
  69. })
  70. this.getList(true);
  71. },
  72. getList(init = false) {
  73. if (init) {
  74. pageNumber = 1;
  75. pageTotal = 1
  76. }
  77. if (pageNumber > pageTotal) return;
  78. let data = this.data.accountList[this.data.active];
  79. _Http.basic({
  80. "id": "20230111103403",
  81. "version": 1,
  82. "content": {
  83. pageNumber,
  84. "sys_enterpriseid": data.sys_enterpriseid,
  85. "sa_accountclassid": data.sa_accountclassid,
  86. "where": {
  87. begindate: this.data.begindate,
  88. enddate: this.data.enddate
  89. }
  90. }
  91. }).then(res => {
  92. console.log("账户流水", res)
  93. if (res.msg == '成功') {
  94. let expend = 0, //收入
  95. earning = 0; //支出
  96. if (res.data.length) {
  97. let expendObj = res.data[0].total.find(v => v.type == 1);
  98. if (expendObj) expend = CNY(expendObj.sumamount);
  99. let earningObj = res.data[0].total.find(v => v.type == 0);
  100. if (earningObj) earning = CNY(earningObj.sumamount);
  101. }
  102. res.data = res.data.map(v => {
  103. v.amount = CNY(v.amount)
  104. v.discountamount = CNY(v.discountamount)
  105. v.showBalance = CNY(v.balance)
  106. return v
  107. })
  108. pageNumber += 1;
  109. pageTotal = res.pageTotal;
  110. this.setData({
  111. recordList: res.pageNumber == 1 ? res.data : this.data.recordList.concat(res.data),
  112. expend,
  113. earning
  114. });
  115. }
  116. })
  117. },
  118. onReachBottom() {
  119. this.getList();
  120. }
  121. })