출장등록 진행중 -> 화면완료
This commit is contained in:
parent
7c9f240ace
commit
b4b54de6d2
42
src/main/java/com/itn/admin/itn/trip/web/TripController.java
Normal file
42
src/main/java/com/itn/admin/itn/trip/web/TripController.java
Normal file
@ -0,0 +1,42 @@
|
||||
package com.itn.admin.itn.trip.web;
|
||||
|
||||
import com.itn.admin.cmn.config.CustomUserDetails;
|
||||
import com.itn.admin.itn.user.mapper.domain.UserVO;
|
||||
import com.itn.admin.itn.user.service.UserService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.security.core.annotation.AuthenticationPrincipal;
|
||||
import org.springframework.security.crypto.password.PasswordEncoder;
|
||||
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 java.util.Map;
|
||||
|
||||
@Slf4j
|
||||
@Controller
|
||||
public class TripController {
|
||||
|
||||
@Autowired
|
||||
private UserService userService;
|
||||
|
||||
|
||||
@GetMapping("/itn/trip/reg")
|
||||
public String list(@ModelAttribute("userVO") UserVO userVO
|
||||
,@AuthenticationPrincipal CustomUserDetails loginUser
|
||||
,Model model
|
||||
) {
|
||||
log.info(" + loginUser :: [{}]", loginUser.getUser());
|
||||
|
||||
/*
|
||||
Map<String, Object> resultMap = userService.getList(userVO);
|
||||
|
||||
model.addAttribute("list", resultMap.get("resultList"));
|
||||
*/
|
||||
model.addAttribute("loginUser", loginUser.getUser());
|
||||
|
||||
return "itn/trip/reg";
|
||||
}
|
||||
|
||||
}
|
||||
@ -40,4 +40,7 @@ public interface UserMapper {
|
||||
|
||||
|
||||
void changepassword(UserVO userVO);
|
||||
|
||||
@Select("SELECT * FROM users WHERE user_name LIKE CONCAT('%', #{userName}, '%')")
|
||||
List<UserVO> findByUniqUserName(String userName);
|
||||
}
|
||||
|
||||
@ -22,9 +22,11 @@ public class UserVO extends CmnVO {
|
||||
private String password;
|
||||
private String userName;
|
||||
private String userRank;
|
||||
private String mobilePhone;
|
||||
private String gwId;
|
||||
private String biostarId;
|
||||
private String deptCd;
|
||||
private String deptNm;
|
||||
private String activeYn;
|
||||
private Role role; // 단일 역할로 변경
|
||||
private String hireDate; // 입사일
|
||||
|
||||
@ -24,4 +24,6 @@ public interface UserService {
|
||||
RestResponse updateUserInfo(UserVO userVO);
|
||||
|
||||
RestResponse changepassword(UserVO userVO);
|
||||
|
||||
RestResponse findByUniqUserName(String userName);
|
||||
}
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
package com.itn.admin.itn.user.service.impl;
|
||||
|
||||
import com.itn.admin.cmn.msg.RestResponse;
|
||||
import com.itn.admin.cmn.util.thymeleafUtils.TCodeUtils;
|
||||
import com.itn.admin.commute.mapper.CommuteMapper;
|
||||
import com.itn.admin.commute.mapper.domain.CommuteVO;
|
||||
import com.itn.admin.commute.mapper.domain.UserEnum;
|
||||
@ -34,6 +35,9 @@ public class UserServiceImpl implements UserService {
|
||||
@Autowired
|
||||
UserMapper userMapper;
|
||||
|
||||
@Autowired
|
||||
TCodeUtils tCodeUtils;
|
||||
|
||||
|
||||
public Map<String, Object> getList(UserVO userVO) {
|
||||
|
||||
@ -94,11 +98,29 @@ public class UserServiceImpl implements UserService {
|
||||
// .msg("수정되었습니다.")
|
||||
.build();
|
||||
|
||||
}
|
||||
@Override
|
||||
public RestResponse findByUniqUserName(String userName) {
|
||||
|
||||
List<UserVO> users = userMapper.findByUniqUserName(userName);
|
||||
// 코드 이름을 붙여주는 처리 (가공)
|
||||
users.forEach(user -> {
|
||||
String deptNm = tCodeUtils.getCodeName("DEPT", user.getDeptCd());
|
||||
user.setDeptNm(deptNm); // UserVO에 deptCdName 필드 있어야 함
|
||||
});
|
||||
|
||||
return RestResponse.builder()
|
||||
.status(HttpStatus.OK) // 200 성공
|
||||
.data(users)
|
||||
// .msg("수정되었습니다.")
|
||||
.build();
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public RestResponse updateUserInfo(UserVO userVO) {
|
||||
userMapper.updateUserInfo(userVO);
|
||||
|
||||
return RestResponse.builder()
|
||||
.status(HttpStatus.OK) // 200 성공
|
||||
.data(userVO.getUserName())
|
||||
|
||||
@ -27,13 +27,13 @@ public class UserRestController {
|
||||
private final PasswordEncoder passwordEncoder;
|
||||
|
||||
public UserRestController(PasswordEncoder passwordEncoder) {
|
||||
log.info(" + UserRestController 등록된 PasswordEncoder instance: {}", passwordEncoder);
|
||||
this.passwordEncoder = passwordEncoder;
|
||||
}
|
||||
|
||||
@PostMapping("/user/updateRole")
|
||||
@ResponseBody
|
||||
public ResponseEntity<?> updateRole(@RequestParam("uniqId") String uniqId, @RequestParam("role") Role role) {
|
||||
public ResponseEntity<?> updateRole(@RequestParam("uniqId") String uniqId
|
||||
, @RequestParam("role") Role role) {
|
||||
return ResponseEntity.ok(userService.updateRole(uniqId, role));
|
||||
}
|
||||
|
||||
@ -41,12 +41,19 @@ public class UserRestController {
|
||||
// 특정 코드 그룹을 ID로 가져오는 메서드
|
||||
@GetMapping("/api/admin/user/{uniqId}")
|
||||
public ResponseEntity<?> findByUniqId(@PathVariable String uniqId) {
|
||||
log.info("getCodeGroupById uniqId={}", uniqId);
|
||||
return ResponseEntity.ok(userService.findByUniqId(uniqId));
|
||||
}
|
||||
// 특정 코드 그룹을 ID로 가져오는 메서드
|
||||
@GetMapping("/api/admin/user/search/name")
|
||||
public ResponseEntity<?> findByUniqUserName(@RequestParam String userName) {
|
||||
log.info("userName: {}", userName);
|
||||
return ResponseEntity.ok(userService.findByUniqUserName(userName));
|
||||
}
|
||||
|
||||
// 코드 그룹 수정 메서드
|
||||
@PutMapping("/api/admin/user/{uniqId}")
|
||||
public ResponseEntity<RestResponse> updateUserInfo(@PathVariable String uniqId, @RequestBody UserVO userVO) {
|
||||
public ResponseEntity<RestResponse> updateUserInfo(/*@PathVariable String uniqId
|
||||
, */@RequestBody UserVO userVO) {
|
||||
return ResponseEntity.ok().body(userService.updateUserInfo(userVO));
|
||||
|
||||
}
|
||||
|
||||
@ -28,7 +28,6 @@ spring.thymeleaf.prefix=classpath:templates/
|
||||
spring.thymeleaf.suffix=.html
|
||||
spring.thymeleaf.cache=false
|
||||
|
||||
|
||||
# itn_admin
|
||||
#spring.main.datasource.driverClassName=com.mysql.cj.jdbc.Driver
|
||||
spring.main.datasource.driverClassName=net.sf.log4jdbc.sql.jdbcapi.DriverSpy
|
||||
|
||||
@ -8,6 +8,7 @@
|
||||
<!-- 특정 코드 그룹의 모든 상세 코드를 조회하는 쿼리 -->
|
||||
<select id="findByGroupId" parameterType="String" resultType="codeDetailVO">
|
||||
SELECT * FROM common_code_detail WHERE code_group_id = #{codeGroupId}
|
||||
order by sort_order
|
||||
</select>
|
||||
|
||||
<!-- 특정 코드 상세를 ID로 조회하는 쿼리 -->
|
||||
|
||||
@ -34,6 +34,7 @@
|
||||
, user_pw AS password
|
||||
, user_name
|
||||
, user_rank
|
||||
, mobile_phone
|
||||
, dept_cd
|
||||
, role
|
||||
, gw_id AS gwId
|
||||
|
||||
@ -82,6 +82,41 @@
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a href="#" class="nav-link" >
|
||||
<i class="nav-icon fas fa-plane-departure"></i>
|
||||
<p>
|
||||
출장
|
||||
<i class="right fas fa-angle-left"></i>
|
||||
</p>
|
||||
</a>
|
||||
<ul class="nav nav-treeview">
|
||||
<li class="nav-item">
|
||||
<a th:href="@{/itn/trip/reg}" class="nav-link">
|
||||
<!-- <i class="far fa-circle nav-icon"></i>-->
|
||||
<!-- <i class="far fa-clock nav-icon"></i>-->
|
||||
<i class="nav-icon fas fa-calendar-check"></i>
|
||||
<p>출장 등록</p>
|
||||
</a>
|
||||
</li>
|
||||
</ul>
|
||||
<!--<ul class="nav nav-treeview">
|
||||
<li class="nav-item">
|
||||
<a th:href="@{/admin/user/list}" class="nav-link">
|
||||
<i class="nav-icon fas fa-user-cog"></i>
|
||||
<p>사용자 관리</p>
|
||||
</a>
|
||||
</li>
|
||||
</ul>
|
||||
<ul class="nav nav-treeview">
|
||||
<li class="nav-item">
|
||||
<a th:href="@{/code/list}" class="nav-link">
|
||||
<i class="nav-icon fas fa-code"></i>
|
||||
<p>공통코드</p>
|
||||
</a>
|
||||
</li>
|
||||
</ul>-->
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a th:href="@{/dict/list}" class="nav-link">
|
||||
<i class="nav-icon fas fa-book"></i>
|
||||
|
||||
@ -10,10 +10,6 @@
|
||||
|
||||
<!-- 필요하다면 개별 파일에 사용될 css/js 선언 -->
|
||||
|
||||
<!-- <link rel="stylesheet" th:href="@{/plugins/datatables-bs4/css/dataTables.bootstrap4.min.css}">-->
|
||||
<!-- <link rel="stylesheet" th:href="@{/plugins/datatables-responsive/css/responsive.bootstrap4.min.css}">-->
|
||||
<!-- <link rel="stylesheet" th:href="@{/plugins/datatables-buttons/css/buttons.bootstrap4.min.css}">-->
|
||||
|
||||
|
||||
|
||||
<link rel="stylesheet" type="text/css" href="https://cdnjs.cloudflare.com/ajax/libs/jsgrid/1.5.3/jsgrid.min.css">
|
||||
|
||||
377
src/main/resources/templates/itn/trip/reg.html
Normal file
377
src/main/resources/templates/itn/trip/reg.html
Normal file
@ -0,0 +1,377 @@
|
||||
<!DOCTYPE html>
|
||||
<!-- 관련 Namespace 선언 및 layout:decorate 추가 -->
|
||||
<html lang="en"
|
||||
xmlns:th="http://www.thymeleaf.org"
|
||||
xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout"
|
||||
layout:decorate="layout">
|
||||
<head>
|
||||
<!-- layout.html 에 들어간 head 부분을 제외하고 개별 파일에만 적용되는 head 부분 추가 -->
|
||||
<title>사용자 관리</title>
|
||||
|
||||
<!-- 필요하다면 개별 파일에 사용될 css/js 선언 -->
|
||||
|
||||
<link rel="stylesheet" th:href="@{/plugins/datatables-bs4/css/dataTables.bootstrap4.min.css}">
|
||||
<link rel="stylesheet" th:href="@{/plugins/datatables-responsive/css/responsive.bootstrap4.min.css}">
|
||||
<link rel="stylesheet" th:href="@{/plugins/datatables-buttons/css/buttons.bootstrap4.min.css}">
|
||||
|
||||
<style>
|
||||
.table-form th {
|
||||
background-color: #f1f1f1;
|
||||
text-align: left;
|
||||
vertical-align: middle;
|
||||
padding: 10px;
|
||||
width: 15%;
|
||||
}
|
||||
|
||||
.table-form td {
|
||||
padding: 10px;
|
||||
}
|
||||
|
||||
.card-header {
|
||||
background-color: #ffffff;
|
||||
font-weight: bold;
|
||||
border-top: 2px solid #009fe3;
|
||||
}
|
||||
|
||||
.btn-custom {
|
||||
border: 1px solid #dcdcdc;
|
||||
background-color: #ffffff;
|
||||
color: #009fe3;
|
||||
font-weight: bold;
|
||||
padding: 6px 18px;
|
||||
border-radius: 6px;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
|
||||
<body layout:fragment="body">
|
||||
|
||||
<div class="wrapper">
|
||||
<div th:replace="~{fragments/top_nav :: topFragment}"/>
|
||||
|
||||
<!-- Main Sidebar Container -->
|
||||
<aside class="main-sidebar sidebar-dark-primary elevation-4"
|
||||
th:insert="~{fragments/mainsidebar :: sidebarFragment}">
|
||||
</aside>
|
||||
|
||||
<!-- Content Wrapper. Contains page content -->
|
||||
<div class="content-wrapper">
|
||||
<!-- Content Header (Page header) -->
|
||||
<div class="content-header">
|
||||
<div class="container-fluid">
|
||||
<div class="row mb-2">
|
||||
<div class="col-sm-6">
|
||||
<h1 class="m-0">출장등록</h1>
|
||||
</div><!-- /.col -->
|
||||
<div class="col-sm-6">
|
||||
<ol class="breadcrumb float-sm-right">
|
||||
<li class="breadcrumb-item"><a href="#">Home</a></li>
|
||||
<li class="breadcrumb-item active">출장</li>
|
||||
</ol>
|
||||
</div><!-- /.col -->
|
||||
</div><!-- /.row -->
|
||||
</div><!-- /.container-fluid -->
|
||||
</div>
|
||||
<!-- /.content-header -->
|
||||
<!-- Main content -->
|
||||
<section class="content">
|
||||
<div class="container-fluid">
|
||||
<!-- <h3>출장 등록</h3>-->
|
||||
|
||||
<!-- 출장신청 영역 -->
|
||||
<div class="card mb-4">
|
||||
<div class="card-header">
|
||||
출장신청
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<table class="table table-bordered table-form" style="table-layout: fixed;">
|
||||
<tbody>
|
||||
<tr>
|
||||
<th>출장구분</th>
|
||||
<td>
|
||||
<select class="form-control" id="tripType" name="tripType">
|
||||
<option value="" th:selected>-- 선택 --</option>
|
||||
<option th:each="code : ${@TCodeUtils.getCodeList('TRIP_TYPE')}"
|
||||
th:value="${code.codeId}"
|
||||
th:text="${code.codeName}">
|
||||
</option>
|
||||
</select>
|
||||
</td>
|
||||
<th>출장지</th>
|
||||
<td>
|
||||
<select class="form-control d-inline" style="width: 20%;" id="tripLocation" name="tripLocation">
|
||||
<option value="" th:selected>-- 선택 --</option>
|
||||
<option th:each="code : ${@TCodeUtils.getCodeList('TRIP_LOCATION')}"
|
||||
th:value="${code.codeId}"
|
||||
th:text="${code.codeName}">
|
||||
</option>
|
||||
</select>
|
||||
|
||||
<input type="text" class="form-control d-inline" style="width: 70%;">
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>출장목적</th>
|
||||
<td><input type="text" class="form-control"></td>
|
||||
<th>이동사항</th>
|
||||
<td>
|
||||
<select class="form-control" id="tripMove" name="tripMove">
|
||||
<option value="" th:selected>-- 선택 --</option>
|
||||
<option th:each="code : ${@TCodeUtils.getCodeList('TRIP_MOVE')}"
|
||||
th:value="${code.codeId}"
|
||||
th:text="${code.codeName}">
|
||||
</option>
|
||||
</select>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>출장일자</th>
|
||||
<td>
|
||||
<input type="date" id="tripDate" class="form-control">
|
||||
</td>
|
||||
<th>시간</th>
|
||||
<td>
|
||||
<div class="d-flex gap-2">
|
||||
<input type="time" id="startTime" class="form-control" style="margin-right: 4px;">
|
||||
<span class="align-self-center">~</span>
|
||||
<input type="time" id="endTime" class="form-control" style="margin-left: 4px;">
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
|
||||
|
||||
<!-- 출장 인원 영역 -->
|
||||
<div class="card mt-4">
|
||||
<div class="card-header">
|
||||
출장 인원
|
||||
</div>
|
||||
<div class="card-body p-0">
|
||||
<table class="table table-bordered table-form mb-0">
|
||||
<thead>
|
||||
<tr class="text-center bg-light">
|
||||
<th style="width: 20%;">이름</th>
|
||||
<th style="width: 25%;">부서명</th>
|
||||
<th style="width: 25%;">연락처</th>
|
||||
<th style="width: 15%;" class="text-center">
|
||||
<button type="button" class="btn btn-info btn-sm" data-toggle="modal" data-target="#userSearchModal">
|
||||
<i class="fas fa-user-plus"></i> 인원 추가
|
||||
</button>
|
||||
</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody id="tripMemberTbody">
|
||||
<tr>
|
||||
<td th:text="${loginUser.getUserName()}"/>
|
||||
|
||||
<td th:text="${@TCodeUtils.getCodeName('DEPT', loginUser.getDeptCd())}"/>
|
||||
<td th:text="${loginUser.getMobilePhone()}"/>
|
||||
<td class="text-center">기안자</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="text-right mt-2">
|
||||
<!-- 등록 버튼 -->
|
||||
<button type="submit" class="btn btn-primary btn-sm">
|
||||
<i class="fas fa-save"></i> 등록
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</section>
|
||||
<!-- /Main content -->
|
||||
|
||||
</div>
|
||||
|
||||
<!-- 사용자 검색 모달 -->
|
||||
<div class="modal fade" id="userSearchModal" tabindex="-1" role="dialog" aria-labelledby="userSearchModalLabel" aria-hidden="true">
|
||||
<div class="modal-dialog modal-xl" role="document">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header bg-info">
|
||||
<h5 class="modal-title text-white" id="userSearchModalLabel">사용자 검색</h5>
|
||||
<button type="button" class="close text-white" data-dismiss="modal" aria-label="Close">
|
||||
<span aria-hidden="true">×</span>
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<div class="modal-body">
|
||||
<!-- 검색 영역 -->
|
||||
<div class="form-inline mb-3">
|
||||
<label class="mr-2">이름 검색</label>
|
||||
<input type="text" class="form-control mr-2" id="userSearchKeyword" placeholder="검색어 입력">
|
||||
<button type="button" class="btn btn-info btn-sm" onclick="searchUser()">검색</button>
|
||||
</div>
|
||||
|
||||
<!-- 결과 테이블 -->
|
||||
<div class="table-responsive" style="max-height: 500px; overflow-y: auto;">
|
||||
<table class="table table-hover table-bordered table-sm text-center">
|
||||
<thead class="thead-light">
|
||||
<tr>
|
||||
<th>이름</th>
|
||||
<th>부서</th>
|
||||
<th>직급</th>
|
||||
<th>추가</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody id="userSearchResult">
|
||||
<!-- 검색 결과 동적 렌더링 -->
|
||||
<!-- 예시 -->
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="modal-footer">
|
||||
<button type="button" class="btn btn-secondary btn-sm" data-dismiss="modal">닫기</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- /.content-wrapper -->
|
||||
<footer class="main-footer"
|
||||
th:insert="~{fragments/footer :: footerFragment}">
|
||||
</footer>
|
||||
|
||||
<!-- Control Sidebar -->
|
||||
<aside class="control-sidebar control-sidebar-dark">
|
||||
<!-- Control sidebar content goes here -->
|
||||
</aside>
|
||||
<!-- /.control-sidebar -->
|
||||
</div>
|
||||
<!-- ./wrapper -->
|
||||
|
||||
<!-- DataTables & Plugins -->
|
||||
<script th:src="@{/plugins/datatables/jquery.dataTables.min.js}"></script>
|
||||
<script th:src="@{/plugins/datatables-bs4/js/dataTables.bootstrap4.min.js}"></script>
|
||||
<script th:src="@{/plugins/datatables-responsive/js/dataTables.responsive.min.js}"></script>
|
||||
<script th:src="@{/plugins/datatables-responsive/js/responsive.bootstrap4.min.js}"></script>
|
||||
<script th:src="@{/plugins/datatables-buttons/js/dataTables.buttons.min.js}"></script>
|
||||
<script th:src="@{/plugins/datatables-buttons/js/buttons.bootstrap4.min.js}"></script>
|
||||
<script th:src="@{/plugins/jszip/jszip.min.js}"></script>
|
||||
<script th:src="@{/plugins/pdfmake/pdfmake.min.js}"></script>
|
||||
<script th:src="@{/plugins/pdfmake/vfs_fonts.js}"></script>
|
||||
<script th:src="@{/plugins/datatables-buttons/js/buttons.html5.min.js}"></script>
|
||||
<script th:src="@{/plugins/datatables-buttons/js/buttons.print.min.js}"></script>
|
||||
<script th:src="@{/plugins/datatables-buttons/js/buttons.colVis.min.js}"></script>
|
||||
<script>
|
||||
document.querySelector('input[id="startTime"]').addEventListener('click', function() {
|
||||
this.showPicker && this.showPicker(); // 일부 브라우저에서 시간 선택기 강제 실행
|
||||
});
|
||||
|
||||
document.querySelector('input[id="endTime"]').addEventListener('click', function() {
|
||||
this.showPicker && this.showPicker(); // 일부 브라우저에서 시간 선택기 강제 실행
|
||||
});
|
||||
document.querySelector('input[id="tripDate"]').addEventListener('click', function() {
|
||||
this.showPicker && this.showPicker(); // 일부 브라우저에서 시간 선택기 강제 실행
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
// 사용자 목록 로딩 (검색 포함)
|
||||
function loadUserList(keyword = "") {
|
||||
$.ajax({
|
||||
url: '/api/admin/user/search/name'
|
||||
,type: 'GET'
|
||||
,data: { userName: keyword }
|
||||
,success: function (resutl) {
|
||||
console.log(' + loadUserList resutl : ', resutl);
|
||||
const tbody = document.getElementById("userSearchResult");
|
||||
tbody.innerHTML = ""; // 초기화
|
||||
|
||||
var data = resutl.data;
|
||||
if (data && data.length > 0) {
|
||||
data.forEach(user => {
|
||||
const row = document.createElement("tr");
|
||||
row.innerHTML = `
|
||||
<td>${user.userName}</td>
|
||||
<td>${user.deptNm || "-"}</td>
|
||||
<td>${user.userRank || "-"}</td>
|
||||
<td>
|
||||
<button class="btn btn-sm btn-success" onclick="selectUser('${user.userName}', '${user.deptNm}', '${user.mobilePhone}')">
|
||||
<i class="fas fa-user-plus"></i> 추가
|
||||
</button>
|
||||
</td>
|
||||
`;
|
||||
tbody.appendChild(row);
|
||||
});
|
||||
} else {
|
||||
tbody.innerHTML = `<tr><td colspan="5" class="text-center text-muted">검색 결과가 없습니다.</td></tr>`;
|
||||
}
|
||||
},
|
||||
error: function () {
|
||||
alert("사용자 목록을 불러오는 데 실패했습니다.");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// 모달 열릴 때 사용자 목록 자동 로드
|
||||
$('#userSearchModal').on('shown.bs.modal', function () {
|
||||
loadUserList(); // 최초 전체 목록 로드
|
||||
});
|
||||
|
||||
|
||||
function selectUser(name, dept, phone) {
|
||||
console.log('phone: ', phone);
|
||||
// 원하는 방식으로 테이블에 사용자 추가
|
||||
const tbody = document.getElementById("tripMemberTbody");
|
||||
|
||||
const newRow = document.createElement("tr");
|
||||
newRow.innerHTML = `
|
||||
<td>${name}</td>
|
||||
<td>${dept}</td>
|
||||
<td>${phone}</td>
|
||||
<td class="text-center">
|
||||
<a href="#" class="btn btn-danger btn-sm" onclick="removeMemberRow(this)">
|
||||
<i class="fas fa-user-minus"></i> 삭제
|
||||
</a>
|
||||
</td>
|
||||
`;
|
||||
tbody.appendChild(newRow);
|
||||
|
||||
// 모달 닫기
|
||||
$('#userSearchModal').modal('hide');
|
||||
}
|
||||
|
||||
// 검색 버튼 클릭 시
|
||||
function searchUser() {
|
||||
const keyword = document.getElementById("userSearchKeyword").value.trim();
|
||||
loadUserList(keyword);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// 출장 인원 행 삭제 함수
|
||||
function removeMemberRow(el) {
|
||||
if (confirm("정말 삭제하시겠습니까?")) {
|
||||
const row = el.closest("tr");
|
||||
if (row) {
|
||||
row.remove();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
</script>
|
||||
|
||||
</body>
|
||||
|
||||
|
||||
|
||||
</html>
|
||||
Loading…
Reference in New Issue
Block a user