index.js 2.8 KB

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