更新若干
This commit is contained in:
1 parent
54c90072fb
commit
5682069553
59 files changed
+3813
-1617
No files matched your search
@@ -0,0 +1,351 @@
|
||||
<template>
|
||||
<div class="container-box storage-page">
|
||||
<div class="header-bar">
|
||||
<h2>存储空间</h2>
|
||||
<div class="header-actions">
|
||||
<el-button @click="loadOrders"><el-icon><Refresh /></el-icon>刷新订单</el-button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<el-alert
|
||||
type="info"
|
||||
:closable="false"
|
||||
show-icon
|
||||
class="tips"
|
||||
title="查看并调整各租户的附件空间。租户实际可用空间 = max(基础额度, 已生效扩容套餐容量)。扩容套餐的维护在「基础设置 → 存储套餐」。"
|
||||
/>
|
||||
|
||||
<div class="panel">
|
||||
<div class="panel-head">
|
||||
<h3>租户存储额度</h3>
|
||||
<span class="tip">输入租户 ID 查询用量,可直接调整基础额度</span>
|
||||
</div>
|
||||
<div class="query-bar">
|
||||
<el-input
|
||||
v-model="tidInput"
|
||||
type="number"
|
||||
placeholder="请输入租户 ID"
|
||||
clearable
|
||||
style="width: 220px"
|
||||
@keyup.enter="queryTenant"
|
||||
/>
|
||||
<el-button type="primary" @click="queryTenant">查询</el-button>
|
||||
</div>
|
||||
|
||||
<div v-if="tenantLoading" v-loading="tenantLoading" class="tenant-placeholder"></div>
|
||||
|
||||
<template v-else-if="info && info.tid">
|
||||
<div class="usage-row">
|
||||
<span class="used">{{ formatSize(info.used_bytes) }}</span>
|
||||
<span class="total">/ {{ formatSize(info.quota_bytes) }}</span>
|
||||
<el-tag size="small" type="info" effect="plain">已用 {{ info.used_percent || 0 }}%</el-tag>
|
||||
</div>
|
||||
<el-progress
|
||||
:percentage="progressPercent"
|
||||
:status="progressStatus"
|
||||
:stroke-width="10"
|
||||
:format="() => `${progressPercent}%`"
|
||||
/>
|
||||
<div class="usage-foot">
|
||||
<span>基础额度 {{ info.base_quota_mb }} MB</span>
|
||||
<span v-if="info.package_quota_mb">· 套餐 {{ info.package_name }} {{ formatCapacity(info.package_quota_mb) }}(剩 {{ info.days_remaining }} 天)</span>
|
||||
<span>· 剩余 {{ formatSize(info.remaining_bytes) }}</span>
|
||||
</div>
|
||||
|
||||
<div class="quota-edit">
|
||||
<span class="label">调整基础额度</span>
|
||||
<el-input-number v-model="quotaInput" :min="0" :max="1024 * 1024" :step="100" controls-position="right" />
|
||||
<span class="unit">MB(0 = 恢复默认 {{ 500 }}MB)</span>
|
||||
<el-button type="primary" :loading="quotaSaving" @click="saveQuota">保存</el-button>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<el-empty v-else description="请输入租户 ID 查询存储用量" />
|
||||
</div>
|
||||
|
||||
<div class="panel">
|
||||
<div class="panel-head">
|
||||
<h3>存储购买订单</h3>
|
||||
<div class="order-filter">
|
||||
<el-select v-model="orderStatus" placeholder="状态" clearable style="width: 130px" @change="loadOrders">
|
||||
<el-option label="待支付" value="pending" />
|
||||
<el-option label="已支付" value="paid" />
|
||||
<el-option label="已取消" value="cancelled" />
|
||||
<el-option label="已替换" value="replaced" />
|
||||
</el-select>
|
||||
</div>
|
||||
</div>
|
||||
<el-table :data="orders" v-loading="ordersLoading" size="small" border stripe>
|
||||
<el-table-column prop="order_no" label="订单号" min-width="180" show-overflow-tooltip />
|
||||
<el-table-column prop="tid" label="租户ID" width="90" align="center" />
|
||||
<el-table-column prop="package_name" label="套餐" min-width="120" />
|
||||
<el-table-column label="容量" width="100" align="center">
|
||||
<template #default="{ row }">{{ formatCapacity(row.capacity_mb) }}</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="金额" width="100" align="center">
|
||||
<template #default="{ row }">¥{{ Number(row.amount || 0).toFixed(2) }}</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="状态" width="100" align="center">
|
||||
<template #default="{ row }">
|
||||
<el-tag size="small" :type="orderStatusType(row.status)">{{ orderStatusText(row.status) }}</el-tag>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="有效期" min-width="190" align="center">
|
||||
<template #default="{ row }">
|
||||
<span v-if="row.start_time && row.end_time">{{ formatDate(row.start_time) }} ~ {{ formatDate(row.end_time) }}</span>
|
||||
<span v-else>-</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="create_time" label="下单时间" min-width="160" align="center">
|
||||
<template #default="{ row }">{{ formatDate(row.create_time) }}</template>
|
||||
</el-table-column>
|
||||
<template #empty><el-empty description="暂无存储订单" /></template>
|
||||
</el-table>
|
||||
<div class="pagination-bar">
|
||||
<el-pagination
|
||||
:current-page="orderPage"
|
||||
:page-size="orderPageSize"
|
||||
:total="orderTotal"
|
||||
@current-change="handleOrderPage"
|
||||
layout="total, prev, pager, next"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { computed, onMounted, ref } from "vue";
|
||||
import { ElMessage } from "element-plus";
|
||||
import { Refresh } from "@element-plus/icons-vue";
|
||||
import {
|
||||
getTenantStorageInfo,
|
||||
getStorageOrders,
|
||||
updateTenantStorageQuota,
|
||||
} from "@/api/storage";
|
||||
|
||||
const tidInput = ref<string>("");
|
||||
const tenantLoading = ref(false);
|
||||
const info = ref<Record<string, any>>({});
|
||||
const quotaInput = ref<number>(500);
|
||||
const quotaSaving = ref(false);
|
||||
|
||||
const orders = ref<any[]>([]);
|
||||
const ordersLoading = ref(false);
|
||||
const orderStatus = ref("");
|
||||
const orderPage = ref(1);
|
||||
const orderPageSize = ref(10);
|
||||
const orderTotal = ref(0);
|
||||
|
||||
const progressPercent = computed(() => {
|
||||
const p = Number(info.value.used_percent) || 0;
|
||||
return Math.min(100, Math.max(0, Math.round(p * 10) / 10));
|
||||
});
|
||||
|
||||
const progressStatus = computed(() => {
|
||||
const p = progressPercent.value;
|
||||
if (p >= 95) return "exception";
|
||||
if (p >= 80) return "warning";
|
||||
return "";
|
||||
});
|
||||
|
||||
const formatSize = (bytes: any) => {
|
||||
const n = Number(bytes) || 0;
|
||||
if (n >= 1024 ** 3) return `${(n / 1024 ** 3).toFixed(2)} GB`;
|
||||
if (n >= 1024 ** 2) return `${(n / 1024 ** 2).toFixed(1)} MB`;
|
||||
if (n >= 1024) return `${(n / 1024).toFixed(1)} KB`;
|
||||
return `${n} B`;
|
||||
};
|
||||
|
||||
const formatCapacity = (mb: any) => {
|
||||
const n = Number(mb) || 0;
|
||||
return n >= 1024 ? `${(n / 1024).toFixed(n % 1024 === 0 ? 0 : 1)} GB` : `${n} MB`;
|
||||
};
|
||||
|
||||
const formatDate = (value: any) => {
|
||||
if (!value) return "-";
|
||||
const d = new Date(value);
|
||||
if (Number.isNaN(d.getTime())) return String(value).slice(0, 19).replace("T", " ");
|
||||
return `${d.getFullYear()}-${String(d.getMonth() + 1).padStart(2, "0")}-${String(d.getDate()).padStart(2, "0")}`;
|
||||
};
|
||||
|
||||
const orderStatusText = (s: string) =>
|
||||
({ pending: "待支付", paid: "已支付", cancelled: "已取消", replaced: "已替换" }[s] || s);
|
||||
const orderStatusType = (s: string) =>
|
||||
({ pending: "warning", paid: "success", cancelled: "info", replaced: "info" }[s] || "info");
|
||||
|
||||
const queryTenant = async () => {
|
||||
const tid = Number(tidInput.value || 0);
|
||||
if (!tid || tid <= 0) {
|
||||
ElMessage.warning("请输入有效的租户 ID");
|
||||
return;
|
||||
}
|
||||
tenantLoading.value = true;
|
||||
try {
|
||||
const res = await getTenantStorageInfo(tid);
|
||||
if (res?.code === 200) {
|
||||
info.value = res.data || {};
|
||||
quotaInput.value = Number(info.value.base_quota_mb || 500);
|
||||
} else {
|
||||
info.value = {};
|
||||
ElMessage.error(res?.msg || "查询失败");
|
||||
}
|
||||
} catch (e: any) {
|
||||
info.value = {};
|
||||
ElMessage.error(e?.message || "查询失败");
|
||||
} finally {
|
||||
tenantLoading.value = false;
|
||||
}
|
||||
};
|
||||
|
||||
const saveQuota = async () => {
|
||||
const tid = Number(info.value.tid || 0);
|
||||
if (!tid) return;
|
||||
quotaSaving.value = true;
|
||||
try {
|
||||
const res = await updateTenantStorageQuota(tid, Number(quotaInput.value || 0));
|
||||
if (res?.code === 200) {
|
||||
info.value = res.data || info.value;
|
||||
ElMessage.success("基础额度已更新");
|
||||
} else {
|
||||
ElMessage.error(res?.msg || "保存失败");
|
||||
}
|
||||
} catch (e: any) {
|
||||
ElMessage.error(e?.message || "保存失败");
|
||||
} finally {
|
||||
quotaSaving.value = false;
|
||||
}
|
||||
};
|
||||
|
||||
const loadOrders = async () => {
|
||||
ordersLoading.value = true;
|
||||
try {
|
||||
const res = await getStorageOrders({
|
||||
page: orderPage.value,
|
||||
pageSize: orderPageSize.value,
|
||||
status: orderStatus.value || undefined,
|
||||
});
|
||||
if (res?.code === 200) {
|
||||
orders.value = res.data?.list || [];
|
||||
orderTotal.value = Number(res.data?.total || 0);
|
||||
}
|
||||
} catch {
|
||||
orders.value = [];
|
||||
} finally {
|
||||
ordersLoading.value = false;
|
||||
}
|
||||
};
|
||||
|
||||
const handleOrderPage = (val: number) => {
|
||||
orderPage.value = val;
|
||||
loadOrders();
|
||||
};
|
||||
|
||||
onMounted(() => {
|
||||
loadOrders();
|
||||
});
|
||||
</script>
|
||||
|
||||
<style scoped lang="less">
|
||||
.storage-page {
|
||||
.tips {
|
||||
margin-bottom: 16px;
|
||||
}
|
||||
|
||||
.panel {
|
||||
padding: 18px 20px;
|
||||
margin-bottom: 18px;
|
||||
border: 1px solid var(--el-border-color-lighter);
|
||||
border-radius: 12px;
|
||||
background: var(--el-bg-color);
|
||||
}
|
||||
|
||||
.panel-head {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
margin-bottom: 16px;
|
||||
|
||||
h3 {
|
||||
margin: 0;
|
||||
font-size: 16px;
|
||||
font-weight: 600;
|
||||
color: var(--el-text-color-primary);
|
||||
}
|
||||
|
||||
.tip {
|
||||
font-size: 12px;
|
||||
color: var(--el-text-color-secondary);
|
||||
}
|
||||
}
|
||||
|
||||
.query-bar {
|
||||
display: flex;
|
||||
gap: 10px;
|
||||
margin-bottom: 18px;
|
||||
}
|
||||
|
||||
.tenant-placeholder {
|
||||
min-height: 60px;
|
||||
}
|
||||
|
||||
.usage-row {
|
||||
display: flex;
|
||||
align-items: baseline;
|
||||
gap: 8px;
|
||||
margin-bottom: 10px;
|
||||
|
||||
.used {
|
||||
font-size: 26px;
|
||||
font-weight: 700;
|
||||
color: var(--el-text-color-primary);
|
||||
}
|
||||
|
||||
.total {
|
||||
font-size: 14px;
|
||||
color: var(--el-text-color-secondary);
|
||||
}
|
||||
}
|
||||
|
||||
.usage-foot {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 6px;
|
||||
margin-top: 10px;
|
||||
font-size: 12px;
|
||||
color: var(--el-text-color-secondary);
|
||||
}
|
||||
|
||||
.quota-edit {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
flex-wrap: wrap;
|
||||
gap: 10px;
|
||||
margin-top: 20px;
|
||||
padding-top: 18px;
|
||||
border-top: 1px solid var(--el-border-color-lighter);
|
||||
|
||||
.label {
|
||||
font-size: 14px;
|
||||
font-weight: 600;
|
||||
color: var(--el-text-color-primary);
|
||||
}
|
||||
|
||||
.unit {
|
||||
font-size: 12px;
|
||||
color: var(--el-text-color-secondary);
|
||||
}
|
||||
}
|
||||
|
||||
.order-filter {
|
||||
display: flex;
|
||||
gap: 10px;
|
||||
}
|
||||
|
||||
.pagination-bar {
|
||||
display: flex;
|
||||
justify-content: flex-end;
|
||||
margin-top: 14px;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -115,6 +115,11 @@
|
||||
<span class="field-tip">关闭后每个租户仅可购买一次(体验套餐),已购买过则无法再次下单</span>
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item label="允许租户购买" prop="can_purchase">
|
||||
<el-switch v-model="form.can_purchase" :active-value="1" :inactive-value="0" />
|
||||
<span class="field-tip">关闭后该套餐不会出现在租户端购买列表,仅可由平台后台为租户指派</span>
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item label="状态" prop="status">
|
||||
<el-radio-group v-model="form.status">
|
||||
<el-radio :label="1">启用</el-radio>
|
||||
@@ -174,6 +179,7 @@ const emptyForm = () => ({
|
||||
extra_user_price: 200,
|
||||
is_default: 0,
|
||||
allow_repurchase: 1,
|
||||
can_purchase: 1,
|
||||
sort: 0,
|
||||
status: 1,
|
||||
remark: "",
|
||||
@@ -254,6 +260,7 @@ const loadDetail = async (id: number) => {
|
||||
extra_user_price: Number(d.extra_user_price || 0),
|
||||
is_default: Number(d.is_default || 0),
|
||||
allow_repurchase: Number(d.allow_repurchase ?? 1),
|
||||
can_purchase: Number(d.can_purchase ?? 1),
|
||||
sort: Number(d.sort || 0),
|
||||
status: Number(d.status ?? 1),
|
||||
remark: d.remark || "",
|
||||
|
||||
@@ -90,6 +90,17 @@
|
||||
</el-tag>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="购买方式" width="110" align="center">
|
||||
<template #default="{ row }">
|
||||
<el-tag
|
||||
size="small"
|
||||
:type="Number(row.can_purchase) === 0 ? 'warning' : 'success'"
|
||||
effect="plain"
|
||||
>
|
||||
{{ Number(row.can_purchase) === 0 ? "后台指派" : "租户购买" }}
|
||||
</el-tag>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="sort" label="排序" width="80" align="center" />
|
||||
<el-table-column prop="status" label="状态" width="80" align="center">
|
||||
<template #default="{ row }">
|
||||
|
||||
@@ -123,6 +123,18 @@
|
||||
</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="存储用量" min-width="180" align="center">
|
||||
<template #default="scope">
|
||||
<div class="storage-cell">
|
||||
<el-progress
|
||||
:percentage="storagePercent(scope.row)"
|
||||
:color="storageColor(scope.row)"
|
||||
:stroke-width="8"
|
||||
:format="() => storageText(scope.row)"
|
||||
/>
|
||||
</div>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="status" label="租户状态" width="90" align="center" fixed="right">
|
||||
<template #default="scope">
|
||||
<el-tag :type="scope.row.status === 1 ? 'success' : 'danger'">{{
|
||||
@@ -218,6 +230,29 @@ const handlePageChange = (val: number) => {
|
||||
refresh();
|
||||
};
|
||||
|
||||
const formatMB = (mb: number) => {
|
||||
const v = Number(mb || 0);
|
||||
return v >= 1024 ? `${(v / 1024).toFixed(2)} GB` : `${v.toFixed(1)} MB`;
|
||||
};
|
||||
|
||||
const storagePercent = (row: any) => {
|
||||
const p = Number(row.storage_percent || 0);
|
||||
return Math.max(0, Math.min(100, p));
|
||||
};
|
||||
|
||||
const storageColor = (row: any) => {
|
||||
const p = storagePercent(row);
|
||||
if (p >= 85) return "#f56c6c";
|
||||
if (p >= 60) return "#e6a23c";
|
||||
return "#67c23a";
|
||||
};
|
||||
|
||||
const storageText = (row: any) => {
|
||||
const used = Number(row.storage_used_mb || 0);
|
||||
const quota = Number(row.storage_quota_mb || 0);
|
||||
return `${formatMB(used)} / ${formatMB(quota)}`;
|
||||
};
|
||||
|
||||
const searchForm = reactive({
|
||||
tenant_name: "",
|
||||
tenant_code: "",
|
||||
@@ -297,6 +332,17 @@ onMounted(() => {
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
.storage-cell {
|
||||
padding: 0 6px;
|
||||
:deep(.el-progress) {
|
||||
line-height: 1;
|
||||
}
|
||||
:deep(.el-progress__text) {
|
||||
font-size: 11px !important;
|
||||
color: var(--el-text-color-secondary);
|
||||
}
|
||||
}
|
||||
|
||||
.search-form {
|
||||
background: var(--el-bg-color-page, #f5f7fa);
|
||||
padding: 20px 20px 0 20px;
|
||||
|
||||
Reference in new issue
Block a user