time.vue 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. <template>
  2. <div>
  3. <uni-table style="margin-top:40px;" ref="table" :loading="loading" border stripe type="" emptyText="暂无更多数据" @selection-change="selectionChange">
  4. <uni-tr>
  5. <uni-th width="60" align="center">收款日期</uni-th>
  6. <uni-th width="60" align="center">房费</uni-th>
  7. <uni-th width="60" align="center">非房费</uni-th>
  8. <uni-th width="60" align="center">小计</uni-th>
  9. </uni-tr>
  10. <uni-tr v-for="(item, index) in tableData" :key="index">
  11. <uni-td align="center">{{ item.time }}</uni-td>
  12. <uni-td align="center">
  13. {{ item.room_money }}
  14. </uni-td>
  15. <uni-td align="center">{{ item.other_money }}</uni-td>
  16. <uni-td align="center">
  17. {{ item.room_money*1+item.other_money }}
  18. </uni-td>
  19. </uni-tr>
  20. </uni-table>
  21. <div style="margin-top:20px;">
  22. <ucharts :chartData="chartsData" :type="'column'"></ucharts>
  23. </div>
  24. <div style="margin-top:20px;">
  25. <ucharts :chartData="chartsData" :type="'line'"></ucharts>
  26. </div>
  27. </div>
  28. </template>
  29. <script>
  30. import ucharts from '../echarts/line.vue'
  31. export default {
  32. components: {
  33. ucharts
  34. },
  35. props: {
  36. tableData: {
  37. type: Array,
  38. default () {
  39. return []
  40. }
  41. }
  42. },
  43. computed: {
  44. chartsData() {
  45. let categories = [];
  46. let series = [];
  47. let obj = {
  48. name: '房费',
  49. data: []
  50. };
  51. let obj1 = {
  52. name: '非房费',
  53. data: []
  54. }
  55. let obj2 = {
  56. name: '小计',
  57. data: []
  58. }
  59. console.log(this.tableData);
  60. if (!this.tableData || this.tableData.length === 0) {
  61. return {
  62. categories,
  63. series
  64. }
  65. } else {
  66. this.tableData.forEach(ele => {
  67. categories.push(ele.time)
  68. obj.data.push(ele.room_money)
  69. obj1.data.push(ele.other_money)
  70. obj2.data.push(ele.room_money * 1 + ele.other_money * 1)
  71. })
  72. series = [obj, obj1, obj2]
  73. return {
  74. categories,
  75. series
  76. }
  77. }
  78. }
  79. },
  80. mounted() {
  81. console.log(this.tableData);
  82. },
  83. data() {
  84. return {
  85. loading: false,
  86. }
  87. }
  88. }
  89. </script>
  90. <style>
  91. </style>