index.js 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148
  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. let usertype = wx.getStorageSync('userMsg').usertype
  20. this.setData({
  21. dateEnd: formatTime(new Date(), '-').split(" ")[0],
  22. usertype
  23. });
  24. if (usertype == 1) {
  25. _Http.basic({
  26. "id": 20240111085504,
  27. "content": {
  28. "hrid": wx.getStorageSync('userMsg').hrid,
  29. "pageSize": 999,
  30. "pageNumner": 1
  31. }
  32. }).then(res => {
  33. console.log("usertype1", res)
  34. this.setData({
  35. accountList: res.data.map(v => {
  36. v.balance = CNY(v.balance)
  37. v.expectedReward = CNY(v.expectedReward)
  38. v.accountname = v.hraccountname
  39. return v
  40. })
  41. });
  42. this.getList(true);
  43. })
  44. } else {
  45. _Http.basic({
  46. id: 20221008145903,
  47. "content": {
  48. pageSize: 999,
  49. type: 1,
  50. "where": {
  51. "condition": ""
  52. }
  53. }
  54. }).then(res => {
  55. console.log(res)
  56. this.setData({
  57. accountList: res.data.map(v => {
  58. v.creditquota = CNY(v.creditquota);
  59. v.usable = CNY(currency(v.creditquota).add(v.balance));
  60. v.balance = CNY(v.balance)
  61. return v
  62. })
  63. });
  64. this.getList(true);
  65. })
  66. }
  67. },
  68. /* 切换查看账户 */
  69. changeAccount(e) {
  70. this.setData({
  71. active: e.detail.value || e.detail.current
  72. });
  73. this.getList();
  74. },
  75. /* 切换查看时间 */
  76. changeDate(e) {
  77. this.setData({
  78. [`${e.currentTarget.dataset.name}`]: e.detail.value
  79. })
  80. this.getList(true);
  81. },
  82. getList() {
  83. let data = this.data.accountList[this.data.active];
  84. let params = this.data.usertype == 1 ? {
  85. "id": 20240111090304,
  86. "content": {
  87. "pageSize": 999999,
  88. "pageNumber": 1,
  89. "hrid": wx.getStorageSync('userMsg').hrid,
  90. "where": {
  91. "condition": "",
  92. begindate: this.data.begindate,
  93. enddate: this.data.enddate,
  94. "type": "",
  95. "sa_hraccountclassid": data.sa_hraccountclassid
  96. }
  97. }
  98. } : {
  99. "id": "20230111103403",
  100. "version": 1,
  101. "content": {
  102. "sys_enterpriseid": data.sys_enterpriseid,
  103. "sa_accountclassid": data.sa_accountclassid,
  104. "where": {
  105. begindate: this.data.begindate,
  106. enddate: this.data.enddate
  107. }
  108. }
  109. };
  110. _Http.basic(params).then(res => {
  111. console.log("账户流水", res)
  112. if (res.msg == '成功') {
  113. let expend = 0, //收入
  114. earning = 0; //支出
  115. if (res.data.total.length) {
  116. let expendObj = res.data.total.find(v => v.type == 1);
  117. if (expendObj) expend = CNY(expendObj.sumamount);
  118. let earningObj = res.data.total.find(v => v.type == 0);
  119. if (earningObj) earning = CNY(earningObj.sumamount);
  120. }
  121. this.setData({
  122. recordList: res.data.rows.map(v => {
  123. v.amount = CNY(v.amount)
  124. v.showBalance = CNY(v.balance)
  125. v.showRemarks = wx.getStorageSync('userMsg').usertype == 1 ? v.allremarks : v.remarks
  126. return v
  127. }),
  128. expend,
  129. earning
  130. })
  131. }
  132. })
  133. },
  134. onReady() {
  135. },
  136. toDetail(e) {
  137. let {
  138. item
  139. } = e.currentTarget.dataset;
  140. item.enddate = this.data.enddate;
  141. item.begindate = this.data.begindate;
  142. wx.navigateTo({
  143. url: '/packageA/account/detail?item=' + JSON.stringify(item)
  144. })
  145. }
  146. })