RuoYi-Vue-Plus/ruoyi-modules/ruoyi-md-form/docs/init_table.sql
2026-04-03 10:03:36 +08:00

179 lines
12 KiB
SQL
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

create table form
(
id bigint unsigned auto_increment comment '主键ID'
primary key,
name varchar(32) not null comment '表单名称',
code varchar(32) not null comment 'code',
agent_id bigint not null,
constraint un_code
unique (agent_id, code)
)
comment '动态表单' collate = utf8mb4_bin;
create table form_dict
(
id bigint auto_increment comment '主键ID'
primary key,
name varchar(100) not null comment '名称',
code varchar(100) not null comment '',
remarks varchar(255) null comment '备注',
created_by bigint not null comment '创建人',
updated_by bigint null comment '更新人',
create_time datetime default CURRENT_TIMESTAMP not null comment '创建时间',
update_time datetime null on update CURRENT_TIMESTAMP comment '更新时间',
agent_id bigint not null,
deleted tinyint default 0 not null comment '是否删除(0:否,1:是)'
)
comment '动态表单字段字典表';
create table form_field_dict
(
id bigint auto_increment comment '主键ID'
primary key,
config_type varchar(50) not null comment '类型:单位类型、往来单位、税率、费用分类、费用科目、仓库管理',
name varchar(100) not null comment '名称',
code varchar(100) not null comment '',
parent_id bigint unsigned null comment '父级ID也可以是关联的id',
other_fields json null comment '其他字段(JSON格式)',
check_ids varchar(255) null comment '检查ids当删除里面的id时进行校验是否有相关联',
sort_order int default 0 null comment '排序',
status tinyint default 1 not null comment '状态(1:启用,0:禁用)',
created_by bigint not null comment '创建人',
updated_by bigint null comment '更新人',
create_time datetime default CURRENT_TIMESTAMP not null comment '创建时间',
update_time datetime default CURRENT_TIMESTAMP null on update CURRENT_TIMESTAMP comment '更新时间',
agent_id bigint not null,
deleted tinyint default 0 not null comment '是否删除(0:否,1:是)'
)
comment '动态表单字段字典表';
create index idx_agent_id_config_type_deleted
on form_field_dict (agent_id, config_type, deleted);
create table form_print_config
(
id bigint auto_increment comment '主键ID'
primary key,
form_id bigint not null comment '关联的表单ID',
main_title varchar(255) null comment '主标题',
sub_title varchar(255) null comment '副标题',
display_format varchar(50) null comment '显示格式:简洁、标准、完整',
document_no_prefix varchar(50) null comment '单据编号前缀如CG-',
show_document_no tinyint(1) default 0 null comment '是否显示单据编号',
print_date_format varchar(50) null comment '打印日期格式',
show_print_date tinyint(1) default 0 null comment '是否显示打印日期',
show_page_number tinyint(1) default 0 null comment '是否显示页码',
column_width_mode varchar(50) null comment '列宽模式:固定宽度或自适应',
table_style varchar(50) default 'bordered' null comment '表格样式:有边框或无边框',
row_height varchar(50) default 'normal_40px' null comment '数据行高',
print_fields json null comment '打印字段',
file_size int null comment '模板文件大小',
file_name varchar(500) null comment '模板文件name',
file_type varchar(20) null comment '文件类型doc、excel',
file_wps_id varchar(255) null comment 'file_wps_id',
file_url_ai varchar(500) null comment 'ai模板文件url',
file_url varchar(500) null comment '模板文件url',
mode int default 1 not null comment '打印配置模式1、默认模式2、模板打印模式',
ext json null comment '扩展属性(JSON格式)',
created_by bigint unsigned not null comment '创建人',
updated_by bigint unsigned null comment '更新人',
create_time datetime default CURRENT_TIMESTAMP not null comment '创建时间',
update_time datetime null on update CURRENT_TIMESTAMP comment '更新时间',
agent_id bigint not null,
constraint un_form_id
unique (agent_id, form_id)
)
comment '表单打印配置表';
create table form_template
(
id bigint unsigned auto_increment comment '主键ID'
primary key,
form_id bigint unsigned not null comment 'form id',
version int not null comment '版本',
content_encoding varchar(100) null comment '内容编码,保存时和上次的编码是否一致,一致时则不进行更新',
created_by bigint unsigned not null comment '创建人',
updated_by bigint unsigned null comment '更新人',
create_time datetime default CURRENT_TIMESTAMP not null comment '创建时间',
update_time datetime null on update CURRENT_TIMESTAMP comment '更新时间',
agent_id bigint not null,
constraint un_name_version
unique (agent_id, form_id, version)
)
comment '动态表单模板' collate = utf8mb4_bin;
create table form_template_field
(
id bigint unsigned auto_increment comment '主键ID'
primary key,
template_id bigint unsigned null comment 'form_template 的id',
code varchar(50) not null comment '编码',
parent_id bigint null comment '父id',
title varchar(50) not null comment '标题',
show_title varchar(50) not null comment 'show标题',
db_field varchar(255) null comment '数据库中关联字段(目前用作流程流转时数据判断)',
required tinyint(1) null comment ' 是否必填',
`show` tinyint(1) null comment ' 是否显示',
dcode varchar(50) null comment '字典code',
type varchar(32) not null comment '字段类型',
fixed tinyint(1) null comment '固定0不固定1固定',
cascade_close varchar(2000) null comment '级联关,英文逗号分割',
cascade_open varchar(2000) null comment '级联开,英文逗号分割',
edit tinyint(1) null comment '是否可编辑',
fmt_constraint varchar(100) null comment '格式约束:int、double、str、boolean、date、select(下拉选择)',
sort_order int default 999 not null comment '排序',
edit_disabled_msg varchar(500) null comment '可编辑按钮禁用提示',
edit_disabled tinyint(1) null comment '可编辑按钮禁用',
show_cascade varchar(2000) null comment '字典级联显示',
ext json not null comment '扩展属性(JSON格式)',
created_by bigint unsigned not null comment '创建人',
updated_by bigint unsigned null comment '更新人',
create_time datetime default CURRENT_TIMESTAMP not null comment '创建时间',
update_time datetime null on update CURRENT_TIMESTAMP comment '更新时间',
agent_id bigint not null,
line tinyint null comment '占行数量0-不占一行,其他-占的行数)',
constraint un_template_id_code
unique (agent_id, template_id, code)
)
comment '动态表单模板字段' collate = utf8mb4_bin;
create table modify_log_record
(
id bigint unsigned auto_increment comment '主键ID'
primary key,
entity_type varchar(50) not null comment '实体类型FormFieldDict, FormTemplate, FormTemplateField等',
entity_id varchar(50) not null comment '实体ID',
form_code varchar(32) null comment 'form_code',
description varchar(200) null comment '描述',
field_chinese_name varchar(100) not null comment '字段中文名',
field_english_name varchar(100) not null comment '字段英文名',
old_value varchar(2048) null comment '修改前值',
new_value varchar(2048) null comment '修改后值',
operator bigint unsigned not null comment '操作人ID',
operator_name varchar(100) not null comment '操作人ID',
operation_time datetime default CURRENT_TIMESTAMP not null comment '操作时间',
create_time datetime default CURRENT_TIMESTAMP not null comment '创建时间',
update_time datetime null on update CURRENT_TIMESTAMP comment '更新时间',
service_name varchar(50) not null comment '服务名称',
deleted tinyint default 0 not null comment '是否删除(0:否,1:是)',
agent_id bigint not null comment '租户ID'
)
comment '修改记录日志表' collate = utf8mb4_bin;
create index idx_entity_type_entity_id
on modify_log_record (agent_id, entity_type, entity_id);
create table tenant_init_status
(
id bigint unsigned auto_increment comment '主键ID'
primary key,
initialized tinyint default 0 not null comment '初始化状态(0:未初始化,1:已初始化)',
create_time datetime default CURRENT_TIMESTAMP not null comment '创建时间',
update_time datetime null on update CURRENT_TIMESTAMP comment '更新时间',
agent_id bigint not null comment '租户ID',
constraint un_agent_id
unique (agent_id)
)
comment '租户初始化状态表' collate = utf8mb4_bin;