From 5622fe502ea9b0e7e009f387bbb2ad0e0885df7c Mon Sep 17 00:00:00 2001 From: fengshuonan Date: Wed, 6 Jan 2021 16:37:40 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0app=E7=95=8C=E9=9D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../guns/modular/app/AppViewController.java | 52 ++++++ .../webapp/assets/modular/auth/app/app.js | 167 ++++++++++++++++++ .../webapp/assets/modular/auth/app/app_add.js | 23 +++ .../assets/modular/auth/app/app_edit.js | 29 +++ .../webapp/pages/modular/auth/app/app.html | 44 +++++ .../pages/modular/auth/app/app_add.html | 31 ++++ .../pages/modular/auth/app/app_edit.html | 31 ++++ 7 files changed, 377 insertions(+) create mode 100644 src/main/java/cn/stylefeng/guns/modular/app/AppViewController.java create mode 100644 src/main/webapp/assets/modular/auth/app/app.js create mode 100644 src/main/webapp/assets/modular/auth/app/app_add.js create mode 100644 src/main/webapp/assets/modular/auth/app/app_edit.js create mode 100644 src/main/webapp/pages/modular/auth/app/app.html create mode 100644 src/main/webapp/pages/modular/auth/app/app_add.html create mode 100644 src/main/webapp/pages/modular/auth/app/app_edit.html diff --git a/src/main/java/cn/stylefeng/guns/modular/app/AppViewController.java b/src/main/java/cn/stylefeng/guns/modular/app/AppViewController.java new file mode 100644 index 00000000..f711a0ba --- /dev/null +++ b/src/main/java/cn/stylefeng/guns/modular/app/AppViewController.java @@ -0,0 +1,52 @@ +package cn.stylefeng.guns.modular.app; + +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 13:32 + */ +@Controller +@Slf4j +@ApiResource(name = "应用管理界面") +public class AppViewController { + + /** + * 应用管理首页 + * + * @author fengshuonan + * @date 2021/1/6 13:32 + */ + @GetResource(name = "应用管理首页", path = "/view/app") + public String appIndex() { + return "/modular/auth/app/app.html"; + } + + /** + * 新增角色界面 + * + * @author fengshuonan + * @date 2021/1/6 13:37 + */ + @GetResource(name = "新增角色界面", path = "/view/app/add") + public String appAdd() { + return "/modular/auth/app/app_add.html"; + } + + /** + * 编辑角色界面 + * + * @author fengshuonan + * @date 2021/1/6 13:37 + */ + @GetResource(name = "编辑角色界面", path = "/view/app/edit") + public String appEdit() { + return "/modular/auth/app/app_edit.html"; + } + +} diff --git a/src/main/webapp/assets/modular/auth/app/app.js b/src/main/webapp/assets/modular/auth/app/app.js new file mode 100644 index 00000000..e91940a1 --- /dev/null +++ b/src/main/webapp/assets/modular/auth/app/app.js @@ -0,0 +1,167 @@ +layui.use(['table', 'HttpRequest', 'func', 'form'], function () { + var $ = layui.$; + var table = layui.table; + var HttpRequest = layui.HttpRequest; + var func = layui.func; + var form = layui.form; + + /** + * 初始化参数 + */ + var App = { + tableId: "appTable" + }; + + /** + * 初始化表格的列 + */ + App.initColumn = function () { + return [[ + {type: 'radio'}, + {field: 'appId', hide: true, title: '主键'}, + {field: 'appName', sort: true, align: "center", title: '应用名称'}, + {field: 'appCode', sort: true, align: "center", title: '应用编码'}, + {field: 'activeFlag', sort: true, align: "center", title: '是否激活', templet: '#activeTpl'}, + {field: 'statusFlag', sort: true, align: "center", title: '是否启用', templet: '#statusTpl'}, + {field: 'createTime', sort: true, align: "center", title: '创建时间'}, + {field: 'updateTime', sort: true, align: "center", title: '更新时间'}, + {align: 'center', toolbar: '#tableBar', title: '操作'} + ]]; + }; + + /** + * 点击查询按钮 + */ + App.search = function () { + var queryData = {}; + queryData['appName'] = $("#appName").val(); + queryData['appCode'] = $("#appCode").val(); + table.reload(App.tableId, { + where: queryData, page: {curr: 1} + }); + }; + + /** + * 添加应用对话框 + */ + App.openAddDlg = function () { + func.open({ + height: 500, + title: '添加应用', + content: Feng.ctxPath + '/view/app/add', + tableId: App.tableId + }); + }; + + /** + * 编辑应用对话框 + * + * @param data 点击按钮时候的行数据 + */ + App.openEditDlg = function (data) { + func.open({ + height: 500, + title: '修改应用', + content: Feng.ctxPath + '/view/app/edit?appId=' + data.appId, + tableId: App.tableId + }); + }; + + /** + * 更新应用为激活状态 + */ + App.updateActiveFlag = function (appId) { + var httpRequest = new HttpRequest(Feng.ctxPath + "/sysApp/updateActiveFlag", 'post', function (data) { + Feng.success("激活成功!"); + table.reload(App.tableId); + }, function (data) { + Feng.error("激活失败!" + data.message); + table.reload(App.tableId); + }); + httpRequest.set("appId", appId); + httpRequest.start(true); + }; + + /** + * 更新应用状态 + */ + App.updateStatus = function (appId, statusFlag) { + var httpRequest = new HttpRequest(Feng.ctxPath + "/sysApp/updateStatus", 'post', function (data) { + Feng.success("修改成功!"); + }, function (data) { + Feng.error("修改失败!" + data.message); + table.reload(App.tableId); + }); + httpRequest.set("appId", appId); + httpRequest.set("statusFlag", statusFlag); + httpRequest.start(true); + }; + + + /** + * 点击删除 + * + * @param data 点击按钮时候的行数据 + */ + App.onDeleteItem = function (data) { + var operation = function () { + var request = new HttpRequest(Feng.ctxPath + "/sysApp/delete", 'post', function (data) { + Feng.success("删除成功!"); + table.reload(App.tableId); + }, function (data) { + Feng.error("删除失败!" + data.message + "!"); + }); + request.set("appId", data.appId); + request.start(true); + }; + Feng.confirm("是否删除?", operation); + }; + + // 渲染表格 + var tableResult = table.render({ + elem: '#' + App.tableId, + url: Feng.ctxPath + '/sysApp/page', + page: true, + height: "full-158", + cellMinWidth: 100, + cols: App.initColumn(), + request: {pageName: 'pageNo', limitName: 'pageSize'}, + parseData: Feng.parseData + }); + + // 搜索按钮点击事件 + $('#btnSearch').click(function () { + App.search(); + }); + + // 添加按钮点击事件 + $('#btnAdd').click(function () { + App.openAddDlg(); + }); + + // 工具条点击事件 + table.on('tool(' + App.tableId + ')', function (obj) { + var data = obj.data; + var layEvent = obj.event; + + if (layEvent === 'edit') { + App.openEditDlg(data); + } else if (layEvent === 'delete') { + App.onDeleteItem(data); + } + }); + + // 修改激活标识 + form.on('switch(activeFilter)', function (obj) { + var appId = obj.elem.value; + App.updateActiveFlag(appId); + }); + + // 修改状态 + form.on('switch(statusFilter)', function (obj) { + var appId = obj.elem.value; + var checked = obj.elem.checked ? 1 : 2; + App.updateStatus(appId, checked); + }); + +}); diff --git a/src/main/webapp/assets/modular/auth/app/app_add.js b/src/main/webapp/assets/modular/auth/app/app_add.js new file mode 100644 index 00000000..97741dd4 --- /dev/null +++ b/src/main/webapp/assets/modular/auth/app/app_add.js @@ -0,0 +1,23 @@ +/** + * 添加应用 + */ +layui.use(['form', 'admin', 'HttpRequest'], function () { + var form = layui.form; + var admin = layui.admin; + var HttpRequest = layui.HttpRequest; + + //表单提交事件 + form.on('submit(btnSubmit)', function (data) { + var request = new HttpRequest(Feng.ctxPath + "/sysApp/add", 'post', function (data) { + admin.closeThisDialog(); + Feng.success("添加成功!"); + admin.putTempData('formOk', true); + }, function (data) { + admin.closeThisDialog(); + Feng.error("添加失败!" + data.message); + }); + request.set(data.field); + request.start(true); + }); + +}); diff --git a/src/main/webapp/assets/modular/auth/app/app_edit.js b/src/main/webapp/assets/modular/auth/app/app_edit.js new file mode 100644 index 00000000..b5d37093 --- /dev/null +++ b/src/main/webapp/assets/modular/auth/app/app_edit.js @@ -0,0 +1,29 @@ +/** + * 编辑应用 + */ +layui.use(['form', 'admin', 'HttpRequest'], function () { + var form = layui.form; + var admin = layui.admin; + var HttpRequest = layui.HttpRequest; + + // 获取应用详情 + var request = new HttpRequest(Feng.ctxPath + "/sysApp/detail?appId=" + Feng.getUrlParam("appId"), 'get'); + var result = request.start(); + + form.val('appForm', result.data); + + // 表单提交事件 + form.on('submit(btnSubmit)', function (data) { + var request = new HttpRequest(Feng.ctxPath + "/sysApp/edit", 'post', function (data) { + Feng.success("修改成功!"); + admin.putTempData('formOk', true); + admin.closeThisDialog(); + }, function (data) { + Feng.error("修改失败!" + data.message); + admin.closeThisDialog(); + }); + request.set(data.field); + request.start(true); + }); + +}); diff --git a/src/main/webapp/pages/modular/auth/app/app.html b/src/main/webapp/pages/modular/auth/app/app.html new file mode 100644 index 00000000..9028f368 --- /dev/null +++ b/src/main/webapp/pages/modular/auth/app/app.html @@ -0,0 +1,44 @@ +@layout("/layout/_container.html", {js:["/assets/modular/auth/app/app.js"]}){ + +
+ 应用管理 +
+ +
+
+
+
+
+
+
+
+ +
+
+ +
+
+ + +
+
+
+
+
+
+
+
+
+ + + + + +@} 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"]}){ + +
+
+
+
+
+ +
+ +
+ +
+
+
+ +
+ +
+
+
+
+
+
+
+ + +
+ +
+@}