mirror of
https://github.com/suhf/No1WMS.git
synced 2026-02-04 12:13:24 +09:00
계정 추가 및 개인 권한 설정 기능 추가
This commit is contained in:
@@ -1,6 +1,8 @@
|
||||
package com.no1.wms.account;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.GsonBuilder;
|
||||
import com.google.gson.stream.JsonReader;
|
||||
import com.no1.wms.authority.AuthorityDto;
|
||||
import com.no1.wms.authority.AuthorityService;
|
||||
import com.no1.wms.utils.ConstantValues;
|
||||
@@ -9,7 +11,9 @@ import org.springframework.stereotype.Controller;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.servlet.ModelAndView;
|
||||
|
||||
import java.io.StringReader;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
|
||||
@Controller
|
||||
@@ -73,9 +77,24 @@ public class AccountController {
|
||||
|
||||
@PostMapping("/update_process")
|
||||
@ResponseBody
|
||||
public String updateProcess(AccountDto dto, Gson gson){
|
||||
public String updateProcess(@RequestBody Map<String, Object> data, Gson gson){
|
||||
AuthorityDto personalAuthorityDto= gson.fromJson(data.get("personalAuthorityDto").toString(), AuthorityDto.class);
|
||||
|
||||
accountService.update(dto);
|
||||
|
||||
AccountDto accountDto = gson.fromJson(data.get("account").toString(), AccountDto.class);
|
||||
|
||||
System.out.println(accountDto);
|
||||
System.out.println(personalAuthorityDto);
|
||||
accountService.update(accountDto);
|
||||
authorityService.update(personalAuthorityDto);
|
||||
|
||||
return gson.toJson("s");
|
||||
}
|
||||
|
||||
@PostMapping("/reset_password")
|
||||
@ResponseBody
|
||||
public String resetPassword(AccountDto dto, Gson gson){
|
||||
accountService.resetPassword(dto);
|
||||
|
||||
return gson.toJson("s");
|
||||
}
|
||||
@@ -98,4 +117,15 @@ public class AccountController {
|
||||
return mav;
|
||||
}
|
||||
|
||||
@PostMapping("/show_personal_auth_modal")
|
||||
public ModelAndView showPersonalAuthModal(ModelAndView mav, AuthorityDto dto){
|
||||
//db에서 데이터 가져오는거 필요
|
||||
dto = authorityService.selectById(dto);
|
||||
|
||||
//
|
||||
mav.addObject("dto", dto);
|
||||
mav.setViewName("personal_auth");
|
||||
return mav;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -40,5 +40,4 @@ public class AccountDto {
|
||||
|
||||
@Builder.Default
|
||||
private Boolean activation = true;
|
||||
|
||||
}
|
||||
|
||||
@@ -25,4 +25,8 @@ public interface AccountMapper {
|
||||
List<DepartmentDto> selectDeptAll(Map<String, Object> m);
|
||||
|
||||
List<PositionDto> selectPosAll(Map<String, Object> m);
|
||||
|
||||
int resetPassword(AccountDto dto);
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -57,5 +57,10 @@ public class AccountService {
|
||||
|
||||
return mapper.selectPosAll(map);
|
||||
}
|
||||
int resetPassword(AccountDto dto){
|
||||
return mapper.resetPassword(dto);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -30,9 +30,16 @@ public class AuthorityController {
|
||||
|
||||
@PostMapping("/read")
|
||||
public ModelAndView read(ModelAndView mav, AuthorityDto dto){
|
||||
dto = authorityService.selectById(dto);
|
||||
if( dto.getIsGroupAuthority() ) {
|
||||
dto = authorityService.selectById(dto);
|
||||
|
||||
mav.setViewName("/authority/update_group");
|
||||
}else{
|
||||
dto = authorityService.selectPersonalAuthorityById(dto);
|
||||
mav.setViewName("/authority/update_personal");
|
||||
}
|
||||
mav.addObject("dto", dto);
|
||||
mav.setViewName("/authority/update_group");
|
||||
System.out.println(dto);
|
||||
return mav;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.no1.wms.authority;
|
||||
|
||||
import com.no1.wms.account.AccountDto;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
@@ -18,4 +19,6 @@ public interface AuthorityMapper {
|
||||
int update(AuthorityDto dto);
|
||||
|
||||
List<AuthorityDto> selectAll(Map<String, Object> m);
|
||||
|
||||
AuthorityDto selectPersonalAuthorityById(AuthorityDto dto);
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package com.no1.wms.authority;
|
||||
|
||||
|
||||
import com.no1.wms.account.AccountDto;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@@ -35,4 +36,10 @@ public class AuthorityService {
|
||||
}
|
||||
|
||||
public int update(AuthorityDto dto) { return mapper.update(dto); }
|
||||
|
||||
public AuthorityDto selectPersonalAuthorityById(AuthorityDto dto){
|
||||
return mapper.selectPersonalAuthorityById(dto);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -15,6 +15,8 @@
|
||||
<result column="activation" property="activation"/>
|
||||
<result column="personal_authority_id" property="personalAuthorityId" />
|
||||
<result column="group_authority_id" property="groupAuthorityId" />
|
||||
<result column="department_id" property="departmentId" />
|
||||
<result column="position_id" property="positionId" />
|
||||
<association property="groupAuthorityDto" javaType="authorityDto">
|
||||
<id column="auth2.id" property="id" />
|
||||
<result column="group_auth_name" property="name" />
|
||||
@@ -101,6 +103,11 @@
|
||||
where name like concat('%',#{search},'%')
|
||||
order by name limit #{start}, #{perPage}
|
||||
</select>
|
||||
<update id="resetPassword" parameterType="accountDto">
|
||||
update account SET
|
||||
password = ( SELECT employee_number from account where id = #{id} )
|
||||
WHERE id = #{id}
|
||||
</update>
|
||||
|
||||
<update id="update" parameterType="accountDto">
|
||||
update account SET
|
||||
|
||||
@@ -31,6 +31,16 @@
|
||||
<select id="selectById" resultType="AuthorityDto">
|
||||
SELECT * FROM authority WHERE id = #{id}
|
||||
</select>
|
||||
<select id="selectPersonalAuthorityById" resultMap="authorityResultMap">
|
||||
SELECT
|
||||
auth.id, auth.name,
|
||||
auth.account, auth.authority, auth.product_category, auth.product,
|
||||
auth.prices, auth.vendor, auth.warehouse, auth.stock, auth.plan_in, auth.product_in,
|
||||
auth.product_out, auth.board, auth.activation, auth.is_group_authority,
|
||||
acc.employee_number, acc.name acc_name
|
||||
from authority auth join account acc on acc.personal_authority_id = auth.id
|
||||
WHERE auth.id = #{id}
|
||||
</select>
|
||||
<select id="selectAll" resultMap="authorityResultMap" parameterType="map">
|
||||
SELECT
|
||||
auth.id, auth.name,
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
*/
|
||||
function showSearchModal(title, val){
|
||||
$("#searchModalLabel").text(title);
|
||||
const data = { name : val};
|
||||
const data = { name : val };
|
||||
$.ajax({
|
||||
type : 'post', // 타입 (get, post, put 등등)
|
||||
url : '/account/show_modal', // 요청할 서버url
|
||||
@@ -50,10 +50,8 @@
|
||||
alert(error)
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
</script>
|
||||
<div class="container-fluid">
|
||||
<div class="row">
|
||||
@@ -74,6 +72,7 @@
|
||||
<span class="me-5"></span>
|
||||
<span id='employee_number_label' class="input-group-text">사번</span>
|
||||
<input id=employee_number" name="employeeNumber" type="text" class="create_data form-control" placeholder="" aria-label="Username" aria-describedby="employee_number_label">
|
||||
|
||||
</div>
|
||||
<div class="input-group w-50 mt-3">
|
||||
<span id='account_dept_label' class="input-group-text">부서 명</span>
|
||||
|
||||
@@ -26,6 +26,23 @@
|
||||
$(".c_body").after($form);
|
||||
$form.submit();
|
||||
}
|
||||
function resetPassword(){
|
||||
const data = {};
|
||||
data.id = tid;
|
||||
|
||||
$.ajax({
|
||||
type: 'post', // 타입 (get, post, put 등등)
|
||||
url: '/account/reset_password', // 요청할 서버url
|
||||
dataType: 'json', // 데이터 타입 (html, xml, json, text 등등)
|
||||
data: data,
|
||||
success: function (result) { // 결과 성공 콜백함수
|
||||
alert("비밀번호가 사번으로 변경되었습니다");
|
||||
},
|
||||
error: function (request, status, error) {
|
||||
alert(error)
|
||||
}
|
||||
});
|
||||
}
|
||||
</script>
|
||||
<div class="container-fluid c_body">
|
||||
<div class="row">
|
||||
@@ -45,6 +62,7 @@
|
||||
|
||||
<span class="me-5"></span>
|
||||
<span>사번 : ${dto.employeeNumber}</span>
|
||||
|
||||
</div>
|
||||
<div class="w-50 mt-3">
|
||||
<span>부서 : ${dto.departmentDto.name}</span>
|
||||
@@ -72,6 +90,7 @@
|
||||
</div>
|
||||
<div class="row mt-4">
|
||||
<div class="col-12">
|
||||
<button class="btn btn-primary" id="password_reset_button" onclick="resetPassword()">비밀번호 리셋</button>
|
||||
<button class="btn btn-primary" id="btn_edit" onclick="goUpdate()">수정</button>
|
||||
<button class="btn btn-danger" id="btn_exit" onclick="goList()">뒤로</button>
|
||||
</div>
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
|
||||
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
|
||||
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
|
||||
<!-- 이 안에 내용 복사해서 jsp에 붙여넣기 -->
|
||||
<script>
|
||||
/*
|
||||
@@ -10,6 +11,7 @@
|
||||
alert("재정의 됨");
|
||||
}
|
||||
*/
|
||||
let personalAuthData = null;
|
||||
const tid = '${dto.id}';
|
||||
function showSearchModal(title, val){
|
||||
$("#searchModalLabel").text(title);
|
||||
@@ -28,37 +30,94 @@
|
||||
}
|
||||
});
|
||||
}
|
||||
//다른거하고 달리 auth의 경우 list가 아닌 값을 가져옴
|
||||
function showAuthModal(title, val){
|
||||
if(personalAuthData == null) {
|
||||
$("#searchModalLabel").text(title);
|
||||
const data = {};
|
||||
data.id = $("#personalAuthorityId").val();
|
||||
$.ajax({
|
||||
type: 'post', // 타입 (get, post, put 등등)
|
||||
url: '/account/show_personal_auth_modal', // 요청할 서버url
|
||||
dataType: 'html', // 데이터 타입 (html, xml, json, text 등등)
|
||||
data: data,
|
||||
success: function (result) { // 결과 성공 콜백함수
|
||||
$("#search_modal_body").html(result);
|
||||
searchModalBootStrap.show();
|
||||
},
|
||||
error: function (request, status, error) {
|
||||
alert(error)
|
||||
}
|
||||
});
|
||||
}else{
|
||||
searchModalBootStrap.show();
|
||||
}
|
||||
}
|
||||
|
||||
function updateProcess(){
|
||||
let data = {};
|
||||
data.id = tid;
|
||||
data.activation = $("input[name='activation']:checked").val();
|
||||
data.personalAuthorityDto = {};
|
||||
data.personalAuthorityDto.name = originalAuthorityName;
|
||||
data.personalAuthorityDto.activation = authorityActivation;
|
||||
data.personalAuthorityDto.isGroupAuthority = "false";
|
||||
data.account = {};
|
||||
data.account.id = tid;
|
||||
data.account.activation = $("input[name='activation']:checked").val();
|
||||
const $dataInputList = $("input.create_data");
|
||||
$dataInputList.each(function(index, element){
|
||||
const $element = $(element);
|
||||
const name = $element.attr("name");
|
||||
const val = $element.val();
|
||||
data[name] = val;
|
||||
data.account[name] = '"'+val.trim()+'"';
|
||||
});
|
||||
|
||||
const $checkBoxList = $(".auth_input:checked");
|
||||
$checkBoxList.each(function(index, element){
|
||||
const category = $(element).data('category');
|
||||
if(data.personalAuthorityDto[category] == null){
|
||||
data.personalAuthorityDto[category] = 0;
|
||||
}
|
||||
data.personalAuthorityDto[category] += Number($(element).val());
|
||||
});
|
||||
data.personalAuthorityDto.id = '${dto.personalAuthorityId}';
|
||||
aaa = data;
|
||||
$.ajax({
|
||||
type : 'post', // 타입 (get, post, put 등등)
|
||||
url : '/account/update_process', // 요청할 서버url
|
||||
contentType : "application/json; charset=UTF-8",
|
||||
dataType : 'json', // 데이터 타입 (html, xml, json, text 등등)
|
||||
data : data,
|
||||
data : JSON.stringify(data),
|
||||
success : function(result) { // 결과 성공 콜백함수
|
||||
alert("성공");
|
||||
const $form = $("<form method='post' action='/account/read'><input name='id' value='"+tid+"'></form>")
|
||||
$("#c-body").after($form);
|
||||
$form.submit();
|
||||
},
|
||||
error : function(request, status, error) {
|
||||
alert(error)
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
$(function (){
|
||||
$("#searchModalLabel").text('개인 권한 수정');
|
||||
const data = {};
|
||||
data.id = $("#personalAuthorityId").val();
|
||||
$.ajax({
|
||||
type: 'post', // 타입 (get, post, put 등등)
|
||||
url: '/account/show_personal_auth_modal', // 요청할 서버url
|
||||
dataType: 'html', // 데이터 타입 (html, xml, json, text 등등)
|
||||
data: data,
|
||||
success: function (result) { // 결과 성공 콜백함수
|
||||
$("#search_modal_body").html(result);
|
||||
},
|
||||
error: function (request, status, error) {
|
||||
alert(error)
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
</script>
|
||||
<div class="container-fluid">
|
||||
<div id='c-body' class="container-fluid">
|
||||
<div class="row">
|
||||
<div class="col-12">
|
||||
<div class="mt-5 mb-5 text-center">
|
||||
@@ -104,7 +163,7 @@
|
||||
<span id='account_group_label' class="input-group-text">권한</span>
|
||||
<input value = "${dto.personalAuthorityDto.name}" readonly id="account_auth_group_name" type="text" class="form-control" placeholder="" aria-label="Username" aria-describedby="account_group_label">
|
||||
<input value = "${dto.personalAuthorityId}" hidden name="personalAuthorityId" readonly id="personalAuthorityId" type="text" class="create_data form-control" placeholder="" aria-label="Username" aria-describedby="account_group_label">
|
||||
<button id="account_search_button" class="btn-primary btn" onclick="showSearchModal('권한 검색','auth')">검색</button>
|
||||
<button id="account_search_button" class="btn-primary btn" onclick="showAuthModal('개인 권한 수정','personal_auth')">수정</button>
|
||||
</div>
|
||||
<div class="input-group w-50 mt-3">
|
||||
<span id='account_email_label' class="input-group-text">이메일</span>
|
||||
@@ -118,7 +177,7 @@
|
||||
<input value = "${dto.gender}" id="account_gender" name="gender" type="text" class="create_data form-control" placeholder="" aria-label="Username" aria-describedby="account_gender_label">
|
||||
<span class="me-5"></span>
|
||||
<span id='employee_birth_label' class="input-group-text">생일</span>
|
||||
<input value = "${dto.birth}" id="employee_birth" name="birth" type="date" class="create_data form-control" placeholder="" aria-label="Username" aria-describedby="employee_birth_label">
|
||||
<input value = "<fmt:formatDate value='${dto.birth}' pattern='yyyy-MM-dd' type='date'/>" id="employee_birth" name="birth" type="date" class="create_data form-control" placeholder="" aria-label="Username" aria-describedby="employee_birth_label">
|
||||
</div>
|
||||
<div class="input-group w-50 mt-3">
|
||||
<span id='account_address_label' class="input-group-text">주소</span>
|
||||
|
||||
@@ -24,8 +24,8 @@
|
||||
}
|
||||
});
|
||||
|
||||
$(".group_authority_tr").on("click", function(event){
|
||||
readGroupAuthority($(event.currentTarget).data("tid"));
|
||||
$(".authority_tr").on("click", function(event){
|
||||
readAuthority($(event.currentTarget).data("tid"), $(event.currentTarget).data("tgroup"));
|
||||
});
|
||||
|
||||
|
||||
@@ -44,8 +44,9 @@
|
||||
console.log(JSON.stringify(jsonData));
|
||||
}
|
||||
|
||||
function readGroupAuthority(id){
|
||||
function readAuthority(id, group){
|
||||
$("#formInput").val(id);
|
||||
$("#isGroupInput").val(group);
|
||||
$("#form").attr("action", "/authority/read" );
|
||||
$("#form").trigger("submit");
|
||||
|
||||
@@ -107,7 +108,7 @@
|
||||
<tbody>
|
||||
<c:forEach items="${list }" var="dto" varStatus="status">
|
||||
<c:if test="${dto.isGroupAuthority == false}">
|
||||
<tr>
|
||||
<tr class="authority_tr" data-tid ="${dto.id}" data-tgroup = "${dto.isGroupAuthority}">
|
||||
<td>${dto.accountDto.employeeNumber}</td>
|
||||
<td>${dto.accountDto.name}</td>
|
||||
<td>${dto.name}</td>
|
||||
@@ -131,7 +132,7 @@
|
||||
<tbody>
|
||||
<c:forEach items="${list }" var="dto" varStatus="status">
|
||||
<c:if test="${dto.isGroupAuthority == true}">
|
||||
<tr class="group_authority_tr" data-tid ="${dto.id}">
|
||||
<tr class="authority_tr" data-tid ="${dto.id}" data-tgroup = "${dto.isGroupAuthority}">
|
||||
<td>${status.count}</td>
|
||||
<td>${dto.name}</td>
|
||||
<td>
|
||||
@@ -157,4 +158,5 @@
|
||||
</div>
|
||||
<form id="form" method="post">
|
||||
<input name="id" id="formInput" hidden>
|
||||
<input name="isGroupAuthority" id="isGroupInput" hidden>
|
||||
</form>
|
||||
188
src/main/webapp/WEB-INF/views/authority/update_personal.jsp
Normal file
188
src/main/webapp/WEB-INF/views/authority/update_personal.jsp
Normal file
@@ -0,0 +1,188 @@
|
||||
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
|
||||
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
|
||||
<script>
|
||||
/*
|
||||
yes no 모달의 확인 버튼을 누를때 재정의할 function
|
||||
|
||||
yesNoModal.yesFunction = myYesFunction;
|
||||
function myYesFunction(){
|
||||
alert("재정의 됨");
|
||||
}
|
||||
*/
|
||||
const originalAuthorityName = '${dto.name}';
|
||||
const authorityId = '${dto.id}';
|
||||
const authorityCategoryList = [
|
||||
{'eng' : 'account', 'kor' : '계정', 'value' : ${dto.account}},
|
||||
{'eng':'authority','kor' : '권한', 'value' : ${dto.authority}},
|
||||
{'eng' : 'productCategory', 'kor' : '제품 카테고리', 'value' : ${dto.productCategory}},
|
||||
{'eng': 'product' ,'kor' : '제품', 'value' : ${dto.product}},
|
||||
{'eng':'prices' ,'kor' : '가격', 'value' : ${dto.prices} },
|
||||
{'eng': 'vendor' ,'kor' : '거래처' , 'value' : ${dto.vendor}} ,
|
||||
{'eng':'warehouse' ,'kor' : '창고' , 'value' : ${dto.warehouse}},
|
||||
{'eng': 'stock' ,'kor' : '재고', 'value' : ${dto.stock} } ,
|
||||
{'eng':'planIn' ,'kor' : '입고 예정', 'value' : ${dto.planIn}},
|
||||
{'eng':'productIn' ,'kor' : '입고', 'value' : ${dto.productIn}},
|
||||
{'eng':'productOut' ,'kor' : '출고', 'value' : ${dto.productOut}},
|
||||
{'eng':'board' ,'kor' : '게시판', 'value' : ${dto.board}}
|
||||
]
|
||||
|
||||
/*뒤에서부터 index번째 비트가 1인가 확인하는 기능
|
||||
ex) data : 9(1001), index : 1 = true
|
||||
index : 2 = false
|
||||
index : 3 = false
|
||||
index : 4 = true
|
||||
*/
|
||||
function bitCalcResult(data, index){
|
||||
let v = 1;
|
||||
for(let i = 1 ; i < index; ++i ){
|
||||
v*=2;
|
||||
}
|
||||
return (data & v) > 0;
|
||||
}
|
||||
|
||||
$(function(){
|
||||
const $div_check_box_body = $("#table_check_box_body");
|
||||
authorityCategoryList.reverse().forEach(function(element){
|
||||
$div_check_box_body.after('<tr>' +
|
||||
' <td>'+element.kor+'</td>\n' +
|
||||
' <td><div id="'+element.eng+'_check_read" class="form-check form-check-inline">\n' +
|
||||
' <input class="form-check-input" data-category="'+element.eng+'" type="checkbox" value="8" id="'+element.eng+'_read">\n' +
|
||||
' <label class="form-check-label" for='+element.eng+'_read">\n' +
|
||||
' 읽기\n' +
|
||||
' </label>\n' +
|
||||
' </div>\n' +
|
||||
' <div id="'+element.eng+'_check_write" class="form-check form-check-inline">\n' +
|
||||
' <input class="form-check-input" data-category="'+element.eng+'" type="checkbox" value="4" id="'+element.eng+'_create">\n' +
|
||||
' <label class="form-check-label" for="'+element.eng+'_create">\n' +
|
||||
' 쓰기\n' +
|
||||
' </label>\n' +
|
||||
' </div>\n' +
|
||||
' <div id="'+element.eng+'_check_create" class="form-check form-check-inline">\n' +
|
||||
' <input class="form-check-input" data-category="'+element.eng+'" type="checkbox" value="2" id="'+element.eng+'_update">\n' +
|
||||
' <label class="form-check-label" for="'+element.eng+'_update">\n' +
|
||||
' 수정\n' +
|
||||
' </label>\n' +
|
||||
' </div>\n' +
|
||||
' <div id="'+element.eng+'_check_delete" class="form-check form-check-inline">\n' +
|
||||
' <input class="form-check-input" data-category="'+element.eng+'" type="checkbox" value="1" id="'+element.eng+'_delete">\n' +
|
||||
' <label class="form-check-label" for="'+element.eng+'_delete">\n' +
|
||||
' 삭제\n' +
|
||||
' </label>\n' +
|
||||
' </div></td>\n' +
|
||||
' </tr>');
|
||||
});
|
||||
authorityCategoryList.reverse().forEach(function(element) {
|
||||
|
||||
const value =element.value;
|
||||
if( bitCalcResult(value, 4 ))
|
||||
$("#"+element.eng+"_read").attr('checked', true);
|
||||
if( bitCalcResult(value, 3 ))
|
||||
$("#"+element.eng+"_create").attr('checked', true);
|
||||
if( bitCalcResult(value, 2 ))
|
||||
$("#"+element.eng+"_update").attr('checked', true);
|
||||
if( bitCalcResult(value, 1 ))
|
||||
$("#"+element.eng+"_delete").attr('checked', true);
|
||||
});
|
||||
|
||||
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
function onAuthorityUpdateProcess(){
|
||||
|
||||
let data = {};
|
||||
data.name = originalAuthorityName;
|
||||
const $checkBoxList = $("input[type='checkbox']:checked");
|
||||
$checkBoxList.each(function(index, element){
|
||||
const category = $(element).data('category');
|
||||
if(data[category] == null){
|
||||
data[category] = 0;
|
||||
}
|
||||
data[category] += Number($(element).val());
|
||||
});
|
||||
data['isGroupAuthority'] = false;
|
||||
data['activation'] = $('input[name="activation"]:checked').val();
|
||||
data['id'] = authorityId;
|
||||
console.log(data);
|
||||
$.ajax({
|
||||
type : 'post', // 타입 (get, post, put 등등)
|
||||
url : '/authority/update_process', // 요청할 서버url
|
||||
dataType : 'json', // 데이터 타입 (html, xml, json, text 등등)
|
||||
data : data,
|
||||
success : function(result) { // 결과 성공 콜백함수
|
||||
if(result){
|
||||
const $form = $("<form method='get' action='/authority/list'></form>");
|
||||
$(".temp").after($form);
|
||||
$form.submit();
|
||||
}else{
|
||||
alert("업데이트 중에 오류기 발생하였습니다");
|
||||
}
|
||||
},
|
||||
error : function(request, status, error) {
|
||||
alert(error)
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
</script>
|
||||
<div class="temp row">
|
||||
<div class="col-12">
|
||||
<div class="mt-5 mb-5 text-center">
|
||||
<h1>개인 권한 수정</h1>
|
||||
</div>
|
||||
<div>
|
||||
<hr>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-12">
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="container">
|
||||
<div class="row">
|
||||
<div class="col-12">
|
||||
<span class="me-5">사용자 명 ${dto.accountDto.name}</span>
|
||||
<span>사번 ${dto.accountDto.employeeNumber}</span>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-2">
|
||||
활성 여부
|
||||
</div>
|
||||
<div class="col-10">
|
||||
<div class="form-check form-check-inline">
|
||||
<input class="form-check-input" type="radio" name="activation" id="inlineRadio1" value="true" <c:if test="${dto.activation == true}"> checked</c:if>>
|
||||
<label class="form-check-label" for="inlineRadio1">활성</label>
|
||||
</div>
|
||||
<div class="form-check form-check-inline">
|
||||
<input class="form-check-input" type="radio" name="activation" id="inlineRadio2" value="false" <c:if test="${dto.activation == false}"> checked</c:if>>
|
||||
<label class="form-check-label" for="inlineRadio2">비활성</label>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-12">
|
||||
<table class="table">
|
||||
<tbody id="table_check_box_body">
|
||||
|
||||
</tbody>
|
||||
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-12">
|
||||
<button class="btn btn-primary" onclick="onAuthorityUpdateProcess()">수정</button>
|
||||
<button class="btn btn-primary" onclick="window.history.back()">뒤로</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
100
src/main/webapp/WEB-INF/views/modal/personal_auth.jsp
Normal file
100
src/main/webapp/WEB-INF/views/modal/personal_auth.jsp
Normal file
@@ -0,0 +1,100 @@
|
||||
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
|
||||
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
|
||||
<script>
|
||||
var originalAuthorityName = '${dto.name}';
|
||||
var authorityId = '${dto.id}';
|
||||
var authorityActivation = '${dto.activation}'
|
||||
personalAuthData = [
|
||||
{'eng' : 'account', 'kor' : '계정', 'value' : ${dto.account}},
|
||||
{'eng':'authority','kor' : '권한', 'value' : ${dto.authority}},
|
||||
{'eng' : 'productCategory', 'kor' : '제품 카테고리', 'value' : ${dto.productCategory}},
|
||||
{'eng': 'product' ,'kor' : '제품', 'value' : ${dto.product}},
|
||||
{'eng':'prices' ,'kor' : '가격', 'value' : ${dto.prices} },
|
||||
{'eng': 'vendor' ,'kor' : '거래처' , 'value' : ${dto.vendor}} ,
|
||||
{'eng':'warehouse' ,'kor' : '창고' , 'value' : ${dto.warehouse}},
|
||||
{'eng': 'stock' ,'kor' : '재고', 'value' : ${dto.stock} } ,
|
||||
{'eng':'planIn' ,'kor' : '입고 예정', 'value' : ${dto.planIn}},
|
||||
{'eng':'productIn' ,'kor' : '입고', 'value' : ${dto.productIn}},
|
||||
{'eng':'productOut' ,'kor' : '출고', 'value' : ${dto.productOut}},
|
||||
{'eng':'board' ,'kor' : '게시판', 'value' : ${dto.board}}
|
||||
]
|
||||
|
||||
$(function(){
|
||||
|
||||
|
||||
const $div_check_box_body = $("#table_check_box_body");
|
||||
personalAuthData.reverse().forEach(function(element){
|
||||
$div_check_box_body.after('<tr>' +
|
||||
' <td>'+element.kor+'</td>\n' +
|
||||
' <td><div id="'+element.eng+'_check_read" class="form-check form-check-inline">\n' +
|
||||
' <input class="auth_input form-check-input" data-category="'+element.eng+'" type="checkbox" value="8" id="'+element.eng+'_read">\n' +
|
||||
' <label class="form-check-label" for='+element.eng+'_read">\n' +
|
||||
' 읽기\n' +
|
||||
' </label>\n' +
|
||||
' </div>\n' +
|
||||
' <div id="'+element.eng+'_check_write" class="form-check form-check-inline">\n' +
|
||||
' <input class="auth_input form-check-input" data-category="'+element.eng+'" type="checkbox" value="4" id="'+element.eng+'_create">\n' +
|
||||
' <label class="form-check-label" for="'+element.eng+'_create">\n' +
|
||||
' 쓰기\n' +
|
||||
' </label>\n' +
|
||||
' </div>\n' +
|
||||
' <div id="'+element.eng+'_check_create" class="form-check form-check-inline">\n' +
|
||||
' <input class="auth_input form-check-input" data-category="'+element.eng+'" type="checkbox" value="2" id="'+element.eng+'_update">\n' +
|
||||
' <label class="form-check-label" for="'+element.eng+'_update">\n' +
|
||||
' 수정\n' +
|
||||
' </label>\n' +
|
||||
' </div>\n' +
|
||||
' <div id="'+element.eng+'_check_delete" class="form-check form-check-inline">\n' +
|
||||
' <input class="auth_input form-check-input" data-category="'+element.eng+'" type="checkbox" value="1" id="'+element.eng+'_delete">\n' +
|
||||
' <label class="form-check-label" for="'+element.eng+'_delete">\n' +
|
||||
' 삭제\n' +
|
||||
' </label>\n' +
|
||||
' </div></td>\n' +
|
||||
' </tr>');
|
||||
});
|
||||
personalAuthData.reverse().forEach(function(element) {
|
||||
|
||||
const value =element.value;
|
||||
if( bitCalcResult(value, 4 ))
|
||||
$("#"+element.eng+"_read").attr('checked', true);
|
||||
if( bitCalcResult(value, 3 ))
|
||||
$("#"+element.eng+"_create").attr('checked', true);
|
||||
if( bitCalcResult(value, 2 ))
|
||||
$("#"+element.eng+"_update").attr('checked', true);
|
||||
if( bitCalcResult(value, 1 ))
|
||||
$("#"+element.eng+"_delete").attr('checked', true);
|
||||
});
|
||||
|
||||
|
||||
});
|
||||
|
||||
function authChange(){
|
||||
hideSearchModal();
|
||||
}
|
||||
function bitCalcResult(data, index){
|
||||
let v = 1;
|
||||
for(let i = 1 ; i < index; ++i ){
|
||||
v*=2;
|
||||
}
|
||||
return (data & v) > 0;
|
||||
}
|
||||
</script>
|
||||
<div class="row">
|
||||
<div class="container">
|
||||
<div class="row">
|
||||
<div class="col-12">
|
||||
<table class="table">
|
||||
<tbody id="table_check_box_body">
|
||||
|
||||
</tbody>
|
||||
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-12">
|
||||
<button class="btn btn-primary" onclick="authChange()">닫기</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
Reference in New Issue
Block a user