index.vue 13 KB

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