index.js 2.3 KB

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