大量的代码格式化
Some checks failed
Docker Build & Deploy / Build Docker Image (push) Failing after 1m10s
Docker Build & Deploy / Deploy to Production (push) Has been skipped
Docker Build & Deploy / Cleanup Dangling Images (push) Successful in 1s
Docker Build & Deploy / WeChat Notification (push) Successful in 1s
Some checks failed
Docker Build & Deploy / Build Docker Image (push) Failing after 1m10s
Docker Build & Deploy / Deploy to Production (push) Has been skipped
Docker Build & Deploy / Cleanup Dangling Images (push) Successful in 1s
Docker Build & Deploy / WeChat Notification (push) Successful in 1s
This commit is contained in:
@@ -6,8 +6,12 @@
|
||||
<van-field label="时间">
|
||||
<template #input>
|
||||
<div style="display: flex; gap: 16px">
|
||||
<div @click="showDatePicker = true">{{ form.date }}</div>
|
||||
<div @click="showTimePicker = true">{{ form.time }}</div>
|
||||
<div @click="showDatePicker = true">
|
||||
{{ form.date }}
|
||||
</div>
|
||||
<div @click="showTimePicker = true">
|
||||
{{ form.time }}
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
</van-field>
|
||||
@@ -37,9 +41,9 @@
|
||||
<van-field name="type" label="类型">
|
||||
<template #input>
|
||||
<van-radio-group v-model="form.type" direction="horizontal" @change="handleTypeChange">
|
||||
<van-radio :name="0">支出</van-radio>
|
||||
<van-radio :name="1">收入</van-radio>
|
||||
<van-radio :name="2">不计</van-radio>
|
||||
<van-radio :name="0"> 支出 </van-radio>
|
||||
<van-radio :name="1"> 收入 </van-radio>
|
||||
<van-radio :name="2"> 不计 </van-radio>
|
||||
</van-radio-group>
|
||||
</template>
|
||||
</van-field>
|
||||
@@ -47,23 +51,20 @@
|
||||
<!-- 分类 -->
|
||||
<van-field name="category" label="分类">
|
||||
<template #input>
|
||||
<span v-if="!categoryName" style="color: var(--van-text-color-3);">请选择分类</span>
|
||||
<span v-if="!categoryName" style="color: var(--van-text-color-3)">请选择分类</span>
|
||||
<span v-else>{{ categoryName }}</span>
|
||||
</template>
|
||||
</van-field>
|
||||
|
||||
|
||||
<!-- 分类选择组件 -->
|
||||
<ClassifySelector
|
||||
v-model="categoryName"
|
||||
:type="form.type"
|
||||
/>
|
||||
<ClassifySelector v-model="categoryName" :type="form.type" />
|
||||
</van-cell-group>
|
||||
|
||||
<div class="actions">
|
||||
<van-button round block type="primary" native-type="submit" :loading="loading">
|
||||
{{ submitText }}
|
||||
</van-button>
|
||||
<slot name="actions"></slot>
|
||||
<slot name="actions" />
|
||||
</div>
|
||||
</van-form>
|
||||
|
||||
@@ -137,7 +138,7 @@ const initForm = async () => {
|
||||
if (props.initialData) {
|
||||
isSyncing.value = true
|
||||
const { occurredAt, amount, reason, type, classify } = props.initialData
|
||||
|
||||
|
||||
if (occurredAt) {
|
||||
const dt = dayjs(occurredAt)
|
||||
form.value.date = dt.format('YYYY-MM-DD')
|
||||
@@ -145,11 +146,17 @@ const initForm = async () => {
|
||||
currentDate.value = form.value.date.split('-')
|
||||
currentTime.value = form.value.time.split(':')
|
||||
}
|
||||
|
||||
if (amount !== undefined) form.value.amount = amount
|
||||
if (reason !== undefined) form.value.note = reason
|
||||
if (type !== undefined) form.value.type = type
|
||||
|
||||
|
||||
if (amount !== undefined) {
|
||||
form.value.amount = amount
|
||||
}
|
||||
if (reason !== undefined) {
|
||||
form.value.note = reason
|
||||
}
|
||||
if (type !== undefined) {
|
||||
form.value.type = type
|
||||
}
|
||||
|
||||
// 如果有传入分类名称,尝试设置
|
||||
if (classify) {
|
||||
categoryName.value = classify
|
||||
@@ -166,9 +173,13 @@ onMounted(() => {
|
||||
})
|
||||
|
||||
// 监听 initialData 变化 (例如重新解析后)
|
||||
watch(() => props.initialData, () => {
|
||||
initForm()
|
||||
}, { deep: true })
|
||||
watch(
|
||||
() => props.initialData,
|
||||
() => {
|
||||
initForm()
|
||||
},
|
||||
{ deep: true }
|
||||
)
|
||||
|
||||
const handleTypeChange = (newType) => {
|
||||
if (!isSyncing.value) {
|
||||
@@ -197,7 +208,7 @@ const handleSubmit = () => {
|
||||
}
|
||||
|
||||
const fullDateTime = `${form.value.date}T${form.value.time}:00`
|
||||
|
||||
|
||||
const payload = {
|
||||
occurredAt: fullDateTime,
|
||||
classify: categoryName.value,
|
||||
@@ -205,7 +216,7 @@ const handleSubmit = () => {
|
||||
reason: form.value.note || '',
|
||||
type: form.value.type
|
||||
}
|
||||
|
||||
|
||||
emit('submit', payload)
|
||||
}
|
||||
|
||||
|
||||
@@ -1,10 +1,6 @@
|
||||
<template>
|
||||
<div class="manual-bill-add">
|
||||
<BillForm
|
||||
ref="billFormRef"
|
||||
:loading="saving"
|
||||
@submit="handleSave"
|
||||
/>
|
||||
<BillForm ref="billFormRef" :loading="saving" @submit="handleSave" />
|
||||
</div>
|
||||
</template>
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<template>
|
||||
<div>
|
||||
<div v-if="!parseResult" class="input-section" style="margin: 12px 12px 0 16px;">
|
||||
<div v-if="!parseResult" class="input-section" style="margin: 12px 12px 0 16px">
|
||||
<van-field
|
||||
v-model="text"
|
||||
type="textarea"
|
||||
@@ -10,11 +10,11 @@
|
||||
:disabled="parsing || saving"
|
||||
/>
|
||||
<div class="actions">
|
||||
<van-button
|
||||
type="primary"
|
||||
round
|
||||
block
|
||||
:loading="parsing"
|
||||
<van-button
|
||||
type="primary"
|
||||
round
|
||||
block
|
||||
:loading="parsing"
|
||||
:disabled="!text.trim()"
|
||||
@click="handleParse"
|
||||
>
|
||||
@@ -31,13 +31,7 @@
|
||||
@submit="handleSave"
|
||||
>
|
||||
<template #actions>
|
||||
<van-button
|
||||
plain
|
||||
round
|
||||
block
|
||||
class="mt-2"
|
||||
@click="parseResult = null"
|
||||
>
|
||||
<van-button plain round block class="mt-2" @click="parseResult = null">
|
||||
重新输入
|
||||
</van-button>
|
||||
</template>
|
||||
@@ -60,17 +54,19 @@ const saving = ref(false)
|
||||
const parseResult = ref(null)
|
||||
|
||||
const handleParse = async () => {
|
||||
if (!text.value.trim()) return
|
||||
|
||||
if (!text.value.trim()) {
|
||||
return
|
||||
}
|
||||
|
||||
parsing.value = true
|
||||
parseResult.value = null
|
||||
|
||||
|
||||
try {
|
||||
const res = await parseOneLine(text.value)
|
||||
if(!res.success){
|
||||
if (!res.success) {
|
||||
throw new Error(res.message || '解析失败')
|
||||
}
|
||||
|
||||
|
||||
parseResult.value = res.data
|
||||
} catch (err) {
|
||||
console.error(err)
|
||||
@@ -84,11 +80,11 @@ const handleSave = async (payload) => {
|
||||
saving.value = true
|
||||
try {
|
||||
const res = await createTransaction(payload)
|
||||
|
||||
|
||||
if (!res.success) {
|
||||
throw new Error(res.message || '保存失败')
|
||||
}
|
||||
|
||||
|
||||
showToast('保存成功')
|
||||
text.value = ''
|
||||
parseResult.value = null
|
||||
|
||||
Reference in New Issue
Block a user