<!DOCTYPE html> <html lang="zh" xmlns:th="http://www.thymeleaf.org" > <meta charset="utf-8"> <head th:include="include :: header"></head> <link href="/ajax/libs/iCheck/custom.css" 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-edit" th:object="${user}"> <input name="id" type="hidden" th:field="*{id}" /> <input name="deptId" type="hidden" th:field="*{deptId}" 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" readonly="true" th:field="*{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" th:field="*{dept.deptName}"> </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" th:field="*{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="text" name="email" id="email" th:field="*{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" th:field="*{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']}" th:field="*{sex}"></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="${user.enable}" 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:${companyList}" class="checkbox-inline i-checks"> <input name="company" id ="company" type="checkbox" th:value="${company.id}" th:text=" ${company.name}" th:checked="${company.flag}" th:disabled="${company.deleted == true}"> </label> </div> </div> <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="warehouse" id ="warehouse" type="checkbox" th:value="${warehouse.code}" th:text="${warehouse.name}" th:checked="${warehouse.flag}" th:disabled="${warehouse.enable == true}"> </label> </div> </div> <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"> <input name="role" type="radio" th:value="${role.id}" th:text="${role.roleName}" th:checked="${role.flag}" th:disabled="${role.enable == false}"> </label> </div> </div> <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-edit").validate({ rules:{ userName:{ required:true, }, deptName:{ required:true, }, email:{ required:false, email:true, // remote: { // url: ctx + "system/user/checkEmailUnique", // type: "post", // dataType: "json", // data: { // "userId": function() { // return $("input[name='userId']").val(); // }, // "email": function() { // return $("input[name='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: { // "userId": function() { // return $("input[name='userId']").val(); // }, // "phoneNumber": function() { // return $("input[name='phoneNumber']").val(); // } // }, // dataFilter: function (data, type) { // if (data == "0") return true; // else return false; // } // } }, }, messages: { // "email": { // remote: "Email已经存在" // }, // "phoneNumber":{ // remote: "手机号码已经存在" // } }, submitHandler:function(form){ edit(); } }); function edit() { var id = $("input[name='id']").val(); var deptId = $("input[name='deptId']").val(); var userName = $("input[name='userName']").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; var roleIds = $("input[name='role']").is(':checked') == true ? 1 : 0; var warehouseCodeList = $.form.selectCheckeds("warehouse"); var companyIdList = $.form.selectCheckeds("company"); $.ajax({ cache : true, type : "POST", url : ctx + "system/user/edit", data : { "id": id, "deptId": deptId, "userName": userName, "email": email, "phoneNumber": phoneNumber, "sex": sex, "enable": enable, "roleIds": roleIds, "warehouseCodeList": warehouseCodeList, "companyIdList": companyIdList }, async : false, error : function(request) { $.modal.alertError("系统错误"); }, success : function(data) { $.operate.saveSuccess(data); } }); } /*用户管理-修改-选择部门树*/ function selectDeptTree() { var deptId = $("#treeId").val(); var url = ctx + "system/dept/selectDeptTree/" + deptId; $.modal.open("选择部门", url, '380', '380'); } </script> </body> </html>