Blame view

src/main/resources/templates/system/user/add.html 8.81 KB
tangying authored
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
<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<meta charset="utf-8">
<head th:include="include :: header"></head>
<link th:href="@{/ajax/libs/iCheck/custom.css}" rel="stylesheet"/>
<body class="white-bg">
	<div class="wrapper wrapper-content animated fadeInRight ibox-content">
		<form class="form-horizontal m" id="form-user-add">
			<input name="deptId"  type="hidden" id="treeId"/>
			<div class="form-group">
				<label class="col-sm-3 control-label ">登录名称:</label>
				<div class="col-sm-8">
					<input class="form-control" type="text" id="loginName" name="loginName"/>
				</div>
			</div>
			<div class="form-group">
				<label class="col-sm-3 control-label">部门名称:</label>
				<div class="col-sm-8">
					<input class="form-control" type="text" name="deptName" onclick="selectDeptTree()" readonly="true" id="treeName">
				</div>
			</div>
			<div class="form-group">
				<label class="col-sm-3 control-label">用户名称:</label>
				<div class="col-sm-8">
					<input class="form-control" type="text" name="userName" id="userName">
				</div>
			</div>
			<div class="form-group">
				<label class="col-sm-3 control-label">密码:</label>
				<div class="col-sm-8">
					<input class="form-control" type="password" name="password" id="password" th:value="${@config.getKey('sys.user.initPassword')}">
				</div>
			</div>
			<div class="form-group">
				<label class="col-sm-3 control-label">邮箱:</label>
				<div class="col-sm-8">
					<input class="form-control" type="text" name="email" id="email">
				</div>
			</div>
			<div class="form-group">
				<label class="col-sm-3 control-label">手机:</label>
				<div class="col-sm-8">
					<input class="form-control" type="text" name="phoneNumber" id="phoneNumber">
				</div>
			</div>
			<div class="form-group">
				<label class="col-sm-3 control-label">性别:</label>
				<div class="col-sm-8">
					<select id="sex" class="form-control m-b" th:with="type=${@dict.getType('sys_user_sex')}">
	                    <option th:each="dict : ${type}" th:text="${dict['dictLabel']}" th:value="${dict['dictValue']}"></option>
	                </select>
				</div>
			</div>
			<div class="form-group">
				<label class="col-sm-3 control-label">启用:</label>
				<div class="col-sm-8">
					<div class="onoffswitch">
                         <input type="checkbox" th:checked="true" class="onoffswitch-checkbox" id="enable" name="enable">
                         <label class="onoffswitch-label" for="enable">
                             <span class="onoffswitch-inner"></span>
                             <span class="onoffswitch-switch"></span>
                         </label>
                     </div>
				</div>
			</div>
			<div class="form-group">
				<label class="col-sm-3 control-label">货主:</label>
				<div class="col-sm-8">
					<label th:each="company:${companys}" class="checkbox-inline i-checks">
70
						<input name="company" type="checkbox" th:value="${company.id}" th:text=" ${company.name}">
tangying authored
71
72
73
					</label>
				</div>
			</div>
mahuandong authored
74
75
76
77
78
79
80
81
82
83

			<div class="form-group">
				<label class="col-sm-3 control-label">仓库:</label>
				<div class="col-sm-8">
					<label th:each="warehouse:${warehouseList}" class="checkbox-inline i-checks">
						<input name="warehouseCode" type="checkbox" th:value="${warehouse.value}" th:text=" ${warehouse.name}" th:disabled="${warehouse.enable == false} ">
					</label>
				</div>
			</div>
tangying authored
84
85
86
87
			<div class="form-group">
				<label class="col-sm-3 control-label">角色:</label>
				<div class="col-sm-8">
					<label th:each="role:${roles}" class="checkbox-inline i-checks">
88
						<input name="role" type="checkbox" th:value="${role.id}" th:text="${role.roleName}" th:checked="${role.flag}" th:disabled="${role.enable == false}">
tangying authored
89
90
91
					</label>
				</div>
			</div>
