index.js 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  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. "where": {
  23. "condition": ""
  24. }
  25. }
  26. }).then(res => {
  27. console.log(res)
  28. this.setData({
  29. accountList: res.data
  30. });
  31. this.getList(true);
  32. })
  33. },
  34. /* 切换查看账户 */
  35. changeAccount(e) {
  36. this.setData({
  37. active: e.detail.value || e.detail.current
  38. });
  39. this.getList();
  40. },
  41. /* 切换查看时间 */
  42. changeDate(e) {
  43. this.setData({
  44. ymonth: e.detail.value
  45. })
  46. this.getList();
  47. },
  48. getList() {
  49. let data = this.data.accountList[this.data.active];
  50. _Http.basic({
  51. "id": "20230111103403",
  52. "version": 1,
  53. "content": {
  54. "sys_enterpriseid": data.sys_enterpriseid,
  55. "sa_accountclassid": data.sa_accountclassid,
  56. "where": {
  57. "year": this.data.ymonth.split("-")[0],
  58. "month": this.data.ymonth.split("-")[1]
  59. }
  60. }
  61. }).then(res => {
  62. console.log("账户流水", res)
  63. if (res.msg == '成功') {
  64. let expend = 0, //收入
  65. earning = 0; //支出
  66. if (res.data.total.length) {
  67. let expendObj = res.data.total.find(v => v.type == 1);
  68. if (expendObj) expend = expendObj.sumamount;
  69. let earningObj = res.data.total.find(v => v.type == 1);
  70. if (earningObj) earning = earningObj.sumamount;
  71. }
  72. this.setData({
  73. recordList: res.data.rows,
  74. expend,
  75. earning
  76. })
  77. }
  78. })
  79. },
  80. onReady() {
  81. },
  82. })