From 336c5fa98b9897f7227ea1cb431f3d1da3264442 Mon Sep 17 00:00:00 2001 From: chenjinlong <$chenjinlong> Date: Tue, 5 Jan 2021 09:17:44 +0800 Subject: [PATCH 01/10] =?UTF-8?q?=E3=80=90Organization=E3=80=91=E9=A1=B5?= =?UTF-8?q?=E9=9D=A2=E4=BF=AE=E6=94=B9=20=E3=80=90Position=E3=80=91?= =?UTF-8?q?=E9=A1=B5=E9=9D=A2=E8=A7=84=E8=8C=83=E6=95=B4=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../system/organization/organization.js | 37 +++++++------------ .../system/organization/organization_add.js | 13 ++++--- .../system/organization/organization_edit.js | 26 ++++++------- .../modular/system/position/position.js | 3 +- .../modular/system/position/position_edit.js | 6 +-- .../system/organization/organization.html | 29 +++++++-------- .../system/organization/organization_add.html | 14 +++---- .../organization/organization_edit.html | 14 +++---- 8 files changed, 64 insertions(+), 78 deletions(-) diff --git a/src/main/webapp/assets/modular/system/organization/organization.js b/src/main/webapp/assets/modular/system/organization/organization.js index 3256b375..8a51ac65 100644 --- a/src/main/webapp/assets/modular/system/organization/organization.js +++ b/src/main/webapp/assets/modular/system/organization/organization.js @@ -1,11 +1,10 @@ -layui.use(['table', 'admin', 'ax', 'form', 'func', 'ajaxUtil', 'dropdown','util'], function () { +layui.use(['table', 'form', 'func', 'HttpRequest', 'xmSelect', 'util'], function () { var $ = layui.$; var table = layui.table; var form = layui.form; var func = layui.func; - var ajaxUtil = layui.ajaxUtil; - var dropdown = layui.dropdown; - var util = layui.util; + var HttpRequest = layui.HttpRequest; + var xmSelect = layui.xmSelect; // 职位表管理 var Organization = { @@ -16,17 +15,11 @@ layui.use(['table', 'admin', 'ax', 'form', 'func', 'ajaxUtil', 'dropdown','util' Organization.initColumn = function () { return [[ {type: 'checkbox'}, - {field: 'positionId', hide: true, title: '主键id'}, - {field: 'positionName', sort: true, title: '职位名称'}, - {field: 'positionCode', sort: true, title: '职位编码'}, - {field: 'positionRemark', sort: true, title: '备注'}, - {field: 'createTime', sort: true, title: '创建时间',templet: function (d) { - return util.toDateString(d.createTime); - }}, - {field: 'updateTime', sort: true, title: '更新时间',templet: function (d) { - console.log(d.updateTime); - return d.updateTime==null?'': util.toDateString(d.updateTime); - }}, + {field: 'orgId', hide: true, title: '主键id'}, + {field: 'orgName', sort: true, title: '机构名称'}, + {field: 'orgCode', sort: true, title: '机构编码'}, + {field: 'orgSort', sort: true, title: '排序'}, + {field: 'orgRemark', sort: true, title: '备注'}, {field: 'statusFlag', sort: true, templet: '#statusTpl', title: '状态'}, {align: 'center', toolbar: '#tableBar', title: '操作'} ]]; @@ -35,8 +28,7 @@ layui.use(['table', 'admin', 'ax', 'form', 'func', 'ajaxUtil', 'dropdown','util' // 点击查询按钮 Organization.search = function () { var queryData = {}; - queryData['positionName'] = $("#positionName").val(); - //queryData['positionCode'] = $("#positionCode").val(); + queryData['orgName'] = $("#orgName").val(); table.reload(Organization.tableId, { where: queryData, page: {curr: 1} @@ -47,7 +39,7 @@ layui.use(['table', 'admin', 'ax', 'form', 'func', 'ajaxUtil', 'dropdown','util' Organization.openAddDlg = function () { func.open({ height: 800, - title: '添加职位', + title: '添加机构', content: Feng.ctxPath + '/hrOrganization/addView', tableId: Organization.tableId }); @@ -57,8 +49,8 @@ layui.use(['table', 'admin', 'ax', 'form', 'func', 'ajaxUtil', 'dropdown','util' Organization.openEditDlg = function (data) { func.open({ height: 800, - title: '修改职位', - content: Feng.ctxPath + '/organization/editView?positionId=' + data.positionId, + title: '修改机构', + content: Feng.ctxPath + '/organization/editView?orgId=' + data.orgId, tableId: Organization.tableId }); }; @@ -76,7 +68,7 @@ layui.use(['table', 'admin', 'ax', 'form', 'func', 'ajaxUtil', 'dropdown','util' // 点击删除 Organization.delete = function (data) { var operation = function () { - ajaxUtil.post(Feng.ctxPath + "/hrOrganization/delete", {"positionId":data.positionId},function (data) { + ajaxUtil.post(Feng.ctxPath + "/hrOrganization/delete", {"orgId":data.positionId},function (data) { Feng.success("删除成功!"); table.reload(Organization.tableId); },function (data) { @@ -88,7 +80,7 @@ layui.use(['table', 'admin', 'ax', 'form', 'func', 'ajaxUtil', 'dropdown','util' // 修改职位状态 Organization.updateStatus = function (positionId, checked) { - ajaxUtil.post(Feng.ctxPath + "/hrOrganization/updateStatus", {"positionId":positionId,"statusFlag":checked},function (data) { + ajaxUtil.post(Feng.ctxPath + "/hrOrganization/updateStatus", {"orgId":positionId,"statusFlag":checked},function (data) { Feng.success("修改成功!"); },function (data) { Feng.error("修改失败!" + data.responseJSON.message); @@ -132,7 +124,6 @@ layui.use(['table', 'admin', 'ax', 'form', 'func', 'ajaxUtil', 'dropdown','util' } else if (event === 'delete') { Organization.delete(data); } - dropdown.hideAll(); }); // 修改状态 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 b01eb4bf..c20142be 100644 --- a/src/main/webapp/assets/modular/system/organization/organization_add.js +++ b/src/main/webapp/assets/modular/system/organization/organization_add.js @@ -1,18 +1,19 @@ -layui.use(['form', 'admin', 'ax', 'ajaxUtil'], function () { +layui.use(['form', 'admin', 'HttpRequest'], function () { var form = layui.form; var admin = layui.admin; - var ajaxUtil = layui.ajaxUtil; + var HttpRequest = layui.HttpRequest; //表单提交事件 form.on('submit(btnSubmit)', function (data) { - ajaxUtil.post(Feng.ctxPath + "/hrOrganization/add", data.field, function (res) { + var request = new HttpRequest(Feng.ctxPath + "/hrOrganization/add", 'post', function (data) { admin.closeThisDialog(); Feng.success("添加成功!"); admin.putTempData('formOk', true); - - }, function (res) { + }, function (data) { admin.closeThisDialog(); - Feng.error("添加失败!" + res.responseJSON.message); + Feng.error("添加失败!" + data.message); }); + request.set(data.field); + request.start(true); }); }); \ No newline at end of file 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 450527c7..07d57bf9 100644 --- a/src/main/webapp/assets/modular/system/organization/organization_edit.js +++ b/src/main/webapp/assets/modular/system/organization/organization_edit.js @@ -1,25 +1,25 @@ -layui.use(['form', 'admin', 'ajaxUtil'], function () { +layui.use(['form', 'admin', 'HttpRequest'], function () { var form = layui.form; var admin = layui.admin; - var ajaxUtil = layui.ajaxUtil; - //获取详情信息,填充表单 + var HttpRequest = layui.HttpRequest; - ajaxUtil.get("/hrOrganization/detail?orgId=" + Feng.getUrlParam("positionId"), function (res) { - form.val('positionForm', res.data); - }, function (res) { - admin.closeThisDialog(); - Feng.error("编辑异常!" + res.responseJSON.message); - }); + //获取信息详情填充表单 + 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); //表单提交事件 form.on('submit(btnSubmit)', function (data) { - ajaxUtil.post(Feng.ctxPath + "/hrOrganization/edit", data.field, function (res) { + var request = new HttpRequest(Feng.ctxPath + "/hrOrganization/edit", 'post', function (data) { + admin.closeThisDialog(); Feng.success("修改成功!"); admin.putTempData('formOk', true); + }, function (data) { admin.closeThisDialog(); - }, function (res) { - admin.closeThisDialog(); - Feng.error("修改失败!" + res.responseJSON.message); + Feng.error("修改失败!" + data.message); }); + request.set(data.field); + request.start(true); }); }); \ No newline at end of file diff --git a/src/main/webapp/assets/modular/system/position/position.js b/src/main/webapp/assets/modular/system/position/position.js index aaad656c..6825c352 100644 --- a/src/main/webapp/assets/modular/system/position/position.js +++ b/src/main/webapp/assets/modular/system/position/position.js @@ -1,10 +1,9 @@ -layui.use(['table', 'admin', 'form', 'func', 'HttpRequest', 'dropdown', 'util'], function () { +layui.use(['table', 'form', 'func', 'HttpRequest', 'util'], function () { var $ = layui.$; var table = layui.table; var form = layui.form; var func = layui.func; var HttpRequest = layui.HttpRequest; - var dropdown = layui.dropdown; var util = layui.util; // 职位表管理 diff --git a/src/main/webapp/assets/modular/system/position/position_edit.js b/src/main/webapp/assets/modular/system/position/position_edit.js index 438a0207..5def58bf 100644 --- a/src/main/webapp/assets/modular/system/position/position_edit.js +++ b/src/main/webapp/assets/modular/system/position/position_edit.js @@ -2,10 +2,8 @@ layui.use(['form', 'admin', 'HttpRequest'], function () { var form = layui.form; var admin = layui.admin; var HttpRequest = layui.HttpRequest; - //获取详情信息,填充表单 - - //获取用户详情 + //获取信息详情填充表单 var request = new HttpRequest(Feng.ctxPath + "/hrPosition/detail?positionId=" + Feng.getUrlParam("positionId"), 'get'); var result = request.start(); form.val('positionForm', result.data); @@ -13,9 +11,9 @@ layui.use(['form', 'admin', 'HttpRequest'], function () { //表单提交事件 form.on('submit(btnSubmit)', function (data) { var request = new HttpRequest(Feng.ctxPath + "/hrPosition/edit", 'post', function (data) { + admin.closeThisDialog(); Feng.success("修改成功!"); admin.putTempData('formOk', true); - admin.closeThisDialog(); }, function (data) { admin.closeThisDialog(); Feng.error("修改失败!" + data.message); diff --git a/src/main/webapp/pages/modular/system/organization/organization.html b/src/main/webapp/pages/modular/system/organization/organization.html index e988d339..991bcd18 100644 --- a/src/main/webapp/pages/modular/system/organization/organization.html +++ b/src/main/webapp/pages/modular/system/organization/organization.html @@ -30,8 +30,20 @@
+
+
+
+ +
+
+ + + +
+
+
-
+
@@ -41,21 +53,6 @@ + + + +@} diff --git a/src/main/webapp/pages/modular/auth/app/app_add.html b/src/main/webapp/pages/modular/auth/app/app_add.html new file mode 100644 index 00000000..a170fb53 --- /dev/null +++ b/src/main/webapp/pages/modular/auth/app/app_add.html @@ -0,0 +1,31 @@ +@layout("/layout/_form.html",{js:["/assets/modular/auth/app/app_add.js"]}){ + +
+
+
+
+
+ +
+ +
+ +
+
+
+ +
+ +
+
+
+
+
+
+
+ + +
+ +
+@} diff --git a/src/main/webapp/pages/modular/auth/app/app_edit.html b/src/main/webapp/pages/modular/auth/app/app_edit.html new file mode 100644 index 00000000..e51cc357 --- /dev/null +++ b/src/main/webapp/pages/modular/auth/app/app_edit.html @@ -0,0 +1,31 @@ +@layout("/layout/_form.html",{js:["/assets/modular/auth/app/app_edit.js"]}){ + +
+
+
+
+
+ +
+ +
+ +
+
+
+ +
+ +
+
+
+
+
+
+
+ + +
+ +
+@} From 4ca1437f6686f269ee6e49e9ac856b34b202f700 Mon Sep 17 00:00:00 2001 From: fengshuonan Date: Wed, 6 Jan 2021 16:38:10 +0800 Subject: [PATCH 07/10] =?UTF-8?q?=E6=9B=B4=E6=96=B0json=E6=97=A5=E6=9C=9F?= =?UTF-8?q?=E8=BF=94=E5=9B=9E=E5=89=8D=E7=AB=AF=E7=9A=84=E6=A0=BC=E5=BC=8F?= =?UTF-8?q?=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/resources/application.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml index af165c22..ccb157ad 100644 --- a/src/main/resources/application.yml +++ b/src/main/resources/application.yml @@ -16,7 +16,7 @@ spring: max-file-size: 200MB jackson: time-zone: GMT+8 - date-format: yyyy-MM-dd HH:mm:ss.SSS + date-format: yyyy-MM-dd HH:mm:ss locale: zh_CN serialization: indent_output: false @@ -40,4 +40,4 @@ mybatis-plus: enable-sql-runner: true db-config: id-type: assign_id - table-underline: true \ No newline at end of file + table-underline: true From 3dd68a721944f87695aa4988f80a8bc20983dea1 Mon Sep 17 00:00:00 2001 From: fengshuonan Date: Wed, 6 Jan 2021 17:56:17 +0800 Subject: [PATCH 08/10] =?UTF-8?q?=E6=9B=B4=E6=96=B0ztree-object=E7=9A=84?= =?UTF-8?q?=E5=B0=81=E8=A3=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../webapp/assets/expand/module/ztree/ztree-object.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/main/webapp/assets/expand/module/ztree/ztree-object.js b/src/main/webapp/assets/expand/module/ztree/ztree-object.js index 0a764e59..bcc5de2b 100644 --- a/src/main/webapp/assets/expand/module/ztree/ztree-object.js +++ b/src/main/webapp/assets/expand/module/ztree/ztree-object.js @@ -1,7 +1,7 @@ -layui.define(['jquery','ax'], function (exports) { +layui.define(['jquery', 'HttpRequest'], function (exports) { var $ = layui.$; - var $ax = layui.ax; + var HttpRequest = layui.HttpRequest; var $ZTree = function(id, url) { this.id = id; @@ -70,12 +70,12 @@ layui.define(['jquery','ax'], function (exports) { */ loadNodes : function() { var zNodes = null; - var ajax = new $ax(Feng.ctxPath + this.url, function(data) { + var request = new HttpRequest(Feng.ctxPath + this.url, 'get', function(data) { zNodes = data; }, function(data) { Feng.error("加载ztree信息失败!"); }); - ajax.start(); + request.start(); return zNodes; }, @@ -91,4 +91,4 @@ layui.define(['jquery','ax'], function (exports) { exports('ztree', $ZTree); -}); \ No newline at end of file +}); From cbcbd85a8cdb9e25384ca00c43e377fe0ca65853 Mon Sep 17 00:00:00 2001 From: fengshuonan Date: Wed, 6 Jan 2021 20:31:18 +0800 Subject: [PATCH 09/10] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E9=80=9A=E7=94=A8tree?= =?UTF-8?q?=E9=80=89=E6=8B=A9=E5=99=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../modular/common/CommonViewController.java | 46 +++++++++++++++++++ .../common/pojo/CommonTreeRequest.java | 34 ++++++++++++++ .../{layout => modular/common}/tree_dlg.html | 0 3 files changed, 80 insertions(+) create mode 100644 src/main/java/cn/stylefeng/guns/modular/common/CommonViewController.java create mode 100644 src/main/java/cn/stylefeng/guns/modular/common/pojo/CommonTreeRequest.java rename src/main/webapp/pages/{layout => modular/common}/tree_dlg.html (100%) diff --git a/src/main/java/cn/stylefeng/guns/modular/common/CommonViewController.java b/src/main/java/cn/stylefeng/guns/modular/common/CommonViewController.java new file mode 100644 index 00000000..c6ef8db1 --- /dev/null +++ b/src/main/java/cn/stylefeng/guns/modular/common/CommonViewController.java @@ -0,0 +1,46 @@ +package cn.stylefeng.guns.modular.common; + +import cn.stylefeng.guns.modular.common.pojo.CommonTreeRequest; +import cn.stylefeng.roses.kernel.resource.api.annotation.ApiResource; +import cn.stylefeng.roses.kernel.resource.api.annotation.GetResource; +import cn.stylefeng.roses.kernel.rule.exception.base.ServiceException; +import cn.stylefeng.roses.kernel.rule.exception.enums.defaults.DefaultBusinessExceptionEnum; +import lombok.extern.slf4j.Slf4j; +import org.springframework.stereotype.Controller; +import org.springframework.ui.Model; + +import javax.validation.Valid; +import java.io.UnsupportedEncodingException; +import java.net.URLDecoder; + +/** + * 通用界面 + * + * @author fengshuonan + * @date 2021/1/6 20:18 + */ +@Controller +@Slf4j +@ApiResource(name = "通用界面") +public class CommonViewController { + + /** + * 通用的树列表选择器 + * + * @author fengshuonan + * @date 2021/1/6 20:19 + */ + @GetResource(name = "通用的树列表选择器", path = "/view/common/tree") + public String commonTreeSelect(@Valid CommonTreeRequest commonTreeRequest, Model model) { + try { + model.addAttribute("formName", URLDecoder.decode(commonTreeRequest.getFormName(), "UTF-8")); + model.addAttribute("formId", URLDecoder.decode(commonTreeRequest.getFormId(), "UTF-8")); + model.addAttribute("treeUrl", URLDecoder.decode(commonTreeRequest.getTreeUrl(), "UTF-8")); + } catch (UnsupportedEncodingException e) { + log.error("解析url的参数出错!", e); + throw new ServiceException("guns-standalone-beetl", DefaultBusinessExceptionEnum.SYSTEM_RUNTIME_ERROR); + } + return "/modular/common/tree_dlg.html"; + } + +} diff --git a/src/main/java/cn/stylefeng/guns/modular/common/pojo/CommonTreeRequest.java b/src/main/java/cn/stylefeng/guns/modular/common/pojo/CommonTreeRequest.java new file mode 100644 index 00000000..e1b49831 --- /dev/null +++ b/src/main/java/cn/stylefeng/guns/modular/common/pojo/CommonTreeRequest.java @@ -0,0 +1,34 @@ +package cn.stylefeng.guns.modular.common.pojo; + +import lombok.Data; + +import javax.validation.constraints.NotBlank; + +/** + * 通用树选择器界面的请求参数 + * + * @author fengshuonan + * @date 2021/1/6 20:20 + */ +@Data +public class CommonTreeRequest { + + /** + * 传递给上级页面的哪个字段,例如 parent.MenuInfoDlg.data.pcodeName + */ + @NotBlank(message = "fromName不能为空") + private String formName; + + /** + * 传递给上级页面的哪个id值,例如 parent.MenuInfoDlg.data.pid + */ + @NotBlank(message = "formId不能为空") + private String formId; + + /** + * 渲染出数据的url,例如/menu/selectMenuTreeList + */ + @NotBlank(message = "tree渲染的url参数不能为空") + private String treeUrl; + +} diff --git a/src/main/webapp/pages/layout/tree_dlg.html b/src/main/webapp/pages/modular/common/tree_dlg.html similarity index 100% rename from src/main/webapp/pages/layout/tree_dlg.html rename to src/main/webapp/pages/modular/common/tree_dlg.html From c829c6cea861bf833e4ec3a8f2b61eff3bdf2a73 Mon Sep 17 00:00:00 2001 From: fengshuonan Date: Wed, 6 Jan 2021 20:31:53 +0800 Subject: [PATCH 10/10] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E8=8F=9C=E5=8D=95?= =?UTF-8?q?=E5=88=97=E8=A1=A8=EF=BC=8C=E6=9F=A5=E8=AF=A2=EF=BC=8C=E5=88=A0?= =?UTF-8?q?=E9=99=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../guns/modular/menu/MenuViewController.java | 52 +++++ .../webapp/assets/modular/auth/menu/menu.js | 181 +++++++++++++++++ .../modular/{system => auth}/menu/menu_add.js | 6 +- .../{system => auth}/menu/menu_edit.js | 0 .../webapp/assets/modular/system/menu/menu.js | 184 ------------------ .../modular/{system => auth}/menu/menu.html | 14 +- .../{system => auth}/menu/menu_add.html | 2 +- .../{system => auth}/menu/menu_edit.html | 2 +- 8 files changed, 242 insertions(+), 199 deletions(-) create mode 100644 src/main/java/cn/stylefeng/guns/modular/menu/MenuViewController.java create mode 100644 src/main/webapp/assets/modular/auth/menu/menu.js rename src/main/webapp/assets/modular/{system => auth}/menu/menu_add.js (94%) rename src/main/webapp/assets/modular/{system => auth}/menu/menu_edit.js (100%) delete mode 100644 src/main/webapp/assets/modular/system/menu/menu.js rename src/main/webapp/pages/modular/{system => auth}/menu/menu.html (78%) rename src/main/webapp/pages/modular/{system => auth}/menu/menu_add.html (98%) rename src/main/webapp/pages/modular/{system => auth}/menu/menu_edit.html (98%) diff --git a/src/main/java/cn/stylefeng/guns/modular/menu/MenuViewController.java b/src/main/java/cn/stylefeng/guns/modular/menu/MenuViewController.java new file mode 100644 index 00000000..ab8572a5 --- /dev/null +++ b/src/main/java/cn/stylefeng/guns/modular/menu/MenuViewController.java @@ -0,0 +1,52 @@ +package cn.stylefeng.guns.modular.menu; + +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 fengshuonan + * @date 2021/1/6 16:43 + */ +@Controller +@Slf4j +@ApiResource(name = "菜单管理界面") +public class MenuViewController { + + /** + * 菜单管理首页 + * + * @author fengshuonan + * @date 2021/1/6 13:32 + */ + @GetResource(name = "菜单管理首页", path = "/view/menu") + public String menuIndex() { + return "/modular/auth/menu/menu.html"; + } + + /** + * 新增菜单界面 + * + * @author fengshuonan + * @date 2021/1/6 13:37 + */ + @GetResource(name = "新增菜单界面", path = "/view/menu/add") + public String menuAdd() { + return "/modular/auth/menu/menu_add.html"; + } + + /** + * 修改菜单界面 + * + * @author fengshuonan + * @date 2021/1/6 13:37 + */ + @GetResource(name = "修改菜单界面", path = "/view/menu/edit") + public String menuEdit() { + return "/modular/auth/menu/menu_edit.html"; + } + +} diff --git a/src/main/webapp/assets/modular/auth/menu/menu.js b/src/main/webapp/assets/modular/auth/menu/menu.js new file mode 100644 index 00000000..6df7a257 --- /dev/null +++ b/src/main/webapp/assets/modular/auth/menu/menu.js @@ -0,0 +1,181 @@ +layui.use(['HttpRequest', 'treeTable', 'func'], function () { + var HttpRequest = layui.HttpRequest; + var treeTable = layui.treeTable; + var func = layui.func; + + /** + * 系统管理--菜单管理 + */ + var Menu = { + tableId: "menuTable", + condition: { + menuName: "", + menuCode: "" + }, + + // treeTable实例 + treeTableInstance: null + }; + + /** + * 初始化表格的列 + */ + Menu.initColumn = function () { + return [ + {type: 'numbers'}, + {field: 'menuName', align: "left", sort: true, title: '菜单名称', minWidth: 120}, + {field: 'menuCode', align: "center", sort: true, title: '菜单编号', minWidth: 120}, + {field: 'appName', align: "center", sort: true, title: '应用名称'}, + {field: 'layuiPath', align: "center", sort: true, title: '请求地址', minWidth: 180}, + { + field: 'layuiIcon', align: "center", sort: true, title: '图标', templet: '

' + }, + { + field: 'visible', align: "center", sort: true, title: '是否可见', templet: function (data) { + if (data.visible === 'Y') { + return '可见'; + } else { + return '不可见'; + } + } + }, + {field: 'menuSort', align: "center", sort: true, title: '排序'}, + { + field: 'statusFlag', align: "center", sort: true, title: '状态', templet: function (data) { + if (data.statusFlag === 1) { + return '启用'; + } else { + return '禁用'; + } + } + }, + {field: 'createTime', align: "center", sort: true, title: '创建时间', minWidth: 120}, + {field: 'updateTime', align: "center", sort: true, title: '更新时间', minWidth: 120}, + {align: 'center', toolbar: '#menuTableBar', title: '操作', minWidth: 120} + ]; + }; + + /** + * 点击查询按钮 + */ + Menu.search = function () { + var queryData = {}; + queryData['menuName'] = $("#menuName").val(); + queryData['menuCode'] = $("#menuCode").val(); + Menu.initTable(Menu.tableId, queryData); + }; + + /** + * 弹出添加菜单对话框 + */ + Menu.openAddMenu = function () { + func.open({ + height: 720, + title: '添加菜单', + content: Feng.ctxPath + '/view/menu/add', + tableId: Menu.tableId, + endCallback: function () { + Menu.initTable(Menu.tableId); + } + }); + }; + + /** + * 点击编辑菜单按钮时 + * + * @param data 点击按钮时候的行数据 + */ + Menu.onEditMenu = function (data) { + func.open({ + height: 720, + title: '修改菜单', + content: Feng.ctxPath + "/view/menu/edit?menuId=" + data.menuId, + tableId: Menu.tableId, + endCallback: function () { + Menu.initTable(Menu.tableId); + } + }); + }; + + /** + * 点击删除菜单按钮 + * + * @param data 点击按钮时候的行数据 + */ + Menu.onDeleteMenu = function (data) { + var operation = function () { + var request = new HttpRequest(Feng.ctxPath + "/sysMenu/delete", 'post', function () { + Feng.success("删除成功!"); + Menu.condition.menuId = ""; + Menu.initTable(Menu.tableId); + }, function (data) { + Feng.error("删除失败!" + data.message + "!"); + }); + request.set("menuId", data.menuId); + request.start(true); + }; + Feng.confirm("是否删除菜单" + data.menuName + "?", operation); + }; + + /** + * 初始化表格 + */ + Menu.initTable = function (menuId, reqData) { + return treeTable.render({ + elem: '#' + menuId, + tree: { + iconIndex: 1, // 折叠图标显示在第几列 + idName: 'menuId', // 自定义id字段的名称 + pidName: 'menuParentId', // 自定义标识是否还有子节点的字段名称 + isPidData: true // 是否是pid形式数据 + }, + height: "full-98", + cols: Menu.initColumn(), + reqData: function (data, callback) { + var request = new HttpRequest(Feng.ctxPath + '/sysMenu/layuiList', 'get', function (res) { + callback(res.data); + }, function (res) { + Feng.error("删除失败!" + res.message + "!"); + }); + request.set(reqData); + request.start(); + } + }); + }; + + // 渲染表格 + Menu.treeTableInstance = Menu.initTable(Menu.tableId); + + // 展开所有按钮 + $('#expandAll').click(function () { + Menu.treeTableInstance.expandAll(); + }); + + // 折叠所有按钮 + $('#foldAll').click(function () { + Menu.treeTableInstance.foldAll(); + }); + + // 搜索按钮点击事件 + $('#btnSearch').click(function () { + Menu.search(); + }); + + // 添加按钮点击事件 + $('#btnAdd').click(function () { + Menu.openAddMenu(); + }); + + // 工具条点击事件 + treeTable.on('tool(menuTable)', function (obj) { + var data = obj.data; + var layEvent = obj.event; + + if (layEvent === 'edit') { + Menu.onEditMenu(data); + } else if (layEvent === 'delete') { + Menu.onDeleteMenu(data); + } + }); + +}); diff --git a/src/main/webapp/assets/modular/system/menu/menu_add.js b/src/main/webapp/assets/modular/auth/menu/menu_add.js similarity index 94% rename from src/main/webapp/assets/modular/system/menu/menu_add.js rename to src/main/webapp/assets/modular/auth/menu/menu_add.js index 6c2b93c0..95809493 100644 --- a/src/main/webapp/assets/modular/system/menu/menu_add.js +++ b/src/main/webapp/assets/modular/auth/menu/menu_add.js @@ -8,9 +8,9 @@ var MenuInfoDlg = { } }; -layui.use(['layer', 'form', 'admin', 'laydate', 'ax', 'iconPicker'], function () { +layui.use(['layer', 'form', 'admin', 'laydate', 'HttpRequest', 'iconPicker'], function () { var $ = layui.jquery; - var $ax = layui.ax; + var HttpRequest = layui.HttpRequest; var form = layui.form; var admin = layui.admin; var laydate = layui.laydate; @@ -85,4 +85,4 @@ layui.use(['layer', 'form', 'admin', 'laydate', 'ax', 'iconPicker'], function () ajax.set("dictTypeCode", "SYSTEM_TYPE"); ajax.start(); -}); \ No newline at end of file +}); diff --git a/src/main/webapp/assets/modular/system/menu/menu_edit.js b/src/main/webapp/assets/modular/auth/menu/menu_edit.js similarity index 100% rename from src/main/webapp/assets/modular/system/menu/menu_edit.js rename to src/main/webapp/assets/modular/auth/menu/menu_edit.js diff --git a/src/main/webapp/assets/modular/system/menu/menu.js b/src/main/webapp/assets/modular/system/menu/menu.js deleted file mode 100644 index 819ced8e..00000000 --- a/src/main/webapp/assets/modular/system/menu/menu.js +++ /dev/null @@ -1,184 +0,0 @@ -layui.use(['layer', 'form', 'ztree', 'laydate', 'admin', 'ax', 'treeTable', 'func'], function () { - var layer = layui.layer; - var form = layui.form; - var $ZTree = layui.ztree; - var $ax = layui.ax; - var laydate = layui.laydate; - var admin = layui.admin; - var treeTable = layui.treeTable; - var func = layui.func; - - //table的初始化实例 - var insTb; - - /** - * 系统管理--菜单管理 - */ - var Menu = { - tableId: "menuTable", //表格id - condition: { - menuId: "", - menuName: "", - level: "" - } - }; - - /** - * 初始化表格的列 - */ - Menu.initColumn = function () { - return [ - {type: 'numbers'}, - {field: 'name', align: "left", sort: true, title: '菜单名称', minWidth: 240}, - {field: 'code', align: "center", sort: true, title: '菜单编号', minWidth: 120}, - {field: 'pcode', align: "center", sort: true, title: '菜单父编号'}, - {field: 'url', align: "center", sort: true, title: '请求地址'}, - {field: 'sort', align: "center", sort: true, title: '排序'}, - {field: 'levels', align: "center", sort: true, title: '层级'}, - {field: 'isMenuName', align: "center", sort: true, title: '是否是菜单'}, - {field: 'statusName', align: "center", sort: true, title: '状态'}, - {align: 'center', toolbar: '#menuTableBar', title: '操作', minWidth: 200} - ]; - }; - - /** - * 点击菜单树时 - */ - Menu.onClickMenu = function (e, treeId, treeNode) { - Menu.condition.menuId = treeNode.id; - Menu.search(); - }; - - /** - * 点击查询按钮 - */ - Menu.search = function () { - var queryData = {}; - queryData['menuName'] = $("#menuName").val(); - queryData['level'] = $("#level").val(); - Menu.initTable(Menu.tableId, queryData); - }; - - /** - * 弹出添加菜单对话框 - */ - Menu.openAddMenu = function () { - func.open({ - height: 720, - title: '添加菜单', - content: Feng.ctxPath + '/menu/menu_add', - tableId: Menu.tableId, - endCallback: function () { - Menu.initTable(Menu.tableId); - } - }); - }; - - /** - * 点击编辑菜单按钮时 - * - * @param data 点击按钮时候的行数据 - */ - Menu.onEditMenu = function (data) { - func.open({ - height: 720, - title: '修改菜单', - content: Feng.ctxPath + "/menu/menu_edit?menuId=" + data.menuId, - tableId: Menu.tableId, - endCallback: function () { - Menu.initTable(Menu.tableId); - } - }); - }; - - /** - * 点击删除菜单按钮 - * - * @param data 点击按钮时候的行数据 - */ - Menu.onDeleteMenu = function (data) { - var operation = function () { - var ajax = new $ax(Feng.ctxPath + "/menu/remove", function () { - Feng.success("删除成功!"); - Menu.condition.menuId = ""; - Menu.initTable(Menu.tableId); - }, function (xhr) { - Feng.error("删除失败!" + xhr.responseJSON.message + "!"); - }); - ajax.set("menuId", data.menuId); - ajax.start(); - }; - Feng.confirm("是否删除菜单" + data.name + "?", operation); - }; - - /** - * 初始化表格 - */ - Menu.initTable = function (menuId, reqData) { - return treeTable.render({ - elem: '#' + menuId, - tree: { - iconIndex: 1, // 折叠图标显示在第几列 - idName: 'code', // 自定义id字段的名称 - pidName: 'pcode', // 自定义标识是否还有子节点的字段名称 - haveChildName: 'haveChild', // 自定义标识是否还有子节点的字段名称 - isPidData: true // 是否是pid形式数据 - }, - height: "full-98", - cols: Menu.initColumn(), - reqData: function (data, callback) { - var ajax = new $ax(Feng.ctxPath + '/menu/listTree', function (res) { - callback(res.data); - }, function (res) { - Feng.error("删除失败!" + res.responseJSON.message + "!"); - }); - ajax.setData(reqData); - ajax.start(); - } - }); - }; - - // 渲染表格 - insTb = Menu.initTable(Menu.tableId); - $('#expandAll').click(function () { - insTb.expandAll(); - }); - $('#foldAll').click(function () { - insTb.foldAll(); - }); - - //渲染时间选择框 - laydate.render({ - elem: '#timeLimit', - range: true, - max: Feng.currentDate() - }); - - //初始化左侧部门树 - var ztree = new $ZTree("menuTree", "/menu/selectMenuTreeList"); - ztree.bindOnClick(Menu.onClickMenu); - ztree.init(); - - // 搜索按钮点击事件 - $('#btnSearch').click(function () { - Menu.search(); - }); - - // 添加按钮点击事件 - $('#btnAdd').click(function () { - Menu.openAddMenu(); - }); - - // 工具条点击事件 - treeTable.on('tool(menuTable)', function (obj) { - var data = obj.data; - var layEvent = obj.event; - - if (layEvent === 'edit') { - Menu.onEditMenu(data); - } else if (layEvent === 'delete') { - Menu.onDeleteMenu(data); - } - }); - -}); diff --git a/src/main/webapp/pages/modular/system/menu/menu.html b/src/main/webapp/pages/modular/auth/menu/menu.html similarity index 78% rename from src/main/webapp/pages/modular/system/menu/menu.html rename to src/main/webapp/pages/modular/auth/menu/menu.html index 721fb853..de547c60 100644 --- a/src/main/webapp/pages/modular/system/menu/menu.html +++ b/src/main/webapp/pages/modular/auth/menu/menu.html @@ -1,4 +1,4 @@ -@layout("/layout/_container.html",{plugins:["ztree"],js:["/assets/modular/system/menu/menu.js"]}){ +@layout("/layout/_container.html",{plugins:["ztree"], js:["/assets/modular/auth/menu/menu.js"]}){
菜单管理 @@ -12,16 +12,14 @@
- +
- +
- @if(shiro.hasPermission("/menu/add")){ - @}
@@ -35,12 +33,8 @@
-@} \ No newline at end of file +@} diff --git a/src/main/webapp/pages/modular/system/menu/menu_add.html b/src/main/webapp/pages/modular/auth/menu/menu_add.html similarity index 98% rename from src/main/webapp/pages/modular/system/menu/menu_add.html rename to src/main/webapp/pages/modular/auth/menu/menu_add.html index 2ac6ca6b..af50208a 100644 --- a/src/main/webapp/pages/modular/system/menu/menu_add.html +++ b/src/main/webapp/pages/modular/auth/menu/menu_add.html @@ -1,4 +1,4 @@ -@layout("/layout/_form.html",{js:["/assets/modular/system/menu/menu_add.js"]}){ +@layout("/layout/_form.html",{js:["/assets/modular/auth/menu/menu_add.js"]}){