feeItems.vue 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  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-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>{{ item.date }}</uni-td> -->
  15. <uni-td align="center">
  16. <view class="name">{{ item.name }}</view>
  17. </uni-td>
  18. <uni-td align="center">{{ item['微信'] }}</uni-td>
  19. <uni-td align="center">{{ item['支付宝'] }}</uni-td>
  20. <uni-td align="center">{{ item['现金'] }}</uni-td>
  21. <uni-td align="center">{{ item['银联卡'] }}</uni-td>
  22. <uni-td align="center">{{ item['其他'] }}</uni-td>
  23. <uni-td align="center">{{ filter(item) }}</uni-td>
  24. </uni-tr>
  25. </uni-table>
  26. <div style="margin-top:20px;">
  27. <ucharts :chartData="chartsData" :type="'column'"></ucharts>
  28. </div>
  29. <div style="margin-top:20px;">
  30. <pieCharts :chartData="chartsPieData"></pieCharts>
  31. </div>
  32. </div>
  33. </template>
  34. <script>
  35. import ucharts from '../echarts/line.vue'
  36. import pieCharts from '../echarts/pie.vue'
  37. export default {
  38. components: {
  39. ucharts,
  40. pieCharts
  41. },
  42. props:{
  43. tableData:{
  44. type:Array,
  45. default(){
  46. return []
  47. }
  48. }
  49. },
  50. data() {
  51. return {
  52. loading:false,
  53. }
  54. },
  55. computed: {
  56. chartsData() {
  57. let categories = [];
  58. let series = [];
  59. let obj = {
  60. name: '小计',
  61. data: []
  62. }
  63. console.log(this.tableData);
  64. if (!this.tableData || this.tableData.length === 0) {
  65. return {
  66. categories,
  67. series
  68. }
  69. } else {
  70. this.tableData.forEach(ele => {
  71. categories.push(ele.name)
  72. obj.data.push(this.filter(ele))
  73. })
  74. series = [obj]
  75. return {
  76. categories,
  77. series
  78. }
  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: this.filter(ele)
  88. })
  89. })
  90. console.log('222222222222', series);
  91. return series
  92. },
  93. },
  94. methods:{
  95. filter(object){
  96. let arr = Object.keys(object).filter(item=>item!='name')
  97. let count = 0
  98. arr.forEach(item=>{
  99. count += object[item]
  100. })
  101. return count
  102. }
  103. }
  104. }
  105. </script>
  106. <style lang="scss">
  107. /deep/.uni-table {
  108. min-width: 100vw !important;
  109. }
  110. /deep/.uni-table-th {
  111. font-size: 12px !important;
  112. }
  113. </style>