roomOrders.vue 14 KB

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