index.vue 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729
  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. }
  249. })
  250. },
  251. //新增订单
  252. createOrder() {
  253. this.clearData()
  254. uni.navigateTo({
  255. url: '/pages/house/createOrder?roomId=' + this.checkDataRoomId
  256. })
  257. },
  258. //展开收起
  259. open(i, F, val) {
  260. this.opens[i] = !this.opens[i];
  261. let list = this.leftData;
  262. for (var i = 0; i < Object.keys(list).length; i++) {
  263. var index = i; // 索引
  264. var key = Object.keys(list)[i].split('-')[0]; // key
  265. if (F == key) {
  266. this.opens[index] = val;
  267. }
  268. }
  269. this.$forceUpdate();
  270. },
  271. delDataStatus(roomNumber, id, roomId, name) {
  272. for (let i = 0; i < roomId.length; i++) {
  273. if (id == roomId[i].houseBaseId && roomNumber == roomId[i].roomNumber) {
  274. return roomId[i][name] + 1;
  275. }
  276. }
  277. },
  278. disTabCli(roomData) {
  279. if (new Date(roomData.rentDate).Format('yyyy-MM-dd') < new Date().Format('yyyy-MM-dd')) {
  280. return 1
  281. }
  282. },
  283. clearData() {
  284. setTimeout(() => {
  285. this.checkDataDate = [];
  286. this.checkPrice = [];
  287. this.checkDataRoomId = [];
  288. this.checkPosition = [];
  289. }, 1500);
  290. },
  291. //选择房间
  292. check(roomNumber, id, item, position) {
  293. for (let i = 0; i < item.roomDataList.length; i++) {
  294. if (
  295. id == item.roomDataList[i].houseBaseId &&
  296. roomNumber == item.roomDataList[i].roomNumber
  297. ) {
  298. //宫格位置标识
  299. if (item.roomDataList[i].status == 0) {
  300. if (this.checkPosition.indexOf(position) < 0) {
  301. this.checkPosition.push(position);
  302. } else {
  303. let index = this.checkPosition.findIndex(
  304. (pos) => pos == position
  305. ); //选中的索引位置
  306. this.checkPosition.splice(index, 1);
  307. }
  308. //房间id
  309. if (this.checkDataRoomId.indexOf(item.roomDataList[i].id) < 0) {
  310. this.checkDataRoomId.push(item.roomDataList[i].id);
  311. } else {
  312. let index = this.checkDataRoomId.findIndex(
  313. (roomId) => roomId == item.roomDataList[i].id
  314. );
  315. this.checkDataRoomId.splice(index, 1);
  316. }
  317. //日期
  318. if (this.checkPosition.indexOf(position) > -1) {
  319. this.checkDataDate.push(item.rentDate);
  320. this.checkPrice.push(item.roomDataList[i].price)
  321. } else {
  322. let index = this.checkDataDate.findIndex(
  323. (date) => date == item.rentDate
  324. );
  325. this.checkDataDate.splice(index, 1);
  326. //价格
  327. let index2 = this.checkPrice.findIndex(
  328. (price) => price == item.price
  329. );
  330. this.checkPrice.splice(index2, 1);
  331. }
  332. if (this.checkPosition.length == 0) {
  333. this.checkDataDate = [];
  334. this.checkPrice = [];
  335. }
  336. }
  337. }
  338. }
  339. },
  340. getLeftData() {
  341. this.$api.get(`/merchant/hotel/room/state/getHouseCategoryData/${this.homestayId}`).then(res => {
  342. if (res.data.code == 0) {
  343. // for (let i; i < res.data.data.length; i++) {
  344. // res.data.data[i].open = true;
  345. // }
  346. for (let i in res.data.data) {
  347. let F = i.split('-')[0];
  348. if (this.indexArr.indexOf(F) < 0) {
  349. this.indexArr.push(F);
  350. this.opens.push(true)
  351. } else {
  352. this.indexArr.push('');
  353. this.opens.push(true)
  354. }
  355. }
  356. this.leftData = res.data.data;
  357. }
  358. })
  359. },
  360. getData() {
  361. this.$api.get('/merchant/hotel/room/state/getDateRoomList', {
  362. homestayId: this.homestayId,
  363. nowDate: '',
  364. status: ''
  365. }).then(res => {
  366. if (res.data.code == 0) {
  367. this.xdata = res.data.data;
  368. }
  369. })
  370. }
  371. }
  372. }
  373. </script>
  374. <style scoped lang="less">
  375. .opration {
  376. height: 140rpx;
  377. padding: 0 30rpx;
  378. background-color: #fff;
  379. position: fixed;
  380. bottom: 0;
  381. left: 0;
  382. width: 100%;
  383. z-index: 999999;
  384. display: flex;
  385. align-items: center;
  386. justify-content: space-between;
  387. box-sizing: border-box;
  388. text {
  389. display: inline-block;
  390. width: 160rpx;
  391. text-align: center;
  392. line-height: 56rpx;
  393. border: 1rpx solid #D1D1D1;
  394. height: 56rpx;
  395. border-radius: 64rpx;
  396. font-size: 24rpx;
  397. color: #999;
  398. &:last-child {
  399. background-color: #1372FF;
  400. color: #fff;
  401. border: 0;
  402. }
  403. }
  404. }
  405. .page {
  406. background: #F3F4F4;
  407. padding-bottom: 40rpx;
  408. box-sizing: border-box;
  409. overflow-x: auto;
  410. .content {}
  411. }
  412. .tj {
  413. padding: 30rpx 0;
  414. text-align: center;
  415. height: 140rpx;
  416. box-sizing: border-box;
  417. position: absolute;
  418. width: 750rpx;
  419. left: 0;
  420. display: flex;
  421. justify-content: space-between;
  422. background-color: #fff;
  423. .item {
  424. display: flex;
  425. flex-direction: column;
  426. align-items: center;
  427. width: 100px;
  428. flex: 1;
  429. }
  430. text {
  431. font-size: 24rpx;
  432. color: #999;
  433. &.label {
  434. font-size: 40rpx;
  435. color: #333;
  436. font-weight: bold;
  437. }
  438. }
  439. }
  440. .date {
  441. display: flex;
  442. position: relative;
  443. border: 1rpx solid #E9F0F5;
  444. // padding-bottom: 19rpx;
  445. margin-top: 140rpx;
  446. .item {
  447. min-width: 130rpx;
  448. width: 130rpx;
  449. height: 136rpx;
  450. display: flex;
  451. flex-direction: column;
  452. align-items: center;
  453. justify-content: center;
  454. font-size: 20rpx;
  455. border-right: 1rpx solid #E9F0F5;
  456. background-color: #fff;
  457. &:last-child {
  458. border: 0;
  459. }
  460. text {
  461. &:nth-child(2) {
  462. margin: 6rpx 0;
  463. }
  464. }
  465. }
  466. }
  467. .head,
  468. .roomType {
  469. padding: 0 30rpx;
  470. display: flex;
  471. width: 400rpx;
  472. // justify-content: space-between;
  473. }
  474. .head {
  475. // position: absolute;
  476. // top: 0;
  477. // left: 0;
  478. margin-top: 16rpx;
  479. width: 750rpx;
  480. display: flex;
  481. box-sizing: border-box;
  482. justify-content: space-between;
  483. &>text {
  484. &:first-child {
  485. font-size: 32rpx;
  486. margin-right: 30rpx;
  487. }
  488. }
  489. .rightIcon {
  490. display: flex;
  491. align-items: center;
  492. font-size: 24rpx;
  493. color: #1F2425;
  494. }
  495. }
  496. .roomType {
  497. // position: absolute;
  498. // top: 40rpx;
  499. // left: 0;
  500. color: #333;
  501. font-size: 24rpx;
  502. position: relative;
  503. padding-left: 44rpx;
  504. margin: 20rpx 0 16rpx;
  505. &::after {
  506. position: absolute;
  507. content: "";
  508. height: 24rpx;
  509. width: 5rpx;
  510. background-color: #1372FF;
  511. left: 30rpx;
  512. top: 4rpx;
  513. z-index: 1;
  514. }
  515. }
  516. .floorData {
  517. .table {
  518. // border: 1rpx solid #E9F0F5;
  519. width: auto;
  520. min-width: 100%;
  521. .tr {
  522. display: flex;
  523. align-items: center;
  524. background-color: #fff;
  525. position: relative;
  526. &:last-child {
  527. border: 0;
  528. }
  529. .td {
  530. display: flex;
  531. align-items: center;
  532. justify-content: center;
  533. position: relative;
  534. width: 130rpx;
  535. min-width: 130rpx;
  536. height: 83rpx;
  537. border-right: 1rpx solid #E9F0F5;
  538. background-color: #fff;
  539. color: #1F2425;
  540. font-size: 20rpx;
  541. box-sizing: border-box;
  542. border-bottom: 1rpx solid #E9F0F5;
  543. .tdP,
  544. .cellBox {
  545. display: flex;
  546. width: 100%;
  547. height: 100%;
  548. flex-direction: column;
  549. align-items: center;
  550. justify-content: center;
  551. &.disT {
  552. color: #ccc;
  553. }
  554. }
  555. &:last-child {
  556. border: 0;
  557. }
  558. //已预订
  559. &.s2 {
  560. background-color: rgba(29, 202, 104, 0.1);
  561. color: rgb(29, 202, 104);
  562. text {
  563. &:first-child {
  564. margin-bottom: 6rpx;
  565. color: #1F2425;
  566. }
  567. }
  568. }
  569. // 已入住
  570. &.s3 {
  571. color: rgb(19, 114, 255);
  572. background-color: rgba(19, 114, 255, 0.1);
  573. text {
  574. &:first-child {
  575. margin-bottom: 6rpx;
  576. color: #1F2425;
  577. }
  578. }
  579. }
  580. // 已退房
  581. &.s4 {
  582. color: rgb(219, 41, 195);
  583. background-color: rgba(219, 41, 195, 0.1);
  584. }
  585. //待确定
  586. &.s0 {
  587. color: rgb(25, 185, 197);
  588. background-color: rgba(25, 185, 197, 0.1);
  589. }
  590. //清洁中
  591. &.s5 {
  592. color: rgb(237, 86, 86);
  593. background-color: rgba(237, 86, 86, 0.1);
  594. }
  595. //暂停使用
  596. &.s6 {
  597. color: rgb(41, 60, 115);
  598. background-color: rgba(41, 60, 115, 0.1);
  599. }
  600. //保留房
  601. &.s7 {
  602. color: rgb(132, 68, 244);
  603. background-color: rgba(132, 68, 244, 0.1);
  604. }
  605. }
  606. }
  607. .cover {
  608. position: absolute;
  609. top: 0;
  610. left: 0;
  611. bottom: 0;
  612. right: 0;
  613. background-color: #1372FF;
  614. color: #fff;
  615. text-align: center;
  616. display: flex;
  617. flex-direction: column;
  618. justify-content: center;
  619. align-items: center;
  620. }
  621. }
  622. }
  623. .small {
  624. padding-top: 68rpx !important;
  625. .roomType {
  626. top: 0 !important;
  627. }
  628. }
  629. .pd0 {
  630. padding: 0 !important;
  631. }
  632. .leftFixed {
  633. width: 72rpx;
  634. position: absolute;
  635. left: 0;
  636. // top: 232rpx;
  637. z-index: 1;
  638. .tj {
  639. width: 0;
  640. position: relative;
  641. }
  642. .year {
  643. min-width: 130rpx;
  644. width: 130rpx;
  645. height: 136rpx;
  646. display: flex;
  647. flex-direction: column;
  648. align-items: center;
  649. justify-content: center;
  650. font-size: 20rpx;
  651. border-right: 1rpx solid #E9F0F5;
  652. background-color: #fff;
  653. margin-bottom: 18rpx;
  654. }
  655. .fixedItem {
  656. display: flex;
  657. flex-direction: column;
  658. .roomNumber {
  659. height: 83rpx;
  660. display: flex;
  661. align-items: center;
  662. border-bottom: 1rpx solid #E9F0F5;
  663. width: 130rpx;
  664. background-color: #fff;
  665. box-shadow: 3px 0 10px #efefef;
  666. box-sizing: border-box;
  667. justify-content: center;
  668. // &:first-child{height: 84rpx;border-top: 1rpx solid #E9F0F5;}
  669. }
  670. }
  671. }
  672. </style>