社員情報登録時のプルダウンの分割化の相談の参照用の一時プッシュ
This commit is contained in:
@@ -24,6 +24,10 @@ public interface SearchDepartment {
|
||||
List<Department> searchByDepartment(SearchConditionDepartment searchConditionDepartment);
|
||||
|
||||
List<Division> searchByDivision(SearchConditionDepartment searchConditionDepartment);
|
||||
|
||||
List<Department>searchByIdHeadquarters(Integer idHeadquarters);
|
||||
|
||||
List<Division>searchByIdDepartment(Integer idDepartment);
|
||||
|
||||
// List<DepartmentInfo> searchByWithLike(SearchConditionDepartment searchConditionDepartment);
|
||||
}
|
||||
|
||||
@@ -45,26 +45,39 @@ public class RegisterDepartmentImpl implements RegisterDepartment {
|
||||
public void registerDepartment(DivisionEntity divisionEntity) {
|
||||
DepartmentEntity departmentEntity = divisionEntity.getDepartment();
|
||||
HeadquartersEntity headquartersEntity = divisionEntity.getDepartment().getHeadquarters();
|
||||
|
||||
if(departmentEntity.getIdDepartment()==null) {
|
||||
departmentEntity = new DepartmentEntity();
|
||||
}
|
||||
if(headquartersEntity.getIdHeadquarters()==null) {
|
||||
HeadquartersEntity originHeadquartersEntity =
|
||||
headquartersRepository.findByNmHeadquarters(
|
||||
divisionEntity.getDepartment().getHeadquarters().getNmHeadquarters());
|
||||
if(originHeadquartersEntity!=null){
|
||||
headquartersEntity=originHeadquartersEntity;
|
||||
}else {
|
||||
headquartersEntity = new HeadquartersEntity();
|
||||
headquartersEntity.setNmHeadquarters(
|
||||
divisionEntity.getDepartment()
|
||||
.getHeadquarters()
|
||||
.getNmHeadquarters()
|
||||
);
|
||||
}
|
||||
|
||||
DepartmentEntity originDepartmentEntity =
|
||||
departmentRepository.findByHeadquartersAndNmDepartment(
|
||||
headquartersEntity,
|
||||
divisionEntity.getDepartment().getNmDepartment());
|
||||
if(originDepartmentEntity!=null) {
|
||||
departmentEntity=originDepartmentEntity;
|
||||
}else {
|
||||
departmentEntity = new DepartmentEntity();
|
||||
departmentEntity.setNmDepartment(
|
||||
divisionEntity.getDepartment()
|
||||
.getNmDepartment()
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
divisionEntity.setIsDisplay(0);
|
||||
departmentEntity.setIsDisplay(0);
|
||||
headquartersEntity.setIsDisplay(0);
|
||||
|
||||
departmentEntity.setNmDepartment(
|
||||
divisionEntity.getDepartment()
|
||||
.getNmDepartment()
|
||||
);
|
||||
headquartersEntity.setNmHeadquarters(
|
||||
divisionEntity.getDepartment()
|
||||
.getHeadquarters()
|
||||
.getNmHeadquarters()
|
||||
);
|
||||
departmentEntity.setHeadquarters(headquartersEntity);
|
||||
divisionEntity.setDepartment(departmentEntity);
|
||||
divisionRepository.save(divisionEntity);
|
||||
|
||||
@@ -22,6 +22,7 @@ import com.example.rhizome.app.infra.repository.DepartmentInfoRepository;
|
||||
import com.example.rhizome.app.infra.repository.DepartmentRepository;
|
||||
import com.example.rhizome.app.infra.repository.DivisionRepository;
|
||||
import com.example.rhizome.app.infra.repository.HeadquartersRepository;
|
||||
import com.example.rhizome.app.infra.repository.RegisterDepartmentRepository;
|
||||
|
||||
/**
|
||||
* 部署情報検索系の機能を集約させるサービスクラスです。
|
||||
@@ -33,6 +34,7 @@ public class SearchDepartmentImpl implements SearchDepartment {
|
||||
DepartmentRepository departmentRepository;
|
||||
HeadquartersRepository headquartersRepository;
|
||||
DepartmentInfoRepository departmentInfoRepository;
|
||||
RegisterDepartmentRepository registerDepartmentRepository;
|
||||
/**
|
||||
* コンストラクタ
|
||||
*
|
||||
@@ -43,11 +45,13 @@ public class SearchDepartmentImpl implements SearchDepartment {
|
||||
DepartmentRepository departmentRepository
|
||||
,DivisionRepository divisionRepository
|
||||
,HeadquartersRepository headquartersRepository
|
||||
,DepartmentInfoRepository departmentInfoRepository) {
|
||||
,DepartmentInfoRepository departmentInfoRepository
|
||||
,RegisterDepartmentRepository registerDepartmentRepository) {
|
||||
this.departmentRepository = departmentRepository;
|
||||
this.divisionRepository = divisionRepository;
|
||||
this.headquartersRepository = headquartersRepository;
|
||||
this.departmentInfoRepository = departmentInfoRepository;
|
||||
this.registerDepartmentRepository = registerDepartmentRepository;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -126,26 +130,20 @@ public class SearchDepartmentImpl implements SearchDepartment {
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
// /**
|
||||
// * searchConditionDepartment の情報を元に Department のレコードを取得
|
||||
// * 部分一致検索
|
||||
// *
|
||||
// * @param searchConditionDepartment 検索条件
|
||||
// * @return 検索結果のレコード
|
||||
// */
|
||||
// public List<DepartmentInfo> searchByWithLike(SearchConditionDepartment searchConditionDepartment) {
|
||||
// // 動的に検索条件を絞り込む
|
||||
// // Specification は Criteria API の Predicate をラップしたもの
|
||||
// return DepartmentEntity
|
||||
// .createDepartmentList(
|
||||
// departmentRepository.findAll(Specification
|
||||
// .where(DepartmentRepository.idDepartmentEqual(searchConditionDepartment.getIdDepartment()))
|
||||
// .and(DepartmentRepository.nmDepartmentLike(searchConditionDepartment.getNmDepartment()))
|
||||
// )
|
||||
// );
|
||||
//
|
||||
// }
|
||||
public List<Department>searchByIdHeadquarters(Integer idHeadquarters){
|
||||
System.out.println("3");
|
||||
registerDepartmentRepository.findAll(Specification
|
||||
.where(RegisterDepartmentRepository.idHeadquartersEqual(idHeadquarters)));
|
||||
|
||||
System.out.println("SearchDepartmentImpl=>4");
|
||||
|
||||
return DepartmentEntity
|
||||
.createDepartmentListBy(registerDepartmentRepository.findAll(Specification
|
||||
.where(RegisterDepartmentRepository.idHeadquartersEqual(idHeadquarters))));
|
||||
}
|
||||
public List<Division>searchByIdDepartment(Integer idDepartment){
|
||||
return DivisionEntity
|
||||
.createDivisionList(divisionRepository.findAll(Specification
|
||||
.where(DivisionRepository.idDepartmentEqual(idDepartment))));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,8 +6,10 @@ import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import com.example.rhizome.app.domain.model.DepartmentInfo;
|
||||
import com.example.rhizome.app.domain.service.UpdateDepartment;
|
||||
import com.example.rhizome.app.infra.entity.DepartmentInfoEntity;
|
||||
import com.example.rhizome.app.infra.repository.DepartmentInfoRepository;
|
||||
import com.example.rhizome.app.infra.entity.DepartmentEntity;
|
||||
import com.example.rhizome.app.infra.entity.DivisionEntity;
|
||||
import com.example.rhizome.app.infra.entity.HeadquartersEntity;
|
||||
import com.example.rhizome.app.infra.repository.DivisionRepository;
|
||||
|
||||
/**
|
||||
* department の更新系の機能を集約させるサービスクラスです。
|
||||
@@ -17,12 +19,12 @@ import com.example.rhizome.app.infra.repository.DepartmentInfoRepository;
|
||||
public class UpdateDepartmentImpl implements UpdateDepartment {
|
||||
|
||||
|
||||
DepartmentInfoRepository departmentInfoRepository;
|
||||
DivisionRepository divisionRepository;
|
||||
|
||||
@Autowired
|
||||
public UpdateDepartmentImpl(DepartmentInfoRepository departmentInfoRepository
|
||||
public UpdateDepartmentImpl(DivisionRepository divisionRepository
|
||||
) {
|
||||
this.departmentInfoRepository = departmentInfoRepository;
|
||||
this.divisionRepository = divisionRepository;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -31,9 +33,21 @@ public class UpdateDepartmentImpl implements UpdateDepartment {
|
||||
* @param department 更新のデータ
|
||||
*/
|
||||
public void updateDepartment(DepartmentInfo departmentInfo) {
|
||||
System.out.println(departmentInfo.getIdDivision());
|
||||
departmentInfoRepository.save(DepartmentInfoEntity.convertFrom(departmentInfo));
|
||||
|
||||
DivisionEntity divisionEntity = DivisionEntity.convertFrom(departmentInfo);
|
||||
DepartmentEntity departmentEntity = divisionEntity.getDepartment();
|
||||
HeadquartersEntity headquartersEntity = divisionEntity.getDepartment().getHeadquarters();
|
||||
departmentEntity.setNmDepartment(
|
||||
divisionEntity.getDepartment()
|
||||
.getNmDepartment()
|
||||
);
|
||||
headquartersEntity.setNmHeadquarters(
|
||||
divisionEntity.getDepartment()
|
||||
.getHeadquarters()
|
||||
.getNmHeadquarters()
|
||||
);
|
||||
departmentEntity.setHeadquarters(headquartersEntity);
|
||||
divisionEntity.setDepartment(departmentEntity);
|
||||
divisionRepository.save(divisionEntity);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -39,6 +39,10 @@ import lombok.NoArgsConstructor;
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
//@NamedEntityGraph(
|
||||
// name = "department_with_headquarters",
|
||||
// includeAllAttributes = true
|
||||
//)
|
||||
public class DepartmentEntity {
|
||||
|
||||
/**
|
||||
@@ -58,6 +62,7 @@ public class DepartmentEntity {
|
||||
*/
|
||||
@Column(name = "is_display", nullable = false)
|
||||
private Integer isDisplay;
|
||||
|
||||
@ManyToOne(cascade = CascadeType.ALL)
|
||||
@JoinColumn(name = "id_headquarters")
|
||||
@Fetch(FetchMode.JOIN)
|
||||
@@ -83,6 +88,20 @@ public class DepartmentEntity {
|
||||
)).toList();
|
||||
}
|
||||
|
||||
public static List<Department> createDepartmentListBy(List<RegisterDepartmentEntity> departmentEntityList) {
|
||||
|
||||
// Stream API を利用するとこうなります。
|
||||
return departmentEntityList
|
||||
.stream()
|
||||
.map(departmentEntity -> new Department(
|
||||
departmentEntity.getIdDepartment(),
|
||||
departmentEntity.getNmDepartment(),
|
||||
departmentEntity.getIsDisplay(),
|
||||
departmentEntity.getIdHeadquarters() == null ? null : departmentEntity.getIdHeadquarters()
|
||||
|
||||
)).toList();
|
||||
}
|
||||
|
||||
/**
|
||||
* Department(BusinessLogic層依存型) から DepartmentEntity(DataAccess層依存)に変換します。
|
||||
*
|
||||
|
||||
@@ -6,6 +6,7 @@ import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import com.example.rhizome.app.infra.entity.DepartmentEntity;
|
||||
import com.example.rhizome.app.infra.entity.HeadquartersEntity;
|
||||
|
||||
|
||||
/**
|
||||
@@ -48,10 +49,14 @@ public interface DepartmentRepository extends JpaRepository<DepartmentEntity, In
|
||||
(Specification<DepartmentEntity>)
|
||||
(root, criteriaQuery, criteriaBuilder) -> criteriaBuilder.like(root.get("nmDepartment"), "%" + nmDepartment + "%");
|
||||
}
|
||||
|
||||
|
||||
|
||||
DepartmentEntity findByHeadquartersAndNmDepartment(HeadquartersEntity headquartersEntity,String nmDepartment);
|
||||
|
||||
|
||||
|
||||
// @Query("SELECT DISTINCT new com.example.rhizome.app.infra.entity.DepartmentEntity(de,h)FROM DepartmentEntity de "
|
||||
// + "INNER JOIN de.headquarters h "
|
||||
// + "WHERE h.idHeadquarters =:idHeadquarters")
|
||||
// List<DepartmentEntity> searchDepartmentByIdHeadquarters(
|
||||
// @Param("idHeadquarters") Integer IdHeadquarters);
|
||||
|
||||
}
|
||||
|
||||
@@ -20,6 +20,7 @@ import com.example.rhizome.app.domain.model.DepartmentInfo;
|
||||
import com.example.rhizome.app.domain.model.SearchConditionDepartment;
|
||||
import com.example.rhizome.app.domain.service.RegisterDepartment;
|
||||
import com.example.rhizome.app.domain.service.SearchDepartment;
|
||||
import com.example.rhizome.app.domain.service.impl.SearchDepartmentImpl;
|
||||
import com.example.rhizome.app.infra.entity.DivisionEntity;
|
||||
import com.example.rhizome.app.presentation.controller.pageproperty.PageReturnAttributeKeyword;
|
||||
import com.example.rhizome.app.presentation.controller.pageproperty.TransitionTargetPageNameKeyword;
|
||||
@@ -33,7 +34,9 @@ import com.example.rhizome.app.presentation.form.MessageForm;
|
||||
@Controller
|
||||
public class InsertDepartmentController {
|
||||
|
||||
// ログ出力用インスタンス
|
||||
private final SearchDepartmentImpl searchDepartmentImpl;
|
||||
|
||||
// ログ出力用インスタンス
|
||||
private final static Logger LOGGER = Logger.getLogger(InsertDepartmentController.class.getName());
|
||||
|
||||
// エラーメッセージ用の定数フィールド
|
||||
@@ -44,10 +47,11 @@ public class InsertDepartmentController {
|
||||
SearchDepartment searchDepartment;
|
||||
|
||||
@Autowired
|
||||
public InsertDepartmentController(HttpSession httpSession, RegisterDepartment registerDepartment, SearchDepartment searchDepartment) {
|
||||
public InsertDepartmentController(HttpSession httpSession, RegisterDepartment registerDepartment, SearchDepartment searchDepartment, SearchDepartmentImpl searchDepartmentImpl) {
|
||||
this.httpSession = httpSession;
|
||||
this.registerDepartment = registerDepartment;
|
||||
this.searchDepartment = searchDepartment;
|
||||
this.searchDepartmentImpl = searchDepartmentImpl;
|
||||
}
|
||||
|
||||
@ModelAttribute
|
||||
@@ -89,19 +93,19 @@ public class InsertDepartmentController {
|
||||
// 登録画面に遷移
|
||||
return INSERT_DEPARTMENT_INPUT_HTML;
|
||||
}
|
||||
|
||||
|
||||
// 部署名で重複が無いかチェック
|
||||
if (!searchDepartment.searchByHeadquarters(
|
||||
new SearchConditionDepartment(
|
||||
null,
|
||||
insertDepartmentForm.getNmHeadquarters())).isEmpty()
|
||||
&&!searchDepartment.searchByDepartment(
|
||||
new SearchConditionDepartment(
|
||||
null,
|
||||
insertDepartmentForm.getNmDepartment())).isEmpty()
|
||||
&&!searchDepartment.searchByDivision(
|
||||
new SearchConditionDepartment(
|
||||
null,
|
||||
insertDepartmentForm.getNmDivision())).isEmpty()) {
|
||||
if (searchDepartment.searchAllDepartmentTable(
|
||||
new SearchConditionDepartment(
|
||||
insertDepartmentForm.getIdHeadquarters(),
|
||||
insertDepartmentForm.getNmHeadquarters()),
|
||||
new SearchConditionDepartment(
|
||||
insertDepartmentForm.getIdDepartment(),
|
||||
insertDepartmentForm.getNmDepartment()),
|
||||
new SearchConditionDepartment(
|
||||
insertDepartmentForm.getIdDivision(),
|
||||
insertDepartmentForm.getNmDivision()))) {
|
||||
|
||||
|
||||
// 存在する場合はエラーメッセージを設定して更新入力画面に遷移
|
||||
|
||||
@@ -2,6 +2,7 @@ package com.example.rhizome.app.presentation.controller;
|
||||
|
||||
import static com.example.rhizome.app.presentation.controller.pageproperty.TransitionTargetPageNameKeyword.*;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
@@ -10,9 +11,12 @@ import javax.servlet.http.HttpSession;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.Model;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.ModelAttribute;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMethod;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.ResponseBody;
|
||||
|
||||
import com.example.rhizome.aop.aspect.PermissionCheck;
|
||||
import com.example.rhizome.aop.aspect.SessionCheck;
|
||||
@@ -20,7 +24,9 @@ import com.example.rhizome.app.domain.service.RegisterEmployee;
|
||||
import com.example.rhizome.app.domain.service.SearchDepartment;
|
||||
import com.example.rhizome.app.presentation.controller.pageproperty.PageReturnAttributeKeyword;
|
||||
import com.example.rhizome.app.presentation.controller.pageproperty.TransitionTargetPageNameKeyword;
|
||||
import com.example.rhizome.app.presentation.form.DepartmentForm;
|
||||
import com.example.rhizome.app.presentation.form.DepartmentInfoForm;
|
||||
import com.example.rhizome.app.presentation.form.DivisionInfoForm;
|
||||
import com.example.rhizome.app.presentation.form.HeadquartersInfoForm;
|
||||
import com.example.rhizome.app.presentation.form.InsertEmployeeForm;
|
||||
|
||||
/**
|
||||
@@ -67,7 +73,7 @@ public class InsertEmployeeInputController {
|
||||
try {
|
||||
// 部署コードリストを作成し、画面に返す値としてセット
|
||||
model.addAttribute(PageReturnAttributeKeyword.DEPARTMENT_FORM_LIST
|
||||
, DepartmentForm.convertFrom(
|
||||
,HeadquartersInfoForm.convertFrom(
|
||||
searchDepartment.searchAllDepartmentTable()));
|
||||
|
||||
// パラメータをセット
|
||||
@@ -88,6 +94,45 @@ public class InsertEmployeeInputController {
|
||||
return TransitionTargetPageNameKeyword.ERROR_HTML;
|
||||
}
|
||||
}
|
||||
|
||||
@GetMapping("insertEmployeeInput/searchDepartment" )
|
||||
@ResponseBody
|
||||
public List<DepartmentInfoForm>departmentsByHeadquarters(
|
||||
@RequestParam("id_headquarters")Integer idHeadquarters){
|
||||
System.out.println("koko");
|
||||
|
||||
List<DepartmentInfoForm> departmentByHeadquarters=
|
||||
DepartmentInfoForm.convertFrom(
|
||||
searchDepartment.searchByIdHeadquarters(idHeadquarters));
|
||||
System.out.println("2");
|
||||
return departmentByHeadquarters
|
||||
.stream()
|
||||
.map(DepartmentInfoForm-> new DepartmentInfoForm(
|
||||
DepartmentInfoForm.getIdDepartment(),
|
||||
DepartmentInfoForm.getNmDepartment()))
|
||||
.distinct()
|
||||
.toList();
|
||||
|
||||
|
||||
}
|
||||
@GetMapping("/insertEmployeeInput/searchDepartment/searchDivision")
|
||||
@ResponseBody
|
||||
public List<DivisionInfoForm>divisionBydepartment(
|
||||
@RequestParam("idDepartment")Integer idDepartment){
|
||||
List<DivisionInfoForm> divisionBydepartment=
|
||||
DivisionInfoForm.convertFrom(
|
||||
searchDepartment.searchByIdDepartment(idDepartment));
|
||||
|
||||
return divisionBydepartment
|
||||
.stream()
|
||||
.map(DivisionInfoForm-> new DivisionInfoForm(
|
||||
DivisionInfoForm.getIdDivision(),
|
||||
DivisionInfoForm.getNmDivision()))
|
||||
.distinct()
|
||||
.toList();
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -75,18 +75,16 @@ public class UpdateDepartmentResultController {
|
||||
}
|
||||
|
||||
// 部署名で重複が無いかチェック
|
||||
if (!searchDepartment.searchByHeadquarters(
|
||||
new SearchConditionDepartment(
|
||||
null,
|
||||
updateDepartmentForm.getNmHeadquarters())).isEmpty()||
|
||||
!searchDepartment.searchByDepartment(
|
||||
new SearchConditionDepartment(
|
||||
null,
|
||||
updateDepartmentForm.getNmDepartment())).isEmpty()||
|
||||
!searchDepartment.searchByDivision(
|
||||
new SearchConditionDepartment(
|
||||
null,
|
||||
updateDepartmentForm.getNmDivision())).isEmpty()) {
|
||||
if (searchDepartment.searchAllDepartmentTable(
|
||||
new SearchConditionDepartment(
|
||||
updateDepartmentForm.getIdHeadquarters(),
|
||||
updateDepartmentForm.getNmHeadquarters()),
|
||||
new SearchConditionDepartment(
|
||||
updateDepartmentForm.getIdDepartment(),
|
||||
updateDepartmentForm.getNmDepartment()),
|
||||
new SearchConditionDepartment(
|
||||
updateDepartmentForm.getIdDivision(),
|
||||
updateDepartmentForm.getNmDivision()))) {
|
||||
// 存在する場合はエラーメッセージを設定して更新入力画面に遷移
|
||||
model.addAttribute(PageReturnAttributeKeyword.MESSAGE_ERROR, new MessageForm(DUPLICATION));
|
||||
model.addAttribute(PageReturnAttributeKeyword.UPDATE_DEPARTMENT_FORM, updateDepartmentForm);
|
||||
|
||||
@@ -52,7 +52,17 @@ public class InsertEmployeeForm {
|
||||
private Integer adminAuth;
|
||||
|
||||
/**
|
||||
* 部署ID
|
||||
* 本部ID
|
||||
*/
|
||||
private Integer idHeadquarters;
|
||||
|
||||
/**
|
||||
* 部ID
|
||||
*/
|
||||
private Integer idDepartment;
|
||||
|
||||
/**
|
||||
* 課ID
|
||||
*/
|
||||
private Integer idDivision;
|
||||
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
<button class="logoutButton" onclick="logoutSubmit()">ログアウト</button>
|
||||
</div>
|
||||
</h1>
|
||||
<form action="insertDepartmentConfirm" method="post" th:object="${insertDepartmentForm}">
|
||||
<form action="insertDepartmentConfirm" method="post" th:object="${insertDepartmentForm}" id="insertDepartmentForm">
|
||||
|
||||
<div class="msgBox error" th:if="${messageError} != null">
|
||||
<span class="error" th:text="${messageError.message}"></span>
|
||||
@@ -39,7 +39,7 @@
|
||||
<th class="header">本部名</th>
|
||||
<td>
|
||||
<label>
|
||||
<input maxlength="50" placeholder="本部名" th:field="*{nmHeadquarters}" type="text" />
|
||||
<input maxlength="50" placeholder="本部名" th:field="*{nmHeadquarters}" type="text"id= "nmHeadquarters1" />
|
||||
</label>
|
||||
</td>
|
||||
</tr>
|
||||
@@ -47,12 +47,13 @@
|
||||
<th class="header"></th>
|
||||
<td>
|
||||
<label>
|
||||
<select th:field="*{nmHeadquarters}">
|
||||
<select th:field="*{nmHeadquarters}"id= "nmHeadquarters2">
|
||||
<option value="">本部を選択</option>
|
||||
<option
|
||||
th:each="headquarters : ${departmentFormList}"
|
||||
th:selected="${insertDepartmentForm.idHeadquarters != null && headquarters.idHeadquarters == insertDepartmentForm.idHeadquarters}"
|
||||
th:text="${headquarters.nmHeadquarters}" th:value="${headquarters.nmHeadquarters}">
|
||||
th:text="${headquarters.nmHeadquarters}" th:value="${headquarters.nmHeadquarters}"
|
||||
>
|
||||
</option>
|
||||
</select>
|
||||
</label>
|
||||
@@ -70,7 +71,7 @@
|
||||
<th class="header">部名</th>
|
||||
<td>
|
||||
<label>
|
||||
<input maxlength="50" placeholder="部名" th:field="*{nmDepartment}" type="text" />
|
||||
<input maxlength="50" placeholder="部名" th:field="*{nmDepartment}" type="text" id="nmDepartment1"/>
|
||||
</label>
|
||||
</td>
|
||||
</tr>
|
||||
@@ -78,7 +79,7 @@
|
||||
<th class="header"></th>
|
||||
<td>
|
||||
<label>
|
||||
<select th:field="*{nmDepartment}">
|
||||
<select th:field="*{nmDepartment}"id="nmDepartment2">
|
||||
<option value="">部を選択</option>
|
||||
<option
|
||||
th:each="department : ${departmentFormList}"
|
||||
@@ -103,7 +104,7 @@
|
||||
<th class="header">課名</th>
|
||||
<td>
|
||||
<label>
|
||||
<input maxlength="50" placeholder="課名" th:field="*{nmDivision}" type="text" />
|
||||
<input maxlength="50" placeholder="課名" th:field="*{nmDivision}" type="text" id="nmDivision1"/>
|
||||
</label>
|
||||
</td>
|
||||
</tr>
|
||||
@@ -114,7 +115,7 @@
|
||||
<th class="header"></th>
|
||||
<td>
|
||||
<label>
|
||||
<select th:field="*{nmDivision}">
|
||||
<select th:field="*{nmDivision}"id="nmDivision2">
|
||||
<option value="">課を選択</option>
|
||||
<option th:each="division : ${departmentFormList}"
|
||||
th:selected="${insertDepartmentForm.idDivision != null && division.idDivision == insertDepartmentForm.idDivision}"
|
||||
@@ -136,5 +137,26 @@
|
||||
</form>
|
||||
<a href="showMenu">メニューに戻る</a>
|
||||
</body>
|
||||
<script type="text/javascript">
|
||||
document.getElementById('insertDepartmentForm').addEventListener('submit',function(e){
|
||||
if(document.getElementById('nmHeadquarters1').value!==""){
|
||||
document.getElementById('nmHeadquarters2').removeAttribute('name');
|
||||
}else if(document.getElementById('nmHeadquarters2').value!==""){
|
||||
document.getElementById('nmHeadquarters1').removeAttribute('name');
|
||||
}
|
||||
if(document.getElementById('nmDepartment1').value!==""){
|
||||
document.getElementById('nmDepartment2').removeAttribute('name');
|
||||
}else if(document.getElementById('nmDepartment2').value!==""){
|
||||
document.getElementById('nmDepartment1').removeAttribute('name');
|
||||
}
|
||||
if(document.getElementById('nmDivision1').value!==""){
|
||||
document.getElementById('nmDivision2').removeAttribute('name');
|
||||
}else if(document.getElementById('nmDivision2').value!==""){
|
||||
document.getElementById('nmDivision1').removeAttribute('name');
|
||||
}
|
||||
|
||||
});
|
||||
</script>
|
||||
|
||||
|
||||
</html>
|
||||
@@ -119,24 +119,52 @@
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th class="header">所属部署</th>
|
||||
<th class="header" style="vertical-align: top;">所属部署</th>
|
||||
<td>
|
||||
<label>
|
||||
<select name="idDivision" required="required" th:field="*{idDivision}">
|
||||
<th:block th:each="division : ${departmentFormList}">
|
||||
<select name="idHeadquarters" required="required" th:field="*{idHeadquarters}">
|
||||
<th:block th:each="headquarters : ${departmentFormList}">
|
||||
<th:block
|
||||
th:if="${insertEmployeeForm.idDivision != null && division.idDivision == insertEmployeeForm.idDivision}">
|
||||
<option
|
||||
th:utext="
|
||||
${division.nmHeadquarters}+' '+
|
||||
${division.nmDepartment}+' '+
|
||||
${division.nmDivision}"
|
||||
th:value="${division.idDivision}">
|
||||
</option>
|
||||
th:if="${insertEmployeeForm.idHeadquarters != null && headquarters.idHeadquarters == insertEmployeeForm.idHeadquarters}">>
|
||||
<option
|
||||
th:utext="
|
||||
${headquarters.nmHeadquarters}"
|
||||
th:value="${headquarters.idHeadquarters}">
|
||||
</option>
|
||||
</th:block>
|
||||
</th:block>
|
||||
</select>
|
||||
</label>
|
||||
<br>
|
||||
<label>
|
||||
<select name="idDepartment" required="required" th:field="*{idDepartment}">
|
||||
<th:block th:each="department : ${departmentFormList}">
|
||||
<th:block
|
||||
th:if="${insertEmployeeForm.idDepartment != null && department.idDepartment == insertEmployeeForm.idDepartment}">>
|
||||
<option
|
||||
th:utext="
|
||||
${department.nmDepartment}"
|
||||
th:value="${department.idDepartment}">
|
||||
</option>
|
||||
</th:block>
|
||||
</th:block>
|
||||
</select>
|
||||
</label>
|
||||
<br>
|
||||
<label>
|
||||
<select name="idDivision" required="required" th:field="*{idDivision}">
|
||||
<th:block th:each="division : ${departmentFormList}">
|
||||
<th:block
|
||||
th:if="${insertEmployeeForm.idDivision != null && division.idDivision == insertEmployeeForm.idDivision}">
|
||||
<option
|
||||
th:utext="
|
||||
${division.nmDivision}"
|
||||
th:value="${division.idDivision}">
|
||||
</option>
|
||||
</th:block>
|
||||
</th:block>
|
||||
</select>
|
||||
</label>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
|
||||
@@ -145,24 +145,46 @@
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<th class="header">所属部署</th>
|
||||
<td>
|
||||
<label>
|
||||
<select required="required" th:field="*{idDivision}">
|
||||
<option value="">所属部署を選択</option>
|
||||
<option th:each="division : ${departmentFormList}"
|
||||
th:selected="${insertEmployeeForm.idDivision != null && division.idDivision == insertEmployeeForm.idDivision}"
|
||||
th:utext="
|
||||
${division.nmHeadquarters}+' '+
|
||||
${division.nmDepartment}+' '+
|
||||
${division.nmDivision}"
|
||||
th:value="${division.idDivision}">
|
||||
</option>
|
||||
</select>
|
||||
</label>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
|
||||
<th class="header" >所属本部</th>
|
||||
<td>
|
||||
|
||||
<label>
|
||||
<select id="headquartersSelect" required="required" th:field="*{idHeadquarters}">
|
||||
|
||||
<option th:each="headquarters : ${departmentFormList}"
|
||||
th:utext="
|
||||
${headquarters.nmHeadquarters}"
|
||||
th:value="${headquarters.idHeadquarters}">
|
||||
</option>
|
||||
|
||||
</select>
|
||||
</label>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th class="header" >所属部</th>
|
||||
<td>
|
||||
<label>
|
||||
<select id="departmentSelect" required="required" th:field="*{idDepartment}">
|
||||
<option value="">先に本部を選択してください</option>
|
||||
|
||||
</select>
|
||||
</label>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th class="header" >所属課</th>
|
||||
<td>
|
||||
<label>
|
||||
<select id="divisionSelect" required="required" th:field="*{idDivision}">
|
||||
<option value="">先に部を選択してください</option>
|
||||
</select>
|
||||
</label>
|
||||
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="btnArea" colspan="2">
|
||||
<input type="submit" value="登録確認"/>
|
||||
@@ -172,4 +194,46 @@
|
||||
</form>
|
||||
<a href="showMenu">メニューに戻る</a>
|
||||
</body>
|
||||
<script>
|
||||
const headquartersSelect = document.getElementById('headquartersSelect');
|
||||
const departmentSelect = document.getElementById('departmentSelect');
|
||||
const divisionSelect = document.getElementById('divisionSelect');
|
||||
|
||||
headquartersSelect.addEventListener('change', function() {
|
||||
const id_headquarters = this.value;
|
||||
|
||||
departmentSelect.disabled = true;
|
||||
divisionSelect.disabled = true;
|
||||
departmentSelect.innerHTML = '<option value="">-- 部を選択 --</option>';
|
||||
divisionSelect.innerHTML = '<option value="">-- 先に部を選択してください --</option>';
|
||||
console.log("koko");
|
||||
if (!id_headquarters) return;
|
||||
fetch(`insertEmployeeInput/searchDepartment?id_headquarters=${id_headquarters}`,{
|
||||
method: 'GET',
|
||||
headers: {
|
||||
'Accept': 'application/json'
|
||||
}
|
||||
})
|
||||
|
||||
.then(res => {
|
||||
return res.json();
|
||||
})
|
||||
.then(list => {
|
||||
console.log("koko");
|
||||
departmentSelect.disabled = false;
|
||||
list.forEach(form => {
|
||||
const opt = document.createElement('option');
|
||||
opt.value = form.idDepartment;
|
||||
opt.textContent = form.nmDepartment;
|
||||
departmentSelect.appendChild(opt);
|
||||
});
|
||||
})
|
||||
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</script>
|
||||
</html>
|
||||
@@ -134,24 +134,46 @@
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th class="header">所属部署</th>
|
||||
<td>
|
||||
|
||||
<th class="header" style="vertical-align: top;">所属部署</th>
|
||||
<td>
|
||||
|
||||
<label>
|
||||
<select required="required" th:field="*{idDivision}">
|
||||
<select required="required" >
|
||||
|
||||
<option th:each="division : ${departmentFormList}"
|
||||
th:selected="${updateEmployeeInfoForm.idDivision != null && division.idDivision == updateEmployeeInfoForm.idDivision}"
|
||||
<option th:each="headquarters : ${departmentFormList}"
|
||||
th:utext="
|
||||
${division.nmHeadquarters}+' '+
|
||||
${division.nmDepartment}+' '+
|
||||
${division.nmDivision}"
|
||||
th:value="${division.idDivision}">
|
||||
${headquarters.nmHeadquarters}"
|
||||
th:value="${headquarters.idHeadquarters}">
|
||||
</option>
|
||||
|
||||
</select>
|
||||
</label>
|
||||
</td>
|
||||
</tr>
|
||||
<br>
|
||||
<label>
|
||||
<select required="required" >
|
||||
<option th:each="department : ${departmentFormList}"
|
||||
|
||||
th:utext="
|
||||
${department.nmDepartment}"
|
||||
th:value="${department.idDepartment}">
|
||||
</option>
|
||||
|
||||
</select>
|
||||
</label>
|
||||
<br>
|
||||
<label>
|
||||
<select required="required" th:field="*{idDivision}">
|
||||
<option th:each="division : ${departmentFormList}"
|
||||
th:utext="
|
||||
${division.nmDivision}"
|
||||
th:value="${division.idDivision}">
|
||||
</option>
|
||||
</select>
|
||||
</label>
|
||||
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="btnArea" colspan="2">
|
||||
<input type="submit" value="更新"/>
|
||||
|
||||
Reference in New Issue
Block a user