Commit b76550030bda1d3fb19bc2582bc3476e61068f95
1 parent
60300479
1.user POST时数据覆盖丢失
Showing
1 changed file
with
229 additions
and
221 deletions
src/main/resources/static/pages/permission/user/edit.html
| 1 | -<div class="page-head"> | ||
| 2 | - <div class="page-title"> | ||
| 3 | - <h1>编辑用户</h1> | ||
| 4 | - </div> | ||
| 5 | -</div> | ||
| 6 | - | ||
| 7 | -<ul class="page-breadcrumb breadcrumb"> | ||
| 8 | - <li><a href="/pages/home.html" data-pjax>首页</a> <i class="fa fa-circle"></i></li> | ||
| 9 | - <li><span class="active">权限管理</span> <i class="fa fa-circle"></i></li> | ||
| 10 | - <li><a href="list.html" data-pjax>用户管理</a> <i class="fa fa-circle"></i></li> | ||
| 11 | - <li><span class="active">编辑用户</span></li> | ||
| 12 | -</ul> | ||
| 13 | - | ||
| 14 | -<div class="portlet light bordered"> | ||
| 15 | - <div class="portlet-title"> | ||
| 16 | - <div class="caption"> | ||
| 17 | - <i class="icon-equalizer font-red-sunglo"></i> <span | ||
| 18 | - class="caption-subject font-red-sunglo bold uppercase">表单</span> | ||
| 19 | - </div> | ||
| 20 | - </div> | ||
| 21 | - <div class="portlet-body form"> | ||
| 22 | - <form action="/addUser" class="form-horizontal" id="user_edit_form" > | ||
| 23 | - <div class="alert alert-danger display-hide"> | ||
| 24 | - <button class="close" data-close="alert"></button> | ||
| 25 | - 您的输入有误,请检查下面的输入项 | ||
| 26 | - </div> | ||
| 27 | - <div class="form-body"> | ||
| 28 | - <div class="form-group"> | ||
| 29 | - <label class="col-md-3 control-label">登录名</label> | ||
| 30 | - <div class="col-md-4"> | ||
| 31 | - <input type="hidden" id="id" name="id"> | ||
| 32 | - <input type="text" class="form-control" id="userName" name="userName" readonly="readonly"> | ||
| 33 | - <span class="help-block"> 登录时的帐号</span> | ||
| 34 | - </div> | ||
| 35 | - </div> | ||
| 36 | - <div class="form-group"> | ||
| 37 | - <label class="col-md-3 control-label">姓名</label> | ||
| 38 | - <div class="col-md-4"> | ||
| 39 | - <input type="text" class="form-control" id="name" name="name" readonly="readonly"> | ||
| 40 | - </div> | ||
| 41 | - </div> | ||
| 42 | - <div class="form-group"> | ||
| 43 | - <label class="col-md-3 control-label">所属机构</label> | ||
| 44 | - <div class="col-md-4"> | ||
| 45 | - <input type="text" class="form-control" id="agencies" name="agencies" > | ||
| 46 | - </div> | ||
| 47 | - </div> | ||
| 48 | - | ||
| 49 | - <div class="form-group"> | ||
| 50 | - <label class="col-md-3 control-label">角色</label> | ||
| 51 | - <div class="col-md-4"> | ||
| 52 | - <select class="form-control" id="role" name="roles[]" style="width: 160px;" multiple="multiple"> | ||
| 53 | - | ||
| 54 | - </select> | ||
| 55 | - </div> | ||
| 56 | - </div> | ||
| 57 | - | ||
| 58 | - <div class="form-group"> | ||
| 59 | - <label class="col-md-3 control-label">是否启用</label> | ||
| 60 | - <div class="col-md-4"> | ||
| 61 | - <div class="input-group"> | ||
| 62 | - <select class="form-control" id="enabled" name="enabled" style="width: 160px;"> | ||
| 63 | - <option value="1">可用</option> | ||
| 64 | - <option value="0">禁用</option> | ||
| 65 | - </select> | ||
| 66 | - </div> | ||
| 67 | - </div> | ||
| 68 | - </div> | ||
| 69 | - </div> | ||
| 70 | - <div> | ||
| 71 | - <!--<iframe src="authorize.html?origin=real_control_iframe" frameborder="0" style="height: 600px;width: 100%;"></iframe>--> | ||
| 72 | - </div> | ||
| 73 | - <div class="form-actions"> | ||
| 74 | - <div class="row"> | ||
| 75 | - <div class="col-md-offset-3 col-md-4"> | ||
| 76 | - <!--<a href="main.html" class="btn green" id="nextStep" ><i class="fa fa-check"></i> 下一步</a>--> | ||
| 77 | - <button type="submit" class="btn green" ><i class="fa fa-check"></i> 提交</button> | ||
| 78 | - <a type="button" class="btn default" href="list.html" data-pjax><i class="fa fa-times"></i> 取消</a> | ||
| 79 | - </div> | ||
| 80 | - </div> | ||
| 81 | - </div> | ||
| 82 | - </form> | ||
| 83 | - <!-- END FORM--> | ||
| 84 | - </div> | ||
| 85 | -</div> | ||
| 86 | - | ||
| 87 | -<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true" style="display: none;left: 50%; | ||
| 88 | - top: 50%;transform: translate(-50%,-50%);min-width:50%;overflow: visible;bottom: inherit; right: inherit;"> | ||
| 89 | - <div class="modal-dialog"> | ||
| 90 | - <div class="modal-content"> | ||
| 91 | - <div class="modal-body" style="text-align: center;"></div> | ||
| 92 | - <div class="modal-footer" style="margin: 0 auto;"> | ||
| 93 | - <center> | ||
| 94 | - <button type="button" class="btn btn-primary" data-dismiss="modal" id="noNext" style="margin-right: 20%;padding:5px 35px;background-color: #337AB7;color: white;"> 完 成 </button> | ||
| 95 | - <button type="button" class="btn btn-primary" id="yesNext">继续配置授权</button> | ||
| 96 | - </center> | ||
| 97 | - </div> | ||
| 98 | - </div><!-- /.modal-content --> | ||
| 99 | - </div><!-- /.modal --> | ||
| 100 | -</div> | ||
| 101 | -<script> | ||
| 102 | - $(function(){ | ||
| 103 | - var id = $.url().param('no'); | ||
| 104 | - if(id){ | ||
| 105 | - $get('/user/'+id,null,function(obj){ | ||
| 106 | - $("#id").attr('value',obj.id); | ||
| 107 | - $("#userName").attr('value',obj.userName); | ||
| 108 | - $("#name").attr('value',obj.name); | ||
| 109 | - $("#agencies").attr('value',obj.agencies); | ||
| 110 | - /*$get('/role/all',null,function(result){ | ||
| 111 | - $.each(result,function(i,r){ | ||
| 112 | - $("#role").append("<option value='"+r.id+"'>"+r.roleName+"</option>"); | ||
| 113 | - }); | ||
| 114 | - $.each(obj.roles,function(i,obt){ | ||
| 115 | - $("#role option[value="+obt.id+"]").attr("selected",true); | ||
| 116 | - }); | ||
| 117 | - });*/ | ||
| 118 | - // 查询下级角色 | ||
| 119 | - $.get('/role/findSubordinate', function (rs) { | ||
| 120 | - if(rs.status == "SUCCESS"){ | ||
| 121 | - $.each(rs.list,function(i,obj){ | ||
| 122 | - $("#role").append("<option value='"+obj.id+"'>"+obj.roleName+"</option>"); | ||
| 123 | - }); | ||
| 124 | - } | ||
| 125 | - $.each(obj.roles,function(i,obt){ | ||
| 126 | - $("#role option[value="+obt.id+"]").attr("selected",true); | ||
| 127 | - }); | ||
| 128 | - }); | ||
| 129 | - if(obj.enabled){ | ||
| 130 | - $("#enabled option[value=1]").attr("selected",true); | ||
| 131 | - }else{ | ||
| 132 | - $("#enabled option[value=0]").attr("selected",true); | ||
| 133 | - } | ||
| 134 | - }); | ||
| 135 | - | ||
| 136 | - }else { | ||
| 137 | - | ||
| 138 | - // 缺少ID | ||
| 139 | - layer.confirm('【ID缺失,请点击返回,重新进行修改操作】', {btn : [ '返回' ],icon: 3, title:'提示'}, function(index){ | ||
| 140 | - | ||
| 141 | - // 关闭弹出层 | ||
| 142 | - layer.close(index); | ||
| 143 | - | ||
| 144 | - // 跳转到list页面 | ||
| 145 | - loadPage('list.html'); | ||
| 146 | - | ||
| 147 | - }); | ||
| 148 | - } | ||
| 149 | - | ||
| 150 | - var form = $('#user_edit_form'); | ||
| 151 | - var error = $('.alert-danger', form); | ||
| 152 | - | ||
| 153 | - //表单 validate | ||
| 154 | - form.validate({ | ||
| 155 | - errorElement : 'span', | ||
| 156 | - errorClass : 'help-block help-block-error', | ||
| 157 | - focusInvalid : false, | ||
| 158 | - rules : { | ||
| 159 | - 'userName' : { | ||
| 160 | - required : true, | ||
| 161 | - maxlength: 25 | ||
| 162 | - }, | ||
| 163 | - 'name' : { | ||
| 164 | - required : true, | ||
| 165 | - maxlength: 25 | ||
| 166 | - }, | ||
| 167 | - 'role' : { | ||
| 168 | - required : true, | ||
| 169 | - minlength: 1 | ||
| 170 | - } | ||
| 171 | - }, | ||
| 172 | - invalidHandler : function(event, validator) { | ||
| 173 | - error.show(); | ||
| 174 | - App.scrollTo(error, -200); | ||
| 175 | - }, | ||
| 176 | - | ||
| 177 | - highlight : function(element) { | ||
| 178 | - $(element).closest('.form-group').addClass('has-error'); | ||
| 179 | - }, | ||
| 180 | - | ||
| 181 | - unhighlight : function(element) { | ||
| 182 | - $(element).closest('.form-group').removeClass('has-error'); | ||
| 183 | - }, | ||
| 184 | - | ||
| 185 | - success : function(label) { | ||
| 186 | - label.closest('.form-group').removeClass('has-error'); | ||
| 187 | - }, | ||
| 188 | - | ||
| 189 | - submitHandler : function(f) { | ||
| 190 | - var params = form.serializeJSON(); | ||
| 191 | - error.hide(); | ||
| 192 | - console.log(params); | ||
| 193 | - | ||
| 194 | - //检查一下用户是否存在 | ||
| 195 | - $.ajax({ | ||
| 196 | - url: '/user', | ||
| 197 | - type: 'POST', | ||
| 198 | - traditional: true, | ||
| 199 | - data: params, | ||
| 200 | - success: function(res){ | ||
| 201 | - layer.msg('修改用户信息成功.'); | ||
| 202 | - $('#myModal').modal(); | ||
| 203 | - //loadPage('list.html'); | ||
| 204 | - } | ||
| 205 | - }); | ||
| 206 | - } | ||
| 207 | - }); | ||
| 208 | - | ||
| 209 | - $('#noNext').click(function () { | ||
| 210 | - $('#myModal').modal('hide'); | ||
| 211 | - $('.modal-backdrop').remove(); | ||
| 212 | - | ||
| 213 | - loadPage('list.html'); | ||
| 214 | - }) | ||
| 215 | - $('#yesNext').click(function () { | ||
| 216 | - var storage = window.localStorage; | ||
| 217 | - storage.setItem("editUser",$('#id').val()); | ||
| 218 | - $('#myModal').modal('hide'); | ||
| 219 | - window.location.href='main.html' | ||
| 220 | - }) | ||
| 221 | - }); | 1 | +<div class="page-head"> |
| 2 | + <div class="page-title"> | ||
| 3 | + <h1>编辑用户</h1> | ||
| 4 | + </div> | ||
| 5 | +</div> | ||
| 6 | + | ||
| 7 | +<ul class="page-breadcrumb breadcrumb"> | ||
| 8 | + <li><a href="/pages/home.html" data-pjax>首页</a> <i class="fa fa-circle"></i></li> | ||
| 9 | + <li><span class="active">权限管理</span> <i class="fa fa-circle"></i></li> | ||
| 10 | + <li><a href="list.html" data-pjax>用户管理</a> <i class="fa fa-circle"></i></li> | ||
| 11 | + <li><span class="active">编辑用户</span></li> | ||
| 12 | +</ul> | ||
| 13 | + | ||
| 14 | +<div class="portlet light bordered"> | ||
| 15 | + <div class="portlet-title"> | ||
| 16 | + <div class="caption"> | ||
| 17 | + <i class="icon-equalizer font-red-sunglo"></i> <span | ||
| 18 | + class="caption-subject font-red-sunglo bold uppercase">表单</span> | ||
| 19 | + </div> | ||
| 20 | + </div> | ||
| 21 | + <div class="portlet-body form"> | ||
| 22 | + <form action="/addUser" class="form-horizontal" id="user_edit_form" > | ||
| 23 | + <div class="alert alert-danger display-hide"> | ||
| 24 | + <button class="close" data-close="alert"></button> | ||
| 25 | + 您的输入有误,请检查下面的输入项 | ||
| 26 | + </div> | ||
| 27 | + <div class="form-body"> | ||
| 28 | + <div class="form-group"> | ||
| 29 | + <label class="col-md-3 control-label">登录名</label> | ||
| 30 | + <div class="col-md-4"> | ||
| 31 | + <input type="hidden" id="id" name="id"> | ||
| 32 | + <input type="hidden" id="jobCode" name="jobCode"> | ||
| 33 | + <input type="hidden" id="realName" name="realName"> | ||
| 34 | + <input type="hidden" id="lastPwdDate" name="lastPwdDate"> | ||
| 35 | + <input type="hidden" id="pwdValidPeriod" name="pwdValidPeriod"> | ||
| 36 | + <input type="text" class="form-control" id="userName" name="userName" readonly="readonly"> | ||
| 37 | + <span class="help-block"> 登录时的帐号</span> | ||
| 38 | + </div> | ||
| 39 | + </div> | ||
| 40 | + <div class="form-group"> | ||
| 41 | + <label class="col-md-3 control-label">姓名</label> | ||
| 42 | + <div class="col-md-4"> | ||
| 43 | + <input type="text" class="form-control" id="name" name="name" readonly="readonly"> | ||
| 44 | + </div> | ||
| 45 | + </div> | ||
| 46 | + <div class="form-group"> | ||
| 47 | + <label class="col-md-3 control-label">所属机构</label> | ||
| 48 | + <div class="col-md-4"> | ||
| 49 | + <input type="text" class="form-control" id="agencies" name="agencies" > | ||
| 50 | + </div> | ||
| 51 | + </div> | ||
| 52 | + | ||
| 53 | + <div class="form-group"> | ||
| 54 | + <label class="col-md-3 control-label">角色</label> | ||
| 55 | + <div class="col-md-4"> | ||
| 56 | + <select class="form-control" id="role" name="roles[]" style="width: 160px;" multiple="multiple"> | ||
| 57 | + | ||
| 58 | + </select> | ||
| 59 | + </div> | ||
| 60 | + </div> | ||
| 61 | + | ||
| 62 | + <div class="form-group"> | ||
| 63 | + <label class="col-md-3 control-label">是否启用</label> | ||
| 64 | + <div class="col-md-4"> | ||
| 65 | + <div class="input-group"> | ||
| 66 | + <select class="form-control" id="enabled" name="enabled" style="width: 160px;"> | ||
| 67 | + <option value="1">可用</option> | ||
| 68 | + <option value="0">禁用</option> | ||
| 69 | + </select> | ||
| 70 | + </div> | ||
| 71 | + </div> | ||
| 72 | + </div> | ||
| 73 | + </div> | ||
| 74 | + <div> | ||
| 75 | + <!--<iframe src="authorize.html?origin=real_control_iframe" frameborder="0" style="height: 600px;width: 100%;"></iframe>--> | ||
| 76 | + </div> | ||
| 77 | + <div class="form-actions"> | ||
| 78 | + <div class="row"> | ||
| 79 | + <div class="col-md-offset-3 col-md-4"> | ||
| 80 | + <!--<a href="main.html" class="btn green" id="nextStep" ><i class="fa fa-check"></i> 下一步</a>--> | ||
| 81 | + <button type="submit" class="btn green" ><i class="fa fa-check"></i> 提交</button> | ||
| 82 | + <a type="button" class="btn default" href="list.html" data-pjax><i class="fa fa-times"></i> 取消</a> | ||
| 83 | + </div> | ||
| 84 | + </div> | ||
| 85 | + </div> | ||
| 86 | + </form> | ||
| 87 | + <!-- END FORM--> | ||
| 88 | + </div> | ||
| 89 | +</div> | ||
| 90 | + | ||
| 91 | +<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true" style="display: none;left: 50%; | ||
| 92 | + top: 50%;transform: translate(-50%,-50%);min-width:50%;overflow: visible;bottom: inherit; right: inherit;"> | ||
| 93 | + <div class="modal-dialog"> | ||
| 94 | + <div class="modal-content"> | ||
| 95 | + <div class="modal-body" style="text-align: center;"></div> | ||
| 96 | + <div class="modal-footer" style="margin: 0 auto;"> | ||
| 97 | + <center> | ||
| 98 | + <button type="button" class="btn btn-primary" data-dismiss="modal" id="noNext" style="margin-right: 20%;padding:5px 35px;background-color: #337AB7;color: white;"> 完 成 </button> | ||
| 99 | + <button type="button" class="btn btn-primary" id="yesNext">继续配置授权</button> | ||
| 100 | + </center> | ||
| 101 | + </div> | ||
| 102 | + </div><!-- /.modal-content --> | ||
| 103 | + </div><!-- /.modal --> | ||
| 104 | +</div> | ||
| 105 | +<script> | ||
| 106 | + $(function(){ | ||
| 107 | + var id = $.url().param('no'); | ||
| 108 | + if(id){ | ||
| 109 | + $get('/user/'+id,null,function(obj){ | ||
| 110 | + $("#id").attr('value',obj.id); | ||
| 111 | + $("#userName").attr('value',obj.userName); | ||
| 112 | + $("#name").attr('value',obj.name); | ||
| 113 | + $("#agencies").attr('value',obj.agencies); | ||
| 114 | + $("#jobCode").attr('value',obj.jobCode); | ||
| 115 | + $("#realName").attr('value',obj.realName); | ||
| 116 | + $("#lastPwdDate").attr('value',obj.lastPwdDate); | ||
| 117 | + $("#pwdValidPeriod").attr('value',obj.pwdValidPeriod); | ||
| 118 | + /*$get('/role/all',null,function(result){ | ||
| 119 | + $.each(result,function(i,r){ | ||
| 120 | + $("#role").append("<option value='"+r.id+"'>"+r.roleName+"</option>"); | ||
| 121 | + }); | ||
| 122 | + $.each(obj.roles,function(i,obt){ | ||
| 123 | + $("#role option[value="+obt.id+"]").attr("selected",true); | ||
| 124 | + }); | ||
| 125 | + });*/ | ||
| 126 | + // 查询下级角色 | ||
| 127 | + $.get('/role/findSubordinate', function (rs) { | ||
| 128 | + if(rs.status == "SUCCESS"){ | ||
| 129 | + $.each(rs.list,function(i,obj){ | ||
| 130 | + $("#role").append("<option value='"+obj.id+"'>"+obj.roleName+"</option>"); | ||
| 131 | + }); | ||
| 132 | + } | ||
| 133 | + $.each(obj.roles,function(i,obt){ | ||
| 134 | + $("#role option[value="+obt.id+"]").attr("selected",true); | ||
| 135 | + }); | ||
| 136 | + }); | ||
| 137 | + if(obj.enabled){ | ||
| 138 | + $("#enabled option[value=1]").attr("selected",true); | ||
| 139 | + }else{ | ||
| 140 | + $("#enabled option[value=0]").attr("selected",true); | ||
| 141 | + } | ||
| 142 | + }); | ||
| 143 | + | ||
| 144 | + }else { | ||
| 145 | + | ||
| 146 | + // 缺少ID | ||
| 147 | + layer.confirm('【ID缺失,请点击返回,重新进行修改操作】', {btn : [ '返回' ],icon: 3, title:'提示'}, function(index){ | ||
| 148 | + | ||
| 149 | + // 关闭弹出层 | ||
| 150 | + layer.close(index); | ||
| 151 | + | ||
| 152 | + // 跳转到list页面 | ||
| 153 | + loadPage('list.html'); | ||
| 154 | + | ||
| 155 | + }); | ||
| 156 | + } | ||
| 157 | + | ||
| 158 | + var form = $('#user_edit_form'); | ||
| 159 | + var error = $('.alert-danger', form); | ||
| 160 | + | ||
| 161 | + //表单 validate | ||
| 162 | + form.validate({ | ||
| 163 | + errorElement : 'span', | ||
| 164 | + errorClass : 'help-block help-block-error', | ||
| 165 | + focusInvalid : false, | ||
| 166 | + rules : { | ||
| 167 | + 'userName' : { | ||
| 168 | + required : true, | ||
| 169 | + maxlength: 25 | ||
| 170 | + }, | ||
| 171 | + 'name' : { | ||
| 172 | + required : true, | ||
| 173 | + maxlength: 25 | ||
| 174 | + }, | ||
| 175 | + 'role' : { | ||
| 176 | + required : true, | ||
| 177 | + minlength: 1 | ||
| 178 | + } | ||
| 179 | + }, | ||
| 180 | + invalidHandler : function(event, validator) { | ||
| 181 | + error.show(); | ||
| 182 | + App.scrollTo(error, -200); | ||
| 183 | + }, | ||
| 184 | + | ||
| 185 | + highlight : function(element) { | ||
| 186 | + $(element).closest('.form-group').addClass('has-error'); | ||
| 187 | + }, | ||
| 188 | + | ||
| 189 | + unhighlight : function(element) { | ||
| 190 | + $(element).closest('.form-group').removeClass('has-error'); | ||
| 191 | + }, | ||
| 192 | + | ||
| 193 | + success : function(label) { | ||
| 194 | + label.closest('.form-group').removeClass('has-error'); | ||
| 195 | + }, | ||
| 196 | + | ||
| 197 | + submitHandler : function(f) { | ||
| 198 | + var params = form.serializeJSON(); | ||
| 199 | + error.hide(); | ||
| 200 | + console.log(params); | ||
| 201 | + | ||
| 202 | + //检查一下用户是否存在 | ||
| 203 | + $.ajax({ | ||
| 204 | + url: '/user', | ||
| 205 | + type: 'POST', | ||
| 206 | + traditional: true, | ||
| 207 | + data: params, | ||
| 208 | + success: function(res){ | ||
| 209 | + layer.msg('修改用户信息成功.'); | ||
| 210 | + $('#myModal').modal(); | ||
| 211 | + //loadPage('list.html'); | ||
| 212 | + } | ||
| 213 | + }); | ||
| 214 | + } | ||
| 215 | + }); | ||
| 216 | + | ||
| 217 | + $('#noNext').click(function () { | ||
| 218 | + $('#myModal').modal('hide'); | ||
| 219 | + $('.modal-backdrop').remove(); | ||
| 220 | + | ||
| 221 | + loadPage('list.html'); | ||
| 222 | + }) | ||
| 223 | + $('#yesNext').click(function () { | ||
| 224 | + var storage = window.localStorage; | ||
| 225 | + storage.setItem("editUser",$('#id').val()); | ||
| 226 | + $('#myModal').modal('hide'); | ||
| 227 | + window.location.href='main.html' | ||
| 228 | + }) | ||
| 229 | + }); | ||
| 222 | </script> | 230 | </script> |
| 223 | \ No newline at end of file | 231 | \ No newline at end of file |