index.vue 14 KB

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