index.vue 17 KB

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