[FIX] 固定費で登録する際、収支区分が自動で入るように修正しました。

This commit is contained in:
s-choi
2026-09-28 16:32:02 +09:00
parent 7aa8e31bfd
commit fd74dee965
3 changed files with 15 additions and 2 deletions

View File

@@ -237,6 +237,8 @@ public class TransactionController {
model.addAttribute(PageReturnAttributeKeyword.INCOME_LIST, incomeList); model.addAttribute(PageReturnAttributeKeyword.INCOME_LIST, incomeList);
model.addAttribute(PageReturnAttributeKeyword.TRANSACTION_FORM, transactionForm); model.addAttribute(PageReturnAttributeKeyword.TRANSACTION_FORM, transactionForm);
session.setAttribute("tType", String.valueOf(transactionForm.getTransactionType()));
model.addAttribute(PageReturnAttributeKeyword.CATEGORY_FORM_LIST, categoryFormList); model.addAttribute(PageReturnAttributeKeyword.CATEGORY_FORM_LIST, categoryFormList);

View File

@@ -83,6 +83,7 @@
<div th:replace="~{footer :: footer}"></div> <div th:replace="~{footer :: footer}"></div>
<script> <script>
const transactionType = document.getElementById("transactionType"); const transactionType = document.getElementById("transactionType");
const categoryId = document.getElementById("categoryId"); const categoryId = document.getElementById("categoryId");
@@ -90,6 +91,7 @@
const expenseList = document.getElementsByClassName("expenseListClass"); const expenseList = document.getElementsByClassName("expenseListClass");
const incomeList = document.getElementsByClassName("incomeListClass"); const incomeList = document.getElementsByClassName("incomeListClass");
transactionType.addEventListener("change", function () { transactionType.addEventListener("change", function () {
if (this.value === "1") { if (this.value === "1") {

View File

@@ -39,7 +39,7 @@
収入・支出 収入・支出
</label> </label>
<select id="transactionType" class="form-select" th:field="*{transactionType}" required> <select id="transactionType" class="form-select" name="transactionType" required>
<option value=""> <option value="">
選択してください 選択してください
@@ -114,13 +114,22 @@
<div th:replace="~{footer :: footer}"></div> <div th:replace="~{footer :: footer}"></div>
<script> <script inline="javascript">
const transactionType = document.getElementById("transactionType"); const transactionType = document.getElementById("transactionType");
const categoryId = document.getElementById("categoryId"); const categoryId = document.getElementById("categoryId");
const expenseList = document.getElementsByClassName("expenseListClass"); const expenseList = document.getElementsByClassName("expenseListClass");
const incomeList = document.getElementsByClassName("incomeListClass"); const incomeList = document.getElementsByClassName("incomeListClass");
const tType = '[[${session.tType}]]';
if (tType == "0") {
transactionType.value = 1;
} else {
transactionType.value = 2;
}
transactionType.addEventListener("change", function () { transactionType.addEventListener("change", function () {
if (this.value === "1") { if (this.value === "1") {