diff --git a/src/main/java/cn/stylefeng/guns/modular/organization/OrganizationViewController.java b/src/main/java/cn/stylefeng/guns/modular/organization/OrganizationViewController.java index 3a8ff30b..07ff9598 100644 --- a/src/main/java/cn/stylefeng/guns/modular/organization/OrganizationViewController.java +++ b/src/main/java/cn/stylefeng/guns/modular/organization/OrganizationViewController.java @@ -13,7 +13,7 @@ import org.springframework.stereotype.Controller; */ @Controller @Slf4j -@ApiResource(name = "职位管理相关的界面渲染", path = "organization") +@ApiResource(name = "职位管理相关的界面渲染", path = "/view/organization") public class OrganizationViewController { private String PREFIX = "/modular/system/organization"; @@ -24,7 +24,7 @@ public class OrganizationViewController { * @author chenjinlong * @date 2020/11/04 11:07 */ - @GetResource(name = "机构管理-首页-视图", path = "", requiredPermission = false, requiredLogin = false) + @GetResource(name = "机构管理-首页-视图", path = "") public String indexView() { return PREFIX + "/organization.html"; } @@ -35,7 +35,7 @@ public class OrganizationViewController { * @author chenjinlong * @date 2020/11/04 11:07 */ - @GetResource(name = "机构管理—新增-视图", path = "/addView", requiredPermission = false, requiredLogin = false) + @GetResource(name = "机构管理—新增-视图", path = "/addView") public String addView() { return PREFIX + "/organization_add.html"; } @@ -46,7 +46,7 @@ public class OrganizationViewController { * @author chenjinlong * @date 2020/11/04 11:07 */ - @GetResource(name = "机构管理-修改-视图", path = "editView", requiredPermission = false, requiredLogin = false) + @GetResource(name = "机构管理-修改-视图", path = "editView") public String editView() { return PREFIX + "/organization_edit.html"; } diff --git a/src/main/java/cn/stylefeng/guns/modular/position/PositionViewController.java b/src/main/java/cn/stylefeng/guns/modular/position/PositionViewController.java index 77d12452..b733de82 100644 --- a/src/main/java/cn/stylefeng/guns/modular/position/PositionViewController.java +++ b/src/main/java/cn/stylefeng/guns/modular/position/PositionViewController.java @@ -13,7 +13,7 @@ import org.springframework.stereotype.Controller; */ @Controller @Slf4j -@ApiResource(name = "职位管理相关的界面渲染", path = "position") +@ApiResource(name = "职位管理相关的界面渲染", path = "/view/position") public class PositionViewController { private String PREFIX = "/modular/system/position"; @@ -24,7 +24,7 @@ public class PositionViewController { * @author chenjinlong * @date 2020/11/04 11:07 */ - @GetResource(name = "职位管理-首页-视图", path = "", requiredPermission = false, requiredLogin = false) + @GetResource(name = "职位管理-首页-视图", path = "") public String indexView() { return PREFIX + "/position.html"; } @@ -35,7 +35,7 @@ public class PositionViewController { * @author chenjinlong * @date 2020/11/04 11:07 */ - @GetResource(name = "职位管理-首页-视图", path = "/addView", requiredPermission = false, requiredLogin = false) + @GetResource(name = "职位管理-首页-视图", path = "/addView") public String addView() { return PREFIX + "/position_add.html"; } @@ -46,7 +46,7 @@ public class PositionViewController { * @author chenjinlong * @date 2020/11/04 11:07 */ - @GetResource(name = "职位管理-首页-视图", path = "editView", requiredPermission = false, requiredLogin = false) + @GetResource(name = "职位管理-首页-视图", path = "editView") public String editView() { return PREFIX + "/position_edit.html"; } diff --git a/src/main/java/cn/stylefeng/guns/modular/user/UserViewController.java b/src/main/java/cn/stylefeng/guns/modular/user/UserViewController.java new file mode 100644 index 00000000..1040c784 --- /dev/null +++ b/src/main/java/cn/stylefeng/guns/modular/user/UserViewController.java @@ -0,0 +1,53 @@ +package cn.stylefeng.guns.modular.user; + +import cn.stylefeng.roses.kernel.resource.api.annotation.ApiResource; +import cn.stylefeng.roses.kernel.resource.api.annotation.GetResource; +import lombok.extern.slf4j.Slf4j; +import org.springframework.stereotype.Controller; + +/** + * 用户管理控制器 + * + * @author chenjinlong + * @date 2021/1/7 19:09 + */ +@Controller +@Slf4j +@ApiResource(name = "用户管理界面渲染", path = "/view/user") +public class UserViewController { + + private String PREFIX = "/modular/system/user"; + + /** + * 用户管理-首页-视图 + * + * @author chenjinlong + * @date 2021/1/7 19:09 + */ + @GetResource(name = "用户管理-首页-视图", path = "") + public String indexView() { + return PREFIX + "/user.html"; + } + + /** + * 用户管理—新增-视图 + * + * @author chenjinlong + * @date 2021/1/7 19:09 + */ + @GetResource(name = "用户管理—新增-视图", path = "/addView") + public String addView() { + return PREFIX + "/user_add.html"; + } + + /** + * 用户管理_修改_视图 + * + * @author chenjinlong + * @date 2021/1/7 19:09 + */ + @GetResource(name = "用户管理-修改-视图", path = "editView") + public String editView() { + return PREFIX + "/user_edit.html"; + } +} diff --git a/src/main/webapp/assets/modular/system/organization/organization.js b/src/main/webapp/assets/modular/system/organization/organization.js index 8a51ac65..624c6510 100644 --- a/src/main/webapp/assets/modular/system/organization/organization.js +++ b/src/main/webapp/assets/modular/system/organization/organization.js @@ -1,16 +1,40 @@ -layui.use(['table', 'form', 'func', 'HttpRequest', 'xmSelect', 'util'], function () { +layui.use(['table', 'form', 'func', 'HttpRequest', 'tree', 'util'], function () { var $ = layui.$; var table = layui.table; var form = layui.form; var func = layui.func; var HttpRequest = layui.HttpRequest; var xmSelect = layui.xmSelect; + var tree = layui.tree; // 职位表管理 var Organization = { tableId: "organizationTable" }; + + /* 渲染树形 */ + function renderTree() { + $.get(Feng.ctxPath + '/hrOrganization/treeLayui', function (data) { + tree.render({ + elem: '#organizationTree', + onlyIconControl: true, + data: data.data, + click: function (rest) { + $('#organizationTree').find('.ew-tree-click').removeClass('ew-tree-click'); + $(rest.elem).children('.layui-tree-entry').addClass('ew-tree-click'); + table.reload(Organization.tableId, { + where: {organizationId: rest.data.id}, + page: {curr: 1} + }); + } + }); + $('#organizationTree').find('.layui-tree-entry:first>.layui-tree-main>.layui-tree-txt').trigger('click'); + }); + } + + renderTree(); + // 初始化表格的列 Organization.initColumn = function () { return [[ @@ -40,7 +64,7 @@ layui.use(['table', 'form', 'func', 'HttpRequest', 'xmSelect', 'util'], function func.open({ height: 800, title: '添加机构', - content: Feng.ctxPath + '/hrOrganization/addView', + content: Feng.ctxPath + '/view/organization/addView', tableId: Organization.tableId }); }; @@ -50,7 +74,7 @@ layui.use(['table', 'form', 'func', 'HttpRequest', 'xmSelect', 'util'], function func.open({ height: 800, title: '修改机构', - content: Feng.ctxPath + '/organization/editView?orgId=' + data.orgId, + content: Feng.ctxPath + '/view/organization/editView?orgId=' + data.orgId, tableId: Organization.tableId }); }; @@ -68,24 +92,29 @@ layui.use(['table', 'form', 'func', 'HttpRequest', 'xmSelect', 'util'], function // 点击删除 Organization.delete = function (data) { var operation = function () { - ajaxUtil.post(Feng.ctxPath + "/hrOrganization/delete", {"orgId":data.positionId},function (data) { + var httpRequest = new HttpRequest(Feng.ctxPath + "/hrOrganization/delete", 'post', function (data) { Feng.success("删除成功!"); table.reload(Organization.tableId); - },function (data) { + }, function (data) { Feng.error("删除失败!" + data.responseJSON.message + "!"); }); + httpRequest.set(data); + httpRequest.start(true); }; Feng.confirm("是否删除?", operation); }; // 修改职位状态 - Organization.updateStatus = function (positionId, checked) { - ajaxUtil.post(Feng.ctxPath + "/hrOrganization/updateStatus", {"orgId":positionId,"statusFlag":checked},function (data) { - Feng.success("修改成功!"); - },function (data) { - Feng.error("修改失败!" + data.responseJSON.message); + Organization.updateStatus = function (orgId, checked) { + var httpRequest = new HttpRequest(Feng.ctxPath + "/hrOrganization/updateStatus", 'post', function (data) { table.reload(Organization.tableId); + Feng.success("修改成功!"); + }, function (data) { + table.reload(Organization.tableId); + Feng.error("修改失败!" + data.responseJSON.message); }); + httpRequest.set({"orgId": orgId, "statusFlag": checked}); + httpRequest.start(true); }; // 渲染表格 @@ -128,8 +157,8 @@ layui.use(['table', 'form', 'func', 'HttpRequest', 'xmSelect', 'util'], function // 修改状态 form.on('switch(status)', function (obj) { - var positionId = obj.elem.value; + var orgId = obj.elem.value; var checked = obj.elem.checked ? 1 : 2; - Organization.updateStatus(positionId, checked); + Organization.updateStatus(orgId, checked); }); }); diff --git a/src/main/webapp/assets/modular/system/organization/organization_add.js b/src/main/webapp/assets/modular/system/organization/organization_add.js index c20142be..dd47fac2 100644 --- a/src/main/webapp/assets/modular/system/organization/organization_add.js +++ b/src/main/webapp/assets/modular/system/organization/organization_add.js @@ -1,10 +1,38 @@ -layui.use(['form', 'admin', 'HttpRequest'], function () { +layui.use(['form', 'admin', 'HttpRequest', 'xmSelect'], function () { + var $ = layui.$; var form = layui.form; var admin = layui.admin; var HttpRequest = layui.HttpRequest; + var xmSelect = layui.xmSelect; + var insXmSel; + + /* 渲染树形 */ + function renderTree() { + $.get(Feng.ctxPath + '/hrOrganization/treeLayui', function (data) { + insXmSel = xmSelect.render({ + el: '#organizationEditParentSel', + height: '250px', + data: data.data, + model: {label: {type: 'text'}}, + prop: {name: 'title', value: 'id'}, + radio: true, + clickClose: true, + tree: { + show: true, + indent: 15, + strict: false, + expandedKeys: true + } + }); + }); + } + + renderTree(); //表单提交事件 form.on('submit(btnSubmit)', function (data) { + //获取机构id + data.field.orgParentId = insXmSel.getValue('valueStr'); var request = new HttpRequest(Feng.ctxPath + "/hrOrganization/add", 'post', function (data) { admin.closeThisDialog(); Feng.success("添加成功!"); diff --git a/src/main/webapp/assets/modular/system/organization/organization_edit.js b/src/main/webapp/assets/modular/system/organization/organization_edit.js index 07d57bf9..1ace2dda 100644 --- a/src/main/webapp/assets/modular/system/organization/organization_edit.js +++ b/src/main/webapp/assets/modular/system/organization/organization_edit.js @@ -1,16 +1,45 @@ -layui.use(['form', 'admin', 'HttpRequest'], function () { +layui.use(['form', 'admin', 'HttpRequest', 'xmSelect'], function () { + var $ = layui.$; var form = layui.form; var admin = layui.admin; var HttpRequest = layui.HttpRequest; + var xmSelect = layui.xmSelect; + var insXmSel; //获取信息详情填充表单 var request = new HttpRequest(Feng.ctxPath + "/hrOrganization/detail?orgId=" + Feng.getUrlParam("orgId"), 'get'); var result = request.start(); - console.log(result); + form.val('organizationForm', result.data); + renderTree(result.data.orgParentId); + + /* 渲染树形 */ + function renderTree(orgParentId) { + $.get(Feng.ctxPath + '/hrOrganization/treeLayui', function (data) { + insXmSel = xmSelect.render({ + el: '#organizationEditParentSel', + height: '250px', + data: data.data, + initValue: [orgParentId], + model: {label: {type: 'text'}}, + prop: {name: 'title', value: 'id'}, + radio: true, + clickClose: true, + tree: { + show: true, + indent: 15, + strict: false, + expandedKeys: true + } + }); + }); + } //表单提交事件 form.on('submit(btnSubmit)', function (data) { + //获取机构id + data.field.orgParentId = insXmSel.getValue('valueStr'); + var request = new HttpRequest(Feng.ctxPath + "/hrOrganization/edit", 'post', function (data) { admin.closeThisDialog(); Feng.success("修改成功!"); diff --git a/src/main/webapp/assets/modular/system/position/position.js b/src/main/webapp/assets/modular/system/position/position.js index 6825c352..b6456195 100644 --- a/src/main/webapp/assets/modular/system/position/position.js +++ b/src/main/webapp/assets/modular/system/position/position.js @@ -50,7 +50,7 @@ layui.use(['table', 'form', 'func', 'HttpRequest', 'util'], function () { func.open({ height: 800, title: '添加职位', - content: Feng.ctxPath + '/position/addView', + content: Feng.ctxPath + '/view/position/addView', tableId: Position.tableId }); }; @@ -60,7 +60,7 @@ layui.use(['table', 'form', 'func', 'HttpRequest', 'util'], function () { func.open({ height: 800, title: '修改职位', - content: Feng.ctxPath + '/position/editView?positionId=' + data.positionId, + content: Feng.ctxPath + '/view/position/editView?positionId=' + data.positionId, tableId: Position.tableId }); }; @@ -93,10 +93,11 @@ layui.use(['table', 'form', 'func', 'HttpRequest', 'util'], function () { // 修改职位状态 Position.updateStatus = function (positionId, checked) { var httpRequest = new HttpRequest(Feng.ctxPath + "/hrPosition/updateStatus", 'post', function (data) { + table.reload(Position.tableId); Feng.success("修改成功!"); }, function (data) { - Feng.error("修改失败!" + data.responseJSON.message); table.reload(Position.tableId); + Feng.error("修改失败!" + data.responseJSON.message); }); httpRequest.set({"positionId": positionId, "statusFlag": checked}); httpRequest.start(true); @@ -138,7 +139,6 @@ layui.use(['table', 'form', 'func', 'HttpRequest', 'util'], function () { } else if (event === 'delete') { Position.delete(data); } - dropdown.hideAll(); }); // 修改状态 diff --git a/src/main/webapp/assets/modular/system/user/user.js b/src/main/webapp/assets/modular/system/user/user.js index 44e2962b..94fe6211 100644 --- a/src/main/webapp/assets/modular/system/user/user.js +++ b/src/main/webapp/assets/modular/system/user/user.js @@ -1,14 +1,11 @@ -layui.use(['layer', 'form', 'table', 'ztree', 'laydate', 'admin', 'ax', 'func', 'tree', 'util'], function () { +layui.use(['layer', 'form', 'table', 'ztree', 'laydate', 'admin', 'HttpRequest', 'func', 'tree', 'util'], function () { var layer = layui.layer; var form = layui.form; var table = layui.table; - var $ZTree = layui.ztree; - var $ax = layui.ax; + var HttpRequest = layui.HttpRequest; var laydate = layui.laydate; - var admin = layui.admin; var func = layui.func; var tree = layui.tree; - var util = layui.util; /** * 系统管理--用户管理 @@ -33,14 +30,14 @@ layui.use(['layer', 'form', 'table', 'ztree', 'laydate', 'admin', 'ax', 'func', return [[ {type: 'checkbox'}, {field: 'userId', hide: true, sort: true, title: '用户id'}, - {field: 'account', align: "center", sort: true, title: langs.FIELD_ACCOUNT}, - {field: 'name', align: "center", sort: true, title: langs.FIELD_NAME}, - {field: 'deptName', align: "center", sort: true, title: langs.FIELD_DEPT}, - {field: 'positionName', align: "center", sort: true, title: langs.FIELD_POST}, - {field: 'phone', align: "center", sort: true, title: langs.FIELD_PHONE, minWidth: 117}, - {field: 'createTime', align: "center", sort: true, title: langs.FIELD_CREATE_TIME, minWidth: 160}, - {field: 'status', align: "center", sort: true, templet: '#statusTpl', title: langs.FIELD_STATUS}, - {align: 'center', toolbar: '#tableBar', title: langs.FIELD_OPERATION, minWidth: 480} + {field: 'account', align: "center", sort: true, title: '账号'}, + {field: 'realName', align: "center", sort: true, title: '姓名'}, + {field: 'orgId', align: "center", sort: true, title: '机构'}, + {field: 'positionId', align: "center", sort: true, title: '职务'}, + {field: 'phone', align: "center", sort: true, title: '电话'}, + {field: 'createTime', align: "center", sort: true, title: '创建时间', minWidth: 160}, + {field: 'status', align: "center", sort: true, templet: '#statusTpl', title: '状态'}, + {align: 'center', toolbar: '#tableBar', title: '操作', minWidth: 300} ]]; }; @@ -65,34 +62,20 @@ layui.use(['layer', 'form', 'table', 'ztree', 'laydate', 'admin', 'ax', 'func', }); }; - /** - * 弹出添加用户对话框 - */ + // 添加按钮 MgrUser.openAddUser = function () { - - //获取多语言 - var langs = layui.data('system').lang; - func.open({ - title: langs.TITLE_ADD_USER, - content: Feng.ctxPath + '/mgr/user_add', + title: '添加用户', + content: Feng.ctxPath + '/view/user/addView', tableId: MgrUser.tableId }); }; - /** - * 点击编辑用户按钮时 - * - * @param data 点击按钮时候的行数据 - */ + // 修改按钮 MgrUser.onEditUser = function (data) { - - //获取多语言 - var langs = layui.data('system').lang; - func.open({ - title: langs.TITLE_EDIT_USER, - content: Feng.ctxPath + '/mgr/user_edit?userId=' + data.userId, + title: '修改用户', + content: Feng.ctxPath + '/view/user/editView?userId=' + data.userId, tableId: MgrUser.tableId }); }; @@ -134,7 +117,6 @@ layui.use(['layer', 'form', 'table', 'ztree', 'laydate', 'admin', 'ax', 'func', * @param data 点击按钮时候的行数据 */ MgrUser.roleAssign = function (data) { - //获取多语言 var langs = layui.data('system').lang; @@ -197,11 +179,12 @@ layui.use(['layer', 'form', 'table', 'ztree', 'laydate', 'admin', 'ax', 'func', // 渲染表格 var tableResult = table.render({ elem: '#' + MgrUser.tableId, - url: Feng.ctxPath + '/mgr/list', + url: Feng.ctxPath + '/sysUser/page', page: true, height: "full-98", cellMinWidth: 100, - cols: MgrUser.initColumn() + cols: MgrUser.initColumn(), + parseData: Feng.parseData }); //渲染时间选择框 @@ -212,16 +195,15 @@ layui.use(['layer', 'form', 'table', 'ztree', 'laydate', 'admin', 'ax', 'func', }); // 初始化部门树 - var ajax = new $ax(Feng.ctxPath + "/dept/layuiTree", function (data) { + var request = new HttpRequest(Feng.ctxPath + '/hrOrganization/treeLayui', 'get', function (data) { tree.render({ elem: '#deptTree', - data: data, + data: data.data, click: MgrUser.onClickDept, onlyIconControl: true }); - }, function (data) { }); - ajax.start(); + request.start(); // 搜索按钮点击事件 $('#btnSearch').click(function () { @@ -256,10 +238,8 @@ layui.use(['layer', 'form', 'table', 'ztree', 'laydate', 'admin', 'ax', 'func', // 修改user状态 form.on('switch(status)', function (obj) { - var userId = obj.elem.value; var checked = obj.elem.checked ? true : false; - MgrUser.changeUserStatus(userId, checked); }); diff --git a/src/main/webapp/assets/modular/system/user/user_add.js b/src/main/webapp/assets/modular/system/user/user_add.js index a63de16c..6e6a838a 100644 --- a/src/main/webapp/assets/modular/system/user/user_add.js +++ b/src/main/webapp/assets/modular/system/user/user_add.js @@ -8,9 +8,9 @@ var UserInfoDlg = { } }; -layui.use(['layer', 'form', 'admin', 'laydate', 'ax', 'formSelects'], function () { +layui.use(['layer', 'form', 'admin', 'laydate', 'HttpRequest', 'formSelects'], function () { var $ = layui.jquery; - var $ax = layui.ax; + var HttpRequest = layui.HttpRequest; var form = layui.form; var admin = layui.admin; var laydate = layui.laydate; diff --git a/src/main/webapp/assets/modular/system/user/user_edit.js b/src/main/webapp/assets/modular/system/user/user_edit.js index 1db838d7..81ef71bf 100644 --- a/src/main/webapp/assets/modular/system/user/user_edit.js +++ b/src/main/webapp/assets/modular/system/user/user_edit.js @@ -8,20 +8,21 @@ var UserInfoDlg = { } }; -layui.use(['layer', 'form', 'admin', 'laydate', 'ax', 'formSelects'], function () { +layui.use(['layer', 'form', 'admin', 'laydate', 'HttpRequest', 'formSelects'], function () { var $ = layui.jquery; - var $ax = layui.ax; + var HttpRequest = layui.HttpRequest; var form = layui.form; var admin = layui.admin; var laydate = layui.laydate; var layer = layui.layer; var formSelects = layui.formSelects; - //获取用户信息 - var ajax = new $ax(Feng.ctxPath + "/mgr/getUserInfo?userId=" + Feng.getUrlParam("userId")); - var result = ajax.start(); + //获取信息详情填充表单 + var request = new HttpRequest(Feng.ctxPath + "/sysUser/detail?userId=" + Feng.getUrlParam("userId"), 'get'); + var result = request.start(); form.val('userForm', result.data); + // 点击部门时 $('#deptName').click(function () { var formName = encodeURIComponent("parent.UserInfoDlg.data.deptName"); @@ -77,9 +78,9 @@ layui.use(['layer', 'form', 'admin', 'laydate', 'ax', 'formSelects'], function ( }); //初始化所有的职位列表 - formSelects.config('selPosition', { - searchUrl: Feng.ctxPath + "/position/listPositions?userId=" + $("#userId").val(), - keyName: 'name', - keyVal: 'positionId' - }); + // formSelects.config('selPosition', { + // searchUrl: Feng.ctxPath + "/position/listPositions?userId=" + $("#userId").val(), + // keyName: 'name', + // keyVal: 'positionId' + // }); }); \ No newline at end of file diff --git a/src/main/webapp/pages/modular/system/organization/organization.html b/src/main/webapp/pages/modular/system/organization/organization.html index 991bcd18..5c941eeb 100644 --- a/src/main/webapp/pages/modular/system/organization/organization.html +++ b/src/main/webapp/pages/modular/system/organization/organization.html @@ -1,7 +1,7 @@ @layout("/layout/_container.html",{js:["/assets/modular/system/organization/organization.js"]}){