index.vue 16 KB

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