roomOrders.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396
  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 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. this.getData()
  113. }
  114. this.getData()
  115. },
  116. filters: {},
  117. methods: {
  118. getData() {
  119. getHotelRoomList().then(res => {
  120. console.log(res)
  121. if (res.code == 200) {
  122. this.roomListCopy = res.result
  123. this.filter()
  124. }
  125. })
  126. getCustomerSource().then(res => {
  127. console.log(res);
  128. if (res.code === 200 && res.result.records.length > 0) {
  129. this.customerSourceList = res.result.records
  130. } else {
  131. this.customerSourceList = []
  132. }
  133. })
  134. getRoomType().then(res => {
  135. console.log(res);
  136. if (res.code === 200 && res.result.records.length > 0) {
  137. this.cesRoomLayoutList = res.result.records
  138. this.current2 = res.result.records[0].id
  139. } else {
  140. this.cesRoomLayoutList = []
  141. }
  142. })
  143. },
  144. searchWord(){
  145. this.filter()
  146. },
  147. /**筛选符合条件的房子列表
  148. * @param {Array} type 房子状态数组
  149. */
  150. filter(type = [3, 4]) {
  151. console.log(type);
  152. let arr = []
  153. // arr = this.roomListCopy.filter(item => {
  154. // return item.rooms.filter(ele => {
  155. // return type.includes(ele.roomInfo.roomStatus)
  156. // })
  157. // })
  158. this.roomListCopy.forEach(item => {
  159. item.rooms = item.rooms.filter(ele => {
  160. return type.includes(ele.roomInfo.roomStatus)
  161. })
  162. })
  163. arr = JSON.parse(JSON.stringify(this.roomListCopy))
  164. console.log(typeof this.keyWord);
  165. if (this.keyWord) {
  166. arr.forEach(item => {
  167. item.rooms = item.rooms.filter(ele => {
  168. return ele.roomInfo.name == this.keyWord ||
  169. (ele.livingData && ele.livingData.livingCustomers ?
  170. ele.livingData.livingCustomers.customerName == this.keyWord :
  171. ele.bookingData && ele.bookingData.bookingCustomer ?
  172. ele.bookingData.bookingCustomer.name == this.keyWord :
  173. false) ||
  174. (ele.livingData && ele.livingData.livingCustomers ?
  175. ele.livingData.livingCustomers.phone == this.keyWord :
  176. ele.bookingData && ele.bookingData.bookingCustomer ?
  177. ele.bookingData.bookingCustomer.phone == this.keyWord :
  178. false)
  179. })
  180. })
  181. }
  182. console.log('arrarrarrarr', arr);
  183. this.roomList = JSON.parse(JSON.stringify(arr))
  184. console.log(this.roomList);
  185. if (this.roomList.length == 0) {
  186. return
  187. }
  188. let nameList = []
  189. this.roomList.forEach(ele => {
  190. ele.rooms.forEach(item => {
  191. nameList.push(item.layout.name)
  192. })
  193. })
  194. this.roomTypeCount = this.count(nameList)
  195. console.log(this.roomTypeCount);
  196. if (this.current == 1) {
  197. nameList = []
  198. this.roomList = this.filterLeave(this.roomList)
  199. }
  200. return arr
  201. },
  202. /**
  203. * 根据id计算每种房型的数量
  204. */
  205. filterRoomType(id) {
  206. let arr = JSON.parse(JSON.stringify(this.roomList))
  207. arr.forEach(item => {
  208. // console.log(item);
  209. item.rooms = item.rooms.filter(ele => {
  210. return ele.layout.id == id
  211. })
  212. })
  213. let count = 0
  214. arr.forEach(ele => {
  215. count += ele.rooms.length
  216. })
  217. return count
  218. },
  219. /**统计数组中每个字符串出现的次数
  220. * @param {Array} arr 要统计的数组
  221. * @returns {Array}
  222. */
  223. count(arr) {
  224. let obj = {}
  225. let array = []
  226. arr.forEach(ele => {
  227. if (obj[ele]) {
  228. obj[ele]++
  229. } else {
  230. obj[ele] = 1
  231. }
  232. })
  233. Object.keys(obj).forEach(ele => {
  234. array.push({
  235. name: ele,
  236. count: obj[ele]
  237. })
  238. })
  239. return array
  240. },
  241. /**
  242. * 筛选预离状态的房间
  243. * @param {Array} arr 房间列表
  244. * @returns {Array}
  245. */
  246. filterLeave(arr) {
  247. if (!arr) {
  248. return
  249. }
  250. let array = JSON.parse(JSON.stringify(arr))
  251. array.forEach(ele => {
  252. ele.rooms = ele.rooms.filter(item => {
  253. //比较时间
  254. return item.livingData.livingOrder.dueOutTime == item.livingData.livingOrder.arrivalTime
  255. })
  256. })
  257. return array
  258. },
  259. rightClick() {
  260. console.log('rightClick')
  261. },
  262. leftClick() {
  263. console.log('leftClick')
  264. },
  265. change(e) {
  266. console.log(e)
  267. },
  268. // 切换分段器
  269. sectionChange(index) {
  270. console.log(index)
  271. this.current = index
  272. if (index == 0) {
  273. this.filter()
  274. }
  275. if (index == 1) {
  276. let arr = this.filter()
  277. this.roomList = this.filterLeave(arr || [])
  278. console.log('1111111111111111111', this.roomList);
  279. if (this.roomList.some(ele => ele.rooms.length == 0) || this.roomList.length == 0) {
  280. // debugger
  281. this.roomTypeCount = [{
  282. name: '高级商务标间',
  283. count: 0
  284. },
  285. {
  286. name: '麻将房',
  287. count: 0
  288. },
  289. {
  290. name: '零压高级大床房',
  291. count: 0
  292. },
  293. {
  294. name: '商务单人房',
  295. count: 0
  296. },
  297. {
  298. name: '特惠大床房',
  299. count: 0
  300. },
  301. ]
  302. return
  303. }
  304. let nameList = []
  305. this.roomList.forEach(ele => {
  306. ele.rooms.forEach(item => {
  307. nameList.push(item.layout.name)
  308. })
  309. })
  310. this.roomTypeCount = this.count(this.roomList)
  311. }
  312. },
  313. bottomChange(index) {
  314. console.log(index)
  315. this.current1 = index
  316. },
  317. switchChange() {
  318. this.$nextTick(() => {
  319. this.getData()
  320. })
  321. }
  322. }
  323. }
  324. </script>
  325. <style lang="scss" scoped>
  326. /deep/.uni-select {
  327. border: none !important;
  328. text-align: center;
  329. }
  330. page {
  331. background-color: #f5f5f5;
  332. }
  333. .card-day {
  334. padding: 10px;
  335. background: #fff;
  336. margin-top: 8px;
  337. border-bottom: #00000030 1px solid;
  338. }
  339. .card-day-top {
  340. display: flex;
  341. justify-content: space-between;
  342. align-items: center;
  343. border-bottom: #00000030 1px solid;
  344. height: 30px;
  345. }
  346. .card-day-btm {
  347. margin-top: 10px;
  348. display: grid;
  349. grid-template-columns: repeat(2, 1fr);
  350. justify-content: space-between;
  351. gap: 10px;
  352. // div为偶数时右对齐
  353. div:nth-child(even) {
  354. text-align: right;
  355. }
  356. }
  357. .day-detail {
  358. background: #fff;
  359. padding: 10px;
  360. margin-top: 8px;
  361. .day-detail-title {
  362. font-weight: bold;
  363. font-size: 16px;
  364. color: #409EFF;
  365. }
  366. }
  367. .day-detail-list {
  368. display: flex;
  369. justify-content: space-between;
  370. align-items: center;
  371. height: 30px;
  372. font-size: 14px;
  373. }
  374. .btm-subsection {
  375. margin-top: 10px;
  376. }
  377. </style>