index.vue 15 KB

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