parent
6bf9d66cb4
commit
7e16a3f38f
@ -1,5 +1,43 @@ |
||||
-- 目录表增加加载顺序字段 |
||||
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 '加载顺序'; |
||||
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), |
||||
"FIELD_TYPE" VARCHAR2(50), |
||||
"DEFAULT_VALUE" VARCHAR2(50) DEFAULT '', |
||||
"IS_REQUIRED" BIT DEFAULT 0, |
||||
"IS_DISABLED" BIT DEFAULT 0, |
||||
"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"."MODIFY_TIME" IS '修改时间'; |
||||
COMMENT ON COLUMN "BIANMU"."SYS_FORM_CONFIG"."MODIFY_USER" IS '修改人'; |
||||
COMMENT ON COLUMN "BIANMU"."SYS_FORM_CONFIG"."SORT" IS '显示顺序'; |
||||
|
@ -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,62 @@ |
||||
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 fieldTitle; |
||||
/** |
||||
* 字段标题 |
||||
*/ |
||||
private String showTitle; |
||||
/** |
||||
* 字段类型 |
||||
*/ |
||||
private String fieldType; |
||||
/** |
||||
* 默认值 |
||||
*/ |
||||
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,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,13 @@ |
||||
package com.keyware.shandan.system.service; |
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService; |
||||
import com.keyware.shandan.system.entity.SysFormConfig; |
||||
|
||||
/** |
||||
* 系统表单配置服务接口类 |
||||
* |
||||
* @author GuoXin |
||||
* @date 2023/8/23 |
||||
*/ |
||||
public interface SysFormConfigService extends IService<SysFormConfig> { |
||||
} |
@ -0,0 +1,17 @@ |
||||
package com.keyware.shandan.system.service.impl; |
||||
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
||||
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; |
||||
|
||||
/** |
||||
* 系统表单配置服务实现类 |
||||
* |
||||
* @author GuoXin |
||||
* @date 2023/8/23 |
||||
*/ |
||||
@Service |
||||
public class SysFormConfigServiceImpl extends ServiceImpl<SysFormConfigMapper, SysFormConfig> implements SysFormConfigService { |
||||
} |
@ -0,0 +1,86 @@ |
||||
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: 'fieldTitle', title: '字段'}, |
||||
{field: 'showTitle', title: '显示的标题', edit: 'text'}, |
||||
{field: 'fieldType', 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: 'isDisabled', |
||||
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) |
||||
} |
||||
}) |
||||
} |
||||
} |
||||
}) |
||||
// 监听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, value}) { |
||||
const id = $(elem).attr('id'), name = $(elem).attr('name'); |
||||
this.dataMap.get(id)[name] = Boolean(value); |
||||
this.consoleDataMap(); |
||||
} |
||||
|
||||
consoleDataMap() { |
||||
console.info(this.dataMap); |
||||
} |
||||
} |
||||
|
||||
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