更新容器获取
This commit is contained in:
@@ -83,15 +83,6 @@
|
|||||||
</configuration>
|
</configuration>
|
||||||
</plugin>
|
</plugin>
|
||||||
|
|
||||||
<!-- Eclipse 插件 -->
|
|
||||||
<plugin>
|
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
|
||||||
<artifactId>maven-eclipse-plugin</artifactId>
|
|
||||||
<configuration>
|
|
||||||
<wtpContextName>${finalName}</wtpContextName>
|
|
||||||
</configuration>
|
|
||||||
</plugin>
|
|
||||||
|
|
||||||
</plugins>
|
</plugins>
|
||||||
</build>
|
</build>
|
||||||
|
|
||||||
|
|||||||
@@ -1,9 +1,12 @@
|
|||||||
package com.jeesite.modules.app;
|
package com.jeesite.modules.app;
|
||||||
|
|
||||||
|
|
||||||
|
import com.jeesite.common.config.Global;
|
||||||
import com.jeesite.modules.app.Service.MyService;
|
import com.jeesite.modules.app.Service.MyService;
|
||||||
import com.jeesite.modules.app.dao.MyWorkInfo;
|
import com.jeesite.modules.app.dao.MyWorkInfo;
|
||||||
|
import com.jeesite.modules.app.dao.info.DockerInfo;
|
||||||
import com.jeesite.modules.app.utils.DateUtils;
|
import com.jeesite.modules.app.utils.DateUtils;
|
||||||
|
import com.jeesite.modules.app.utils.DockerUtils;
|
||||||
import com.jeesite.modules.app.utils.MyUtils;
|
import com.jeesite.modules.app.utils.MyUtils;
|
||||||
|
|
||||||
import com.jeesite.modules.biz.entity.*;
|
import com.jeesite.modules.biz.entity.*;
|
||||||
@@ -15,9 +18,13 @@ import org.springframework.stereotype.Controller;
|
|||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
import org.springframework.web.bind.annotation.ResponseBody;
|
import org.springframework.web.bind.annotation.ResponseBody;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
|
|
||||||
|
import static com.jeesite.common.web.BaseController.text;
|
||||||
|
import static com.jeesite.common.web.http.ServletUtils.renderResult;
|
||||||
|
|
||||||
|
|
||||||
@Controller
|
@Controller
|
||||||
@RequestMapping(value = "${adminPath}/biz/myWork")
|
@RequestMapping(value = "${adminPath}/biz/myWork")
|
||||||
@@ -32,6 +39,9 @@ public class appStart {
|
|||||||
@Resource
|
@Resource
|
||||||
private BizProjectInfoService bizProjectInfoService;
|
private BizProjectInfoService bizProjectInfoService;
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private BizMonitorHostService bizMonitorHostService;
|
||||||
|
|
||||||
|
|
||||||
@Resource
|
@Resource
|
||||||
private BizCalendarInfoService bizCalendarInfoService;
|
private BizCalendarInfoService bizCalendarInfoService;
|
||||||
@@ -88,4 +98,66 @@ public class appStart {
|
|||||||
return new MyWorkInfo(weatherText, notifyNums, listItems.size(), projectNums, projectInfos.size(), calendarNums, schedules.size(), employees.size());
|
return new MyWorkInfo(weatherText, notifyNums, listItems.size(), projectNums, projectInfos.size(), calendarNums, schedules.size(), employees.size());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@RequestMapping(value = "dockerList")
|
||||||
|
@ResponseBody
|
||||||
|
public List<DockerInfo> dockerList(DockerInfo dockerInfo) {
|
||||||
|
BizMonitorHost monitorHost = new BizMonitorHost();
|
||||||
|
monitorHost.setHostId(dockerInfo.getHostId());
|
||||||
|
List<BizMonitorHost> bizMonitorHostList = bizMonitorHostService.findList(monitorHost);
|
||||||
|
BizMonitorHost bizMonitorHost = bizMonitorHostList.get(0);
|
||||||
|
if (bizMonitorHost.getIsAuth().equals("1")) {
|
||||||
|
try {
|
||||||
|
DockerUtils dockerUtils = new DockerUtils(bizMonitorHost.getIpAddress(), bizMonitorHost.getCheckTargetPort());
|
||||||
|
return dockerUtils.dockerInfoList(bizMonitorHost.getHostId());
|
||||||
|
} catch (Exception e) {
|
||||||
|
System.out.println(e.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return new ArrayList<>();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@RequestMapping(value = "restart")
|
||||||
|
@ResponseBody
|
||||||
|
public String restart(DockerInfo dockerInfo) {
|
||||||
|
BizMonitorHost monitorHost = new BizMonitorHost();
|
||||||
|
monitorHost.setHostId(dockerInfo.getHostId());
|
||||||
|
List<BizMonitorHost> bizMonitorHostList = bizMonitorHostService.findList(monitorHost);
|
||||||
|
BizMonitorHost bizMonitorHost = bizMonitorHostList.get(0);
|
||||||
|
if (bizMonitorHost.getIsAuth().equals("1")) {
|
||||||
|
DockerUtils dockerUtils = new DockerUtils(bizMonitorHost.getIpAddress(), bizMonitorHost.getCheckTargetPort());
|
||||||
|
dockerUtils.stopContainer(dockerInfo.getId());
|
||||||
|
dockerUtils.startContainer(dockerInfo.getId());
|
||||||
|
}
|
||||||
|
return renderResult(Global.TRUE, text("重启容器成功!"));
|
||||||
|
}
|
||||||
|
|
||||||
|
@RequestMapping(value = "start")
|
||||||
|
@ResponseBody
|
||||||
|
public String start(DockerInfo dockerInfo) {
|
||||||
|
BizMonitorHost monitorHost = new BizMonitorHost();
|
||||||
|
monitorHost.setHostId(dockerInfo.getHostId());
|
||||||
|
List<BizMonitorHost> bizMonitorHostList = bizMonitorHostService.findList(monitorHost);
|
||||||
|
BizMonitorHost bizMonitorHost = bizMonitorHostList.get(0);
|
||||||
|
if (bizMonitorHost.getIsAuth().equals("1")) {
|
||||||
|
DockerUtils dockerUtils = new DockerUtils(bizMonitorHost.getIpAddress(), bizMonitorHost.getCheckTargetPort());
|
||||||
|
dockerUtils.startContainer(dockerInfo.getId());
|
||||||
|
}
|
||||||
|
return renderResult(Global.TRUE, text("启动容器成功!"));
|
||||||
|
}
|
||||||
|
|
||||||
|
@RequestMapping(value = "stop")
|
||||||
|
@ResponseBody
|
||||||
|
public String stop(DockerInfo dockerInfo) {
|
||||||
|
BizMonitorHost monitorHost = new BizMonitorHost();
|
||||||
|
monitorHost.setHostId(dockerInfo.getHostId());
|
||||||
|
List<BizMonitorHost> bizMonitorHostList = bizMonitorHostService.findList(monitorHost);
|
||||||
|
BizMonitorHost bizMonitorHost = bizMonitorHostList.get(0);
|
||||||
|
if (bizMonitorHost.getIsAuth().equals("1")) {
|
||||||
|
DockerUtils dockerUtils = new DockerUtils(bizMonitorHost.getIpAddress(), bizMonitorHost.getCheckTargetPort());
|
||||||
|
dockerUtils.stopContainer(dockerInfo.getId());
|
||||||
|
}
|
||||||
|
return renderResult(Global.TRUE, text("停止容器成功!"));
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,39 @@
|
|||||||
|
package com.jeesite.modules.app.dao.info;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class DockerInfo implements Serializable {
|
||||||
|
|
||||||
|
private String name; // 容器名称
|
||||||
|
private String id; // 容器id
|
||||||
|
private String cid;
|
||||||
|
private String imageName; // 镜像名称
|
||||||
|
private String mapPorts; // 映射端口
|
||||||
|
private String status; // 运行时长
|
||||||
|
private String state; // 运行状态
|
||||||
|
private double cpuUsage; //CPU
|
||||||
|
private double memUsage; // 内存
|
||||||
|
|
||||||
|
private String hostId;
|
||||||
|
|
||||||
|
public DockerInfo() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public DockerInfo(String name, String id,String imageName, String mapPorts, String status, String state, double cpuUsage, double memUsage,String hostId) {
|
||||||
|
this.name = name;
|
||||||
|
this.id = id;
|
||||||
|
this.cid = id.substring(0, 12);
|
||||||
|
this.imageName = imageName;
|
||||||
|
this.mapPorts = mapPorts;
|
||||||
|
this.state = state;
|
||||||
|
this.status = status;
|
||||||
|
this.cpuUsage = cpuUsage;
|
||||||
|
this.memUsage = memUsage;
|
||||||
|
this.hostId = hostId;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,66 +1,229 @@
|
|||||||
package com.jeesite.modules.app.utils;
|
package com.jeesite.modules.app.utils;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||||
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
import com.github.dockerjava.api.DockerClient;
|
import com.github.dockerjava.api.DockerClient;
|
||||||
import com.github.dockerjava.api.command.CreateContainerResponse;
|
import com.github.dockerjava.api.command.CreateContainerResponse;
|
||||||
|
import com.github.dockerjava.api.command.InspectContainerResponse;
|
||||||
import com.github.dockerjava.api.model.Container;
|
import com.github.dockerjava.api.model.Container;
|
||||||
import com.github.dockerjava.core.DockerClientBuilder;
|
import com.github.dockerjava.core.DockerClientBuilder;
|
||||||
import com.github.dockerjava.okhttp.OkDockerHttpClient;
|
import com.github.dockerjava.okhttp.OkDockerHttpClient;
|
||||||
|
import com.jeesite.modules.app.dao.info.DockerInfo;
|
||||||
|
|
||||||
import java.net.URI;
|
import java.net.URI;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Objects;
|
||||||
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
|
|
||||||
|
public class DockerUtils implements AutoCloseable {
|
||||||
|
private static final ObjectMapper OBJECT_MAPPER = new ObjectMapper();
|
||||||
|
// 重试次数
|
||||||
|
private static final int RETRY_COUNT = 3;
|
||||||
|
// 重试间隔(秒)
|
||||||
|
private static final int RETRY_INTERVAL = 2;
|
||||||
|
|
||||||
public class DockerUtils {
|
|
||||||
private final DockerClient dockerClient;
|
private final DockerClient dockerClient;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 构造Docker客户端连接(重点:调整HTTP客户端超时配置)
|
||||||
|
*
|
||||||
|
* @param dockerIp Docker服务端IP
|
||||||
|
* @param dockerPort Docker服务端端口
|
||||||
|
* @throws IllegalArgumentException IP/端口不合法时抛出
|
||||||
|
*/
|
||||||
public DockerUtils(String dockerIp, int dockerPort) {
|
public DockerUtils(String dockerIp, int dockerPort) {
|
||||||
|
if (dockerIp == null || dockerIp.isBlank()) {
|
||||||
|
throw new IllegalArgumentException("Docker IP地址不能为空");
|
||||||
|
}
|
||||||
|
if (dockerPort <= 0 || dockerPort > 65535) {
|
||||||
|
throw new IllegalArgumentException("Docker端口号必须在1-65535之间");
|
||||||
|
}
|
||||||
|
|
||||||
String dockerHostStr = String.format("tcp://%s:%d", dockerIp, dockerPort);
|
String dockerHostStr = String.format("tcp://%s:%d", dockerIp, dockerPort);
|
||||||
URI dockerHost = URI.create(dockerHostStr);
|
URI dockerHost = URI.create(dockerHostStr);
|
||||||
|
|
||||||
|
// 核心调整:增大HTTP客户端超时时间(连接超时60秒,读取超时120秒)
|
||||||
OkDockerHttpClient httpClient = new OkDockerHttpClient.Builder()
|
OkDockerHttpClient httpClient = new OkDockerHttpClient.Builder()
|
||||||
.dockerHost(dockerHost)
|
.dockerHost(dockerHost)
|
||||||
.connectTimeout(10)
|
.connectTimeout(60) // 连接超时从10秒→60秒
|
||||||
.readTimeout(30)
|
.readTimeout(120) // 读取超时从30秒→120秒
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
this.dockerClient = DockerClientBuilder.getInstance()
|
this.dockerClient = DockerClientBuilder.getInstance()
|
||||||
.withDockerHttpClient(httpClient)
|
.withDockerHttpClient(httpClient)
|
||||||
.build();
|
.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取容器列表 all true=包含停止容器,false=仅运行中容器
|
* 启动容器(移除无效的withTimeout,保留重试机制+延长HTTP超时)
|
||||||
|
*
|
||||||
|
* @param containerId 容器ID/名称
|
||||||
|
* @return true=启动成功,false=启动失败
|
||||||
|
*/
|
||||||
|
public boolean startContainer(String containerId) {
|
||||||
|
// 1. 参数校验
|
||||||
|
if (containerId == null || containerId.isBlank()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
// 2. 增加重试机制
|
||||||
|
int retry = 0;
|
||||||
|
while (retry < RETRY_COUNT) {
|
||||||
|
try {
|
||||||
|
// 检查容器是否存在
|
||||||
|
InspectContainerResponse containerInfo = dockerClient.inspectContainerCmd(containerId).exec();
|
||||||
|
// 检查容器是否已启动
|
||||||
|
if (containerInfo.getState().getRunning()) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
// 修复点:移除无效的withTimeout调用,仅保留核心启动逻辑
|
||||||
|
dockerClient.startContainerCmd(containerId).exec();
|
||||||
|
// 等待2秒后验证启动结果(给容器足够的启动时间,避免状态未同步)
|
||||||
|
TimeUnit.SECONDS.sleep(2);
|
||||||
|
InspectContainerResponse afterStart = dockerClient.inspectContainerCmd(containerId).exec();
|
||||||
|
if (afterStart.getState().getRunning()) {
|
||||||
|
System.out.println("容器[" + containerId + "]启动成功(重试次数:" + retry + ")");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
retry++;
|
||||||
|
// 非最后一次重试时,等待后重试
|
||||||
|
if (retry < RETRY_COUNT) {
|
||||||
|
try {
|
||||||
|
TimeUnit.SECONDS.sleep(RETRY_INTERVAL);
|
||||||
|
} catch (InterruptedException ie) {
|
||||||
|
Thread.currentThread().interrupt();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取容器列表
|
||||||
*/
|
*/
|
||||||
public List<Container> listContainers(boolean all) {
|
public List<Container> listContainers(boolean all) {
|
||||||
return dockerClient.listContainersCmd().withShowAll(all).exec();
|
try {
|
||||||
|
return dockerClient.listContainersCmd().withShowAll(all).exec();
|
||||||
|
} catch (Exception e) {
|
||||||
|
System.out.println(e.getMessage());
|
||||||
|
return Collections.emptyList();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 创建容器(指定镜像+唯一容器名,后台运行)
|
* 封装容器信息为业务模型
|
||||||
|
*/
|
||||||
|
public List<DockerInfo> dockerInfoList(String hostId) {
|
||||||
|
if (hostId == null || hostId.isBlank()) {
|
||||||
|
return Collections.emptyList();
|
||||||
|
}
|
||||||
|
|
||||||
|
List<DockerInfo> dockerInfos = new ArrayList<>();
|
||||||
|
try {
|
||||||
|
List<Container> containers = listContainers(true);
|
||||||
|
for (Container container : containers) {
|
||||||
|
String containerName = container.getNames() != null
|
||||||
|
? String.join("", container.getNames()).replace("/", "")
|
||||||
|
: "未知容器";
|
||||||
|
String portsJson;
|
||||||
|
try {
|
||||||
|
portsJson = OBJECT_MAPPER.writeValueAsString(container.getPorts());
|
||||||
|
} catch (JsonProcessingException e) {
|
||||||
|
System.out.println("容器[" + container.getId() + "]端口信息序列化失败:" + e.getMessage());
|
||||||
|
portsJson = "[]";
|
||||||
|
}
|
||||||
|
dockerInfos.add(new DockerInfo(
|
||||||
|
containerName,
|
||||||
|
container.getId(),
|
||||||
|
container.getImage(),
|
||||||
|
portsJson,
|
||||||
|
container.getStatus(),
|
||||||
|
"running".equals(container.getState()) ? "1" : "0",
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
hostId
|
||||||
|
));
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
System.out.println(e.getMessage());
|
||||||
|
}
|
||||||
|
return dockerInfos;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 创建容器(指定镜像+唯一容器名)
|
||||||
*/
|
*/
|
||||||
public String createContainer(String image, String containerName) {
|
public String createContainer(String image, String containerName) {
|
||||||
CreateContainerResponse resp = dockerClient.createContainerCmd(image)
|
if (image == null || image.isBlank()) {
|
||||||
.withName(containerName)
|
throw new IllegalArgumentException("镜像名称不能为空");
|
||||||
.withTty(true) // 分配伪终端,后台运行
|
}
|
||||||
.exec();
|
if (containerName == null || containerName.isBlank()) {
|
||||||
return resp.getId();
|
throw new IllegalArgumentException("容器名称不能为空");
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
CreateContainerResponse resp = dockerClient.createContainerCmd(image)
|
||||||
|
.withName(containerName)
|
||||||
|
.withTty(true)
|
||||||
|
.exec();
|
||||||
|
return resp.getId();
|
||||||
|
} catch (Exception e) {
|
||||||
|
System.out.println(e.getMessage());
|
||||||
|
return null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 启动容器(支持完整ID/短ID/容器名)
|
* 停止容器
|
||||||
*/
|
*/
|
||||||
public void startContainer(String containerId) {
|
public boolean stopContainer(String containerId) {
|
||||||
dockerClient.startContainerCmd(containerId).exec();
|
if (containerId == null || containerId.isBlank()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
InspectContainerResponse containerInfo = dockerClient.inspectContainerCmd(containerId).exec();
|
||||||
|
if (!containerInfo.getState().getRunning()) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
dockerClient.stopContainerCmd(containerId).exec();
|
||||||
|
return true;
|
||||||
|
} catch (Exception e) {
|
||||||
|
System.out.println(e.getMessage());
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 停止容器(支持完整ID/短ID/容器名)
|
* 删除容器
|
||||||
*/
|
*/
|
||||||
public void stopContainer(String containerId) {
|
public boolean removeContainer(String containerId, boolean force) {
|
||||||
dockerClient.stopContainerCmd(containerId).exec();
|
if (containerId == null || containerId.isBlank()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
dockerClient.removeContainerCmd(containerId).withForce(force).exec();
|
||||||
|
return true;
|
||||||
|
} catch (Exception e) {
|
||||||
|
System.out.println(e.getMessage());
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 删除容器 true=强制删除运行中的容器,false=仅删除停止的
|
* 关闭Docker客户端连接,释放资源
|
||||||
*/
|
*/
|
||||||
public void removeContainer(String containerId, boolean force) {
|
@Override
|
||||||
dockerClient.removeContainerCmd(containerId).withForce(force).exec();
|
public void close() {
|
||||||
|
if (Objects.nonNull(dockerClient)) {
|
||||||
|
try {
|
||||||
|
dockerClient.close();
|
||||||
|
System.out.println("Docker客户端连接已关闭");
|
||||||
|
} catch (Exception e) {
|
||||||
|
System.err.println("关闭Docker客户端连接失败,异常信息:" + e.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -4,6 +4,8 @@ import java.util.ArrayList;
|
|||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.function.Function;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
import com.jeesite.modules.app.dao.file.FolderItem;
|
import com.jeesite.modules.app.dao.file.FolderItem;
|
||||||
import com.jeesite.modules.app.utils.MyUtils;
|
import com.jeesite.modules.app.utils.MyUtils;
|
||||||
@@ -160,51 +162,49 @@ public class BizFoldersController extends BaseController {
|
|||||||
@RequestMapping(value = "foldersAll")
|
@RequestMapping(value = "foldersAll")
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
public List<Map<String, Object>> foldersAll(BizFolders bizFolders) {
|
public List<Map<String, Object>> foldersAll(BizFolders bizFolders) {
|
||||||
|
// 构建根节点
|
||||||
List<Map<String, Object>> treeData = new ArrayList<>();
|
List<Map<String, Object>> treeData = new ArrayList<>();
|
||||||
Map<String, Object> rootNode = new HashMap<>();
|
Map<String, Object> rootNode = new HashMap<>();
|
||||||
rootNode.put("id", "0");
|
rootNode.put("id", "0");
|
||||||
rootNode.put("name", "根目录");
|
rootNode.put("name", "根目录");
|
||||||
rootNode.put("disabled", false);
|
rootNode.put("disabled", false);
|
||||||
rootNode.put("children", new ArrayList<>());
|
// 1. 一次性查询所有未删除的文件夹
|
||||||
bizFolders.setParentId("0");
|
BizFolders query = new BizFolders();
|
||||||
bizFolders.setIsDeleted(0);
|
query.setIsDeleted(0);
|
||||||
List<BizFolders> firstLevelFolders = bizFoldersService.findList(bizFolders);
|
List<BizFolders> allFolders = bizFoldersService.findList(query);
|
||||||
List<Map<String, Object>> firstNodeList = new ArrayList<>();
|
// 2. 按parentId分组,构建映射Map
|
||||||
for (BizFolders firstFolder : firstLevelFolders) {
|
Map<String, List<BizFolders>> folderMap = allFolders.stream()
|
||||||
Map<String, Object> firstNode = MyUtils.convertToTreeNode(firstFolder, "根目录");
|
.collect(Collectors.groupingBy(BizFolders::getParentId, Collectors.toList()));
|
||||||
BizFolders secondQuery = new BizFolders();
|
// 3. 递归构建树形结构的核心逻辑(内部递归方法)
|
||||||
secondQuery.setParentId(firstFolder.getFolderId());
|
Function<String, List<Map<String, Object>>> buildTree = new Function<String, List<Map<String, Object>>>() {
|
||||||
secondQuery.setIsDeleted(0);
|
@Override
|
||||||
List<BizFolders> secondLevelFolders = bizFoldersService.findList(secondQuery);
|
public List<Map<String, Object>> apply(String parentId) {
|
||||||
List<Map<String, Object>> secondNodeList = new ArrayList<>();
|
List<Map<String, Object>> nodeList = new ArrayList<>();
|
||||||
for (BizFolders secondFolder : secondLevelFolders) {
|
List<BizFolders> childFolders = folderMap.getOrDefault(parentId, new ArrayList<>());
|
||||||
Map<String, Object> secondNode = MyUtils.convertToTreeNode(secondFolder, firstFolder.getFolderName());
|
for (BizFolders folder : childFolders) {
|
||||||
BizFolders thirdQuery = new BizFolders();
|
// 转换为节点
|
||||||
thirdQuery.setParentId(secondFolder.getFolderId());
|
Map<String, Object> node = MyUtils.convertToTreeNode(folder,
|
||||||
thirdQuery.setIsDeleted(0);
|
parentId.equals("0") ? "根目录" : getFolderNameById(folderMap, parentId));
|
||||||
List<BizFolders> thirdLevelFolders = bizFoldersService.findList(thirdQuery);
|
// 递归获取子节点
|
||||||
List<Map<String, Object>> thirdNodeList = new ArrayList<>();
|
node.put("children", this.apply(folder.getFolderId()));
|
||||||
for (BizFolders thirdFolder : thirdLevelFolders) {
|
nodeList.add(node);
|
||||||
Map<String, Object> thirdNode = MyUtils.convertToTreeNode(thirdFolder, secondFolder.getFolderName());
|
|
||||||
BizFolders fourthQuery = new BizFolders();
|
|
||||||
fourthQuery.setParentId(thirdFolder.getFolderId());
|
|
||||||
fourthQuery.setIsDeleted(0);
|
|
||||||
List<BizFolders> fourthLevelFolders = bizFoldersService.findList(fourthQuery);
|
|
||||||
List<Map<String, Object>> fourthNodeList = new ArrayList<>();
|
|
||||||
for (BizFolders fourthFolder : fourthLevelFolders) {
|
|
||||||
Map<String, Object> fourthNode = MyUtils.convertToTreeNode(fourthFolder, thirdFolder.getFolderName());
|
|
||||||
fourthNodeList.add(fourthNode);
|
|
||||||
}
|
|
||||||
thirdNode.put("children", fourthNodeList);
|
|
||||||
thirdNodeList.add(thirdNode);
|
|
||||||
}
|
}
|
||||||
secondNode.put("children", thirdNodeList);
|
return nodeList;
|
||||||
secondNodeList.add(secondNode);
|
|
||||||
}
|
}
|
||||||
firstNode.put("children", secondNodeList);
|
// 辅助方法:根据folderId获取文件夹名称
|
||||||
firstNodeList.add(firstNode);
|
private String getFolderNameById(Map<String, List<BizFolders>> folderMap, String folderId) {
|
||||||
}
|
for (List<BizFolders> folders : folderMap.values()) {
|
||||||
rootNode.put("children", firstNodeList);
|
for (BizFolders f : folders) {
|
||||||
|
if (folderId.equals(f.getFolderId())) {
|
||||||
|
return f.getFolderName();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
};
|
||||||
|
// 4. 构建根节点的子节点并返回
|
||||||
|
rootNode.put("children", buildTree.apply("0"));
|
||||||
treeData.add(rootNode);
|
treeData.add(rootNode);
|
||||||
return treeData;
|
return treeData;
|
||||||
}
|
}
|
||||||
@@ -213,53 +213,47 @@ public class BizFoldersController extends BaseController {
|
|||||||
@RequestMapping(value = "treeData")
|
@RequestMapping(value = "treeData")
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
public List<Map<String, Object>> treeFoldersData(BizFolders bizFolders) {
|
public List<Map<String, Object>> treeFoldersData(BizFolders bizFolders) {
|
||||||
|
// 1. 构建根节点
|
||||||
List<Map<String, Object>> treeData = new ArrayList<>();
|
List<Map<String, Object>> treeData = new ArrayList<>();
|
||||||
Map<String, Object> rootNode = new HashMap<>();
|
Map<String, Object> rootNode = new HashMap<>();
|
||||||
rootNode.put("id", "0");
|
rootNode.put("id", "0");
|
||||||
rootNode.put("name", "根目录");
|
rootNode.put("name", "根目录");
|
||||||
rootNode.put("disabled", false);
|
rootNode.put("disabled", false);
|
||||||
rootNode.put("children", new ArrayList<>());
|
// 2. 一次性查询所有未删除的文件夹(仅1次数据库查询)
|
||||||
bizFolders.setParentId("0");
|
BizFolders query = new BizFolders();
|
||||||
bizFolders.setIsDeleted(0);
|
query.setIsDeleted(0);
|
||||||
List<BizFolders> firstLevelFolders = bizFoldersService.findList(bizFolders);
|
List<BizFolders> allFolders = bizFoldersService.findList(query);
|
||||||
List<Map<String, Object>> firstNodeList = new ArrayList<>();
|
// 3. 按parentId分组,快速查找子节点
|
||||||
for (BizFolders firstFolder : firstLevelFolders) {
|
Map<String, List<BizFolders>> folderMap = allFolders.stream()
|
||||||
Map<String, Object> firstNode = MyUtils.convertToTreeNode(firstFolder, false);
|
.collect(Collectors.groupingBy(BizFolders::getParentId, Collectors.toList()));
|
||||||
BizFolders secondQuery = new BizFolders();
|
final List<java.util.function.BiFunction<String, Integer, List<Map<String, Object>>>> recursiveHolder = new ArrayList<>();
|
||||||
secondQuery.setParentId(firstFolder.getFolderId());
|
// 匿名内部类实现递归逻辑(BiFunction:入参parentId+level,出参节点列表)
|
||||||
secondQuery.setIsDeleted(0);
|
java.util.function.BiFunction<String, Integer, List<Map<String, Object>>> buildTree = new java.util.function.BiFunction<String, Integer, List<Map<String, Object>>>() {
|
||||||
List<BizFolders> secondLevelFolders = bizFoldersService.findList(secondQuery);
|
@Override
|
||||||
List<Map<String, Object>> secondNodeList = new ArrayList<>();
|
public List<Map<String, Object>> apply(String parentId, Integer level) {
|
||||||
for (BizFolders secondFolder : secondLevelFolders) {
|
List<Map<String, Object>> nodeList = new ArrayList<>();
|
||||||
Map<String, Object> secondNode = MyUtils.convertToTreeNode(secondFolder, false);
|
// 空值保护:获取当前父ID下的子文件夹
|
||||||
BizFolders thirdQuery = new BizFolders();
|
List<BizFolders> childFolders = folderMap.getOrDefault(parentId, new ArrayList<>());
|
||||||
thirdQuery.setParentId(secondFolder.getFolderId());
|
for (BizFolders folder : childFolders) {
|
||||||
thirdQuery.setIsDeleted(0);
|
// 原业务逻辑:四级节点特殊处理,其他传false
|
||||||
List<BizFolders> thirdLevelFolders = bizFoldersService.findList(thirdQuery);
|
boolean flag = level == 4 ? "add".equals(bizFolders.getDescription()) : false;
|
||||||
List<Map<String, Object>> thirdNodeList = new ArrayList<>();
|
Map<String, Object> node = MyUtils.convertToTreeNode(folder, flag);
|
||||||
for (BizFolders thirdFolder : thirdLevelFolders) {
|
// 递归调用自身(通过holder获取)
|
||||||
Map<String, Object> thirdNode = MyUtils.convertToTreeNode(thirdFolder, false);
|
List<Map<String, Object>> children = recursiveHolder.get(0).apply(folder.getFolderId(), level + 1);
|
||||||
BizFolders fourthQuery = new BizFolders();
|
// 无子节点时设为空列表(和原代码一致)
|
||||||
fourthQuery.setParentId(thirdFolder.getFolderId());
|
node.put("children", children.isEmpty() ? new ArrayList<>() : children);
|
||||||
fourthQuery.setIsDeleted(0);
|
nodeList.add(node);
|
||||||
List<BizFolders> fourthLevelFolders = bizFoldersService.findList(fourthQuery);
|
|
||||||
List<Map<String, Object>> fourthNodeList = new ArrayList<>();
|
|
||||||
for (BizFolders fourthFolder : fourthLevelFolders) {
|
|
||||||
Map<String, Object> fourthNode = MyUtils.convertToTreeNode(fourthFolder, bizFolders.getDescription().equals("add") ? true : false);
|
|
||||||
fourthNode.put("children", new ArrayList<>());
|
|
||||||
fourthNodeList.add(fourthNode);
|
|
||||||
}
|
|
||||||
thirdNode.put("children", fourthNodeList);
|
|
||||||
thirdNodeList.add(thirdNode);
|
|
||||||
}
|
}
|
||||||
secondNode.put("children", thirdNodeList);
|
return nodeList;
|
||||||
secondNodeList.add(secondNode);
|
|
||||||
}
|
}
|
||||||
firstNode.put("children", secondNodeList);
|
};
|
||||||
firstNodeList.add(firstNode);
|
|
||||||
}
|
// 将递归逻辑放入holder,供内部调用
|
||||||
rootNode.put("children", firstNodeList);
|
recursiveHolder.add(buildTree);
|
||||||
|
// 5. 从根节点(parentId=0,层级1)开始构建
|
||||||
|
rootNode.put("children", buildTree.apply("0", 1));
|
||||||
treeData.add(rootNode);
|
treeData.add(rootNode);
|
||||||
|
|
||||||
return treeData;
|
return treeData;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -17,7 +17,33 @@ export interface MyWorkInfo extends BasicModel<MyWorkInfo> {
|
|||||||
calendarNums?: number;
|
calendarNums?: number;
|
||||||
calendarAllNums?: number;
|
calendarAllNums?: number;
|
||||||
teamNums?: number;
|
teamNums?: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
export interface DockerInfo extends BasicModel<DockerInfo> {
|
||||||
|
name?: string;
|
||||||
|
id: string;
|
||||||
|
cid: string;
|
||||||
|
createTime?: string;
|
||||||
|
imageName?: string;
|
||||||
|
mapPorts?: string;
|
||||||
|
status?: string;
|
||||||
|
state?: string;
|
||||||
|
cpuUsage?: string;
|
||||||
|
memUsage?: string;
|
||||||
|
}
|
||||||
|
|
||||||
export const bizMyWorkInfoList = () =>
|
export const bizMyWorkInfoList = () =>
|
||||||
defHttp.get<MyWorkInfo>({ url: adminPath + '/biz/myWork/list'});
|
defHttp.get<MyWorkInfo>({ url: adminPath + '/biz/myWork/list'});
|
||||||
|
|
||||||
|
export const bizDockerInfoList = (params?: DockerInfo | any) =>
|
||||||
|
defHttp.get<DockerInfo[]>({ url: adminPath + '/biz/myWork/dockerList' , params });
|
||||||
|
|
||||||
|
export const bizDockerRestart = (params?: DockerInfo | any) =>
|
||||||
|
defHttp.get<DockerInfo>({ url: adminPath + '/biz/myWork/restart', params });
|
||||||
|
|
||||||
|
export const bizDockerStart = (params?: DockerInfo | any) =>
|
||||||
|
defHttp.get<DockerInfo>({ url: adminPath + '/biz/myWork/start', params });
|
||||||
|
|
||||||
|
export const bizDockerStop = (params?: DockerInfo | any) =>
|
||||||
|
defHttp.get<DockerInfo>({ url: adminPath + '/biz/myWork/stop', params });
|
||||||
@@ -95,7 +95,7 @@
|
|||||||
component: 'Input',
|
component: 'Input',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: t('是否有附件'),
|
label: t('有无附件'),
|
||||||
field: 'hasAttachment',
|
field: 'hasAttachment',
|
||||||
component: 'Select',
|
component: 'Select',
|
||||||
componentProps: {
|
componentProps: {
|
||||||
@@ -138,7 +138,7 @@
|
|||||||
dataIndex: 'fromAddress',
|
dataIndex: 'fromAddress',
|
||||||
key: 'a.from_address',
|
key: 'a.from_address',
|
||||||
sorter: true,
|
sorter: true,
|
||||||
width: 130,
|
width: 225,
|
||||||
align: 'left',
|
align: 'left',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -146,20 +146,12 @@
|
|||||||
dataIndex: 'subject',
|
dataIndex: 'subject',
|
||||||
key: 'a.subject',
|
key: 'a.subject',
|
||||||
sorter: true,
|
sorter: true,
|
||||||
width: 425,
|
width: 1000,
|
||||||
align: 'left',
|
align: 'left',
|
||||||
slot: 'slotBizKey',
|
slot: 'slotBizKey',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: t('接收时间'),
|
title: t('有无附件'),
|
||||||
dataIndex: 'receivedTime',
|
|
||||||
key: 'a.received_time',
|
|
||||||
sorter: true,
|
|
||||||
width: 180,
|
|
||||||
align: 'center',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
title: t('是否有附件'),
|
|
||||||
dataIndex: 'hasAttachment',
|
dataIndex: 'hasAttachment',
|
||||||
key: 'a.has_attachment',
|
key: 'a.has_attachment',
|
||||||
sorter: true,
|
sorter: true,
|
||||||
|
|||||||
@@ -19,8 +19,8 @@
|
|||||||
<div class="content-header">
|
<div class="content-header">
|
||||||
<span class="content-title">邮件内容</span>
|
<span class="content-title">邮件内容</span>
|
||||||
<span class="content-tip" v-if="!ReceivedList?.mailContent">暂无邮件内容</span>
|
<span class="content-tip" v-if="!ReceivedList?.mailContent">暂无邮件内容</span>
|
||||||
</div>
|
</div>
|
||||||
<div class="db-content" v-html="ReceivedList?.mailContent || ''"></div>
|
<div class="db-content" v-html="decodeHtmlEntities(ReceivedList?.mailContent)"></div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- 附件列表区域 -->
|
<!-- 附件列表区域 -->
|
||||||
@@ -66,7 +66,14 @@
|
|||||||
emits: ['modalClose'],
|
emits: ['modalClose'],
|
||||||
setup(props, { emit }) {
|
setup(props, { emit }) {
|
||||||
const ReceivedList = ref<BizMailReceived>();
|
const ReceivedList = ref<BizMailReceived>();
|
||||||
const MailAttachments = ref<BizMailAttachments[]>([]);
|
const MailAttachments = ref<BizMailAttachments[]>([]);
|
||||||
|
|
||||||
|
const decodeHtmlEntities = (html: string) => {
|
||||||
|
if (!html) return '';
|
||||||
|
const txt = document.createElement('textarea');
|
||||||
|
txt.innerHTML = html;
|
||||||
|
return txt.value.replace(/\s+/g, ' ').trim();
|
||||||
|
};
|
||||||
|
|
||||||
const [register, { closeModal }] = useModalInner(async (data: any) => {
|
const [register, { closeModal }] = useModalInner(async (data: any) => {
|
||||||
if (!data) return;
|
if (!data) return;
|
||||||
@@ -123,7 +130,8 @@
|
|||||||
ReceivedList,
|
ReceivedList,
|
||||||
MailAttachments,
|
MailAttachments,
|
||||||
downloadAttachment,
|
downloadAttachment,
|
||||||
formatFileSize,
|
formatFileSize,
|
||||||
|
decodeHtmlEntities
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
@@ -234,7 +242,7 @@
|
|||||||
padding: 14px;
|
padding: 14px;
|
||||||
margin: 0;
|
margin: 0;
|
||||||
font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
|
font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
|
||||||
white-space: pre-wrap;
|
white-space: normal;
|
||||||
word-break: break-all;
|
word-break: break-all;
|
||||||
color: #333;
|
color: #333;
|
||||||
flex: 1;
|
flex: 1;
|
||||||
|
|||||||
@@ -95,9 +95,18 @@
|
|||||||
label: t('邮件主题'),
|
label: t('邮件主题'),
|
||||||
field: 'subject',
|
field: 'subject',
|
||||||
component: 'Input',
|
component: 'Input',
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
label: t('有无附件'),
|
||||||
|
field: 'hasAttachment',
|
||||||
|
component: 'Select',
|
||||||
|
componentProps: {
|
||||||
|
dictType: 'has_attachment',
|
||||||
|
allowClear: true,
|
||||||
|
},
|
||||||
|
},
|
||||||
{
|
{
|
||||||
label: t('发送状态'),
|
label: t('状态'),
|
||||||
field: 'sendStatus',
|
field: 'sendStatus',
|
||||||
component: 'Select',
|
component: 'Select',
|
||||||
componentProps: {
|
componentProps: {
|
||||||
@@ -105,15 +114,6 @@
|
|||||||
allowClear: true,
|
allowClear: true,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
|
||||||
label: t('有无附件'),
|
|
||||||
field: 'hasAttachment',
|
|
||||||
component: 'Select',
|
|
||||||
componentProps: {
|
|
||||||
dictType: 'has_attachment',
|
|
||||||
allowClear: true,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
],
|
],
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -6,9 +6,11 @@
|
|||||||
<div class="server-card">
|
<div class="server-card">
|
||||||
<div class="ip-info">
|
<div class="ip-info">
|
||||||
<div class="info-item ip-row">
|
<div class="info-item ip-row">
|
||||||
<span><a-button type="link" size="small" @click="openModal(true, item)">{{ item.sysHostname || '未知IP' }}</a-button></span>
|
<span><a-button type="link" size="small" @click="openModalServer(true, item)">{{ item.sysHostname || '未知IP' }}</a-button></span>
|
||||||
<span class="status-tag" :class="item.ustatus === '1' ? 'status-running' : 'status-offline'">
|
<span class="status-tag" :class="item.ustatus === '1' ? 'status-running' : 'status-offline'">
|
||||||
{{ item.ustatus === '1' ? '运行中' : '已离线' }}
|
<a-button type="link" size="small" @click="openModalDocker(true, item)">
|
||||||
|
{{ item.ustatus === '1' ? '运行中' : '已离线' }}
|
||||||
|
</a-button>
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -67,7 +69,8 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</Card>
|
</Card>
|
||||||
<Modal @register="register" />
|
<ModalInfo @register="ServerRegister" />
|
||||||
|
<DockerInfo @register="DockerRegister" />
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
@@ -77,13 +80,15 @@ import { Icon } from '@jeesite/core/components/Icon';
|
|||||||
import { useModal } from '@jeesite/core/components/Modal';
|
import { useModal } from '@jeesite/core/components/Modal';
|
||||||
import { useRouter } from 'vue-router';
|
import { useRouter } from 'vue-router';
|
||||||
import { BizServerInfo, bizServerInfoListAll } from '@jeesite/biz/api/biz/serverInfo';
|
import { BizServerInfo, bizServerInfoListAll } from '@jeesite/biz/api/biz/serverInfo';
|
||||||
import Modal from './info/ServerInfo.vue';
|
import ModalInfo from './info/ServerInfo.vue';
|
||||||
|
import DockerInfo from './info/DockerInfo.vue';
|
||||||
|
|
||||||
export default defineComponent({
|
export default defineComponent({
|
||||||
components: { Card, Icon, Modal },
|
components: { Card, Icon, ModalInfo, DockerInfo },
|
||||||
setup() {
|
setup() {
|
||||||
|
|
||||||
const [register, { openModal }] = useModal();
|
const [ServerRegister, { openModal: openModalServer }] = useModal();
|
||||||
|
const [DockerRegister, { openModal: openModalDocker }] = useModal();
|
||||||
// 服务器数据列表
|
// 服务器数据列表
|
||||||
const listData = ref<BizServerInfo[]>([]);
|
const listData = ref<BizServerInfo[]>([]);
|
||||||
|
|
||||||
@@ -119,8 +124,10 @@ export default defineComponent({
|
|||||||
|
|
||||||
return {
|
return {
|
||||||
listData,
|
listData,
|
||||||
register,
|
ServerRegister,
|
||||||
openModal,
|
DockerRegister,
|
||||||
|
openModalServer,
|
||||||
|
openModalDocker,
|
||||||
getUsageClass,
|
getUsageClass,
|
||||||
getProgressClass,
|
getProgressClass,
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -0,0 +1,414 @@
|
|||||||
|
<template>
|
||||||
|
<BasicModal
|
||||||
|
v-bind="$attrs"
|
||||||
|
@register="register"
|
||||||
|
title="容器详情"
|
||||||
|
:showOkBtn="false"
|
||||||
|
:showCancelBtn="false"
|
||||||
|
width="70%"
|
||||||
|
>
|
||||||
|
<div class="container-outer-wrapper">
|
||||||
|
<div class="search-filter-header">
|
||||||
|
<div class="search-box">
|
||||||
|
<a-input-search
|
||||||
|
v-model:value="searchKey"
|
||||||
|
placeholder="搜索容器名称"
|
||||||
|
enter-button
|
||||||
|
@search="onSearch"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<!-- 内容滚动 -->
|
||||||
|
<div class="content-scroll-container">
|
||||||
|
<div v-if="loading" class="loading-placeholder">
|
||||||
|
<a-skeleton :paragraph="{ rows: 3 }" style="width: 100%" active />
|
||||||
|
</div>
|
||||||
|
<div class="container-card-list">
|
||||||
|
<a-card
|
||||||
|
v-for="item in filteredContainerList"
|
||||||
|
:key="item.id"
|
||||||
|
class="single-container-card"
|
||||||
|
hoverable
|
||||||
|
:bordered="false"
|
||||||
|
>
|
||||||
|
<div class="card-content-wrapper">
|
||||||
|
<div class="top-info-row">
|
||||||
|
<div class="left-name-status">
|
||||||
|
<Tooltip :title="item.name" placement="topLeft">
|
||||||
|
<h3 class="container-name">{{ item.name }}</h3>
|
||||||
|
</Tooltip>
|
||||||
|
<Tooltip :title="item.state" placement="topLeft">
|
||||||
|
{{ item.state === '1' ? '运行中' : '已停止' }}
|
||||||
|
</Tooltip>
|
||||||
|
</div>
|
||||||
|
<div class="right-resource-text">
|
||||||
|
<span class="cpu-text">CPU: {{ item.cpuUsage }}%</span>
|
||||||
|
<span class="mem-text">内存: {{ item.memUsage }}%</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="detail-info-group">
|
||||||
|
<div class="info-item">
|
||||||
|
<span class="label">容器ID:</span>
|
||||||
|
<Tooltip :title="item.id" placement="top">
|
||||||
|
<span class="value">{{ item.cid }}</span>
|
||||||
|
</Tooltip>
|
||||||
|
</div>
|
||||||
|
<div class="info-item">
|
||||||
|
<span class="label">镜像:</span>
|
||||||
|
<Tooltip :title="item.imageName" placement="top">
|
||||||
|
<span class="value">{{ item.imageName }}</span>
|
||||||
|
</Tooltip>
|
||||||
|
</div>
|
||||||
|
<div class="info-item">
|
||||||
|
<span class="label">端口映射:</span>
|
||||||
|
<Tooltip :title="item.mapPorts || '无'" placement="top">
|
||||||
|
<span class="value">{{ item.mapPorts || '无' }}</span>
|
||||||
|
</Tooltip>
|
||||||
|
</div>
|
||||||
|
<div class="info-item">
|
||||||
|
<span class="label">运行时长:</span>
|
||||||
|
<Tooltip :title="item.status || '无'" placement="top">
|
||||||
|
<span class="value">{{ item.status || '无' }}</span>
|
||||||
|
</Tooltip>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="action-divider"></div>
|
||||||
|
<div class="action-button-section">
|
||||||
|
<a-space size="middle">
|
||||||
|
<a-button size="small" @click="handleRestart(item)">重启</a-button>
|
||||||
|
<a-button type="error" size="small" @click="handleStop(item)" :disabled="item.state == '0'" > 停止</a-button>
|
||||||
|
<a-button type="success" size="small" @click="handleStart(item)" :disabled="item.state == '1'" >启动</a-button>
|
||||||
|
</a-space>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</a-card>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</BasicModal>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script lang="ts">
|
||||||
|
import { defineComponent, ref, onMounted } from 'vue';
|
||||||
|
import { Tag, Tabs, TabPane, Tooltip, InputSearch } from 'ant-design-vue'; // 显式导入InputSearch
|
||||||
|
import { BasicModal, useModalInner } from '@jeesite/core/components/Modal';
|
||||||
|
import { useMessage } from '@jeesite/core/hooks/web/useMessage';
|
||||||
|
import { DockerInfo , bizDockerInfoList, bizDockerRestart, bizDockerStart, bizDockerStop } from '@jeesite/biz/api/biz/myWork';
|
||||||
|
import { message, Modal } from 'ant-design-vue';
|
||||||
|
|
||||||
|
export default defineComponent({
|
||||||
|
components: { BasicModal, Tag, Tabs, TabPane, Tooltip, InputSearch },
|
||||||
|
setup() {
|
||||||
|
const { createMessage } = useMessage();
|
||||||
|
const loading = ref(false);
|
||||||
|
const searchKey = ref<string>('');
|
||||||
|
const containerList = ref<DockerInfo[]>([]);
|
||||||
|
const filteredContainerList = ref<DockerInfo[]>([]);
|
||||||
|
const FormValues = ref<Record<string, any>>({
|
||||||
|
hostId: '-1'
|
||||||
|
});
|
||||||
|
|
||||||
|
const handleInput = (value: string) => {
|
||||||
|
searchKey.value = value;
|
||||||
|
};
|
||||||
|
|
||||||
|
const onSearch = async () => {
|
||||||
|
await getDockerList();
|
||||||
|
if (!searchKey.value.trim()) {
|
||||||
|
filteredContainerList.value = [...containerList.value];
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const keyword = searchKey.value.toLowerCase();
|
||||||
|
const filtered = containerList.value.filter(item => {
|
||||||
|
return item.name?.toLowerCase().includes(keyword);
|
||||||
|
});
|
||||||
|
|
||||||
|
filteredContainerList.value = filtered;
|
||||||
|
};
|
||||||
|
|
||||||
|
const getDockerList = async () => {
|
||||||
|
try {
|
||||||
|
loading.value = true;
|
||||||
|
const params = {
|
||||||
|
... FormValues.value
|
||||||
|
};
|
||||||
|
const result = await bizDockerInfoList(params);
|
||||||
|
containerList.value = result || [];
|
||||||
|
filteredContainerList.value = [...containerList.value];
|
||||||
|
} catch (error) {
|
||||||
|
console.error('获取数据失败:', error);
|
||||||
|
containerList.value = [];
|
||||||
|
filteredContainerList.value = [];
|
||||||
|
} finally {
|
||||||
|
loading.value = false;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const handleRestart = async (item: DockerInfo) => {
|
||||||
|
Modal.confirm({
|
||||||
|
title: '温馨提示',
|
||||||
|
content: '您确定要重启当前容器吗?',
|
||||||
|
okText: '确认',
|
||||||
|
cancelText: '取消',
|
||||||
|
okType: 'danger',
|
||||||
|
width: 420,
|
||||||
|
onOk: async () => {
|
||||||
|
try {
|
||||||
|
const res = await bizDockerRestart(item);
|
||||||
|
createMessage.success(res.message);
|
||||||
|
onSearch();
|
||||||
|
} catch (error) {
|
||||||
|
console.error('重启容器失败:', error);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
onCancel: () => {
|
||||||
|
createMessage.info('已取消重启操作');
|
||||||
|
}
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
const handleStop = async (item: DockerInfo) => {
|
||||||
|
Modal.confirm({
|
||||||
|
title: '温馨提示',
|
||||||
|
content: '您确定要停止当前容器吗?',
|
||||||
|
okText: '确认',
|
||||||
|
cancelText: '取消',
|
||||||
|
okType: 'danger',
|
||||||
|
width: 420,
|
||||||
|
onOk: async () => {
|
||||||
|
try {
|
||||||
|
const res = await bizDockerStop(item);
|
||||||
|
createMessage.success(res.message);
|
||||||
|
onSearch();
|
||||||
|
} catch (error) {
|
||||||
|
console.error('停止容器失败:', error);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
onCancel: () => {
|
||||||
|
createMessage.info('已取消停止操作');
|
||||||
|
}
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
const handleStart = async (item: DockerInfo) => {
|
||||||
|
Modal.confirm({
|
||||||
|
title: '温馨提示',
|
||||||
|
content: '您确定要启动当前容器吗?',
|
||||||
|
okText: '确认',
|
||||||
|
cancelText: '取消',
|
||||||
|
okType: 'danger',
|
||||||
|
width: 420,
|
||||||
|
onOk: async () => {
|
||||||
|
try {
|
||||||
|
const res = await bizDockerStart(item);
|
||||||
|
createMessage.success(res.message);
|
||||||
|
onSearch();
|
||||||
|
} catch (error) {
|
||||||
|
console.error('启动容器失败:', error);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
onCancel: () => {
|
||||||
|
createMessage.info('已取消启动操作');
|
||||||
|
}
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
const [register, { closeModal }] = useModalInner(async (data: any) => {
|
||||||
|
if (!data?.hostId) {
|
||||||
|
closeModal();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
searchKey.value = ''; // 重置搜索关键词
|
||||||
|
FormValues.value.hostId = data.hostId;
|
||||||
|
await getDockerList();
|
||||||
|
});
|
||||||
|
|
||||||
|
return {
|
||||||
|
register,
|
||||||
|
onSearch,
|
||||||
|
handleInput,
|
||||||
|
closeModal,
|
||||||
|
loading,
|
||||||
|
searchKey,
|
||||||
|
containerList,
|
||||||
|
filteredContainerList,
|
||||||
|
handleRestart,
|
||||||
|
handleStop,
|
||||||
|
handleStart,
|
||||||
|
};
|
||||||
|
},
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style scoped>
|
||||||
|
/* 样式部分保持不变 */
|
||||||
|
.container-outer-wrapper {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
gap: 8px;
|
||||||
|
padding: 12px;
|
||||||
|
background-color: #f5f7fa;
|
||||||
|
border-radius: 12px;
|
||||||
|
height: calc(100vh - 320px);
|
||||||
|
box-sizing: border-box;
|
||||||
|
overflow: hidden;
|
||||||
|
}
|
||||||
|
|
||||||
|
.search-filter-header {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
padding: 4px 12px;
|
||||||
|
background: #fff;
|
||||||
|
border-bottom: 1px solid #d9e8f0;
|
||||||
|
position: sticky;
|
||||||
|
top: 0;
|
||||||
|
z-index: 10;
|
||||||
|
gap: 12px;
|
||||||
|
}
|
||||||
|
|
||||||
|
:deep(.ant-tabs-tab-active) {
|
||||||
|
background-color: #4096ff !important;
|
||||||
|
color: #fff !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
.content-scroll-container {
|
||||||
|
flex: 1;
|
||||||
|
overflow-y: auto;
|
||||||
|
padding: 2px 4px;
|
||||||
|
scrollbar-width: thin;
|
||||||
|
scrollbar-color: #4096ff #e8f4f8;
|
||||||
|
}
|
||||||
|
|
||||||
|
.content-scroll-container::-webkit-scrollbar { width: 8px; }
|
||||||
|
.content-scroll-container::-webkit-scrollbar-track { background: #e8f4f8; border-radius: 4px; }
|
||||||
|
.content-scroll-container::-webkit-scrollbar-thumb { background: #4096ff; border-radius: 4px; }
|
||||||
|
|
||||||
|
.container-card-list {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
gap: 12px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.single-container-card {
|
||||||
|
background: #fff;
|
||||||
|
border-radius: 8px;
|
||||||
|
box-shadow: 0 2px 8px rgba(0,0,0,0.08);
|
||||||
|
transition: all 0.3s;
|
||||||
|
}
|
||||||
|
.single-container-card:hover {
|
||||||
|
box-shadow: 0 4px 16px rgba(0,0,0,0.12);
|
||||||
|
transform: translateY(-1px);
|
||||||
|
}
|
||||||
|
|
||||||
|
.card-content-wrapper {
|
||||||
|
padding: 16px 20px;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
gap: 14px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.top-info-row {
|
||||||
|
display: flex;
|
||||||
|
justify-content: space-between;
|
||||||
|
align-items: center;
|
||||||
|
padding-bottom: 12px;
|
||||||
|
border-bottom: 1px solid #f0f7fb;
|
||||||
|
}
|
||||||
|
|
||||||
|
.left-name-status {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 16px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.container-name {
|
||||||
|
font-size: 18px;
|
||||||
|
font-weight: 600;
|
||||||
|
color: #1f2937;
|
||||||
|
margin: 0;
|
||||||
|
width: 180px;
|
||||||
|
white-space: nowrap;
|
||||||
|
overflow: hidden;
|
||||||
|
text-overflow: ellipsis;
|
||||||
|
cursor: pointer;
|
||||||
|
}
|
||||||
|
|
||||||
|
.right-resource-text {
|
||||||
|
display: flex;
|
||||||
|
gap: 20px;
|
||||||
|
font-size: 14px;
|
||||||
|
}
|
||||||
|
.cpu-text { color: #2f54eb; font-weight: 500; }
|
||||||
|
.mem-text { color: #1890ff; font-weight: 500; }
|
||||||
|
|
||||||
|
.detail-info-group {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 16px;
|
||||||
|
font-size: 14px;
|
||||||
|
flex-wrap: nowrap;
|
||||||
|
overflow: hidden;
|
||||||
|
white-space: nowrap;
|
||||||
|
}
|
||||||
|
|
||||||
|
.info-item {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
flex-shrink: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.info-item .label {
|
||||||
|
color: #667085;
|
||||||
|
margin-right: 4px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.info-item .value {
|
||||||
|
color: #344054;
|
||||||
|
max-width: 200px;
|
||||||
|
white-space: nowrap;
|
||||||
|
overflow: hidden;
|
||||||
|
text-overflow: ellipsis;
|
||||||
|
cursor: pointer;
|
||||||
|
}
|
||||||
|
|
||||||
|
.action-divider {
|
||||||
|
width: 100%;
|
||||||
|
height: 1px;
|
||||||
|
background-color: #f0f7fb;
|
||||||
|
margin: 4px 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.action-button-section {
|
||||||
|
display: flex;
|
||||||
|
justify-content: flex-end;
|
||||||
|
padding-top: 2px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.action-button-section :deep(.ant-btn) {
|
||||||
|
padding: 4px 12px;
|
||||||
|
font-size: 12px;
|
||||||
|
height: 28px;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* 无结果提示样式 */
|
||||||
|
.no-result {
|
||||||
|
text-align: center;
|
||||||
|
padding: 40px 0;
|
||||||
|
color: #667085;
|
||||||
|
font-size: 14px;
|
||||||
|
}
|
||||||
|
|
||||||
|
@media (max-width: 768px) {
|
||||||
|
.top-info-row {
|
||||||
|
flex-direction: column;
|
||||||
|
align-items: flex-start;
|
||||||
|
gap: 10px;
|
||||||
|
}
|
||||||
|
.detail-info-group {
|
||||||
|
flex-direction: column;
|
||||||
|
align-items: flex-start;
|
||||||
|
gap: 8px;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</style>
|
||||||
@@ -36,15 +36,13 @@ const chartDom = ref<HTMLDivElement | null>(null);
|
|||||||
const statusOptions = ref([
|
const statusOptions = ref([
|
||||||
{ value: '-12', label: '12小时' },
|
{ value: '-12', label: '12小时' },
|
||||||
{ value: '-24', label: '24小时' },
|
{ value: '-24', label: '24小时' },
|
||||||
{ value: '-36', label: '36小时' },
|
{ value: '-48', label: '48小时' },
|
||||||
{ value: '-72', label: '72小时' },
|
{ value: '-72', label: '72小时' },
|
||||||
]);
|
]);
|
||||||
const currentStatus = ref<string>('-12');
|
const currentStatus = ref<string>('-12');
|
||||||
|
|
||||||
// 防抖处理resize,避免频繁触发
|
|
||||||
const resizeHandler = () => {
|
const resizeHandler = () => {
|
||||||
if (chartInstance.value) {
|
if (chartInstance.value) {
|
||||||
// 使用nextTick确保DOM更新完成后再调整大小
|
|
||||||
nextTick(() => {
|
nextTick(() => {
|
||||||
chartInstance.value?.resize({
|
chartInstance.value?.resize({
|
||||||
animation: { duration: 200 }
|
animation: { duration: 200 }
|
||||||
|
|||||||
@@ -1,103 +0,0 @@
|
|||||||
<!--
|
|
||||||
* Copyright (c) 2013-Now http://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 { bizTableInfoImportData } from '@jeesite/biz/api/biz/tableInfo';
|
|
||||||
import { FileType } from 'ant-design-vue/es/upload/interface';
|
|
||||||
import { AxiosProgressEvent } from 'axios';
|
|
||||||
|
|
||||||
const emit = defineEmits(['success', 'register']);
|
|
||||||
|
|
||||||
const { t } = useI18n('biz.tableInfo');
|
|
||||||
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/tableInfo/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 bizTableInfoImportData(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,262 +0,0 @@
|
|||||||
<!--
|
|
||||||
* Copyright (c) 2013-Now http://jeesite.com All rights reserved.
|
|
||||||
* No deletion without permission, or be held responsible to law.
|
|
||||||
* @author gaoxq
|
|
||||||
-->
|
|
||||||
<template>
|
|
||||||
<div>
|
|
||||||
<BasicTable @register="registerTable">
|
|
||||||
<template #toolbar>
|
|
||||||
<a-button type="default" :loading="loading" @click="handleExport()">
|
|
||||||
<Icon icon="i-ant-design:download-outlined" /> {{ t('导出') }}
|
|
||||||
</a-button>
|
|
||||||
</template>
|
|
||||||
</BasicTable>
|
|
||||||
<FormImport @register="registerImportModal" @success="handleSuccess" />
|
|
||||||
</div>
|
|
||||||
</template>
|
|
||||||
<script lang="ts" setup name="ViewsBizTableInfoList">
|
|
||||||
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 { BizTableInfo, bizTableInfoList } from '@jeesite/biz/api/biz/tableInfo';
|
|
||||||
import { bizTableInfoDelete, bizTableInfoListData } from '@jeesite/biz/api/biz/tableInfo';
|
|
||||||
import { useDrawer } from '@jeesite/core/components/Drawer';
|
|
||||||
import { useModal } from '@jeesite/core/components/Modal';
|
|
||||||
import { FormProps } from '@jeesite/core/components/Form';
|
|
||||||
import FormImport from './formImport.vue';
|
|
||||||
|
|
||||||
const { t } = useI18n('biz.tableInfo');
|
|
||||||
const { showMessage } = useMessage();
|
|
||||||
const { meta } = unref(router.currentRoute);
|
|
||||||
const record = ref<BizTableInfo>({} as BizTableInfo);
|
|
||||||
const loading = ref(false);
|
|
||||||
|
|
||||||
const searchForm: FormProps<BizTableInfo> = {
|
|
||||||
baseColProps: { md: 8, lg: 6 },
|
|
||||||
labelWidth: 90,
|
|
||||||
schemas: [
|
|
||||||
{
|
|
||||||
label: t('记录时间起'),
|
|
||||||
field: 'createTime_gte',
|
|
||||||
component: 'DatePicker',
|
|
||||||
componentProps: {
|
|
||||||
format: 'YYYY-MM-DD HH:mm',
|
|
||||||
showTime: { format: 'HH:mm' },
|
|
||||||
},
|
|
||||||
},
|
|
||||||
{
|
|
||||||
label: t('记录时间止'),
|
|
||||||
field: 'createTime_lte',
|
|
||||||
component: 'DatePicker',
|
|
||||||
componentProps: {
|
|
||||||
format: 'YYYY-MM-DD HH:mm',
|
|
||||||
showTime: { format: 'HH:mm' },
|
|
||||||
},
|
|
||||||
},
|
|
||||||
{
|
|
||||||
label: t('数据表名称'),
|
|
||||||
field: 'dataName',
|
|
||||||
component: 'Input',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
label: t('数据表描述'),
|
|
||||||
field: 'tableComment',
|
|
||||||
component: 'Input',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
label: t('数据库名称'),
|
|
||||||
field: 'dbId',
|
|
||||||
fieldLabel: 'dbName',
|
|
||||||
component: 'ListSelect',
|
|
||||||
componentProps: {
|
|
||||||
selectType: 'bizDbSelect',
|
|
||||||
},
|
|
||||||
},
|
|
||||||
{
|
|
||||||
label: t('数据来源'),
|
|
||||||
field: 'dataSource',
|
|
||||||
component: 'Input',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
label: t('备注信息'),
|
|
||||||
field: 'remarks',
|
|
||||||
component: 'Input',
|
|
||||||
},
|
|
||||||
],
|
|
||||||
};
|
|
||||||
|
|
||||||
const tableColumns: BasicColumn<BizTableInfo>[] = [
|
|
||||||
{
|
|
||||||
title: t('记录时间'),
|
|
||||||
dataIndex: 'createTime',
|
|
||||||
key: 'a.create_time',
|
|
||||||
sorter: true,
|
|
||||||
width: 180,
|
|
||||||
align: 'left',
|
|
||||||
fixed: 'left',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
title: t('数据库名称'),
|
|
||||||
dataIndex: 'dbName',
|
|
||||||
key: 'b.db_name',
|
|
||||||
sorter: true,
|
|
||||||
width: 200,
|
|
||||||
align: 'left',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
title: t('数据库IP'),
|
|
||||||
dataIndex: 'dbIp',
|
|
||||||
key: 'b.db_ip',
|
|
||||||
sorter: true,
|
|
||||||
width: 200,
|
|
||||||
align: 'left',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
title: t('数据表名称'),
|
|
||||||
dataIndex: 'dataName',
|
|
||||||
key: 'a.data_name',
|
|
||||||
sorter: true,
|
|
||||||
width: 200,
|
|
||||||
align: 'left',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
title: t('数据表描述'),
|
|
||||||
dataIndex: 'tableComment',
|
|
||||||
key: 'a.table_comment',
|
|
||||||
sorter: true,
|
|
||||||
width: 225,
|
|
||||||
align: 'left',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
title: t('数据表大小'),
|
|
||||||
dataIndex: 'tableSize',
|
|
||||||
key: 'a.table_size',
|
|
||||||
sorter: true,
|
|
||||||
width: 130,
|
|
||||||
align: 'right',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
title: t('数据来源'),
|
|
||||||
dataIndex: 'dataSource',
|
|
||||||
key: 'a.data_source',
|
|
||||||
sorter: true,
|
|
||||||
width: 130,
|
|
||||||
align: 'left',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
title: t('创建人员'),
|
|
||||||
dataIndex: 'creator',
|
|
||||||
key: 'a.creator',
|
|
||||||
sorter: true,
|
|
||||||
width: 130,
|
|
||||||
align: 'left',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
title: t('记录条数'),
|
|
||||||
dataIndex: 'dataRows',
|
|
||||||
key: 'a.data_rows',
|
|
||||||
sorter: true,
|
|
||||||
width: 130,
|
|
||||||
align: 'center',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
title: t('更新时间'),
|
|
||||||
dataIndex: 'updateTime',
|
|
||||||
key: 'a.update_time',
|
|
||||||
sorter: true,
|
|
||||||
width: 180,
|
|
||||||
align: 'center',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
title: t('备注信息'),
|
|
||||||
dataIndex: 'remarks',
|
|
||||||
key: 'a.remarks',
|
|
||||||
sorter: true,
|
|
||||||
width: 130,
|
|
||||||
align: 'left',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
title: t('分区日期'),
|
|
||||||
dataIndex: 'ds',
|
|
||||||
key: 'a.ds',
|
|
||||||
sorter: true,
|
|
||||||
width: 130,
|
|
||||||
align: 'left',
|
|
||||||
},
|
|
||||||
];
|
|
||||||
|
|
||||||
const actionColumn: BasicColumn<BizTableInfo> = {
|
|
||||||
width: 160,
|
|
||||||
align: 'center',
|
|
||||||
actions: (record: BizTableInfo) => [
|
|
||||||
{
|
|
||||||
icon: 'i-ant-design:delete-outlined',
|
|
||||||
color: 'error',
|
|
||||||
title: t('删除'),
|
|
||||||
popConfirm: {
|
|
||||||
title: t('是否确认删除数据信息?'),
|
|
||||||
confirm: handleDelete.bind(this, record),
|
|
||||||
},
|
|
||||||
auth: 'biz:tableInfo:edit',
|
|
||||||
},
|
|
||||||
],
|
|
||||||
};
|
|
||||||
|
|
||||||
const [registerTable, { reload, getForm }] = useTable<BizTableInfo>({
|
|
||||||
api: bizTableInfoListData,
|
|
||||||
beforeFetch: (params) => {
|
|
||||||
return params;
|
|
||||||
},
|
|
||||||
columns: tableColumns,
|
|
||||||
actionColumn: actionColumn,
|
|
||||||
formConfig: searchForm,
|
|
||||||
showTableSetting: true,
|
|
||||||
useSearchForm: true,
|
|
||||||
canResize: true,
|
|
||||||
});
|
|
||||||
|
|
||||||
onMounted(async () => {
|
|
||||||
const res = await bizTableInfoList();
|
|
||||||
record.value = (res.bizTableInfo || {}) as BizTableInfo;
|
|
||||||
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/tableInfo/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 bizTableInfoDelete(params);
|
|
||||||
showMessage(res.message);
|
|
||||||
await handleSuccess(record);
|
|
||||||
}
|
|
||||||
|
|
||||||
async function handleSuccess(record: Recordable) {
|
|
||||||
await reload({ record });
|
|
||||||
}
|
|
||||||
</script>
|
|
||||||
@@ -11,9 +11,6 @@
|
|||||||
<TabPane key="3" tab="文件管理">
|
<TabPane key="3" tab="文件管理">
|
||||||
<MyfileInfo />
|
<MyfileInfo />
|
||||||
</TabPane>
|
</TabPane>
|
||||||
<TabPane key="4" tab="字典管理">
|
|
||||||
<TableInfo />
|
|
||||||
</TabPane>
|
|
||||||
</Tabs>
|
</Tabs>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
@@ -23,7 +20,6 @@
|
|||||||
import { Tag, Tabs, TabPane } from 'ant-design-vue';
|
import { Tag, Tabs, TabPane } from 'ant-design-vue';
|
||||||
import MySchedule from './components/MySchedule.vue';
|
import MySchedule from './components/MySchedule.vue';
|
||||||
import Calendar from './components/calendar/list.vue';
|
import Calendar from './components/calendar/list.vue';
|
||||||
import TableInfo from './components/tableInfo/list.vue';
|
|
||||||
import ItemsInfo from './components/listItem/list.vue';
|
import ItemsInfo from './components/listItem/list.vue';
|
||||||
import MyfileInfo from './components/myfiles/index.vue';
|
import MyfileInfo from './components/myfiles/index.vue';
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user