| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220 |
- <template>
- <view>
- <Header @change="headerChange">
- <template #search>
- <div class="header-top">
- <b style="color:rgb(60, 156, 255)">远期房态</b>
- <div style="font-size: 12px;" class="header-top">
- <u-switch size="12" v-model="isContainLeave" @change="change"></u-switch>包含当日预离房
- </div>
- </div>
- </template>
- <template #section>
- <div style="display:flex;align-items:center;font-size: 12px;padding:0 10px;">
- <span style="color:#00000060;">请选择日期</span>
- <div @click="show = true" class="calendar">{{`${startTime} ~ ${endTime}`}}</div>
- </div>
- </template>
- </Header>
- <u-calendar closeOnClickOverlay :show="show" mode="range" @close="close" @confirm="confirm"></u-calendar>
- <div style="background:#fff">
- <div class="table">
- <table>
- <tr>
- <td>房型</td>
- <td style="font-size: 14px;" v-for="item in timeList" :key="item.id">{{item}}</td>
- </tr>
- <tr v-for="(item, index) in dataList" :key="index">
- <td>{{item.layout_name}}</td>
- <td v-for="sItem in timeList" :key="sItem.id">
- <span style="color:rgb(255, 141, 26)">{{item[sItem].leaveCount || 0}}/</span>
- <span style="color:rgb(42, 130, 228)">{{item[sItem].livingCount || 0}}/</span>
- <span style="color:rgb(67, 207, 124)">{{item.count - item[sItem].livingCount || 0}}</span>
- </td>
- </tr>
- </table>
- </div>
- <div class="explain">
- <div>
- 说明:
- </div>
- <div>1、15/25/38,15表示当日预离间数,25表示占用房间数,38表示可用房间数</div>
- <div>2、占用放 = 在住房+预定房+自用房+维修房+预离房(可选)+锁房</div>
- <div>3、可用房 = 总房·占用房</div>
- </div>
- </div>
- </view>
- </template>
- <script>
- import Header from '@/components/header.vue'
- import {
- getFutureRoomStatus
- } from '../../utils/api'
- export default {
- components: {
- Header
- },
- data() {
- return {
- isContainLeave: true,
- startTime: (new Date().toLocaleDateString()).replace(/\//g, '-'),
- endTime: (new Date(new Date().getTime() + 24 * 60 * 60 * 1000).toLocaleDateString()).replace(/\//g, '-'),
- show: false,
- timeList: [],
- dataList: [],
- }
- },
- mounted() {
- this.createTime()
- this.getData()
- },
- methods: {
- change(e) {
- console.log(e)
- this.isContainLeave = e
- this.getData()
- },
- close() {
- this.show = false
- },
- confirm(e) {
- console.log(e);
- this.show = false
- this.timeList = e
- this.startTime = e[0]
- this.endTime = e[e.length - 1]
- this.getData()
- },
- createTime() {
- // Create a new Date object
- const today = new Date();
- // Get yesterday's date by subtracting one day from today's date
- const yesterday = new Date(today);
- yesterday.setDate(yesterday.getDate() - 1);
- // Get tomorrow's date by adding one day to today's date
- const tomorrow = new Date(today);
- tomorrow.setDate(tomorrow.getDate() + 1);
- // Store the dates in an array with yyyy-mm-dd format
- const dates = [
- // yesterday.toISOString().slice(0, 10),
- today.toISOString().slice(0, 10),
- tomorrow.toISOString().slice(0, 10)
- ];
- this.timeList = dates
- // return dates
- },
- getData() {
- getFutureRoomStatus({
- start: this.startTime,
- end: this.endTime,
- isContainLeave: this.isContainLeave
- }).then(res => {
- console.log(res)
- let brr = []
- res.result.layoutRooms.forEach(ele => {
- brr.push({
- layout_name: ele.layoutName,
- count: ele.roomCount,
- data: res.result.dateList.filter(item => item.layoutId == ele.layoutId)
- })
- })
- brr.forEach(ele => {
- ele.data.forEach(item => {
- ele[item.date] = item
- })
- })
- console.log(brr);
- let arr = []
- brr[0].data.forEach(ele => {
- arr.push({
- title: ele.date,
- align: "center",
- dataIndex: ele.date,
- width: '120px',
- scopedSlots: {
- customRender: 'long'
- },
- })
- })
- this.dataList = brr
- // this.columns = this.columns.concat(arr)
- console.log('1111111111111111', arr);
- })
- },
- headerChange() {
- this.getData()
- }
- }
- }
- </script>
- <style lang="scss" scoped>
- page {
- background-color: #f5f5f5;
- }
- .header-top {
- display: flex;
- justify-content: space-between;
- align-items: center;
- padding: 10px;
- }
- .calendar {
- border: 1px solid;
- padding: 5px 10px;
- border-radius: 5px;
- color: #409EFF;
- font-size: 12px;
- min-width: 30%;
- margin-left: 10px;
- }
- .table {
- width: 98%;
- font-size: 16px;
- padding: 2px;
- box-shadow: 0 4px 4px rgba(0, 0, 0, 0.4);
- overflow-x: auto;
- overflow-y: hidden;
- table {
- width: 100%;
- height: 100%;
- table-layout: fixed;
- }
- table,
- td {
- // width: 100%;
- border: 1px solid #ccc;
- border-collapse: collapse;
- }
- table>tr>td {
- text-align: center;
- height: 40px;
- }
- table>tr>td:first-child {
- background: #409EFF;
- color: #fff;
- width: 115px;
- position: sticky;
- left: 0;
- padding: 0;
- }
- table>tr>td:not(:first-child) {
- width: 100px
- }
- }
- .explain {
- padding: 20px;
- font-size: 14px;
- color: #999;
- }
- </style>
|