roomStateDiagram.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339
  1. <template>
  2. <view>
  3. <Header ref="header" @change="headerChange" :isSwitch="true">
  4. <template #search>
  5. <!-- <u--input placeholder="房间号/姓名/手机号/身份证号" border="surround" shape="circle" prefixIcon="search" prefixIconStyle="font-size: 22px;color: #909399" fontSize="12px" :customStyle="{border:'1px solid #e2e2e2',padding:'0 10px',margin:'0 10px',borderRadius:'20px'}" @change="searchChange"></u--input> -->
  6. </template>
  7. <template #section>
  8. <u-subsection :list="list" mode="subsection" :current="current" @change="sectionChange"></u-subsection>
  9. </template>
  10. </Header>
  11. <div style="background:#fff">
  12. <div class="room-state-explain">
  13. <div style="margin-right:8px">房态说明</div>
  14. <div v-for="(item, index) in roomStatusColorList" :key="index" style="margin-right:8px">
  15. <div :style="{width:'15px',height:'10px',background:item.extend}"></div>{{item.text}}:{{roomStateFilter(item.value)}}
  16. </div>
  17. </div>
  18. <div style="width:50%;margin-bottom:10px">
  19. <u-subsection :bold="false" :list="list1" mode="subsection" :current="current1" @change="selectChange"></u-subsection>
  20. </div>
  21. <div v-if="current1==1">
  22. <!-- <u-subsection :list="list2" mode="subsection" :current="current2" @change="selectChangeRoomState" fontSize="10"></u-subsection> -->
  23. <div class="tabs-list">
  24. <div v-for="(item, index) in cesRoomLayoutList" :key="item.id" class="tabs-list-content" :class="{'tabs-list-border':index!=list2.length-1}" @click="selectChangeRoomModel(item,index)" :style="{background:item.id==current2?'rgb(60, 156, 255)':'',color:item.id==current2?'#fff':''}">{{item.name}}</div>
  25. </div>
  26. </div>
  27. <div v-if="current1==2">
  28. <u-subsection :bold="false" :list="list3" mode="subsection" :current="current3" @change="selectChangeRoomState" fontSize="10"></u-subsection>
  29. </div>
  30. <div style="margin-top:10px">
  31. <div class="room-state-detail" v-for="item in dataList" :key="item.id">
  32. <div class="room-state-detail-title">{{item.name.includes('栋')? item.name : item.buildingName + item.name}}:{{item.rooms.length}}间</div>
  33. <div class="ctner">
  34. <div class="room-state-detail-grid">
  35. <div class="room-state-detail-card" v-for="sItem in item.rooms" :key="sItem.id" :style="{background: roomStatusColorList && roomStatusColorList.length > 0 ? getRoomStatusColor(sItem.roomInfo.roomStatus) : '',}">
  36. <div style="display:flex;justify-content: space-between;">
  37. <div><b>{{sItem.roomInfo.name}}</b></div>
  38. <div v-if="sItem.livingData.livingOrder" style="background:rgb(255, 141, 26);color:#fff;padding:1px 2px;border-radius:5px;">{{getCustomerSourceList(sItem.livingData.livingOrder.customerSource)}}</div>
  39. </div>
  40. <div v-if="sItem.livingData.livingOrder">
  41. <div style="width:100%;overflow: hidden;"><b>{{sItem.livingData.livingCustomers.customerName}}</b><span v-if="sItem.livingData.livingOrder.vipCustomerId" style="color:red; font-size: 12px;transform: scale(0.6);display:inline-block;">VIP</span></div>
  42. <div>{{sItem.livingData.livingOrder.dayCount}}天/{{ sItem.livingData.livingOrder.arrivalTime }}</div>
  43. <div style="width:100%;overflow: hidden;">¥{{sItem.livingData.price && sItem.livingData.price.length > 0 ? sItem.livingData.price[0].price : 0 }}/剩0</div>
  44. </div>
  45. <b v-else>
  46. {{sItem.layout.name}}
  47. </b>
  48. </div>
  49. </div>
  50. </div>
  51. </div>
  52. </div>
  53. </div>
  54. </view>
  55. </template>
  56. <script>
  57. import Header from '@/components/header.vue'
  58. import {
  59. getHotelRoomList,
  60. getRoomStatus,
  61. getCustomerSource,
  62. getRoomType
  63. } from '../../utils/customerOrder'
  64. export default {
  65. components: {
  66. Header
  67. },
  68. data() {
  69. return {
  70. list: ['全部', '在住', '预离', '欠费', '钟点', '团队', '散客', '联房', '脏房'],
  71. list1: ['按楼层', '按房型', '按房态'],
  72. list2: [],
  73. list3: [],
  74. current: 0,
  75. current1: 0,
  76. current2: 0,
  77. current3: 0,
  78. dataList: [],
  79. dataListCopy: [],
  80. /**
  81. * 用户来源列表
  82. */
  83. customerSourceList: [],
  84. /**
  85. * 方块背景颜色列表
  86. */
  87. roomStatusColorList: [],
  88. /**
  89. * 房型列表
  90. */
  91. cesRoomLayoutList: [],
  92. }
  93. },
  94. mounted() {
  95. },
  96. onShow() {
  97. this.$nextTick(()=>{
  98. this.$refs.header.getHotels(()=>{
  99. })
  100. })
  101. },
  102. methods: {
  103. sectionChange(i) {
  104. console.log(i)
  105. this.current = i
  106. },
  107. searchChange(e) {
  108. console.log(e)
  109. },
  110. selectChange(e) {
  111. console.log(e)
  112. this.current1 = e
  113. this.filter()
  114. },
  115. selectChangeRoomModel(data, idx) {
  116. console.log(data)
  117. this.current2 = data.id
  118. this.filter()
  119. },
  120. selectChangeRoomState(e) {
  121. console.log(e)
  122. this.current3 = e
  123. this.filter()
  124. },
  125. randomColor() {
  126. const color = Math.floor(Math.random() * 0xffffff).toString(16).padEnd(6, '0');
  127. return `#${color}`;
  128. },
  129. headerChange(e) {
  130. this.getData(e)
  131. },
  132. getData(id) {
  133. getHotelRoomList({hotelId:id}).then(res => {
  134. console.log(res);
  135. if (res.code == 200 && res.result.length > 0) {
  136. this.dataListCopy = res.result
  137. this.dataList = res.result
  138. }else{
  139. this.dataListCopy = []
  140. this.dataList = []
  141. }
  142. })
  143. getRoomStatus().then(res => {
  144. console.log(res);
  145. if (res.code == 200 && res.result.length > 0) {
  146. let arr = []
  147. res.result.forEach(ele => {
  148. arr.push(ele.text)
  149. })
  150. this.roomStatusColorList = res.result
  151. this.list3 = arr
  152. this.list3.unshift('全部')
  153. }else{
  154. this.roomStatusColorList = []
  155. this.list3 = []
  156. }
  157. })
  158. getCustomerSource().then(res => {
  159. console.log(res);
  160. if (res.code === 200 && res.result.records.length > 0) {
  161. this.customerSourceList = res.result.records
  162. console.log(this.current2);
  163. }else{
  164. this.customerSourceList = []
  165. }
  166. })
  167. getRoomType().then(res => {
  168. console.log(res);
  169. if (res.code === 200 && res.result.records.length > 0) {
  170. this.cesRoomLayoutList = res.result.records
  171. this.current2 = res.result.records[0].id
  172. }else{
  173. this.cesRoomLayoutList = []
  174. }
  175. })
  176. },
  177. /**
  178. * @description: 筛选
  179. * @param
  180. * @return
  181. */
  182. filter() {
  183. console.log('this.current1', this.current1);
  184. console.log('this.current3', this.current3);
  185. let arr = JSON.parse(JSON.stringify(this.dataListCopy))
  186. console.log('...............');
  187. arr.forEach(item => {
  188. this.current3 == 0 ? item.rooms = item.rooms :
  189. item.rooms = item.rooms.filter(ele => {
  190. return ele.roomInfo.roomStatus == this.current3
  191. })
  192. })
  193. if (this.current2 && this.current1 == 1) {
  194. arr.forEach(item => {
  195. item.rooms = item.rooms.filter(ele => {
  196. return ele.layout.id == this.current2
  197. })
  198. })
  199. }
  200. console.log('arrarrarrarr', arr);
  201. this.dataList = JSON.parse(JSON.stringify(arr))
  202. // console.log(this.roomList);
  203. // if (this.roomList.length == 0) {
  204. // return
  205. // }
  206. // let nameList = []
  207. // this.roomList.forEach(ele => {
  208. // ele.rooms.forEach(item => {
  209. // nameList.push(item.layout.name)
  210. // })
  211. // })
  212. // this.roomTypeCount = this.count(nameList)
  213. // console.log(this.roomTypeCount);
  214. return arr
  215. },
  216. getCustomerSourceList(customerSource, first) {
  217. console.log(customerSource);
  218. var find = this.customerSourceList.find((t) => t.id == customerSource);
  219. console.log(find);
  220. console.log(this.customerSourceList);
  221. if (find) {
  222. // return first ? find.label.substr(0, 1) : find.label;
  223. return find.itemText.substr(0, 1);
  224. }
  225. return "";
  226. },
  227. /**
  228. * 计算方块的背景颜色
  229. */
  230. getRoomStatusColor(roomStatus) {
  231. var find = this.roomStatusColorList.find((t) => t.value == roomStatus);
  232. return find ? find.extend : "";
  233. },
  234. /**
  235. * 计算房态出现的数量
  236. */
  237. roomStateFilter(roomStatus) {
  238. let count = 0
  239. let arr = JSON.parse(JSON.stringify(this.dataListCopy))
  240. arr.forEach(ele => {
  241. ele.rooms.forEach(item => {
  242. if (item.roomInfo.roomStatus == roomStatus) {
  243. count++
  244. }
  245. })
  246. })
  247. return count
  248. },
  249. }
  250. }
  251. </script>
  252. <style lang="scss" scoped>
  253. page {
  254. background-color: #f5f5f5;
  255. }
  256. .room-state-explain {
  257. display: flex;
  258. // justify-content: space-between;
  259. align-items: center;
  260. padding: 10px;
  261. font-size: 12px;
  262. height: 30px;
  263. margin-top: 10px;
  264. flex-wrap: wrap;
  265. div {
  266. display: flex;
  267. align-items: center;
  268. justify-content: center;
  269. // width: 20%;
  270. // height: 30px;
  271. // border-radius: 5px;
  272. // background-color: #fff;
  273. }
  274. }
  275. .room-state-detail-title {
  276. font-size: 14px;
  277. color: #00000080;
  278. padding: 0 8px;
  279. text-align: right;
  280. border-bottom: 1px solid #00000030;
  281. }
  282. .room-state-detail-grid {
  283. display: flex;
  284. flex-wrap: wrap;
  285. align-items: center;
  286. justify-content: start;
  287. width: 96vw;
  288. margin: 0 auto;
  289. // grid-template-columns: repeat(4, 1fr);
  290. // grid-gap: 10px;
  291. // padding: 10px;
  292. }
  293. .room-state-detail-card {
  294. width: calc(30vw);
  295. height: calc(30vw );
  296. font-size: 12px;
  297. border-radius: 8px;
  298. margin: 1vw;
  299. // background: red;
  300. color: #fff;
  301. padding: 1vw 1vw;
  302. box-sizing: border-box;
  303. //阴影
  304. box-shadow: 0 4px 5px rgba(0, 0, 0, 0.6);
  305. }
  306. .tabs-list {
  307. display: flex;
  308. flex-wrap: nowrap;
  309. font-size: 12px;
  310. border-radius: 3px;
  311. // overflow: hidden;
  312. border: 1px solid rgb(60, 156, 255);
  313. .tabs-list-content {
  314. text-align: center;
  315. padding: 5px 7px;
  316. flex: 1;
  317. // text-overflow: ellipsis;
  318. white-space: nowrap;
  319. // overflow: hidden;
  320. }
  321. .tabs-list-border {
  322. border-right: 1px solid rgb(60, 156, 255);
  323. }
  324. }
  325. </style>