payMethods.vue 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  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.name }}</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. <pieCharts :chartData="chartsPieData"></pieCharts>
  26. </div>
  27. </div>
  28. </template>
  29. <script>
  30. import ucharts from '../echarts/line.vue'
  31. import pieCharts from '../echarts/pie.vue'
  32. export default {
  33. components: {
  34. ucharts,
  35. pieCharts
  36. },
  37. props:{
  38. tableData:{
  39. type:Array,
  40. default(){
  41. return []
  42. }
  43. }
  44. },
  45. computed:{
  46. chartsData(){
  47. let categories = [];
  48. let series = [];
  49. let obj = {name:'房费',data:[]};
  50. let obj1 = {name:'非房费', data:[]}
  51. let obj2 = {name:'小计', data:[]}
  52. if (this.tableData.length == 0) {
  53. return { categories, series }
  54. }
  55. this.tableData.forEach(ele=>{
  56. categories.push(ele.name)
  57. obj.data.push(ele.room_money)
  58. obj1.data.push(ele.other_money)
  59. obj2.data.push(ele.room_money*1+ele.other_money*1)
  60. })
  61. series = [obj, obj1, obj2]
  62. return { categories, series }
  63. },
  64. chartsPieData(){
  65. console.log('111111111',this.tableData);
  66. let series= []
  67. this.tableData.forEach(ele=>{
  68. series.push({name:ele.name,value:((ele.room_money*1+ele.other_money*1)/this.tableData.reduce((pre, cur)=> pre+(cur.room_money*1+cur.other_money*1), 0 )).toFixed(0)})
  69. })
  70. console.log('222222222222',series);
  71. return series
  72. }
  73. },
  74. data() {
  75. return {
  76. loading:false,
  77. }
  78. }
  79. }
  80. </script>
  81. <style lang="scss">
  82. </style>