details.vue 5.7 KB

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