index.vue 17 KB

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