index.vue 14 KB

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