修复:综合流量查询结果列表表头配置不生效的问题

master
guoxin 1 year ago
parent a3637f44b8
commit b8850f414a
  1. 43
      shandan-browser/src/main/resources/static/js/browser.js
  2. 2
      shandan-system/src/main/java/com/keyware/shandan/system/service/impl/SysTheadConfigServiceImpl.java

@ -218,7 +218,7 @@ layui.use(['layer', 'listPage', 'globalTree', 'gtable', 'form', 'element', 'drop
} }
}) })
new THeadSetLayer(metaListTable, layui); new THeadSetLayer(layui, metaListTable, [...sourceTableConfigMap.values()]);
} }
function initFileSearchTable(id) { function initFileSearchTable(id) {
@ -290,7 +290,7 @@ layui.use(['layer', 'listPage', 'globalTree', 'gtable', 'form', 'element', 'drop
openMaxLayerWithURL(`${ctx}/sys/file/view?fileId=${obj.id}`) openMaxLayerWithURL(`${ctx}/sys/file/view?fileId=${obj.id}`)
}) })
new THeadSetLayer(dirFileTable, layui); new THeadSetLayer(layui, dirFileTable, [...fileTableConfigMap.values()]);
} }
/** /**
@ -520,12 +520,13 @@ layui.use(['layer', 'listPage', 'globalTree', 'gtable', 'form', 'element', 'drop
* 表格表头配置组件 * 表格表头配置组件
*/ */
class THeadSetLayer { class THeadSetLayer {
constructor(pageTable, lay) { constructor(lay, pageTable, configData) {
this.layer = lay.layer; this.layer = lay.layer;
this.form = lay.form; this.form = lay.form;
this.gtable = lay.gtable; this.gtable = lay.gtable;
this.pageTable = pageTable; this.pageTable = pageTable;
this.id = pageTable.id + 'Set'; this.id = pageTable.table.id + 'Set';
this.configData = configData;
this.pageTable.addTableRowEvent('theadSet', () => this.show()) this.pageTable.addTableRowEvent('theadSet', () => this.show())
} }
@ -557,7 +558,7 @@ class THeadSetLayer {
const {gtable, form, id} = this; const {gtable, form, id} = this;
gtable.init({ gtable.init({
id, id,
data: [...sourceTableConfigMap.values()], data: this.configData,
method: 'get', method: 'get',
toolbar: false, toolbar: false,
height: 'full-310', height: 'full-310',
@ -581,13 +582,23 @@ class THeadSetLayer {
]], ]],
}); });
gtable.on(`edit(${id})`, ({field, value, data}) => { gtable.on(`edit(${id})`, ({field, value, data}) => {
sourceTableConfigMap.get(data.id)[field] = value; this._setData(data.id, field, value);
if (this.id.startsWith('dirMetadataTable')) {
sourceTableConfigMap.get(data.id)[field] = value;
} else if (this.id.startsWith('dirFileTable')) {
fileTableConfigMap.get(data.id)[field] = value;
}
}) })
// 监听switch按钮 // 监听switch按钮
form.on(`switch(${id}-switch)`, ({elem}) => { form.on(`switch(${id}-switch)`, ({elem}) => {
const id = $(elem).attr('id'), name = $(elem).attr('name'); const id = $(elem).attr('id'), name = $(elem).attr('name');
const value = sourceTableConfigMap.get(id)[name]; if (this.id.startsWith('dirMetadataTable')) {
sourceTableConfigMap.get(id)[name] = !value; const value = sourceTableConfigMap.get(id)[name];
sourceTableConfigMap.get(id)[name] = !value;
} else if (this.id.startsWith('dirFileTable')) {
const value = fileTableConfigMap.get(id)[name];
fileTableConfigMap.get(id)[name] = !value;
}
}); });
function renderSwitch(colName, data) { function renderSwitch(colName, data) {
@ -596,13 +607,21 @@ class THeadSetLayer {
} }
} }
_setData(id, name, value) {
if (this.id.startsWith('dirMetadataTable')) {
sourceTableConfigMap.get(id)[name] = value;
} else if (this.id.startsWith('dirFileTable')) {
fileTableConfigMap.get(id)[name] = value;
}
}
_saveTheadSet() { _saveTheadSet() {
return new Promise(resolve => { return new Promise(resolve => {
Util.post(`/sys/thead/config/api/save`, {params: JSON.stringify([...sourceTableConfigMap.values()])}).then(res=>{ Util.post(`/sys/thead/config/api/save`, {params: JSON.stringify([...sourceTableConfigMap.values(), ...fileTableConfigMap.values()])}).then(res => {
if(res.flag){ if (res.flag) {
showOkMsg('保存成功') showOkMsg('保存成功')
}else{ } else {
showErrorMsg2('保存失败:'+res.msg) showErrorMsg2('保存失败:' + res.msg)
} }
}) })
resolve(); resolve();

@ -61,7 +61,7 @@ public class SysTheadConfigServiceImpl extends ServiceImpl<SysTheadConfigMapper,
LambdaQueryWrapper<SysTheadConfig> query = new LambdaQueryWrapper<>(); LambdaQueryWrapper<SysTheadConfig> query = new LambdaQueryWrapper<>();
query.eq(SysTheadConfig::getCreateUser, userId); query.eq(SysTheadConfig::getCreateUser, userId);
List<SysTheadConfig> list = list(query); List<SysTheadConfig> list = list(query);
if (list.size() == 0) { if (list.isEmpty()) {
// 为默认数据生成包含用户主键的ID // 为默认数据生成包含用户主键的ID
defaultConfig.forEach(conf -> conf.genId(userId)); defaultConfig.forEach(conf -> conf.genId(userId));
return defaultConfig; return defaultConfig;