longTermHousingStatus.vue 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220
  1. <template>
  2. <view>
  3. <Header @change="headerChange">
  4. <template #search>
  5. <div class="header-top">
  6. <b style="color:rgb(60, 156, 255)">远期房态</b>
  7. <div style="font-size: 12px;" class="header-top">
  8. <u-switch size="12" v-model="isContainLeave" @change="change"></u-switch>包含当日预离房
  9. </div>
  10. </div>
  11. </template>
  12. <template #section>
  13. <div style="display:flex;align-items:center;font-size: 12px;padding:0 10px;">
  14. <span style="color:#00000060;">请选择日期</span>
  15. <div @click="show = true" class="calendar">{{`${startTime} ~ ${endTime}`}}</div>
  16. </div>
  17. </template>
  18. </Header>
  19. <u-calendar closeOnClickOverlay :show="show" mode="range" @close="close" @confirm="confirm"></u-calendar>
  20. <div style="background:#fff">
  21. <div class="table">
  22. <table>
  23. <tr>
  24. <td>房型</td>
  25. <td style="font-size: 14px;" v-for="item in timeList" :key="item.id">{{item}}</td>
  26. </tr>
  27. <tr v-for="(item, index) in dataList" :key="index">
  28. <td>{{item.layout_name}}</td>
  29. <td v-for="sItem in timeList" :key="sItem.id">
  30. <span style="color:rgb(255, 141, 26)">{{item[sItem].leaveCount || 0}}/</span>
  31. <span style="color:rgb(42, 130, 228)">{{item[sItem].livingCount || 0}}/</span>
  32. <span style="color:rgb(67, 207, 124)">{{item.count - item[sItem].livingCount || 0}}</span>
  33. </td>
  34. </tr>
  35. </table>
  36. </div>
  37. <div class="explain">
  38. <div>
  39. 说明:
  40. </div>
  41. <div>1、15/25/38,15表示当日预离间数,25表示占用房间数,38表示可用房间数</div>
  42. <div>2、占用放 = 在住房+预定房+自用房+维修房+预离房(可选)+锁房</div>
  43. <div>3、可用房 = 总房·占用房</div>
  44. </div>
  45. </div>
  46. </view>
  47. </template>
  48. <script>
  49. import Header from '@/components/header.vue'
  50. import {
  51. getFutureRoomStatus
  52. } from '../../utils/api'
  53. export default {
  54. components: {
  55. Header
  56. },
  57. data() {
  58. return {
  59. isContainLeave: true,
  60. startTime: (new Date().toLocaleDateString()).replace(/\//g, '-'),
  61. endTime: (new Date(new Date().getTime() + 24 * 60 * 60 * 1000).toLocaleDateString()).replace(/\//g, '-'),
  62. show: false,
  63. timeList: [],
  64. dataList: [],
  65. }
  66. },
  67. mounted() {
  68. this.createTime()
  69. this.getData()
  70. },
  71. methods: {
  72. change(e) {
  73. console.log(e)
  74. this.isContainLeave = e
  75. this.getData()
  76. },
  77. close() {
  78. this.show = false
  79. },
  80. confirm(e) {
  81. console.log(e);
  82. this.show = false
  83. this.timeList = e
  84. this.startTime = e[0]
  85. this.endTime = e[e.length - 1]
  86. this.getData()
  87. },
  88. createTime() {
  89. // Create a new Date object
  90. const today = new Date();
  91. // Get yesterday's date by subtracting one day from today's date
  92. const yesterday = new Date(today);
  93. yesterday.setDate(yesterday.getDate() - 1);
  94. // Get tomorrow's date by adding one day to today's date
  95. const tomorrow = new Date(today);
  96. tomorrow.setDate(tomorrow.getDate() + 1);
  97. // Store the dates in an array with yyyy-mm-dd format
  98. const dates = [
  99. // yesterday.toISOString().slice(0, 10),
  100. today.toISOString().slice(0, 10),
  101. tomorrow.toISOString().slice(0, 10)
  102. ];
  103. this.timeList = dates
  104. // return dates
  105. },
  106. getData() {
  107. getFutureRoomStatus({
  108. start: this.startTime,
  109. end: this.endTime,
  110. isContainLeave: this.isContainLeave
  111. }).then(res => {
  112. console.log(res)
  113. let brr = []
  114. res.result.layoutRooms.forEach(ele => {
  115. brr.push({
  116. layout_name: ele.layoutName,
  117. count: ele.roomCount,
  118. data: res.result.dateList.filter(item => item.layoutId == ele.layoutId)
  119. })
  120. })
  121. brr.forEach(ele => {
  122. ele.data.forEach(item => {
  123. ele[item.date] = item
  124. })
  125. })
  126. console.log(brr);
  127. let arr = []
  128. brr[0].data.forEach(ele => {
  129. arr.push({
  130. title: ele.date,
  131. align: "center",
  132. dataIndex: ele.date,
  133. width: '120px',
  134. scopedSlots: {
  135. customRender: 'long'
  136. },
  137. })
  138. })
  139. this.dataList = brr
  140. // this.columns = this.columns.concat(arr)
  141. console.log('1111111111111111', arr);
  142. })
  143. },
  144. headerChange() {
  145. this.getData()
  146. }
  147. }
  148. }
  149. </script>
  150. <style lang="scss" scoped>
  151. page {
  152. background-color: #f5f5f5;
  153. }
  154. .header-top {
  155. display: flex;
  156. justify-content: space-between;
  157. align-items: center;
  158. padding: 10px;
  159. }
  160. .calendar {
  161. border: 1px solid;
  162. padding: 5px 10px;
  163. border-radius: 5px;
  164. color: #409EFF;
  165. font-size: 12px;
  166. min-width: 30%;
  167. margin-left: 10px;
  168. }
  169. .table {
  170. width: 98%;
  171. font-size: 16px;
  172. padding: 2px;
  173. box-shadow: 0 4px 4px rgba(0, 0, 0, 0.4);
  174. overflow-x: auto;
  175. overflow-y: hidden;
  176. table {
  177. width: 100%;
  178. height: 100%;
  179. table-layout: fixed;
  180. }
  181. table,
  182. td {
  183. // width: 100%;
  184. border: 1px solid #ccc;
  185. border-collapse: collapse;
  186. }
  187. table>tr>td {
  188. text-align: center;
  189. height: 40px;
  190. }
  191. table>tr>td:first-child {
  192. background: #409EFF;
  193. color: #fff;
  194. width: 115px;
  195. position: sticky;
  196. left: 0;
  197. padding: 0;
  198. }
  199. table>tr>td:not(:first-child) {
  200. width: 100px
  201. }
  202. }
  203. .explain {
  204. padding: 20px;
  205. font-size: 14px;
  206. color: #999;
  207. }
  208. </style>