roomStateDiagram.vue 11 KB

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