commit
a3637f44b8
@ -0,0 +1,47 @@ |
||||
-- 目录表增加加载顺序字段 |
||||
alter table BIANMU.B_DIRECTORY add SORT integer; |
||||
comment on column BIANMU.B_DIRECTORY.SORT is '加载顺序'; |
||||
-- 置标标签表增加加载顺序字段 |
||||
alter table BIANMU.B_DATA_LABELS add SORT integer; |
||||
comment on column BIANMU.B_DATA_LABELS.SORT is '加载顺序'; |
||||
-- 更新菜单数据 |
||||
UPDATE BIANMU.SYS_MENU t |
||||
SET t.IS_DELETE = '0', |
||||
t.MENU_NAME = '表单配置', |
||||
t.MENU_PATH = '/sys/form/config/page/index' |
||||
WHERE t.MENU_ID = '1525058137475338242'; |
||||
|
||||
CREATE TABLE "BIANMU"."SYS_FORM_CONFIG" |
||||
( |
||||
"ID" INTEGER IDENTITY(1000, 1) NOT NULL, |
||||
"FORM_TYPE" INTEGER, |
||||
"FIELD_TITLE" VARCHAR2(50), |
||||
"SHOW_TITLE" VARCHAR2(50), |
||||
"FIELD_TYPE" VARCHAR2(50), |
||||
"DEFAULT_VALUE" VARCHAR2(50) DEFAULT '', |
||||
"IS_REQUIRED" BIT DEFAULT 0, |
||||
"IS_DISABLED" BIT DEFAULT 0, |
||||
"IS_SHOW" BIT DEFAULT 1, |
||||
"SORT" INTEGER, |
||||
"CREATE_USER" VARCHAR2(50), |
||||
"CREATE_TIME" TIMESTAMP(6), |
||||
"MODIFY_USER" VARCHAR2(50), |
||||
"MODIFY_TIME" TIMESTAMP(6), |
||||
CLUSTER PRIMARY KEY("ID") |
||||
) STORAGE(ON "MAIN", CLUSTERBTR); |
||||
|
||||
COMMENT ON TABLE "BIANMU"."SYS_FORM_CONFIG" IS '系统表单配置表'; |
||||
COMMENT ON COLUMN "BIANMU"."SYS_FORM_CONFIG"."CREATE_TIME" IS '创建时间'; |
||||
COMMENT ON COLUMN "BIANMU"."SYS_FORM_CONFIG"."CREATE_USER" IS '创建人'; |
||||
COMMENT ON COLUMN "BIANMU"."SYS_FORM_CONFIG"."DEFAULT_VALUE" IS '默认值'; |
||||
COMMENT ON COLUMN "BIANMU"."SYS_FORM_CONFIG"."FIELD_TITLE" IS '字段标题'; |
||||
COMMENT ON COLUMN "BIANMU"."SYS_FORM_CONFIG"."FIELD_TYPE" IS '字段类型'; |
||||
COMMENT ON COLUMN "BIANMU"."SYS_FORM_CONFIG"."FORM_TYPE" IS '表单类型:1-资源注册表单,2-文件上传表单'; |
||||
COMMENT ON COLUMN "BIANMU"."SYS_FORM_CONFIG"."ID" IS '主键'; |
||||
COMMENT ON COLUMN "BIANMU"."SYS_FORM_CONFIG"."IS_DISABLED" IS '是否必填:0-非必填,1-必填'; |
||||
COMMENT ON COLUMN "BIANMU"."SYS_FORM_CONFIG"."IS_REQUIRED" IS '是否禁用:0-不禁用,1-禁用'; |
||||
COMMENT ON COLUMN "BIANMU"."SYS_FORM_CONFIG"."IS_SHOW" IS '是否显示'; |
||||
COMMENT ON COLUMN "BIANMU"."SYS_FORM_CONFIG"."MODIFY_TIME" IS '修改时间'; |
||||
COMMENT ON COLUMN "BIANMU"."SYS_FORM_CONFIG"."MODIFY_USER" IS '修改人'; |
||||
COMMENT ON COLUMN "BIANMU"."SYS_FORM_CONFIG"."SHOW_TITLE" IS '显示标题'; |
||||
COMMENT ON COLUMN "BIANMU"."SYS_FORM_CONFIG"."SORT" IS '显示顺序'; |
@ -0,0 +1,34 @@ |
||||
package com.keyware.shandan.browser.entity; |
||||
|
||||
|
||||
|
||||
import com.keyware.shandan.common.util.StringUtils; |
||||
import joptsimple.internal.Strings; |
||||
import lombok.Getter; |
||||
import lombok.Setter; |
||||
|
||||
/** |
||||
* 排序 |
||||
* |
||||
* @author GuoXin |
||||
* @date 2023/8/29 |
||||
*/ |
||||
@Getter |
||||
@Setter |
||||
public class SearchResultSort { |
||||
//排序字段
|
||||
private String field; |
||||
//排序方式
|
||||
private String sort; |
||||
|
||||
/** |
||||
* @return order by sql语句 |
||||
*/ |
||||
public String getOrderBy() { |
||||
return isEmpty() ? Strings.EMPTY : " order by " + getField() + " " + getSort(); |
||||
} |
||||
|
||||
public boolean isEmpty() { |
||||
return StringUtils.isBlankAny(this.field, this.sort); |
||||
} |
||||
} |
@ -0,0 +1,57 @@ |
||||
package com.keyware.shandan.system.controller; |
||||
|
||||
import cn.hutool.json.JSONArray; |
||||
import cn.hutool.json.JSONUtil; |
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
||||
import com.keyware.shandan.common.entity.Result; |
||||
import com.keyware.shandan.system.entity.SysFormConfig; |
||||
import com.keyware.shandan.system.service.SysFormConfigService; |
||||
import lombok.extern.slf4j.Slf4j; |
||||
import org.springframework.web.bind.annotation.*; |
||||
import org.springframework.web.servlet.ModelAndView; |
||||
|
||||
import java.util.List; |
||||
|
||||
/** |
||||
* 系统表单配置模块前端控制类 |
||||
* |
||||
* @author GuoXin |
||||
* @date 2023/8/23 |
||||
*/ |
||||
@Slf4j |
||||
@RestController |
||||
@RequestMapping("/sys/form/config") |
||||
public class SysFormConfigController { |
||||
private final SysFormConfigService formConfigService; |
||||
|
||||
public SysFormConfigController(SysFormConfigService formConfigService) { |
||||
this.formConfigService = formConfigService; |
||||
} |
||||
|
||||
|
||||
@GetMapping("/page/index") |
||||
public ModelAndView indexPage(ModelAndView mav) { |
||||
mav.setViewName("sys/form/formConfig"); |
||||
return mav; |
||||
} |
||||
|
||||
|
||||
@GetMapping("/api/get/{id}") |
||||
public Result<SysFormConfig> getById(@PathVariable String id) { |
||||
return Result.of(formConfigService.getById(id)); |
||||
} |
||||
|
||||
@GetMapping("/api/list/{formType}") |
||||
public Result<List<SysFormConfig>> list(@PathVariable String formType) { |
||||
QueryWrapper<SysFormConfig> query = new QueryWrapper<>(); |
||||
query.eq("FORM_TYPE", formType); |
||||
return Result.of(formConfigService.list(query)); |
||||
} |
||||
|
||||
@PostMapping(value = "/api/save") |
||||
public Result<Object> save(String params) { |
||||
JSONArray jsonArray = JSONUtil.parseArray(params); |
||||
List<SysFormConfig> list = jsonArray.toList(SysFormConfig.class); |
||||
return Result.of(formConfigService.saveOrUpdateBatch(list)); |
||||
} |
||||
} |
@ -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<Object> save(String params, Authentication auth) { |
||||
JSONArray jsonArray = JSONUtil.parseArray(params); |
||||
List<SysTheadConfig> list = jsonArray.toList(SysTheadConfig.class); |
||||
list.forEach(item->{ |
||||
if(!StringUtils.hasText(item.getId())){ |
||||
item.genId(auth.getName()); |
||||
} |
||||
}); |
||||
return Result.of(theadConfigService.saveOrUpdateBatch(list)); |
||||
} |
||||
} |
@ -0,0 +1,66 @@ |
||||
package com.keyware.shandan.system.entity; |
||||
|
||||
import com.baomidou.mybatisplus.annotation.OrderBy; |
||||
import com.keyware.shandan.common.entity.BaseEntity; |
||||
import lombok.Data; |
||||
import lombok.EqualsAndHashCode; |
||||
|
||||
/** |
||||
* 系统表单配置实体类 |
||||
* |
||||
* @author GuoXin |
||||
* @date 2023/8/23 |
||||
*/ |
||||
@Data |
||||
@EqualsAndHashCode(callSuper = true) |
||||
public class SysFormConfig extends BaseEntity { |
||||
|
||||
private static final long serialVersionUID = 6628747783449277117L; |
||||
|
||||
/** |
||||
* 主键 |
||||
*/ |
||||
private Integer id; |
||||
/** |
||||
* 表单类型:1-资源注册表单,2-文件上传表单 |
||||
*/ |
||||
private Integer formType; |
||||
/** |
||||
* 字段名 |
||||
*/ |
||||
private String fieldName; |
||||
/** |
||||
* 字段显示标题 |
||||
*/ |
||||
private String showTitle; |
||||
/** |
||||
* 字段类型 |
||||
*/ |
||||
private String fieldType; |
||||
/** |
||||
* 数据字典类型,只有当fieldType为"dict"时才有效 |
||||
*/ |
||||
private String dictType; |
||||
/** |
||||
* 默认值 |
||||
*/ |
||||
private String defaultValue; |
||||
/** |
||||
* 是否必填:0-非必填,1-必填 |
||||
*/ |
||||
private Boolean isRequired; |
||||
/** |
||||
* 是否禁用:0-不禁用,1-禁用 |
||||
*/ |
||||
private Boolean isDisabled; |
||||
/** |
||||
* 是否禁用:0-不禁用,1-禁用 |
||||
*/ |
||||
private Boolean isShow; |
||||
/** |
||||
* 显示顺序 |
||||
*/ |
||||
@OrderBy(isDesc = false) |
||||
private Integer sort; |
||||
|
||||
} |
@ -0,0 +1,65 @@ |
||||
package com.keyware.shandan.system.entity; |
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType; |
||||
import com.baomidou.mybatisplus.annotation.OrderBy; |
||||
import com.baomidou.mybatisplus.annotation.TableId; |
||||
import com.baomidou.mybatisplus.annotation.TableName; |
||||
import com.keyware.shandan.common.entity.BaseEntity; |
||||
import com.keyware.shandan.common.util.MD5Util; |
||||
import lombok.Builder; |
||||
import lombok.Data; |
||||
import lombok.EqualsAndHashCode; |
||||
|
||||
/** |
||||
* 前端数据表格表头配置实体类 |
||||
* |
||||
* @author GuoXin |
||||
* @date 2023/8/30 |
||||
*/ |
||||
@Data |
||||
@Builder |
||||
@EqualsAndHashCode(callSuper = true) |
||||
@TableName("SYS_THEAD_CONFIG") |
||||
public class SysTheadConfig extends BaseEntity { |
||||
|
||||
private static final long serialVersionUID = 1480474706145625172L; |
||||
/** |
||||
* 主键 |
||||
*/ |
||||
@TableId(type = IdType.INPUT) |
||||
private String id; |
||||
/** |
||||
* 数据表ID,对应前端页面上的layui中table组件的id |
||||
*/ |
||||
private String tableId; |
||||
/** |
||||
* 列名 |
||||
*/ |
||||
private String colName; |
||||
/** |
||||
* 列标题 |
||||
*/ |
||||
private String colTitle; |
||||
/** |
||||
* 列顺序 |
||||
*/ |
||||
@OrderBy(isDesc = false, sort = 2) |
||||
private Integer colSort; |
||||
/** |
||||
* 列宽度 |
||||
*/ |
||||
private String colWidth; |
||||
/** |
||||
* 是否显示 |
||||
*/ |
||||
@OrderBy(sort = 1) |
||||
private Boolean isShow; |
||||
/** |
||||
* 是否允许排序 |
||||
*/ |
||||
private Boolean isSort; |
||||
|
||||
public void genId(String userName) { |
||||
this.id = MD5Util.getMD5(tableId + colName + userName); |
||||
} |
||||
} |
@ -0,0 +1,15 @@ |
||||
package com.keyware.shandan.system.mapper; |
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
||||
import com.keyware.shandan.system.entity.SysFormConfig; |
||||
import org.apache.ibatis.annotations.Mapper; |
||||
|
||||
/** |
||||
* 系统表单配置数据库操作映射 |
||||
* |
||||
* @author GuoXin |
||||
* @date 2023/8/23 |
||||
*/ |
||||
@Mapper |
||||
public interface SysFormConfigMapper extends BaseMapper<SysFormConfig> { |
||||
} |
@ -0,0 +1,15 @@ |
||||
package com.keyware.shandan.system.mapper; |
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
||||
import com.keyware.shandan.system.entity.SysTheadConfig; |
||||
import org.apache.ibatis.annotations.Mapper; |
||||
|
||||
/** |
||||
* 前端数据表格表头配置数据库操作映射接口 |
||||
* |
||||
* @author GuoXin |
||||
* @date 2023/8/30 |
||||
*/ |
||||
@Mapper |
||||
public interface SysTheadConfigMapper extends BaseMapper<SysTheadConfig> { |
||||
} |
@ -0,0 +1,18 @@ |
||||
package com.keyware.shandan.system.service; |
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService; |
||||
import com.keyware.shandan.system.constants.FormTypeEnum; |
||||
import com.keyware.shandan.system.entity.SysFormConfig; |
||||
|
||||
import java.util.List; |
||||
|
||||
/** |
||||
* 系统表单配置服务接口类 |
||||
* |
||||
* @author GuoXin |
||||
* @date 2023/8/23 |
||||
*/ |
||||
public interface SysFormConfigService extends IService<SysFormConfig> { |
||||
|
||||
List<SysFormConfig> listByFormType(FormTypeEnum formTypeEnum); |
||||
} |
@ -0,0 +1,16 @@ |
||||
package com.keyware.shandan.system.service; |
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService; |
||||
import com.keyware.shandan.system.entity.SysTheadConfig; |
||||
|
||||
import java.util.List; |
||||
|
||||
/** |
||||
* 前端数据表格表头配置数据库操作接口 |
||||
* |
||||
* @author GuoXin |
||||
* @date 2023/8/30 |
||||
*/ |
||||
public interface SysTheadConfigService extends IService<SysTheadConfig> { |
||||
List<SysTheadConfig> listByCreateUser(String userId); |
||||
} |
@ -0,0 +1,27 @@ |
||||
package com.keyware.shandan.system.service.impl; |
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
||||
import com.keyware.shandan.system.constants.FormTypeEnum; |
||||
import com.keyware.shandan.system.entity.SysFormConfig; |
||||
import com.keyware.shandan.system.mapper.SysFormConfigMapper; |
||||
import com.keyware.shandan.system.service.SysFormConfigService; |
||||
import org.springframework.stereotype.Service; |
||||
|
||||
import java.util.List; |
||||
|
||||
/** |
||||
* 系统表单配置服务实现类 |
||||
* |
||||
* @author GuoXin |
||||
* @date 2023/8/23 |
||||
*/ |
||||
@Service |
||||
public class SysFormConfigServiceImpl extends ServiceImpl<SysFormConfigMapper, SysFormConfig> implements SysFormConfigService { |
||||
@Override |
||||
public List<SysFormConfig> listByFormType(FormTypeEnum formTypeEnum) { |
||||
QueryWrapper<SysFormConfig> query = new QueryWrapper<>(); |
||||
query.eq("FORM_TYPE", formTypeEnum.getValue()); |
||||
return list(query); |
||||
} |
||||
} |
@ -0,0 +1,78 @@ |
||||
package com.keyware.shandan.system.service.impl; |
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
||||
import com.keyware.shandan.common.util.StringUtils; |
||||
import com.keyware.shandan.system.entity.SysTheadConfig; |
||||
import com.keyware.shandan.system.mapper.SysTheadConfigMapper; |
||||
import com.keyware.shandan.system.service.SysTheadConfigService; |
||||
import org.springframework.stereotype.Service; |
||||
|
||||
import java.util.ArrayList; |
||||
import java.util.Collection; |
||||
import java.util.Collections; |
||||
import java.util.List; |
||||
|
||||
/** |
||||
* 前端数据表格表头配置数据库操作接口实现类 |
||||
* |
||||
* @author GuoXin |
||||
* @date 2023/8/30 |
||||
*/ |
||||
@Service |
||||
public class SysTheadConfigServiceImpl extends ServiceImpl<SysTheadConfigMapper, SysTheadConfig> implements SysTheadConfigService { |
||||
static final String resourceTableId = "browser_resource_table", fileTableId = "browser_file_table"; |
||||
static List<SysTheadConfig> defaultConfig = new ArrayList<>(); |
||||
|
||||
static { |
||||
SysTheadConfig.SysTheadConfigBuilder builder = SysTheadConfig.builder(); |
||||
// 初始化综合浏览系统资源查询数据表表头默认配置
|
||||
defaultConfig.add(builder.tableId(resourceTableId).colName("resourceName").colTitle("资源名称").colSort(1).colWidth("100").isShow(true).isSort(false).build()); |
||||
defaultConfig.add(builder.tableId(resourceTableId).colName("resourceComment").colTitle("资源注释").colSort(2).colWidth("100").isShow(true).isSort(false).build()); |
||||
defaultConfig.add(builder.tableId(resourceTableId).colName("directoryPath").colTitle("目录路径").colSort(3).colWidth("100").isShow(true).isSort(false).build()); |
||||
defaultConfig.add(builder.tableId(resourceTableId).colName("themeTask").colTitle("主题任务").colSort(4).colWidth("100").isShow(true).isSort(false).build()); |
||||
defaultConfig.add(builder.tableId(resourceTableId).colName("dataSource").colTitle("数据来源").colSort(5).colWidth("100").isShow(true).isSort(false).build()); |
||||
defaultConfig.add(builder.tableId(resourceTableId).colName("taskTime").colTitle("任务时间").colSort(6).colWidth("100").isShow(true).isSort(false).build()); |
||||
defaultConfig.add(builder.tableId(resourceTableId).colName("dataType").colTitle("数据类型").colSort(7).colWidth("100").isShow(true).isSort(false).build()); |
||||
defaultConfig.add(builder.tableId(resourceTableId).colName("secretLevel").colTitle("数据密级").colSort(8).colWidth("100").isShow(true).isSort(false).build()); |
||||
defaultConfig.add(builder.tableId(resourceTableId).colName("resourceType").colTitle("资源类型").colSort(9).colWidth("100").isShow(true).isSort(false).build()); |
||||
// 初始化综合浏览系统文件全文检索数据表表头默认配置
|
||||
defaultConfig.add(builder.tableId(fileTableId).colName("fileName").colTitle("文件名称").colSort(9).colWidth("100").isShow(true).isSort(false).build()); |
||||
defaultConfig.add(builder.tableId(fileTableId).colName("fileType").colTitle("文件类型").colSort(9).colWidth("100").isShow(true).isSort(false).build()); |
||||
defaultConfig.add(builder.tableId(fileTableId).colName("fileSize").colTitle("文件大小").colSort(9).colWidth("100").isShow(true).isSort(false).build()); |
||||
defaultConfig.add(builder.tableId(fileTableId).colName("remark").colTitle("文件描述").colSort(9).colWidth("100").isShow(true).isSort(false).build()); |
||||
defaultConfig.add(builder.tableId(fileTableId).colName("exerciseData").colTitle("是否演训数据").colSort(9).colWidth("100").isShow(true).isSort(false).build()); |
||||
defaultConfig.add(builder.tableId(fileTableId).colName("entryStaff").colTitle("录入人员").colSort(9).colWidth("100").isShow(true).isSort(false).build()); |
||||
defaultConfig.add(builder.tableId(fileTableId).colName("equipmentModel").colTitle("装备型号").colSort(9).colWidth("100").isShow(true).isSort(false).build()); |
||||
defaultConfig.add(builder.tableId(fileTableId).colName("inputDate").colTitle("任务时间").colSort(9).colWidth("100").isShow(true).isSort(false).build()); |
||||
defaultConfig.add(builder.tableId(fileTableId).colName("source").colTitle("文件来源").colSort(9).colWidth("100").isShow(true).isSort(false).build()); |
||||
defaultConfig.add(builder.tableId(fileTableId).colName("taskCode").colTitle("任务代号").colSort(9).colWidth("100").isShow(true).isSort(false).build()); |
||||
defaultConfig.add(builder.tableId(fileTableId).colName("taskNature").colTitle("任务性质").colSort(9).colWidth("100").isShow(true).isSort(false).build()); |
||||
defaultConfig.add(builder.tableId(fileTableId).colName("troopCode").colTitle("部队代号").colSort(9).colWidth("100").isShow(true).isSort(false).build()); |
||||
defaultConfig.add(builder.tableId(fileTableId).colName("targetNumber").colTitle("目标/靶标类型").colSort(9).colWidth("100").isShow(true).isSort(false).build()); |
||||
defaultConfig.add(builder.tableId(fileTableId).colName("missileNumber").colTitle("导弹编号").colSort(9).colWidth("100").isShow(true).isSort(false).build()); |
||||
defaultConfig.add(builder.tableId(fileTableId).colName("themeTask").colTitle("主题任务").colSort(9).colWidth("100").isShow(true).isSort(false).build()); |
||||
defaultConfig.add(builder.tableId(fileTableId).colName("secretLevel").colTitle("文件密级").colSort(9).colWidth("100").isShow(true).isSort(false).build()); |
||||
} |
||||
|
||||
@Override |
||||
public List<SysTheadConfig> listByCreateUser(String userId) { |
||||
if (StringUtils.hasText(userId)) { |
||||
LambdaQueryWrapper<SysTheadConfig> query = new LambdaQueryWrapper<>(); |
||||
query.eq(SysTheadConfig::getCreateUser, userId); |
||||
List<SysTheadConfig> list = list(query); |
||||
if (list.size() == 0) { |
||||
// 为默认数据生成包含用户主键的ID
|
||||
defaultConfig.forEach(conf -> conf.genId(userId)); |
||||
return defaultConfig; |
||||
} |
||||
return list; |
||||
} |
||||
return Collections.emptyList(); |
||||
} |
||||
|
||||
@Override |
||||
public boolean saveOrUpdateBatch(Collection<SysTheadConfig> entityList, int batchSize) { |
||||
return super.saveOrUpdateBatch(entityList, batchSize); |
||||
} |
||||
} |
@ -0,0 +1,88 @@ |
||||
class FormConfigComponent { |
||||
constructor(formType, elemId, lay) { |
||||
this.formType = formType; |
||||
this.elemId = elemId; |
||||
this.lay = lay; |
||||
this.dataMap = new Map(); |
||||
this.renderTable(); |
||||
} |
||||
|
||||
renderTable() { |
||||
const {lay, formType, elemId} = this, {form, gtable} = lay; |
||||
gtable.init({ |
||||
id: elemId, |
||||
url: `${ctx}/sys/form/config/api/list/${formType}`, |
||||
method: 'get', |
||||
toolbar: '#tableTool', |
||||
height: 'full-125', |
||||
page: false, |
||||
cols: [[ |
||||
{field: 'id', hide: true}, |
||||
{field: 'fieldName', title: '字段名'}, |
||||
{field: 'showTitle', title: '显示的标题', edit: 'text'}, |
||||
{field: 'fieldType', title: '字段类型', hide: true}, |
||||
{field: 'dictType', title: '数据字典', hide: true}, |
||||
{field: 'defaultValue', title: '默认值', edit: 'text', hide: true}, |
||||
{ |
||||
field: 'isRequired', |
||||
title: '是否必填', |
||||
templet: (data) => renderSwitch('isRequired', data) |
||||
}, |
||||
{ |
||||
field: 'isDisabled', |
||||
title: '是否禁用', |
||||
templet: (data) => renderSwitch('isDisabled', data) |
||||
}, |
||||
{ |
||||
field: 'isShow', |
||||
title: '是否显示', |
||||
templet: (data) => renderSwitch('isShow', data) |
||||
}, |
||||
{field: 'sort', title: '显示顺序', edit: 'text'} |
||||
]], |
||||
done: (res) => this.tableLoadDoneListen(res), |
||||
onToolBarTable: ({event, config})=> { |
||||
if(event === 'save'){ |
||||
const datas = [...this.dataMap.values()]; |
||||
Util.post(`/sys/form/config/api/save`, {params: JSON.stringify(datas)}).then(res=>{ |
||||
if(res.flag){ |
||||
showOkMsg('保存成功') |
||||
}else{ |
||||
showErrorMsg2('保存失败:'+res.msg) |
||||
} |
||||
}) |
||||
} |
||||
} |
||||
}); |
||||
|
||||
gtable.on(`edit(${elemId})`, ({field, value, data}) => { |
||||
this.dataMap.get(data.id)[field] = value; |
||||
}) |
||||
|
||||
// 监听switch按钮
|
||||
form.on(`switch(${elemId}-switch)`, (data) => this.switchChangeListen(data)); |
||||
|
||||
function renderSwitch(fieldName, data) { |
||||
const id = data.id, value = data[fieldName]; |
||||
return `<input type="checkbox" id="${id}" name="${fieldName}" value="${value}" title="是|否" lay-skin="switch" lay-filter="${elemId}-switch" ${value ? 'checked' : ''} />` |
||||
} |
||||
} |
||||
|
||||
tableLoadDoneListen(res) { |
||||
if (res.flag) { |
||||
res.records.map(record => this.dataMap.set(record.id + '', record)); |
||||
} |
||||
} |
||||
|
||||
switchChangeListen({elem}) { |
||||
const id = $(elem).attr('id'), name = $(elem).attr('name'); |
||||
const value = this.dataMap.get(id)[name]; |
||||
this.dataMap.get(id)[name] = !value; |
||||
} |
||||
} |
||||
|
||||
layui.use(['form', 'gtable', 'dropdown', 'element'], function () { |
||||
const metadataForm = new FormConfigComponent(1, 'metadataFormTable', layui); |
||||
const fileUploadForm = new FormConfigComponent(2, 'fileUploadFormTable', layui); |
||||
}); |
||||
|
@ -0,0 +1,57 @@ |
||||
<!DOCTYPE html> |
||||
<!--解决idea thymeleaf 表达式模板报红波浪线--> |
||||
<!--suppress ALL --> |
||||
<html xmlns:th="http://www.thymeleaf.org"> |
||||
<head> |
||||
<!-- 引入公用部分 --> |
||||
<script th:replace="common/head::static"></script> |
||||
<!-- 样式 --> |
||||
<link th:href="@{/css/common/contianer.css}" rel="stylesheet" type="text/css"/> |
||||
<script th:inline="javascript"> |
||||
const FormTypeEnum = /*[[${FormTypeEnum}]]*/ {}; |
||||
</script> |
||||
</head> |
||||
<body> |
||||
<div class="layui-row"> |
||||
<!-- 树 --> |
||||
<div class="layui-col-md12"> |
||||
<div class="layui-card"> |
||||
<div class="layui-card-header layui-hide"></div> |
||||
<div class="layui-card-body"> |
||||
<div class="layui-tab layui-tab-brief" lay-filter="form-config-tab"> |
||||
<ul class="layui-tab-title"> |
||||
<li class="layui-this" data-form-type="1">数据资源注册表单</li> |
||||
<li data-form-type="2">文件上传表单</li> |
||||
</ul> |
||||
<div class="layui-tab-content" style="padding: 0"> |
||||
<div class="layui-tab-item layui-show"> |
||||
<table class="layui-hide" id="metadataFormTable" |
||||
lay-filter="metadataFormTable"></table> |
||||
</div> |
||||
<div class="layui-tab-item"> |
||||
<table class="layui-hide" id="fileUploadFormTable" |
||||
lay-filter="fileUploadFormTable"></table> |
||||
</div> |
||||
<script type="text/html" id="tableTool"> |
||||
<div class="layui-btn-container"> |
||||
<button class="layui-btn layui-btn-sm" lay-event="save">保存修改</button> |
||||
</div> |
||||
</script> |
||||
</div> |
||||
</div> |
||||
</div> |
||||
</div> |
||||
</div> |
||||
</div> |
||||
</body> |
||||
<!-- js --> |
||||
<script th:replace="common/head::static-foot"></script> |
||||
<script th:src="@{/js/sys/form/formConfig.js}"></script> |
||||
<script> |
||||
const sizeInit = () => { |
||||
$(".layui-card-body").height(window.innerHeight - 43 - 40 - 20); |
||||
} |
||||
window.onresize = sizeInit; |
||||
sizeInit(); |
||||
</script> |
||||
</html> |
Reference in new issue