Merge remote-tracking branch 'origin/main'

This commit is contained in:
limengnan 2025-05-21 08:27:48 +08:00
commit 1aa11909fa
15 changed files with 685 additions and 26 deletions

3
core/core-backend/.env Normal file
View File

@ -0,0 +1,3 @@
{
"JAVA_HOME": "C:\\Users\\13910\\.jdks\\corretto-21.0.5"
}

View File

@ -93,6 +93,11 @@
<groupId>org.apache.commons</groupId> <groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId> <artifactId>commons-lang3</artifactId>
</dependency> </dependency>
<dependency>
<groupId>cn.hutool</groupId>
<artifactId>hutool-all</artifactId>
<version>5.8.38</version>
</dependency>
<dependency> <dependency>
<groupId>io.gisbi</groupId> <groupId>io.gisbi</groupId>
<artifactId>api-permissions</artifactId> <artifactId>api-permissions</artifactId>
@ -184,6 +189,15 @@
</execution> </execution>
</executions> </executions>
</plugin> </plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.11.0</version>
<configuration>
<source>21</source>
<target>21</target>
</configuration>
</plugin>
</plugins> </plugins>
</build> </build>
</profile> </profile>

View File

@ -201,7 +201,7 @@ public class RoleController {
boolean isOk = true; boolean isOk = true;
String[] temp = userids.split(","); String[] temp = userids.split(",");
for (String userid : temp) { for (String userid : temp) {
isOk = isOk && userService.addUserRoles(roleid, userid); isOk = isOk && userService.addUserRole(roleid, userid);
} }
if (isOk) { if (isOk) {
return ResponseResult.success(); return ResponseResult.success();

View File

@ -86,5 +86,5 @@ public interface IUserService extends IService<User> {
* userids 用户id组 * userids 用户id组
* 返回值说明: 是否新增成功 * 返回值说明: 是否新增成功
***********************************/ ***********************************/
boolean addUserRoles(String roleid, String userid); boolean addUserRole(String roleid, String userid);
} }

View File

@ -313,7 +313,7 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements IU
* 返回值说明: 是否新增成功 * 返回值说明: 是否新增成功
***********************************/ ***********************************/
@Override @Override
public boolean addUserRoles(String roleid, String userid) { public boolean addUserRole(String roleid, String userid) {
boolean isOk = true; boolean isOk = true;
if (StringUtils.isEmpty(roleid) || StringUtils.isEmpty(userid)) { if (StringUtils.isEmpty(roleid) || StringUtils.isEmpty(userid)) {
return false; return false;

View File

@ -1,5 +1,7 @@
package io.gisbi.dataset.manage; package io.gisbi.dataset.manage;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import io.gisbi.api.chart.dto.DeSortField; import io.gisbi.api.chart.dto.DeSortField;
import io.gisbi.api.dataset.dto.*; import io.gisbi.api.dataset.dto.*;
import io.gisbi.api.dataset.union.DatasetGroupInfoDTO; import io.gisbi.api.dataset.union.DatasetGroupInfoDTO;
@ -7,6 +9,10 @@ import io.gisbi.api.dataset.union.DatasetTableInfoDTO;
import io.gisbi.chart.utils.ChartDataBuild; import io.gisbi.chart.utils.ChartDataBuild;
import io.gisbi.commons.utils.SqlparserUtils; import io.gisbi.commons.utils.SqlparserUtils;
import io.gisbi.dataset.constant.DatasetTableType; import io.gisbi.dataset.constant.DatasetTableType;
import io.gisbi.dataset.dao.auto.entity.CoreDatasetTable;
import io.gisbi.dataset.dao.auto.entity.CoreDatasetTableField;
import io.gisbi.dataset.dao.auto.mapper.CoreDatasetTableFieldMapper;
import io.gisbi.dataset.dao.auto.mapper.CoreDatasetTableMapper;
import io.gisbi.dataset.utils.DatasetUtils; import io.gisbi.dataset.utils.DatasetUtils;
import io.gisbi.dataset.utils.FieldUtils; import io.gisbi.dataset.utils.FieldUtils;
import io.gisbi.dataset.utils.TableUtils; import io.gisbi.dataset.utils.TableUtils;
@ -71,7 +77,10 @@ public class DatasetDataManage {
private DatasetTableSqlLogManage datasetTableSqlLogManage; private DatasetTableSqlLogManage datasetTableSqlLogManage;
@Autowired(required = false) @Autowired(required = false)
private PluginManageApi pluginManage; private PluginManageApi pluginManage;
@Resource
private CoreDatasetTableFieldMapper coreDatasetTableFieldMapper;
@Resource
private CoreDatasetTableMapper coreDatasetTableMapper;
@Resource @Resource
private DataSourceManage dataSourceManage; private DataSourceManage dataSourceManage;
@ -1139,4 +1148,333 @@ public class DatasetDataManage {
return nodes; return nodes;
} }
//-----------------------下面代码为扩展代码实现了数据表的增删改查功能--zhengsl at 2025-05-20----------------------------------------------------------------------------------------//
public List<CoreDatasetTable> getTablesByAppId(Long id) throws Exception {
QueryWrapper<CoreDatasetTable> wrapper = new QueryWrapper<>();
wrapper.eq("app_id", id);
wrapper.eq("type", "db");
List<CoreDatasetTable> tables = coreDatasetTableMapper.selectList(wrapper);
return tables;
}
public List<CoreDatasetTableField> getFieldsByTableId(Long id) throws Exception {
QueryWrapper<CoreDatasetTableField> wrapper = new QueryWrapper<>();
wrapper.eq("dataset_table_id", id);
wrapper.eq("checked", true);
wrapper.isNull("chart_id");
List<CoreDatasetTableField> fields = coreDatasetTableFieldMapper.selectList(wrapper);
return fields;
}
public boolean addTableData(Long datasourceId, String tableData) throws Exception {
// 根据数据源 id 查询数据源信息调用通用数据源执行器
CoreDatasource coreDatasource = coreDatasourceMapper.selectById(datasourceId);
if (coreDatasource == null) {
DEException.throwException("数据源不存在");
}
// 解析 tableData JSON 字符串 "{ \"tableName\": \"user\", \"data\": [ { \"fieldName\": \"id\", \"fieldType\": \"varchar\", \"IsPrimaryKey\": true, \"fieldValue\": \"0001\" }, { \"fieldName\": \"name\", \"fieldType\": \"varchar\", \"fieldValue\": \"张三\" } ] }";
Map<String, Object> dataMap = JsonUtil.parseObject(tableData, Map.class);
String tableName = (String) dataMap.get("tableName");
List<Map<String, Object>> fieldList = (List<Map<String, Object>>) dataMap.get("data");
if (fieldList == null || fieldList.isEmpty()) {
DEException.throwException("没有可插入的数据字段");
}
// 构建插入语句
StringBuilder columns = new StringBuilder();
StringBuilder values = new StringBuilder();
for (int i = 0; i < fieldList.size(); i++) {
Map<String, Object> field = fieldList.get(i);
String fieldName = (String) field.get("fieldName");
Object fieldValue = field.get("fieldValue");
if (i > 0) {
columns.append(", ");
values.append(", ");
}
columns.append(fieldName);
if (fieldValue instanceof String) {
values.append("'").append(fieldValue).append("'");
} else {
values.append(fieldValue);
}
}
String sql = String.format("INSERT INTO %s (%s) VALUES (%s)", tableName, columns.toString(), values.toString());
// 调用执行器向数据表中插入 tableData 数据
DatasourceSchemaDTO datasourceSchemaDTO = new DatasourceSchemaDTO();
BeanUtils.copyBean(datasourceSchemaDTO, coreDatasource);
Provider provider = ProviderFactory.getProvider(coreDatasource.getType());
DatasourceRequest datasourceRequest = new DatasourceRequest();
datasourceRequest.setQuery(sql);
datasourceRequest.setDsList(Map.of(datasourceSchemaDTO.getId(), datasourceSchemaDTO));
logger.debug("执行插入数据的SQL: {}", sql);
// 执行插入操作
Map<String, Object> result = provider.fetchResultField(datasourceRequest);
return result != null && !result.isEmpty();
}
public boolean updateTableData(Long datasourceId, String tableData) throws Exception {
// 获取数据源信息
CoreDatasource coreDatasource = coreDatasourceMapper.selectById(datasourceId);
if (coreDatasource == null) {
DEException.throwException("数据源不存在");
}
//String tableDataJson = "{ \"tableName\": \"user\", \"primaryKeyField\": \"id\", \"primaryKeyValue\": \"0001\", \"data\": [ { \"fieldName\": \"name\", \"fieldType\": \"varchar\", \"fieldValue\": \"李四\" } ] }";
// 解析 JSON 数据
Map<String, Object> dataMap = JsonUtil.parseObject(tableData, Map.class);
String tableName = (String) dataMap.get("tableName");
String primaryKeyField = (String) dataMap.get("primaryKeyField");
Object primaryKeyValue = dataMap.get("primaryKeyValue");
List<Map<String, Object>> fieldList = (List<Map<String, Object>>) dataMap.get("data");
if (fieldList == null || fieldList.isEmpty()) {
DEException.throwException("没有可更新的数据字段");
}
if (StringUtils.isBlank(tableName)) {
DEException.throwException("表名不能为空");
}
if (StringUtils.isBlank(primaryKeyField) || primaryKeyValue == null) {
DEException.throwException("主键字段或值不能为空");
}
// 构建 UPDATE 语句
StringBuilder setClause = new StringBuilder();
for (int i = 0; i < fieldList.size(); i++) {
Map<String, Object> field = fieldList.get(i);
String fieldName = (String) field.get("fieldName");
Object fieldValue = field.get("fieldValue");
if (i > 0) {
setClause.append(", ");
}
if (fieldValue instanceof String) {
setClause.append(String.format("%s = '%s'", fieldName, fieldValue));
} else {
setClause.append(String.format("%s = %s", fieldName, fieldValue));
}
}
String whereClause = String.format("%s = ", primaryKeyField);
if (primaryKeyValue instanceof String) {
whereClause += String.format("'%s'", primaryKeyValue);
} else {
whereClause += primaryKeyValue;
}
String sql = String.format("UPDATE %s SET %s WHERE %s", tableName, setClause.toString(), whereClause);
// 调用执行器执行 SQL
DatasourceSchemaDTO datasourceSchemaDTO = new DatasourceSchemaDTO();
BeanUtils.copyBean(datasourceSchemaDTO, coreDatasource);
Provider provider = ProviderFactory.getProvider(coreDatasource.getType());
DatasourceRequest datasourceRequest = new DatasourceRequest();
datasourceRequest.setQuery(sql);
datasourceRequest.setDsList(Map.of(datasourceSchemaDTO.getId(), datasourceSchemaDTO));
logger.debug("执行更新数据的SQL: {}", sql);
// 执行更新操作
Map<String, Object> result = provider.fetchResultField(datasourceRequest);
return result != null && !result.isEmpty();
}
public boolean deleteTableData(Long datasourceId, String whereJson) throws Exception {
// 获取数据源信息
CoreDatasource coreDatasource = coreDatasourceMapper.selectById(datasourceId);
if (coreDatasource == null) {
DEException.throwException("数据源不存在");
}
// 解析 JSON 数据
//String tableDataJson = "{ \"tableName\": \"user\", \"primaryKeyField\": \"id\", \"primaryKeyValue\": \"0001\" }";
Map<String, Object> dataMap = JsonUtil.parseObject(whereJson, Map.class);
String tableName = (String) dataMap.get("tableName");
String primaryKeyField = (String) dataMap.get("primaryKeyField");
Object primaryKeyValue = dataMap.get("primaryKeyValue");
if (StringUtils.isBlank(tableName)) {
DEException.throwException("表名不能为空");
}
if (StringUtils.isBlank(primaryKeyField) || primaryKeyValue == null) {
DEException.throwException("主键字段或值不能为空");
}
// 构建 DELETE 语句
String whereClause = String.format("%s = ", primaryKeyField);
if (primaryKeyValue instanceof String) {
whereClause += String.format("'%s'", primaryKeyValue);
} else {
whereClause += primaryKeyValue;
}
String sql = String.format("DELETE FROM %s WHERE %s", tableName, whereClause);
// 调用执行器执行 SQL
DatasourceSchemaDTO datasourceSchemaDTO = new DatasourceSchemaDTO();
BeanUtils.copyBean(datasourceSchemaDTO, coreDatasource);
Provider provider = ProviderFactory.getProvider(coreDatasource.getType());
DatasourceRequest datasourceRequest = new DatasourceRequest();
datasourceRequest.setQuery(sql);
datasourceRequest.setDsList(Map.of(datasourceSchemaDTO.getId(), datasourceSchemaDTO));
logger.debug("执行删除数据的SQL: {}", sql);
// 执行删除操作
Map<String, Object> result = provider.fetchResultField(datasourceRequest);
return result != null && !result.isEmpty();
}
public Page<Map<String, Object>> queryTableDataPaged(Long datasourceId, String queryJson) throws Exception {
// 获取数据源信息
CoreDatasource coreDatasource = coreDatasourceMapper.selectById(datasourceId);
if (coreDatasource == null) {
DEException.throwException("数据源不存在");
}
//String queryJson = "{ \"tableName\": \"user\", \"conditions\": [ { \"field\": \"name\", \"operator\": \"like\", \"value\": \"\" }, { \"field\": \"id\", \"operator\": \"in\", \"value\": [1, 2, 3] } ], \"pageNum\": 1, \"pageSize\": 10 }";
// 解析 JSON 查询参数
Map<String, Object> dataMap = JsonUtil.parseObject(queryJson, Map.class);
String tableName = (String) dataMap.get("tableName");
List<Map<String, Object>> conditionList = (List<Map<String, Object>>) dataMap.get("conditions");
Integer pageNum = (Integer) dataMap.getOrDefault("pageNum", 1);
Integer pageSize = (Integer) dataMap.getOrDefault("pageSize", 10);
if (StringUtils.isBlank(tableName)) {
DEException.throwException("表名不能为空");
}
// 构建 WHERE 条件子句
StringBuilder whereClause = new StringBuilder();
if (conditionList != null && !conditionList.isEmpty()) {
whereClause.append(" WHERE ");
for (int i = 0; i < conditionList.size(); i++) {
Map<String, Object> condition = conditionList.get(i);
String field = (String) condition.get("field");
String operator = ((String) condition.get("operator")).toLowerCase();
Object value = condition.get("value");
if (i > 0) {
whereClause.append(" AND ");
}
// 处理不同类型的条件
switch (operator) {
case "like":
whereClause.append(String.format("%s LIKE '%%%s%%'", field, value));
break;
case "=":
appendValue(whereClause, field, value, "=");
break;
case "<":
appendValue(whereClause, field, value, "<");
break;
case ">":
appendValue(whereClause, field, value, ">");
break;
case "<=":
appendValue(whereClause, field, value, "<=");
break;
case ">=":
appendValue(whereClause, field, value, ">=");
break;
case "!=":
case "<>":
appendValue(whereClause, field, value, "<>");
break;
case "in":
if (!(value instanceof List<?>)) {
DEException.throwException("IN 操作符要求值为列表类型");
}
List<?> values = (List<?>) value;
String inValues = values.stream()
.map(v -> v instanceof String ? "'" + v + "'" : v.toString())
.collect(Collectors.joining(", "));
whereClause.append(String.format("%s IN (%s)", field, inValues));
break;
default:
DEException.throwException("不支持的操作符: " + operator);
}
}
}
// 构建基础查询语句
String baseSql = String.format("SELECT * FROM %s%s", tableName, whereClause);
// 根据数据库类型生成分页语句
String dbType = coreDatasource.getType().toLowerCase();
String pagedSql = buildPagedSQL(baseSql, dbType, pageNum, pageSize);
// 构建 COUNT 查询语句用于分页计算
String countSql = String.format("SELECT COUNT(*) FROM %s%s", tableName, whereClause);
// 执行查询
DatasourceSchemaDTO schemaDTO = new DatasourceSchemaDTO();
BeanUtils.copyBean(schemaDTO, coreDatasource);
Provider provider = ProviderFactory.getProvider(coreDatasource.getType());
DatasourceRequest request = new DatasourceRequest();
request.setDsList(Map.of(schemaDTO.getId(), schemaDTO));
// 1. 查询分页数据
request.setQuery(pagedSql);
Map<String, Object> result = provider.fetchResultField(request);
List<Map<String, Object>> dataList = (List<Map<String, Object>>) result.get("data");
// 2. 查询总记录数
request.setQuery(countSql);
Map<String, Object> countResult = provider.fetchResultField(request);
long total = Long.parseLong(((List<String[]>) countResult.get("data")).get(0)[0]);
// 封装分页结果
Page<Map<String, Object>> page = new Page<>();
page.setCurrent(pageNum);
page.setSize(pageSize);
page.setTotal(total);
page.setRecords(dataList);
return page;
}
private void appendValue(StringBuilder sb, String field, Object value, String op) {
if (value instanceof String) {
sb.append(String.format("%s %s '%s'", field, op, value));
} else {
sb.append(String.format("%s %s %s", field, op, value));
}
}
private String buildPagedSQL(String baseSql, String dbType, int pageNum, int pageSize) {
int offset = (pageNum - 1) * pageSize;
switch (dbType) {
case "mysql":
case "mariadb":
return String.format("%s LIMIT %d OFFSET %d", baseSql, pageSize, offset);
case "postgresql":
return String.format("%s LIMIT %d OFFSET %d", baseSql, pageSize, offset);
case "oracle":
int start = offset + 1;
int end = offset + pageSize;
return String.format("SELECT * FROM (SELECT ROWNUM rn, t.* FROM (%s) t WHERE ROWNUM <= %d) WHERE rn >= %d", baseSql, end, start);
case "sqlserver":
return String.format("%s OFFSET %d ROWS FETCH NEXT %d ROWS ONLY", baseSql, offset, pageSize);
default:
// 默认使用 MySQL 方式
return String.format("%s LIMIT %d OFFSET %d", baseSql, pageSize, offset);
}
}
} }

View File

@ -1,5 +1,6 @@
package io.gisbi.dataset.server; package io.gisbi.dataset.server;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import io.gisbi.api.dataset.DatasetDataApi; import io.gisbi.api.dataset.DatasetDataApi;
import io.gisbi.api.dataset.dto.BaseTreeNodeDTO; import io.gisbi.api.dataset.dto.BaseTreeNodeDTO;
import io.gisbi.api.dataset.dto.EnumValueRequest; import io.gisbi.api.dataset.dto.EnumValueRequest;
@ -7,11 +8,15 @@ import io.gisbi.api.dataset.dto.MultFieldValuesRequest;
import io.gisbi.api.dataset.dto.PreviewSqlDTO; import io.gisbi.api.dataset.dto.PreviewSqlDTO;
import io.gisbi.api.dataset.union.DatasetGroupInfoDTO; import io.gisbi.api.dataset.union.DatasetGroupInfoDTO;
import io.gisbi.api.dataset.dto.EnumObj; import io.gisbi.api.dataset.dto.EnumObj;
import io.gisbi.dataset.dao.auto.entity.CoreDatasetTable;
import io.gisbi.dataset.dao.auto.entity.CoreDatasetTableField;
import io.gisbi.dataset.manage.DatasetDataManage; import io.gisbi.dataset.manage.DatasetDataManage;
import io.gisbi.extensions.datasource.dto.DatasetTableDTO; import io.gisbi.extensions.datasource.dto.DatasetTableDTO;
import io.gisbi.extensions.datasource.dto.DatasetTableFieldDTO; import io.gisbi.extensions.datasource.dto.DatasetTableFieldDTO;
import io.gisbi.utils.LogUtil; import io.gisbi.utils.LogUtil;
import jakarta.annotation.Resource; import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
@ -32,6 +37,7 @@ public class DatasetDataServer implements DatasetDataApi {
return datasetDataManage.previewDataWithLimit(datasetGroupInfoDTO, 0, 100, false); return datasetDataManage.previewDataWithLimit(datasetGroupInfoDTO, 0, 100, false);
} }
@Override @Override
public List<DatasetTableFieldDTO> tableField(DatasetTableDTO datasetTableDTO) throws Exception { public List<DatasetTableFieldDTO> tableField(DatasetTableDTO datasetTableDTO) throws Exception {
return datasetDataManage.getTableFields(datasetTableDTO); return datasetDataManage.getTableFields(datasetTableDTO);
@ -100,4 +106,47 @@ public class DatasetDataServer implements DatasetDataApi {
return null; return null;
} }
} }
@GetMapping("getTablesByAppId")
public List<CoreDatasetTable> getTablesByAppId(Long id) throws Exception {
List<CoreDatasetTable> result = datasetDataManage.getTablesByAppId(id);
return result;
}
@GetMapping("getFieldsByTableId")
public List<CoreDatasetTableField> getFieldsByTableId(Long id) throws Exception {
List<CoreDatasetTableField> result = datasetDataManage.getFieldsByTableId(id);
return result;
}
@PostMapping("addTableData")
public boolean addTableData(Long datasourceId, String tableData) throws Exception {
boolean result = datasetDataManage.addTableData(
datasourceId,
tableData
);
return result;
}
@PostMapping("updateTableData")
public boolean updateTableData(Long datasourceId, String tableData) throws Exception {
boolean result = datasetDataManage.updateTableData(
datasourceId,
tableData
);
return result;
}
@PostMapping("deleteTableData")
public boolean deleteTableData(Long datasourceId, String whereJson) throws Exception {
boolean result = datasetDataManage.deleteTableData(
datasourceId,
whereJson
);
return result;
}
@GetMapping("queryTableDataPaged")
public Page<Map<String, Object>> queryTableDataPaged(Long datasourceId, String queryJson) throws Exception {
Page<Map<String, Object>> result = datasetDataManage.queryTableDataPaged(
datasourceId,
queryJson
);
return result;
}
} }

