feat: 计划模式(时间段+打卡+计时时钟) / 工作详情范围导出 / 工作与记账分类自定义(含历史迁移)
This commit is contained in:
@@ -7,7 +7,7 @@ import {
|
||||
addTransaction, deleteTransaction, listTransactionsBetween,
|
||||
setTransactionReimbursed, updateTransaction, type Transaction
|
||||
} from '../db/repo'
|
||||
import { EXPENSE_CATEGORIES, INCOME_CATEGORIES } from '../db/schema'
|
||||
import { getLedgerCategories } from '../db/categories'
|
||||
import { addMonths, todayStr } from '../lib/date'
|
||||
import { showToast } from '../lib/toast'
|
||||
|
||||
@@ -20,7 +20,7 @@ const loading = ref(true)
|
||||
// ---- 新增表单 ----
|
||||
const fType = ref<TxType>('expense')
|
||||
const fAmount = ref('')
|
||||
const fCategory = ref(EXPENSE_CATEGORIES[0])
|
||||
const fCategory = ref('')
|
||||
const fDate = ref(todayStr())
|
||||
const fNote = ref('')
|
||||
const fReimb = ref(false)
|
||||
@@ -30,7 +30,7 @@ const submitting = ref(false)
|
||||
|
||||
const dialogOpen = ref(false)
|
||||
const editingId = ref<number | null>(null)
|
||||
const dialogInitial = ref({ type: 'expense', category: EXPENSE_CATEGORIES[0], amountYuan: '', date: todayStr(), note: '', reimbursable: 0, reimbursed: 0 })
|
||||
const dialogInitial = ref({ type: 'expense', category: '', amountYuan: '', date: todayStr(), note: '', reimbursable: 0, reimbursed: 0 })
|
||||
const deleteTarget = ref<Transaction | null>(null)
|
||||
|
||||
const monthStart = computed(() => monthRef.value.slice(0, 7) + '-01')
|
||||
@@ -56,8 +56,17 @@ async function load() {
|
||||
onMounted(load)
|
||||
watch(monthRef, load)
|
||||
|
||||
const expenseCats = ref<string[]>([])
|
||||
const incomeCats = ref<string[]>([])
|
||||
async function loadCats() {
|
||||
expenseCats.value = await getLedgerCategories('expense')
|
||||
incomeCats.value = await getLedgerCategories('income')
|
||||
if (fType.value === 'expense' && !expenseCats.value.includes(fCategory.value)) fCategory.value = expenseCats.value[0] || ''
|
||||
if (fType.value === 'income' && !incomeCats.value.includes(fCategory.value)) fCategory.value = incomeCats.value[0] || ''
|
||||
}
|
||||
loadCats()
|
||||
watch(fType, t => {
|
||||
fCategory.value = t === 'expense' ? EXPENSE_CATEGORIES[0] : INCOME_CATEGORIES[0]
|
||||
fCategory.value = t === 'expense' ? (expenseCats.value[0] || '') : (incomeCats.value[0] || '')
|
||||
})
|
||||
|
||||
const sorted = computed(() =>
|
||||
@@ -249,7 +258,7 @@ async function confirmDelete() {
|
||||
<div class="field">
|
||||
<label>分类</label>
|
||||
<select class="select" v-model="fCategory">
|
||||
<option v-for="c in (fType === 'expense' ? EXPENSE_CATEGORIES : INCOME_CATEGORIES)" :key="c" :value="c">{{ c }}</option>
|
||||
<option v-for="c in (fType === 'expense' ? expenseCats : incomeCats)" :key="c" :value="c">{{ c }}</option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="field" v-if="fType === 'expense'">
|
||||
|
||||
Reference in New Issue
Block a user