feat:对接ACS容器和虚拟机
This commit is contained in:
@@ -217,30 +217,36 @@
|
||||
<div class="time-info">{{ scope.row.become_time }}</div>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="规格" prop="plan_id" width="80" />
|
||||
<el-table-column label="规格" prop="plan_name" width="80" />
|
||||
<el-table-column label="用户ID" prop="user_id" width="80" />
|
||||
<el-table-column label="状态" width="100" align="center">
|
||||
<template #default="scope">
|
||||
<el-tag
|
||||
:type="scope.row.container_state == 0 || scope.row.container_state == 1
|
||||
? 'info'
|
||||
: scope.row.container_state == 2
|
||||
? 'danger'
|
||||
: scope.row.container_state == 3
|
||||
? 'danger'
|
||||
: 'success'"
|
||||
:type="scope.row.container_state == 0
|
||||
? 'warning'
|
||||
: scope.row.container_state == 1
|
||||
? 'info'
|
||||
: scope.row.container_state == 2
|
||||
? 'success'
|
||||
: scope.row.container_state == 3
|
||||
? 'info'
|
||||
: scope.row.container_state == 4
|
||||
? 'danger'
|
||||
: 'info'"
|
||||
effect="light"
|
||||
>
|
||||
{{
|
||||
scope.row.container_state == 0
|
||||
? "未构建"
|
||||
? "未支付"
|
||||
: scope.row.container_state == 1
|
||||
? "已构建"
|
||||
? "未构建"
|
||||
: scope.row.container_state == 2
|
||||
? "构建失败"
|
||||
? "已构建"
|
||||
: scope.row.container_state == 3
|
||||
? "已删除"
|
||||
: "未知状态"
|
||||
? "未知"
|
||||
: scope.row.container_state == 4
|
||||
? "已删除"
|
||||
: "未知状态"
|
||||
}}
|
||||
</el-tag>
|
||||
</template>
|
||||
@@ -251,7 +257,7 @@
|
||||
type="primary"
|
||||
size="small"
|
||||
:icon="Setting"
|
||||
@click="$router.push('/servers/containers?container_id=' + scope.row.container_id)"
|
||||
@click="$router.push('/servers/container?container_id=' + scope.row.container_id)"
|
||||
>
|
||||
管理
|
||||
</el-button>
|
||||
@@ -610,7 +616,8 @@ import {
|
||||
getFloatingIpList,
|
||||
addFloatingIp,
|
||||
delFloatingIp,
|
||||
addFloatingIpBatch
|
||||
addFloatingIpBatch,
|
||||
selectServerPlan
|
||||
} from "@/utils/acs/server";
|
||||
import { ElMessage, ElNotification } from 'element-plus';
|
||||
import { copyDomText } from "@/utils/hide";
|
||||
@@ -671,31 +678,43 @@ const initData = async () => {
|
||||
try {
|
||||
const userInfoRes = await getUserInfo();
|
||||
console.log("获取用户信息", userInfoRes);
|
||||
if (userInfoRes && userInfoRes.data && userInfoRes.data.data) {
|
||||
// 根据API返回的用户信息设置用户类型
|
||||
const userType = userInfoRes.data.is_admin == true ? "1" : "0";
|
||||
localStorage.setItem("user_id", userInfoRes.real_name.UserId);
|
||||
localStorage.setItem("user_type", userType);
|
||||
console.log("获取到用户类型", userType);
|
||||
if (userInfoRes && userInfoRes.data ) {
|
||||
console.log("获取用户信息", userInfoRes);
|
||||
localStorage.setItem("user_id", userInfoRes.data.user_id);
|
||||
}
|
||||
} catch (error) {
|
||||
console.error("获取用户信息失败:", error);
|
||||
// 如果获取失败,默认设置为管理员权限确保功能可用
|
||||
localStorage.setItem("user_type", "1");
|
||||
}
|
||||
|
||||
// 获取所有容器
|
||||
let usertype = localStorage.getItem("user_type");
|
||||
console.log("用户类型", usertype);
|
||||
if (usertype == "1") {
|
||||
containerBox.server_id = route.query.server_id;
|
||||
containerBox.user_id = localStorage.getItem("user_id");
|
||||
let cons = await getContainer(containerBox);
|
||||
console.log("获取容器列表", cons);
|
||||
if (cons && cons.data) {
|
||||
user_servers.value = cons.data.data || [];
|
||||
// user_servers.value = cons.data.data.forEach(async item => {
|
||||
// item.plan_name = await selectServerPlan({
|
||||
// server_type: 'dockerContainer',
|
||||
// plan_id: item.plan_id
|
||||
// })
|
||||
// }
|
||||
// )
|
||||
for (const item of user_servers.value){
|
||||
try{
|
||||
const res = await selectServerPlan({
|
||||
server_type: 'dockerContainer',
|
||||
plan_id: item.plan_id
|
||||
})
|
||||
console.log("获取容器规格:", res);
|
||||
item.plan_name = res.data.data.name;
|
||||
}catch(error){
|
||||
console.error("获取容器列表失败:", error);
|
||||
ElMessage.error("获取容器列表失败");
|
||||
}
|
||||
}
|
||||
console.log("获取容器列表", user_servers.value);
|
||||
total.value = cons.data.count || 0;
|
||||
}
|
||||
}
|
||||
} catch (error) {
|
||||
console.error("初始化数据失败:", error);
|
||||
ElMessage.error("加载数据失败,请刷新页面重试");
|
||||
@@ -727,7 +746,6 @@ const GetSpecs = async () => {
|
||||
server_id: route.query.server_id,
|
||||
count: 30
|
||||
});
|
||||
console.log("服务器实例规格", plans.data.data);
|
||||
spec_list.value = plans.data.data;
|
||||
} catch (error) {
|
||||
console.error("获取实例规格列表失败:", error);
|
||||
@@ -929,8 +947,9 @@ const editSpec = async () => {
|
||||
server_id: route.query.server_id,
|
||||
server_type:TypeData.value
|
||||
});
|
||||
console.log("添加实例规格:",res)
|
||||
|
||||
if (res.code == 200) {
|
||||
if (res.data.code == 200) {
|
||||
ElNotification({
|
||||
title: '添加成功',
|
||||
message: `已成功添加规格 "${spec_form.name}"`,
|
||||
@@ -939,7 +958,7 @@ const editSpec = async () => {
|
||||
});
|
||||
centerDialogVisible.value = false;
|
||||
} else {
|
||||
ElMessage.error(res.data.message || "添加失败");
|
||||
ElMessage.error(res.data.msg || "添加失败");
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user