lector authored
92
tangying authored
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
			<div class="form-group">
				<div class="form-control-static col-sm-offset-9">
					<button type="submit" class="btn btn-primary">提交</button>
					<button onclick="$.modal.close()" class="btn btn-danger" type="button">关闭</button>
				</div>
			</div>
		</form>
	</div>
	<div th:include="include::footer"></div>
	<script th:src="@{/ajax/libs/iCheck/icheck.min.js}"></script>
	<script th:src="@{/ajax/libs/select/select2.js}"></script>
	<script>
        $("#form-user-add").validate({
        	rules:{
        		loginName:{
        			required:true,
        			minlength: 2,
        			maxlength: 20,
        			remote: {
                        url: ctx + "system/user/checkLoginNameUnique",
                        type: "post",
                        dataType: "json",
                        data: {
                        	name : function() {
                                return $.trim($("#loginName").val());
                            }
                        },
                        dataFilter: function(data, type) {
mahuandong authored
121
122
123
124
125
                            if (data) {
								return true;
							} else {
								return false;
							}
tangying authored
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
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
                        }
                    }
        		},
        		userName:{
        			required:true,
        		},
        		deptName:{
        			required:true,
        		},
        		password:{
        			required:true,
        			minlength: 5,
        			maxlength: 20
        		},
        		email:{
        			required:false,
                    email:true,
                    // remote: {
                    //     url: ctx + "system/user/checkEmailUnique",
                    //     type: "post",
                    //     dataType: "json",
                    //     data: {
                    //         name: function () {
                    //             return $.trim($("#email").val());
                    //         }
                    //     },
                    //     dataFilter: function (data, type) {
                    //         if (data == "0") return true;
                    //         else return false;
                    //     }
                    // }
        		},
        		phoneNumber:{
        			required:false,
        			isPhone:true,
                    // remote: {
                    //     url: ctx + "system/user/checkPhoneUnique",
                    //     type: "post",
                    //     dataType: "json",
                    //     data: {
                    //         name: function () {
                    //             return $.trim($("#phoneNumber").val());
                    //         }
                    //     },
                    //     dataFilter: function (data, type) {
                    //         if (data == "0") return true;
                    //         else return false;
                    //     }
                    // }
        		},
        	},
        	messages: {
                "loginName": {
                    remote: "用户已经存在"
                },
        		// "email": {
                 //    remote: "Email已经存在"
                // },
        		// "phoneNumber":{
                	// remote: "手机号码已经存在"
        		// }
            },
        	submitHandler:function(form){
        		add();
        	}
        });

        function add() {
        	var id = $("input[name='id']").val();
        	var deptId = $("input[name='deptId']").val();
        	var loginName = $("input[name='loginName']").val();
        	var userName = $("input[name='userName']").val();
        	var password = $("input[name='password']").val();
        	var email = $("input[name='email']").val();
        	var phoneNumber = $("input[name='phoneNumber']").val();
        	var sex = $("#sex option:selected").val();
        	var enable = $("input[name='enable']").is(':checked') == true ? 1 : 0;
203
			var roleIds = $.form.selectCheckeds("role");
mahuandong authored
204
			var warehouseCodeList = $.form.selectCheckeds("warehouseCode");
tangying authored
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
        	var companyIdList = $.form.selectCheckeds("company");
        	$.ajax({
        		cache : true,
        		type : "POST",
        		url : ctx + "system/user/add",
        		data : {
        			"id": id,
        			"deptId": deptId,
        			"loginName": loginName,
        			"userName": userName,
        			"password": password,
        			"email": email,
        			"phoneNumber": phoneNumber,
        			"sex": sex,
        			"enable": enable,
        			"roleIds": roleIds,
mahuandong authored
221
					"warehouseCodeList": warehouseCodeList,
tangying authored
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
        			"companyIdList": companyIdList
        		},
        		async : false,
        		error : function(request) {
        			$.modal.alertError("系统错误");
        		},
        		success : function(data) {
        			$.operate.saveSuccess(data);
        		}
        	});
        }

        /*用户管理-新增-选择部门树*/
        function selectDeptTree() {
        	var treeId = $("#treeId").val();
237
        	var deptId = treeId == null || treeId == "" ? "1" : treeId;
tangying authored
238
239
240
241
242
243
        	var url = ctx + "system/dept/selectDeptTree/" + deptId;
        	$.modal.open("选择部门", url, '380', '380');
        }
    </script>
</body>
</html>