View File

@ -4,5 +4,6 @@
// Generated by unplugin-auto-import // Generated by unplugin-auto-import
export {} export {}
declare global { declare global {
const ElMessage: typeof import('element-plus-secondary/es')['ElMessage']
const ElMessageBox: typeof import('element-plus-secondary/es')['ElMessageBox']
} }

Binary file not shown.

After

Width:  |  Height:  |  Size: 122 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 130 B

View File

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<svg version="1.1" xmlns:xlink="http://www.w3.org/1999/xlink" width="14px" height="14px" xmlns="http://www.w3.org/2000/svg">
<g transform="matrix(1 0 0 1 -1745 -108 )">
<path d="M 6.125 14 L 6.12499612962483 7.875 L 0 7.875 L 0 6.125 L 6.125 6.1249999982702 L 6.125 0 L 7.875 0 L 7.87500387037517 6.125 L 14 6.125 L 14 7.875 L 7.875 7.8750000017298 L 7.875 14 L 6.125 14 Z " fill-rule="nonzero" fill="#f8f9fc" stroke="none" transform="matrix(1 0 0 1 1745 108 )" />
</g>
</svg>

View File

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<svg version="1.1" xmlns:xlink="http://www.w3.org/1999/xlink" width="16px" height="16px" xmlns="http://www.w3.org/2000/svg">
<g transform="matrix(1 0 0 1 -1295 -14 )">
<path d="M 8.12485581871556 0 C 6.37694406474134 0 4.95831567940832 1.29486602735432 4.8979485140751 2.9205080029394 L 0.823164854075912 2.9205080029394 C 0.370428541086994 2.9205080029394 0 3.26410005353614 0 3.68973470098136 C 0 4.11281264185548 0.367692500394924 4.45897768377856 0.823182281086702 4.45897768377856 L 1.73142580177864 4.45897768377856 L 1.73142580177864 13.0641029033683 C 1.73142580177864 14.6794854831585 2.9030960173834 16 4.35192541239394 16 L 11.7331358272113 16 C 13.1792291815295 16 14.3536354378264 14.6871881723823 14.3536354378264 13.0641029033683 L 14.3536354378264 4.46410738167599 L 15.1768177189133 4.46410738167599 C 15.629571458913 4.46410738167599 16 4.12049904632403 16 3.69486439887879 C 16 3.27178645800467 15.6323074996051 2.92563770083683 15.1768177189133 2.92563770083683 L 11.3462561879503 2.92563770083683 C 11.2941145717039 1.29488231210955 9.87275014567899 1.62847552331868E-05 8.12485581871556 1.62847552331868E-05 Z M 9.80689347195062 2.9205080029394 L 6.44006469777742 2.9205080029394 C 6.50043186311086 2.08718450831235 7.22759131481348 1.44103799029836 8.12759185940763 1.44103799029836 C 9.02759240400178 1.44103799029836 9.7547518557044 2.08974121488345 9.80689347195062 2.9205080029394 Z M 4.34917194469108 14.5692376902517 L 4.34917194469108 14.561535001028 C 3.8360510393577 14.561535001028 3.27078851777833 13.9461503856434 3.27078851777833 13.0641029033683 L 3.27078851777833 4.46410738167599 L 12.808783213432 4.46410738167599 L 12.808783213432 13.0717893078368 C 12.808783213432 13.9512800835408 12.2435206918524 14.5692376902517 11.730399786519 14.5692376902517 L 4.34917194469108 14.5692376902517 Z M 4.76898863432143 11.9205222521002 C 4.76898863432143 12.3589730019114 5.07082446098798 12.712824448303 5.45498548656769 12.712824448303 C 5.8308861090386 12.712824448303 6.14096491180294 12.3615459932378 6.14096491180294 11.9205222521002 L 6.14096491180294 7.40000447830769 C 6.14096491180294 6.95898073717015 5.83363957674146 6.60768599734966 5.45498548656769 6.60768599734966 C 5.07905001007498 6.60768599734966 4.76898863432143 6.95898073717015 4.76898863432143 7.40000447830769 L 4.76898863432143 11.9205222521002 Z M 7.25226796207448 11.9205222521002 C 7.25226796207448 12.3589730019114 7.56234676483882 12.712824448303 7.93826481432052 12.712824448303 C 8.31418286380244 12.712824448303 8.62424423955599 12.3615459932378 8.62424423955599 11.9205222521002 L 8.62424423955599 7.40000447830769 C 8.62424423955599 6.95898073717015 8.31691890449451 6.60768599734966 7.93826481432075 6.60768599734966 C 7.56234676483882 6.60768599734966 7.25226796207448 6.95898073717015 7.25226796207448 7.40000447830769 L 7.25226796207448 11.9205222521002 Z M 9.86452459659199 11.9205222521002 C 9.86452459659199 12.3589730019114 10.1636069555557 12.712824448303 10.5505040218272 12.712824448303 C 10.9264220713092 12.712824448303 11.2365008740735 12.3615459932378 11.2365008740735 11.9205222521002 L 11.2365008740735 7.40000447830769 C 11.2365008740735 6.95898073717015 10.929175539012 6.60768599734966 10.5505040218272 6.60768599734966 C 10.1745859723455 6.60768599734966 9.86452459659199 6.95898073717015 9.86452459659199 7.40000447830769 L 9.86452459659199 11.9205222521002 Z " fill-rule="nonzero" fill="#0089ff" stroke="none" transform="matrix(1 0 0 1 1295 14 )" />
</g>
</svg>

