feat:更新账单搜索模块
This commit is contained in:
@@ -1,7 +1,7 @@
|
|||||||
<template>
|
<template>
|
||||||
<div class="common-query">
|
<div class="common-query">
|
||||||
<el-select v-model="billStore.billQueryForm.billBook"
|
<el-select v-model="billStore.billQueryForm.billBook"
|
||||||
@change="billStore.refreshInfo()" style="width: 120px">
|
@change="billStore.refreshInfo(isStats)" style="width: 120px">
|
||||||
<el-option
|
<el-option
|
||||||
v-for="(item, index) in billQuery.billBookList"
|
v-for="(item, index) in billQuery.billBookList"
|
||||||
:key="index" :label="item.label" :value="item.name"
|
:key="index" :label="item.label" :value="item.name"
|
||||||
@@ -9,7 +9,7 @@
|
|||||||
</el-select>
|
</el-select>
|
||||||
|
|
||||||
<el-select v-model="billStore.billDateType"
|
<el-select v-model="billStore.billDateType"
|
||||||
@change="billStore.refreshInfo()"
|
@change="billStore.refreshInfo(isStats)"
|
||||||
style="width: 120px;align-self: center;">
|
style="width: 120px;align-self: center;">
|
||||||
<el-option v-for="(item, index) in dateTypeOptions" :key="index"
|
<el-option v-for="(item, index) in dateTypeOptions" :key="index"
|
||||||
:label="item.label" :value="item.value"/>
|
:label="item.label" :value="item.value"/>
|
||||||
@@ -20,23 +20,25 @@
|
|||||||
inline-prompt
|
inline-prompt
|
||||||
active-value="income" inactive-value="expensive"
|
active-value="income" inactive-value="expensive"
|
||||||
active-text="收入账单" inactive-text="支出账单"
|
active-text="收入账单" inactive-text="支出账单"
|
||||||
@change="billStore.refreshInfo()"
|
@change="billStore.refreshInfo(isStats)"
|
||||||
style="--el-switch-on-color: #6FBB69; --el-switch-off-color: #CA6C65;"
|
style="--el-switch-on-color: #6FBB69; --el-switch-off-color: #CA6C65;"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { onMounted, reactive } from 'vue'
|
import { computed, onMounted, reactive } from 'vue'
|
||||||
import { useBillStore } from '@/store/bill.ts'
|
import { useBillStore } from '@/store/bill.ts'
|
||||||
import { deepCopyObject } from 'vue3-common/utils/dataUtil'
|
import { deepCopyObject } from 'vue3-common/utils/dataUtil'
|
||||||
import { IBillBook } from '@/types/bill.ts'
|
import { IBillBook } from '@/types/bill.ts'
|
||||||
|
import { useRoute } from 'vue-router'
|
||||||
|
|
||||||
const billStore = useBillStore()
|
const billStore = useBillStore()
|
||||||
|
const route = useRoute()
|
||||||
|
|
||||||
|
const isStats = computed(() => route.path.includes('chart'))
|
||||||
|
|
||||||
onMounted(async () => {
|
onMounted(async () => {
|
||||||
await billStore.initBillInfo()
|
|
||||||
|
|
||||||
billQuery.billBookList = deepCopyObject(billStore.billBookList)
|
billQuery.billBookList = deepCopyObject(billStore.billBookList)
|
||||||
billQuery.billBookList.push({
|
billQuery.billBookList.push({
|
||||||
color: '',
|
color: '',
|
||||||
|
|||||||
38
src/components/Bill/BillSearch.vue
Normal file
38
src/components/Bill/BillSearch.vue
Normal file
@@ -0,0 +1,38 @@
|
|||||||
|
<template>
|
||||||
|
<div class="common-query">
|
||||||
|
<el-form :model="billStore.billSearchForm">
|
||||||
|
<el-form-item label="账单内容">
|
||||||
|
<el-input v-model="billStore.billSearchForm.content"
|
||||||
|
@input="billStore.searchInfo()"
|
||||||
|
placeholder="请输入账单内容" clearable/>
|
||||||
|
</el-form-item>
|
||||||
|
|
||||||
|
<el-form-item label="账单类别">
|
||||||
|
<el-input v-model="billStore.billSearchForm.category"
|
||||||
|
@input="billStore.searchInfo()"
|
||||||
|
placeholder="请输入账单类别" clearable/>
|
||||||
|
</el-form-item>
|
||||||
|
|
||||||
|
<el-form-item label="账单地址">
|
||||||
|
<el-input v-model="billStore.billSearchForm.location"
|
||||||
|
@input="billStore.searchInfo()"
|
||||||
|
placeholder="请输入账单地址" clearable/>
|
||||||
|
</el-form-item>
|
||||||
|
</el-form>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script lang="ts" setup>
|
||||||
|
import { onMounted } from 'vue'
|
||||||
|
import { useBillStore } from '@/store/bill.ts'
|
||||||
|
|
||||||
|
const billStore = useBillStore()
|
||||||
|
|
||||||
|
onMounted(async () => {
|
||||||
|
await billStore.searchInfo()
|
||||||
|
})
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style lang="scss">
|
||||||
|
@use "@/styles/home/bill.mobile.module";
|
||||||
|
</style>
|
||||||
@@ -130,15 +130,21 @@ export const useBillStore = defineStore('bill', {
|
|||||||
await this.refreshInfo()
|
await this.refreshInfo()
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
async refreshInfo() {
|
getBillDateList() {
|
||||||
this.isLoading = true
|
|
||||||
const bookName = this.billQueryForm.billBook === 'all' ? '' : this.billQueryForm.billBook
|
|
||||||
const { billYear, billMonth } = this.billQueryForm
|
const { billYear, billMonth } = this.billQueryForm
|
||||||
const date = this.billDateType === 'year' ? billYear : billMonth
|
const date = this.billDateType === 'year' ? billYear : billMonth
|
||||||
this.billDateList = getStartEndDate(date, this.billDateType)
|
this.billDateList = getStartEndDate(date, this.billDateType)
|
||||||
|
},
|
||||||
|
async refreshInfo(isStats = false) {
|
||||||
|
this.isLoading = true
|
||||||
|
const bookName = this.billQueryForm.billBook === 'all' ? '' : this.billQueryForm.billBook
|
||||||
|
this.getBillDateList()
|
||||||
|
|
||||||
await this.queryBillSummary(bookName)
|
if (isStats) {
|
||||||
await this.queryBillStats(bookName)
|
await this.queryBillStats(bookName)
|
||||||
|
} else {
|
||||||
|
await this.queryBillSummary(bookName)
|
||||||
|
}
|
||||||
this.isRefresh = !this.isRefresh
|
this.isRefresh = !this.isRefresh
|
||||||
this.isLoading = false
|
this.isLoading = false
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -32,5 +32,12 @@
|
|||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
gap: 10px;
|
gap: 10px;
|
||||||
|
|
||||||
|
.search-result-title {
|
||||||
|
align-self: flex-end;
|
||||||
|
|
||||||
|
display: flex;
|
||||||
|
gap: 10px;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -113,3 +113,9 @@ export const getRateColor = (rate: number) => {
|
|||||||
return '#CD4F39'
|
return '#CD4F39'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export const getTotalAmount = (billRecordList: IBillRecord[], type: IBillType) => {
|
||||||
|
return billRecordList
|
||||||
|
.filter((record) => record.type === type)
|
||||||
|
.reduce((total, record) => total + record.amount, 0)
|
||||||
|
}
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ import { useBillStore } from '@/store/bill.ts'
|
|||||||
const billStore = useBillStore()
|
const billStore = useBillStore()
|
||||||
|
|
||||||
onMounted(async () => {
|
onMounted(async () => {
|
||||||
await billStore.refreshInfo()
|
await billStore.refreshInfo(true)
|
||||||
})
|
})
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|||||||
@@ -37,6 +37,7 @@ onMounted(async () => {
|
|||||||
|
|
||||||
billStore.billType = 'expensive'
|
billStore.billType = 'expensive'
|
||||||
billStore.billDateType = 'month'
|
billStore.billDateType = 'month'
|
||||||
|
|
||||||
await billStore.refreshInfo()
|
await billStore.refreshInfo()
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|||||||
@@ -129,7 +129,6 @@ const billInfo = reactive({
|
|||||||
onMounted(async () => {
|
onMounted(async () => {
|
||||||
appStore.isShowMobileBack = true
|
appStore.isShowMobileBack = true
|
||||||
|
|
||||||
await billStore.initBillInfo()
|
|
||||||
await initBillRecord()
|
await initBillRecord()
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|||||||
@@ -1,32 +1,16 @@
|
|||||||
<template>
|
<template>
|
||||||
<div class="mobile-bill-view common-mobile-view">
|
<div class="mobile-bill-view common-mobile-view">
|
||||||
<div class="common-query">
|
<bill-search />
|
||||||
<el-form :model="billStore.billSearchForm">
|
|
||||||
<el-form-item label="账单内容">
|
|
||||||
<el-input v-model="billStore.billSearchForm.content"
|
|
||||||
@input="billStore.searchInfo()"
|
|
||||||
placeholder="请输入账单内容" clearable/>
|
|
||||||
</el-form-item>
|
|
||||||
|
|
||||||
<el-form-item label="账单类别">
|
|
||||||
<el-input v-model="billStore.billSearchForm.category"
|
|
||||||
@input="billStore.searchInfo()"
|
|
||||||
placeholder="请输入账单类别" clearable/>
|
|
||||||
</el-form-item>
|
|
||||||
|
|
||||||
<el-form-item label="账单地址">
|
|
||||||
<el-input v-model="billStore.billSearchForm.location"
|
|
||||||
@input="billStore.searchInfo()"
|
|
||||||
placeholder="请输入账单地址" clearable/>
|
|
||||||
</el-form-item>
|
|
||||||
</el-form>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div v-if="billStore.billRecordList.length === 0">
|
<div v-if="billStore.billRecordList.length === 0">
|
||||||
<el-empty description="暂无数据"/>
|
<el-empty description="暂无数据"/>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div v-else class="bill-search-list card-item">
|
<div v-else class="bill-search-list card-item">
|
||||||
|
<div class="search-result-title">
|
||||||
|
<span>收入:{{ formatAmount(getTotalAmount(billStore.billRecordList, 'income')) }}</span>
|
||||||
|
<span>支出:{{ formatAmount(getTotalAmount(billStore.billRecordList, 'expensive')) }}</span>
|
||||||
|
</div>
|
||||||
<daily-card v-for="(item, index) in billStore.billRecordList"
|
<daily-card v-for="(item, index) in billStore.billRecordList"
|
||||||
:key="index" @click="selectBillRecordClick(item)"
|
:key="index" @click="selectBillRecordClick(item)"
|
||||||
:title="item.category" :content="item.content">
|
:title="item.category" :content="item.content">
|
||||||
@@ -53,10 +37,11 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
|
import BillSearch from '@/components/Bill/BillSearch.vue'
|
||||||
import DailyCard from '@/components/DailyCard.vue'
|
import DailyCard from '@/components/DailyCard.vue'
|
||||||
import { onMounted } from 'vue'
|
import { onMounted } from 'vue'
|
||||||
import { useBillStore } from '@/store/bill.ts'
|
import { useBillStore } from '@/store/bill.ts'
|
||||||
import { getCategoryByName } from '@/utils/home/billUtil'
|
import { getCategoryByName, getTotalAmount } from '@/utils/home/billUtil'
|
||||||
import { formatAmount } from 'vue3-common/utils/numberUtil'
|
import { formatAmount } from 'vue3-common/utils/numberUtil'
|
||||||
import { IBillRecord } from '@/types/bill'
|
import { IBillRecord } from '@/types/bill'
|
||||||
import { useRouter } from 'vue-router'
|
import { useRouter } from 'vue-router'
|
||||||
|
|||||||
@@ -13,12 +13,6 @@
|
|||||||
|
|
||||||
<weather-time-card />
|
<weather-time-card />
|
||||||
|
|
||||||
<!-- <el-carousel height="150px">-->
|
|
||||||
<!-- <el-carousel-item v-for="item in 4" :key="item">-->
|
|
||||||
<!-- <h3>{{ item }}</h3>-->
|
|
||||||
<!-- </el-carousel-item>-->
|
|
||||||
<!-- </el-carousel>-->
|
|
||||||
|
|
||||||
<div class="module-list">
|
<div class="module-list">
|
||||||
<module-card icon="iconfont icon-fenlei" color="#00CED1"
|
<module-card icon="iconfont icon-fenlei" color="#00CED1"
|
||||||
title="博客文章" sub-title="分享学习点滴"
|
title="博客文章" sub-title="分享学习点滴"
|
||||||
@@ -26,7 +20,7 @@
|
|||||||
|
|
||||||
<module-card icon="iconfont icon-zhangdan" color="#FFCC00"
|
<module-card icon="iconfont icon-zhangdan" color="#FFCC00"
|
||||||
title="账单记录" sub-title="收支一目了然"
|
title="账单记录" sub-title="收支一目了然"
|
||||||
router="/bill/data"/>
|
router="/bill/data" @click="initBillClick"/>
|
||||||
|
|
||||||
<module-card icon="iconfont icon-jingdian" color="#FF9966"
|
<module-card icon="iconfont icon-jingdian" color="#FF9966"
|
||||||
title="旅行记录" sub-title="足迹遍及四方"
|
title="旅行记录" sub-title="足迹遍及四方"
|
||||||
@@ -72,17 +66,6 @@
|
|||||||
title="密码管家" sub-title="守护数字安全"
|
title="密码管家" sub-title="守护数字安全"
|
||||||
router="/password/list"/>
|
router="/password/list"/>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- <div class="note-container">-->
|
|
||||||
<!-- <div class="content">-->
|
|
||||||
<!-- <span class="title">消息中心</span>-->
|
|
||||||
<!-- </div>-->
|
|
||||||
<!-- <div class="note-list">-->
|
|
||||||
<!-- <div class="note">-->
|
|
||||||
|
|
||||||
<!-- </div>-->
|
|
||||||
<!-- </div>-->
|
|
||||||
<!-- </div>-->
|
|
||||||
</main>
|
</main>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
@@ -90,9 +73,15 @@
|
|||||||
import WeatherTimeCard from '@/components/Common/WeatherTimeCard.vue'
|
import WeatherTimeCard from '@/components/Common/WeatherTimeCard.vue'
|
||||||
import ModuleCard from '@/components/ModuleCard.vue'
|
import ModuleCard from '@/components/ModuleCard.vue'
|
||||||
import { useAppStore } from '@/store/app'
|
import { useAppStore } from '@/store/app'
|
||||||
|
import { useBillStore } from '@/store/bill.ts'
|
||||||
import { getAssetsImageFile } from '@/utils'
|
import { getAssetsImageFile } from '@/utils'
|
||||||
|
|
||||||
const appStore = useAppStore()
|
const appStore = useAppStore()
|
||||||
|
const billStore = useBillStore()
|
||||||
|
|
||||||
|
const initBillClick = async () => {
|
||||||
|
await billStore.initBillInfo()
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style lang="scss">
|
<style lang="scss">
|
||||||
|
|||||||
Reference in New Issue
Block a user