본문 바로가기
개발/개인

function userUpdateModalShow(emp,title) // 사용자 정보 상세보기 - 정보수정부분전체

by areumtb 2016. 12. 1.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
 
//사용자 정보수정 버튼 클릭
$("#userUpdate_Btn").click(function(){
    var rowid =$("#list2").getGridParam('selarrrow');
    if(rowid == ""){
        alert("수정할 데이터를 선택해주세요 ");
    }/*else if(rowid.length == 1){ 
        var row = JSON.stringify($("#list2").getRowData(rowid));
        var arr = JSON.parse(row);
        var dcode = arr.dcode;
        $("#userModal_GridBtn").click();
        userUpdateModalconfirm_Btn(dcode);
    }*/else if(rowid.length >= 1){ 
        console.log("사용자 정보 다중수정");
        var dcode = new Array();
        for (var i = 0; i < rowid.length; i++) {
            rows = JSON.stringify($("#list2").getRowData(rowid[i]));
            dcode.push(JSON.parse(rows).dcode);
        }
        $("#userModal_GridBtn").click();
        userUpdateModalconfirmMult_Btn(dcode,rowid);
    }
});
 
cs


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
/*
 * //사용자 정보수정confirm - 화면에서 수정버튼 클릭시 
function userUpdateModalconfirm_Btn(dcode){
    console.log("dcode "+dcode);
    if(confirm("수정하시겠습니까?")==true){
        modalFormClean(); // 모델 초기화
        userUpdateModal(dcode);
    }else {
        console.log("수정취소 ");
        $("#close").click();
    }
}
//사용자 정보수정confirm
function userUpdateModalconfirm(dcode){
    console.log("dcode "+dcode);
    if(confirm("수정하시겠습니까?")==true){
        modalFormClean(); // 모델 초기화
        userUpdateModal(dcode);
    }else {
        console.log("수정취소 ");
    }
}
function userUpdateModal(dcode){
    console.log("수정을 시작합시다. "+dcode);
    $.ajax({
        type : "POST",
        url:"/library/userUpdateSelect.do",
        dataType:"html",
        async:true,
        data:{"dcode":dcode},
        contentType: "application/json",
        success: function (data){             
            var emp = data;
            var title = {};
                title.title = "사용자 정보수정";
                title.formClass = "user_UpdatePopup";
            userUpdateModalShow(emp,title);
        },error:function(request,status,error){
            console.log("code:"+request.status+"\n"+"message:"
                    +request.responseText+"\n"+"error:"+error);
            alert("실패");
        }
    });    
}
// 사용자 정보 상세보기 - 정보수정
function userUpdateModalShow(emp,title){
    console.log(emp+" "+title);
    var modalTitle = title;
    var data = JSON.parse(emp);
    //var dcode = data.dcode;
    if(data.note==null){data.note="";}
    
    $("#modal_insertForm").attr("class",modalTitle.formClass);// form에 추가할 class
    
    $(".modal-title").html(
            "<strong>"+modalTitle.title+"</strong>" 
    );
    
    //사원정보 수정 
    $("#grid_list_modal").html(
            "<li hidden>"+data.ucode+"</li>"+
            "<input type='hidden' name='UCODE' id='UCODE_update'value='"+data.ucode+"'>"+
            "<li>" +
            "<label>사원ID</label>  "+
            "<input type='text' name='ename' id='ENAME_update' readonly='readonly' value='"+data.ename+"'>"+
            "<label>자택정보</label>"+
            "<input type='text' name='address' id='ADDRESS_update' value='"+data.address+"'>"+
            "</li>"+
            "<li>" +
            "<label>이름</label>"+
            "<input type='text' name='name' id='NAME_update' value='"+data.name+"'>"+
            "<label>사원번호</label>"+
            "<input type='text' name='dcode' id='DCODE_update' readonly='readonly' value='"+data.dcode+"'>"+
            "</li>"+
            "<li>" +
            "<label>부서</label>"+
                "<select name='department' id='DEPARTMENT_update'>"+
                "<option value='DEPT01' >도서관관리팀</option>"+
                "<option value='DEPT02' >일본사업팀 </option>"+
                "<option value='DEPT03' >디자인팀  </option>"+
                "<option value='DEPT04' >자료관리팀 </option>"+
                "</select>"+
            "<label>직급</label>"+
                "<select name='position' id='POSITION_update'>"+
                "<option value='W_PO1' >사원 </option>"+
                "<option value='W_PO2' >선임</option>"+
                "<option value='W_PO3' >책임 </option>"+
                "<option value='W_PO4' >과장 </option>"+
                "<option value='W_PO5' >차장 </option>"+
                "<option value='W_PO6' >팀장 </option>"+
                "<option value='W_PO7' >이사 </option>"+
                "</select>"+
            "</li>"+
            "<li>" +
            "<label>생년월일</label>"+
            "<input type='text' name='birthday' id='birthday_piker' value='"+data.birthday+"' >"+ //value='birthday"+data.birthday    +" '
            "<label>입사일</label>"+
            "<input type='text' name='bireday'  id='bireday_piker' value='"+data.bireday+"' >"+ //value='"+data.bireday    +" '
            "</li>"+
            "<li>" +
            "<label>전화번호</label>"+
            "<input type='text' name='phone' id='PHONE_update' value='"+data.phone+"'>"+
            "<label>내선번호</label>"+
            "<input type='text' name='exnum' id='EXNUM_update' value='"+data.exnum+"'>"+
            "</li>"+
            "<li>" +
            "<label>이메일</label>"+
            "<input type='text' name='email' id='EMAIL_update' value='"+data.email+"'>"+
            "<label>사원상태</label>"+
                "<select name='present' id='PRESENT_update'>"+
                "<option value='W_PE1' >정상회원</option>"+
                "<option value='W_PE2' >대출정지</option>"+
                "<option value='W_PE3' >관리자</option>"+
                "</select>"+
            "</li>"+
            "<li>" +
            "<label>비고</label>"+
            "<input type='text' name='note' id='NOTE_update' value='"+data.note+"'>"+
            "</li>"
    );
    
    $("#DEPARTMENT_update").val(data.department).attr("selected", "selected");
    $("#PRESENT_update").val(data.present).attr("selected", "selected");
    $("#POSITION_update").val(data.position).attr("selected", "selected");
    
    $("#birthday_piker , #bireday_piker").datepicker({
              dateFormat: "yy-mm-dd" // 만약 2011년 4월 29일 선택하면  inputbox 에 '2011/04/29' 로표시
              , changeMonth: true // 월선택 select box 표시 (기본은 false)
              ,changeYear: true  // 년선택 selectbox 표시 (기본은 false)
              ,monthNames: ['1월', '2월', '3월', '4월', '5월', '6월', '7월', '8월', '9월', '10월', '11월', '12월']
              ,monthNamesShort: ['1월', '2월', '3월', '4월', '5월', '6월', '7월', '8월', '9월', '10월', '11월', '12월']
              ,dayNames: ['일', '월', '화', '수', '목', '금', '토']
              ,dayNamesShort: ['일', '월', '화', '수', '목', '금', '토']
              ,dayNamesMin: ['일', '월', '화', '수', '목', '금', '토']
              ,showMonthAfterYear: true
              ,yearSuffix: '년'
        });
    
    //사용자 정보 수정 - 사원번호 , 아이디 클릭시 팝업창 발생
    $("#DCODE_update").on("click",DCODE_update);
    function DCODE_update(){
        alert("사원번호는 수정하실 수 없습니다.");
    }
    $("#ENAME_update").on("click",ENAME_update);
    function ENAME_update(){
        alert("사원ID는 수정하실 수 없습니다.");
    }
    listCss();
    $("#popup_btn").html(
            "<button type='button' id='close' class='btn btn-default' data-dismiss='modal'>닫기</button>"+
            "<button type='button' id='deleteModel' class='btn btn-default' data-dismiss='' >삭제하기</button>"+
            "<button type='button' id='updataSaveModal' class='btn btn-default' data-dismiss='' >수정하기</button>"
    );
    $("#updataSaveModal").click(function(){
        alert("수정내용을 저장합니다");
        var dcode = data.dcode;
        var user = $(".user_UpdatePopup").serialize(); //나중에 다시시도하기
        userUpdateSave(user,dcode);
        });
    
    $("#deleteModel").click(function(){
        var DCODE = data.dcode;
        userDelete(DCODE);
        $("#close").click();
        });
}
*/
cs


댓글