index.vue 17 KB

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