arrivalsDay.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386
  1. <template>
  2. <div>
  3. <template>
  4. <div class="card-day">
  5. <div >
  6. <div style="font-size: 12px;color:#409EFF; display:flex;justify-content:space-between;align-items:center;">
  7. <div>
  8. <span style="font-size: 16px;font-weight: bold;margin-right:10px">今日预抵概览</span>共 <span>{{dataList.length}}</span> 间
  9. </div>
  10. <!-- <div @click="show = true" class="calendar">{{`${startTime} ~ ${endTime}`}}</div> -->
  11. <div style="color:#409EFF;font-size:14px;width:40%;">
  12. <u-subsection :list="list" mode="subsection" :current="current" @change="sectionChangeDay"></u-subsection>
  13. </div>
  14. </div>
  15. </div>
  16. <div class="card-day-btm" v-show="current==0">
  17. <div v-for="(item, index) in cesRoomLayoutList" :key="index">
  18. <div>
  19. {{item.name}} {{ filterRoomType(item.id)}}间
  20. </div>
  21. </div>
  22. </div>
  23. <div class="card-day-btm" v-show="current==1">
  24. <div v-for="(item, index) in customerSourceList" :key="index">
  25. <div>
  26. {{item.itemText}} {{ filterCustomerSource(item.id)}}间
  27. </div>
  28. </div>
  29. <!-- <div>
  30. <div>
  31. 携程 {{25}}间
  32. </div>
  33. <div>
  34. 去哪儿 {{25}} 间
  35. </div>
  36. </div>
  37. <div>
  38. <div>
  39. 艺龙 {{25}}间
  40. </div>
  41. <div>
  42. 微信 {{25}} 间
  43. </div>
  44. </div> -->
  45. </div>
  46. </div>
  47. <div class="day-detail">
  48. <div class="day-detail-title">
  49. <div style="color: #409EFF;">
  50. 今日{{'预抵'}}详情
  51. </div>
  52. <uni-data-select :placeholder="current==0? '请选择房型' : '请选择订单来源'" :clear="false" style="width:40%;flex:none;" :localdata="current==0? range : range2" @change="change"></uni-data-select>
  53. </div>
  54. <div>
  55. <!-- <div style="color:rgb(255, 141, 26);text-align:right;border-bottom:1px solid #00000030;line-height:30px">A栋6层:12间</div> -->
  56. <div v-for="(sItem, index) in dataList" :key="sItem.id" :class="index==curIdx?'list-active':''" :style="{height:'90px',borderBottom:index!=5?'1px solid #00000030':'',padding:'10px 0 0 0'}" @click="changeList(index)">
  57. <div>
  58. <span v-if="sItem.bookingData &&sItem.bookingData.bookingOrder && sItem.bookingData.bookingCustomer" style="font-size: 16px; font-weight: bold;">{{index+1}} {{sItem.bookingData.bookingCustomer.name + ' / '+ (sItem.livingData.livingCustomers? sItem.livingData.livingCustomers.gender == 1 ? "男 / ": "女 / " : "") + sItem.bookingData.bookingCustomer.phone }}</span>
  59. <b v-else>{{index+1}}</b>
  60. </div>
  61. <div class="day-detail-list">
  62. <div>房型:{{sItem.layout.name}}/1间</div>
  63. <!-- <div>一天</div> -->
  64. <div>预住时长:{{sItem.bookingData.bookingOrder.dayCount}}天</div>
  65. </div>
  66. <div class="day-detail-list">
  67. <div>预抵:{{sItem.bookingData.bookingOrder.arrivalTime}}</div>
  68. <div>保留:03/24/16:00</div>
  69. <div>已付:300元</div>
  70. </div>
  71. </div>
  72. </div>
  73. </div>
  74. </template>
  75. <u-calendar closeOnClickOverlay :show="show" mode="range" @close="close" @confirm="confirm"></u-calendar>
  76. </div>
  77. </template>
  78. <script>
  79. import {
  80. getHotelRoomList,
  81. getRoomStatus,
  82. getCustomerSource,
  83. getRoomType
  84. } from '../../utils/customerOrder'
  85. import {
  86. mapState
  87. } from 'vuex'
  88. export default {
  89. data() {
  90. return {
  91. list: ['按房间类型', '按订单来源'],
  92. current: 0,
  93. value: 0,
  94. range: [],
  95. range2:[],
  96. show:false,
  97. startTime:'开始时间',
  98. endTime:'结束时间',
  99. curIdx:-1,
  100. dataList: [],
  101. dataListCopy: [],
  102. /**
  103. * 用户来源列表
  104. */
  105. customerSourceList: [],
  106. /**
  107. * 方块背景颜色列表
  108. */
  109. roomStatusColorList: [],
  110. /**
  111. * 房型列表
  112. */
  113. cesRoomLayoutList: [],
  114. }
  115. },
  116. computed: {
  117. ...mapState(['hotelId'])
  118. },
  119. mounted() {
  120. this.getData()
  121. },
  122. filters: {
  123. },
  124. methods:{
  125. sectionChangeDay(e) {
  126. console.log(e)
  127. this.current = e
  128. },
  129. change(e) {
  130. console.log(e)
  131. this.filterId = e
  132. this.filter()
  133. },
  134. confirm(e) {
  135. console.log(e)
  136. this.startTime = e[0]
  137. this.endTime = e[e.length - 1]
  138. this.show = false
  139. },
  140. close() {
  141. this.show = false
  142. },
  143. changeList(index) {
  144. this.curIdx = index
  145. this.$emit('changeList', index)
  146. },
  147. headerChange(e) {
  148. this.getData(e)
  149. },
  150. getData(id = this.hotelId) {
  151. getHotelRoomList({
  152. hotelId: id
  153. }).then(res => {
  154. console.log(res);
  155. if (res.code == 200 && res.result.length > 0) {
  156. this.dataListCopy = res.result
  157. // this.dataList = res.result
  158. this.filter()
  159. } else {
  160. this.dataListCopy = []
  161. this.dataList = []
  162. }
  163. })
  164. getRoomStatus().then(res => {
  165. console.log(res);
  166. if (res.code == 200 && res.result.length > 0) {
  167. let arr = []
  168. res.result.forEach(ele => {
  169. arr.push(ele.text)
  170. })
  171. this.roomStatusColorList = res.result
  172. this.list3 = arr
  173. this.list3.unshift('全部')
  174. } else {
  175. this.roomStatusColorList = []
  176. this.list3 = []
  177. }
  178. })
  179. getCustomerSource().then(res => {
  180. console.log(res);
  181. if (res.code === 200 && res.result.records.length > 0) {
  182. this.customerSourceList = res.result.records
  183. console.log(this.current2);
  184. this.range2 = res.result.records.map(item => {
  185. return {
  186. value: item.id,
  187. text: item.itemText
  188. }
  189. })
  190. this.range2.unshift({
  191. value: null,
  192. text: '全部'
  193. })
  194. } else {
  195. this.customerSourceList = []
  196. this.range2 = []
  197. }
  198. })
  199. getRoomType().then(res => {
  200. console.log(res);
  201. if (res.code === 200 && res.result.records.length > 0) {
  202. this.cesRoomLayoutList = res.result.records
  203. this.current2 = res.result.records[0].id
  204. this.range = res.result.records.map(item => {
  205. return {
  206. value: item.id,
  207. text: item.name
  208. }
  209. })
  210. this.range.unshift({
  211. value: null,
  212. text: '全部'
  213. })
  214. } else {
  215. this.cesRoomLayoutList = []
  216. this.range = []
  217. }
  218. })
  219. },
  220. /**
  221. * @description: 筛选
  222. * @param
  223. * @return
  224. */
  225. filter() {
  226. console.log('this.current', this.current);
  227. console.log('this.current3', this.current3);
  228. let arr = JSON.parse(JSON.stringify(this.dataListCopy))
  229. console.log(arr);
  230. arr.forEach(item => {
  231. item.rooms = item.rooms.filter(ele => {
  232. return ele.bookingData && ele.bookingData.bookingOrder && new Date().toLocaleDateString() == new Date(ele.bookingData.bookingOrder.arrivalTime).toLocaleDateString()
  233. })
  234. })
  235. if (this.current == 0 && this.filterId) {
  236. arr.forEach(item => {
  237. console.log(item);
  238. item.rooms = item.rooms.filter(ele => {
  239. return ele.layout.id == this.filterId
  240. })
  241. })
  242. }
  243. if (this.current == 1 && this.filterId) {
  244. arr.forEach(item => {
  245. console.log(item);
  246. item.rooms = item.rooms.filter(ele => {
  247. return ele.livingData && ele.livingData.livingOrder ? ele.livingData.livingOrder.customerSource == this.filterId : ele.bookingData && ele.bookingData.bookingOrder ? ele.bookingData.bookingOrder.customerSource == this.filterId : false
  248. })
  249. })
  250. }
  251. let brr = []
  252. arr.forEach(item => {
  253. if (item.rooms.length > 0) {
  254. brr.push(...item.rooms)
  255. }
  256. })
  257. console.log('arrarrarrarr', arr);
  258. this.dataList = JSON.parse(JSON.stringify(brr))
  259. // this.dataListCopy = JSON.parse(JSON.stringify(brr))
  260. console.log(brr);
  261. // return arr
  262. },
  263. /**
  264. * 根据id计算每种房型的数量
  265. */
  266. filterRoomType(id) {
  267. let arr = JSON.parse(JSON.stringify(this.dataList))
  268. arr = arr.filter(item => {
  269. return item.layout.id == id
  270. })
  271. return arr.length
  272. },
  273. /**
  274. * 根据id计算每种来源的数量
  275. */
  276. filterCustomerSource(id) {
  277. let arr = JSON.parse(JSON.stringify(this.dataList))
  278. arr = arr.filter(item => {
  279. return item.livingData && item.livingData.livingOrder ? item.livingData.livingOrder.customerSource == id : item.bookingData && item.bookingData.bookingOrder ? item.bookingData.bookingOrder.customerSource == id : false
  280. })
  281. return arr.length
  282. },
  283. getCustomerSourceList(customerSource, first) {
  284. console.log(customerSource);
  285. var find = this.customerSourceList.find((t) => t.id == customerSource);
  286. console.log(find);
  287. console.log(this.customerSourceList);
  288. if (find) {
  289. // return first ? find.label.substr(0, 1) : find.label;
  290. return find.itemText.substr(0, 1);
  291. }
  292. return "";
  293. },
  294. /**
  295. * 计算方块的背景颜色
  296. */
  297. getRoomStatusColor(roomStatus) {
  298. var find = this.roomStatusColorList.find((t) => t.value == roomStatus);
  299. return find ? find.extend : "";
  300. },
  301. /**
  302. * 计算房态出现的数量
  303. */
  304. roomStateFilter(roomStatus) {
  305. let count = 0
  306. let arr = JSON.parse(JSON.stringify(this.dataListCopy))
  307. arr.forEach(ele => {
  308. ele.rooms.forEach(item => {
  309. if (item.roomInfo.roomStatus == roomStatus) {
  310. count++
  311. }
  312. })
  313. })
  314. return count
  315. },
  316. }
  317. }
  318. </script>
  319. <style lang="scss" scoped>
  320. .list-active{
  321. background: rgb(228, 240, 253);
  322. }
  323. .card-day {
  324. padding: 10px;
  325. background: #fff;
  326. margin-top: 8px;
  327. border-bottom: #00000030 1px solid;
  328. }
  329. .card-day-top {
  330. display: flex;
  331. justify-content: space-between;
  332. align-items: center;
  333. border-bottom: #00000030 1px solid;
  334. height: 35px;
  335. }
  336. .card-day-btm {
  337. margin-top: 10px;
  338. display: grid;
  339. grid-template-columns: repeat(2, 1fr);
  340. justify-content: space-between;
  341. gap: 10px;
  342. // div为偶数时右对齐
  343. div:nth-child(even) {
  344. text-align: right;
  345. }
  346. }
  347. .day-detail {
  348. background: #fff;
  349. padding: 10px;
  350. margin-top: 8px;
  351. .day-detail-title {
  352. font-weight: bold;
  353. font-size: 16px;
  354. display: flex;
  355. justify-content: space-between;
  356. align-items: center;
  357. }
  358. }
  359. .day-detail-list {
  360. display: flex;
  361. justify-content: space-between;
  362. align-items: center;
  363. margin: 10px 15px;
  364. // height: 30px;
  365. font-size: 12px;
  366. }
  367. .calendar{
  368. border: 1px solid;
  369. padding: 5px 10px;
  370. border-radius: 5px;
  371. }
  372. </style>