ZyFeeDetail.vue 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. <template>
  2. <window-size>
  3. <van-cell title="选择日期区间" :value="date" @click="showCalendar = true" />
  4. <van-calendar
  5. v-model:show="showCalendar"
  6. type="range"
  7. :min-date="minDate"
  8. :max-date="maxDate"
  9. @confirm="onConfirmDate"
  10. />
  11. <van-cell title="花费金额">
  12. <template #default>
  13. <span style="color: orangered">¥ {{ totalCost }}</span>
  14. </template>
  15. </van-cell>
  16. <div style="height: 3px"></div>
  17. <div style="background: white; text-align: center; font-size: 12px; padding: 0 10px">
  18. <div style="height: 5px"></div>
  19. <van-row>
  20. <van-col :span="10">项目名称</van-col>
  21. <van-col :span="5">单价</van-col>
  22. <van-col :span="4">数量</van-col>
  23. <van-col :span="5">金额</van-col>
  24. </van-row>
  25. <div style="height: 8px"></div>
  26. <div :style="scrollStyle">
  27. <div v-for="(fee, index) in fees.slice(pageSize * (currentPage - 1), pageSize * currentPage)" :key="index">
  28. <div style="height: 8px"></div>
  29. <van-row>
  30. <van-col :span="10">{{ fee.xmmc }}</van-col>
  31. <van-col :span="5">{{ fee.dj }}</van-col>
  32. <van-col :span="4">{{ fee.sl }}</van-col>
  33. <van-col :span="5">{{ fee.je }}</van-col>
  34. </van-row>
  35. <div style="height: 8px"></div>
  36. </div>
  37. </div>
  38. <div style="position: absolute; bottom: 0; left: 0; right: 0; background: white">
  39. <van-pagination
  40. v-model="currentPage"
  41. :total-items="fees.length"
  42. :items-per-page="pageSize"
  43. force-ellipses
  44. @change="handleCurrentPageChange"
  45. />
  46. </div>
  47. </div>
  48. </window-size>
  49. </template>
  50. <script>
  51. import store from '../../../store'
  52. import { onMounted, ref } from 'vue'
  53. import { useRouter } from 'vue-router'
  54. import { getOneWeekOffset } from '../../../utils/date'
  55. import { getZyFees } from '../../../api/inpatient-service'
  56. export default {
  57. name: 'ZyFeeDetail',
  58. setup() {
  59. const scrollStyle = {
  60. height: store.state.screenSize.h - 208 + 'px',
  61. overflowY: 'scroll',
  62. }
  63. const router = useRouter()
  64. const params = router.currentRoute.value.params
  65. const date = ref('')
  66. const showCalendar = ref(false)
  67. const minDate = new Date(2012, 0, 1)
  68. const maxDate = new Date()
  69. const fees = ref([])
  70. const totalCost = ref('')
  71. const currentPage = ref(1)
  72. const pageSize = ref(30)
  73. const handleCurrentPageChange = (val) => {
  74. currentPage.value = val
  75. }
  76. const onConfirmDate = (val) => {
  77. const [start, end] = val
  78. showCalendar.value = false
  79. date.value = `${formatDate(start)} - ${formatDate(end)}`
  80. params.start = formatDate(start)
  81. params.end = formatDate(end)
  82. getZyFees(params).then((res) => {
  83. fees.value = res.fees
  84. totalCost.value = res.totalCost
  85. })
  86. }
  87. onMounted(() => {
  88. const oneWeekOffset = getOneWeekOffset(params.admissDate)
  89. date.value = oneWeekOffset.start + ' - ' + oneWeekOffset.end
  90. params.start = oneWeekOffset.start
  91. params.end = oneWeekOffset.end
  92. getZyFees(params).then((res) => {
  93. fees.value = res.fees
  94. totalCost.value = res.totalCost
  95. })
  96. })
  97. return {
  98. scrollStyle,
  99. params,
  100. date,
  101. minDate,
  102. maxDate,
  103. showCalendar,
  104. currentPage,
  105. pageSize,
  106. handleCurrentPageChange,
  107. onConfirmDate,
  108. fees,
  109. totalCost,
  110. }
  111. },
  112. }
  113. function formatDate(date) {
  114. return `${date.getFullYear()}-${date.getMonth() + 1}-${date.getDate()}`
  115. }
  116. </script>