index.vue 17 KB

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