details.vue 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183
  1. <template>
  2. <view class="page" :style="{'height':h+'px','padding-top':mt+'px'}">
  3. <c-nav-bar :title="title"></c-nav-bar>
  4. <view class="table">
  5. <view class="t_th">
  6. <view class="b_grey b_rb">房型</view>
  7. <view class="b_grey b_rb">数量</view>
  8. <view class="b_grey b_rb">可售</view>
  9. <view class="b_grey b_rb">占用</view>
  10. <view class="b_grey b_rb">不可售</view>
  11. </view>
  12. <view v-if="list.length>0" class="t_item" v-for="(item,index) in list" :key="index">
  13. <view class="b_grey b_rb">{{item.houseBaseName}}</view>
  14. <view class="b_rb" :class="(index==list.length-1||index==list.length-2)?'b_grey':''">{{item.totalNums}}
  15. </view>
  16. <view class="b_rb" :class="(index==list.length-1||index==list.length-2)?'b_grey':''">{{item.saleNums}}
  17. </view>
  18. <view class="b_rb" :class="(index==list.length-1||index==list.length-2)?'b_grey':''">{{item.occupyNums}}
  19. </view>
  20. <view class="b_rb" :class="(index==list.length-1||index==list.length-2)?'b_grey':''">{{item.unSaleNums}}
  21. </view>
  22. </view>
  23. </view>
  24. </view>
  25. </template>
  26. <script>
  27. export default {
  28. data() {
  29. return {
  30. title: '',
  31. item: null,
  32. list: []
  33. }
  34. },
  35. onLoad(option) {
  36. if (option.item) {
  37. this.item = JSON.parse(decodeURIComponent(option.item));
  38. this.title = this.item.dateDay + '房情表';
  39. this.getList();
  40. }
  41. },
  42. methods: {
  43. getList() {
  44. this.$api.get('/merchant/hotel/home/getRoomConditionList', {
  45. homestayId: uni.getStorageSync('homestayId'),
  46. dateDay: this.item.dateDay
  47. }).then(res => {
  48. if (res.data.code === 0) {
  49. if (res.data.data.length > 6 || res.data.data.length == 6) {
  50. this.list = res.data.data.splice(0, res.data.data.length - 3);
  51. console.log('000000', this.list);
  52. let totalNums = this.list.reduce((cur, pre) => cur + pre.totalNums, 0);
  53. let saleNums = this.list.reduce((cur, pre) => cur + pre.saleNums, 0);
  54. let occupyNums = this.list.reduce((cur, pre) => cur + pre.occupyNums, 0);
  55. let unSaleNums = this.list.reduce((cur, pre) => cur + pre.unSaleNums, 0);
  56. this.list.push({
  57. houseBaseName: '占房屋总数的比例',
  58. totalNums: '-',
  59. saleNums: (saleNums / totalNums * 100).toFixed(2) + '%',
  60. occupyNums: (occupyNums / totalNums * 100).toFixed(2) + '%',
  61. unSaleNums: (unSaleNums / totalNums * 100).toFixed(2) + '%'
  62. })
  63. this.list.push({
  64. houseBaseName: '总计',
  65. totalNums: totalNums,
  66. saleNums: saleNums,
  67. occupyNums: occupyNums,
  68. unSaleNums: unSaleNums
  69. })
  70. } else if (res.data.data.length == 3) {
  71. this.list = res.data.data.splice(0, res.data.data.length - 2);
  72. console.log('1111', this.list);
  73. let totalNums = this.list.reduce((cur, pre) => cur + pre.totalNums, 0);
  74. let saleNums = this.list.reduce((cur, pre) => cur + pre.saleNums, 0);
  75. let occupyNums = this.list.reduce((cur, pre) => cur + pre.occupyNums, 0);
  76. let unSaleNums = this.list.reduce((cur, pre) => cur + pre.unSaleNums, 0);
  77. this.list.push({
  78. houseBaseName: '占房屋总数的比例',
  79. totalNums: '-',
  80. saleNums: (saleNums / totalNums * 100).toFixed(2) + '%',
  81. occupyNums: (occupyNums / totalNums * 100).toFixed(2) + '%',
  82. unSaleNums: (unSaleNums / totalNums * 100).toFixed(2) + '%'
  83. })
  84. this.list.push({
  85. houseBaseName: '总计',
  86. totalNums: totalNums,
  87. saleNums: saleNums,
  88. occupyNums: occupyNums,
  89. unSaleNums: unSaleNums
  90. })
  91. } else {
  92. this.list = res.data.data.splice(0, res.data.data.length - 2);
  93. console.log('2222', this.list);
  94. let totalNums = this.list.reduce((cur, pre) => cur + pre.totalNums, 0);
  95. let saleNums = this.list.reduce((cur, pre) => cur + pre.saleNums, 0);
  96. let occupyNums = this.list.reduce((cur, pre) => cur + pre.occupyNums, 0);
  97. let unSaleNums = this.list.reduce((cur, pre) => cur + pre.unSaleNums, 0);
  98. this.list.push({
  99. houseBaseName: '占房屋总数的比例',
  100. totalNums: '-',
  101. saleNums: (saleNums / totalNums * 100).toFixed(2) + '%',
  102. occupyNums: (occupyNums / totalNums * 100).toFixed(2) + '%',
  103. unSaleNums: (unSaleNums / totalNums * 100).toFixed(2) + '%'
  104. })
  105. this.list.push({
  106. houseBaseName: '总计',
  107. totalNums: totalNums,
  108. saleNums: saleNums,
  109. occupyNums: occupyNums,
  110. unSaleNums: unSaleNums
  111. })
  112. }
  113. } else this.$showToast(res.data.msg)
  114. })
  115. }
  116. }
  117. }
  118. </script>
  119. <style scoped lang="less">
  120. .page {
  121. background: #F9FAFC;
  122. .table {
  123. width: 100%;
  124. border-top: 1rpx solid #D1D1D1;
  125. border-left: 1rpx solid #D1D1D1;
  126. margin-top: 20rpx;
  127. .t_th {
  128. display: flex;
  129. align-items: center;
  130. justify-content: space-around;
  131. &>view {
  132. width: 25%;
  133. display: flex;
  134. align-items: center;
  135. justify-content: center;
  136. padding: 20rpx 0;
  137. box-sizing: border-box;
  138. font-size: 24rpx;
  139. font-family: PingFang SC, PingFang SC;
  140. font-weight: 400;
  141. color: #1F2425;
  142. }
  143. }
  144. .t_item {
  145. display: flex;
  146. align-items: center;
  147. justify-content: space-around;
  148. &>view {
  149. width: 25%;
  150. height: 106rpx;
  151. display: flex;
  152. align-items: center;
  153. justify-content: center;
  154. box-sizing: border-box;
  155. background: #ffffff;
  156. font-size: 24rpx;
  157. font-family: PingFang SC, PingFang SC;
  158. font-weight: 400;
  159. color: #1F2425;
  160. text-align: center;
  161. }
  162. }
  163. }
  164. .b_grey {
  165. background: #FAFAFA !important;
  166. }
  167. .b_rb {
  168. border-right: 1rpx solid #D1D1D1;
  169. border-bottom: 1rpx solid #D1D1D1;
  170. }
  171. }
  172. </style>