|
@@ -18,7 +18,7 @@
|
|
|
<div>0.00</div>
|
|
|
</div>
|
|
|
<div class="yarn-box">
|
|
|
- <div>99999</div>
|
|
|
+ <div>{{ totalFee }}</div>
|
|
|
</div>
|
|
|
</div>
|
|
|
</div>
|
|
@@ -47,7 +47,7 @@
|
|
|
<script setup>
|
|
|
import { ref, computed, watch, onMounted } from 'vue'
|
|
|
import { register, login } from '@/api/base'
|
|
|
-import { getBookInfo } from '@/api/api'
|
|
|
+import { getBookInfo, getAllRecordyMonth } from '@/api/api'
|
|
|
import dayjs from 'dayjs'
|
|
|
import RecordInRow from '@/components/RecordInRow.vue'
|
|
|
|
|
@@ -59,7 +59,7 @@ const currentDate = ref([])
|
|
|
const currentDateAfter = ref([])
|
|
|
|
|
|
const time_record_list = ref([])
|
|
|
-
|
|
|
+const totalFee = ref(0)
|
|
|
const selectTime = () => {
|
|
|
if (!currentDate.value.length) {
|
|
|
const timeStr = dayjs().format('YYYY,MM')
|
|
@@ -77,6 +77,7 @@ const cancelSelectTime = () => {
|
|
|
const confirmSelectTime = ({ selectedValues }) => {
|
|
|
currentDate.value = selectedValues
|
|
|
cancelSelectTime()
|
|
|
+ pageInit()
|
|
|
}
|
|
|
|
|
|
const yearStr = computed(() => {
|
|
@@ -107,19 +108,40 @@ onMounted(() => {
|
|
|
commonStore.initBook()
|
|
|
// getBookInfoFn()
|
|
|
// getLogin()
|
|
|
+ pageInit()
|
|
|
+})
|
|
|
|
|
|
- for (let index = 0; index < 40; index++) {
|
|
|
- const elm = {
|
|
|
- name: 'name' + index,
|
|
|
- record_list: []
|
|
|
- }
|
|
|
- for (let j = 0; j < 10; j++) {
|
|
|
- elm.record_list.push({})
|
|
|
+// 分组函数
|
|
|
+const groupByTime = (data) => {
|
|
|
+ return data.reduce((acc, item) => {
|
|
|
+ const { time } = item
|
|
|
+ if (!acc[time]) {
|
|
|
+ acc[time] = [] // 初始化该分组
|
|
|
}
|
|
|
+ acc[time].push(item) // 将当前项加入对应分组
|
|
|
+ return acc
|
|
|
+ }, {})
|
|
|
+}
|
|
|
|
|
|
- time_record_list.value.push(elm)
|
|
|
- }
|
|
|
-})
|
|
|
+const pageInit = async () => {
|
|
|
+ const res = await getAllRecordyMonth(1, `${yearStr.value}-${monthlyStr.value}`)
|
|
|
+ let _totalFee = 0
|
|
|
+ // 使用分组函数
|
|
|
+ const groupedData = groupByTime(res)
|
|
|
+ const new_time_record_list = []
|
|
|
+ Object.keys(groupedData).forEach((time) => {
|
|
|
+ new_time_record_list.push({
|
|
|
+ time: time,
|
|
|
+ totalFee: groupedData[time].reduce((fee, elm) => {
|
|
|
+ _totalFee += Number(elm.total_fee)
|
|
|
+ return (fee += Number(elm.total_fee))
|
|
|
+ }, 0),
|
|
|
+ record_list: groupedData[time]
|
|
|
+ })
|
|
|
+ })
|
|
|
+ totalFee.value = _totalFee
|
|
|
+ time_record_list.value = new_time_record_list
|
|
|
+}
|
|
|
async function getRegister() {
|
|
|
const res = await register({
|
|
|
account: 'x.czvufulcym@qqxhjl.ee',
|