From ad5eb5aa483d86d3c94d1642eb15911593fdff88 Mon Sep 17 00:00:00 2001
From: Guo XIn <371864209@qq.com>
Date: Thu, 31 Aug 2023 10:08:43 +0800
Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=EF=BC=9A=E7=BB=BC=E5=90=88?=
=?UTF-8?q?=E6=B5=8F=E8=A7=88=E7=B3=BB=E7=BB=9F=E8=B5=84=E6=BA=90=E6=9F=A5?=
=?UTF-8?q?=E8=AF=A2=E9=A1=B5=E9=9D=A2=E5=A2=9E=E5=8A=A0=E6=95=B0=E6=8D=AE?=
=?UTF-8?q?=E8=A1=A8=E8=A1=A8=E5=A4=B4=E9=85=8D=E7=BD=AE=E5=8A=9F=E8=83=BD?=
=?UTF-8?q?=E6=8C=89=E9=92=AE=E5=92=8C=E9=A1=B5=E9=9D=A2?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../controller/BrowserIndexController.java | 14 +--
.../src/main/resources/static/js/browser.js | 112 +++++++++++++++++-
.../src/main/resources/view/browser.html | 57 ++++++---
.../controller/SysTheadConfigController.java | 42 +++++++
.../shandan/system/entity/SysTheadConfig.java | 65 ++++++++++
.../system/mapper/SysTheadConfigMapper.java | 15 +++
.../system/service/SysTheadConfigService.java | 16 +++
.../impl/SysTheadConfigServiceImpl.java | 78 ++++++++++++
.../static/js/sys/form/formConfig.js | 5 +
9 files changed, 375 insertions(+), 29 deletions(-)
create mode 100644 shandan-system/src/main/java/com/keyware/shandan/system/controller/SysTheadConfigController.java
create mode 100644 shandan-system/src/main/java/com/keyware/shandan/system/entity/SysTheadConfig.java
create mode 100644 shandan-system/src/main/java/com/keyware/shandan/system/mapper/SysTheadConfigMapper.java
create mode 100644 shandan-system/src/main/java/com/keyware/shandan/system/service/SysTheadConfigService.java
create mode 100644 shandan-system/src/main/java/com/keyware/shandan/system/service/impl/SysTheadConfigServiceImpl.java
diff --git a/shandan-browser/src/main/java/com/keyware/shandan/browser/controller/BrowserIndexController.java b/shandan-browser/src/main/java/com/keyware/shandan/browser/controller/BrowserIndexController.java
index 7c105f5..1f2d5b6 100644
--- a/shandan-browser/src/main/java/com/keyware/shandan/browser/controller/BrowserIndexController.java
+++ b/shandan-browser/src/main/java/com/keyware/shandan/browser/controller/BrowserIndexController.java
@@ -4,7 +4,6 @@ import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.keyware.shandan.bianmu.entity.MetadataBasicVo;
import com.keyware.shandan.bianmu.service.DirPermissionService;
-import com.keyware.shandan.bianmu.service.DirectoryService;
import com.keyware.shandan.bianmu.service.MetadataService;
import com.keyware.shandan.common.enums.SystemTypes;
import com.keyware.shandan.common.util.RsaUtil;
@@ -13,11 +12,12 @@ import com.keyware.shandan.datasource.entity.DBTableColumnVo;
import com.keyware.shandan.frame.config.security.SecurityUtil;
import com.keyware.shandan.system.entity.SysSetting;
import com.keyware.shandan.system.entity.SysUser;
-import com.keyware.shandan.system.service.SysFileService;
+import com.keyware.shandan.system.service.SysTheadConfigService;
import com.keyware.shandan.system.service.SysUserService;
import com.keyware.shandan.system.utils.SysSettingUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
+import org.springframework.security.core.Authentication;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
@@ -39,9 +39,6 @@ import java.util.List;
@RequestMapping("/")
public class BrowserIndexController {
- @Autowired
- private DirectoryService directoryService;
-
@Autowired
private MetadataService metadataService;
@@ -49,10 +46,10 @@ public class BrowserIndexController {
private SysUserService sysUserService;
@Autowired
- private SysFileService sysFileService;
+ private DirPermissionService permissionService;
@Autowired
- private DirPermissionService permissionService;
+ private SysTheadConfigService theadConfigService;
@Value("${project.cors-lib-search:#}")
private String corsLibSearchUrl;
@@ -90,10 +87,11 @@ public class BrowserIndexController {
}
@GetMapping("/browser")
- public ModelAndView browser(ModelAndView mov) {
+ public ModelAndView browser(ModelAndView mov, Authentication auth) {
mov.setViewName("browser");
SysSetting bianmuSetting = SysSettingUtil.getSysSetting(SystemTypes.BIANMU.name());
mov.addObject("bianmuServer", bianmuSetting.getSysAddress());
+ mov.addObject("theadConfig", theadConfigService.listByCreateUser(auth.getName()));
return mov;
}
diff --git a/shandan-browser/src/main/resources/static/js/browser.js b/shandan-browser/src/main/resources/static/js/browser.js
index 6d46f0c..51a9108 100644
--- a/shandan-browser/src/main/resources/static/js/browser.js
+++ b/shandan-browser/src/main/resources/static/js/browser.js
@@ -135,11 +135,10 @@ layui.use(['layer', 'listPage', 'globalTree', 'gtable', 'form', 'element', 'drop
height: 'full-110',
method: 'post',
autoSort: false,
- defaultToolbar: [{
- title: '导出' //标题
- , layEvent: 'export' //事件名,用于 toolbar 事件中使用
- , icon: 'layui-icon-export' //图标类名
- }],
+ defaultToolbar: [
+ {title: '导出', layEvent: 'export', icon: 'layui-icon-export'},
+ {title: '列表配置', layEvent: 'theadSet', icon: 'layui-icon-cols'}
+ ],
request: {pageName: 'page', limitName: 'size'},
limit: 30,
cols: [[
@@ -218,6 +217,8 @@ layui.use(['layer', 'listPage', 'globalTree', 'gtable', 'form', 'element', 'drop
openMaxLayerWithURL(`${ctx}/search/meta/${obj.id}`)
}
})
+
+ new THeadSetLayer(metaListTable, layui);
}
function initFileSearchTable(id) {
@@ -230,6 +231,9 @@ layui.use(['layer', 'listPage', 'globalTree', 'gtable', 'form', 'element', 'drop
url: `${ctx}/search/full/file?metaId=${id}`,
height: 'full-110',
request: {pageName: 'page', limitName: 'size'},
+ defaultToolbar: [
+ {title: '列表配置', layEvent: 'theadSet', icon: 'layui-icon-cols'}
+ ],
autoSort: false,
limit: 30,
method: 'get',
@@ -285,6 +289,8 @@ layui.use(['layer', 'listPage', 'globalTree', 'gtable', 'form', 'element', 'drop
dirFileTable.addTableRowEvent('details-file', function (obj) {
openMaxLayerWithURL(`${ctx}/sys/file/view?fileId=${obj.id}`)
})
+
+ new THeadSetLayer(dirFileTable, layui);
}
/**
@@ -508,4 +514,98 @@ layui.use(['layer', 'listPage', 'globalTree', 'gtable', 'form', 'element', 'drop
closeBtn: 1
});
}
-})
\ No newline at end of file
+})
+
+/**
+ * 表格表头配置组件
+ */
+class THeadSetLayer {
+ constructor(pageTable, lay) {
+ this.layer = lay.layer;
+ this.form = lay.form;
+ this.gtable = lay.gtable;
+ this.pageTable = pageTable;
+ this.id = pageTable.id + 'Set';
+ this.pageTable.addTableRowEvent('theadSet', () => this.show())
+ }
+
+ show() {
+ const {layer, pageTable, id} = this;
+ layer.open({
+ id: id + 'Layer',
+ title: '数据列表配置',
+ type: 1,
+ area: ['1000px', '700px'],
+ shadeClose: true,
+ maxmin: false,
+ anim: 0,
+ content: `
`,
+ btn: ['保存', '取消'],
+ success: () => {
+ this._renderInnerTable();
+ },
+ yes: (layerIndex) => {
+ this._saveTheadSet().then(() => {
+ pageTable.reloadTable();
+ layer.close(layerIndex);
+ })
+ }
+ });
+ }
+
+ _renderInnerTable() {
+ const {gtable, form, id} = this;
+ gtable.init({
+ id,
+ data: [...sourceTableConfigMap.values()],
+ method: 'get',
+ toolbar: false,
+ height: 'full-310',
+ page: false,
+ cols: [[
+ {field: 'id', hide: true},
+ {field: 'colName', title: '列名'},
+ {field: 'colTitle', title: '列标题', edit: 'text'},
+ {field: 'colSort', title: '列顺序', edit: 'text'},
+ {field: 'colWidth', title: '列宽度', edit: 'text'},
+ {
+ field: 'isSort',
+ title: '是否允许排序',
+ templet: (data) => renderSwitch('isSort', data)
+ },
+ {
+ field: 'isShow',
+ title: '是否显示',
+ templet: (data) => renderSwitch('isShow', data)
+ }
+ ]],
+ });
+ gtable.on(`edit(${id})`, ({field, value, data}) => {
+ sourceTableConfigMap.get(data.id)[field] = value;
+ })
+ // 监听switch按钮
+ form.on(`switch(${id}-switch)`, ({elem}) => {
+ const id = $(elem).attr('id'), name = $(elem).attr('name');
+ const value = sourceTableConfigMap.get(id)[name];
+ sourceTableConfigMap.get(id)[name] = !value;
+ });
+
+ function renderSwitch(colName, data) {
+ const dataId = data.id, value = data[colName];
+ return ``
+ }
+ }
+
+ _saveTheadSet() {
+ return new Promise(resolve => {
+ Util.post(`/sys/thead/config/api/save`, {params: JSON.stringify([...sourceTableConfigMap.values()])}).then(res=>{
+ if(res.flag){
+ showOkMsg('保存成功')
+ }else{
+ showErrorMsg2('保存失败:'+res.msg)
+ }
+ })
+ resolve();
+ })
+ }
+}
\ No newline at end of file
diff --git a/shandan-browser/src/main/resources/view/browser.html b/shandan-browser/src/main/resources/view/browser.html
index 3c069da..5d8c1da 100644
--- a/shandan-browser/src/main/resources/view/browser.html
+++ b/shandan-browser/src/main/resources/view/browser.html
@@ -11,6 +11,18 @@
@@ -79,18 +91,23 @@
当前位置:
diff --git a/shandan-system/src/main/java/com/keyware/shandan/system/controller/SysTheadConfigController.java b/shandan-system/src/main/java/com/keyware/shandan/system/controller/SysTheadConfigController.java
new file mode 100644
index 0000000..cc2e3e6
--- /dev/null
+++ b/shandan-system/src/main/java/com/keyware/shandan/system/controller/SysTheadConfigController.java
@@ -0,0 +1,42 @@
+package com.keyware.shandan.system.controller;
+
+import cn.hutool.json.JSONArray;
+import cn.hutool.json.JSONUtil;
+import com.keyware.shandan.common.entity.Result;
+import com.keyware.shandan.common.util.StringUtils;
+import com.keyware.shandan.system.entity.SysTheadConfig;
+import com.keyware.shandan.system.service.SysTheadConfigService;
+import org.springframework.security.core.Authentication;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+import java.util.List;
+
+/**
+ * 前端数据表格表头配置前端控制器
+ *
+ * @author GuoXin
+ * @date 2023/8/30
+ */
+@RestController
+@RequestMapping("/sys/thead/config")
+public class SysTheadConfigController {
+ private final SysTheadConfigService theadConfigService;
+
+ public SysTheadConfigController(SysTheadConfigService theadConfigService) {
+ this.theadConfigService = theadConfigService;
+ }
+
+ @PostMapping(value = "/api/save")
+ public Result