u
This commit is contained in:
1 parent
1934225c53
commit
e51f4948d4
10 files changed
+89
-66
No files matched your search
@@ -49,6 +49,12 @@ export default function CreateCategory({
|
||||
|
||||
useEffect(() => {
|
||||
setIsOpen(open)
|
||||
if (!open) {
|
||||
setForm({
|
||||
icon: '',
|
||||
name: '',
|
||||
})
|
||||
}
|
||||
}, [open])
|
||||
|
||||
useEffect(() => {
|
||||
@@ -67,13 +73,12 @@ export default function CreateCategory({
|
||||
}, [category])
|
||||
|
||||
function handleClose() {
|
||||
setIsOpen(false)
|
||||
onClose && onClose()
|
||||
|
||||
setForm({
|
||||
icon: '',
|
||||
name: '',
|
||||
})
|
||||
setIsOpen(false)
|
||||
onClose && onClose()
|
||||
}
|
||||
|
||||
return (
|
||||
|
||||
@@ -99,6 +99,8 @@ export default function MoneyCategorySetting() {
|
||||
sort_number: 0,
|
||||
type: selectedTab,
|
||||
})
|
||||
|
||||
scrollableRef.current?.scrollToEnd({ animated: true })
|
||||
}
|
||||
|
||||
setshowEditCategory(false)
|
||||
|
||||
@@ -4,14 +4,18 @@ import { Text, View } from 'react-native'
|
||||
import { AButton, ACell, ACellGroup, AModal } from '@/components/common/ao'
|
||||
import MoneyCategoryIcon from '@/components/common/MoneyCategoryIcon'
|
||||
import CustomHeader from '@/components/custom/Header'
|
||||
import { useMoneyCategoryStore } from '@/store/moneyCategory'
|
||||
import { useMoneyRecordStore } from '@/store/moneyRecord'
|
||||
import { useUserStore } from '@/store/user'
|
||||
import { MoneyCategoryEnum } from '@/types/money/category'
|
||||
import { toDateString, toDateTimeString } from '@/utils/time'
|
||||
|
||||
export default function MoneyRecordDetail() {
|
||||
const router = useRouter()
|
||||
const moneyRecordStore = useMoneyRecordStore()
|
||||
const moneyCategoryStore = useMoneyCategoryStore()
|
||||
const userStore = useUserStore()
|
||||
|
||||
const { id: detailId } = useLocalSearchParams<{ id: string }>()
|
||||
|
||||
const moneryRecord = moneyRecordStore.getMoneyRecordById(Number(detailId))
|
||||
@@ -22,18 +26,20 @@ export default function MoneyRecordDetail() {
|
||||
return null
|
||||
}
|
||||
|
||||
const moneyCategory = moneyCategoryStore.getCategoryById(moneryRecord.category_id)
|
||||
|
||||
return (
|
||||
<>
|
||||
<View className="flex-1">
|
||||
<CustomHeader title="账单详情" />
|
||||
<View className="flex-1">
|
||||
<View className="flex flex-col items-center">
|
||||
<MoneyCategoryIcon name={moneryRecord.category_icon} size={56} />
|
||||
<Text className="mt-1">{moneryRecord.category_name}</Text>
|
||||
<MoneyCategoryIcon name={moneyCategory?.icon} size={56} />
|
||||
<Text className="mt-1">{moneyCategory?.name}</Text>
|
||||
</View>
|
||||
|
||||
<ACellGroup showDivider={false} className="mt-4">
|
||||
<ACell title="类别" rightText={moneryRecord.category_type === 0 ? '支出' : '收入'} />
|
||||
<ACell title="类别" rightText={moneyCategory?.type === MoneyCategoryEnum.Expense ? '支出' : '收入'} />
|
||||
<ACell title="金额" rightText={moneryRecord.amount} />
|
||||
<ACell title="备注" rightText={moneryRecord.remark} />
|
||||
<ACell title="日期" rightText={toDateString(moneryRecord.record_time)} />
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import type { MoneyCategoryItem } from '@/types/money/category'
|
||||
import type { MoneyRecordBase, MoneyRecordItem } from '@/types/money/record'
|
||||
import type { MoneyRecord } from '@/types/money/record'
|
||||
import { useLocalSearchParams, useRouter } from 'expo-router'
|
||||
import { useEffect, useState } from 'react'
|
||||
import { Text, TouchableOpacity, View } from 'react-native'
|
||||
@@ -28,21 +28,19 @@ export default function MoenyRecordEditor() {
|
||||
// 选中分类
|
||||
const [selectedCategory, setSelectedCategory] = useState<MoneyCategoryItem | null>(null)
|
||||
// 记账记录
|
||||
const defaultMoneyRecord: MoneyRecordBase = {
|
||||
const defaultMoneyRecord: MoneyRecord = {
|
||||
id: -1,
|
||||
category_id: -1,
|
||||
username: '',
|
||||
category_icon: '',
|
||||
category_name: '',
|
||||
category_type: 0,
|
||||
user_id: -1,
|
||||
amount: '0.00',
|
||||
remark: '',
|
||||
record_time: getCurrentDate(),
|
||||
create_time: '',
|
||||
create_time: 0,
|
||||
update_time: 0,
|
||||
}
|
||||
|
||||
const [moneyRecord, setMoneyRecord] = useState<MoneyRecordBase>(defaultMoneyRecord)
|
||||
const [moneyRecord, setMoneyRecord] = useState<MoneyRecord>(defaultMoneyRecord)
|
||||
|
||||
useEffect(() => {
|
||||
if (updateId) {
|
||||
@@ -90,12 +88,9 @@ export default function MoenyRecordEditor() {
|
||||
record_time: moneyRecord.record_time,
|
||||
}).then((res) => {
|
||||
if (res.isSuccess) {
|
||||
const result: MoneyRecordItem = {
|
||||
const result: MoneyRecord = {
|
||||
...moneyRecord,
|
||||
category_id: selectedCategory.id,
|
||||
category_type: selectedCategory.type,
|
||||
category_name: selectedCategory.name,
|
||||
category_icon: selectedCategory.icon,
|
||||
}
|
||||
|
||||
moneyRecordStore.updateMoneyRecord(result)
|
||||
@@ -115,12 +110,9 @@ export default function MoenyRecordEditor() {
|
||||
})
|
||||
.then((res) => {
|
||||
if (res.isSuccess) {
|
||||
const result: MoneyRecordItem = {
|
||||
const result: MoneyRecord = {
|
||||
...res.data,
|
||||
category_id: selectedCategory.id,
|
||||
category_type: selectedCategory.type,
|
||||
category_name: selectedCategory.name,
|
||||
category_icon: selectedCategory.icon,
|
||||
}
|
||||
|
||||
moneyRecordStore.addMoneyRecord(result)
|
||||
|
||||
Reference in new issue
Block a user