roomOrders.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411
  1. <template>
  2. <view>
  3. <Header ref="header" @change="switchChange">
  4. <template #search>
  5. <u--input v-model="keyWord" @change="searchWord" 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'}">
  6. </u--input>
  7. </template>
  8. <template #section>
  9. <u-subsection :list="list" mode="subsection" :current="current" @change="sectionChange"></u-subsection>
  10. </template>
  11. </Header>
  12. <template>
  13. <div class="card-day">
  14. <div class="card-day-top">
  15. <div style="font-size: 16px;color:#409EFF;font-weight: bold;">今日{{list[current]}}概览</div>
  16. <div style="color:#409EFF;font-size:14px">
  17. <!-- 合计 <span>{{roomTypeCount.reduce((pre, cur)=> pre+cur.count,0 )}}</span> 间 -->
  18. </div>
  19. </div>
  20. <div class="card-day-btm">
  21. <div v-for="(item, index) in cesRoomLayoutList" :key="index">
  22. <div>
  23. {{item.name}} {{filterRoomType(item.id)}}间
  24. </div>
  25. </div>
  26. </div>
  27. </div>
  28. <div class="day-detail">
  29. <div class="day-detail-title">
  30. 今日{{list[current]}}概览
  31. </div>
  32. <div v-for="item in roomList" :key="item.id">
  33. <template v-if="item.rooms.length>0">
  34. <div style="color:rgb(255, 141, 26);text-align:right;border-bottom:1px solid #00000030;line-height:30px">{{item.name}}:{{item.rooms.length}}间</div>
  35. <div v-for="(sItem, index) in item.rooms" :key="sItem.id" :style="{height:'60px',borderBottom:index!=item.rooms.length-1?'1px solid #00000030':'',}">
  36. <div style="margin-top:10px">
  37. <span style="font-size: 16px; font-weight: bold;margin-right:10px;">{{sItem.roomInfo.name}}</span> <span style="font-size: 16px; font-weight: bold;">{{sItem.layout.name }}</span> <span style="margin-left:10px;">{{''}}</span>
  38. </div>
  39. <div class="day-detail-list" v-if="sItem.livingData.livingOrder">
  40. <div style="width:35%;">{{sItem.livingData.livingCustomers.customerName}}/ {{sItem.livingData.livingCustomers.phone}}</div>
  41. <div>{{sItem.livingData.livingOrder.dayCount}}天/{{sItem.livingData.livingOrder.arrivalTime.substr(5,5)}}</div>
  42. <div>¥{{sItem.layout.marketPrice}}/付0/余0</div>
  43. </div>
  44. </div>
  45. </template>
  46. </div>
  47. </div>
  48. </template>
  49. <div class="btm-subsection">
  50. <u-subsection :list="list1" mode="subsection" :current="current1" @change="bottomChange"></u-subsection>
  51. </div>
  52. <div style="width:100vw;height: 30px;"></div>
  53. </view>
  54. </template>
  55. <script>
  56. import Header from '@/components/header.vue'
  57. import {
  58. getHotelRoomList,
  59. getCustomerSource,
  60. getRoomType
  61. } from '../../utils/customerOrder'
  62. export default {
  63. components: {
  64. Header
  65. },
  66. data() {
  67. return {
  68. value: 0,
  69. range: [{
  70. value: 0,
  71. text: "全部"
  72. },
  73. {
  74. value: 1,
  75. text: "沙县大酒店"
  76. },
  77. {
  78. value: 2,
  79. text: "游泳"
  80. },
  81. ],
  82. roomStatus: 3,
  83. list: ['全部', '预离', '续住', '欠费', '钟点', '散客', '团队', '联房'],
  84. list1: ['查看详情', '缴费', '退房结账'],
  85. current: 0,
  86. current1: 0,
  87. //酒店房子列表
  88. roomList: [],
  89. roomListCopy: [],
  90. //房型数量
  91. roomTypeCount: [],
  92. /**
  93. * 用户来源列表
  94. */
  95. customerSourceList: [],
  96. /**
  97. * 方块背景颜色列表
  98. */
  99. roomStatusColorList: [],
  100. /**
  101. * 房型列表
  102. */
  103. cesRoomLayoutList: [],
  104. keyWord: '',
  105. };
  106. },
  107. onLoad(options) {
  108. console.log(options);
  109. if (options.current) {
  110. // this.sectionChange(options.current)
  111. this.current = options.current
  112. }
  113. },
  114. onShow(){
  115. this.$nextTick(()=>{
  116. this.$refs.header.getHotels(()=>{
  117. setTimeout(()=>{
  118. this.getData()
  119. },500)
  120. })
  121. })
  122. },
  123. filters: {},
  124. methods: {
  125. getData() {
  126. getHotelRoomList().then(res => {
  127. console.log(res)
  128. if (res.code == 200) {
  129. this.roomListCopy = res.result
  130. this.filter()
  131. }
  132. })
  133. getCustomerSource().then(res => {
  134. console.log(res);
  135. if (res.code === 200 && res.result.records.length > 0) {
  136. this.customerSourceList = res.result.records
  137. } else {
  138. this.customerSourceList = []
  139. }
  140. })
  141. getRoomType().then(res => {
  142. console.log(res);
  143. if (res.code === 200 && res.result.records.length > 0) {
  144. this.cesRoomLayoutList = res.result.records
  145. this.current2 = res.result.records[0].id
  146. } else {
  147. this.cesRoomLayoutList = []
  148. }
  149. })
  150. },
  151. searchWord(){
  152. this.filter()
  153. },
  154. /**筛选符合条件的房子列表
  155. * @param {Array} type 房子状态数组
  156. */
  157. filter(type = [3, 4]) {
  158. console.log(type);
  159. let arr = []
  160. // arr = this.roomListCopy.filter(item => {
  161. // return item.rooms.filter(ele => {
  162. // return type.includes(ele.roomInfo.roomStatus)
  163. // })
  164. // })
  165. this.roomListCopy.forEach(item => {
  166. item.rooms = item.rooms.filter(ele => {
  167. return type.includes(ele.roomInfo.roomStatus)
  168. })
  169. })
  170. arr = JSON.parse(JSON.stringify(this.roomListCopy))
  171. console.log(typeof this.keyWord);
  172. if (this.keyWord) {
  173. arr.forEach(item => {
  174. item.rooms = item.rooms.filter(ele => {
  175. return ele.roomInfo.name == this.keyWord ||
  176. (ele.livingData && ele.livingData.livingCustomers ?
  177. ele.livingData.livingCustomers.customerName == this.keyWord :
  178. ele.bookingData && ele.bookingData.bookingCustomer ?
  179. ele.bookingData.bookingCustomer.name == this.keyWord :
  180. false) ||
  181. (ele.livingData && ele.livingData.livingCustomers ?
  182. ele.livingData.livingCustomers.phone == this.keyWord :
  183. ele.bookingData && ele.bookingData.bookingCustomer ?
  184. ele.bookingData.bookingCustomer.phone == this.keyWord :
  185. false)
  186. })
  187. })
  188. }
  189. console.log('arrarrarrarr', arr);
  190. this.roomList = JSON.parse(JSON.stringify(arr))
  191. console.log(this.roomList);
  192. if (this.roomList.length == 0) {
  193. return
  194. }
  195. let nameList = []
  196. this.roomList.forEach(ele => {
  197. ele.rooms.forEach(item => {
  198. nameList.push(item.layout.name)
  199. })
  200. })
  201. this.roomTypeCount = this.count(nameList)
  202. console.log(this.roomTypeCount);
  203. if (this.current == 1) {
  204. nameList = []
  205. this.roomList = this.filterLeave(this.roomList)
  206. }
  207. return arr
  208. },
  209. /**
  210. * 根据id计算每种房型的数量
  211. */
  212. filterRoomType(id) {
  213. let arr = JSON.parse(JSON.stringify(this.roomList))
  214. arr.forEach(item => {
  215. // console.log(item);
  216. item.rooms = item.rooms.filter(ele => {
  217. return ele.layout.id == id
  218. })
  219. })
  220. let count = 0
  221. arr.forEach(ele => {
  222. count += ele.rooms.length
  223. })
  224. return count
  225. },
  226. /**统计数组中每个字符串出现的次数
  227. * @param {Array} arr 要统计的数组
  228. * @returns {Array}
  229. */
  230. count(arr) {
  231. let obj = {}
  232. let array = []
  233. arr.forEach(ele => {
  234. if (obj[ele]) {
  235. obj[ele]++
  236. } else {
  237. obj[ele] = 1
  238. }
  239. })
  240. Object.keys(obj).forEach(ele => {
  241. array.push({
  242. name: ele,
  243. count: obj[ele]
  244. })
  245. })
  246. return array
  247. },
  248. /**
  249. * 筛选预离状态的房间
  250. * @param {Array} arr 房间列表
  251. * @returns {Array}
  252. */
  253. filterLeave(arr) {
  254. if (!arr) {
  255. return
  256. }
  257. let array = JSON.parse(JSON.stringify(arr))
  258. array.forEach(ele => {
  259. ele.rooms = ele.rooms.filter(item => {
  260. //比较时间
  261. return item.livingData.livingOrder.dueOutTime == item.livingData.livingOrder.arrivalTime
  262. })
  263. })
  264. return array
  265. },
  266. rightClick() {
  267. console.log('rightClick')
  268. },
  269. leftClick() {
  270. console.log('leftClick')
  271. },
  272. change(e) {
  273. console.log(e)
  274. },
  275. // 切换分段器
  276. sectionChange(index) {
  277. console.log(index)
  278. this.current = index
  279. if (index == 0) {
  280. this.filter()
  281. }
  282. if (index == 1) {
  283. let arr = this.filter()
  284. this.roomList = this.filterLeave(arr || [])
  285. console.log('1111111111111111111', this.roomList);
  286. if (this.roomList.some(ele => ele.rooms.length == 0) || this.roomList.length == 0) {
  287. // debugger
  288. this.roomTypeCount = [{
  289. name: '高级商务标间',
  290. count: 0
  291. },
  292. {
  293. name: '麻将房',
  294. count: 0
  295. },
  296. {
  297. name: '零压高级大床房',
  298. count: 0
  299. },
  300. {
  301. name: '商务单人房',
  302. count: 0
  303. },
  304. {
  305. name: '特惠大床房',
  306. count: 0
  307. },
  308. ]
  309. return
  310. }
  311. let nameList = []
  312. this.roomList.forEach(ele => {
  313. ele.rooms.forEach(item => {
  314. nameList.push(item.layout.name)
  315. })
  316. })
  317. this.roomTypeCount = this.count(this.roomList)
  318. }
  319. },
  320. bottomChange(index) {
  321. console.log(index)
  322. this.current1 = index
  323. },
  324. switchChange() {
  325. this.$nextTick(() => {
  326. this.getData()
  327. })
  328. }
  329. }
  330. }
  331. </script>
  332. <style lang="scss" scoped>
  333. /deep/.uni-select {
  334. border: none !important;
  335. text-align: center;
  336. }
  337. page {
  338. background-color: #f5f5f5;
  339. }
  340. .card-day {
  341. padding: 10px;
  342. background: #fff;
  343. margin-top: 8px;
  344. border-bottom: #00000030 1px solid;
  345. }
  346. .card-day-top {
  347. display: flex;
  348. justify-content: space-between;
  349. align-items: center;
  350. border-bottom: #00000030 1px solid;
  351. height: 30px;
  352. }
  353. .card-day-btm {
  354. margin-top: 10px;
  355. display: flex;
  356. flex-wrap: wrap;
  357. grid-template-columns: repeat(2, 1fr);
  358. justify-content: space-between;
  359. gap: 10px;
  360. text-align: center;
  361. div{
  362. width: 100%;
  363. text-align: center;
  364. }
  365. // div为偶数时右对齐
  366. // div:nth-child(even) {
  367. // text-align: right;
  368. // }
  369. }
  370. .day-detail {
  371. background: #fff;
  372. padding: 10px;
  373. margin-top: 8px;
  374. .day-detail-title {
  375. font-weight: bold;
  376. font-size: 16px;
  377. color: #409EFF;
  378. }
  379. }
  380. .day-detail-list {
  381. display: flex;
  382. justify-content: space-between;
  383. align-items: center;
  384. height: 30px;
  385. font-size: 14px;
  386. }
  387. .btm-subsection {
  388. margin-top: 10px;
  389. }
  390. </style>