From 7168036c493452a59585fe0d48e5f6d25dc501ee Mon Sep 17 00:00:00 2001 From: jiawei <892369583@qq.com> Date: Tue, 5 Jan 2021 20:46:19 +0800 Subject: [PATCH] =?UTF-8?q?=E7=B3=BB=E7=BB=9F=E5=8F=82=E6=95=B0=E6=A8=A1?= =?UTF-8?q?=E5=9D=97=E5=BC=80=E5=8F=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../modular/config/ConfigViewController.java | 54 +++++ .../assets/modular/sysConfig/sysConfig_add.js | 133 ++++--------- .../modular/sysConfig/sysConfig_edit.js | 185 ++++++------------ .../pages/modular/sysConfig/sysConfig.html | 2 +- .../modular/sysConfig/sysConfig_add.html | 76 +++---- .../modular/sysConfig/sysConfig_edit.html | 74 +++---- 6 files changed, 207 insertions(+), 317 deletions(-) create mode 100644 src/main/java/cn/stylefeng/guns/modular/config/ConfigViewController.java diff --git a/src/main/java/cn/stylefeng/guns/modular/config/ConfigViewController.java b/src/main/java/cn/stylefeng/guns/modular/config/ConfigViewController.java new file mode 100644 index 00000000..748f94c1 --- /dev/null +++ b/src/main/java/cn/stylefeng/guns/modular/config/ConfigViewController.java @@ -0,0 +1,54 @@ +package cn.stylefeng.guns.modular.config; + +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: jiawei + * @date: 2021/01/04 12:02 + */ +@Controller +@Slf4j +@ApiResource(name = "系统配置相关页面", path = "config") +public class ConfigViewController { + private String PREFIX = "/modular/sysConfig"; + + /** + * 系统配置-首页-视图 + * + * @author jiawei + * @date 2021/1/4 13:33 + */ + @GetResource(name = "系统配置-列表-视图", path = "", requiredPermission = false, requiredLogin = false) + public String indexView() { + return PREFIX + "/sysConfig.html"; + } + + /** + * 系统配置—新增-视图 + * + * @author jiawei + * @date 2021/1/4 13:34 + * @param + */ + @GetResource(name = "系统配置—新增-视图", path = "/addView", requiredPermission = false, requiredLogin = false) + public String addView() { + return PREFIX + "/sysConfig_add.html"; + } + + /** + * 系统配置-修改-视图 + * + * @author jiawei + * @date 2021/1/4 13:35 + * @param + */ + @GetResource(name = "系统配置-修改-视图", path = "editView", requiredPermission = false, requiredLogin = false) + public String editView() { + return PREFIX + "/sysConfig_edit.html"; + } +} diff --git a/src/main/webapp/assets/modular/sysConfig/sysConfig_add.js b/src/main/webapp/assets/modular/sysConfig/sysConfig_add.js index 1ed786a3..f2a1af47 100644 --- a/src/main/webapp/assets/modular/sysConfig/sysConfig_add.js +++ b/src/main/webapp/assets/modular/sysConfig/sysConfig_add.js @@ -1,128 +1,61 @@ /** - * 添加或者修改页面 + * 修改 */ var SysConfigInfoDlg = { - data: { - name: "", - dictFlag: "", - code: "", - value: "", - remark: "", - createTime: "", - createUser: "", - updateTime: "", - updateUser: "" - } + data: {} }; -layui.use(['form', 'admin', 'ax'], function () { +layui.use(['form', 'admin', 'HttpRequest'], function () { var $ = layui.jquery; - var $ax = layui.ax; var form = layui.form; var admin = layui.admin; + var HttpRequest = layui.HttpRequest; - //默认的激活状态 dict 或者 custom - var status = "dict"; - - //初始化字典选择框 + // 初始化所属分类字典下拉 var activeDictSelect = function () { - $("#dictCodeDiv").show(); - $("#customCodeDiv").hide(); - status = "dict"; - //初始化所有字典类型 - $("#dictTypeId").html(''); - var ajax = new $ax(Feng.ctxPath + "/dictType/listTypes", function (data) { + $("#groupCode").html(''); + // var httpRequest = new HttpRequest(Feng.ctxPath + "/dictType/dropDown", function (data) { + // var dictTypeList = res.data; + // dictTypeList.forEach(function (v, i) { + // $("#groupCode").append(''); + // }) + // form.render(); + // + // }, function (data) { + // }); + // httpRequest.start(); - for (var i = 0; i < data.data.length; i++) { - var dictTypeId = data.data[i].dictTypeId; - var name = data.data[i].name; - var code = data.data[i].code; - $("#dictTypeId").append(''); - } - form.render(); - - }, function (data) { - }); - ajax.start(); - }; - - //初始化非字典选择 - var activeCustomSelect = function () { - $("#dictCodeDiv").hide(); - $("#customCodeDiv").show(); - status = "custom"; + //要删掉 + $("#groupCode").append(''); + form.render(); }; //表单提交事件 form.on('submit(btnSubmit)', function (data) { - //如果是选择字典 - if (status === "dict") { + SysConfigInfoDlg.data = $.extend({"sysFlag":data.field.sysFlag?data.field.sysFlag:'N'},data.field) - var radio = $('input:radio[name="dictValue"]:checked').val(); - - if (!$("#dictTypeId").val() || !radio) { - Feng.error("请选择具体字典!"); - return false; - } - } else { - if (!$("#value").val()) { - Feng.error("请填写参数值!"); - return false; - } + var groupCode = $("#groupCode").find("option:selected").val() + if(!groupCode){ + Feng.error("所属分类不能为空") + return false; } + SysConfigInfoDlg.data = $.extend({"groupCode":groupCode},data.field) - var ajax = new $ax(Feng.ctxPath + "/sysConfig/addItem", function (data) { + var httpRequest = new HttpRequest(Feng.ctxPath + "/sysConfig/add",'post', function (data) { + admin.closeThisDialog(); Feng.success("添加成功!"); - window.location.href = Feng.ctxPath + '/sysConfig' + admin.putTempData('formOk', true); }, function (data) { - Feng.error("添加失败!" + data.responseJSON.message) + admin.closeThisDialog(); + Feng.error("添加失败!" + data.message) }); - ajax.set(data.field); - ajax.start(); - - return false; + httpRequest.set(SysConfigInfoDlg.data); + httpRequest.start(true); }); - //监听单选切换 - form.on('radio(dictChecked)', function (data) { - if (data.value === "Y") { - activeDictSelect(); - } else { - activeCustomSelect(); - } - }); - - //监听字典选择 - form.on('select(dictTypeId)', function (data) { - - var dictTypeId = data.value; - - //初始化字典详细列表 - $("#dictDetails").html(''); - var ajax = new $ax(Feng.ctxPath + "/dict/listDicts", function (data) { - - for (var i = 0; i < data.data.length; i++) { - var name = data.data[i].name; - var code = data.data[i].code; - $("#dictDetails").append(''); - } - form.render(); - - }, function (data) { - }); - ajax.set("dictTypeId", dictTypeId); - ajax.start(); - - }); - - //返回按钮 - $("#backupPage").click(function () { - window.location.href = Feng.ctxPath + '/sysConfig' - }); - - //显示字典编码选择 + // 常量所属分类动态赋值 activeDictSelect(); }); \ No newline at end of file diff --git a/src/main/webapp/assets/modular/sysConfig/sysConfig_edit.js b/src/main/webapp/assets/modular/sysConfig/sysConfig_edit.js index 3721dfe6..64f6fb17 100644 --- a/src/main/webapp/assets/modular/sysConfig/sysConfig_edit.js +++ b/src/main/webapp/assets/modular/sysConfig/sysConfig_edit.js @@ -2,158 +2,83 @@ * 详情对话框 */ var SysConfigInfoDlg = { - data: { - name: "", - dictFlag: "", - code: "", - value: "", - remark: "", - createTime: "", - createUser: "", - updateTime: "", - updateUser: "" - } + data: {} }; -layui.use(['form', 'admin', 'ax'], function () { +layui.use(['form', 'admin','selectPlus', 'HttpRequest'], function () { var $ = layui.jquery; - var $ax = layui.ax; var form = layui.form; var admin = layui.admin; + var selectPlus = layui.selectPlus; + var HttpRequest = layui.HttpRequest; - //获取详情信息,填充表单 - var ajax = new $ax(Feng.ctxPath + "/sysConfig/detail?id=" + Feng.getUrlParam("id")); - var result = ajax.start(); + // 获取详情信息,填充表单 + var httpRequest = new HttpRequest(Feng.ctxPath + "/sysConfig/detail?configId=" + Feng.getUrlParam("configId"),'get'); + var result = httpRequest.start(); form.val('sysConfigForm', result.data); - //初始化字典选择框 - var activeDictSelect = function () { - $("#dictCodeDiv").show(); - $("#customCodeDiv").hide(); - status = "dict"; - //初始化所有字典类型 - $("#dictTypeId").html(''); - var ajax = new $ax(Feng.ctxPath + "/dictType/listTypes", function (data) { - for (var i = 0; i < data.data.length; i++) { - var dictTypeId = data.data[i].dictTypeId; - var name = data.data[i].name; - var code = data.data[i].code; - $("#dictTypeId").append(''); - } - form.render(); - - }, function (data) { - }); - ajax.start(); - }; - - //初始化非字典选择 - var activeCustomSelect = function () { - $("#dictCodeDiv").hide(); - $("#customCodeDiv").show(); - status = "custom"; - }; - - //更新字典详情列表 - var updateDictDetail = function (dictTypeId, activeCode) { - $("#dictDetails").html(''); - var ajax = new $ax(Feng.ctxPath + "/dict/listDicts", function (data) { - - for (var i = 0; i < data.data.length; i++) { - var name = data.data[i].name; - var code = data.data[i].code; - - if (activeCode === code) { - $("#dictDetails").append(''); - } else { - $("#dictDetails").append(''); - } - - } - form.render(); - - }, function (data) { - }); - ajax.set("dictTypeId", dictTypeId); - ajax.start(); - }; - - //监听单选切换 - form.on('radio(dictChecked)', function (data) { - if (data.value === "Y") { - activeDictSelect(); - } else { - activeCustomSelect(); + // 系统参数样式 + 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(''); + // var httpRequest = new HttpRequest(Feng.ctxPath + "/dictType/dropDown", function (data) { + // var dictTypeList = res.data; + // dictTypeList.forEach(function (v, i) { + // $("#groupCode").append(''); + // }) + // form.render(); + // + // }, function (data) { + // }); + // httpRequest.start(); + + //要删掉 + $("#groupCode").append(''); + $("#groupCode").val(result.data.groupCode); + form.render(); + }; //表单提交事件 form.on('submit(btnSubmit)', function (data) { - //如果是选择字典 - if (status === "dict") { - var radio = $('input:radio[name="dictValue"]:checked').val(); + SysConfigInfoDlg.data = $.extend({"sysFlag":data.field.sysFlag?data.field.sysFlag:'N'},data.field) - if (!$("#dictTypeId").val() || !radio) { - Feng.error("请选择具体字典!"); - return false; - } - } else { - if (!$("#value").val()) { - Feng.error("请填写参数值!"); - return false; - } + var groupCode = $("#groupCode").find("option:selected").val() + if(!groupCode){ + Feng.error("所属分类不能为空") + return false; } + SysConfigInfoDlg.data = $.extend({"groupCode":groupCode},data.field) - var ajax = new $ax(Feng.ctxPath + "/sysConfig/editItem", function (data) { - Feng.success("更新成功!"); - window.location.href = Feng.ctxPath + '/sysConfig' + var httpRequest = new HttpRequest(Feng.ctxPath + "/sysConfig/edit",'post', function (data) { + admin.closeThisDialog(); + Feng.success("修改成功!"); + admin.putTempData('formOk', true); }, function (data) { - Feng.error("更新失败!" + data.responseJSON.message) + admin.closeThisDialog(); + Feng.error("修改失败!" + data.message) }); - ajax.set(data.field); - ajax.start(); - - return false; + httpRequest.set(SysConfigInfoDlg.data); + httpRequest.start(true); }); - //监听字典选择 - form.on('select(dictTypeId)', function (data) { - - var dictTypeId = data.value; - - //初始化字典详细列表 - updateDictDetail(dictTypeId); - - }); - - //返回按钮 - $("#backupPage").click(function () { - window.location.href = Feng.ctxPath + '/sysConfig' - }); - - //如果当前配置是带字典类型,则初始化字典类型选择 - if (result.data.dictFlag === 'Y') { - activeDictSelect(); - - //更新选项 - $("#dictTypeId").val(result.data.dictTypeId); - form.render(); - - //更新字典类型的详情 - updateDictDetail(result.data.dictTypeId, result.data.value); - } else { - activeCustomSelect(); - } - - //如果是系统类型,则不能改变取值范围和字典类型 - if(result.data.code.indexOf('GUNS_') === 0){ - $("[name='dictFlag']").attr("disabled","disabled"); - $("#dictTypeId").attr("disabled","disabled"); - form.render(); - } + // 常量所属分类动态赋值 + activeDictSelect(); }); \ No newline at end of file diff --git a/src/main/webapp/pages/modular/sysConfig/sysConfig.html b/src/main/webapp/pages/modular/sysConfig/sysConfig.html index 7be7e141..8d45f8c6 100644 --- a/src/main/webapp/pages/modular/sysConfig/sysConfig.html +++ b/src/main/webapp/pages/modular/sysConfig/sysConfig.html @@ -12,7 +12,7 @@
- +
diff --git a/src/main/webapp/pages/modular/sysConfig/sysConfig_add.html b/src/main/webapp/pages/modular/sysConfig/sysConfig_add.html index b0fae0ea..ffa84f97 100644 --- a/src/main/webapp/pages/modular/sysConfig/sysConfig_add.html +++ b/src/main/webapp/pages/modular/sysConfig/sysConfig_add.html @@ -1,59 +1,48 @@ -@layout("/layout/_container.html",{js:["/assets/modular/sysConfig/sysConfig_add.js"]}){ - -
- 添加 -
- -
-
-
-
- +@layout("/layout/_form.html",{js:["/assets/modular/sysConfig/sysConfig_add.js"]}){ + +
+
+
基本信息
+
+
- +
- +
+
- +
- + +
+
+ +
+ +
+
-
推荐采用下划线大写风格,例如,KAPTCH_OPEN,若以GUNS_开头则是系统常量不可删除。
-
-
- -
- - -
-
如果选择字典,则取值来自于 系统管理->字典管理
-
-
- -
- -
-
-
- -
- -
+ +
+ +
+ +
+
- +
- +
@@ -65,12 +54,11 @@
- +
- +
-
- + @} \ No newline at end of file diff --git a/src/main/webapp/pages/modular/sysConfig/sysConfig_edit.html b/src/main/webapp/pages/modular/sysConfig/sysConfig_edit.html index fcc59832..ed5df831 100644 --- a/src/main/webapp/pages/modular/sysConfig/sysConfig_edit.html +++ b/src/main/webapp/pages/modular/sysConfig/sysConfig_edit.html @@ -1,59 +1,49 @@ -@layout("/layout/_container.html",{js:["/assets/modular/sysConfig/sysConfig_edit.js"]}){ +@layout("/layout/_form.html",{js:["/assets/modular/sysConfig/sysConfig_edit.js"]}){ -
- 修改 -
- -
-
-
-
- + +
+
+
基本信息
+
+
- +
- +
+
- +
- + +
+
+ +
+ +
+
-
编码填写后不可修改,系统字典(GUNS_开头)添加后不可修改取值范围和字典类型
-
-
- -
- - -
-
如果选择字典,则取值来自于 系统管理->字典管理
-
-
- -
- -
-
-
- -
- -
+ +
+ +
+ +
+
- +
- +
@@ -65,12 +55,12 @@
- +
- +
-
+ @} \ No newline at end of file