feat: 添加交易时间选择框,支持手动选择交易日期
This commit is contained in:
parent
22db4e461e
commit
fa45406d8d
@ -214,6 +214,16 @@
|
||||
</picker>
|
||||
</view>
|
||||
|
||||
<view class="form-item">
|
||||
<text class="form-label">交易时间</text>
|
||||
<picker mode="date" @change="onDateChange" :value="transactionForm.transactionDate">
|
||||
<view class="form-select">
|
||||
<text>{{ transactionForm.transactionDate }}</text>
|
||||
<uni-icons type="bottom" size="14" color="#9CA3AF"></uni-icons>
|
||||
</view>
|
||||
</picker>
|
||||
</view>
|
||||
|
||||
<view class="form-item">
|
||||
<text class="form-label">备注</text>
|
||||
<input
|
||||
@ -264,11 +274,21 @@ const logs = ref([]);
|
||||
// 交易表单
|
||||
const showTransactionForm = ref(false);
|
||||
const transactionType = ref('buy'); // buy 或 sell
|
||||
// 获取当前日期格式化为YYYY-MM-DD
|
||||
const getCurrentDate = () => {
|
||||
const now = new Date();
|
||||
const year = now.getFullYear();
|
||||
const month = String(now.getMonth() + 1).padStart(2, '0');
|
||||
const day = String(now.getDate()).padStart(2, '0');
|
||||
return `${year}-${month}-${day}`;
|
||||
};
|
||||
|
||||
const transactionForm = ref({
|
||||
stockCode: '',
|
||||
amount: '',
|
||||
price: '',
|
||||
currency: 'CNY',
|
||||
transactionDate: getCurrentDate(),
|
||||
remark: ''
|
||||
});
|
||||
|
||||
@ -285,6 +305,10 @@ const onCurrencyChange = (e) => {
|
||||
transactionForm.value.currency = currencyList.value[currencyIndex.value].code;
|
||||
};
|
||||
|
||||
const onDateChange = (e) => {
|
||||
transactionForm.value.transactionDate = e.detail.value;
|
||||
};
|
||||
|
||||
// 股票搜索相关
|
||||
const searchResults = ref([]);
|
||||
const searchTimer = ref(null);
|
||||
@ -398,6 +422,7 @@ const resetTransactionForm = () => {
|
||||
amount: '',
|
||||
price: '',
|
||||
currency: 'CNY',
|
||||
transactionDate: getCurrentDate(),
|
||||
remark: ''
|
||||
};
|
||||
};
|
||||
@ -421,6 +446,7 @@ const submitTransaction = async () => {
|
||||
amount: parseFloat(transactionForm.value.amount),
|
||||
price: parseFloat(transactionForm.value.price),
|
||||
currency: transactionForm.value.currency,
|
||||
transactionDate: transactionForm.value.transactionDate,
|
||||
remark: transactionForm.value.remark
|
||||
};
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user