diff --git a/src/main/java/cn/stylefeng/guns/modular/system/config/ConfigViewController.java b/src/main/java/cn/stylefeng/guns/modular/system/config/ConfigViewController.java index ad8a2f6e..ef87ad8d 100644 --- a/src/main/java/cn/stylefeng/guns/modular/system/config/ConfigViewController.java +++ b/src/main/java/cn/stylefeng/guns/modular/system/config/ConfigViewController.java @@ -22,7 +22,8 @@ public class ConfigViewController { */ @GetResource(name = "系统配置-列表-视图", path = "/view/config") public String indexView() { - return "/modular/system/config/sysConfig.html"; + return "/modular/system/config/config.html"; + //return "/modular/system/config/sysConfig.html"; } /** @@ -36,6 +37,17 @@ public class ConfigViewController { return "/modular/system/config/sysConfig_add.html"; } + /** + * 系统配置—新增-视图 + * + * @author jiawei + * @date 2021/1/4 13:34 + */ + @GetResource(name = "系统配置—新增-视图", path = "/view/config/addConfigDictView") + public String addConfigDictView() { + return "/modular/system/config/config_add.html"; + } + /** * 系统配置-修改-视图 * diff --git a/src/main/webapp/assets/common/js/common.js b/src/main/webapp/assets/common/js/common.js index 5d4eb963..93948d5f 100644 --- a/src/main/webapp/assets/common/js/common.js +++ b/src/main/webapp/assets/common/js/common.js @@ -11,6 +11,9 @@ Feng.parseData = function (res) { "data": res.data.rows //解析数据列表 }; }; +/* 设置分页请求参数 */ +Feng.pageRequest = {pageName: 'pageNo', limitName: 'pageSize'}; + Feng.info = function (info) { top.layer.msg(info, {icon: 6}); }; @@ -146,7 +149,10 @@ layui.config({ iconPicker: '../../expand/module/iconPicker/iconPicker', ztree: '../../expand/module/ztree/ztree-object', HttpRequest: '../../expand/module/HttpRequest/HttpRequest', - func: '../../expand/module/func/func' + func: '../../expand/module/func/func', + dict: '../../expand/module/dict/dict', + gunsSelect: '../../expand/module/gunsSelect/gunsSelect' + }).use(['layer', 'admin'], function () { var $ = layui.jquery; var layer = layui.layer; diff --git a/src/main/webapp/assets/expand/module/dict/dict.js b/src/main/webapp/assets/expand/module/dict/dict.js new file mode 100644 index 00000000..32bab719 --- /dev/null +++ b/src/main/webapp/assets/expand/module/dict/dict.js @@ -0,0 +1,44 @@ +/** + * 基于xmSelect封装字典通用下拉选项 + * v1.0 + * @author 陈金龙 + * @date 2021/1/25 10:59 + */ + +layui.define(['jquery', 'HttpRequest', 'xmSelect'], function (exports) { + "use strict"; + var dict = function () { + this.v = '1.0'; + }, + $ = layui.$, + HttpRequest = layui.HttpRequest, + xmSelect = layui.xmSelect; + + dict.prototype.render = function (options) { + var opts = options, + url = opts.url || Feng.ctxPath + '/dict/getDictList', + method = opts.method || 'get', + code = opts.code, + elem = opts.elem; + var xm = xmSelect.render({ + el: elem, + radio: true, //单选 + toolbar: {show: true}, //开启工具栏 + data: [] + }) + new HttpRequest(url, method, function (obj) { + //转换成xmSelect格式数据 + for (var i = 0; i < obj.data.length; i++) { + obj.data[i].name = obj.data[i].dictName; + obj.data[i].value = obj.data[i].dictCode; + } + xm.update({ + data: obj.data, + autoRow: true, + }); + }, function (data) { + }).set("dictTypeCode", code).start(); + return new dict(); + }; + exports('dict', new dict()); +}); \ No newline at end of file diff --git a/src/main/webapp/assets/expand/module/dict/readme.md b/src/main/webapp/assets/expand/module/dict/readme.md new file mode 100644 index 00000000..f642fe6b --- /dev/null +++ b/src/main/webapp/assets/expand/module/dict/readme.md @@ -0,0 +1,15 @@ +1.添加html标签 +
+ +2.引入layui 模块组件'dict' +layui.use(['dict'], function () { + + var dict = layui.dict; + // 渲染组件 + dict.render({ + elem: '#demo2', //控件 + code: '' //字典dictTypeCode + }); + +} + diff --git a/src/main/webapp/assets/expand/module/gunsSelect/gunsSelect.js b/src/main/webapp/assets/expand/module/gunsSelect/gunsSelect.js new file mode 100644 index 00000000..ac02165d --- /dev/null +++ b/src/main/webapp/assets/expand/module/gunsSelect/gunsSelect.js @@ -0,0 +1,54 @@ +/** + * 封装通用选择组件 + * + * v1.0 + * 目前仅支持下拉框 + * + * @author 陈金龙 + * @date 2021/1/25 10:59 + */ +layui.define(['jquery', 'HttpRequest', 'xmSelect', 'form'], function (exports) { + "use strict"; + var gunsSelect = function () { + this.v = '1.0'; + }, + $ = layui.$, + HttpRequest = layui.HttpRequest, + form = layui.form; + + gunsSelect.prototype.render = function (options) { + + var opts = options, + url = opts.url, + method = opts.method || 'get', + where = opts.where, + fields = opts.fields || {name: 'name', value: 'value'}, + elem = opts.elem; + //渲染 + //渲染 + + var a = { + init: function () { + new HttpRequest(url, method, function (obj) { + for (var i = 0; i < obj.data.length; i++) { + $(elem).append(''); + } + form.render(); + }, function (data) { + }).set(where).start(); + } + } + + var common = { + get: function (obj, key) { + return obj[key]; + } + }; + + a.init(); + return new gunsSelect(); + + + }; + exports('gunsSelect', new gunsSelect()); +}); \ No newline at end of file diff --git a/src/main/webapp/assets/expand/module/gunsSelect/readme.md b/src/main/webapp/assets/expand/module/gunsSelect/readme.md new file mode 100644 index 00000000..4d8d0a33 --- /dev/null +++ b/src/main/webapp/assets/expand/module/gunsSelect/readme.md @@ -0,0 +1,17 @@ +1.添加html标签 + + +2.引入layui 模块组件'dict' +layui.use(['gunsSelect'], function () { + var gunsSelect = layui.gunsSelect; + // 渲染组件 + gunsSelect.render({ + url: Feng.ctxPath + '/dict/getDictList', + elem: '#city', + fields: {name: 'dictName', value: 'dictCode'}, + where:{code:123} + }); +} + diff --git a/src/main/webapp/assets/modular/system/config/config.js b/src/main/webapp/assets/modular/system/config/config.js new file mode 100644 index 00000000..363f70e0 --- /dev/null +++ b/src/main/webapp/assets/modular/system/config/config.js @@ -0,0 +1,186 @@ +layui.use(['layer', 'form', 'table', 'util', 'admin', 'func', 'HttpRequest'], function () { + var $ = layui.jquery; + var layer = layui.layer; + var form = layui.form; + var table = layui.table; + var admin = layui.admin; + var HttpRequest = layui.HttpRequest; + var func = layui.func; + var dictTypeObj; // 左表选中数据 + + var Dict = { + tableId: "dictTable", + }; + + var DictType = { + tableId: "dictTypeTable" + }; + + + /* 字典类型-点击新增对话框 */ + DictType.openAddDlg = function (data) { + console.log(data); + func.open({ + height: 680, + title: '添加系统配置', + content: Feng.ctxPath + '/view/config/addView?groupCode=' + data.dictCode, + tableId: Dict.tableId + }); + }; + + /* 字典类型-点击编辑对话框 */ + DictType.openEditDlg = function (data) { + func.open({ + height: 680, + title: '修改系统配置', + content: Feng.ctxPath + '/view/config/editView?configId=' + data.configId, + tableId: Dict.tableId + }); + }; + + /* 字典类型-点击删除 */ + DictType.onDeleteItem = function (data) { + var operation = function () { + var httpRequest = new HttpRequest(Feng.ctxPath + "/sysConfig/delete", 'post', function (data) { + Feng.success("删除成功!"); + table.reload(Dict.tableId); + }, function (data) { + Feng.error(data.message + "!"); + }); + httpRequest.set(data); + httpRequest.start(true); + }; + Feng.confirm("是否删除?", operation); + }; + + /* 字典类型-点击搜索 */ + form.on('submit(dictTypeTbSearch)', function (data) { + dictTypeTable.reload({where: data.field}); + return false; + }); + + /* 字典类型-点击表格头工具栏 */ + table.on('toolbar(dictTypeTable)', function (obj) { + var data = dictTypeObj.data; + if (obj.event === 'add') { // 添加 + Dict.openAddDlg(); + } else if (obj.event === 'edit') { // 修改 + DictType.openEditDlg(data); + } else if (obj.event === 'del') { // 删除 + Dict.onDeleteItem(data); + } + }); + + /* 字典类型-渲染表格 */ + var dictTypeTable = table.render({ + elem: '#dictTypeTable', + url: Feng.ctxPath + '/dict/getConfigGroupPage', + height: 'full-100', + toolbar: '#dictTypeHtbBar', + defaultToolbar: [], //默认表格头部右侧工具栏 + cols: [[ + {type: 'numbers'}, + {field: 'dictName', title: '类型'}, + {field: 'dictCode', title: '编码'} + ]], + done: function (res, curr, count) { + //加载后自动选中第一行并出发click事件 + $('#dictTypeTable+.layui-table-view .layui-table-body tbody>tr:first').trigger('click'); + }, + parseData: Feng.parseData //解析成 table 组件所规定的数据格式 + }); + + /* 字典类型-监听行单击事件 */ + table.on('row(dictTypeTable)', function (obj) { + dictTypeObj = obj; + obj.tr.addClass('layui-table-click').siblings().removeClass('layui-table-click'); + dictTable.reload({ + where: {groupCode: obj.data.dictCode}, + page: {curr: 1}, + url: Feng.ctxPath + '/sysConfig/page' + }); + }); + + + /* 字典-点击新增对话框 */ + Dict.openAddDlg = function (data) { + func.open({ + height: 680, + title: '添加字典', + content: Feng.ctxPath + '/view/config/addConfigDictView', + tableId: DictType.tableId + }); + }; + + /* 字典-点击编辑对话框 */ + Dict.openEditDlg = function (data) { + func.open({ + height: 680, + title: '修改字典', + content: Feng.ctxPath + '/view/dict/editView?dictId=' + data.dictId, + tableId: Dict.tableId + }); + }; + + /* 字典-点击删除 */ + Dict.onDeleteItem = function (data) { + var operation = function () { + var httpRequest = new HttpRequest(Feng.ctxPath + "/dict/deleteDict", 'post', function (data) { + Feng.success("删除成功!"); + table.reload(DictType.tableId); + }, function (data) { + Feng.error("删除失败!" + data.message + "!"); + }); + httpRequest.set(data); + httpRequest.start(true); + }; + Feng.confirm("是否删除?", operation); + }; + + /* 字典-点击搜索 */ + form.on('submit(dictTbSearch)', function (data) { + //赋值左表dictTypeCode + data.field.dictTypeCode = dictTypeObj.data.dictTypeCode; + dictTable.reload({where: data.field}); + return false; + }); + + /* 字典-点击操作工具栏 */ + table.on('tool(dictTable)', function (obj) { + var data = obj.data; + if (obj.event === 'edit') { // 修改 + DictType.openEditDlg(data); + } else if (obj.event === 'del') { // 删除 + DictType.onDeleteItem(data); + } + }); + + // 添加按钮点击事件 + $('#btnAdd').click(function () { + console.log(dictTypeObj.data); + DictType.openAddDlg(dictTypeObj.data); + return false; + }); + + /* 字典-渲染表格 */ + var dictTable = table.render({ + elem: '#dictTable', + data: [], + height: 'full-100', + page: true, + //toolbar: '#dictHtbBar', + cellMinWidth: 100, + cols: [[ + {type: 'checkbox'}, + {type: 'numbers'}, + {field: 'configId', hide: true, title: '主键'}, + {field: 'configName', sort: true, title: '名称'}, + {field: 'configCode', sort: true, title: '属性编码'}, + {field: 'configValue', sort: true, title: '属性值'}, + {field: 'remark', sort: true, title: '备注'}, + {align: 'center', toolbar: '#dictTbBar', title: '操作'} + ]], + parseData: Feng.parseData, + request: Feng.pageRequest + }); +}); \ No newline at end of file diff --git a/src/main/webapp/assets/modular/system/config/config_add.js b/src/main/webapp/assets/modular/system/config/config_add.js new file mode 100644 index 00000000..340f4847 --- /dev/null +++ b/src/main/webapp/assets/modular/system/config/config_add.js @@ -0,0 +1,25 @@ +layui.use(['form', 'admin', 'HttpRequest'], function () { + var $ = layui.jquery; + var form = layui.form; + var admin = layui.admin; + var HttpRequest = layui.HttpRequest; + + //获取信息详情填充表单 + var request = new HttpRequest(Feng.ctxPath + '/dictType/getConfigDictTypeDetail', 'get'); + var result = request.start(); + form.val('dictForm', result.data); + + //表单提交事件 + form.on('submit(btnSubmit)', function (data) { + var request = new HttpRequest(Feng.ctxPath + "/dict/addDict", '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); + }); +}); \ No newline at end of file diff --git a/src/main/webapp/assets/modular/system/config/sysConfig_add.js b/src/main/webapp/assets/modular/system/config/sysConfig_add.js index 38a8f54d..78cb7cc4 100644 --- a/src/main/webapp/assets/modular/system/config/sysConfig_add.js +++ b/src/main/webapp/assets/modular/system/config/sysConfig_add.js @@ -1,39 +1,14 @@ -/** - * 修改 - */ -var SysConfigInfoDlg = { - data: {} -}; - layui.use(['form', 'admin', 'HttpRequest'], function () { var $ = layui.jquery; var form = layui.form; var admin = layui.admin; var HttpRequest = layui.HttpRequest; - // 初始化所属分类字典下拉 - var activeDictSelect = function () { - $("#groupCode").html(''); - - //要删掉 - $("#groupCode").append(''); - - form.render(); - }; + $("#groupCode").val(Feng.getUrlParam("groupCode")); //表单提交事件 form.on('submit(btnSubmit)', function (data) { - - SysConfigInfoDlg.data = $.extend({"sysFlag": data.field.sysFlag ? data.field.sysFlag : 'N'}, data.field) - - var groupCode = $("#groupCode").find("option:selected").val() - if (!groupCode) { - Feng.error("所属分类不能为空") - return false; - } - SysConfigInfoDlg.data = $.extend({"groupCode": groupCode}, data.field) - var httpRequest = new HttpRequest(Feng.ctxPath + "/sysConfig/add", 'post', function (data) { admin.closeThisDialog(); Feng.success("添加成功!"); @@ -42,11 +17,7 @@ layui.use(['form', 'admin', 'HttpRequest'], function () { admin.closeThisDialog(); Feng.error("添加失败!" + data.message) }); - httpRequest.set(SysConfigInfoDlg.data); + httpRequest.set(data.field); httpRequest.start(true); }); - - // 常量所属分类动态赋值 - activeDictSelect(); - }); diff --git a/src/main/webapp/assets/modular/system/config/sysConfig_edit.js b/src/main/webapp/assets/modular/system/config/sysConfig_edit.js index 5a1c35f4..dbc8e929 100644 --- a/src/main/webapp/assets/modular/system/config/sysConfig_edit.js +++ b/src/main/webapp/assets/modular/system/config/sysConfig_edit.js @@ -1,15 +1,7 @@ -/** - * 详情对话框 - */ -var SysConfigInfoDlg = { - data: {} -}; - -layui.use(['form', 'admin', 'selectPlus', 'HttpRequest'], function () { +layui.use(['form', 'admin', 'HttpRequest'], function () { var $ = layui.jquery; var form = layui.form; var admin = layui.admin; - var selectPlus = layui.selectPlus; var HttpRequest = layui.HttpRequest; // 获取详情信息,填充表单 @@ -18,45 +10,9 @@ layui.use(['form', 'admin', 'selectPlus', 'HttpRequest'], function () { form.val('sysConfigForm', result.data); - // 系统参数样式 - if (result.data) { - var mData = result.data; - if (mData.sysFlag == 'Y') { - $('input[name="sysFlag"]').attr('checked', 'checked'); //改变开关为 开 - } else { - $('input[name="sysFlag"]').removeAttr('checked'); //改变开关为 关 - } - /*改变是否系统参数样式*/ - $("input[name='sysFlag']").attr("disabled", "true"); - form.render(); //系统参数禁用 - $("input[name='sysFlag']").next().removeClass("layui-form-onswitch"); // 系统参数去掉样式 - } - - // 初始化所属分类字典下拉 - var activeDictSelect = function () { - - $("#groupCode").html(''); - - //要删掉 - $("#groupCode").append(''); - $("#groupCode").val(result.data.groupCode); - form.render(); - - }; - //表单提交事件 form.on('submit(btnSubmit)', function (data) { - - SysConfigInfoDlg.data = $.extend({"sysFlag": data.field.sysFlag ? data.field.sysFlag : 'N'}, data.field) - - var groupCode = $("#groupCode").find("option:selected").val() - if (!groupCode) { - Feng.error("所属分类不能为空") - return false; - } - SysConfigInfoDlg.data = $.extend({"groupCode": groupCode}, data.field) - var httpRequest = new HttpRequest(Feng.ctxPath + "/sysConfig/edit", 'post', function (data) { admin.closeThisDialog(); Feng.success("修改成功!"); @@ -65,11 +21,8 @@ layui.use(['form', 'admin', 'selectPlus', 'HttpRequest'], function () { admin.closeThisDialog(); Feng.error("修改失败!" + data.message) }); - httpRequest.set(SysConfigInfoDlg.data); + httpRequest.set(data.field); httpRequest.start(true); }); - // 常量所属分类动态赋值 - activeDictSelect(); - }); diff --git a/src/main/webapp/assets/modular/system/log/login_log.js b/src/main/webapp/assets/modular/system/log/login_log.js index 0b114cec..c650baa0 100644 --- a/src/main/webapp/assets/modular/system/log/login_log.js +++ b/src/main/webapp/assets/modular/system/log/login_log.js @@ -86,7 +86,8 @@ layui.use(['layer', 'table', 'HttpRequest', 'laydate'], function () { height: "full-98", cellMinWidth: 100, cols: LoginLog.initColumn(), - parseData: Feng.parseData + parseData: Feng.parseData, + request: Feng.pageRequest }); // 搜索按钮点击事件 diff --git a/src/main/webapp/assets/modular/system/organization/organization.js b/src/main/webapp/assets/modular/system/organization/organization.js index 183bc4d6..c5c12696 100644 --- a/src/main/webapp/assets/modular/system/organization/organization.js +++ b/src/main/webapp/assets/modular/system/organization/organization.js @@ -36,7 +36,10 @@ layui.use(['layer', 'form', 'table', 'util', 'admin', 'tree', 'dropdown', 'xmSel height: 800, title: '修改机构', content: Feng.ctxPath + '/view/organization/editView?orgId=' + data.id, - tableId: Organization.tableId + tableId: Organization.tableId, + endCallback: function () { + renderTree(); + } }); }; @@ -45,7 +48,10 @@ layui.use(['layer', 'form', 'table', 'util', 'admin', 'tree', 'dropdown', 'xmSel var operation = function () { var httpRequest = new HttpRequest(Feng.ctxPath + "/hrOrganization/delete", 'post', function (data) { Feng.success("删除成功!"); + //刷新表格 table.reload(Organization.tableId); + //刷新树 + renderTree(); }, function (data) { Feng.error("删除失败!" + data.message + "!"); }); @@ -66,8 +72,6 @@ layui.use(['layer', 'form', 'table', 'util', 'admin', 'tree', 'dropdown', 'xmSel selObj = obj; $('#organizationTree').find('.ew-tree-click').removeClass('ew-tree-click'); $(obj.elem).children('.layui-tree-entry').addClass('ew-tree-click'); - - console.log(obj.data); insTb.reload({ where: {orgParentId: obj.data.id}, page: {curr: 1}, diff --git a/src/main/webapp/assets/modular/system/user/user.js b/src/main/webapp/assets/modular/system/user/user.js index cff840d0..a1fec553 100644 --- a/src/main/webapp/assets/modular/system/user/user.js +++ b/src/main/webapp/assets/modular/system/user/user.js @@ -17,6 +17,55 @@ layui.use(['layer', 'form', 'table', 'util', 'admin', 'tree', 'dropdown', 'xmSel tableId: "userTable", //表格id }; + + var Organization = { + + }; + + + /* 点击新增对话框 */ + Organization.openAddDlg = function () { + func.open({ + height: 800, + title: '添加机构', + content: Feng.ctxPath + '/view/organization/addView', + tableId: OrganizationUser.tableId, + endCallback: function () { + renderTree(); + } + }); + }; + + /* 点击编辑对话框 */ + Organization.openEditDlg = function (data) { + func.open({ + height: 800, + title: '修改机构', + content: Feng.ctxPath + '/view/organization/editView?orgId=' + data.id, + tableId: OrganizationUser.tableId, + endCallback: function () { + renderTree(); + } + }); + }; + + /* 点击删除 */ + Organization.delete = function (data) { + var operation = function () { + var httpRequest = new HttpRequest(Feng.ctxPath + "/hrOrganization/delete", 'post', function (data) { + Feng.success("删除成功!"); + table.reload(OrganizationUser.tableId); + //刷新树 + renderTree(); + }, function (data) { + Feng.error("删除失败!" + data.message + "!"); + }); + httpRequest.set(data); + httpRequest.start(true); + }; + Feng.confirm("是否删除?", operation); + }; + /* 点击新增对话框 */ OrganizationUser.openAddDlg = function () { func.open({ @@ -152,6 +201,25 @@ layui.use(['layer', 'form', 'table', 'util', 'admin', 'tree', 'dropdown', 'xmSel return false; }); + /* 添加 */ + $('#organizationAddBtn').click(function () { + Organization.openAddDlg(); + }); + + /* 修改 */ + $('#organizationEditBtn').click(function () { + if (!selObj) return layer.msg('未选择机构', {icon: 2}); + Organization.openEditDlg(selObj.data) + }); + + /* 删除 */ + $('#organizationDelBtn').click(function () { + if (!selObj) return layer.msg('未选择机构', {icon: 2}); + selObj.data.orgId = selObj.data.id; + Organization.delete(selObj.data) + + }); + /* 表格工具条点击事件 */ table.on('tool(userTable)', function (obj) { if (obj.event === 'edit') { // 修改 diff --git a/src/main/webapp/pages/modular/system/config/config.html b/src/main/webapp/pages/modular/system/config/config.html new file mode 100644 index 00000000..49ebdb68 --- /dev/null +++ b/src/main/webapp/pages/modular/system/config/config.html @@ -0,0 +1,109 @@ +@layout("/layout/_container.html",{js:["/assets/modular/system/config/config.js"]}){ + +