allPredetermine.vue 15 KB

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