增加主机信息功能
This commit is contained in:
@@ -0,0 +1,23 @@
|
|||||||
|
package com.jeesite.modules.apps.Module.Dict;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class DataColumn implements Serializable {
|
||||||
|
|
||||||
|
private String createTime; // 创建时间
|
||||||
|
private String columnId; // 字段ID
|
||||||
|
private String tableId; // 所属表ID
|
||||||
|
private String tableSchema;
|
||||||
|
private String tableName;
|
||||||
|
private String columnName; // 字段名
|
||||||
|
private String columnComment; // 字段注释
|
||||||
|
private String columnType; // 字段类型
|
||||||
|
private String dataType; // 数据类型
|
||||||
|
private Long maxLength; // 长度
|
||||||
|
private String isNullable; // 0非空 1可为空
|
||||||
|
private String isPrimaryKey; // 0否 1是主键
|
||||||
|
private Integer sort; // 排序
|
||||||
|
}
|
||||||
@@ -0,0 +1,19 @@
|
|||||||
|
package com.jeesite.modules.apps.Module.Dict;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class DataTable implements Serializable {
|
||||||
|
|
||||||
|
private String createTime; // 创建时间
|
||||||
|
private String tableId; // 表ID
|
||||||
|
private String sourceId; // 数据源ID
|
||||||
|
private String tableName; // 数据表名
|
||||||
|
private String tableComment; // 表注释
|
||||||
|
private Long tableRows; // 数据行数
|
||||||
|
private BigDecimal tableSize;
|
||||||
|
private String dataSource;
|
||||||
|
}
|
||||||
@@ -0,0 +1,24 @@
|
|||||||
|
package com.jeesite.modules.apps.Module.Dict;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class TableTree implements Serializable {
|
||||||
|
|
||||||
|
DataTable dataTable;
|
||||||
|
|
||||||
|
List<DataColumn> dataColumns;
|
||||||
|
|
||||||
|
public TableTree() {
|
||||||
|
}
|
||||||
|
|
||||||
|
public TableTree(DataTable dataTable, List<DataColumn> dataColumns) {
|
||||||
|
this.dataTable = dataTable;
|
||||||
|
this.dataColumns = dataColumns;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,26 +0,0 @@
|
|||||||
package com.jeesite.modules.apps.Module;
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
import com.jeesite.modules.biz.entity.MyDataColumn;
|
|
||||||
import com.jeesite.modules.biz.entity.MyDataTable;
|
|
||||||
import lombok.Data;
|
|
||||||
|
|
||||||
import java.io.Serializable;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
@Data
|
|
||||||
public class TableTree implements Serializable {
|
|
||||||
|
|
||||||
MyDataTable dataTable;
|
|
||||||
|
|
||||||
List<MyDataColumn> dataColumns;
|
|
||||||
|
|
||||||
public TableTree() {
|
|
||||||
}
|
|
||||||
|
|
||||||
public TableTree(MyDataTable dataTable, List<MyDataColumn> dataColumns) {
|
|
||||||
this.dataTable = dataTable;
|
|
||||||
this.dataColumns = dataColumns;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,9 +1,9 @@
|
|||||||
package com.jeesite.modules.apps.utils;
|
package com.jeesite.modules.apps.utils;
|
||||||
|
|
||||||
import com.jeesite.modules.apps.Module.TableTree;
|
import com.jeesite.modules.apps.Module.Dict.DataColumn;
|
||||||
import com.jeesite.modules.biz.entity.MyDataColumn;
|
import com.jeesite.modules.apps.Module.Dict.DataTable;
|
||||||
|
import com.jeesite.modules.apps.Module.Dict.TableTree;
|
||||||
import com.jeesite.modules.biz.entity.MyDataSource;
|
import com.jeesite.modules.biz.entity.MyDataSource;
|
||||||
import com.jeesite.modules.biz.entity.MyDataTable;
|
|
||||||
|
|
||||||
|
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
@@ -44,14 +44,14 @@ public class MysqlUtils {
|
|||||||
* @return 数据库名 -> 表信息列表(包含字段)的映射
|
* @return 数据库名 -> 表信息列表(包含字段)的映射
|
||||||
* @throws Exception 连接或查询异常
|
* @throws Exception 连接或查询异常
|
||||||
*/
|
*/
|
||||||
public static Map<String, List<MyDataTable>> getMysqlSchemaInfo(Connection conn) throws Exception {
|
public static Map<String, List<DataTable>> getMysqlSchemaInfo(Connection conn) throws Exception {
|
||||||
Map<String, List<MyDataTable>> result = new HashMap<>();
|
Map<String, List<DataTable>> result = new HashMap<>();
|
||||||
// 1. 获取所有非系统数据库
|
// 1. 获取所有非系统数据库
|
||||||
List<String> databases = getNonSystemDatabases(conn);
|
List<String> databases = getNonSystemDatabases(conn);
|
||||||
logger.info("获取到非系统数据库数量:", databases.size());
|
logger.info("获取到非系统数据库数量:", databases.size());
|
||||||
// 2. 遍历数据库,获取表和字段信息
|
// 2. 遍历数据库,获取表和字段信息
|
||||||
for (String dbName : databases) {
|
for (String dbName : databases) {
|
||||||
List<MyDataTable> tableInfos = getTablesByDatabase(conn, dbName);
|
List<DataTable> tableInfos = getTablesByDatabase(conn, dbName);
|
||||||
result.put(dbName, tableInfos);
|
result.put(dbName, tableInfos);
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
@@ -80,8 +80,8 @@ public class MysqlUtils {
|
|||||||
/**
|
/**
|
||||||
* 获取指定数据库下的所有表信息(包含字段)
|
* 获取指定数据库下的所有表信息(包含字段)
|
||||||
*/
|
*/
|
||||||
private static List<MyDataTable> getTablesByDatabase(Connection conn, String dbName) throws SQLException {
|
private static List<DataTable> getTablesByDatabase(Connection conn, String dbName) throws SQLException {
|
||||||
List<MyDataTable> tableInfos = new ArrayList<>();
|
List<DataTable> tableInfos = new ArrayList<>();
|
||||||
String tableSql = "SELECT " +
|
String tableSql = "SELECT " +
|
||||||
"TABLE_NAME, TABLE_COMMENT, CREATE_TIME, UPDATE_TIME, " +
|
"TABLE_NAME, TABLE_COMMENT, CREATE_TIME, UPDATE_TIME, " +
|
||||||
"DATA_LENGTH, INDEX_LENGTH, TABLE_ROWS " +
|
"DATA_LENGTH, INDEX_LENGTH, TABLE_ROWS " +
|
||||||
@@ -90,8 +90,8 @@ public class MysqlUtils {
|
|||||||
tablePs.setString(1, dbName);
|
tablePs.setString(1, dbName);
|
||||||
try (ResultSet tableRs = tablePs.executeQuery()) {
|
try (ResultSet tableRs = tablePs.executeQuery()) {
|
||||||
while (tableRs.next()) {
|
while (tableRs.next()) {
|
||||||
MyDataTable tableInfo = buildDataTableInfo(tableRs, dbName);
|
DataTable tableInfo = buildDataTableInfo(tableRs, dbName);
|
||||||
List<MyDataColumn> fields = getFieldsByTable(conn, dbName, tableInfo.getTableName());
|
List<DataColumn> fields = getFieldsByTable(conn, dbName, tableInfo.getTableName());
|
||||||
fields.forEach(field -> field.setTableId(tableInfo.getTableId()));
|
fields.forEach(field -> field.setTableId(tableInfo.getTableId()));
|
||||||
tableInfos.add(tableInfo);
|
tableInfos.add(tableInfo);
|
||||||
}
|
}
|
||||||
@@ -103,8 +103,8 @@ public class MysqlUtils {
|
|||||||
/**
|
/**
|
||||||
* 构建DataTableInfo实体
|
* 构建DataTableInfo实体
|
||||||
*/
|
*/
|
||||||
private static MyDataTable buildDataTableInfo(ResultSet tableRs, String dbName) throws SQLException {
|
private static DataTable buildDataTableInfo(ResultSet tableRs, String dbName) throws SQLException {
|
||||||
MyDataTable dataTable = new MyDataTable();
|
DataTable dataTable = new DataTable();
|
||||||
String runTime = DateUtils.getCurrentDateTime();
|
String runTime = DateUtils.getCurrentDateTime();
|
||||||
String createDate = tableRs.getString("CREATE_TIME");
|
String createDate = tableRs.getString("CREATE_TIME");
|
||||||
String updateDate = tableRs.getString("UPDATE_TIME");
|
String updateDate = tableRs.getString("UPDATE_TIME");
|
||||||
@@ -120,19 +120,17 @@ public class MysqlUtils {
|
|||||||
dataTable.setTableSize(tableSize);
|
dataTable.setTableSize(tableSize);
|
||||||
dataTable.setDataSource(dbName);
|
dataTable.setDataSource(dbName);
|
||||||
dataTable.setCreateTime(createDate != null ? createDate : runTime);
|
dataTable.setCreateTime(createDate != null ? createDate : runTime);
|
||||||
dataTable.setUpdateTime(updateDate != null ? updateDate : runTime);
|
|
||||||
dataTable.setDs(DateUtils.dsValue());
|
|
||||||
return dataTable;
|
return dataTable;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取指定表的字段信息
|
* 获取指定表的字段信息
|
||||||
*/
|
*/
|
||||||
private static List<MyDataColumn> getFieldsByTable(Connection conn, String dbName, String tableName) throws SQLException {
|
private static List<DataColumn> getFieldsByTable(Connection conn, String dbName, String tableName) throws SQLException {
|
||||||
List<MyDataColumn> columns = new ArrayList<>();
|
List<DataColumn> columns = new ArrayList<>();
|
||||||
String fieldSql = "SELECT " +
|
String fieldSql = "SELECT " +
|
||||||
"TABLE_SCHEMA,TABLE_NAME,COLUMN_NAME,DATA_TYPE, COLUMN_TYPE, COLUMN_COMMENT, " +
|
"TABLE_SCHEMA,TABLE_NAME,COLUMN_NAME,DATA_TYPE, COLUMN_TYPE, COLUMN_COMMENT, " +
|
||||||
"ORDINAL_POSITION, CHARACTER_MAXIMUM_LENGTH " +
|
"ORDINAL_POSITION, CHARACTER_MAXIMUM_LENGTH, IS_NULLABLE,COLUMN_KEY " +
|
||||||
"FROM COLUMNS WHERE TABLE_SCHEMA = ? AND TABLE_NAME = ? " +
|
"FROM COLUMNS WHERE TABLE_SCHEMA = ? AND TABLE_NAME = ? " +
|
||||||
"ORDER BY ORDINAL_POSITION";
|
"ORDER BY ORDINAL_POSITION";
|
||||||
try (PreparedStatement fieldPs = conn.prepareStatement(fieldSql)) {
|
try (PreparedStatement fieldPs = conn.prepareStatement(fieldSql)) {
|
||||||
@@ -150,22 +148,22 @@ public class MysqlUtils {
|
|||||||
/**
|
/**
|
||||||
* 构建DataTableField实体
|
* 构建DataTableField实体
|
||||||
*/
|
*/
|
||||||
private static MyDataColumn buildDataTableField(ResultSet fieldRs) throws SQLException {
|
private static DataColumn buildDataTableField(ResultSet fieldRs) throws SQLException {
|
||||||
MyDataColumn column = new MyDataColumn();
|
DataColumn column = new DataColumn();
|
||||||
column.setColumnId(KeyUtil.ObjKey(32, 0));
|
column.setColumnId(KeyUtil.ObjKey(32, 0));
|
||||||
column.setTableSchema(fieldRs.getString("TABLE_SCHEMA"));
|
column.setTableSchema(fieldRs.getString("TABLE_SCHEMA"));
|
||||||
column.setTableName(fieldRs.getString("TABLE_NAME"));
|
column.setTableName(fieldRs.getString("TABLE_NAME"));
|
||||||
column.setColumnName(fieldRs.getString("COLUMN_NAME"));
|
column.setColumnName(fieldRs.getString("COLUMN_NAME"));
|
||||||
column.setDataType(fieldRs.getString("DATA_TYPE"));
|
column.setDataType(fieldRs.getString("DATA_TYPE"));
|
||||||
column.setSort(fieldRs.getInt("ORDINAL_POSITION"));
|
column.setSort(fieldRs.getInt("ORDINAL_POSITION"));
|
||||||
|
column.setIsNullable(fieldRs.getString("IS_NULLABLE"));
|
||||||
|
column.setIsPrimaryKey(fieldRs.getString("COLUMN_KEY"));
|
||||||
column.setColumnComment(fieldRs.getString("COLUMN_COMMENT"));
|
column.setColumnComment(fieldRs.getString("COLUMN_COMMENT"));
|
||||||
Long length = fieldRs.getLong("CHARACTER_MAXIMUM_LENGTH");
|
Long length = fieldRs.getLong("CHARACTER_MAXIMUM_LENGTH");
|
||||||
if (length == 0 || fieldRs.wasNull()) {
|
if (length == 0 || fieldRs.wasNull()) {
|
||||||
length = extractLengthFromType(fieldRs.getString("COLUMN_TYPE"));
|
length = extractLengthFromType(fieldRs.getString("COLUMN_TYPE"));
|
||||||
}
|
}
|
||||||
column.setMaxLength(length);
|
column.setMaxLength(length);
|
||||||
column.setCreateTime(new Date());
|
|
||||||
column.setDs(DateUtils.dsValue());
|
|
||||||
return column;
|
return column;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -189,11 +187,11 @@ public class MysqlUtils {
|
|||||||
List<TableTree> tableTrees = new ArrayList<>();
|
List<TableTree> tableTrees = new ArrayList<>();
|
||||||
try {
|
try {
|
||||||
Connection conn = getConnection(dbConfig.getDbHost(), dbConfig.getDbPort(), dbConfig.getUsername(), dbConfig.getPassword());
|
Connection conn = getConnection(dbConfig.getDbHost(), dbConfig.getDbPort(), dbConfig.getUsername(), dbConfig.getPassword());
|
||||||
Map<String, List<MyDataTable>> schemaInfo = MysqlUtils.getMysqlSchemaInfo(conn);
|
Map<String, List<DataTable>> schemaInfo = MysqlUtils.getMysqlSchemaInfo(conn);
|
||||||
for (Map.Entry<String, List<MyDataTable>> entry : schemaInfo.entrySet()) {
|
for (Map.Entry<String, List<DataTable>> entry : schemaInfo.entrySet()) {
|
||||||
for (MyDataTable dataTable : entry.getValue()) {
|
for (DataTable dataTable : entry.getValue()) {
|
||||||
dataTable.setSourceId(dbConfig.getId());
|
dataTable.setSourceId(dbConfig.getId());
|
||||||
List<MyDataColumn> dataTableFields = getFieldsByTable(conn, entry.getKey(), dataTable.getTableName());
|
List<DataColumn> dataTableFields = getFieldsByTable(conn, entry.getKey(), dataTable.getTableName());
|
||||||
dataTableFields.stream().forEach(tableField -> tableField.setTableId(dataTable.getTableId()));
|
dataTableFields.stream().forEach(tableField -> tableField.setTableId(dataTable.getTableId()));
|
||||||
tableTrees.add(new TableTree(dataTable, dataTableFields));
|
tableTrees.add(new TableTree(dataTable, dataTableFields));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
package com.jeesite.modules.apps.utils;
|
package com.jeesite.modules.apps.utils;
|
||||||
|
|
||||||
|
|
||||||
import com.jeesite.modules.biz.entity.MyDataColumn;
|
import com.jeesite.modules.apps.Module.Dict.DataColumn;
|
||||||
import com.jeesite.modules.biz.entity.MyDataTable;
|
import com.jeesite.modules.apps.Module.Dict.DataTable;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@@ -14,13 +14,13 @@ public class SqlUtils {
|
|||||||
*
|
*
|
||||||
* @return CREATE TABLE语句
|
* @return CREATE TABLE语句
|
||||||
*/
|
*/
|
||||||
public static String CreateTableSql(MyDataTable dataTable, List<MyDataColumn> dataColumns) {
|
public static String CreateTableSql(DataTable dataTable, List<DataColumn> dataColumns) {
|
||||||
StringBuilder sb = new StringBuilder();
|
StringBuilder sb = new StringBuilder();
|
||||||
// 表定义开始
|
// 表定义开始
|
||||||
sb.append("CREATE TABLE ").append(dataTable.getTableName()).append(" (\n");
|
sb.append("CREATE TABLE ").append(dataTable.getTableName()).append(" (\n");
|
||||||
// 拼接字段定义
|
// 拼接字段定义
|
||||||
for (int i = 0; i < dataColumns.size(); i++) {
|
for (int i = 0; i < dataColumns.size(); i++) {
|
||||||
MyDataColumn dataColumn = dataColumns.get(i);
|
DataColumn dataColumn = dataColumns.get(i);
|
||||||
sb.append(" ").append(dataColumn.getColumnName()).append(" ");
|
sb.append(" ").append(dataColumn.getColumnName()).append(" ");
|
||||||
// 处理字段类型和长度
|
// 处理字段类型和长度
|
||||||
if (dataColumn.getMaxLength() != null && dataColumn.getMaxLength() > 0) {
|
if (dataColumn.getMaxLength() != null && dataColumn.getMaxLength() > 0) {
|
||||||
@@ -56,7 +56,7 @@ public class SqlUtils {
|
|||||||
*
|
*
|
||||||
* @return 带注释的SELECT语句
|
* @return 带注释的SELECT语句
|
||||||
*/
|
*/
|
||||||
public static String SelectSqlComments(MyDataTable dataTable, List<MyDataColumn> dataColumns) {
|
public static String SelectSqlComments(DataTable dataTable, List<DataColumn> dataColumns) {
|
||||||
StringBuilder sb = new StringBuilder();
|
StringBuilder sb = new StringBuilder();
|
||||||
// 表注释
|
// 表注释
|
||||||
sb.append("-- 表名:").append(dataTable.getTableName()).append("\n");
|
sb.append("-- 表名:").append(dataTable.getTableName()).append("\n");
|
||||||
@@ -66,7 +66,7 @@ public class SqlUtils {
|
|||||||
sb.append("SELECT\n");
|
sb.append("SELECT\n");
|
||||||
// 拼接字段(带注释)
|
// 拼接字段(带注释)
|
||||||
for (int i = 0; i < dataColumns.size(); i++) {
|
for (int i = 0; i < dataColumns.size(); i++) {
|
||||||
MyDataColumn dataColumn = dataColumns.get(i);
|
DataColumn dataColumn = dataColumns.get(i);
|
||||||
// 拼接字段名
|
// 拼接字段名
|
||||||
sb.append(" ").append(dataColumn.getColumnName());
|
sb.append(" ").append(dataColumn.getColumnName());
|
||||||
if (i != dataColumns.size() - 1) {
|
if (i != dataColumns.size() - 1) {
|
||||||
|
|||||||
@@ -1,15 +0,0 @@
|
|||||||
package com.jeesite.modules.biz.dao;
|
|
||||||
|
|
||||||
import com.jeesite.common.dao.CrudDao;
|
|
||||||
import com.jeesite.common.mybatis.annotation.MyBatisDao;
|
|
||||||
import com.jeesite.modules.biz.entity.MyDataColumn;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 数据字段信息表 DAO 接口
|
|
||||||
* @author gaoxq
|
|
||||||
* @version 2026-04-19
|
|
||||||
*/
|
|
||||||
@MyBatisDao(dataSourceName="work")
|
|
||||||
public interface MyDataColumnDao extends CrudDao<MyDataColumn> {
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,15 +0,0 @@
|
|||||||
package com.jeesite.modules.biz.dao;
|
|
||||||
|
|
||||||
import com.jeesite.common.dao.CrudDao;
|
|
||||||
import com.jeesite.common.mybatis.annotation.MyBatisDao;
|
|
||||||
import com.jeesite.modules.biz.entity.MyDataTable;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 数据表信息表 DAO 接口
|
|
||||||
* @author gaoxq
|
|
||||||
* @version 2026-04-19
|
|
||||||
*/
|
|
||||||
@MyBatisDao(dataSourceName="work")
|
|
||||||
public interface MyDataTableDao extends CrudDao<MyDataTable> {
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,91 +0,0 @@
|
|||||||
package com.jeesite.modules.biz.entity;
|
|
||||||
|
|
||||||
import java.io.Serializable;
|
|
||||||
import java.util.Date;
|
|
||||||
|
|
||||||
import com.jeesite.common.mybatis.annotation.JoinTable;
|
|
||||||
import com.jeesite.common.mybatis.annotation.JoinTable.Type;
|
|
||||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
|
||||||
import jakarta.validation.constraints.NotBlank;
|
|
||||||
import jakarta.validation.constraints.Size;
|
|
||||||
|
|
||||||
import com.jeesite.common.entity.DataEntity;
|
|
||||||
import com.jeesite.common.mybatis.annotation.Column;
|
|
||||||
import com.jeesite.common.mybatis.annotation.Table;
|
|
||||||
import com.jeesite.common.mybatis.mapper.query.QueryType;
|
|
||||||
import com.jeesite.common.utils.excel.annotation.ExcelField;
|
|
||||||
import com.jeesite.common.utils.excel.annotation.ExcelField.Align;
|
|
||||||
import com.jeesite.common.utils.excel.annotation.ExcelFields;
|
|
||||||
import lombok.Data;
|
|
||||||
import lombok.EqualsAndHashCode;
|
|
||||||
|
|
||||||
import java.io.Serial;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 数据字段信息表 Entity
|
|
||||||
*
|
|
||||||
* @author gaoxq
|
|
||||||
* @version 2026-04-19
|
|
||||||
*/
|
|
||||||
@EqualsAndHashCode(callSuper = true)
|
|
||||||
@Table(name = "my_data_column", alias = "a", label = "字段信息表信息", columns = {
|
|
||||||
@Column(name = "create_time", attrName = "createTime", label = "创建时间", isUpdateForce = true),
|
|
||||||
@Column(name = "column_id", attrName = "columnId", label = "字段ID", isPK = true),
|
|
||||||
@Column(name = "table_id", attrName = "tableId", label = "所属表ID"),
|
|
||||||
@Column(name = "table_schema", attrName = "tableSchema", label = "数据库名称"),
|
|
||||||
@Column(name = "table_name", attrName = "tableName", label = "所属表名称"),
|
|
||||||
@Column(name = "column_name", attrName = "columnName", label = "字段名", queryType = QueryType.LIKE),
|
|
||||||
@Column(name = "column_comment", attrName = "columnComment", label = "字段注释"),
|
|
||||||
@Column(name = "column_type", attrName = "columnType", label = "字段类型"),
|
|
||||||
@Column(name = "data_type", attrName = "dataType", label = "数据类型"),
|
|
||||||
@Column(name = "max_length", attrName = "maxLength", label = "长度", isUpdateForce = true),
|
|
||||||
@Column(name = "is_nullable", attrName = "isNullable", label = "0非空 1可为空"),
|
|
||||||
@Column(name = "is_primary_key", attrName = "isPrimaryKey", label = "0否 1是主键"),
|
|
||||||
@Column(name = "sort", attrName = "sort", label = "排序", isUpdateForce = true),
|
|
||||||
@Column(name = "update_time", attrName = "updateTime", label = "更新日期", isUpdateForce = true),
|
|
||||||
@Column(name = "ds", attrName = "ds", label = "日期分区"),
|
|
||||||
}, orderBy = "a.column_id DESC"
|
|
||||||
)
|
|
||||||
@Data
|
|
||||||
public class MyDataColumn extends DataEntity<MyDataColumn> implements Serializable {
|
|
||||||
|
|
||||||
@Serial
|
|
||||||
private static final long serialVersionUID = 1L;
|
|
||||||
private Date createTime; // 创建时间
|
|
||||||
private String columnId; // 字段ID
|
|
||||||
private String tableId; // 所属表ID
|
|
||||||
private String tableSchema;
|
|
||||||
private String tableName;
|
|
||||||
private String columnName; // 字段名
|
|
||||||
private String columnComment; // 字段注释
|
|
||||||
private String columnType; // 字段类型
|
|
||||||
private String dataType; // 数据类型
|
|
||||||
private Long maxLength; // 长度
|
|
||||||
private String isNullable; // 0非空 1可为空
|
|
||||||
private String isPrimaryKey; // 0否 1是主键
|
|
||||||
private Integer sort; // 排序
|
|
||||||
private Date updateTime; // 更新日期
|
|
||||||
private String ds;
|
|
||||||
|
|
||||||
@ExcelFields({
|
|
||||||
@ExcelField(title = "创建时间", attrName = "createTime", align = Align.CENTER, sort = 10, dataFormat = "yyyy-MM-dd hh:mm"),
|
|
||||||
@ExcelField(title = "字段ID", attrName = "columnId", align = Align.CENTER, sort = 20),
|
|
||||||
@ExcelField(title = "所属表ID", attrName = "tableId", align = Align.CENTER, sort = 30),
|
|
||||||
@ExcelField(title = "字段名", attrName = "columnName", align = Align.CENTER, sort = 40),
|
|
||||||
@ExcelField(title = "字段注释", attrName = "columnComment", align = Align.CENTER, sort = 50),
|
|
||||||
@ExcelField(title = "字段类型", attrName = "columnType", align = Align.CENTER, sort = 60),
|
|
||||||
@ExcelField(title = "数据类型", attrName = "dataType", align = Align.CENTER, sort = 70),
|
|
||||||
@ExcelField(title = "长度", attrName = "maxLength", align = Align.CENTER, sort = 80),
|
|
||||||
@ExcelField(title = "0非空 1可为空", attrName = "isNullable", align = Align.CENTER, sort = 90),
|
|
||||||
@ExcelField(title = "0否 1是主键", attrName = "isPrimaryKey", align = Align.CENTER, sort = 100),
|
|
||||||
@ExcelField(title = "排序", attrName = "sort", align = Align.CENTER, sort = 110),
|
|
||||||
@ExcelField(title = "update_time", attrName = "updateTime", align = Align.CENTER, sort = 120, dataFormat = "yyyy-MM-dd hh:mm"),
|
|
||||||
})
|
|
||||||
public MyDataColumn() {
|
|
||||||
this(null);
|
|
||||||
}
|
|
||||||
|
|
||||||
public MyDataColumn(String id) {
|
|
||||||
super(id);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,76 +0,0 @@
|
|||||||
package com.jeesite.modules.biz.entity;
|
|
||||||
|
|
||||||
import java.io.Serializable;
|
|
||||||
import java.math.BigDecimal;
|
|
||||||
import java.util.Date;
|
|
||||||
|
|
||||||
import com.jeesite.common.mybatis.annotation.JoinTable;
|
|
||||||
import com.jeesite.common.mybatis.annotation.JoinTable.Type;
|
|
||||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
|
||||||
import jakarta.validation.constraints.NotBlank;
|
|
||||||
import jakarta.validation.constraints.Size;
|
|
||||||
|
|
||||||
import com.jeesite.common.entity.DataEntity;
|
|
||||||
import com.jeesite.common.mybatis.annotation.Column;
|
|
||||||
import com.jeesite.common.mybatis.annotation.Table;
|
|
||||||
import com.jeesite.common.mybatis.mapper.query.QueryType;
|
|
||||||
import com.jeesite.common.utils.excel.annotation.ExcelField;
|
|
||||||
import com.jeesite.common.utils.excel.annotation.ExcelField.Align;
|
|
||||||
import com.jeesite.common.utils.excel.annotation.ExcelFields;
|
|
||||||
import lombok.Data;
|
|
||||||
|
|
||||||
import java.io.Serial;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 数据表信息表 Entity
|
|
||||||
*
|
|
||||||
* @author gaoxq
|
|
||||||
* @version 2026-04-19
|
|
||||||
*/
|
|
||||||
@Table(name = "my_data_table", alias = "a", label = "数据表信息信息", columns = {
|
|
||||||
@Column(name = "create_time", attrName = "createTime", label = "创建时间", isUpdate = false, isUpdateForce = true),
|
|
||||||
@Column(name = "table_id", attrName = "tableId", label = "表ID", isPK = true),
|
|
||||||
@Column(name = "source_id", attrName = "sourceId", label = "数据源ID"),
|
|
||||||
@Column(name = "table_name", attrName = "tableName", label = "数据表名", queryType = QueryType.LIKE),
|
|
||||||
@Column(name = "table_comment", attrName = "tableComment", label = "表注释"),
|
|
||||||
@Column(name = "table_rows", attrName = "tableRows", label = "数据行数"),
|
|
||||||
@Column(name = "table_size", attrName = "tableSize", label = "数据表大小"),
|
|
||||||
@Column(name = "update_time", attrName = "updateTime", label = "更新日期"),
|
|
||||||
@Column(name = "data_source", attrName = "dataSource", label = "数据库名称"),
|
|
||||||
@Column(name = "ds", attrName = "ds", label = "日期分区"),
|
|
||||||
}, orderBy = "a.create_time DESC"
|
|
||||||
)
|
|
||||||
@Data
|
|
||||||
public class MyDataTable extends DataEntity<MyDataTable> implements Serializable {
|
|
||||||
|
|
||||||
@Serial
|
|
||||||
private static final long serialVersionUID = 1L;
|
|
||||||
private String createTime; // 创建时间
|
|
||||||
private String tableId; // 表ID
|
|
||||||
private String sourceId; // 数据源ID
|
|
||||||
private String tableName; // 数据表名
|
|
||||||
private String tableComment; // 表注释
|
|
||||||
private Long tableRows; // 数据行数
|
|
||||||
private BigDecimal tableSize;
|
|
||||||
private String updateTime; // 更新日期
|
|
||||||
private String dataSource;
|
|
||||||
private String ds;
|
|
||||||
|
|
||||||
@ExcelFields({
|
|
||||||
@ExcelField(title = "创建时间", attrName = "createTime", align = Align.CENTER, sort = 10, dataFormat = "yyyy-MM-dd hh:mm"),
|
|
||||||
@ExcelField(title = "表ID", attrName = "tableId", align = Align.CENTER, sort = 20),
|
|
||||||
@ExcelField(title = "数据源ID", attrName = "sourceId", align = Align.CENTER, sort = 30),
|
|
||||||
@ExcelField(title = "数据表名", attrName = "tableName", align = Align.CENTER, sort = 40),
|
|
||||||
@ExcelField(title = "表注释", attrName = "tableComment", align = Align.CENTER, sort = 50),
|
|
||||||
@ExcelField(title = "数据行数", attrName = "tableRows", align = Align.CENTER, sort = 60),
|
|
||||||
@ExcelField(title = "update_time", attrName = "updateTime", align = Align.CENTER, sort = 70, dataFormat = "yyyy-MM-dd hh:mm"),
|
|
||||||
})
|
|
||||||
public MyDataTable() {
|
|
||||||
this(null);
|
|
||||||
}
|
|
||||||
|
|
||||||
public MyDataTable(String id) {
|
|
||||||
super(id);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,134 +0,0 @@
|
|||||||
package com.jeesite.modules.biz.service;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
import org.springframework.stereotype.Service;
|
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
|
||||||
|
|
||||||
import com.jeesite.common.entity.Page;
|
|
||||||
import com.jeesite.common.service.CrudService;
|
|
||||||
import com.jeesite.modules.biz.entity.MyDataColumn;
|
|
||||||
import com.jeesite.modules.biz.dao.MyDataColumnDao;
|
|
||||||
import com.jeesite.common.service.ServiceException;
|
|
||||||
import com.jeesite.common.config.Global;
|
|
||||||
import com.jeesite.common.validator.ValidatorUtils;
|
|
||||||
import com.jeesite.common.utils.excel.ExcelImport;
|
|
||||||
import org.springframework.web.multipart.MultipartFile;
|
|
||||||
import jakarta.validation.ConstraintViolation;
|
|
||||||
import jakarta.validation.ConstraintViolationException;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 数据字段信息表 Service
|
|
||||||
* @author gaoxq
|
|
||||||
* @version 2026-04-19
|
|
||||||
*/
|
|
||||||
@Service
|
|
||||||
public class MyDataColumnService extends CrudService<MyDataColumnDao, MyDataColumn> {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取单条数据
|
|
||||||
* @param myDataColumn 主键
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public MyDataColumn get(MyDataColumn myDataColumn) {
|
|
||||||
return super.get(myDataColumn);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 查询分页数据
|
|
||||||
* @param myDataColumn 查询条件
|
|
||||||
* @param myDataColumn page 分页对象
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public Page<MyDataColumn> findPage(MyDataColumn myDataColumn) {
|
|
||||||
return super.findPage(myDataColumn);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 查询列表数据
|
|
||||||
* @param myDataColumn 查询条件
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public List<MyDataColumn> findList(MyDataColumn myDataColumn) {
|
|
||||||
return super.findList(myDataColumn);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 保存数据(插入或更新)
|
|
||||||
* @param myDataColumn 数据对象
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
@Transactional
|
|
||||||
public void save(MyDataColumn myDataColumn) {
|
|
||||||
super.save(myDataColumn);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 导入数据
|
|
||||||
* @param file 导入的数据文件
|
|
||||||
*/
|
|
||||||
@Transactional
|
|
||||||
public String importData(MultipartFile file) {
|
|
||||||
if (file == null){
|
|
||||||
throw new ServiceException(text("请选择导入的数据文件!"));
|
|
||||||
}
|
|
||||||
int successNum = 0; int failureNum = 0;
|
|
||||||
StringBuilder successMsg = new StringBuilder();
|
|
||||||
StringBuilder failureMsg = new StringBuilder();
|
|
||||||
try(ExcelImport ei = new ExcelImport(file, 2, 0)){
|
|
||||||
List<MyDataColumn> list = ei.getDataList(MyDataColumn.class);
|
|
||||||
for (MyDataColumn myDataColumn : list) {
|
|
||||||
try{
|
|
||||||
ValidatorUtils.validateWithException(myDataColumn);
|
|
||||||
this.save(myDataColumn);
|
|
||||||
successNum++;
|
|
||||||
successMsg.append("<br/>" + successNum + "、编号 " + myDataColumn.getId() + " 导入成功");
|
|
||||||
} catch (Exception e) {
|
|
||||||
failureNum++;
|
|
||||||
String msg = "<br/>" + failureNum + "、编号 " + myDataColumn.getId() + " 导入失败:";
|
|
||||||
if (e instanceof ConstraintViolationException){
|
|
||||||
ConstraintViolationException cve = (ConstraintViolationException)e;
|
|
||||||
for (ConstraintViolation<?> violation : cve.getConstraintViolations()) {
|
|
||||||
msg += Global.getText(violation.getMessage()) + " ("+violation.getPropertyPath()+")";
|
|
||||||
}
|
|
||||||
}else{
|
|
||||||
msg += e.getMessage();
|
|
||||||
}
|
|
||||||
failureMsg.append(msg);
|
|
||||||
logger.error(msg, e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} catch (Exception e) {
|
|
||||||
logger.error(e.getMessage(), e);
|
|
||||||
failureMsg.append(e.getMessage());
|
|
||||||
return failureMsg.toString();
|
|
||||||
}
|
|
||||||
if (failureNum > 0) {
|
|
||||||
failureMsg.insert(0, "很抱歉,导入失败!共 " + failureNum + " 条数据格式不正确,错误如下:");
|
|
||||||
throw new ServiceException(failureMsg.toString());
|
|
||||||
}else{
|
|
||||||
successMsg.insert(0, "恭喜您,数据已全部导入成功!共 " + successNum + " 条,数据如下:");
|
|
||||||
}
|
|
||||||
return successMsg.toString();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 更新状态
|
|
||||||
* @param myDataColumn 数据对象
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
@Transactional
|
|
||||||
public void updateStatus(MyDataColumn myDataColumn) {
|
|
||||||
super.updateStatus(myDataColumn);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 删除数据
|
|
||||||
* @param myDataColumn 数据对象
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
@Transactional
|
|
||||||
public void delete(MyDataColumn myDataColumn) {
|
|
||||||
super.delete(myDataColumn);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,134 +0,0 @@
|
|||||||
package com.jeesite.modules.biz.service;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
import org.springframework.stereotype.Service;
|
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
|
||||||
|
|
||||||
import com.jeesite.common.entity.Page;
|
|
||||||
import com.jeesite.common.service.CrudService;
|
|
||||||
import com.jeesite.modules.biz.entity.MyDataTable;
|
|
||||||
import com.jeesite.modules.biz.dao.MyDataTableDao;
|
|
||||||
import com.jeesite.common.service.ServiceException;
|
|
||||||
import com.jeesite.common.config.Global;
|
|
||||||
import com.jeesite.common.validator.ValidatorUtils;
|
|
||||||
import com.jeesite.common.utils.excel.ExcelImport;
|
|
||||||
import org.springframework.web.multipart.MultipartFile;
|
|
||||||
import jakarta.validation.ConstraintViolation;
|
|
||||||
import jakarta.validation.ConstraintViolationException;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 数据表信息表 Service
|
|
||||||
* @author gaoxq
|
|
||||||
* @version 2026-04-19
|
|
||||||
*/
|
|
||||||
@Service
|
|
||||||
public class MyDataTableService extends CrudService<MyDataTableDao, MyDataTable> {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取单条数据
|
|
||||||
* @param myDataTable 主键
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public MyDataTable get(MyDataTable myDataTable) {
|
|
||||||
return super.get(myDataTable);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 查询分页数据
|
|
||||||
* @param myDataTable 查询条件
|
|
||||||
* @param myDataTable page 分页对象
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public Page<MyDataTable> findPage(MyDataTable myDataTable) {
|
|
||||||
return super.findPage(myDataTable);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 查询列表数据
|
|
||||||
* @param myDataTable 查询条件
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public List<MyDataTable> findList(MyDataTable myDataTable) {
|
|
||||||
return super.findList(myDataTable);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 保存数据(插入或更新)
|
|
||||||
* @param myDataTable 数据对象
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
@Transactional
|
|
||||||
public void save(MyDataTable myDataTable) {
|
|
||||||
super.save(myDataTable);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 导入数据
|
|
||||||
* @param file 导入的数据文件
|
|
||||||
*/
|
|
||||||
@Transactional
|
|
||||||
public String importData(MultipartFile file) {
|
|
||||||
if (file == null){
|
|
||||||
throw new ServiceException(text("请选择导入的数据文件!"));
|
|
||||||
}
|
|
||||||
int successNum = 0; int failureNum = 0;
|
|
||||||
StringBuilder successMsg = new StringBuilder();
|
|
||||||
StringBuilder failureMsg = new StringBuilder();
|
|
||||||
try(ExcelImport ei = new ExcelImport(file, 2, 0)){
|
|
||||||
List<MyDataTable> list = ei.getDataList(MyDataTable.class);
|
|
||||||
for (MyDataTable myDataTable : list) {
|
|
||||||
try{
|
|
||||||
ValidatorUtils.validateWithException(myDataTable);
|
|
||||||
this.save(myDataTable);
|
|
||||||
successNum++;
|
|
||||||
successMsg.append("<br/>" + successNum + "、编号 " + myDataTable.getId() + " 导入成功");
|
|
||||||
} catch (Exception e) {
|
|
||||||
failureNum++;
|
|
||||||
String msg = "<br/>" + failureNum + "、编号 " + myDataTable.getId() + " 导入失败:";
|
|
||||||
if (e instanceof ConstraintViolationException){
|
|
||||||
ConstraintViolationException cve = (ConstraintViolationException)e;
|
|
||||||
for (ConstraintViolation<?> violation : cve.getConstraintViolations()) {
|
|
||||||
msg += Global.getText(violation.getMessage()) + " ("+violation.getPropertyPath()+")";
|
|
||||||
}
|
|
||||||
}else{
|
|
||||||
msg += e.getMessage();
|
|
||||||
}
|
|
||||||
failureMsg.append(msg);
|
|
||||||
logger.error(msg, e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} catch (Exception e) {
|
|
||||||
logger.error(e.getMessage(), e);
|
|
||||||
failureMsg.append(e.getMessage());
|
|
||||||
return failureMsg.toString();
|
|
||||||
}
|
|
||||||
if (failureNum > 0) {
|
|
||||||
failureMsg.insert(0, "很抱歉,导入失败!共 " + failureNum + " 条数据格式不正确,错误如下:");
|
|
||||||
throw new ServiceException(failureMsg.toString());
|
|
||||||
}else{
|
|
||||||
successMsg.insert(0, "恭喜您,数据已全部导入成功!共 " + successNum + " 条,数据如下:");
|
|
||||||
}
|
|
||||||
return successMsg.toString();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 更新状态
|
|
||||||
* @param myDataTable 数据对象
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
@Transactional
|
|
||||||
public void updateStatus(MyDataTable myDataTable) {
|
|
||||||
super.updateStatus(myDataTable);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 删除数据
|
|
||||||
* @param myDataTable 数据对象
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
@Transactional
|
|
||||||
public void delete(MyDataTable myDataTable) {
|
|
||||||
super.delete(myDataTable);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,146 +0,0 @@
|
|||||||
package com.jeesite.modules.biz.web;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
import jakarta.servlet.http.HttpServletRequest;
|
|
||||||
import jakarta.servlet.http.HttpServletResponse;
|
|
||||||
|
|
||||||
import org.apache.shiro.authz.annotation.RequiresPermissions;
|
|
||||||
import org.springframework.stereotype.Controller;
|
|
||||||
import org.springframework.ui.Model;
|
|
||||||
import org.springframework.validation.annotation.Validated;
|
|
||||||
import org.springframework.web.bind.annotation.ModelAttribute;
|
|
||||||
import org.springframework.web.bind.annotation.PostMapping;
|
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
|
||||||
import org.springframework.web.bind.annotation.ResponseBody;
|
|
||||||
|
|
||||||
import com.jeesite.common.config.Global;
|
|
||||||
import com.jeesite.common.collect.ListUtils;
|
|
||||||
import com.jeesite.common.entity.Page;
|
|
||||||
import com.jeesite.common.lang.DateUtils;
|
|
||||||
import com.jeesite.common.utils.excel.ExcelExport;
|
|
||||||
import com.jeesite.common.utils.excel.annotation.ExcelField.Type;
|
|
||||||
import org.springframework.web.multipart.MultipartFile;
|
|
||||||
import com.jeesite.common.web.BaseController;
|
|
||||||
import com.jeesite.modules.biz.entity.MyDataColumn;
|
|
||||||
import com.jeesite.modules.biz.service.MyDataColumnService;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 数据字段信息表 Controller
|
|
||||||
* @author gaoxq
|
|
||||||
* @version 2026-04-19
|
|
||||||
*/
|
|
||||||
@Controller
|
|
||||||
@RequestMapping(value = "${adminPath}/biz/myDataColumn")
|
|
||||||
public class MyDataColumnController extends BaseController {
|
|
||||||
|
|
||||||
private final MyDataColumnService myDataColumnService;
|
|
||||||
|
|
||||||
public MyDataColumnController(MyDataColumnService myDataColumnService) {
|
|
||||||
this.myDataColumnService = myDataColumnService;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取数据
|
|
||||||
*/
|
|
||||||
@ModelAttribute
|
|
||||||
public MyDataColumn get(String columnId, boolean isNewRecord) {
|
|
||||||
return myDataColumnService.get(columnId, isNewRecord);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 查询列表
|
|
||||||
*/
|
|
||||||
@RequiresPermissions("biz:myDataColumn:view")
|
|
||||||
@RequestMapping(value = {"list", ""})
|
|
||||||
public String list(MyDataColumn myDataColumn, Model model) {
|
|
||||||
model.addAttribute("myDataColumn", myDataColumn);
|
|
||||||
return "modules/biz/myDataColumnList";
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 查询列表数据
|
|
||||||
*/
|
|
||||||
@RequiresPermissions("biz:myDataColumn:view")
|
|
||||||
@RequestMapping(value = "listData")
|
|
||||||
@ResponseBody
|
|
||||||
public Page<MyDataColumn> listData(MyDataColumn myDataColumn, HttpServletRequest request, HttpServletResponse response) {
|
|
||||||
myDataColumn.setPage(new Page<>(request, response));
|
|
||||||
Page<MyDataColumn> page = myDataColumnService.findPage(myDataColumn);
|
|
||||||
return page;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 查看编辑表单
|
|
||||||
*/
|
|
||||||
@RequiresPermissions("biz:myDataColumn:view")
|
|
||||||
@RequestMapping(value = "form")
|
|
||||||
public String form(MyDataColumn myDataColumn, Model model) {
|
|
||||||
model.addAttribute("myDataColumn", myDataColumn);
|
|
||||||
return "modules/biz/myDataColumnForm";
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 保存数据
|
|
||||||
*/
|
|
||||||
@RequiresPermissions("biz:myDataColumn:edit")
|
|
||||||
@PostMapping(value = "save")
|
|
||||||
@ResponseBody
|
|
||||||
public String save(@Validated MyDataColumn myDataColumn) {
|
|
||||||
myDataColumnService.save(myDataColumn);
|
|
||||||
return renderResult(Global.TRUE, text("保存字段信息表成功!"));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 导出数据
|
|
||||||
*/
|
|
||||||
@RequiresPermissions("biz:myDataColumn:view")
|
|
||||||
@RequestMapping(value = "exportData")
|
|
||||||
public void exportData(MyDataColumn myDataColumn, HttpServletResponse response) {
|
|
||||||
List<MyDataColumn> list = myDataColumnService.findList(myDataColumn);
|
|
||||||
String fileName = "字段信息表" + DateUtils.getDate("yyyyMMddHHmmss") + ".xlsx";
|
|
||||||
try(ExcelExport ee = new ExcelExport("字段信息表", MyDataColumn.class)){
|
|
||||||
ee.setDataList(list).write(response, fileName);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 下载模板
|
|
||||||
*/
|
|
||||||
@RequiresPermissions("biz:myDataColumn:view")
|
|
||||||
@RequestMapping(value = "importTemplate")
|
|
||||||
public void importTemplate(HttpServletResponse response) {
|
|
||||||
MyDataColumn myDataColumn = new MyDataColumn();
|
|
||||||
List<MyDataColumn> list = ListUtils.newArrayList(myDataColumn);
|
|
||||||
String fileName = "字段信息表模板.xlsx";
|
|
||||||
try(ExcelExport ee = new ExcelExport("字段信息表", MyDataColumn.class, Type.IMPORT)){
|
|
||||||
ee.setDataList(list).write(response, fileName);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 导入数据
|
|
||||||
*/
|
|
||||||
@ResponseBody
|
|
||||||
@RequiresPermissions("biz:myDataColumn:edit")
|
|
||||||
@PostMapping(value = "importData")
|
|
||||||
public String importData(MultipartFile file) {
|
|
||||||
try {
|
|
||||||
String message = myDataColumnService.importData(file);
|
|
||||||
return renderResult(Global.TRUE, "posfull:"+message);
|
|
||||||
} catch (Exception ex) {
|
|
||||||
return renderResult(Global.FALSE, "posfull:"+ex.getMessage());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 删除数据
|
|
||||||
*/
|
|
||||||
@RequiresPermissions("biz:myDataColumn:edit")
|
|
||||||
@RequestMapping(value = "delete")
|
|
||||||
@ResponseBody
|
|
||||||
public String delete(MyDataColumn myDataColumn) {
|
|
||||||
myDataColumnService.delete(myDataColumn);
|
|
||||||
return renderResult(Global.TRUE, text("删除字段信息表成功!"));
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,146 +0,0 @@
|
|||||||
package com.jeesite.modules.biz.web;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
import jakarta.servlet.http.HttpServletRequest;
|
|
||||||
import jakarta.servlet.http.HttpServletResponse;
|
|
||||||
|
|
||||||
import org.apache.shiro.authz.annotation.RequiresPermissions;
|
|
||||||
import org.springframework.stereotype.Controller;
|
|
||||||
import org.springframework.ui.Model;
|
|
||||||
import org.springframework.validation.annotation.Validated;
|
|
||||||
import org.springframework.web.bind.annotation.ModelAttribute;
|
|
||||||
import org.springframework.web.bind.annotation.PostMapping;
|
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
|
||||||
import org.springframework.web.bind.annotation.ResponseBody;
|
|
||||||
|
|
||||||
import com.jeesite.common.config.Global;
|
|
||||||
import com.jeesite.common.collect.ListUtils;
|
|
||||||
import com.jeesite.common.entity.Page;
|
|
||||||
import com.jeesite.common.lang.DateUtils;
|
|
||||||
import com.jeesite.common.utils.excel.ExcelExport;
|
|
||||||
import com.jeesite.common.utils.excel.annotation.ExcelField.Type;
|
|
||||||
import org.springframework.web.multipart.MultipartFile;
|
|
||||||
import com.jeesite.common.web.BaseController;
|
|
||||||
import com.jeesite.modules.biz.entity.MyDataTable;
|
|
||||||
import com.jeesite.modules.biz.service.MyDataTableService;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 数据表信息表 Controller
|
|
||||||
* @author gaoxq
|
|
||||||
* @version 2026-04-19
|
|
||||||
*/
|
|
||||||
@Controller
|
|
||||||
@RequestMapping(value = "${adminPath}/biz/myDataTable")
|
|
||||||
public class MyDataTableController extends BaseController {
|
|
||||||
|
|
||||||
private final MyDataTableService myDataTableService;
|
|
||||||
|
|
||||||
public MyDataTableController(MyDataTableService myDataTableService) {
|
|
||||||
this.myDataTableService = myDataTableService;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取数据
|
|
||||||
*/
|
|
||||||
@ModelAttribute
|
|
||||||
public MyDataTable get(String tableId, boolean isNewRecord) {
|
|
||||||
return myDataTableService.get(tableId, isNewRecord);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 查询列表
|
|
||||||
*/
|
|
||||||
@RequiresPermissions("biz:myDataTable:view")
|
|
||||||
@RequestMapping(value = {"list", ""})
|
|
||||||
public String list(MyDataTable myDataTable, Model model) {
|
|
||||||
model.addAttribute("myDataTable", myDataTable);
|
|
||||||
return "modules/biz/myDataTableList";
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 查询列表数据
|
|
||||||
*/
|
|
||||||
@RequiresPermissions("biz:myDataTable:view")
|
|
||||||
@RequestMapping(value = "listData")
|
|
||||||
@ResponseBody
|
|
||||||
public Page<MyDataTable> listData(MyDataTable myDataTable, HttpServletRequest request, HttpServletResponse response) {
|
|
||||||
myDataTable.setPage(new Page<>(request, response));
|
|
||||||
Page<MyDataTable> page = myDataTableService.findPage(myDataTable);
|
|
||||||
return page;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 查看编辑表单
|
|
||||||
*/
|
|
||||||
@RequiresPermissions("biz:myDataTable:view")
|
|
||||||
@RequestMapping(value = "form")
|
|
||||||
public String form(MyDataTable myDataTable, Model model) {
|
|
||||||
model.addAttribute("myDataTable", myDataTable);
|
|
||||||
return "modules/biz/myDataTableForm";
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 保存数据
|
|
||||||
*/
|
|
||||||
@RequiresPermissions("biz:myDataTable:edit")
|
|
||||||
@PostMapping(value = "save")
|
|
||||||
@ResponseBody
|
|
||||||
public String save(@Validated MyDataTable myDataTable) {
|
|
||||||
myDataTableService.save(myDataTable);
|
|
||||||
return renderResult(Global.TRUE, text("保存数据表信息成功!"));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 导出数据
|
|
||||||
*/
|
|
||||||
@RequiresPermissions("biz:myDataTable:view")
|
|
||||||
@RequestMapping(value = "exportData")
|
|
||||||
public void exportData(MyDataTable myDataTable, HttpServletResponse response) {
|
|
||||||
List<MyDataTable> list = myDataTableService.findList(myDataTable);
|
|
||||||
String fileName = "数据表信息" + DateUtils.getDate("yyyyMMddHHmmss") + ".xlsx";
|
|
||||||
try(ExcelExport ee = new ExcelExport("数据表信息", MyDataTable.class)){
|
|
||||||
ee.setDataList(list).write(response, fileName);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 下载模板
|
|
||||||
*/
|
|
||||||
@RequiresPermissions("biz:myDataTable:view")
|
|
||||||
@RequestMapping(value = "importTemplate")
|
|
||||||
public void importTemplate(HttpServletResponse response) {
|
|
||||||
MyDataTable myDataTable = new MyDataTable();
|
|
||||||
List<MyDataTable> list = ListUtils.newArrayList(myDataTable);
|
|
||||||
String fileName = "数据表信息模板.xlsx";
|
|
||||||
try(ExcelExport ee = new ExcelExport("数据表信息", MyDataTable.class, Type.IMPORT)){
|
|
||||||
ee.setDataList(list).write(response, fileName);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 导入数据
|
|
||||||
*/
|
|
||||||
@ResponseBody
|
|
||||||
@RequiresPermissions("biz:myDataTable:edit")
|
|
||||||
@PostMapping(value = "importData")
|
|
||||||
public String importData(MultipartFile file) {
|
|
||||||
try {
|
|
||||||
String message = myDataTableService.importData(file);
|
|
||||||
return renderResult(Global.TRUE, "posfull:"+message);
|
|
||||||
} catch (Exception ex) {
|
|
||||||
return renderResult(Global.FALSE, "posfull:"+ex.getMessage());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 删除数据
|
|
||||||
*/
|
|
||||||
@RequiresPermissions("biz:myDataTable:edit")
|
|
||||||
@RequestMapping(value = "delete")
|
|
||||||
@ResponseBody
|
|
||||||
public String delete(MyDataTable myDataTable) {
|
|
||||||
myDataTableService.delete(myDataTable);
|
|
||||||
return renderResult(Global.TRUE, text("删除数据表信息成功!"));
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,15 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8" ?>
|
|
||||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
|
||||||
<mapper namespace="com.jeesite.modules.biz.dao.MyDataColumnDao">
|
|
||||||
|
|
||||||
<!-- 查询数据
|
|
||||||
<select id="findList" resultType="MyDataColumn">
|
|
||||||
SELECT ${sqlMap.column.toSql()}
|
|
||||||
FROM ${sqlMap.table.toSql()}
|
|
||||||
<where>
|
|
||||||
${sqlMap.where.toSql()}
|
|
||||||
</where>
|
|
||||||
ORDER BY ${sqlMap.order.toSql()}
|
|
||||||
</select> -->
|
|
||||||
|
|
||||||
</mapper>
|
|
||||||
@@ -1,15 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8" ?>
|
|
||||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
|
||||||
<mapper namespace="com.jeesite.modules.biz.dao.MyDataTableDao">
|
|
||||||
|
|
||||||
<!-- 查询数据
|
|
||||||
<select id="findList" resultType="MyDataTable">
|
|
||||||
SELECT ${sqlMap.column.toSql()}
|
|
||||||
FROM ${sqlMap.table.toSql()}
|
|
||||||
<where>
|
|
||||||
${sqlMap.where.toSql()}
|
|
||||||
</where>
|
|
||||||
ORDER BY ${sqlMap.order.toSql()}
|
|
||||||
</select> -->
|
|
||||||
|
|
||||||
</mapper>
|
|
||||||
@@ -1,55 +0,0 @@
|
|||||||
/**
|
|
||||||
* Copyright (c) 2013-Now https://jeesite.com All rights reserved.
|
|
||||||
* No deletion without permission, or be held responsible to law.
|
|
||||||
* @author gaoxq
|
|
||||||
*/
|
|
||||||
import { defHttp } from '@jeesite/core/utils/http/axios';
|
|
||||||
import { useGlobSetting } from '@jeesite/core/hooks/setting';
|
|
||||||
import { BasicModel, Page } from '@jeesite/core/api/model/baseModel';
|
|
||||||
import { UploadApiResult } from '@jeesite/core/api/sys/upload';
|
|
||||||
import { UploadFileParams } from '@jeesite/types/axios';
|
|
||||||
import { AxiosProgressEvent } from 'axios';
|
|
||||||
|
|
||||||
const { ctxPath, adminPath } = useGlobSetting();
|
|
||||||
|
|
||||||
export interface MyDataColumn extends BasicModel<MyDataColumn> {
|
|
||||||
createTime?: string; // 创建时间
|
|
||||||
columnId?: string; // 字段ID
|
|
||||||
tableId: string; // 所属表ID
|
|
||||||
columnName: string; // 字段名
|
|
||||||
columnComment?: string; // 字段注释
|
|
||||||
columnType: string; // 字段类型
|
|
||||||
dataType?: string; // 数据类型
|
|
||||||
maxLength?: number; // 长度
|
|
||||||
isNullable?: string; // 0非空 1可为空
|
|
||||||
isPrimaryKey?: string; // 0否 1是主键
|
|
||||||
sort?: number; // 排序
|
|
||||||
updateTime?: string; // update_time
|
|
||||||
}
|
|
||||||
|
|
||||||
export const myDataColumnList = (params?: MyDataColumn | any) =>
|
|
||||||
defHttp.get<MyDataColumn>({ url: adminPath + '/biz/myDataColumn/list', params });
|
|
||||||
|
|
||||||
export const myDataColumnListData = (params?: MyDataColumn | any) =>
|
|
||||||
defHttp.post<Page<MyDataColumn>>({ url: adminPath + '/biz/myDataColumn/listData', params });
|
|
||||||
|
|
||||||
export const myDataColumnForm = (params?: MyDataColumn | any) =>
|
|
||||||
defHttp.get<MyDataColumn>({ url: adminPath + '/biz/myDataColumn/form', params });
|
|
||||||
|
|
||||||
export const myDataColumnSave = (params?: any, data?: MyDataColumn | any) =>
|
|
||||||
defHttp.postJson<MyDataColumn>({ url: adminPath + '/biz/myDataColumn/save', params, data });
|
|
||||||
|
|
||||||
export const myDataColumnImportData = (
|
|
||||||
params: UploadFileParams,
|
|
||||||
onUploadProgress: (progressEvent: AxiosProgressEvent) => void,
|
|
||||||
) =>
|
|
||||||
defHttp.uploadFile<UploadApiResult>(
|
|
||||||
{
|
|
||||||
url: ctxPath + adminPath + '/biz/myDataColumn/importData',
|
|
||||||
onUploadProgress,
|
|
||||||
},
|
|
||||||
params,
|
|
||||||
);
|
|
||||||
|
|
||||||
export const myDataColumnDelete = (params?: MyDataColumn | any) =>
|
|
||||||
defHttp.get<MyDataColumn>({ url: adminPath + '/biz/myDataColumn/delete', params });
|
|
||||||
@@ -1,50 +0,0 @@
|
|||||||
/**
|
|
||||||
* Copyright (c) 2013-Now https://jeesite.com All rights reserved.
|
|
||||||
* No deletion without permission, or be held responsible to law.
|
|
||||||
* @author gaoxq
|
|
||||||
*/
|
|
||||||
import { defHttp } from '@jeesite/core/utils/http/axios';
|
|
||||||
import { useGlobSetting } from '@jeesite/core/hooks/setting';
|
|
||||||
import { BasicModel, Page } from '@jeesite/core/api/model/baseModel';
|
|
||||||
import { UploadApiResult } from '@jeesite/core/api/sys/upload';
|
|
||||||
import { UploadFileParams } from '@jeesite/types/axios';
|
|
||||||
import { AxiosProgressEvent } from 'axios';
|
|
||||||
|
|
||||||
const { ctxPath, adminPath } = useGlobSetting();
|
|
||||||
|
|
||||||
export interface MyDataTable extends BasicModel<MyDataTable> {
|
|
||||||
createTime?: string; // 创建时间
|
|
||||||
tableId?: string; // 表ID
|
|
||||||
sourceId: string; // 数据源ID
|
|
||||||
tableName: string; // 数据表名
|
|
||||||
tableComment?: string; // 表注释
|
|
||||||
tableRows?: number; // 数据行数
|
|
||||||
updateTime?: string; // update_time
|
|
||||||
}
|
|
||||||
|
|
||||||
export const myDataTableList = (params?: MyDataTable | any) =>
|
|
||||||
defHttp.get<MyDataTable>({ url: adminPath + '/biz/myDataTable/list', params });
|
|
||||||
|
|
||||||
export const myDataTableListData = (params?: MyDataTable | any) =>
|
|
||||||
defHttp.post<Page<MyDataTable>>({ url: adminPath + '/biz/myDataTable/listData', params });
|
|
||||||
|
|
||||||
export const myDataTableForm = (params?: MyDataTable | any) =>
|
|
||||||
defHttp.get<MyDataTable>({ url: adminPath + '/biz/myDataTable/form', params });
|
|
||||||
|
|
||||||
export const myDataTableSave = (params?: any, data?: MyDataTable | any) =>
|
|
||||||
defHttp.postJson<MyDataTable>({ url: adminPath + '/biz/myDataTable/save', params, data });
|
|
||||||
|
|
||||||
export const myDataTableImportData = (
|
|
||||||
params: UploadFileParams,
|
|
||||||
onUploadProgress: (progressEvent: AxiosProgressEvent) => void,
|
|
||||||
) =>
|
|
||||||
defHttp.uploadFile<UploadApiResult>(
|
|
||||||
{
|
|
||||||
url: ctxPath + adminPath + '/biz/myDataTable/importData',
|
|
||||||
onUploadProgress,
|
|
||||||
},
|
|
||||||
params,
|
|
||||||
);
|
|
||||||
|
|
||||||
export const myDataTableDelete = (params?: MyDataTable | any) =>
|
|
||||||
defHttp.get<MyDataTable>({ url: adminPath + '/biz/myDataTable/delete', params });
|
|
||||||
@@ -1,175 +0,0 @@
|
|||||||
<!--
|
|
||||||
* Copyright (c) 2013-Now https://jeesite.com All rights reserved.
|
|
||||||
* No deletion without permission, or be held responsible to law.
|
|
||||||
* @author gaoxq
|
|
||||||
-->
|
|
||||||
<template>
|
|
||||||
<BasicDrawer
|
|
||||||
v-bind="$attrs"
|
|
||||||
:showFooter="true"
|
|
||||||
:okAuth="'biz:myDataColumn:edit'"
|
|
||||||
@register="registerDrawer"
|
|
||||||
@ok="handleSubmit"
|
|
||||||
width="70%"
|
|
||||||
>
|
|
||||||
<template #title>
|
|
||||||
<Icon :icon="getTitle.icon" class="m-1 pr-1" />
|
|
||||||
<span> {{ getTitle.value }} </span>
|
|
||||||
</template>
|
|
||||||
<BasicForm @register="registerForm" />
|
|
||||||
</BasicDrawer>
|
|
||||||
</template>
|
|
||||||
<script lang="ts" setup name="ViewsBizMyDataColumnForm">
|
|
||||||
import { ref, unref, computed } from 'vue';
|
|
||||||
import { useI18n } from '@jeesite/core/hooks/web/useI18n';
|
|
||||||
import { useMessage } from '@jeesite/core/hooks/web/useMessage';
|
|
||||||
import { router } from '@jeesite/core/router';
|
|
||||||
import { Icon } from '@jeesite/core/components/Icon';
|
|
||||||
import { BasicForm, FormSchema, useForm } from '@jeesite/core/components/Form';
|
|
||||||
import { BasicDrawer, useDrawerInner } from '@jeesite/core/components/Drawer';
|
|
||||||
import { MyDataColumn, myDataColumnSave, myDataColumnForm } from '@jeesite/biz/api/biz/myDataColumn';
|
|
||||||
|
|
||||||
const emit = defineEmits(['success', 'register']);
|
|
||||||
|
|
||||||
const { t } = useI18n('biz.myDataColumn');
|
|
||||||
const { showMessage } = useMessage();
|
|
||||||
const { meta } = unref(router.currentRoute);
|
|
||||||
const record = ref<MyDataColumn>({} as MyDataColumn);
|
|
||||||
|
|
||||||
const getTitle = computed(() => ({
|
|
||||||
icon: meta.icon || 'i-ant-design:book-outlined',
|
|
||||||
value: record.value.isNewRecord ? t('新增字段信息表') : t('编辑字段信息表'),
|
|
||||||
}));
|
|
||||||
|
|
||||||
const inputFormSchemas: FormSchema<MyDataColumn>[] = [
|
|
||||||
{
|
|
||||||
label: t('基本信息'),
|
|
||||||
field: 'basicInfo',
|
|
||||||
component: 'FormGroup',
|
|
||||||
colProps: { md: 24, lg: 24 },
|
|
||||||
},
|
|
||||||
{
|
|
||||||
label: t('所属表ID'),
|
|
||||||
field: 'tableId',
|
|
||||||
component: 'Input',
|
|
||||||
componentProps: {
|
|
||||||
maxlength: 52,
|
|
||||||
},
|
|
||||||
required: true,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
label: t('字段名'),
|
|
||||||
field: 'columnName',
|
|
||||||
component: 'Input',
|
|
||||||
componentProps: {
|
|
||||||
maxlength: 200,
|
|
||||||
},
|
|
||||||
required: true,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
label: t('字段注释'),
|
|
||||||
field: 'columnComment',
|
|
||||||
component: 'Input',
|
|
||||||
componentProps: {
|
|
||||||
maxlength: 500,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
{
|
|
||||||
label: t('字段类型'),
|
|
||||||
field: 'columnType',
|
|
||||||
component: 'Input',
|
|
||||||
componentProps: {
|
|
||||||
maxlength: 100,
|
|
||||||
},
|
|
||||||
required: true,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
label: t('数据类型'),
|
|
||||||
field: 'dataType',
|
|
||||||
component: 'Input',
|
|
||||||
componentProps: {
|
|
||||||
maxlength: 50,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
{
|
|
||||||
label: t('长度'),
|
|
||||||
field: 'maxLength',
|
|
||||||
component: 'Input',
|
|
||||||
componentProps: {
|
|
||||||
maxlength: 9,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
{
|
|
||||||
label: t('0非空 1可为空'),
|
|
||||||
field: 'isNullable',
|
|
||||||
component: 'Input',
|
|
||||||
componentProps: {
|
|
||||||
maxlength: 12,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
{
|
|
||||||
label: t('0否 1是主键'),
|
|
||||||
field: 'isPrimaryKey',
|
|
||||||
component: 'Input',
|
|
||||||
componentProps: {
|
|
||||||
maxlength: 12,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
{
|
|
||||||
label: t('排序'),
|
|
||||||
field: 'sort',
|
|
||||||
component: 'Input',
|
|
||||||
componentProps: {
|
|
||||||
maxlength: 9,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
{
|
|
||||||
label: t('update_time'),
|
|
||||||
field: 'updateTime',
|
|
||||||
component: 'DatePicker',
|
|
||||||
componentProps: {
|
|
||||||
format: 'YYYY-MM-DD HH:mm',
|
|
||||||
showTime: { format: 'HH:mm' },
|
|
||||||
},
|
|
||||||
},
|
|
||||||
];
|
|
||||||
|
|
||||||
const [registerForm, { resetFields, setFieldsValue, validate }] = useForm<MyDataColumn>({
|
|
||||||
labelWidth: 120,
|
|
||||||
schemas: inputFormSchemas,
|
|
||||||
baseColProps: { md: 24, lg: 12 },
|
|
||||||
});
|
|
||||||
|
|
||||||
const [registerDrawer, { setDrawerProps, closeDrawer }] = useDrawerInner(async (data) => {
|
|
||||||
setDrawerProps({ loading: true });
|
|
||||||
await resetFields();
|
|
||||||
const res = await myDataColumnForm(data);
|
|
||||||
record.value = (res.myDataColumn || {}) as MyDataColumn;
|
|
||||||
record.value.__t = new Date().getTime();
|
|
||||||
await setFieldsValue(record.value);
|
|
||||||
setDrawerProps({ loading: false });
|
|
||||||
});
|
|
||||||
|
|
||||||
async function handleSubmit() {
|
|
||||||
try {
|
|
||||||
const data = await validate();
|
|
||||||
setDrawerProps({ confirmLoading: true });
|
|
||||||
const params: any = {
|
|
||||||
isNewRecord: record.value.isNewRecord,
|
|
||||||
columnId: record.value.columnId || data.columnId,
|
|
||||||
};
|
|
||||||
// console.log('submit', params, data, record);
|
|
||||||
const res = await myDataColumnSave(params, data);
|
|
||||||
showMessage(res.message);
|
|
||||||
setTimeout(closeDrawer);
|
|
||||||
emit('success', data);
|
|
||||||
} catch (error: any) {
|
|
||||||
if (error && error.errorFields) {
|
|
||||||
showMessage(error.message || t('common.validateError'));
|
|
||||||
}
|
|
||||||
console.log('error', error);
|
|
||||||
} finally {
|
|
||||||
setDrawerProps({ confirmLoading: false });
|
|
||||||
}
|
|
||||||
}
|
|
||||||
</script>
|
|
||||||
@@ -1,103 +0,0 @@
|
|||||||
<!--
|
|
||||||
* Copyright (c) 2013-Now https://jeesite.com All rights reserved.
|
|
||||||
* No deletion without permission, or be held responsible to law.
|
|
||||||
* @author gaoxq
|
|
||||||
-->
|
|
||||||
<template>
|
|
||||||
<BasicModal
|
|
||||||
v-bind="$attrs"
|
|
||||||
:title="t('导入字段信息表')"
|
|
||||||
:okText="t('导入')"
|
|
||||||
@register="registerModal"
|
|
||||||
@ok="handleSubmit"
|
|
||||||
:minHeight="120"
|
|
||||||
:width="400"
|
|
||||||
>
|
|
||||||
<Upload accept=".xls,.xlsx" :file-list="fileList" :before-upload="beforeUpload" @remove="handleRemove">
|
|
||||||
<a-button> <Icon icon="ant-design:upload-outlined" /> {{ t('选择文件') }} </a-button>
|
|
||||||
<span class="ml-4">{{ uploadInfo }}</span>
|
|
||||||
</Upload>
|
|
||||||
<div class="ml-4 mt-4">
|
|
||||||
{{ t('提示:仅允许导入“xls”或“xlsx”格式文件!') }}
|
|
||||||
</div>
|
|
||||||
<div class="mt-4">
|
|
||||||
<a-button @click="handleDownloadTemplate()" type="text">
|
|
||||||
<Icon icon="i-fa:file-excel-o" />
|
|
||||||
{{ t('下载模板') }}
|
|
||||||
</a-button>
|
|
||||||
</div>
|
|
||||||
</BasicModal>
|
|
||||||
</template>
|
|
||||||
<script lang="ts" setup>
|
|
||||||
import { ref } from 'vue';
|
|
||||||
import { Upload } from 'ant-design-vue';
|
|
||||||
import { useI18n } from '@jeesite/core/hooks/web/useI18n';
|
|
||||||
import { useMessage } from '@jeesite/core/hooks/web/useMessage';
|
|
||||||
import { useGlobSetting } from '@jeesite/core/hooks/setting';
|
|
||||||
import { downloadByUrl } from '@jeesite/core/utils/file/download';
|
|
||||||
import { Icon } from '@jeesite/core/components/Icon';
|
|
||||||
import { BasicModal, useModalInner } from '@jeesite/core/components/Modal';
|
|
||||||
import { myDataColumnImportData } from '@jeesite/biz/api/biz/myDataColumn';
|
|
||||||
import { FileType } from 'ant-design-vue/es/upload/interface';
|
|
||||||
import { AxiosProgressEvent } from 'axios';
|
|
||||||
|
|
||||||
const emit = defineEmits(['success', 'register']);
|
|
||||||
|
|
||||||
const { t } = useI18n('biz.myDataColumn');
|
|
||||||
const { showMessage, showMessageModal } = useMessage();
|
|
||||||
|
|
||||||
const fileList = ref<FileType[]>([]);
|
|
||||||
const uploadInfo = ref('');
|
|
||||||
|
|
||||||
const beforeUpload = (file: FileType) => {
|
|
||||||
fileList.value = [file];
|
|
||||||
return false;
|
|
||||||
};
|
|
||||||
|
|
||||||
const handleRemove = () => {
|
|
||||||
fileList.value = [];
|
|
||||||
};
|
|
||||||
|
|
||||||
const [registerModal, { setModalProps, closeModal }] = useModalInner(() => {
|
|
||||||
fileList.value = [];
|
|
||||||
uploadInfo.value = '';
|
|
||||||
});
|
|
||||||
|
|
||||||
async function handleDownloadTemplate() {
|
|
||||||
const { ctxAdminPath } = useGlobSetting();
|
|
||||||
downloadByUrl({ url: ctxAdminPath + '/biz/myDataColumn/importTemplate' });
|
|
||||||
}
|
|
||||||
|
|
||||||
function onUploadProgress(progressEvent: AxiosProgressEvent) {
|
|
||||||
const complete = ((progressEvent.loaded / (progressEvent.total || 1)) * 100) | 0;
|
|
||||||
if (complete != 100) {
|
|
||||||
uploadInfo.value = t('正在导入,请稍候') + ' ' + complete + '%...';
|
|
||||||
} else {
|
|
||||||
uploadInfo.value = '';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
async function handleSubmit() {
|
|
||||||
try {
|
|
||||||
if (fileList.value.length == 0) {
|
|
||||||
showMessage(t('请选择要导入的数据文件'));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
setModalProps({ confirmLoading: true });
|
|
||||||
const params = {
|
|
||||||
file: fileList.value[0],
|
|
||||||
};
|
|
||||||
const { data } = await myDataColumnImportData(params, onUploadProgress);
|
|
||||||
showMessageModal({ content: data.message });
|
|
||||||
setTimeout(closeModal);
|
|
||||||
emit('success');
|
|
||||||
} catch (error: any) {
|
|
||||||
if (error && error.errorFields) {
|
|
||||||
showMessage(error.message || t('common.validateError'));
|
|
||||||
}
|
|
||||||
console.log('error', error);
|
|
||||||
} finally {
|
|
||||||
setModalProps({ confirmLoading: false });
|
|
||||||
}
|
|
||||||
}
|
|
||||||
</script>
|
|
||||||
@@ -1,297 +0,0 @@
|
|||||||
<!--
|
|
||||||
* Copyright (c) 2013-Now https://jeesite.com All rights reserved.
|
|
||||||
* No deletion without permission, or be held responsible to law.
|
|
||||||
* @author gaoxq
|
|
||||||
-->
|
|
||||||
<template>
|
|
||||||
<div>
|
|
||||||
<BasicTable @register="registerTable">
|
|
||||||
<template #tableTitle>
|
|
||||||
<Icon :icon="getTitle.icon" class="m-1 pr-1" />
|
|
||||||
<span> {{ getTitle.value }} </span>
|
|
||||||
</template>
|
|
||||||
<template #toolbar>
|
|
||||||
<a-button type="default" :loading="loading" @click="handleExport()">
|
|
||||||
<Icon icon="i-ant-design:download-outlined" /> {{ t('导出') }}
|
|
||||||
</a-button>
|
|
||||||
<a-button type="default" @click="handleImport()">
|
|
||||||
<Icon icon="i-ant-design:import-outlined" /> {{ t('导入') }}
|
|
||||||
</a-button>
|
|
||||||
<a-button type="primary" @click="handleForm({})" v-auth="'biz:myDataColumn:edit'">
|
|
||||||
<Icon icon="i-fluent:add-12-filled" /> {{ t('新增') }}
|
|
||||||
</a-button>
|
|
||||||
</template>
|
|
||||||
<template #firstColumn="{ record, text, value }">
|
|
||||||
<a @click="handleForm({ columnId: record.columnId })" :title="value">
|
|
||||||
{{ text }}
|
|
||||||
</a>
|
|
||||||
</template>
|
|
||||||
</BasicTable>
|
|
||||||
<InputForm @register="registerDrawer" @success="handleSuccess" />
|
|
||||||
<FormImport @register="registerImportModal" @success="handleSuccess" />
|
|
||||||
</div>
|
|
||||||
</template>
|
|
||||||
<script lang="ts" setup name="ViewsBizMyDataColumnList">
|
|
||||||
import { onMounted, ref, unref } from 'vue';
|
|
||||||
import { useI18n } from '@jeesite/core/hooks/web/useI18n';
|
|
||||||
import { useMessage } from '@jeesite/core/hooks/web/useMessage';
|
|
||||||
import { useGlobSetting } from '@jeesite/core/hooks/setting';
|
|
||||||
import { downloadByUrl } from '@jeesite/core/utils/file/download';
|
|
||||||
import { router } from '@jeesite/core/router';
|
|
||||||
import { Icon } from '@jeesite/core/components/Icon';
|
|
||||||
import { BasicTable, BasicColumn, useTable } from '@jeesite/core/components/Table';
|
|
||||||
import { MyDataColumn, myDataColumnList } from '@jeesite/biz/api/biz/myDataColumn';
|
|
||||||
import { myDataColumnDelete, myDataColumnListData } from '@jeesite/biz/api/biz/myDataColumn';
|
|
||||||
import { useDrawer } from '@jeesite/core/components/Drawer';
|
|
||||||
import { useModal } from '@jeesite/core/components/Modal';
|
|
||||||
import { FormProps } from '@jeesite/core/components/Form';
|
|
||||||
import InputForm from './form.vue';
|
|
||||||
import FormImport from './formImport.vue';
|
|
||||||
|
|
||||||
const { t } = useI18n('biz.myDataColumn');
|
|
||||||
const { showMessage } = useMessage();
|
|
||||||
const { meta } = unref(router.currentRoute);
|
|
||||||
const record = ref<MyDataColumn>({} as MyDataColumn);
|
|
||||||
|
|
||||||
const getTitle = {
|
|
||||||
icon: meta.icon || 'i-ant-design:book-outlined',
|
|
||||||
value: meta.title || t('字段信息表管理'),
|
|
||||||
};
|
|
||||||
const loading = ref(false);
|
|
||||||
|
|
||||||
const searchForm: FormProps<MyDataColumn> = {
|
|
||||||
baseColProps: { md: 8, lg: 6 },
|
|
||||||
labelWidth: 90,
|
|
||||||
schemas: [
|
|
||||||
{
|
|
||||||
label: t('创建时间'),
|
|
||||||
field: 'createTime',
|
|
||||||
component: 'DatePicker',
|
|
||||||
componentProps: {
|
|
||||||
format: 'YYYY-MM-DD HH:mm',
|
|
||||||
showTime: { format: 'HH:mm' },
|
|
||||||
},
|
|
||||||
},
|
|
||||||
{
|
|
||||||
label: t('所属表ID'),
|
|
||||||
field: 'tableId',
|
|
||||||
component: 'Input',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
label: t('字段名'),
|
|
||||||
field: 'columnName',
|
|
||||||
component: 'Input',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
label: t('字段注释'),
|
|
||||||
field: 'columnComment',
|
|
||||||
component: 'Input',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
label: t('字段类型'),
|
|
||||||
field: 'columnType',
|
|
||||||
component: 'Input',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
label: t('数据类型'),
|
|
||||||
field: 'dataType',
|
|
||||||
component: 'Input',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
label: t('长度'),
|
|
||||||
field: 'maxLength',
|
|
||||||
component: 'Input',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
label: t('0非空 1可为空'),
|
|
||||||
field: 'isNullable',
|
|
||||||
component: 'Input',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
label: t('0否 1是主键'),
|
|
||||||
field: 'isPrimaryKey',
|
|
||||||
component: 'Input',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
label: t('排序'),
|
|
||||||
field: 'sort',
|
|
||||||
component: 'Input',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
label: t('update_time'),
|
|
||||||
field: 'updateTime',
|
|
||||||
component: 'DatePicker',
|
|
||||||
componentProps: {
|
|
||||||
format: 'YYYY-MM-DD HH:mm',
|
|
||||||
showTime: { format: 'HH:mm' },
|
|
||||||
},
|
|
||||||
},
|
|
||||||
],
|
|
||||||
};
|
|
||||||
|
|
||||||
const tableColumns: BasicColumn<MyDataColumn>[] = [
|
|
||||||
{
|
|
||||||
title: t('创建时间'),
|
|
||||||
dataIndex: 'createTime',
|
|
||||||
key: 'a.create_time',
|
|
||||||
sorter: true,
|
|
||||||
width: 230,
|
|
||||||
align: 'left',
|
|
||||||
slot: 'firstColumn',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
title: t('所属表ID'),
|
|
||||||
dataIndex: 'tableId',
|
|
||||||
key: 'a.table_id',
|
|
||||||
sorter: true,
|
|
||||||
width: 130,
|
|
||||||
align: 'left',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
title: t('字段名'),
|
|
||||||
dataIndex: 'columnName',
|
|
||||||
key: 'a.column_name',
|
|
||||||
sorter: true,
|
|
||||||
width: 130,
|
|
||||||
align: 'left',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
title: t('字段注释'),
|
|
||||||
dataIndex: 'columnComment',
|
|
||||||
key: 'a.column_comment',
|
|
||||||
sorter: true,
|
|
||||||
width: 130,
|
|
||||||
align: 'left',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
title: t('字段类型'),
|
|
||||||
dataIndex: 'columnType',
|
|
||||||
key: 'a.column_type',
|
|
||||||
sorter: true,
|
|
||||||
width: 130,
|
|
||||||
align: 'left',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
title: t('数据类型'),
|
|
||||||
dataIndex: 'dataType',
|
|
||||||
key: 'a.data_type',
|
|
||||||
sorter: true,
|
|
||||||
width: 130,
|
|
||||||
align: 'left',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
title: t('长度'),
|
|
||||||
dataIndex: 'maxLength',
|
|
||||||
key: 'a.max_length',
|
|
||||||
sorter: true,
|
|
||||||
width: 130,
|
|
||||||
align: 'center',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
title: t('0非空 1可为空'),
|
|
||||||
dataIndex: 'isNullable',
|
|
||||||
key: 'a.is_nullable',
|
|
||||||
sorter: true,
|
|
||||||
width: 130,
|
|
||||||
align: 'left',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
title: t('0否 1是主键'),
|
|
||||||
dataIndex: 'isPrimaryKey',
|
|
||||||
key: 'a.is_primary_key',
|
|
||||||
sorter: true,
|
|
||||||
width: 130,
|
|
||||||
align: 'left',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
title: t('排序'),
|
|
||||||
dataIndex: 'sort',
|
|
||||||
key: 'a.sort',
|
|
||||||
sorter: true,
|
|
||||||
width: 130,
|
|
||||||
align: 'center',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
title: t('update_time'),
|
|
||||||
dataIndex: 'updateTime',
|
|
||||||
key: 'a.update_time',
|
|
||||||
sorter: true,
|
|
||||||
width: 130,
|
|
||||||
align: 'center',
|
|
||||||
},
|
|
||||||
];
|
|
||||||
|
|
||||||
const actionColumn: BasicColumn<MyDataColumn> = {
|
|
||||||
width: 160,
|
|
||||||
actions: (record: MyDataColumn) => [
|
|
||||||
{
|
|
||||||
icon: 'i-clarity:note-edit-line',
|
|
||||||
title: t('编辑字段信息表'),
|
|
||||||
onClick: handleForm.bind(this, { columnId: record.columnId }),
|
|
||||||
auth: 'biz:myDataColumn:edit',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
icon: 'i-ant-design:delete-outlined',
|
|
||||||
color: 'error',
|
|
||||||
title: t('删除字段信息表'),
|
|
||||||
popConfirm: {
|
|
||||||
title: t('是否确认删除字段信息表'),
|
|
||||||
confirm: handleDelete.bind(this, record),
|
|
||||||
},
|
|
||||||
auth: 'biz:myDataColumn:edit',
|
|
||||||
},
|
|
||||||
],
|
|
||||||
};
|
|
||||||
|
|
||||||
const [registerTable, { reload, getForm }] = useTable<MyDataColumn>({
|
|
||||||
api: myDataColumnListData,
|
|
||||||
beforeFetch: (params) => {
|
|
||||||
return params;
|
|
||||||
},
|
|
||||||
columns: tableColumns,
|
|
||||||
actionColumn: actionColumn,
|
|
||||||
formConfig: searchForm,
|
|
||||||
showTableSetting: true,
|
|
||||||
useSearchForm: true,
|
|
||||||
canResize: true,
|
|
||||||
});
|
|
||||||
|
|
||||||
onMounted(async () => {
|
|
||||||
const res = await myDataColumnList();
|
|
||||||
record.value = (res.myDataColumn || {}) as MyDataColumn;
|
|
||||||
await getForm().setFieldsValue(record.value);
|
|
||||||
});
|
|
||||||
|
|
||||||
const [registerDrawer, { openDrawer }] = useDrawer();
|
|
||||||
|
|
||||||
function handleForm(record: Recordable) {
|
|
||||||
openDrawer(true, record);
|
|
||||||
}
|
|
||||||
|
|
||||||
async function handleExport() {
|
|
||||||
loading.value = true;
|
|
||||||
const { ctxAdminPath } = useGlobSetting();
|
|
||||||
await downloadByUrl({
|
|
||||||
url: ctxAdminPath + '/biz/myDataColumn/exportData',
|
|
||||||
params: getForm().getFieldsValue(),
|
|
||||||
});
|
|
||||||
loading.value = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
const [registerImportModal, { openModal: importModal }] = useModal();
|
|
||||||
|
|
||||||
function handleImport() {
|
|
||||||
importModal(true, {});
|
|
||||||
}
|
|
||||||
|
|
||||||
async function handleDelete(record: Recordable) {
|
|
||||||
const params = { columnId: record.columnId };
|
|
||||||
const res = await myDataColumnDelete(params);
|
|
||||||
showMessage(res.message);
|
|
||||||
await handleSuccess(record);
|
|
||||||
}
|
|
||||||
|
|
||||||
async function handleSuccess(record: Recordable) {
|
|
||||||
await reload({ record });
|
|
||||||
}
|
|
||||||
</script>
|
|
||||||
@@ -1,190 +0,0 @@
|
|||||||
import { useI18n } from '@jeesite/core/hooks/web/useI18n';
|
|
||||||
import { BasicColumn, BasicTableProps, FormProps } from '@jeesite/core/components/Table';
|
|
||||||
import { myDataColumnListData } from '@jeesite/biz/api/biz/myDataColumn';
|
|
||||||
|
|
||||||
const { t } = useI18n('biz.myDataColumn');
|
|
||||||
|
|
||||||
const modalProps = {
|
|
||||||
title: t('字段信息表选择'),
|
|
||||||
};
|
|
||||||
|
|
||||||
const searchForm: FormProps<MyDataColumn> = {
|
|
||||||
baseColProps: { md: 8, lg: 6 },
|
|
||||||
labelWidth: 90,
|
|
||||||
schemas: [
|
|
||||||
{
|
|
||||||
label: t('创建时间'),
|
|
||||||
field: 'createTime',
|
|
||||||
component: 'DatePicker',
|
|
||||||
componentProps: {
|
|
||||||
format: 'YYYY-MM-DD HH:mm',
|
|
||||||
showTime: { format: 'HH:mm' },
|
|
||||||
},
|
|
||||||
},
|
|
||||||
{
|
|
||||||
label: t('所属表ID'),
|
|
||||||
field: 'tableId',
|
|
||||||
component: 'Input',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
label: t('字段名'),
|
|
||||||
field: 'columnName',
|
|
||||||
component: 'Input',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
label: t('字段注释'),
|
|
||||||
field: 'columnComment',
|
|
||||||
component: 'Input',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
label: t('字段类型'),
|
|
||||||
field: 'columnType',
|
|
||||||
component: 'Input',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
label: t('数据类型'),
|
|
||||||
field: 'dataType',
|
|
||||||
component: 'Input',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
label: t('长度'),
|
|
||||||
field: 'maxLength',
|
|
||||||
component: 'Input',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
label: t('0非空 1可为空'),
|
|
||||||
field: 'isNullable',
|
|
||||||
component: 'Input',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
label: t('0否 1是主键'),
|
|
||||||
field: 'isPrimaryKey',
|
|
||||||
component: 'Input',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
label: t('排序'),
|
|
||||||
field: 'sort',
|
|
||||||
component: 'Input',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
label: t('update_time'),
|
|
||||||
field: 'updateTime',
|
|
||||||
component: 'DatePicker',
|
|
||||||
componentProps: {
|
|
||||||
format: 'YYYY-MM-DD HH:mm',
|
|
||||||
showTime: { format: 'HH:mm' },
|
|
||||||
},
|
|
||||||
},
|
|
||||||
],
|
|
||||||
};
|
|
||||||
|
|
||||||
const tableColumns: BasicColumn<MyDataColumn>[] = [
|
|
||||||
{
|
|
||||||
title: t('创建时间'),
|
|
||||||
dataIndex: 'createTime',
|
|
||||||
key: 'a.create_time',
|
|
||||||
sorter: true,
|
|
||||||
width: 230,
|
|
||||||
align: 'left',
|
|
||||||
slot: 'firstColumn',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
title: t('所属表ID'),
|
|
||||||
dataIndex: 'tableId',
|
|
||||||
key: 'a.table_id',
|
|
||||||
sorter: true,
|
|
||||||
width: 130,
|
|
||||||
align: 'left',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
title: t('字段名'),
|
|
||||||
dataIndex: 'columnName',
|
|
||||||
key: 'a.column_name',
|
|
||||||
sorter: true,
|
|
||||||
width: 130,
|
|
||||||
align: 'left',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
title: t('字段注释'),
|
|
||||||
dataIndex: 'columnComment',
|
|
||||||
key: 'a.column_comment',
|
|
||||||
sorter: true,
|
|
||||||
width: 130,
|
|
||||||
align: 'left',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
title: t('字段类型'),
|
|
||||||
dataIndex: 'columnType',
|
|
||||||
key: 'a.column_type',
|
|
||||||
sorter: true,
|
|
||||||
width: 130,
|
|
||||||
align: 'left',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
title: t('数据类型'),
|
|
||||||
dataIndex: 'dataType',
|
|
||||||
key: 'a.data_type',
|
|
||||||
sorter: true,
|
|
||||||
width: 130,
|
|
||||||
align: 'left',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
title: t('长度'),
|
|
||||||
dataIndex: 'maxLength',
|
|
||||||
key: 'a.max_length',
|
|
||||||
sorter: true,
|
|
||||||
width: 130,
|
|
||||||
align: 'center',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
title: t('0非空 1可为空'),
|
|
||||||
dataIndex: 'isNullable',
|
|
||||||
key: 'a.is_nullable',
|
|
||||||
sorter: true,
|
|
||||||
width: 130,
|
|
||||||
align: 'left',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
title: t('0否 1是主键'),
|
|
||||||
dataIndex: 'isPrimaryKey',
|
|
||||||
key: 'a.is_primary_key',
|
|
||||||
sorter: true,
|
|
||||||
width: 130,
|
|
||||||
align: 'left',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
title: t('排序'),
|
|
||||||
dataIndex: 'sort',
|
|
||||||
key: 'a.sort',
|
|
||||||
sorter: true,
|
|
||||||
width: 130,
|
|
||||||
align: 'center',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
title: t('update_time'),
|
|
||||||
dataIndex: 'updateTime',
|
|
||||||
key: 'a.update_time',
|
|
||||||
sorter: true,
|
|
||||||
width: 130,
|
|
||||||
align: 'center',
|
|
||||||
},
|
|
||||||
];
|
|
||||||
|
|
||||||
const tableProps: BasicTableProps = {
|
|
||||||
api: myDataColumnListData,
|
|
||||||
beforeFetch: (params) => {
|
|
||||||
params['isAll'] = true;
|
|
||||||
return params;
|
|
||||||
},
|
|
||||||
columns: tableColumns,
|
|
||||||
formConfig: searchForm,
|
|
||||||
rowKey: 'columnId',
|
|
||||||
};
|
|
||||||
|
|
||||||
export default {
|
|
||||||
modalProps,
|
|
||||||
tableProps,
|
|
||||||
itemCode: 'columnId',
|
|
||||||
itemName: 'columnId',
|
|
||||||
isShowCode: false,
|
|
||||||
};
|
|
||||||
@@ -1,134 +0,0 @@
|
|||||||
<!--
|
|
||||||
* Copyright (c) 2013-Now https://jeesite.com All rights reserved.
|
|
||||||
* No deletion without permission, or be held responsible to law.
|
|
||||||
* @author gaoxq
|
|
||||||
-->
|
|
||||||
<template>
|
|
||||||
<BasicDrawer
|
|
||||||
v-bind="$attrs"
|
|
||||||
:showFooter="true"
|
|
||||||
:okAuth="'biz:myDataTable:edit'"
|
|
||||||
@register="registerDrawer"
|
|
||||||
@ok="handleSubmit"
|
|
||||||
width="70%"
|
|
||||||
>
|
|
||||||
<template #title>
|
|
||||||
<Icon :icon="getTitle.icon" class="m-1 pr-1" />
|
|
||||||
<span> {{ getTitle.value }} </span>
|
|
||||||
</template>
|
|
||||||
<BasicForm @register="registerForm" />
|
|
||||||
</BasicDrawer>
|
|
||||||
</template>
|
|
||||||
<script lang="ts" setup name="ViewsBizMyDataTableForm">
|
|
||||||
import { ref, unref, computed } from 'vue';
|
|
||||||
import { useI18n } from '@jeesite/core/hooks/web/useI18n';
|
|
||||||
import { useMessage } from '@jeesite/core/hooks/web/useMessage';
|
|
||||||
import { router } from '@jeesite/core/router';
|
|
||||||
import { Icon } from '@jeesite/core/components/Icon';
|
|
||||||
import { BasicForm, FormSchema, useForm } from '@jeesite/core/components/Form';
|
|
||||||
import { BasicDrawer, useDrawerInner } from '@jeesite/core/components/Drawer';
|
|
||||||
import { MyDataTable, myDataTableSave, myDataTableForm } from '@jeesite/biz/api/biz/myDataTable';
|
|
||||||
|
|
||||||
const emit = defineEmits(['success', 'register']);
|
|
||||||
|
|
||||||
const { t } = useI18n('biz.myDataTable');
|
|
||||||
const { showMessage } = useMessage();
|
|
||||||
const { meta } = unref(router.currentRoute);
|
|
||||||
const record = ref<MyDataTable>({} as MyDataTable);
|
|
||||||
|
|
||||||
const getTitle = computed(() => ({
|
|
||||||
icon: meta.icon || 'i-ant-design:book-outlined',
|
|
||||||
value: record.value.isNewRecord ? t('新增数据表信息') : t('编辑数据表信息'),
|
|
||||||
}));
|
|
||||||
|
|
||||||
const inputFormSchemas: FormSchema<MyDataTable>[] = [
|
|
||||||
{
|
|
||||||
label: t('基本信息'),
|
|
||||||
field: 'basicInfo',
|
|
||||||
component: 'FormGroup',
|
|
||||||
colProps: { md: 24, lg: 24 },
|
|
||||||
},
|
|
||||||
{
|
|
||||||
label: t('数据源ID'),
|
|
||||||
field: 'sourceId',
|
|
||||||
component: 'Input',
|
|
||||||
componentProps: {
|
|
||||||
maxlength: 52,
|
|
||||||
},
|
|
||||||
required: true,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
label: t('数据表名'),
|
|
||||||
field: 'tableName',
|
|
||||||
component: 'Input',
|
|
||||||
componentProps: {
|
|
||||||
maxlength: 200,
|
|
||||||
},
|
|
||||||
required: true,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
label: t('表注释'),
|
|
||||||
field: 'tableComment',
|
|
||||||
component: 'Input',
|
|
||||||
componentProps: {
|
|
||||||
maxlength: 500,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
{
|
|
||||||
label: t('数据行数'),
|
|
||||||
field: 'tableRows',
|
|
||||||
component: 'Input',
|
|
||||||
componentProps: {
|
|
||||||
maxlength: 18,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
{
|
|
||||||
label: t('update_time'),
|
|
||||||
field: 'updateTime',
|
|
||||||
component: 'DatePicker',
|
|
||||||
componentProps: {
|
|
||||||
format: 'YYYY-MM-DD HH:mm',
|
|
||||||
showTime: { format: 'HH:mm' },
|
|
||||||
},
|
|
||||||
},
|
|
||||||
];
|
|
||||||
|
|
||||||
const [registerForm, { resetFields, setFieldsValue, validate }] = useForm<MyDataTable>({
|
|
||||||
labelWidth: 120,
|
|
||||||
schemas: inputFormSchemas,
|
|
||||||
baseColProps: { md: 24, lg: 12 },
|
|
||||||
});
|
|
||||||
|
|
||||||
const [registerDrawer, { setDrawerProps, closeDrawer }] = useDrawerInner(async (data) => {
|
|
||||||
setDrawerProps({ loading: true });
|
|
||||||
await resetFields();
|
|
||||||
const res = await myDataTableForm(data);
|
|
||||||
record.value = (res.myDataTable || {}) as MyDataTable;
|
|
||||||
record.value.__t = new Date().getTime();
|
|
||||||
await setFieldsValue(record.value);
|
|
||||||
setDrawerProps({ loading: false });
|
|
||||||
});
|
|
||||||
|
|
||||||
async function handleSubmit() {
|
|
||||||
try {
|
|
||||||
const data = await validate();
|
|
||||||
setDrawerProps({ confirmLoading: true });
|
|
||||||
const params: any = {
|
|
||||||
isNewRecord: record.value.isNewRecord,
|
|
||||||
tableId: record.value.tableId || data.tableId,
|
|
||||||
};
|
|
||||||
// console.log('submit', params, data, record);
|
|
||||||
const res = await myDataTableSave(params, data);
|
|
||||||
showMessage(res.message);
|
|
||||||
setTimeout(closeDrawer);
|
|
||||||
emit('success', data);
|
|
||||||
} catch (error: any) {
|
|
||||||
if (error && error.errorFields) {
|
|
||||||
showMessage(error.message || t('common.validateError'));
|
|
||||||
}
|
|
||||||
console.log('error', error);
|
|
||||||
} finally {
|
|
||||||
setDrawerProps({ confirmLoading: false });
|
|
||||||
}
|
|
||||||
}
|
|
||||||
</script>
|
|
||||||
@@ -1,103 +0,0 @@
|
|||||||
<!--
|
|
||||||
* Copyright (c) 2013-Now https://jeesite.com All rights reserved.
|
|
||||||
* No deletion without permission, or be held responsible to law.
|
|
||||||
* @author gaoxq
|
|
||||||
-->
|
|
||||||
<template>
|
|
||||||
<BasicModal
|
|
||||||
v-bind="$attrs"
|
|
||||||
:title="t('导入数据表信息')"
|
|
||||||
:okText="t('导入')"
|
|
||||||
@register="registerModal"
|
|
||||||
@ok="handleSubmit"
|
|
||||||
:minHeight="120"
|
|
||||||
:width="400"
|
|
||||||
>
|
|
||||||
<Upload accept=".xls,.xlsx" :file-list="fileList" :before-upload="beforeUpload" @remove="handleRemove">
|
|
||||||
<a-button> <Icon icon="ant-design:upload-outlined" /> {{ t('选择文件') }} </a-button>
|
|
||||||
<span class="ml-4">{{ uploadInfo }}</span>
|
|
||||||
</Upload>
|
|
||||||
<div class="ml-4 mt-4">
|
|
||||||
{{ t('提示:仅允许导入“xls”或“xlsx”格式文件!') }}
|
|
||||||
</div>
|
|
||||||
<div class="mt-4">
|
|
||||||
<a-button @click="handleDownloadTemplate()" type="text">
|
|
||||||
<Icon icon="i-fa:file-excel-o" />
|
|
||||||
{{ t('下载模板') }}
|
|
||||||
</a-button>
|
|
||||||
</div>
|
|
||||||
</BasicModal>
|
|
||||||
</template>
|
|
||||||
<script lang="ts" setup>
|
|
||||||
import { ref } from 'vue';
|
|
||||||
import { Upload } from 'ant-design-vue';
|
|
||||||
import { useI18n } from '@jeesite/core/hooks/web/useI18n';
|
|
||||||
import { useMessage } from '@jeesite/core/hooks/web/useMessage';
|
|
||||||
import { useGlobSetting } from '@jeesite/core/hooks/setting';
|
|
||||||
import { downloadByUrl } from '@jeesite/core/utils/file/download';
|
|
||||||
import { Icon } from '@jeesite/core/components/Icon';
|
|
||||||
import { BasicModal, useModalInner } from '@jeesite/core/components/Modal';
|
|
||||||
import { myDataTableImportData } from '@jeesite/biz/api/biz/myDataTable';
|
|
||||||
import { FileType } from 'ant-design-vue/es/upload/interface';
|
|
||||||
import { AxiosProgressEvent } from 'axios';
|
|
||||||
|
|
||||||
const emit = defineEmits(['success', 'register']);
|
|
||||||
|
|
||||||
const { t } = useI18n('biz.myDataTable');
|
|
||||||
const { showMessage, showMessageModal } = useMessage();
|
|
||||||
|
|
||||||
const fileList = ref<FileType[]>([]);
|
|
||||||
const uploadInfo = ref('');
|
|
||||||
|
|
||||||
const beforeUpload = (file: FileType) => {
|
|
||||||
fileList.value = [file];
|
|
||||||
return false;
|
|
||||||
};
|
|
||||||
|
|
||||||
const handleRemove = () => {
|
|
||||||
fileList.value = [];
|
|
||||||
};
|
|
||||||
|
|
||||||
const [registerModal, { setModalProps, closeModal }] = useModalInner(() => {
|
|
||||||
fileList.value = [];
|
|
||||||
uploadInfo.value = '';
|
|
||||||
});
|
|
||||||
|
|
||||||
async function handleDownloadTemplate() {
|
|
||||||
const { ctxAdminPath } = useGlobSetting();
|
|
||||||
downloadByUrl({ url: ctxAdminPath + '/biz/myDataTable/importTemplate' });
|
|
||||||
}
|
|
||||||
|
|
||||||
function onUploadProgress(progressEvent: AxiosProgressEvent) {
|
|
||||||
const complete = ((progressEvent.loaded / (progressEvent.total || 1)) * 100) | 0;
|
|
||||||
if (complete != 100) {
|
|
||||||
uploadInfo.value = t('正在导入,请稍候') + ' ' + complete + '%...';
|
|
||||||
} else {
|
|
||||||
uploadInfo.value = '';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
async function handleSubmit() {
|
|
||||||
try {
|
|
||||||
if (fileList.value.length == 0) {
|
|
||||||
showMessage(t('请选择要导入的数据文件'));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
setModalProps({ confirmLoading: true });
|
|
||||||
const params = {
|
|
||||||
file: fileList.value[0],
|
|
||||||
};
|
|
||||||
const { data } = await myDataTableImportData(params, onUploadProgress);
|
|
||||||
showMessageModal({ content: data.message });
|
|
||||||
setTimeout(closeModal);
|
|
||||||
emit('success');
|
|
||||||
} catch (error: any) {
|
|
||||||
if (error && error.errorFields) {
|
|
||||||
showMessage(error.message || t('common.validateError'));
|
|
||||||
}
|
|
||||||
console.log('error', error);
|
|
||||||
} finally {
|
|
||||||
setModalProps({ confirmLoading: false });
|
|
||||||
}
|
|
||||||
}
|
|
||||||
</script>
|
|
||||||
@@ -1,232 +0,0 @@
|
|||||||
<!--
|
|
||||||
* Copyright (c) 2013-Now https://jeesite.com All rights reserved.
|
|
||||||
* No deletion without permission, or be held responsible to law.
|
|
||||||
* @author gaoxq
|
|
||||||
-->
|
|
||||||
<template>
|
|
||||||
<div>
|
|
||||||
<BasicTable @register="registerTable">
|
|
||||||
<template #tableTitle>
|
|
||||||
<Icon :icon="getTitle.icon" class="m-1 pr-1" />
|
|
||||||
<span> {{ getTitle.value }} </span>
|
|
||||||
</template>
|
|
||||||
<template #toolbar>
|
|
||||||
<a-button type="default" :loading="loading" @click="handleExport()">
|
|
||||||
<Icon icon="i-ant-design:download-outlined" /> {{ t('导出') }}
|
|
||||||
</a-button>
|
|
||||||
<a-button type="default" @click="handleImport()">
|
|
||||||
<Icon icon="i-ant-design:import-outlined" /> {{ t('导入') }}
|
|
||||||
</a-button>
|
|
||||||
<a-button type="primary" @click="handleForm({})" v-auth="'biz:myDataTable:edit'">
|
|
||||||
<Icon icon="i-fluent:add-12-filled" /> {{ t('新增') }}
|
|
||||||
</a-button>
|
|
||||||
</template>
|
|
||||||
<template #firstColumn="{ record, text, value }">
|
|
||||||
<a @click="handleForm({ tableId: record.tableId })" :title="value">
|
|
||||||
{{ text }}
|
|
||||||
</a>
|
|
||||||
</template>
|
|
||||||
</BasicTable>
|
|
||||||
<InputForm @register="registerDrawer" @success="handleSuccess" />
|
|
||||||
<FormImport @register="registerImportModal" @success="handleSuccess" />
|
|
||||||
</div>
|
|
||||||
</template>
|
|
||||||
<script lang="ts" setup name="ViewsBizMyDataTableList">
|
|
||||||
import { onMounted, ref, unref } from 'vue';
|
|
||||||
import { useI18n } from '@jeesite/core/hooks/web/useI18n';
|
|
||||||
import { useMessage } from '@jeesite/core/hooks/web/useMessage';
|
|
||||||
import { useGlobSetting } from '@jeesite/core/hooks/setting';
|
|
||||||
import { downloadByUrl } from '@jeesite/core/utils/file/download';
|
|
||||||
import { router } from '@jeesite/core/router';
|
|
||||||
import { Icon } from '@jeesite/core/components/Icon';
|
|
||||||
import { BasicTable, BasicColumn, useTable } from '@jeesite/core/components/Table';
|
|
||||||
import { MyDataTable, myDataTableList } from '@jeesite/biz/api/biz/myDataTable';
|
|
||||||
import { myDataTableDelete, myDataTableListData } from '@jeesite/biz/api/biz/myDataTable';
|
|
||||||
import { useDrawer } from '@jeesite/core/components/Drawer';
|
|
||||||
import { useModal } from '@jeesite/core/components/Modal';
|
|
||||||
import { FormProps } from '@jeesite/core/components/Form';
|
|
||||||
import InputForm from './form.vue';
|
|
||||||
import FormImport from './formImport.vue';
|
|
||||||
|
|
||||||
const { t } = useI18n('biz.myDataTable');
|
|
||||||
const { showMessage } = useMessage();
|
|
||||||
const { meta } = unref(router.currentRoute);
|
|
||||||
const record = ref<MyDataTable>({} as MyDataTable);
|
|
||||||
|
|
||||||
const getTitle = {
|
|
||||||
icon: meta.icon || 'i-ant-design:book-outlined',
|
|
||||||
value: meta.title || t('数据表信息管理'),
|
|
||||||
};
|
|
||||||
const loading = ref(false);
|
|
||||||
|
|
||||||
const searchForm: FormProps<MyDataTable> = {
|
|
||||||
baseColProps: { md: 8, lg: 6 },
|
|
||||||
labelWidth: 90,
|
|
||||||
schemas: [
|
|
||||||
{
|
|
||||||
label: t('创建时间'),
|
|
||||||
field: 'createTime',
|
|
||||||
component: 'DatePicker',
|
|
||||||
componentProps: {
|
|
||||||
format: 'YYYY-MM-DD HH:mm',
|
|
||||||
showTime: { format: 'HH:mm' },
|
|
||||||
},
|
|
||||||
},
|
|
||||||
{
|
|
||||||
label: t('数据源ID'),
|
|
||||||
field: 'sourceId',
|
|
||||||
component: 'Input',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
label: t('数据表名'),
|
|
||||||
field: 'tableName',
|
|
||||||
component: 'Input',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
label: t('表注释'),
|
|
||||||
field: 'tableComment',
|
|
||||||
component: 'Input',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
label: t('数据行数'),
|
|
||||||
field: 'tableRows',
|
|
||||||
component: 'Input',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
label: t('update_time'),
|
|
||||||
field: 'updateTime',
|
|
||||||
component: 'DatePicker',
|
|
||||||
componentProps: {
|
|
||||||
format: 'YYYY-MM-DD HH:mm',
|
|
||||||
showTime: { format: 'HH:mm' },
|
|
||||||
},
|
|
||||||
},
|
|
||||||
],
|
|
||||||
};
|
|
||||||
|
|
||||||
const tableColumns: BasicColumn<MyDataTable>[] = [
|
|
||||||
{
|
|
||||||
title: t('创建时间'),
|
|
||||||
dataIndex: 'createTime',
|
|
||||||
key: 'a.create_time',
|
|
||||||
sorter: true,
|
|
||||||
width: 230,
|
|
||||||
align: 'left',
|
|
||||||
slot: 'firstColumn',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
title: t('数据源ID'),
|
|
||||||
dataIndex: 'sourceId',
|
|
||||||
key: 'a.source_id',
|
|
||||||
sorter: true,
|
|
||||||
width: 130,
|
|
||||||
align: 'left',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
title: t('数据表名'),
|
|
||||||
dataIndex: 'tableName',
|
|
||||||
key: 'a.table_name',
|
|
||||||
sorter: true,
|
|
||||||
width: 130,
|
|
||||||
align: 'left',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
title: t('表注释'),
|
|
||||||
dataIndex: 'tableComment',
|
|
||||||
key: 'a.table_comment',
|
|
||||||
sorter: true,
|
|
||||||
width: 130,
|
|
||||||
align: 'left',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
title: t('数据行数'),
|
|
||||||
dataIndex: 'tableRows',
|
|
||||||
key: 'a.table_rows',
|
|
||||||
sorter: true,
|
|
||||||
width: 130,
|
|
||||||
align: 'center',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
title: t('update_time'),
|
|
||||||
dataIndex: 'updateTime',
|
|
||||||
key: 'a.update_time',
|
|
||||||
sorter: true,
|
|
||||||
width: 130,
|
|
||||||
align: 'center',
|
|
||||||
},
|
|
||||||
];
|
|
||||||
|
|
||||||
const actionColumn: BasicColumn<MyDataTable> = {
|
|
||||||
width: 160,
|
|
||||||
actions: (record: MyDataTable) => [
|
|
||||||
{
|
|
||||||
icon: 'i-clarity:note-edit-line',
|
|
||||||
title: t('编辑数据表信息'),
|
|
||||||
onClick: handleForm.bind(this, { tableId: record.tableId }),
|
|
||||||
auth: 'biz:myDataTable:edit',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
icon: 'i-ant-design:delete-outlined',
|
|
||||||
color: 'error',
|
|
||||||
title: t('删除数据表信息'),
|
|
||||||
popConfirm: {
|
|
||||||
title: t('是否确认删除数据表信息'),
|
|
||||||
confirm: handleDelete.bind(this, record),
|
|
||||||
},
|
|
||||||
auth: 'biz:myDataTable:edit',
|
|
||||||
},
|
|
||||||
],
|
|
||||||
};
|
|
||||||
|
|
||||||
const [registerTable, { reload, getForm }] = useTable<MyDataTable>({
|
|
||||||
api: myDataTableListData,
|
|
||||||
beforeFetch: (params) => {
|
|
||||||
return params;
|
|
||||||
},
|
|
||||||
columns: tableColumns,
|
|
||||||
actionColumn: actionColumn,
|
|
||||||
formConfig: searchForm,
|
|
||||||
showTableSetting: true,
|
|
||||||
useSearchForm: true,
|
|
||||||
canResize: true,
|
|
||||||
});
|
|
||||||
|
|
||||||
onMounted(async () => {
|
|
||||||
const res = await myDataTableList();
|
|
||||||
record.value = (res.myDataTable || {}) as MyDataTable;
|
|
||||||
await getForm().setFieldsValue(record.value);
|
|
||||||
});
|
|
||||||
|
|
||||||
const [registerDrawer, { openDrawer }] = useDrawer();
|
|
||||||
|
|
||||||
function handleForm(record: Recordable) {
|
|
||||||
openDrawer(true, record);
|
|
||||||
}
|
|
||||||
|
|
||||||
async function handleExport() {
|
|
||||||
loading.value = true;
|
|
||||||
const { ctxAdminPath } = useGlobSetting();
|
|
||||||
await downloadByUrl({
|
|
||||||
url: ctxAdminPath + '/biz/myDataTable/exportData',
|
|
||||||
params: getForm().getFieldsValue(),
|
|
||||||
});
|
|
||||||
loading.value = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
const [registerImportModal, { openModal: importModal }] = useModal();
|
|
||||||
|
|
||||||
function handleImport() {
|
|
||||||
importModal(true, {});
|
|
||||||
}
|
|
||||||
|
|
||||||
async function handleDelete(record: Recordable) {
|
|
||||||
const params = { tableId: record.tableId };
|
|
||||||
const res = await myDataTableDelete(params);
|
|
||||||
showMessage(res.message);
|
|
||||||
await handleSuccess(record);
|
|
||||||
}
|
|
||||||
|
|
||||||
async function handleSuccess(record: Recordable) {
|
|
||||||
await reload({ record });
|
|
||||||
}
|
|
||||||
</script>
|
|
||||||
@@ -1,125 +0,0 @@
|
|||||||
import { useI18n } from '@jeesite/core/hooks/web/useI18n';
|
|
||||||
import { BasicColumn, BasicTableProps, FormProps } from '@jeesite/core/components/Table';
|
|
||||||
import { myDataTableListData } from '@jeesite/biz/api/biz/myDataTable';
|
|
||||||
|
|
||||||
const { t } = useI18n('biz.myDataTable');
|
|
||||||
|
|
||||||
const modalProps = {
|
|
||||||
title: t('数据表信息选择'),
|
|
||||||
};
|
|
||||||
|
|
||||||
const searchForm: FormProps<MyDataTable> = {
|
|
||||||
baseColProps: { md: 8, lg: 6 },
|
|
||||||
labelWidth: 90,
|
|
||||||
schemas: [
|
|
||||||
{
|
|
||||||
label: t('创建时间'),
|
|
||||||
field: 'createTime',
|
|
||||||
component: 'DatePicker',
|
|
||||||
componentProps: {
|
|
||||||
format: 'YYYY-MM-DD HH:mm',
|
|
||||||
showTime: { format: 'HH:mm' },
|
|
||||||
},
|
|
||||||
},
|
|
||||||
{
|
|
||||||
label: t('数据源ID'),
|
|
||||||
field: 'sourceId',
|
|
||||||
component: 'Input',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
label: t('数据表名'),
|
|
||||||
field: 'tableName',
|
|
||||||
component: 'Input',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
label: t('表注释'),
|
|
||||||
field: 'tableComment',
|
|
||||||
component: 'Input',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
label: t('数据行数'),
|
|
||||||
field: 'tableRows',
|
|
||||||
component: 'Input',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
label: t('update_time'),
|
|
||||||
field: 'updateTime',
|
|
||||||
component: 'DatePicker',
|
|
||||||
componentProps: {
|
|
||||||
format: 'YYYY-MM-DD HH:mm',
|
|
||||||
showTime: { format: 'HH:mm' },
|
|
||||||
},
|
|
||||||
},
|
|
||||||
],
|
|
||||||
};
|
|
||||||
|
|
||||||
const tableColumns: BasicColumn<MyDataTable>[] = [
|
|
||||||
{
|
|
||||||
title: t('创建时间'),
|
|
||||||
dataIndex: 'createTime',
|
|
||||||
key: 'a.create_time',
|
|
||||||
sorter: true,
|
|
||||||
width: 230,
|
|
||||||
align: 'left',
|
|
||||||
slot: 'firstColumn',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
title: t('数据源ID'),
|
|
||||||
dataIndex: 'sourceId',
|
|
||||||
key: 'a.source_id',
|
|
||||||
sorter: true,
|
|
||||||
width: 130,
|
|
||||||
align: 'left',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
title: t('数据表名'),
|
|
||||||
dataIndex: 'tableName',
|
|
||||||
key: 'a.table_name',
|
|
||||||
sorter: true,
|
|
||||||
width: 130,
|
|
||||||
align: 'left',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
title: t('表注释'),
|
|
||||||
dataIndex: 'tableComment',
|
|
||||||
key: 'a.table_comment',
|
|
||||||
sorter: true,
|
|
||||||
width: 130,
|
|
||||||
align: 'left',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
title: t('数据行数'),
|
|
||||||
dataIndex: 'tableRows',
|
|
||||||
key: 'a.table_rows',
|
|
||||||
sorter: true,
|
|
||||||
width: 130,
|
|
||||||
align: 'center',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
title: t('update_time'),
|
|
||||||
dataIndex: 'updateTime',
|
|
||||||
key: 'a.update_time',
|
|
||||||
sorter: true,
|
|
||||||
width: 130,
|
|
||||||
align: 'center',
|
|
||||||
},
|
|
||||||
];
|
|
||||||
|
|
||||||
const tableProps: BasicTableProps = {
|
|
||||||
api: myDataTableListData,
|
|
||||||
beforeFetch: (params) => {
|
|
||||||
params['isAll'] = true;
|
|
||||||
return params;
|
|
||||||
},
|
|
||||||
columns: tableColumns,
|
|
||||||
formConfig: searchForm,
|
|
||||||
rowKey: 'tableId',
|
|
||||||
};
|
|
||||||
|
|
||||||
export default {
|
|
||||||
modalProps,
|
|
||||||
tableProps,
|
|
||||||
itemCode: 'tableId',
|
|
||||||
itemName: 'tableId',
|
|
||||||
isShowCode: false,
|
|
||||||
};
|
|
||||||
Reference in New Issue
Block a user