View File

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<svg version="1.1" xmlns:xlink="http://www.w3.org/1999/xlink" width="16px" height="16px" xmlns="http://www.w3.org/2000/svg">
<g transform="matrix(1 0 0 1 -1264 -14 )">
<path d="M 0.816326535714285 14.6007661114098 L 0.816326535714285 14.6020087727099 L 15.1836734642857 14.6020087727099 C 15.6342857142857 14.6020087727099 16 14.9139161474101 16 15.3003830641997 C 16 15.6856073196891 15.6342857142857 16.0000000169895 15.1836734642857 16 L 0.816326535714285 16 C 0.365714285714261 16 0 15.6868499639997 0 15.3003830641997 C 0 14.9151588087102 0.365714285714261 14.6007661114098 0.816326535714285 14.6007661114098 Z M 11.1046530535713 6.04878774487922 L 8.56555101785717 3.63305890058814 L 2.53126530357138 9.37414289392706 L 2.53126530357138 11.7898717382181 L 5.07036733928574 11.7898717382181 L 11.1046530535713 6.04878774487922 Z M 10.6435918392858 1.65598862876383 L 9.60391837499988 2.64390244252067 L 12.1443265357143 5.06087394811183 L 13.1826938749999 4.07171749004437 L 10.6435918392858 1.65598862876383 Z M 1.30089796428586 8.56889995149318 L 1.30089796428586 8.5676572901931 L 10.0636734642856 0.228173581240137 C 10.2168232824194 0.082096387960783 10.4247718162709 0 10.6416326517857 0 C 10.8584934873005 0 11.0664420211519 0.082096387960783 11.2195918392858 0.228173581240137 L 14.6821224464286 3.52246226574376 C 14.8352599193069 3.66812048877461 14.9212950501126 3.86569848729826 14.9212950501126 4.07171748154964 C 14.9212950501126 4.27773647580102 14.8352599193069 4.47531447432467 14.6821224464286 4.62097269735552 L 5.91804082142859 12.9604564063085 C 5.76459889954193 13.1064048621351 5.5563997583075 13.1882314288448 5.33942857142869 13.1878629824977 L 1.87689796428588 13.1878629824977 C 1.42656342552247 13.1871774553282 1.0618769771398 12.8396548290337 1.06187755357141 12.4112011820079 L 1.06187755357141 9.11815515880434 C 1.06187755357141 8.91187379073764 1.14677551785718 8.71429101779258 1.30089796428586 8.56889995149318 Z " fill-rule="nonzero" fill="#0089ff" stroke="none" transform="matrix(1 0 0 1 1264 14 )" />
</g>
</svg>

