123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816 |
- <template>
- <view class="page" :style="{'padding-top':mt+'px'}">
- <c-nav-bar title="房态" :showIcon="false" :titleStyle="titleStyle" bgColor="transparent"></c-nav-bar>
- <view class="leftFixed" v-if="leftData.length!=0" :style="{'top':(mt+2)+'px'}">
- <view class="tj" :style="{'top':mt+'px'}"></view>
- <view class="year">
- <u-icon name="calendar-fill" color="#B9C2D2" size="40" style="margin-bottom:10rpx;"></u-icon>
- <text style="font-size: 24rpx;">2024</text>
- </view>
- <view v-for="(item,key,i) in leftData" :key="i"
- :class="indexArr[i]!=key.split('-')[0]?'mg0 fixedItem':'fixedItem'">
- <view class="head" v-if="indexArr[i]==key.split('-')[0]" style="margin-top: 16rpx;">
- <!-- <text>{{key.split('-')[0]}}F</text> -->
- <view class="roomType" :style="{'left':scrollLeft+'px'}">{{indexHouseNameArr[i]}}</view>
- <view class="rightIcon" @click="open(i,key.split('-')[0],false)" v-if="opens[i]">
- <text>收起</text>
- <u-icon name="arrow-up-fill" size="18" style="margin-left: 10rpx;"></u-icon>
- </view>
- <view class="rightIcon" @click="open(i,key.split('-')[0],true)" v-else>
- <text>展开</text>
- <u-icon name="arrow-down-fill" size="18" style="margin-left: 10rpx;"></u-icon>
- </view>
- </view>
- <template v-if="opens[i]">
- <!-- <view class="roomType" :style="{'left':scrollLeft+'px'}">{{key.split('-')[1]}}</view> -->
- <text v-for="(item2,index2) in item" class="roomNumber">
- {{item2.roomNumber}}
- </text>
- </template>
- </view>
- </view>
- <view>
- <view class="content">
- <view class="tj" :style="{'top':mt+'px'}">
- <view class="item">
- <text class="label">{{info.bookRooms||0}}</text>
- <text>待入住</text>
- </view>
- <view class="item">
- <text class="label">{{info.checkinRooms||0}}</text>
- <text>已入住</text>
- </view>
- <view class="item">
- <text class="label">{{info.checkoutRooms||0}}</text>
- <text>已退房</text>
- </view>
- </view>
- <view class="date">
- <view class="item">
- <u-icon name="calendar-fill" color="#B9C2D2" size="40" style="margin-bottom:10rpx;"></u-icon>
- <text style="font-size: 24rpx;">2024</text>
- </view>
- <view class="item" v-for="(item,keynme,index) in xdata" :key="index">
- <text>{{item.rentDate.substring(5)}}</text>
- <text>{{weeks[item.rentWeek]}}</text>
- <text>剩{{item.spareRooms||0}}间</text>
- </view>
- </view>
- <view style="height:18rpx"></view>
- <view class="floorData" v-if="leftData.length!=0">
- <view v-for="(item,key,i) in leftData" :key="i">
- <view class="head" v-if="indexArr[i]==key.split('-')[0]" style="opacity: 0;">
- <!-- <text>{{key.split('-')[0]}}F</text> -->
- <view class="roomType" :style="{'left':scrollLeft+'px'}">{{indexHouseNameArr[i]}}</view>
- <view class="rightIcon" @click="open(i,key.split('-')[0],false)" v-if="opens[i]">
- <text>收起</text>
- <u-icon name="arrow-up-fill" size="18" style="margin-left: 10rpx;"></u-icon>
- </view>
- <view class="rightIcon" @click="open(i,key.split('-')[0],true)" v-else>
- <text>展开</text>
- <u-icon name="arrow-down-fill" size="18" style="margin-left: 10rpx;"></u-icon>
- </view>
- </view>
- <template v-if="opens[i]">
- <!-- <view class="roomType" style="opacity: 0;">{{key.split('-')[1]}}</view> -->
- <view class="table">
- <view class="tr" v-for="(item2,index2) in item" :key="index2">
- <view class="td" :style="{'left':scrollLeft+'px'}">{{item2.roomNumber}}</view>
- <view class="td" v-for="(roomData,ind) in xdata" :key="ind"
- :class="'s'+delDataStatus(item2.roomNumber,item2.houseBaseId,roomData.roomDataList,'status',item2.floor)">
- <!-- 空置房-->
- <template
- v-if="!delDataStatus(item2.roomNumber,item2.houseBaseId,roomData.roomDataList,'status',item2.floor) == 1">
- </template>
- <template v-else>
- <template
- v-if="delDataStatus(item2.roomNumber,item2.houseBaseId,roomData.roomDataList,'status',item2.floor) == 1">
- <view v-if="disTabCli(roomData) == 1" class="cellBox disT">
- ¥{{item2.roomNumber|delDataStatus(item2.houseBaseId,roomData.roomDataList,'price',item2.floor)}}
- </view>
- <view v-else
- @click.stop="check(item2.roomNumber,item2.houseBaseId,roomData,i + '-'+index2+ '-'+ ind,item2.floor)"
- class="cellBox">
- ¥{{item2.roomNumber|delDataStatus(item2.houseBaseId,roomData.roomDataList,'price',item2.floor)}}
- </view>
- </template>
- <template v-else>
- <view
- @click.stop="tabCli(item2.roomNumber,item2.houseBaseId,roomData.roomDataList,item2)"
- class="tdP">
- <text>{{item2.roomNumber|delDataStatus(item2.houseBaseId,roomData.roomDataList,'guestName',item2.floor)}}</text>
- <text>{{item2.roomNumber|delDataStatus(item2.houseBaseId,roomData.roomDataList,'status',item2.floor)}}</text>
- </view>
- </template>
- </template>
- <!-- 点击时状态 -->
- <view class="cover" v-if="checkPosition.indexOf(i + '-'+index2+ '-'+ ind) > -1"
- @click="check(item2.roomNumber,item2.houseBaseId,roomData,i + '-'+index2+ '-'+ ind,item2.floor)">
- <u-icon name="checkbox-mark" size="36" color="#fff"></u-icon>
- </view>
- </view>
- </view>
- </view>
- </template>
- </view>
- </view>
- </view>
- <view class="opration" v-if="checkDataRoomId.length!=0">
- <text @click="areaShow=true">关房</text>
- <text @click="priceShow=true">修改价格</text>
- <text @click="createOrder()">预订</text>
- </view>
- </view>
- <Tabbar :tabbarIndex="1"></Tabbar>
- <!-- 关房 -->
- <u-picker :itemHeight="88" :immediateChange="true" :show="areaShow" :columns="areaTxt" title="房态选择"
- :defaultIndex="passengerDefault" @cancel="areaShow=false;clearData();"
- @confirm="passengerConfirm"></u-picker>
- <!-- 修改价格 -->
- <u-popup :show="priceShow" mode="center">
- <view class="changePrice">
- <u--input placeholder="请设置新价格" type="number" border="surround" v-model="newPrice"></u--input>
- <view class="btns">
- <u-button text="取消" type="info" @click="priceShow=false;clearData()"></u-button>
- <u-button text="确定" type="primary" @click="changePrice()"></u-button>
- </view>
- </view>
- </u-popup>
- <!-- 刷新 -->
- <!-- <u-icon name="reload" @tap="init()" customStyle="position: fixed;z-index: 99;right: 280rpx;top: 68rpx;padding-left: 100rpx;" size="42"></u-icon> -->
- </view>
- </template>
- <script>
- var that;
- export default {
- data() {
- return {
- priceShow: false,
- newPrice: '',
- homestayId: uni.getStorageSync('homestayId') || 0,
- areaShow: false,
- passengerDefault: [0],
- info: {},
- areaTxt: [
- ['清洁中', '暂停使用', '保留房', '空置房']
- ],
- area: [{
- label: '清洁中',
- id: 4
- }, {
- label: '暂停使用',
- id: 5
- }, {
- label: '保留房',
- id: 6
- }, {
- label: '空置房',
- id: 0
- }],
- titleStyle: {
- fontSize: '34rpx',
- fontWeight: "bold",
- },
- dateArr: [1, 2, 3, 4, 5],
- xdata: [], //纵向列
- leftData: [], //横向列,
- indexArr: [], //楼层索引,
- indexHouseBaseIdArr: [],
- indexHouseNameArr: [],
- indexNameArr: [], //楼层Id索引,
- opens: [],
- statusTxt: {
- '-2': '待支付',
- '-1': '待确定',
- '1': '已预订',
- '2': '已入住',
- '3': '已退房',
- '4': '清洁中',
- '5': '暂停使用',
- '6': '保留房',
- },
- weeks: ["周日", "周一", "周二", "周三", "周四", "周五", "周六"],
- checkPosition: [],
- checkDataDate: [],
- checkPrice: [],
- checkDataRoomId: [],
- checkStatus: '',
- scrollLeft: 0
- }
- },
-
- mounted() {
- that = this;
- this.getLeftData();
- this.getData();
- this.getTj();
- },
- filters: {
- delDataStatus(roomNumber, id, roomId, name, floor) {
- for (let i = 0; i < roomId.length; i++) {
- if (floor == roomId[i].floor && id == roomId[i].houseBaseId && roomNumber == roomId[i].roomNumber) {
- if (name == "status") {
- return that.statusTxt[roomId[i][name]]
- } else {
- return roomId[i][name] || ''
- }
- }
- }
- },
- },
- onPullDownRefresh() {
- setTimeout(() => {
- this.init();
- uni.stopPullDownRefresh();
- }, 1000);
- },
- methods: {
- init() {
- this.getLeftData();
- this.getData();
- this.$forceUpdate();
- },
- getTj() {
- this.$api.get('/merchant/hotel/room/state/getRoomStateCount', {
- homestayId: this.homestayId
- }).then(res => {
- if (res.data.code == 0) {
- this.info = res.data.data;
- }
- })
- },
- scroll(e) {
- //this.scrollLeft = e.detail.scrollLeft; // div 到左边的距离
- },
- //关房
- tabCli(roomNumber, id, roomId,row) {
- if (roomNumber) {
- let obj = {};
- obj=roomId.filter((item)=>item.houseBaseId==id&&item.roomNumber==roomNumber)
- //已预订,已入住 待确认 待支付
- if (obj.status == 1 || obj.status == 2 || obj.status == -1 || obj.status == -2) {
- let orderId = obj.orderId;
- uni.navigateTo({
- url: "/pages/house/orderInfo?orderId=" + orderId
- })
- //到详情
- } else {
- //更改状态
- // this.checkDataRoomId = [obj[0].id];
- this.$set(this.checkDataRoomId,0,obj[0].id);
- this.checkStatus = obj.status;
- this.$nextTick(()=>{
- this.areaShow = true;
- })
- }
- }
- },
- //确定关房
- passengerConfirm(e) {
- let status = this.area[e.indexs[0]].id;
- this.$api.post('/merchant/hotel/room/state/updRoomState', {
- roomIds: this.checkDataRoomId,
- status: status
- }).then(res => {
- if (res.data.code == 0) {
- this.areaShow = false;
- this.$nextTick(()=>{
- this.clearData();
- this.init()
- })
- } else {
- this.$showToast(res.data.msg);
- }
- })
- },
- changePrice() {
- if(!this.newPrice) return this.$showToast('请填写新价格');
- if(+this.newPrice<=0) return this.$showToast('新价格须大于0');
-
- this.$api
- .post("/merchant/hotel/room/state/updRoomPrice", {
- idList: this.checkDataRoomId,
- price: this.newPrice,
- })
- .then((res) => {
- if (res.data.code !== 0) {
- return this.$showToast(res.data.msg);
- } else {
- this.$showToast('操作成功');
- setTimeout(() => {
- this.clearData();
- this.priceShow = false;
- this.init()
- }, 500)
- }
- });
- },
- //新增订单
- createOrder() {
- this.clearData()
- uni.navigateTo({
- url: '/pages/house/createOrder?roomId=' + this.checkDataRoomId
- })
- },
- //展开收起
- open(i, F, val) {
- this.opens[i] = !this.opens[i];
- let list = this.leftData;
- for (var i = 0; i < Object.keys(list).length; i++) {
- var index = i; // 索引
- var key = Object.keys(list)[i].split('-')[0]; // key
- if (F == key) {
- this.opens[index] = val;
- }
- }
- this.$forceUpdate();
- },
- delDataStatus(roomNumber, id, roomId, name, floor) {
- for (let i = 0; i < roomId.length; i++) {
- if (floor == roomId[i].floor && id == roomId[i].houseBaseId && roomNumber == roomId[i].roomNumber) {
- return roomId[i][name] + 1;
- }
- }
- },
- disTabCli(roomData) {
- if (new Date(roomData.rentDate).Format('yyyy-MM-dd') < new Date().Format('yyyy-MM-dd')) {
- return 1
- }
- },
- clearData() {
- this.newPrice = '';
- this.checkDataDate = [];
- this.checkPrice = [];
- this.checkDataRoomId = [];
- this.checkPosition = [];
- },
- //选择房间
- check(roomNumber, id, item, position, floor) {
- console.log(floor)
- console.log(item)
- for (let i = 0; i < item.roomDataList.length; i++) {
- if (
- floor == item.roomDataList[i].floor && id == item.roomDataList[i].houseBaseId &&
- roomNumber == item.roomDataList[i].roomNumber
- ) {
- //宫格位置标识
- if (item.roomDataList[i].status == 0) {
- if (this.checkPosition.indexOf(position) < 0) {
- this.checkPosition.push(position);
- } else {
- let index = this.checkPosition.findIndex(
- (pos) => pos == position
- ); //选中的索引位置
- this.checkPosition.splice(index, 1);
- }
- //房间id
- if (this.checkDataRoomId.indexOf(item.roomDataList[i].id) < 0) {
- this.checkDataRoomId.push(item.roomDataList[i].id);
- } else {
- let index = this.checkDataRoomId.findIndex(
- (roomId) => roomId == item.roomDataList[i].id
- );
- this.checkDataRoomId.splice(index, 1);
- }
- console.log(this.checkDataRoomId)
- //日期
- if (this.checkPosition.indexOf(position) > -1) {
- this.checkDataDate.push(item.rentDate);
- this.checkPrice.push(item.roomDataList[i].price)
- } else {
- let index = this.checkDataDate.findIndex(
- (date) => date == item.rentDate
- );
- this.checkDataDate.splice(index, 1);
- //价格
- let index2 = this.checkPrice.findIndex(
- (price) => price == item.price
- );
- this.checkPrice.splice(index2, 1);
- }
- if (this.checkPosition.length == 0) {
- this.checkDataDate = [];
- this.checkPrice = [];
- }
- }
- }
- }
- },
- getLeftData() {
- this.$api.get(`/merchant/hotel/room/state/getHouseCategoryData/${this.homestayId}`).then(res => {
- if (res.data.code == 0) {
- for (let i in res.data.data) {
- let F = i.split('-')[0];
- let houseBaseId = res.data.data[i][0].houseBaseId;
- let name = res.data.data[i][0].name;
- if (this.indexHouseBaseIdArr.indexOf(houseBaseId) < 0) {
- this.indexArr.push(F);
- this.indexHouseBaseIdArr.push(houseBaseId)
- this.indexHouseNameArr.push(name)
- this.opens.push(true)
- } else {
- this.indexArr.push('');
- this.indexHouseNameArr.push('')
- this.opens.push(true)
- }
- }
- this.leftData = res.data.data;
- }
- })
- },
- getData() {
- this.$api.get('/merchant/hotel/room/state/getDateRoomList', {
- homestayId: this.homestayId,
- nowDate: '',
- status: ''
- }).then(res => {
- if (res.data.code == 0) {
- this.xdata = res.data.data;
- }
- })
- }
- }
- }
- </script>
- <style scoped lang="less">
- .changePrice {
- padding:50rpx;
- width: 600rpx;
- border-radius: 20rpx;
- .btns {
- margin-top: 60rpx;
- display: flex;
- justify-content: space-between;
- align-items: center;
- text {
- display: inline-block;
- width: 180rpx;
- height: 50rpx;
- line-height: 50rpx;
- text-align: center;
- }
- }
- }
- .opration {
- height: 140rpx;
- padding: 0 30rpx;
- background-color: #fff;
- position: fixed;
- bottom: 0;
- left: 0;
- width: 100%;
- z-index: 9;
- display: flex;
- align-items: center;
- justify-content: space-between;
- box-sizing: border-box;
- text {
- display: inline-block;
- width: 160rpx;
- text-align: center;
- line-height: 56rpx;
- border: 1rpx solid #D1D1D1;
- height: 56rpx;
- border-radius: 64rpx;
- font-size: 24rpx;
- color: #999;
- &:last-child {
- background-color: #1372FF;
- color: #fff;
- border: 0;
- }
- }
- }
- .page {
- background: #F3F4F4;
- padding-bottom: 40rpx;
- box-sizing: border-box;
- overflow-x: auto;
- .content {}
- }
- .tj {
- padding: 30rpx 0;
- text-align: center;
- height: 140rpx;
- box-sizing: border-box;
- position: absolute;
- width: 750rpx;
- left: 0;
- display: flex;
- justify-content: space-between;
- background-color: #fff;
- .item {
- display: flex;
- flex-direction: column;
- align-items: center;
- width: 100px;
- flex: 1;
- }
- text {
- font-size: 24rpx;
- color: #999;
- &.label {
- font-size: 40rpx;
- color: #333;
- font-weight: bold;
- }
- }
- }
- .date {
- display: flex;
- position: relative;
- border: 1rpx solid #E9F0F5;
- // padding-bottom: 19rpx;
- margin-top: 140rpx;
- .item {
- min-width: 140rpx;
- width: 140rpx;
- height: 136rpx;
- display: flex;
- flex-direction: column;
- align-items: center;
- justify-content: center;
- font-size: 20rpx;
- border-right: 1rpx solid #E9F0F5;
- background-color: #fff;
- &:last-child {
- border: 0;
- }
- text {
- &:nth-child(2) {
- margin: 6rpx 0;
- }
- }
- }
- }
- .head,
- .roomType {
- padding: 0 30rpx 0 0;
- display: flex;
- width: 400rpx;
- // justify-content: space-between;
- }
- .head {
- // position: absolute;
- // top: 0;
- // left: 0;
- margin-top: 16rpx;
- width: 750rpx;
- display: flex;
- box-sizing: border-box;
- justify-content: space-between;
- &>text {
- &:first-child {
- font-size: 32rpx;
- margin-right: 30rpx;
- }
- }
- .rightIcon {
- display: flex;
- align-items: center;
- font-size: 24rpx;
- color: #1F2425;
- }
- }
- .roomType {
- // position: absolute;
- // top: 40rpx;
- // left: 0;
- color: #333;
- font-size: 24rpx;
- position: relative;
- padding-left: 34rpx;
- margin: 20rpx 0 16rpx;
- &::after {
- position: absolute;
- content: "";
- height: 24rpx;
- width: 5rpx;
- background-color: #1372FF;
- left: 20rpx;
- top: 4rpx;
- z-index: 1;
- }
- }
- .floorData {
- .table {
- // border: 1rpx solid #E9F0F5;
- width: auto;
- min-width: 100%;
- .tr {
- display: flex;
- align-items: center;
- background-color: #fff;
- position: relative;
- &:last-child {
- border: 0;
- }
- .td {
- display: flex;
- align-items: center;
- justify-content: center;
- position: relative;
- width: 140rpx;
- min-width: 140rpx;
- height: 110rpx;
- border-right: 1rpx solid #E9F0F5;
- background-color: #fff;
- color: #1F2425;
- font-size: 24rpx;
- box-sizing: border-box;
- border-bottom: 1rpx solid #E9F0F5;
- .tdP,
- .cellBox {
- display: flex;
- width: 100%;
- height: 100%;
- flex-direction: column;
- align-items: center;
- justify-content: center;
- &.disT {
- color: #ccc;
- }
- }
- // &:last-child {
- // border: 0;
- // }
- //已预订
- &.s2 {
- background-color: rgba(29, 202, 104, 0.1);
- color: rgb(29, 202, 104);
- text {
- &:first-child {
- margin-bottom: 6rpx;
- color: #1F2425;
- }
- }
- }
- // 已入住
- &.s3 {
- color: rgb(19, 114, 255);
- background-color: rgba(19, 114, 255, 0.1);
- text {
- &:first-child {
- margin-bottom: 6rpx;
- color: #1F2425;
- }
- }
- }
- // 已退房
- &.s4 {
- color: rgb(219, 41, 195);
- background-color: rgba(219, 41, 195, 0.1);
- }
- //待确定
- &.s0 {
- color: rgb(25, 185, 197);
- background-color: rgba(25, 185, 197, 0.1);
- }
- //清洁中
- &.s5 {
- color: rgb(237, 86, 86);
- background-color: rgba(237, 86, 86, 0.1);
- }
- //暂停使用
- &.s6 {
- color: rgb(41, 60, 115);
- background-color: rgba(41, 60, 115, 0.1);
- }
- //保留房
- &.s7 {
- color: rgb(132, 68, 244);
- background-color: rgba(132, 68, 244, 0.1);
- }
- }
- }
- .cover {
- position: absolute;
- top: 0;
- left: 0;
- bottom: 0;
- right: 0;
- background-color: #1372FF;
- color: #fff;
- text-align: center;
- display: flex;
- flex-direction: column;
- justify-content: center;
- align-items: center;
- }
- }
- }
- .small {
- padding-top: 68rpx !important;
- .roomType {
- top: 0 !important;
- }
- }
- .pd0 {
- padding: 0 !important;
- }
- .leftFixed {
- width: 72rpx;
- position: absolute;
- left: 0;
- // top: 232rpx;
- z-index: 1;
- .tj {
- width: 0;
- position: relative;
- }
- .year {
- min-width: 140rpx;
- width: 140rpx;
- height: 136rpx;
- display: flex;
- flex-direction: column;
- align-items: center;
- justify-content: center;
- font-size: 20rpx;
- border-right: 1rpx solid #E9F0F5;
- background-color: #fff;
- margin-bottom: 18rpx;
- }
- .fixedItem {
- display: flex;
- flex-direction: column;
- .roomNumber {
- height: 110rpx;
- display: flex;
- align-items: center;
- border-bottom: 1rpx solid #E9F0F5;
- width: 140rpx;
- background-color: #fff;
- box-shadow: 3px 0 10px #efefef;
- box-sizing: border-box;
- justify-content: center;
- text-align: center;
- // &:first-child{height: 84rpx;border-top: 1rpx solid #E9F0F5;}
- }
- }
- }
- </style>
|