feat: 添加交易时间选择框,支持手动选择交易日期
This commit is contained in:
parent
22db4e461e
commit
fa45406d8d
@ -214,6 +214,16 @@
|
|||||||
</picker>
|
</picker>
|
||||||
</view>
|
</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">
|
<view class="form-item">
|
||||||
<text class="form-label">备注</text>
|
<text class="form-label">备注</text>
|
||||||
<input
|
<input
|
||||||
@ -264,11 +274,21 @@ const logs = ref([]);
|
|||||||
// 交易表单
|
// 交易表单
|
||||||
const showTransactionForm = ref(false);
|
const showTransactionForm = ref(false);
|
||||||
const transactionType = ref('buy'); // buy 或 sell
|
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({
|
const transactionForm = ref({
|
||||||
stockCode: '',
|
stockCode: '',
|
||||||
amount: '',
|
amount: '',
|
||||||
price: '',
|
price: '',
|
||||||
currency: 'CNY',
|
currency: 'CNY',
|
||||||
|
transactionDate: getCurrentDate(),
|
||||||
remark: ''
|
remark: ''
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -285,6 +305,10 @@ const onCurrencyChange = (e) => {
|
|||||||
transactionForm.value.currency = currencyList.value[currencyIndex.value].code;
|
transactionForm.value.currency = currencyList.value[currencyIndex.value].code;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const onDateChange = (e) => {
|
||||||
|
transactionForm.value.transactionDate = e.detail.value;
|
||||||
|
};
|
||||||
|
|
||||||
// 股票搜索相关
|
// 股票搜索相关
|
||||||
const searchResults = ref([]);
|
const searchResults = ref([]);
|
||||||
const searchTimer = ref(null);
|
const searchTimer = ref(null);
|
||||||
@ -398,6 +422,7 @@ const resetTransactionForm = () => {
|
|||||||
amount: '',
|
amount: '',
|
||||||
price: '',
|
price: '',
|
||||||
currency: 'CNY',
|
currency: 'CNY',
|
||||||
|
transactionDate: getCurrentDate(),
|
||||||
remark: ''
|
remark: ''
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
@ -421,6 +446,7 @@ const submitTransaction = async () => {
|
|||||||
amount: parseFloat(transactionForm.value.amount),
|
amount: parseFloat(transactionForm.value.amount),
|
||||||
price: parseFloat(transactionForm.value.price),
|
price: parseFloat(transactionForm.value.price),
|
||||||
currency: transactionForm.value.currency,
|
currency: transactionForm.value.currency,
|
||||||
|
transactionDate: transactionForm.value.transactionDate,
|
||||||
remark: transactionForm.value.remark
|
remark: transactionForm.value.remark
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user