businessAnalysis.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443
  1. <template>
  2. <view>
  3. <Header :borbtm="false" @change="headerChange">
  4. <template #search>
  5. <u-subsection :list="list" mode="subsection" :current="current" @change="topChange"></u-subsection>
  6. </template>
  7. <template #section>
  8. </template>
  9. </Header>
  10. <div style="display:flex;padding:10px;">
  11. <uni-data-select :clear="false" v-model="timeCheck" :localdata="rangeTime" @change="changeTime"></uni-data-select>
  12. <uni-data-select :clear="false" v-model="dayCheck" :localdata="rangeDay" @change="changeDay"></uni-data-select>
  13. <div @click="show = true" class="calendar">{{`${startTime} ~ ${endTime}`}}</div>
  14. </div>
  15. <u-calendar closeOnClickOverlay :show="show" mode="range" @close="close" @confirm="confirm"></u-calendar>
  16. <div class="content-detail">
  17. <div class="content-detail-top">
  18. <div>
  19. <div>
  20. 总营业额/元
  21. </div>
  22. <div>
  23. {{todayTotalIncome}}元
  24. </div>
  25. </div>
  26. <div v-if="currentWay == 1">
  27. <div>
  28. 实收
  29. </div>
  30. <div>
  31. {{todayIncome.reduce((pre, cur) => pre+cur.amount,0 ) || 0}}元
  32. </div>
  33. </div>
  34. <div v-if="currentWay == 1">
  35. <div>
  36. 欠款(预付)/元
  37. </div>
  38. <div>
  39. {{roomData.todayArrearsRoomData}}
  40. </div>
  41. </div>
  42. </div>
  43. <div class="content-detail-bottom">
  44. <!-- <div>
  45. <div>间夜数</div>
  46. <div>1234</div>
  47. </div> -->
  48. <div>
  49. <div>入住率</div>
  50. <div>{{((roomData.checkInRoomData/roomData.allRoomData) || 0).toFixed(2)}}%</div>
  51. </div>
  52. <div>
  53. <div>平均房价/元</div>
  54. <div>{{roomData.housingPrices}}</div>
  55. </div>
  56. <div>
  57. <div>RevPAR</div>
  58. <div v-if="roomData.checkInRoomData/roomData.allRoomData!=0 && roomData.allRoomData!=0" style="font-size: 18px;">{{((roomData.housingPrices*roomData.allRoomData)/(roomData.checkInRoomData/roomData.allRoomData).toFixed(2)).toFixed(2)}}</div>
  59. <div v-else style="font-size: 18px;">{{0}}</div>
  60. </div>
  61. </div>
  62. </div>
  63. <!-- 支付方式 -->
  64. <u-subsection v-if="currentWay==1" style="margin-top:20px;width:35vw;" :list="payMethodsList" mode="subsection" :current="currentPayMethods" @change="PayChange"></u-subsection>
  65. <u-subsection style="margin-top:20px;" :list="listWay" mode="subsection" :current="currentWay" @change="WayChange"></u-subsection>
  66. <!-- table表格 -->
  67. <!-- 按时间 -->
  68. <Time :tableData="tableData" v-if="currentWay==0" />
  69. <!-- 按收款方式 -->
  70. <PayMethodsVue :tableData="tableData" v-if="currentWay==1" />
  71. <!-- 按房型 -->
  72. <RoomTypeVue :tableData="tableData" v-if="currentWay==2" />
  73. <!-- 按费项 -->
  74. <FeeItemsVue :tableData="tableData" v-if="currentWay==3" />
  75. <!-- 按来源 -->
  76. <SourceVue :tableData="tableData" v-if="currentWay==4" />
  77. <!-- 按客型 -->
  78. <CustomerTypeVue :tableData="tableData" v-if="currentWay==5" />
  79. <!-- 按入住类型 -->
  80. <OccupancyTypeVue :tableData="tableData" v-if="currentWay==6" />
  81. </view>
  82. </template>
  83. <script>
  84. import Header from '../header.vue'
  85. import PayMethodsVue from '../tableCharts/payMethods.vue'
  86. import RoomTypeVue from '../tableCharts/roomType.vue'
  87. import Time from '../tableCharts/time.vue'
  88. import FeeItemsVue from '../tableCharts/feeItems.vue'
  89. import SourceVue from '../tableCharts/source.vue'
  90. import CustomerTypeVue from '../tableCharts/customerType.vue'
  91. import OccupancyTypeVue from '../tableCharts/occupancyType.vue'
  92. import {
  93. getDataList,
  94. getShouKuanList,
  95. getFangXingList,
  96. getFeiXiangList,
  97. getLaiYuanList,
  98. getKeXingList,
  99. getRuZhuList
  100. } from '../../utils/businessAnalysisApi'
  101. import {
  102. getHotelList,
  103. getRevPAR,
  104. getTodayIncome,
  105. getTodayTotalIncome,
  106. getStaySource,
  107. getRoomStatus,
  108. getIncomeAndExpenditure
  109. } from '../../utils/api.js';
  110. export default {
  111. components: {
  112. Header,
  113. Time,
  114. PayMethodsVue,
  115. RoomTypeVue,
  116. FeeItemsVue,
  117. SourceVue,
  118. CustomerTypeVue,
  119. OccupancyTypeVue
  120. },
  121. data() {
  122. return {
  123. list: ['收入统计', '支出统计'],
  124. listWay: ['按时间', '按收款方式', '按房型', '按费项', '按来源', '按客型', '按入住类型'],
  125. payMethodsList: ['查看营业额', '查看实收'],
  126. current: 0,
  127. currentWay: 0,
  128. currentPayMethods: 0,
  129. rangeTime: [{
  130. value: 1,
  131. text: "按日"
  132. },
  133. {
  134. value: 2,
  135. text: "按月"
  136. },
  137. {
  138. value: 3,
  139. text: "按季度"
  140. },
  141. {
  142. value: 4,
  143. text: "按年"
  144. },
  145. ],
  146. rangeDay: [{
  147. value: 0,
  148. text: "按营业日"
  149. },
  150. {
  151. value: 1,
  152. text: "按自然日"
  153. }
  154. ],
  155. timeCheck: 1,
  156. dayCheck: 0,
  157. startTime: (new Date().toLocaleDateString()).replace(/\//g, '-'),
  158. endTime: (new Date(new Date().getTime() + 24 * 60 * 60 * 1000).toLocaleDateString()).replace(/\//g, '-'),
  159. show: false,
  160. tableData: [], //表格数据
  161. todayTotalIncome: 0, //今日总收款
  162. roomData: {
  163. //房间总数
  164. allRoomData: 0,
  165. //入住总数
  166. checkInRoomData: 0,
  167. //平均房价
  168. housingPrices: 0,
  169. // 今日预离
  170. todayLeaveRoomData: 0,
  171. //今日预抵
  172. todayArriveRoomData: 0,
  173. //今日欠费
  174. todayArrearsRoomData: 0,
  175. //脏房
  176. dirtyRoomData: 0,
  177. },
  178. todayIncome:[],
  179. }
  180. },
  181. onLoad(options) {
  182. console.log(options.current);
  183. if (options.current) {
  184. this.currentWay = options.current
  185. }
  186. },
  187. mounted() {
  188. this.getData()
  189. },
  190. methods: {
  191. topChange(e) {
  192. this.current = e
  193. },
  194. changeTime(e) {
  195. console.log(e);
  196. this.timeCheck = e
  197. this.getData()
  198. },
  199. changeDay(e) {
  200. this.dayCheck = e
  201. },
  202. /**
  203. * 日期选择确认
  204. */
  205. confirm(e) {
  206. this.show = false
  207. this.timeList = e
  208. this.startTime = e[0].replace(/\//g, '-')
  209. this.endTime = e[e.length - 1].replace(/\//g, '-')
  210. },
  211. /**
  212. * 日期选择取消
  213. */
  214. close() {
  215. this.show = false
  216. },
  217. WayChange(e) {
  218. this.currentWay = e
  219. this.tableData = []
  220. this.getData()
  221. },
  222. PayChange(e) {
  223. this.currentPayMethods = e
  224. },
  225. getData(all = false) {
  226. // console.log(this.startTime);
  227. this.startTime = this.startTime.replace(/\//g, '-')
  228. this.endTime = this.endTime.replace(/\//g, '-')
  229. getTodayTotalIncome({
  230. startTime: this.startTime,
  231. endTime: this.endTime
  232. }).then(res => {
  233. console.log(res);
  234. if (res.code == 200 && res.result.records.length > 0) {
  235. let brr = []
  236. let data = res.result.records
  237. data.forEach(item => {
  238. let arr = []
  239. arr = Object.keys(item).filter(items => items != 'department' && items != 'hotel_name')
  240. brr = Object.keys(item).filter(items => items == '现金' || items == '微信' || items == '支付宝')
  241. console.log(arr);
  242. arr.forEach(ele => {
  243. this.todayTotalIncome += item[ele] * 1
  244. })
  245. })
  246. let obj = {}
  247. let copy = []
  248. brr.forEach((item, i) => {
  249. console.log(obj);
  250. copy.push({
  251. name: item,
  252. amount: data.reduce((pre, cur) => {
  253. return pre + cur[item]
  254. }, 0)
  255. })
  256. })
  257. // this.paymentMethod = copy
  258. // console.log('2222222222', copy);
  259. // console.log(this.todayTotalIncome);
  260. } else {
  261. this.todayTotalIncome = 0
  262. }
  263. })
  264. // 房间数据统计
  265. getRevPAR({
  266. startTime: this.startTime,
  267. endTime: this.endTime
  268. }).then(res => {
  269. if (res.code == 200 && res.result.length > 0) {
  270. this.roomData.allRoomData = res.result[0]
  271. this.roomData.checkInRoomData = res.result[1]
  272. this.roomData.housingPrices = res.result[2]
  273. this.roomData.todayLeaveRoomData = res.result[3]
  274. this.roomData.todayArriveRoomData = res.result[4]
  275. this.roomData.todayArrearsRoomData = res.result[5]
  276. this.roomData.dirtyRoomData = res.result[6]
  277. }
  278. })
  279. //今日收入统计
  280. getTodayIncome({
  281. startTime: this.startTime,
  282. endTime: this.endTime
  283. }).then(res => {
  284. if (res.code == 200 && res.result.length > 0) {
  285. console.log(res.result);
  286. this.todayIncome = res.result
  287. } else {
  288. this.todayIncome = [{
  289. name: '押金',
  290. amount: 0
  291. },
  292. {
  293. name: '房费',
  294. amount: 0
  295. },
  296. {
  297. name: '商品',
  298. amount: 0
  299. }
  300. ]
  301. }
  302. })
  303. if (this.currentWay == 0 || all) {
  304. getDataList(this.startTime, this.endTime, this.timeCheck).then(res => {
  305. console.log(res);
  306. if (res.code == 200 && res.result) {
  307. this.tableData = res.result
  308. } else {
  309. this.tableData = []
  310. }
  311. })
  312. }
  313. if (this.currentWay == 1 || all) {
  314. getShouKuanList(this.startTime, this.endTime).then(res => {
  315. console.log(res);
  316. if (res.code == 200 && res.result) {
  317. this.tableData = res.result
  318. }
  319. })
  320. }
  321. if (this.currentWay == 2 || all) {
  322. getFangXingList(this.startTime, this.endTime).then(res => {
  323. console.log(res);
  324. if (res.code == 200 && res.result) {
  325. this.tableData = res.result
  326. }
  327. })
  328. }
  329. if (this.currentWay == 3 || all) {
  330. getFeiXiangList(this.startTime, this.endTime).then(res => {
  331. console.log(res);
  332. if (res.code == 200 && res.result) {
  333. this.tableData = res.result
  334. }
  335. })
  336. }
  337. if (this.currentWay == 4 || all) {
  338. getLaiYuanList(this.startTime, this.endTime).then(res => {
  339. console.log(res);
  340. if (res.code == 200 && res.result) {
  341. this.tableData = res.result
  342. }
  343. })
  344. }
  345. if (this.currentWay == 5 || all) {
  346. getKeXingList(this.startTime, this.endTime).then(res => {
  347. console.log(res);
  348. if (res.code == 200 && res.result) {
  349. this.tableData = res.result
  350. }
  351. })
  352. }
  353. if (this.currentWay == 6 || all) {
  354. getRuZhuList(this.startTime, this.endTime).then(res => {
  355. console.log(res);
  356. if (res.code == 200 && res.result) {
  357. this.tableData = res.result
  358. }
  359. })
  360. }
  361. },
  362. headerChange() {
  363. this.getData()
  364. }
  365. }
  366. }
  367. </script>
  368. <style lang="scss" scoped>
  369. .pages {
  370. width: 100vw;
  371. height: 100vh;
  372. background-color: #f5f5f5;
  373. }
  374. .calendar {
  375. border: 1px solid;
  376. padding: 5px 10px;
  377. border-radius: 5px;
  378. color: #409EFF;
  379. font-size: 12px;
  380. // min-width: 30%;
  381. margin-left: 10px;
  382. display: flex;
  383. align-items: center;
  384. }
  385. .content-detail {
  386. background: #409EFF;
  387. padding: 10px;
  388. display: flex;
  389. flex-direction: column;
  390. box-shadow: 0 0 10px #000;
  391. color: #fff;
  392. height: 130px;
  393. justify-content: space-between;
  394. .content-detail-top {
  395. display: flex;
  396. justify-content: space-between;
  397. margin-bottom: 10px;
  398. div {
  399. display: flex;
  400. flex-direction: column;
  401. justify-content: center;
  402. align-items: center;
  403. flex: 1;
  404. }
  405. }
  406. .content-detail-bottom {
  407. display: flex;
  408. justify-content: space-between;
  409. div {
  410. display: flex;
  411. flex-direction: column;
  412. justify-content: center;
  413. align-items: center;
  414. flex: 1;
  415. font-size: 16px;
  416. }
  417. }
  418. }
  419. </style>