index.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547
  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">
  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;">
  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) {
  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. uni.navigateTo({
  192. url: '/pages/house/createOrder?roomId=' + this.checkDataRoomId
  193. })
  194. },
  195. //展开收起
  196. open(i, F, val) {
  197. this.opens[i] = !this.opens[i];
  198. let list = this.leftData;
  199. for (var i = 0; i < Object.keys(list).length; i++) {
  200. var index = i; // 索引
  201. var key = Object.keys(list)[i].split('-')[0]; // key
  202. if (F == key) {
  203. this.opens[index] = val;
  204. }
  205. }
  206. this.$forceUpdate();
  207. },
  208. delDataStatus(roomNumber, id, roomId, name) {
  209. for (let i = 0; i < roomId.length; i++) {
  210. if (id == roomId[i].houseBaseId && roomNumber == roomId[i].roomNumber) {
  211. return roomId[i][name] + 1;
  212. }
  213. }
  214. },
  215. clearData() {
  216. setTimeout(() => {
  217. this.checkDataDate = [];
  218. this.checkPrice = [];
  219. this.checkDataRoomId = [];
  220. this.checkPosition = [];
  221. }, 1500);
  222. },
  223. //选择房间
  224. check(roomNumber, id, item, position) {
  225. for (let i = 0; i < item.roomDataList.length; i++) {
  226. if (
  227. id == item.roomDataList[i].houseBaseId &&
  228. roomNumber == item.roomDataList[i].roomNumber
  229. ) {
  230. //宫格位置标识
  231. if (item.roomDataList[i].status == 0) {
  232. if (this.checkPosition.indexOf(position) < 0) {
  233. this.checkPosition.push(position);
  234. } else {
  235. let index = this.checkPosition.findIndex(
  236. (pos) => pos == position
  237. ); //选中的索引位置
  238. this.checkPosition.splice(index, 1);
  239. }
  240. //房间id
  241. if (this.checkDataRoomId.indexOf(item.roomDataList[i].id) < 0) {
  242. this.checkDataRoomId.push(item.roomDataList[i].id);
  243. } else {
  244. let index = this.checkDataRoomId.findIndex(
  245. (roomId) => roomId == item.roomDataList[i].id
  246. );
  247. this.checkDataRoomId.splice(index, 1);
  248. }
  249. //日期
  250. if (this.checkPosition.indexOf(position) > -1) {
  251. this.checkDataDate.push(item.rentDate);
  252. this.checkPrice.push(item.roomDataList[i].price)
  253. } else {
  254. let index = this.checkDataDate.findIndex(
  255. (date) => date == item.rentDate
  256. );
  257. this.checkDataDate.splice(index, 1);
  258. //价格
  259. let index2 = this.checkPrice.findIndex(
  260. (price) => price == item.price
  261. );
  262. this.checkPrice.splice(index2, 1);
  263. }
  264. if (this.checkPosition.length == 0) {
  265. this.checkDataDate = [];
  266. this.checkPrice = [];
  267. }
  268. console.log(this.checkDataDate);
  269. console.log(this.checkDataRoomId)
  270. }
  271. }
  272. }
  273. },
  274. getLeftData() {
  275. this.$api.get(`/merchant/hotel/room/state/getHouseCategoryData/${this.homestayId}`).then(res => {
  276. console.log(res)
  277. if (res.data.code == 0) {
  278. // for (let i; i < res.data.data.length; i++) {
  279. // res.data.data[i].open = true;
  280. // }
  281. for (let i in res.data.data) {
  282. let F = i.split('-')[0];
  283. if (this.indexArr.indexOf(F) < 0) {
  284. this.indexArr.push(F);
  285. this.opens.push(true)
  286. } else {
  287. this.indexArr.push('');
  288. this.opens.push(true)
  289. }
  290. }
  291. this.leftData = res.data.data;
  292. console.log(this.leftData)
  293. console.log(this.indexArr)
  294. }
  295. })
  296. },
  297. getData() {
  298. this.$api.get('/merchant/hotel/room/state/getDateRoomList', {
  299. homestayId: this.homestayId,
  300. nowDate: '',
  301. status: ''
  302. }).then(res => {
  303. if (res.data.code == 0) {
  304. this.xdata = res.data.data;
  305. }
  306. })
  307. }
  308. }
  309. }
  310. </script>
  311. <style scoped lang="less">
  312. .opration {
  313. height: 140rpx;
  314. padding: 0 30rpx;
  315. background-color: #fff;
  316. position: fixed;
  317. bottom: 0;
  318. left: 0;
  319. width: 100%;
  320. z-index: 9;
  321. display: flex;
  322. align-items: center;
  323. justify-content: space-between;
  324. box-sizing: border-box;
  325. text {
  326. display: inline-block;
  327. width: 160rpx;
  328. text-align: center;
  329. line-height: 56rpx;
  330. border: 1rpx solid #D1D1D1;
  331. height: 56rpx;
  332. border-radius: 64rpx;
  333. font-size: 24rpx;
  334. color: #999;
  335. &:last-child {
  336. background-color: #1372FF;
  337. color: #fff;
  338. border: 0;
  339. }
  340. }
  341. }
  342. .page {
  343. background: #F3F4F4;
  344. padding-bottom: 40rpx;
  345. box-sizing: border-box;
  346. overflow-y: auto;
  347. overflow-x: auto;
  348. }
  349. .date {
  350. display: flex;
  351. border: 1rpx solid #E9F0F5;
  352. margin-bottom: 30rpx;
  353. .item {
  354. min-width: 130rpx;
  355. width: 130rpx;
  356. height: 136rpx;
  357. display: flex;
  358. flex-direction: column;
  359. align-items: center;
  360. justify-content: center;
  361. font-size: 20rpx;
  362. border-right: 1rpx solid #E9F0F5;
  363. background-color: #fff;
  364. &:last-child {
  365. border: 0;
  366. }
  367. text {
  368. &:nth-child(2) {
  369. margin: 6rpx 0;
  370. }
  371. }
  372. }
  373. }
  374. .floorData {
  375. .head,
  376. .roomType {
  377. padding: 0 30rpx;
  378. display: flex;
  379. justify-content: space-between;
  380. }
  381. .head {
  382. &>text {
  383. &:first-child {
  384. font-size: 32rpx;
  385. }
  386. }
  387. .rightIcon {
  388. display: flex;
  389. align-items: center;
  390. font-size: 24rpx;
  391. color: #1F2425;
  392. }
  393. }
  394. .roomType {
  395. color: #333;
  396. font-size: 24rpx;
  397. position: relative;
  398. padding-left: 44rpx;
  399. margin: 20rpx 0 16rpx;
  400. &::after {
  401. position: absolute;
  402. content: "";
  403. height: 24rpx;
  404. width: 5rpx;
  405. background-color: #1372FF;
  406. left: 30rpx;
  407. top: 4rpx;
  408. z-index: 1;
  409. }
  410. }
  411. .table {
  412. border: 1rpx solid #E9F0F5;
  413. width: auto;
  414. min-width: 100%;
  415. .tr {
  416. border-bottom: 1rpx solid #E9F0F5;
  417. display: flex;
  418. align-items: center;
  419. background-color: #fff;
  420. &:last-child {
  421. border: 0;
  422. }
  423. .td {
  424. display: flex;
  425. align-items: center;
  426. justify-content: center;
  427. position: relative;
  428. width: 130rpx;
  429. min-width: 130rpx;
  430. height: 83rpx;
  431. border-right: 1rpx solid #E9F0F5;
  432. background-color: #fff;
  433. color: #1F2425;
  434. font-size: 20rpx;
  435. .tdP,
  436. .cellBox {
  437. display: flex;
  438. height: 100%;
  439. flex-direction: column;
  440. align-items: center;
  441. justify-content: center;
  442. }
  443. &:last-child {
  444. border: 0;
  445. }
  446. //已预订
  447. &.s2 {
  448. background-color: rgba(29, 202, 104, 0.1);
  449. color: rgb(29, 202, 104);
  450. text {
  451. &:first-child {
  452. margin-bottom: 6rpx;
  453. color: #1F2425;
  454. }
  455. }
  456. }
  457. // 已入住
  458. &.s3 {
  459. color: rgb(19, 114, 255);
  460. background-color: rgba(19, 114, 255, 0.1);
  461. text {
  462. &:first-child {
  463. margin-bottom: 6rpx;
  464. color: #1F2425;
  465. }
  466. }
  467. }
  468. // 已退房
  469. &.s4 {
  470. color: rgb(219, 41, 195);
  471. background-color: rgba(219, 41, 195, 0.1);
  472. }
  473. //待确定
  474. &.s5 {
  475. color: rgb(25, 185, 197);
  476. background-color: rgba(25, 185, 197, 0.1);
  477. }
  478. //清洁中
  479. &.s6 {
  480. color: rgb(237, 86, 86);
  481. background-color: rgba(237, 86, 86, 0.1);
  482. }
  483. //暂停使用
  484. &.s7 {
  485. color: rgb(41, 60, 115);
  486. background-color: rgba(41, 60, 115, 0.1);
  487. }
  488. //保留房
  489. &.s8 {
  490. color: rgb(132, 68, 244);
  491. background-color: rgba(132, 68, 244, 0.1);
  492. }
  493. }
  494. }
  495. .cover {
  496. position: absolute;
  497. top: 0;
  498. left: 0;
  499. bottom: 0;
  500. right: 0;
  501. background-color: #1372FF;
  502. color: #fff;
  503. text-align: center;
  504. display: flex;
  505. flex-direction: column;
  506. justify-content: center;
  507. align-items: center;
  508. }
  509. }
  510. }
  511. </style>