View File

@ -1,4 +1,4 @@
<script lang="tsx" setup> <script lang="ts" setup>
import Header from './header.vue' import Header from './header.vue'
import { findApplicationById } from "@/api/application/application"; import { findApplicationById } from "@/api/application/application";
import { useRoute, useRouter } from 'vue-router' import { useRoute, useRouter } from 'vue-router'

View File

@ -1,14 +1,20 @@
<script lang="tsx" setup> <script lang="ts" setup>
import { ref, onMounted } from 'vue' import { ref, onMounted,reactive} from 'vue'
import icon_permission_del_white from '@/assets/svg/permission_del_white.svg' import icon_permission_del_white from '@/assets/svg/permission_del_white.svg'
import icon_permission_edit_white from '@/assets/svg/permission_edit_white.svg' import icon_permission_edit_white from '@/assets/svg/permission_edit_white.svg'
import icon_permission_edit_blue from '@/assets/svg/permission_edit_blue.svg' import icon_permission_edit_blue from '@/assets/svg/permission_edit_blue.svg'
import icon_permission_del_blue from '@/assets/svg/permission_del_blue.svg' import icon_permission_del_blue from '@/assets/svg/permission_del_blue.svg'
import icon_add from '@/assets/svg/adds.svg' import permission_table_edit_blue from '@/assets/svg/permission_table_edit_blue.svg'
import permission_table_del_blue from '@/assets/svg/permission_table_del_blue.svg'
import icon_add from '@/assets/svg/add_white.svg'
import type { FormInstance, FormRules } from 'element-plus'
import { ElMessage, ElMessageBox } from 'element-plus'
import { Delete } from '@element-plus/icons-vue'
import { ElTable } from 'element-plus'
const props = defineProps({ const props = defineProps({
applicationId:String applicationId:String
}) })
const treeData:any = ref([]) const treeData:any = ref([])
const defaultProps = { const defaultProps = {
children: 'children', children: 'children',
@ -18,25 +24,91 @@ const hoverNodeId = ref(null);
const currentNodeId = ref(null); const currentNodeId = ref(null);
const dialogVisible = ref(false); const dialogVisible = ref(false);
const title = ref('新增企业'); const title = ref('新增企业');
onMounted(() => { const ruleForm = ref({id:'',app_id:'',orgname: '',orgcode: '',orgtype: ''});
treeData.value = [{id:'111',name:'53'},{id:'232',name:'3434'}] const ruleFormRef = ref<FormInstance>()
const rules = ref({
orgname: [
{ required: true, message: '请输入名称', trigger: 'blur' },
],
orgcode: [
{ required: true, message: '请输入编号', trigger: 'blur' },
],
}) })
const queryorgname = ref('')
const multipleTableRef = ref<InstanceType<typeof ElTable>>()
const multipleSelection = ref([])
const tableData = ref([{orgname:'23'}])
const handleMouseEnter = (node) => { const handleMouseEnter = (node) => {
hoverNodeId.value = node.key; hoverNodeId.value = node.key;
}; };
const handleMouseLeave = () => { const handleMouseLeave = () => {
hoverNodeId.value = null; hoverNodeId.value = null;
}; };
const submitForm = (formEl: FormInstance | undefined) => {
if (!formEl) return
formEl.validate((valid) => {
if (valid) {
console.log('submit!')
} else {
console.log('error submit!')
return false
}
})
}
const resetForm = (formEl: FormInstance | undefined) => {
if (!formEl) return
formEl.resetFields()
dialogVisible.value = false
}
const deltree = (data:any) => {
ElMessageBox.confirm(
'确定删除该条信息吗?',
'提示',
{
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning',
}
)
.then(() => {
ElMessage({
type: 'success',
message: '删除成功',
})
})
.catch(() => {
})
}
const handleSelectionChange = (val:any) => {
multipleSelection.value = val
}
onMounted(() => {
treeData.value = []
})
function nodeclick(data:any,node:any){ function nodeclick(data:any,node:any){
currentNodeId.value = node.key currentNodeId.value = node.key
} }
function addtree(data:any){ function addtree(data:any){
ruleForm.value = {
id:'',
app_id:props.applicationId,
orgname: '',
orgcode: '',
orgtype: '01'
}
title.value = '新增企业'
dialogVisible.value = true dialogVisible.value = true
} }
function edittree(data:any){ function edittree(data:any){
title.value = '修改企业'
ruleForm.value = JSON.parse(JSON.stringify(data))
dialogVisible.value = true
} }
function deltree(data:any){ function edittable(data:any){
}
function deltable(data:any){
} }
function handleClose() { function handleClose() {
dialogVisible.value = false; dialogVisible.value = false;
@ -47,12 +119,8 @@ function handleClose() {
<div class="organization-leftbox"> <div class="organization-leftbox">
<div class="leftbox-title">企业列表</div> <div class="leftbox-title">企业列表</div>
<div class="leftbox-btn" @click="addtree"> <div class="leftbox-btn" @click="addtree">
<el-icon style="font-size: 14px;"> <img src="@/assets/newimg/add.png" style="margin-right: 5px;" alt="">
<Icon name="icon_add" <span>新增企业</span>
><icon_add class="svg-icon"
/></Icon>
</el-icon>
<span>新增企业</span>
</div> </div>
<el-tree :data="treeData" node-key="id" :props="defaultProps" <el-tree :data="treeData" node-key="id" :props="defaultProps"
highlight-current default-expand-all :expand-on-click-node="false" highlight-current default-expand-all :expand-on-click-node="false"
@ -71,7 +139,7 @@ function handleClose() {
</el-icon> </el-icon>
</div> </div>
<div style="margin-left: 8px;"> <div style="margin-left: 8px;">
<el-icon v-if="currentNodeId === node.key" @click.stop="deltree(data)"> <el-icon v-if="currentNodeId === node.key" @click.stop="deltree(data)">
<icon_permission_del_white class="svg-icon"/> <icon_permission_del_white class="svg-icon"/>
</el-icon> </el-icon>
<el-icon v-else @click.stop="deltree(data)"> <el-icon v-else @click.stop="deltree(data)">
@ -84,14 +152,63 @@ function handleClose() {
</el-tree> </el-tree>
</div> </div>
<div class="organization-rightbox"> <div class="organization-rightbox">
<div class="querybox">
<div>
<el-input v-model="queryorgname" placeholder="请输入部门名称" style="width: 200px;margin-right: 10px;" />
<el-button type="primary" style="min-width: 50px;">搜索</el-button>
</div>
<div>
<el-button type="primary" style="min-width: 50px;">
<el-icon style="margin-right: 3px;">
<icon_add class="svg-icon" />
</el-icon>
</el-button>
<el-button :type="tableData.length>0?'primary':''" :disabled="tableData.length>0?false:true" style="min-width: 50px;">
<el-icon style="margin-right: 3px;"><Delete /></el-icon>
</el-button>
</div>
</div>
<el-table ref="multipleTableRef" :data="tableData" border style="width: 100%" @selection-change="handleSelectionChange">
<el-table-column type="selection" width="55" />
<el-table-column prop="orgcode" label="部门编号"/>
<el-table-column prop="orgname" label="部门名称"/>
<el-table-column prop="manager" label="负责人"/>
<el-table-column prop="address" label="联系信息"/>
<el-table-column prop="description" label="部门描述"/>
<el-table-column prop="isvaild" label="是否有效" width="110">
<template #default="scope">
<el-switch v-model="scope.row.isvaild" style="margin-right: 10px;"/>
<span v-if="scope.row.isvaild == '1'" style="color: #0089ff;font-size: 14px;">有效</span>
<span v-else-if="scope.row.isvaild == '0'" style="color: #bbbfc4;font-size: 14px;">无效</span>
</template>
</el-table-column>
<el-table-column prop="lastmodifier" label="最近修改者"/>
<el-table-column prop="lastmodifydate" label="最近修改日期"/>
<el-table-column fixed="right" label="操作" width="80">
<template #default="scope">
<el-icon style="font-size: 16px;margin-right: 18px;" @click="edittable(scope.row)">
<permission_table_edit_blue class="svg-icon"/>
</el-icon>
<el-icon style="font-size: 16px;" @click="deltable(scope.row)">
<permission_table_del_blue class="svg-icon"/>
</el-icon>
</template>
</el-table-column>
</el-table>
</div> </div>
<el-dialog v-model="dialogVisible" title="Tips" width="30%" :before-close="handleClose"> <el-dialog v-model="dialogVisible" :title="title" width="30%" :before-close="handleClose">
<span>This is a message</span> <el-form ref="ruleFormRef" :model="ruleForm" :rules="rules" label-width="60px" class="demo-ruleForm">
<el-form-item label="编号" prop="orgcode">
<el-input v-model="ruleForm.orgcode" />
</el-form-item>
<el-form-item label="名称" prop="orgname">
<el-input v-model="ruleForm.orgname" />
</el-form-item>
</el-form>
<template #footer> <template #footer>
<span class="dialog-footer"> <span class="dialog-footer">
<el-button @click="handleClose">取消</el-button> <el-button @click="resetForm(ruleFormRef)">取消</el-button>
<el-button type="primary" @click="dialogVisible = false">确定</el-button> <el-button type="primary" @click="submitForm(ruleFormRef)">确定</el-button>
</span> </span>
</template> </template>
</el-dialog> </el-dialog>
@ -132,6 +249,9 @@ function handleClose() {
color: #0089FF; color: #0089FF;
margin: 0 auto; margin: 0 auto;
margin-top: 15px; margin-top: 15px;
display: flex;
align-items: center;
justify-content: center;
} }
:deep(.ed-tree){ :deep(.ed-tree){
background:#212121; background:#212121;
@ -169,6 +289,122 @@ function handleClose() {
height: 100%; height: 100%;
background: rgb(33,33,33); background: rgb(33,33,33);
border-radius: 5px; border-radius: 5px;
padding: 20px;
}
.querybox{
display: flex;
justify-content: space-between;
margin-bottom: 20px;
} }
} }
</style>
<style>
.ed-form-item__label{
color: #D2D2D2;
}
.ed-input__wrapper {
background-color: #252626;
box-sizing: border-box;
border-width: 1px;
border-style: solid;
border-color: rgba(67, 67, 67, 0);
border-radius: 4px;
box-shadow: none;
border: 1px solid #434343;
}
.ed-form-item.is-error .ed-input__wrapper{
box-shadow: none;
border: 1px solid #f54a45;
}
.ed-input__wrapper.is-focus{
box-shadow: none;
border: 1px solid #0089ff;
}
.ed-input__wrapper:hover{
box-shadow: none;
border: 1px solid #0089ff;
}
.ed-input__inner{
color: #fff;
}
.ed-button {
color: #ffffff;
background-color: rgb(54,55,56);
border: 1px solid #363636;
}
.ed-button:focus, .ed-button:hover{
color: #ffffff;
background-color: rgb(54,55,56);
border: 1px solid #363636;
}
.ed-button--primary{
background-color: #0089ff;
border-color:#0089ff ;
}
.ed-button--primary:focus, .ed-button--primary:hover{
background-color: #0089ff;
border-color:#0089ff ;
}
.ed-button.is-disabled{
color: #949494;
background-color: rgb(54,55,56);
border: 1px solid rgb(54,55,56);
}
.ed-button.is-disabled, .ed-button.is-disabled:focus, .ed-button.is-disabled:hover{
color: #949494;
background-color: rgb(54,55,56);
border: 1px solid rgb(54,55,56);
}
.el-table{
background-color: rgb(33,33,33);
}
.el-table tr{
background: rgb(40,40,40);
border-color: #434343;
}
.el-table th.el-table__cell {
background-color: rgb(40,40,40);
border-color: #434343;
}
.el-table.is-scrolling-none th.el-table-fixed-column--left, .el-table.is-scrolling-none th.el-table-fixed-column--right {
background-color: rgb(40,40,40);
}
.el-table--border .el-table__inner-wrapper:after, .el-table--border:after, .el-table--border:before, .el-table__inner-wrapper:before{
background-color: #434343;
}
.el-table__border-bottom-patch, .el-table__border-left-patch{
background-color: #434343;
}
.el-table td.el-table__cell, .el-table th.el-table__cell.is-leaf{
border-color: #434343;
}
.ed-checkbox__inner{
background: transparent;
border-color: #787878;
}
.ed-checkbox__input.is-disabled .ed-checkbox__inner{
background: #434343;
border-color: #787878;
}
.el-table thead{
color: #E4E4E4;
}
.el-table .el-table__cell{
background: #212121;
color: #F2F4F5;
}
.el-table__body-wrapper tr td.el-table-fixed-column--left, .el-table__body-wrapper tr td.el-table-fixed-column--right, .el-table__body-wrapper tr th.el-table-fixed-column--left, .el-table__body-wrapper tr th.el-table-fixed-column--right, .el-table__footer-wrapper tr td.el-table-fixed-column--left, .el-table__footer-wrapper tr td.el-table-fixed-column--right, .el-table__footer-wrapper tr th.el-table-fixed-column--left, .el-table__footer-wrapper tr th.el-table-fixed-column--right, .el-table__header-wrapper tr td.el-table-fixed-column--left, .el-table__header-wrapper tr td.el-table-fixed-column--right, .el-table__header-wrapper tr th.el-table-fixed-column--left, .el-table__header-wrapper tr th.el-table-fixed-column--right{
background: #212121;
}
.hover-row > td {
background-color: rgb(48,48,48) !important;
}
.ed-checkbox__input.is-checked .ed-checkbox__inner {
background-color: #409eff;
border-color: #409eff;
}
.ed-switch.is-checked .ed-switch__core{
border-color: #0089ff;
background-color: #0089ff;
}
</style> </style>