init
Showing
1 changed file
with
34 additions
and
5 deletions
| ... | @@ -3,22 +3,23 @@ | ... | @@ -3,22 +3,23 @@ |
| 3 | <body> | 3 | <body> |
| 4 | <div class="panel panel-default"> | 4 | <div class="panel panel-default"> |
| 5 | <div class="panel-body"> | 5 | <div class="panel-body"> |
| 6 | <form action="system/user/add" id="add"> | ||
| 6 | <div class="row cl"> | 7 | <div class="row cl"> |
| 7 | <div class="form-group col-sm-4 col-md-2"> | 8 | <div class="form-group col-sm-4 col-md-2"> |
| 8 | <label>用户名</label> | 9 | <label>用户名</label> |
| 9 | <input type="text" class="form-control input-text" value=""> | 10 | <input type="text" class="form-control input-text" name="username" value=""> |
| 10 | </div> | 11 | </div> |
| 11 | <div class="form-group col-sm-4 col-md-2"> | 12 | <div class="form-group col-sm-4 col-md-2"> |
| 12 | <label>真实姓名</label> | 13 | <label>真实姓名</label> |
| 13 | <input type="text" class="form-control input-text" value=""> | 14 | <input type="text" class="form-control input-text" name="name" value=""> |
| 14 | </div> | 15 | </div> |
| 15 | <div class="form-group col-sm-4 col-md-2"> | 16 | <div class="form-group col-sm-4 col-md-2"> |
| 16 | <label>手机号</label> | 17 | <label>手机号</label> |
| 17 | <input type="text" class="form-control input-text" value=""> | 18 | <input type="text" class="form-control input-text" name="phone" value=""> |
| 18 | </div> | 19 | </div> |
| 19 | <div class="form-group col-sm-4 col-md-2"> | 20 | <div class="form-group col-sm-4 col-md-2"> |
| 20 | <label>身份证号码</label> | 21 | <label>身份证号码</label> |
| 21 | <input type="text" class="form-control input-text" value=""> | 22 | <input type="text" class="form-control input-text" name="" value=""> |
| 22 | </div> | 23 | </div> |
| 23 | </div> | 24 | </div> |
| 24 | <div class="row cl"> | 25 | <div class="row cl"> |
| ... | @@ -55,6 +56,7 @@ | ... | @@ -55,6 +56,7 @@ |
| 55 | </select> | 56 | </select> |
| 56 | </div> | 57 | </div> |
| 57 | </div> | 58 | </div> |
| 59 | </form> | ||
| 58 | </div> | 60 | </div> |
| 59 | </div> | 61 | </div> |
| 60 | 62 | ||
| ... | @@ -76,8 +78,35 @@ | ... | @@ -76,8 +78,35 @@ |
| 76 | } | 78 | } |
| 77 | 79 | ||
| 78 | function save() { | 80 | function save() { |
| 81 | var targetUrl = $("#add").attr("action"); | ||
| 82 | var data = $("#add").serializeJson(); | ||
| 83 | $.ajax({ | ||
| 84 | type: 'post', | ||
| 85 | url: apiBaseUrl + targetUrl, | ||
| 86 | cache: false, | ||
| 87 | data: JSON.stringify(data), | ||
| 88 | dataType: 'json', | ||
| 89 | contentType: "application/json; charset=UTF-8", | ||
| 90 | success: function (data) { | ||
| 91 | if (data.msg) { | ||
| 92 | layer.alert(data.msg); | ||
| 93 | } else if (data.code != 0) { | ||
| 94 | layer.alert('操作失败'); | ||
| 95 | } else { | ||
| 96 | layer.alert('操作成功'); | ||
| 97 | } | ||
| 98 | if(!data.code) { | ||
| 99 | window.parent.msg('添加成功'); | ||
| 100 | window.parent.reload(); | ||
| 101 | layer_close(); | ||
| 102 | } | ||
| 103 | }, | ||
| 104 | error: function () { | ||
| 105 | layer.alert("操作失败") | ||
| 106 | } | ||
| 107 | }) | ||
| 108 | |||
| 79 | 109 | ||
| 80 | window.parent.msg('添加成功') | ||
| 81 | 110 | ||
| 82 | layer_close(); | 111 | layer_close(); |
| 83 | } | 112 | } | ... | ... |
-
Please register or sign in to post a comment