roomType.vue 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  1. <template>
  2. <div>
  3. <uni-table style="margin-top:40px;" ref="table" :loading="loading" border stripe type="selection" 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-th width="60" align="center">非房费收入</uni-th>
  10. <uni-th width="60" align="center">收入小计</uni-th>
  11. <uni-th width="60" align="center">平均房价</uni-th>
  12. </uni-tr>
  13. <uni-tr v-for="(item, index) in tableData" :key="index">
  14. <uni-td align="center">{{ item.name }}</uni-td>
  15. <uni-td align="center">
  16. <view class="name">{{ item.rz_count }}</view>
  17. </uni-td>
  18. <uni-td align="center">{{ ((item.rz_count/item.room_count) || 0).toFixed(2)}}</uni-td>
  19. <uni-td align="center">{{ item.room_money }}</uni-td>
  20. <uni-td align="center">{{ item.other_money }}</uni-td>
  21. <uni-td align="center">{{ item.sum_money }}</uni-td>
  22. <uni-td align="center">{{ item.room_average_price }}</uni-td>
  23. </uni-tr>
  24. </uni-table>
  25. <div style="margin-top:20px;">
  26. <ucharts :chartData="chartsData" :type="'column'"></ucharts>
  27. </div>
  28. <div style="margin-top:20px;">
  29. <pieCharts :chartData="chartsPieData" ></pieCharts>
  30. </div>
  31. <div style="margin-top:20px;">
  32. <pieCharts :chartData="chartsPieData2" ></pieCharts>
  33. </div>
  34. </div>
  35. </template>
  36. <script>
  37. import ucharts from '../echarts/line.vue'
  38. import pieCharts from '../echarts/pie.vue'
  39. export default {
  40. components: {
  41. ucharts,
  42. pieCharts
  43. },
  44. props: {
  45. tableData: {
  46. type: Array,
  47. default () {
  48. return []
  49. }
  50. }
  51. },
  52. computed: {
  53. chartsData() {
  54. let categories = [];
  55. let series = [];
  56. let obj = {
  57. name: '房费收入',
  58. data: []
  59. };
  60. let obj1 = {
  61. name: '间数',
  62. data: []
  63. }
  64. if (this.tableData.length == 0) {
  65. return {
  66. categories,
  67. series
  68. }
  69. }
  70. this.tableData.forEach(ele => {
  71. categories.push(ele.name)
  72. obj.data.push(ele.room_money)
  73. obj1.data.push(ele.rz_count)
  74. })
  75. series = [obj, obj1]
  76. return {
  77. categories,
  78. series
  79. }
  80. },
  81. chartsPieData() {
  82. console.log('111111111', this.tableData);
  83. let series = []
  84. this.tableData.forEach(ele => {
  85. series.push({
  86. name: ele.name,
  87. value: ele.room_money
  88. })
  89. })
  90. console.log('222222222222', series);
  91. return series
  92. },
  93. chartsPieData2(){
  94. console.log('111111111', this.tableData);
  95. let series = []
  96. this.tableData.forEach(ele => {
  97. series.push({
  98. name: ele.name,
  99. value: ele.other_money
  100. })
  101. })
  102. console.log('222222222222', series);
  103. return series
  104. }
  105. },
  106. data() {
  107. return {
  108. loading: false,
  109. }
  110. }
  111. }
  112. </script>
  113. <style lang="scss">
  114. /deep/.uni-table {
  115. min-width: 100vw !important;
  116. }
  117. /deep/.uni-table-th {
  118. font-size: 12px !important;
  119. }
  120. </style>