index.vue 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734
  1. <template>
  2. <view class="page" :style="{'padding-top':mt+'px'}">
  3. <c-nav-bar title="房态" :showIcon="false" :titleStyle="titleStyle" bgColor="transparent"></c-nav-bar>
  4. <view class="leftFixed" v-if="leftData.length!=0" :style="{'top':(mt+2)+'px'}">
  5. <view class="tj" :style="{'top':mt+'px'}"></view>
  6. <view class="year">
  7. <u-icon name="calendar-fill" color="#B9C2D2" size="40" style="margin-bottom:10rpx;"></u-icon>
  8. <text style="font-size: 24rpx;">2024</text>
  9. </view>
  10. <view v-for="(item,key,i) in leftData" :key="i"
  11. :class="indexArr[i]!=key.split('-')[0]?'mg0 fixedItem':'fixedItem'">
  12. <view class="head" v-if="indexArr[i]==key.split('-')[0]" style="margin-top: 16rpx;">
  13. <!-- <text>{{key.split('-')[0]}}F</text> -->
  14. <view class="roomType" :style="{'left':scrollLeft+'px'}">{{key.split('-')[1]}}</view>
  15. <view class="rightIcon" @click="open(i,key.split('-')[0],false)" v-if="opens[i]">
  16. <text>收起</text>
  17. <u-icon name="arrow-up-fill" size="18" style="margin-left: 10rpx;"></u-icon>
  18. </view>
  19. <view class="rightIcon" @click="open(i,key.split('-')[0],true)" v-else>
  20. <text>展开</text>
  21. <u-icon name="arrow-down-fill" size="18" style="margin-left: 10rpx;"></u-icon>
  22. </view>
  23. </view>
  24. <template v-if="opens[i]">
  25. <!-- <view class="roomType" :style="{'left':scrollLeft+'px'}">{{key.split('-')[1]}}</view> -->
  26. <text v-for="(item2,index2) in item" class="roomNumber">
  27. {{item2.roomNumber}}
  28. </text>
  29. </template>
  30. </view>
  31. </view>
  32. <view>
  33. <view class="content" v-if="xdata.length!=0">
  34. <view class="tj" :style="{'top':mt+'px'}">
  35. <view class="item">
  36. <text class="label">{{info.totalRooms}}</text>
  37. <text>房间总数</text>
  38. </view>
  39. <view class="item">
  40. <text class="label">{{info.checkinRooms}}</text>
  41. <text>在入住房间</text>
  42. </view>
  43. <view class="item">
  44. <text class="label">{{info.bookRooms}}</text>
  45. <text>待入住房间</text>
  46. </view>
  47. </view>
  48. <view class="date">
  49. <view class="item">
  50. <u-icon name="calendar-fill" color="#B9C2D2" size="40" style="margin-bottom:10rpx;"></u-icon>
  51. <text style="font-size: 24rpx;">2024</text>
  52. </view>
  53. <view class="item" v-for="(item,keynme,index) in xdata" :key="index">
  54. <text>{{item.rentDate.substring(5)}}</text>
  55. <text>{{weeks[item.rentWeek]}}</text>
  56. <text>剩{{item.spareRooms||0}}间</text>
  57. </view>
  58. </view>
  59. <view style="height:18rpx"></view>
  60. <view class="floorData" v-if="leftData.length!=0">
  61. <view v-for="(item,key,i) in leftData" :key="i">
  62. <view class="head" v-if="indexArr[i]==key.split('-')[0]" style="opacity: 0;">
  63. <!-- <text>{{key.split('-')[0]}}F</text> -->
  64. <view class="roomType" :style="{'left':scrollLeft+'px'}">{{key.split('-')[1]}}</view>
  65. <view class="rightIcon" @click="open(i,key.split('-')[0],false)" v-if="opens[i]">
  66. <text>收起</text>
  67. <u-icon name="arrow-up-fill" size="18" style="margin-left: 10rpx;"></u-icon>
  68. </view>
  69. <view class="rightIcon" @click="open(i,key.split('-')[0],true)" v-else>
  70. <text>展开</text>
  71. <u-icon name="arrow-down-fill" size="18" style="margin-left: 10rpx;"></u-icon>
  72. </view>
  73. </view>
  74. <template v-if="opens[i]">
  75. <!-- <view class="roomType" style="opacity: 0;">{{key.split('-')[1]}}</view> -->
  76. <view class="table">
  77. <view class="tr" v-for="(item2,index2) in item" :key="index2">
  78. <view class="td" :style="{'left':scrollLeft+'px'}">{{item2.roomNumber}}</view>
  79. <view class="td" v-for="(roomData,ind) in xdata" :key="ind"
  80. :class="'s'+delDataStatus(item2.roomNumber,item2.houseBaseId,roomData.roomDataList,'status')">
  81. <!-- 空置房-->
  82. <template
  83. v-if="delDataStatus(item2.roomNumber,item2.houseBaseId,roomData.roomDataList,'status') == 1">
  84. <view v-if="disTabCli(roomData) == 1" class="cellBox disT">
  85. ¥{{item2.roomNumber|delDataStatus(item2.houseBaseId,roomData.roomDataList,'price')}}
  86. </view>
  87. <view v-else
  88. @click="check(item2.roomNumber,item2.houseBaseId,roomData,i + '-'+index2+ '-'+ ind)"
  89. class="cellBox">
  90. ¥{{item2.roomNumber|delDataStatus(item2.houseBaseId,roomData.roomDataList,'price')}}
  91. </view>
  92. </template>
  93. <template v-else>
  94. <view
  95. @click="tabCli(item2.roomNumber,item2.houseBaseId,roomData.roomDataList)"
  96. class="tdP">
  97. <text>{{item2.roomNumber|delDataStatus(item2.houseBaseId,roomData.roomDataList,'guestName')}}</text>
  98. <text>{{item2.roomNumber|delDataStatus(item2.houseBaseId,roomData.roomDataList,'status')}}</text>
  99. </view>
  100. </template>
  101. <!-- 点击时状态 -->
  102. <view class="cover" v-if="checkPosition.indexOf(i + '-'+index2+ '-'+ ind) > -1"
  103. @click="check(item2.roomNumber,item2.houseBaseId,roomData,i + '-'+index2+ '-'+ ind)">
  104. <u-icon name="checkbox-mark" size="36" color="#fff"></u-icon>
  105. </view>
  106. </view>
  107. </view>
  108. </view>
  109. </template>
  110. </view>
  111. </view>
  112. </view>
  113. <view class="opration" v-if="checkDataRoomId.length!=0">
  114. <text @click="areaShow=true">关房</text>
  115. <text @click="createOrder()">新增</text>
  116. </view>
  117. </view>
  118. <Tabbar :tabbarIndex="1"></Tabbar>
  119. <!-- 关房 -->
  120. <u-picker :itemHeight="88" :immediateChange="true" :show="areaShow" :columns="areaTxt" title="房态选择"
  121. :defaultIndex="passengerDefault" @cancel="areaShow=false;clearData();"
  122. @confirm="passengerConfirm"></u-picker>
  123. </view>
  124. </template>
  125. <script>
  126. var that;
  127. export default {
  128. data() {
  129. return {
  130. homestayId: uni.getStorageSync('homestayId') || 0,
  131. areaShow: false,
  132. passengerDefault: [0],
  133. info: {},
  134. areaTxt: [
  135. ['清洁中', '暂停使用', '保留房', '空置房']
  136. ],
  137. area: [{
  138. label: '清洁中',
  139. id: 4
  140. }, {
  141. label: '暂停使用',
  142. id: 5
  143. }, {
  144. label: '保留房',
  145. id: 6
  146. }, {
  147. label: '空置房',
  148. id: 0
  149. }],
  150. titleStyle: {
  151. fontSize: '34rpx',
  152. fontWeight: "bold",
  153. },
  154. dateArr: [1, 2, 3, 4, 5],
  155. xdata: [], //纵向列
  156. leftData: [], //横向列,
  157. indexArr: [], //楼层索引,
  158. opens: [],
  159. statusTxt: {
  160. '-2': '待支付',
  161. '-1': '待确定',
  162. '1': '已预订',
  163. '2': '已入住',
  164. '3': '已退房',
  165. '4': '清洁中',
  166. '5': '暂停使用',
  167. '6': '保留房',
  168. },
  169. weeks: ["周日", "周一", "周二", "周三", "周四", "周五", "周六"],
  170. checkPosition: [],
  171. checkDataDate: [],
  172. checkPrice: [],
  173. checkDataRoomId: [],
  174. checkStatus: '',
  175. scrollLeft: 0
  176. }
  177. },
  178. mounted() {
  179. that = this;
  180. this.getLeftData();
  181. this.getData();
  182. this.getTj();
  183. },
  184. filters: {
  185. delDataStatus(roomNumber, id, roomId, name) {
  186. for (let i = 0; i < roomId.length; i++) {
  187. if (id == roomId[i].houseBaseId && roomNumber == roomId[i].roomNumber) {
  188. if (name == "status") {
  189. return that.statusTxt[roomId[i][name]]
  190. } else {
  191. return roomId[i][name] || ''
  192. }
  193. }
  194. }
  195. },
  196. },
  197. methods: {
  198. init() {
  199. this.getLeftData();
  200. this.getData();
  201. this.$forceUpdate();
  202. },
  203. getTj() {
  204. this.$api.get('/merchant/hotel/room/state/getRoomStateCount', {
  205. homestayId: this.homestayId
  206. }).then(res => {
  207. if (res.data.code == 0) {
  208. this.info = res.data.data;
  209. }
  210. })
  211. },
  212. scroll(e) {
  213. //this.scrollLeft = e.detail.scrollLeft; // div 到左边的距离
  214. },
  215. //关房
  216. tabCli(roomNumber, id, roomId) {
  217. if (roomNumber) {
  218. let obj = {};
  219. for (let i = 0; i < roomId.length; i++) {
  220. if (id == roomId[i].houseBaseId && roomNumber == roomId[i].roomNumber) {
  221. obj = roomId[i];
  222. }
  223. }
  224. //已预订,已入住 待确认 待支付
  225. if (obj.status == 1 || obj.status == 2 || obj.status == -1 || obj.status == -2) {
  226. let orderId = obj.orderId;
  227. uni.navigateTo({
  228. url: "/pages/house/orderInfo?orderId=" + orderId
  229. })
  230. //到详情
  231. } else {
  232. //更改状态
  233. this.areaShow = true;
  234. this.checkDataRoomId = [obj.id];
  235. this.checkStatus = obj.status;
  236. }
  237. }
  238. },
  239. //确定关房
  240. passengerConfirm(e) {
  241. let status = this.area[e.indexs[0]].id;
  242. this.$api.post('/merchant/hotel/room/state/updRoomState', {
  243. roomIds: this.checkDataRoomId,
  244. status: status
  245. }).then(res => {
  246. if (res.data.code == 0) {
  247. this.clearData();
  248. this.areaShow = false;
  249. this.init()
  250. } else {
  251. this.$showToast(res.data.msg);
  252. }
  253. })
  254. },
  255. //新增订单
  256. createOrder() {
  257. this.clearData()
  258. uni.navigateTo({
  259. url: '/pages/house/createOrder?roomId=' + this.checkDataRoomId
  260. })
  261. },
  262. //展开收起
  263. open(i, F, val) {
  264. this.opens[i] = !this.opens[i];
  265. let list = this.leftData;
  266. for (var i = 0; i < Object.keys(list).length; i++) {
  267. var index = i; // 索引
  268. var key = Object.keys(list)[i].split('-')[0]; // key
  269. if (F == key) {
  270. this.opens[index] = val;
  271. }
  272. }
  273. this.$forceUpdate();
  274. },
  275. delDataStatus(roomNumber, id, roomId, name) {
  276. for (let i = 0; i < roomId.length; i++) {
  277. if (id == roomId[i].houseBaseId && roomNumber == roomId[i].roomNumber) {
  278. return roomId[i][name] + 1;
  279. }
  280. }
  281. },
  282. disTabCli(roomData) {
  283. if (new Date(roomData.rentDate).Format('yyyy-MM-dd') < new Date().Format('yyyy-MM-dd')) {
  284. return 1
  285. }
  286. },
  287. clearData() {
  288. setTimeout(() => {
  289. this.checkDataDate = [];
  290. this.checkPrice = [];
  291. this.checkDataRoomId = [];
  292. this.checkPosition = [];
  293. }, 1500);
  294. },
  295. //选择房间
  296. check(roomNumber, id, item, position) {
  297. for (let i = 0; i < item.roomDataList.length; i++) {
  298. if (
  299. id == item.roomDataList[i].houseBaseId &&
  300. roomNumber == item.roomDataList[i].roomNumber
  301. ) {
  302. //宫格位置标识
  303. if (item.roomDataList[i].status == 0) {
  304. if (this.checkPosition.indexOf(position) < 0) {
  305. this.checkPosition.push(position);
  306. } else {
  307. let index = this.checkPosition.findIndex(
  308. (pos) => pos == position
  309. ); //选中的索引位置
  310. this.checkPosition.splice(index, 1);
  311. }
  312. //房间id
  313. if (this.checkDataRoomId.indexOf(item.roomDataList[i].id) < 0) {
  314. this.checkDataRoomId.push(item.roomDataList[i].id);
  315. } else {
  316. let index = this.checkDataRoomId.findIndex(
  317. (roomId) => roomId == item.roomDataList[i].id
  318. );
  319. this.checkDataRoomId.splice(index, 1);
  320. }
  321. //日期
  322. if (this.checkPosition.indexOf(position) > -1) {
  323. this.checkDataDate.push(item.rentDate);
  324. this.checkPrice.push(item.roomDataList[i].price)
  325. } else {
  326. let index = this.checkDataDate.findIndex(
  327. (date) => date == item.rentDate
  328. );
  329. this.checkDataDate.splice(index, 1);
  330. //价格
  331. let index2 = this.checkPrice.findIndex(
  332. (price) => price == item.price
  333. );
  334. this.checkPrice.splice(index2, 1);
  335. }
  336. if (this.checkPosition.length == 0) {
  337. this.checkDataDate = [];
  338. this.checkPrice = [];
  339. }
  340. }
  341. }
  342. }
  343. },
  344. getLeftData() {
  345. this.$api.get(`/merchant/hotel/room/state/getHouseCategoryData/${this.homestayId}`).then(res => {
  346. if (res.data.code == 0) {
  347. // for (let i; i < res.data.data.length; i++) {
  348. // res.data.data[i].open = true;
  349. // }
  350. for (let i in res.data.data) {
  351. let F = i.split('-')[0];
  352. if (this.indexArr.indexOf(F) < 0) {
  353. this.indexArr.push(F);
  354. this.opens.push(true)
  355. } else {
  356. this.indexArr.push('');
  357. this.opens.push(true)
  358. }
  359. }
  360. this.leftData = res.data.data;
  361. }
  362. })
  363. },
  364. getData() {
  365. this.$api.get('/merchant/hotel/room/state/getDateRoomList', {
  366. homestayId: this.homestayId,
  367. nowDate: '',
  368. status: ''
  369. }).then(res => {
  370. if (res.data.code == 0) {
  371. this.xdata = res.data.data;
  372. }
  373. })
  374. }
  375. }
  376. }
  377. </script>
  378. <style scoped lang="less">
  379. .opration {
  380. height: 140rpx;
  381. padding: 0 30rpx;
  382. background-color: #fff;
  383. position: fixed;
  384. bottom: 0;
  385. left: 0;
  386. width: 100%;
  387. z-index: 9;
  388. display: flex;
  389. align-items: center;
  390. justify-content: space-between;
  391. box-sizing: border-box;
  392. text {
  393. display: inline-block;
  394. width: 160rpx;
  395. text-align: center;
  396. line-height: 56rpx;
  397. border: 1rpx solid #D1D1D1;
  398. height: 56rpx;
  399. border-radius: 64rpx;
  400. font-size: 24rpx;
  401. color: #999;
  402. &:last-child {
  403. background-color: #1372FF;
  404. color: #fff;
  405. border: 0;
  406. }
  407. }
  408. }
  409. .page {
  410. background: #F3F4F4;
  411. padding-bottom: 40rpx;
  412. box-sizing: border-box;
  413. overflow-x: auto;
  414. .content {}
  415. }
  416. .tj {
  417. padding: 30rpx 0;
  418. text-align: center;
  419. height: 140rpx;
  420. box-sizing: border-box;
  421. position: absolute;
  422. width: 750rpx;
  423. left: 0;
  424. display: flex;
  425. justify-content: space-between;
  426. background-color: #fff;
  427. .item {
  428. display: flex;
  429. flex-direction: column;
  430. align-items: center;
  431. width: 100px;
  432. flex: 1;
  433. }
  434. text {
  435. font-size: 24rpx;
  436. color: #999;
  437. &.label {
  438. font-size: 40rpx;
  439. color: #333;
  440. font-weight: bold;
  441. }
  442. }
  443. }
  444. .date {
  445. display: flex;
  446. position: relative;
  447. border: 1rpx solid #E9F0F5;
  448. // padding-bottom: 19rpx;
  449. margin-top: 140rpx;
  450. .item {
  451. min-width: 130rpx;
  452. width: 130rpx;
  453. height: 136rpx;
  454. display: flex;
  455. flex-direction: column;
  456. align-items: center;
  457. justify-content: center;
  458. font-size: 20rpx;
  459. border-right: 1rpx solid #E9F0F5;
  460. background-color: #fff;
  461. &:last-child {
  462. border: 0;
  463. }
  464. text {
  465. &:nth-child(2) {
  466. margin: 6rpx 0;
  467. }
  468. }
  469. }
  470. }
  471. .head,
  472. .roomType {
  473. padding: 0 30rpx;
  474. display: flex;
  475. width: 400rpx;
  476. // justify-content: space-between;
  477. }
  478. .head {
  479. // position: absolute;
  480. // top: 0;
  481. // left: 0;
  482. margin-top: 16rpx;
  483. width: 750rpx;
  484. display: flex;
  485. box-sizing: border-box;
  486. justify-content: space-between;
  487. &>text {
  488. &:first-child {
  489. font-size: 32rpx;
  490. margin-right: 30rpx;
  491. }
  492. }
  493. .rightIcon {
  494. display: flex;
  495. align-items: center;
  496. font-size: 24rpx;
  497. color: #1F2425;
  498. }
  499. }
  500. .roomType {
  501. // position: absolute;
  502. // top: 40rpx;
  503. // left: 0;
  504. color: #333;
  505. font-size: 24rpx;
  506. position: relative;
  507. padding-left: 44rpx;
  508. margin: 20rpx 0 16rpx;
  509. &::after {
  510. position: absolute;
  511. content: "";
  512. height: 24rpx;
  513. width: 5rpx;
  514. background-color: #1372FF;
  515. left: 30rpx;
  516. top: 4rpx;
  517. z-index: 1;
  518. }
  519. }
  520. .floorData {
  521. .table {
  522. // border: 1rpx solid #E9F0F5;
  523. width: auto;
  524. min-width: 100%;
  525. .tr {
  526. display: flex;
  527. align-items: center;
  528. background-color: #fff;
  529. position: relative;
  530. &:last-child {
  531. border: 0;
  532. }
  533. .td {
  534. display: flex;
  535. align-items: center;
  536. justify-content: center;
  537. position: relative;
  538. width: 130rpx;
  539. min-width: 130rpx;
  540. height: 83rpx;
  541. border-right: 1rpx solid #E9F0F5;
  542. background-color: #fff;
  543. color: #1F2425;
  544. font-size: 20rpx;
  545. box-sizing: border-box;
  546. border-bottom: 1rpx solid #E9F0F5;
  547. .tdP,
  548. .cellBox {
  549. display: flex;
  550. width: 100%;
  551. height: 100%;
  552. flex-direction: column;
  553. align-items: center;
  554. justify-content: center;
  555. &.disT {
  556. color: #ccc;
  557. }
  558. }
  559. &:last-child {
  560. border: 0;
  561. }
  562. //已预订
  563. &.s2 {
  564. background-color: rgba(29, 202, 104, 0.1);
  565. color: rgb(29, 202, 104);
  566. text {
  567. &:first-child {
  568. margin-bottom: 6rpx;
  569. color: #1F2425;
  570. }
  571. }
  572. }
  573. // 已入住
  574. &.s3 {
  575. color: rgb(19, 114, 255);
  576. background-color: rgba(19, 114, 255, 0.1);
  577. text {
  578. &:first-child {
  579. margin-bottom: 6rpx;
  580. color: #1F2425;
  581. }
  582. }
  583. }
  584. // 已退房
  585. &.s4 {
  586. color: rgb(219, 41, 195);
  587. background-color: rgba(219, 41, 195, 0.1);
  588. }
  589. //待确定
  590. &.s0 {
  591. color: rgb(25, 185, 197);
  592. background-color: rgba(25, 185, 197, 0.1);
  593. }
  594. //清洁中
  595. &.s5 {
  596. color: rgb(237, 86, 86);
  597. background-color: rgba(237, 86, 86, 0.1);
  598. }
  599. //暂停使用
  600. &.s6 {
  601. color: rgb(41, 60, 115);
  602. background-color: rgba(41, 60, 115, 0.1);
  603. }
  604. //保留房
  605. &.s7 {
  606. color: rgb(132, 68, 244);
  607. background-color: rgba(132, 68, 244, 0.1);
  608. }
  609. }
  610. }
  611. .cover {
  612. position: absolute;
  613. top: 0;
  614. left: 0;
  615. bottom: 0;
  616. right: 0;
  617. background-color: #1372FF;
  618. color: #fff;
  619. text-align: center;
  620. display: flex;
  621. flex-direction: column;
  622. justify-content: center;
  623. align-items: center;
  624. }
  625. }
  626. }
  627. .small {
  628. padding-top: 68rpx !important;
  629. .roomType {
  630. top: 0 !important;
  631. }
  632. }
  633. .pd0 {
  634. padding: 0 !important;
  635. }
  636. .leftFixed {
  637. width: 72rpx;
  638. position: absolute;
  639. left: 0;
  640. // top: 232rpx;
  641. z-index: 1;
  642. .tj {
  643. width: 0;
  644. position: relative;
  645. }
  646. .year {
  647. min-width: 130rpx;
  648. width: 130rpx;
  649. height: 136rpx;
  650. display: flex;
  651. flex-direction: column;
  652. align-items: center;
  653. justify-content: center;
  654. font-size: 20rpx;
  655. border-right: 1rpx solid #E9F0F5;
  656. background-color: #fff;
  657. margin-bottom: 18rpx;
  658. }
  659. .fixedItem {
  660. display: flex;
  661. flex-direction: column;
  662. .roomNumber {
  663. height: 83rpx;
  664. display: flex;
  665. align-items: center;
  666. border-bottom: 1rpx solid #E9F0F5;
  667. width: 130rpx;
  668. background-color: #fff;
  669. box-shadow: 3px 0 10px #efefef;
  670. box-sizing: border-box;
  671. justify-content: center;
  672. // &:first-child{height: 84rpx;border-top: 1rpx solid #E9F0F5;}
  673. }
  674. }
  675. }
  676. </style>