更新uniapp和platform
This commit is contained in:
1 parent
31ae07175d
commit
7f9a66da0f
47 files changed
+5207
-1974
No files matched your search
@@ -0,0 +1,43 @@
|
||||
import request from "@/utils/request";
|
||||
|
||||
/** 当前租户附件空间用量(基础额度 / 生效套餐 / 已用) */
|
||||
export function getStorageInfo() {
|
||||
return request({
|
||||
url: "/backend/tenant/storageInfo",
|
||||
method: "get",
|
||||
});
|
||||
}
|
||||
|
||||
/** 可购买的附件空间套餐 */
|
||||
export function getStoragePackages() {
|
||||
return request({
|
||||
url: "/backend/tenant/storagePackages",
|
||||
method: "get",
|
||||
});
|
||||
}
|
||||
|
||||
/** 创建附件空间订单并拉起支付 */
|
||||
export function createStorageOrder(data) {
|
||||
return request({
|
||||
url: "/backend/tenant/storage/order",
|
||||
method: "post",
|
||||
data,
|
||||
});
|
||||
}
|
||||
|
||||
/** 我的购买记录 */
|
||||
export function getStorageOrders(params = {}) {
|
||||
return request({
|
||||
url: "/backend/tenant/storage/orders",
|
||||
method: "get",
|
||||
params,
|
||||
});
|
||||
}
|
||||
|
||||
/** 订单详情(支付后轮询) */
|
||||
export function getStorageOrder(orderNo) {
|
||||
return request({
|
||||
url: `/backend/tenant/storage/order/${orderNo}`,
|
||||
method: "get",
|
||||
});
|
||||
}
|
||||
@@ -23,7 +23,7 @@
|
||||
<el-menu
|
||||
:collapse="isCollapse"
|
||||
:collapse-transition="false"
|
||||
class="el-menu-vertical-demo"
|
||||
class="el-menu-vertical-demo aside-root-menu"
|
||||
popper-class="common-aside-popper"
|
||||
:unique-opened="true"
|
||||
:default-active="route.path"
|
||||
@@ -169,10 +169,15 @@ onUnmounted(() => {
|
||||
</script>
|
||||
|
||||
<style scoped lang="less">
|
||||
.common-aside {
|
||||
// 用 aside.common-aside 提权:Main.vue 里 :deep(.el-aside) 也是 !important,
|
||||
// 权重相同时会被后加载的规则覆盖,导致 flex 布局失效、菜单无法滚动。
|
||||
aside.common-aside {
|
||||
--aside-footer-height: 0px;
|
||||
position: relative;
|
||||
display: flex !important;
|
||||
flex-direction: column;
|
||||
height: 100%;
|
||||
min-height: 0;
|
||||
overflow: hidden;
|
||||
background: var(--yz-aside-bg);
|
||||
border-right: 1px solid var(--yz-border);
|
||||
@@ -224,11 +229,16 @@ onUnmounted(() => {
|
||||
}
|
||||
}
|
||||
|
||||
:deep(.el-menu) {
|
||||
// 只作用于「侧栏根菜单」:flex / overflow / padding 不能写到 :deep(.el-menu) 上,
|
||||
// 否则展开出来的 el-menu--inline 也会命中,导致子菜单宽度、缩进、箭头定位全部错乱。
|
||||
.aside-root-menu {
|
||||
position: relative;
|
||||
z-index: 1;
|
||||
height: calc(100% - var(--aside-footer-height) - 52px);
|
||||
padding: 16px 10px 12px;
|
||||
flex: 1 1 auto;
|
||||
min-height: 0;
|
||||
height: auto;
|
||||
// 底部留出折叠按钮(约 52px)与小程序码区域
|
||||
padding: 16px 10px calc(64px + var(--aside-footer-height));
|
||||
overflow-y: auto;
|
||||
overflow-x: hidden;
|
||||
border-right: none !important;
|
||||
@@ -275,20 +285,10 @@ onUnmounted(() => {
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
// 展开出来的子菜单背景透明;缩进交给 Element Plus 自身(--el-menu-level)计算,
|
||||
// 不能在这里写 padding-left,否则多级子菜单的缩进与图标间距会被叠坏。
|
||||
.el-menu--inline {
|
||||
background: transparent !important;
|
||||
padding-top: 0 !important;
|
||||
padding-bottom: 0 !important;
|
||||
}
|
||||
|
||||
.el-menu--inline > .el-menu-item,
|
||||
.el-menu--inline > .el-sub-menu > .el-sub-menu__title {
|
||||
padding-left: 26px !important;
|
||||
}
|
||||
|
||||
.el-menu--inline .el-menu--inline > .el-menu-item,
|
||||
.el-menu--inline .el-menu--inline > .el-sub-menu > .el-sub-menu__title {
|
||||
padding-left: 44px !important;
|
||||
}
|
||||
|
||||
.is-locked {
|
||||
@@ -302,7 +302,7 @@ onUnmounted(() => {
|
||||
}
|
||||
}
|
||||
|
||||
:deep(.el-menu.el-menu--collapse) {
|
||||
.aside-root-menu.el-menu--collapse {
|
||||
width: 100% !important;
|
||||
padding-left: 0;
|
||||
padding-right: 0;
|
||||
@@ -320,7 +320,7 @@ onUnmounted(() => {
|
||||
}
|
||||
}
|
||||
|
||||
:deep(.el-menu--collapse .menu-icon) {
|
||||
.aside-root-menu.el-menu--collapse :deep(.menu-icon) {
|
||||
margin-right: 0 !important;
|
||||
}
|
||||
|
||||
@@ -475,8 +475,8 @@ onUnmounted(() => {
|
||||
}
|
||||
|
||||
@media (max-width: 768px) {
|
||||
:deep(.el-menu) {
|
||||
padding: 12px 6px;
|
||||
.aside-root-menu {
|
||||
padding: 12px 6px calc(56px + var(--aside-footer-height));
|
||||
}
|
||||
}
|
||||
</style>
|
||||
|
||||
@@ -620,9 +620,13 @@ const canCloseRight = computed(() => {
|
||||
background-color: var(--bg-color-page);
|
||||
transition: background-color 0.3s ease;
|
||||
:deep(.el-aside) {
|
||||
display: block !important;
|
||||
// 侧栏内部是「菜单 + 底部小程序码」的纵向布局:
|
||||
// 必须是 flex 列容器,菜单才能 flex:1 收缩并在内部滚动;写成 block 会溢出裁剪。
|
||||
display: flex !important;
|
||||
flex-direction: column;
|
||||
visibility: visible !important;
|
||||
height: 100vh;
|
||||
min-height: 0;
|
||||
}
|
||||
.main-header {
|
||||
background-color: var(--header-bg-color, #3973ff);
|
||||
|
||||
@@ -38,97 +38,23 @@
|
||||
/>
|
||||
<el-button type="primary" :icon="Search" @click="applyFilters">查询</el-button>
|
||||
<el-button :icon="RefreshLeft" @click="resetFilters">重置</el-button>
|
||||
|
||||
<!-- 统计周期:切换后重新拉取汇总,展开的明细按新周期加载 -->
|
||||
<div class="period-switch">
|
||||
<el-radio-group v-model="summary.period" @change="onPeriodChange">
|
||||
<el-radio-button value="month">月度</el-radio-button>
|
||||
<el-radio-button value="quarter">季度</el-radio-button>
|
||||
<el-radio-button value="year">年度</el-radio-button>
|
||||
</el-radio-group>
|
||||
<div class="year-nav">
|
||||
<el-button :icon="ArrowLeft" text @click="shiftYear(-1)" />
|
||||
<span class="year-text">{{ summary.year }} 年</span>
|
||||
<el-button :icon="ArrowRight" text @click="shiftYear(1)" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="content-card">
|
||||
<!-- ==================== 考勤汇总(可折叠,默认收起) ==================== -->
|
||||
<el-collapse v-model="summaryPanels" class="summary-collapse">
|
||||
<el-collapse-item name="overview">
|
||||
<template #title>
|
||||
<div class="collapse-title">
|
||||
<span class="ct-title">{{ periodTitle }}</span>
|
||||
<span class="ct-sub">{{ summary.label }}</span>
|
||||
<span class="ct-rate">出勤率 {{ summary.stats.attendance_rate || 0 }}%</span>
|
||||
<span class="ct-hint">{{ summary.startDate }} 至 {{ summary.endDate }}</span>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<div class="period-bar">
|
||||
<el-radio-group v-model="summary.period" @change="onPeriodChange">
|
||||
<el-radio-button value="month">月度</el-radio-button>
|
||||
<el-radio-button value="quarter">季度</el-radio-button>
|
||||
<el-radio-button value="year">年度</el-radio-button>
|
||||
</el-radio-group>
|
||||
<div class="year-nav">
|
||||
<el-button :icon="ArrowLeft" text @click="shiftYear(-1)" />
|
||||
<span class="year-text">{{ summary.year }} 年</span>
|
||||
<el-button :icon="ArrowRight" text @click="shiftYear(1)" />
|
||||
</div>
|
||||
<span class="period-tip">格子里为「已打卡 / 应出勤」,颜色按当日出勤率</span>
|
||||
</div>
|
||||
|
||||
<div class="sum-metrics">
|
||||
<div class="sum-metric">
|
||||
<span class="sm-label">应出勤</span>
|
||||
<span class="sm-value">{{ summary.stats.scheduled || 0 }}</span>
|
||||
</div>
|
||||
<div class="sum-metric">
|
||||
<span class="sm-label">已打卡</span>
|
||||
<span class="sm-value is-ok">{{ summary.stats.clocked || 0 }}</span>
|
||||
</div>
|
||||
<div class="sum-metric">
|
||||
<span class="sm-label">迟到</span>
|
||||
<span class="sm-value is-warn">{{ summary.stats.late || 0 }}</span>
|
||||
</div>
|
||||
<div class="sum-metric">
|
||||
<span class="sm-label">早退</span>
|
||||
<span class="sm-value is-warn">{{ summary.stats.early || 0 }}</span>
|
||||
</div>
|
||||
<div class="sum-metric">
|
||||
<span class="sm-label">缺卡</span>
|
||||
<span class="sm-value is-danger">{{ summary.stats.missing || 0 }}</span>
|
||||
</div>
|
||||
<div class="sum-metric">
|
||||
<span class="sm-label">无排班</span>
|
||||
<span class="sm-value is-info">{{ summary.stats.noschedule || 0 }}</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div v-loading="summary.loading" class="calendar-wrap" :class="'cols-' + calendarColumns">
|
||||
<div v-for="cal in summaryCalendars" :key="cal.key" class="cal-month">
|
||||
<div class="cal-month-head">
|
||||
<span class="cal-month-title">{{ cal.month }} 月</span>
|
||||
<span class="cal-month-rate">{{ cal.rate }}%</span>
|
||||
</div>
|
||||
<div class="cal-week">
|
||||
<span v-for="week in WEEK_HEAD" :key="week">{{ week }}</span>
|
||||
</div>
|
||||
<div class="cal-grid">
|
||||
<div
|
||||
v-for="cell in cal.cells"
|
||||
:key="cell.key"
|
||||
class="cal-cell"
|
||||
:class="[cell.status, { 'is-blank': cell.blank, 'is-today': cell.isToday, 'is-future': cell.future }]"
|
||||
:title="cell.tip"
|
||||
>
|
||||
<span v-if="!cell.blank" class="cal-day">{{ cell.day }}</span>
|
||||
<span v-if="cell.stat && cell.stat.scheduled" class="cal-num">
|
||||
{{ cell.stat.clocked }}/{{ cell.stat.scheduled }}
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="cal-legend">
|
||||
<span class="legend-item"><i class="dot is-ok" />出勤率 ≥ 90%</span>
|
||||
<span class="legend-item"><i class="dot is-warn" />70% ~ 90%</span>
|
||||
<span class="legend-item"><i class="dot is-danger" />低于 70%</span>
|
||||
<span class="legend-item"><i class="dot is-info" />无排班打卡</span>
|
||||
<span class="legend-item"><i class="dot is-off" />无排班</span>
|
||||
</div>
|
||||
</el-collapse-item>
|
||||
</el-collapse>
|
||||
|
||||
<!-- ==================== 人员考勤(点姓名展开明细) ==================== -->
|
||||
<div class="list-head">
|
||||
@@ -146,17 +72,80 @@
|
||||
empty-text="当前范围内没有员工"
|
||||
style="width: 100%"
|
||||
@expand-change="onExpandChange"
|
||||
@row-click="onRowClick"
|
||||
>
|
||||
<el-table-column type="expand" width="38">
|
||||
<template #default="{ row }">
|
||||
<div class="row-detail">
|
||||
<div class="rd-head">
|
||||
<span class="rd-name">{{ row.employee_name || '未绑定员工' }}</span>
|
||||
<span class="rd-meta">
|
||||
应出勤 {{ row.scheduled_days }} 天 · 打卡 {{ row.clocked_days }} 天 · 迟到 {{ row.late_count }} ·
|
||||
早退 {{ row.early_count }} · 缺卡 {{ row.missing_days }}
|
||||
</span>
|
||||
<span class="rd-range">{{ summary.label }}</span>
|
||||
<span class="rd-meta">{{ row.employee_account || '—' }}</span>
|
||||
<span class="rd-range">{{ summary.label }} · {{ summary.startDate }} 至 {{ summary.endDate }}</span>
|
||||
</div>
|
||||
|
||||
<!-- 个人汇总指标 -->
|
||||
<div class="sum-metrics rd-metrics">
|
||||
<div class="sum-metric">
|
||||
<span class="sm-label">应出勤</span>
|
||||
<span class="sm-value">{{ row.scheduled_days || 0 }}</span>
|
||||
</div>
|
||||
<div class="sum-metric">
|
||||
<span class="sm-label">已打卡</span>
|
||||
<span class="sm-value is-ok">{{ row.clocked_days || 0 }}</span>
|
||||
</div>
|
||||
<div class="sum-metric">
|
||||
<span class="sm-label">迟到</span>
|
||||
<span class="sm-value is-warn">{{ row.late_count || 0 }}</span>
|
||||
</div>
|
||||
<div class="sum-metric">
|
||||
<span class="sm-label">早退</span>
|
||||
<span class="sm-value is-warn">{{ row.early_count || 0 }}</span>
|
||||
</div>
|
||||
<div class="sum-metric">
|
||||
<span class="sm-label">缺卡</span>
|
||||
<span class="sm-value is-danger">{{ row.missing_days || 0 }}</span>
|
||||
</div>
|
||||
<div class="sum-metric">
|
||||
<span class="sm-label">无排班</span>
|
||||
<span class="sm-value is-info">{{ row.noschedule_count || 0 }}</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 个人打卡日历:格子里为「已打卡 / 应出勤」,颜色按当日结果 -->
|
||||
<div
|
||||
v-loading="rowDetail(row).loading"
|
||||
class="calendar-wrap rd-calendar"
|
||||
:class="'cols-' + calendarColumns"
|
||||
>
|
||||
<div v-for="cal in employeeMonths(row)" :key="cal.key" class="cal-month">
|
||||
<div class="cal-month-head">
|
||||
<span class="cal-month-title">{{ cal.month }} 月</span>
|
||||
<span class="cal-month-rate">{{ cal.rate }}%</span>
|
||||
</div>
|
||||
<div class="cal-week">
|
||||
<span v-for="week in WEEK_HEAD" :key="week">{{ week }}</span>
|
||||
</div>
|
||||
<div class="cal-grid">
|
||||
<div
|
||||
v-for="cell in cal.cells"
|
||||
:key="cell.key"
|
||||
class="cal-cell"
|
||||
:class="[cell.status, { 'is-blank': cell.blank, 'is-today': cell.isToday, 'is-future': cell.future }]"
|
||||
:title="cell.tip"
|
||||
>
|
||||
<span v-if="!cell.blank" class="cal-day">{{ cell.day }}</span>
|
||||
<span v-if="cell.stat" class="cal-num">{{ cell.stat.clocked }}/{{ cell.stat.scheduled }}</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="cal-legend">
|
||||
<span class="legend-item"><i class="dot is-ok" />正常</span>
|
||||
<span class="legend-item"><i class="dot is-warn" />迟到 / 早退</span>
|
||||
<span class="legend-item"><i class="dot is-danger" />缺卡</span>
|
||||
<span class="legend-item"><i class="dot is-info" />无排班打卡</span>
|
||||
<span class="legend-item"><i class="dot is-off" />休息 / 无排班</span>
|
||||
</div>
|
||||
|
||||
<el-table
|
||||
@@ -242,8 +231,7 @@
|
||||
<el-table-column label="员工" min-width="170">
|
||||
<template #default="{ row }">
|
||||
<div class="emp-cell">
|
||||
<span class="emp-name is-clickable" @click.stop="toggleRow(row)">
|
||||
<el-icon class="expand-caret" :class="{ 'is-open': isExpanded(row) }"><ArrowRight /></el-icon>
|
||||
<span class="emp-name">
|
||||
{{ row.employee_name || '未绑定员工' }}
|
||||
<el-tag v-if="!row.bound" size="small" type="info" effect="plain">未绑定档案</el-tag>
|
||||
</span>
|
||||
@@ -402,9 +390,6 @@ function unwrap(res) {
|
||||
|
||||
const filters = reactive({ org_id: 0, include_child: true, keyword: '' })
|
||||
|
||||
// 汇总面板默认收起,点标题展开日历
|
||||
const summaryPanels = ref([])
|
||||
|
||||
const summary = reactive({
|
||||
period: 'month',
|
||||
anchor: todayString(),
|
||||
@@ -426,12 +411,6 @@ const summary = reactive({
|
||||
const orgTree = ref([])
|
||||
const orgFilterTree = computed(() => [{ id: 0, org_name: '全部', children: orgTree.value }])
|
||||
|
||||
const periodTitle = computed(() => {
|
||||
if (summary.period === 'year') return '年度考勤'
|
||||
if (summary.period === 'quarter') return '季度考勤'
|
||||
return '月度考勤'
|
||||
})
|
||||
|
||||
// 月度 1 张、季度 3 张、年度 12 张日历
|
||||
const calendarColumns = computed(() => {
|
||||
if (summary.period === 'year') return 4
|
||||
@@ -451,25 +430,45 @@ const summaryMonthList = computed(() => {
|
||||
return [{ year, month: startMonth }]
|
||||
})
|
||||
|
||||
const summaryCalendarMap = computed(() => {
|
||||
const map = {}
|
||||
;(summary.calendar || []).forEach((item) => {
|
||||
map[item.date] = item
|
||||
// 后端「当日结果」枚举 → 日历颜色:1正常 2迟到 3早退 4缺卡 5无排班 6时段异常 7未签退 8休息
|
||||
const DAY_STATUS_COLOR = {
|
||||
1: 'is-ok',
|
||||
2: 'is-warn',
|
||||
3: 'is-warn',
|
||||
4: 'is-danger',
|
||||
5: 'is-info',
|
||||
6: 'is-warn',
|
||||
7: 'is-warn',
|
||||
8: 'is-off'
|
||||
}
|
||||
|
||||
/** 某个员工在当前统计周期内的日历(月度 1 张 / 季度 3 张 / 年度 12 张) */
|
||||
function employeeMonths(row) {
|
||||
const list = rowDetail(row).list || []
|
||||
const byDate = {}
|
||||
list.forEach((item) => {
|
||||
if (item.attend_date) byDate[item.attend_date] = item
|
||||
})
|
||||
return map
|
||||
})
|
||||
return summaryMonthList.value.map((item) => {
|
||||
const cells = buildEmployeeMonthGrid(item.year, item.month, byDate)
|
||||
let scheduled = 0
|
||||
let clocked = 0
|
||||
cells.forEach((cell) => {
|
||||
if (cell.blank || !cell.stat) return
|
||||
scheduled += cell.stat.scheduled
|
||||
clocked += cell.stat.clocked
|
||||
})
|
||||
return {
|
||||
key: `${item.year}-${item.month}`,
|
||||
month: item.month,
|
||||
rate: scheduled > 0 ? Math.round((clocked / scheduled) * 100) : 0,
|
||||
cells
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
const summaryCalendars = computed(() =>
|
||||
summaryMonthList.value.map((item) => ({
|
||||
key: `${item.year}-${item.month}`,
|
||||
month: item.month,
|
||||
rate: (summary.cards.months[item.month - 1] || {}).attendance_rate || 0,
|
||||
cells: buildMonthGrid(item.year, item.month)
|
||||
}))
|
||||
)
|
||||
|
||||
/** 生成某月日历格子:空白占位 + 每日考勤色块 */
|
||||
function buildMonthGrid(year, month) {
|
||||
/** 生成某员工某月的日历格子:空白占位 + 每日打卡色块 */
|
||||
function buildEmployeeMonthGrid(year, month, byDate) {
|
||||
const firstDay = new Date(year, month - 1, 1)
|
||||
const leading = (firstDay.getDay() + 6) % 7 // 周一为第一列
|
||||
const daysInMonth = new Date(year, month, 0).getDate()
|
||||
@@ -481,28 +480,36 @@ function buildMonthGrid(year, month) {
|
||||
}
|
||||
for (let day = 1; day <= daysInMonth; day += 1) {
|
||||
const date = `${year}-${pad2(month)}-${pad2(day)}`
|
||||
const stat = summaryCalendarMap.value[date]
|
||||
const rec = byDate[date]
|
||||
let status = 'is-off'
|
||||
if (stat) {
|
||||
if (stat.scheduled > 0) {
|
||||
if (stat.attendance_rate >= 90) status = 'is-ok'
|
||||
else if (stat.attendance_rate >= 70) status = 'is-warn'
|
||||
else status = 'is-danger'
|
||||
} else if (stat.clocked > 0) {
|
||||
status = 'is-info'
|
||||
}
|
||||
let scheduled = 0
|
||||
let clocked = 0
|
||||
let tip = '休息 / 无排班'
|
||||
|
||||
if (rec) {
|
||||
clocked = rec.clock_in_hm ? 1 : 0
|
||||
// 休息(8) 与 无排班(5) 不算应出勤
|
||||
scheduled = rec.day_status === 5 || rec.day_status === 8 ? 0 : 1
|
||||
status = DAY_STATUS_COLOR[rec.day_status] || 'is-off'
|
||||
if (scheduled > 0 && clocked === 0) status = 'is-danger'
|
||||
if (scheduled === 0 && clocked > 0) status = 'is-info'
|
||||
|
||||
const parts = [rec.day_status_text || '']
|
||||
if (rec.shift_name) parts.push(rec.shift_name)
|
||||
if (rec.clock_in_hm) parts.push(`签到 ${rec.clock_in_hm}`)
|
||||
if (rec.clock_out_hm) parts.push(`签退 ${rec.clock_out_hm}`)
|
||||
tip = parts.filter(Boolean).join(' · ')
|
||||
}
|
||||
|
||||
cells.push({
|
||||
key: date,
|
||||
day,
|
||||
date,
|
||||
stat,
|
||||
status,
|
||||
stat: scheduled > 0 ? { scheduled, clocked } : null,
|
||||
future: date > today,
|
||||
isToday: date === today,
|
||||
tip: stat
|
||||
? `应出勤 ${stat.scheduled} · 已打卡 ${stat.clocked} · 缺卡 ${stat.missing} · 迟到 ${stat.late} · 早退 ${stat.early}`
|
||||
: '无排班'
|
||||
tip
|
||||
})
|
||||
}
|
||||
return cells
|
||||
@@ -517,14 +524,16 @@ function rowDetail(row) {
|
||||
return rowDetailMap.value[row.key] || { loading: false, loaded: false, list: [], total: 0 }
|
||||
}
|
||||
|
||||
function isExpanded(row) {
|
||||
return expandedKeys.value.includes(row.key)
|
||||
}
|
||||
|
||||
function toggleRow(row) {
|
||||
tableRef.value?.toggleRowExpansion(row)
|
||||
}
|
||||
|
||||
/** 点击整行展开/收起明细;展开箭头列自身已处理,跳过避免重复切换 */
|
||||
function onRowClick(row, column) {
|
||||
if (column && column.type === 'expand') return
|
||||
toggleRow(row)
|
||||
}
|
||||
|
||||
function onExpandChange(row, expandedRows) {
|
||||
const rows = Array.isArray(expandedRows) ? expandedRows : []
|
||||
expandedKeys.value = rows.map((item) => item.key)
|
||||
@@ -533,6 +542,32 @@ function onExpandChange(row, expandedRows) {
|
||||
}
|
||||
}
|
||||
|
||||
/** 后端明细接口单次最多查询 92 天,季度/年度需要按区间切片后合并 */
|
||||
const ATTENDANCE_MAX_SPAN_DAYS = 92
|
||||
|
||||
function toDateStr(date) {
|
||||
return `${date.getFullYear()}-${pad2(date.getMonth() + 1)}-${pad2(date.getDate())}`
|
||||
}
|
||||
|
||||
/** 把 [start, end] 按最多 maxDays 天切成若干段(闭区间) */
|
||||
function splitDateRange(start, end, maxDays = ATTENDANCE_MAX_SPAN_DAYS) {
|
||||
const ranges = []
|
||||
if (!start || !end) return ranges
|
||||
let cursor = new Date(`${start}T00:00:00`)
|
||||
const stop = new Date(`${end}T00:00:00`)
|
||||
if (Number.isNaN(cursor.getTime()) || Number.isNaN(stop.getTime()) || cursor > stop) return ranges
|
||||
|
||||
while (cursor <= stop) {
|
||||
const next = new Date(cursor)
|
||||
next.setDate(next.getDate() + maxDays - 1)
|
||||
const chunkEnd = next > stop ? stop : next
|
||||
ranges.push([toDateStr(cursor), toDateStr(chunkEnd)])
|
||||
cursor = new Date(chunkEnd)
|
||||
cursor.setDate(cursor.getDate() + 1)
|
||||
}
|
||||
return ranges
|
||||
}
|
||||
|
||||
/** 展开某人的明细:按当前汇总周期取该员工的考勤记录 */
|
||||
async function loadRowDetail(row) {
|
||||
const key = row.key
|
||||
@@ -542,20 +577,31 @@ async function loadRowDetail(row) {
|
||||
}
|
||||
rowDetailMap.value = { ...rowDetailMap.value, [key]: { loading: true, loaded: false, list: [], total: 0 } }
|
||||
try {
|
||||
const data =
|
||||
unwrap(
|
||||
await getAttendanceRecords({
|
||||
const ranges = splitDateRange(summary.startDate, summary.endDate)
|
||||
const responses = await Promise.all(
|
||||
ranges.map(([startDate, endDate]) =>
|
||||
getAttendanceRecords({
|
||||
page: 1,
|
||||
pageSize: 100,
|
||||
start_date: summary.startDate,
|
||||
end_date: summary.endDate,
|
||||
pageSize: 200,
|
||||
start_date: startDate,
|
||||
end_date: endDate,
|
||||
employee_id: row.bound ? row.employee_id : '',
|
||||
uid: row.bound ? '' : row.uid
|
||||
})
|
||||
) || {}
|
||||
)
|
||||
)
|
||||
|
||||
const list = []
|
||||
let total = 0
|
||||
responses.forEach((res) => {
|
||||
const data = unwrap(res) || {}
|
||||
list.push(...(data.list || []))
|
||||
total += Number(data.total || 0)
|
||||
})
|
||||
|
||||
rowDetailMap.value = {
|
||||
...rowDetailMap.value,
|
||||
[key]: { loading: false, loaded: true, list: data.list || [], total: data.total || 0 }
|
||||
[key]: { loading: false, loaded: true, list, total }
|
||||
}
|
||||
} catch (error) {
|
||||
rowDetailMap.value = { ...rowDetailMap.value, [key]: { loading: false, loaded: false, list: [], total: 0 } }
|
||||
@@ -610,10 +656,6 @@ async function loadSummary() {
|
||||
|
||||
function onPeriodChange() {
|
||||
summary.page = 1
|
||||
// 切换维度时自动展开日历,避免以为没数据
|
||||
if (!summaryPanels.value.includes('overview')) {
|
||||
summaryPanels.value = ['overview']
|
||||
}
|
||||
loadSummary()
|
||||
}
|
||||
|
||||
@@ -794,7 +836,7 @@ onMounted(async () => {
|
||||
}
|
||||
p {
|
||||
margin: 0;
|
||||
color: #909399;
|
||||
color: var(--el-text-color-secondary);
|
||||
font-size: 13px;
|
||||
}
|
||||
}
|
||||
@@ -810,14 +852,21 @@ onMounted(async () => {
|
||||
gap: 12px;
|
||||
padding: 14px 16px;
|
||||
margin-bottom: 14px;
|
||||
background: #fff;
|
||||
border: 1px solid #ebeef5;
|
||||
background: var(--el-bg-color);
|
||||
border: 1px solid var(--el-border-color-lighter);
|
||||
border-radius: 8px;
|
||||
}
|
||||
// 周期切换靠右,与筛选条件同一行
|
||||
.period-switch {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 12px;
|
||||
margin-left: auto;
|
||||
}
|
||||
.content-card {
|
||||
padding: 8px 16px 16px;
|
||||
background: #fff;
|
||||
border: 1px solid #ebeef5;
|
||||
background: var(--el-bg-color);
|
||||
border: 1px solid var(--el-border-color-lighter);
|
||||
border-radius: 8px;
|
||||
}
|
||||
|
||||
@@ -825,7 +874,7 @@ onMounted(async () => {
|
||||
.summary-collapse {
|
||||
margin-top: 6px;
|
||||
border-top: none;
|
||||
border-bottom: 1px solid #ebeef5;
|
||||
border-bottom: 1px solid var(--el-border-color-lighter);
|
||||
|
||||
:deep(.el-collapse-item__header) {
|
||||
height: auto;
|
||||
@@ -852,20 +901,20 @@ onMounted(async () => {
|
||||
.ct-title {
|
||||
font-size: 15px;
|
||||
font-weight: 600;
|
||||
color: #303133;
|
||||
color: var(--el-text-color-primary);
|
||||
}
|
||||
.ct-sub {
|
||||
font-size: 13px;
|
||||
color: #606266;
|
||||
color: var(--el-text-color-regular);
|
||||
}
|
||||
.ct-rate {
|
||||
font-size: 13px;
|
||||
font-weight: 600;
|
||||
color: #409eff;
|
||||
color: var(--el-color-primary);
|
||||
}
|
||||
.ct-hint {
|
||||
font-size: 12px;
|
||||
color: #909399;
|
||||
color: var(--el-text-color-secondary);
|
||||
}
|
||||
|
||||
/* ============ 周期切换 ============ */
|
||||
@@ -884,12 +933,12 @@ onMounted(async () => {
|
||||
.year-text {
|
||||
font-size: 14px;
|
||||
font-weight: 600;
|
||||
color: #303133;
|
||||
color: var(--el-text-color-primary);
|
||||
min-width: 62px;
|
||||
text-align: center;
|
||||
}
|
||||
.period-tip {
|
||||
color: #909399;
|
||||
color: var(--el-text-color-secondary);
|
||||
font-size: 12px;
|
||||
}
|
||||
|
||||
@@ -903,32 +952,39 @@ onMounted(async () => {
|
||||
.sum-metric {
|
||||
flex: 1 0 110px;
|
||||
padding: 10px 14px;
|
||||
background: #f7f8fa;
|
||||
background: var(--el-fill-color-light);
|
||||
border-radius: 8px;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 2px;
|
||||
}
|
||||
// 展开明细内的指标条:与上方姓名行、下方日历的间距收紧
|
||||
.rd-metrics {
|
||||
margin: 0 0 12px;
|
||||
}
|
||||
.rd-calendar {
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
.sm-label {
|
||||
font-size: 12px;
|
||||
color: #909399;
|
||||
color: var(--el-text-color-secondary);
|
||||
}
|
||||
.sm-value {
|
||||
font-size: 20px;
|
||||
font-weight: 600;
|
||||
color: #303133;
|
||||
color: var(--el-text-color-primary);
|
||||
|
||||
&.is-ok {
|
||||
color: #67c23a;
|
||||
color: var(--el-color-success);
|
||||
}
|
||||
&.is-warn {
|
||||
color: #e6a23c;
|
||||
color: var(--el-color-warning);
|
||||
}
|
||||
&.is-danger {
|
||||
color: #f56c6c;
|
||||
color: var(--el-color-danger);
|
||||
}
|
||||
&.is-info {
|
||||
color: #409eff;
|
||||
color: var(--el-color-primary);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -957,9 +1013,9 @@ onMounted(async () => {
|
||||
}
|
||||
.cal-month {
|
||||
padding: 10px 12px 12px;
|
||||
border: 1px solid #ebeef5;
|
||||
border: 1px solid var(--el-border-color-lighter);
|
||||
border-radius: 10px;
|
||||
background: #fff;
|
||||
background: var(--el-bg-color);
|
||||
}
|
||||
.cal-month-head {
|
||||
display: flex;
|
||||
@@ -970,11 +1026,11 @@ onMounted(async () => {
|
||||
.cal-month-title {
|
||||
font-size: 13px;
|
||||
font-weight: 600;
|
||||
color: #303133;
|
||||
color: var(--el-text-color-primary);
|
||||
}
|
||||
.cal-month-rate {
|
||||
font-size: 12px;
|
||||
color: #909399;
|
||||
color: var(--el-text-color-secondary);
|
||||
}
|
||||
.cal-week,
|
||||
.cal-grid {
|
||||
@@ -988,7 +1044,7 @@ onMounted(async () => {
|
||||
span {
|
||||
text-align: center;
|
||||
font-size: 11px;
|
||||
color: #c0c4cc;
|
||||
color: var(--el-text-color-placeholder);
|
||||
}
|
||||
}
|
||||
.cal-cell {
|
||||
@@ -996,7 +1052,7 @@ onMounted(async () => {
|
||||
min-height: 34px;
|
||||
padding: 3px 4px 2px;
|
||||
border-radius: 6px;
|
||||
background: #f7f8fa;
|
||||
background: var(--el-fill-color-light);
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: flex-start;
|
||||
@@ -1013,35 +1069,35 @@ onMounted(async () => {
|
||||
background: transparent;
|
||||
}
|
||||
&.is-ok {
|
||||
background: #ecfdf3;
|
||||
background: var(--el-color-success-light-9);
|
||||
}
|
||||
&.is-warn {
|
||||
background: #fef7e6;
|
||||
background: var(--el-color-warning-light-9);
|
||||
}
|
||||
&.is-danger {
|
||||
background: #fef0f0;
|
||||
background: var(--el-color-danger-light-9);
|
||||
}
|
||||
&.is-info {
|
||||
background: #eff6ff;
|
||||
background: var(--el-color-primary-light-9);
|
||||
}
|
||||
&.is-off {
|
||||
background: #f7f8fa;
|
||||
background: var(--el-fill-color-light);
|
||||
}
|
||||
&.is-future {
|
||||
opacity: 0.45;
|
||||
}
|
||||
&.is-today {
|
||||
box-shadow: inset 0 0 0 1.5px #409eff;
|
||||
box-shadow: inset 0 0 0 1.5px var(--el-color-primary);
|
||||
}
|
||||
}
|
||||
.cal-day {
|
||||
font-size: 11px;
|
||||
color: #606266;
|
||||
color: var(--el-text-color-regular);
|
||||
line-height: 1.2;
|
||||
}
|
||||
.cal-num {
|
||||
font-size: 10px;
|
||||
color: #909399;
|
||||
color: var(--el-text-color-secondary);
|
||||
line-height: 1.2;
|
||||
font-variant-numeric: tabular-nums;
|
||||
}
|
||||
@@ -1052,7 +1108,7 @@ onMounted(async () => {
|
||||
gap: 16px;
|
||||
margin-top: 12px;
|
||||
font-size: 12px;
|
||||
color: #909399;
|
||||
color: var(--el-text-color-secondary);
|
||||
}
|
||||
.legend-item {
|
||||
display: inline-flex;
|
||||
@@ -1066,19 +1122,19 @@ onMounted(async () => {
|
||||
display: inline-block;
|
||||
|
||||
&.is-ok {
|
||||
background: #67c23a;
|
||||
background: var(--el-color-success);
|
||||
}
|
||||
&.is-warn {
|
||||
background: #e6a23c;
|
||||
background: var(--el-color-warning);
|
||||
}
|
||||
&.is-danger {
|
||||
background: #f56c6c;
|
||||
background: var(--el-color-danger);
|
||||
}
|
||||
&.is-info {
|
||||
background: #409eff;
|
||||
background: var(--el-color-primary);
|
||||
}
|
||||
&.is-off {
|
||||
background: #dcdfe6;
|
||||
background: var(--el-border-color);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1093,11 +1149,11 @@ onMounted(async () => {
|
||||
.list-title {
|
||||
font-size: 15px;
|
||||
font-weight: 600;
|
||||
color: #303133;
|
||||
color: var(--el-text-color-primary);
|
||||
}
|
||||
.list-sub {
|
||||
font-size: 12px;
|
||||
color: #909399;
|
||||
color: var(--el-text-color-secondary);
|
||||
}
|
||||
.emp-cell {
|
||||
display: flex;
|
||||
@@ -1109,37 +1165,22 @@ onMounted(async () => {
|
||||
align-items: center;
|
||||
gap: 6px;
|
||||
font-weight: 500;
|
||||
color: #303133;
|
||||
|
||||
&.is-clickable {
|
||||
cursor: pointer;
|
||||
user-select: none;
|
||||
|
||||
&:hover {
|
||||
color: #409eff;
|
||||
}
|
||||
}
|
||||
color: var(--el-text-color-primary);
|
||||
}
|
||||
.expand-caret {
|
||||
font-size: 12px;
|
||||
color: #909399;
|
||||
transition: transform 0.2s ease;
|
||||
|
||||
&.is-open {
|
||||
transform: rotate(90deg);
|
||||
color: #409eff;
|
||||
}
|
||||
// 点击整行即可展开/收起明细
|
||||
:deep(.el-table__body tr.el-table__row) {
|
||||
cursor: pointer;
|
||||
}
|
||||
.emp-meta {
|
||||
color: #909399;
|
||||
color: var(--el-text-color-secondary);
|
||||
font-size: 12px;
|
||||
}
|
||||
|
||||
/* ============ 展开的明细 ============ */
|
||||
.row-detail {
|
||||
padding: 8px 12px 12px;
|
||||
background: #fafbfc;
|
||||
border-left: 3px solid #409eff;
|
||||
background: var(--el-fill-color-lighter);
|
||||
border-left: 3px solid var(--el-color-primary);
|
||||
}
|
||||
.rd-head {
|
||||
display: flex;
|
||||
@@ -1151,21 +1192,21 @@ onMounted(async () => {
|
||||
.rd-name {
|
||||
font-size: 14px;
|
||||
font-weight: 600;
|
||||
color: #303133;
|
||||
color: var(--el-text-color-primary);
|
||||
}
|
||||
.rd-meta {
|
||||
font-size: 12px;
|
||||
color: #606266;
|
||||
color: var(--el-text-color-regular);
|
||||
}
|
||||
.rd-range {
|
||||
margin-left: auto;
|
||||
font-size: 12px;
|
||||
color: #909399;
|
||||
color: var(--el-text-color-secondary);
|
||||
}
|
||||
.rd-more {
|
||||
margin-top: 8px;
|
||||
font-size: 12px;
|
||||
color: #909399;
|
||||
color: var(--el-text-color-secondary);
|
||||
}
|
||||
.date-cell {
|
||||
display: flex;
|
||||
@@ -1173,7 +1214,7 @@ onMounted(async () => {
|
||||
gap: 2px;
|
||||
}
|
||||
.weekday {
|
||||
color: #909399;
|
||||
color: var(--el-text-color-secondary);
|
||||
font-size: 12px;
|
||||
}
|
||||
.shift-cell {
|
||||
@@ -1193,10 +1234,10 @@ onMounted(async () => {
|
||||
gap: 2px;
|
||||
}
|
||||
.shift-name {
|
||||
color: #303133;
|
||||
color: var(--el-text-color-primary);
|
||||
}
|
||||
.shift-time {
|
||||
color: #909399;
|
||||
color: var(--el-text-color-secondary);
|
||||
font-size: 12px;
|
||||
}
|
||||
.punch-cell {
|
||||
@@ -1206,13 +1247,13 @@ onMounted(async () => {
|
||||
}
|
||||
.punch-time {
|
||||
font-weight: 500;
|
||||
color: #303133;
|
||||
color: var(--el-text-color-primary);
|
||||
}
|
||||
.note-text {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 4px;
|
||||
color: #e6a23c;
|
||||
color: var(--el-color-warning);
|
||||
font-size: 12px;
|
||||
line-height: 1.4;
|
||||
}
|
||||
@@ -1220,19 +1261,19 @@ onMounted(async () => {
|
||||
display: inline-block;
|
||||
margin-top: 2px;
|
||||
font-size: 12px;
|
||||
color: #606266;
|
||||
color: var(--el-text-color-regular);
|
||||
}
|
||||
.is-warn {
|
||||
color: #e6a23c;
|
||||
color: var(--el-color-warning);
|
||||
}
|
||||
.is-danger {
|
||||
color: #f56c6c;
|
||||
color: var(--el-color-danger);
|
||||
}
|
||||
.is-info {
|
||||
color: #409eff;
|
||||
color: var(--el-color-primary);
|
||||
}
|
||||
.muted {
|
||||
color: #c0c4cc;
|
||||
color: var(--el-text-color-placeholder);
|
||||
}
|
||||
.pager {
|
||||
display: flex;
|
||||
@@ -1246,12 +1287,12 @@ onMounted(async () => {
|
||||
margin-bottom: 12px;
|
||||
}
|
||||
.missing-tip {
|
||||
color: #909399;
|
||||
color: var(--el-text-color-secondary);
|
||||
font-size: 12px;
|
||||
}
|
||||
.missing-count {
|
||||
margin-right: auto;
|
||||
color: #909399;
|
||||
color: var(--el-text-color-secondary);
|
||||
font-size: 13px;
|
||||
}
|
||||
.remark-head {
|
||||
|
||||
@@ -416,7 +416,7 @@ onMounted(loadList)
|
||||
}
|
||||
p {
|
||||
margin: 0;
|
||||
color: #909399;
|
||||
color: var(--el-text-color-secondary);
|
||||
font-size: 13px;
|
||||
}
|
||||
}
|
||||
@@ -430,9 +430,11 @@ onMounted(loadList)
|
||||
}
|
||||
.table-card {
|
||||
padding: 16px;
|
||||
background: #fff;
|
||||
border: 1px solid #ebeef5;
|
||||
// 跟随主题:暗色模式下使用 Element Plus 暗色变量,避免白底块
|
||||
background: var(--el-bg-color);
|
||||
border: 1px solid var(--el-border-color-lighter);
|
||||
border-radius: 8px;
|
||||
transition: background-color 0.3s ease, border-color 0.3s ease;
|
||||
}
|
||||
.name-cell {
|
||||
display: inline-flex;
|
||||
@@ -446,9 +448,9 @@ onMounted(loadList)
|
||||
gap: 4px;
|
||||
|
||||
.is-default {
|
||||
color: #e6a23c;
|
||||
border-color: #f3d19e;
|
||||
background: #fdf6ec;
|
||||
color: var(--el-color-warning);
|
||||
border-color: var(--el-color-warning-light-5);
|
||||
background: var(--el-color-warning-light-9);
|
||||
}
|
||||
}
|
||||
.model-editor {
|
||||
@@ -464,7 +466,7 @@ onMounted(loadList)
|
||||
}
|
||||
.form-tip {
|
||||
margin-left: 10px;
|
||||
color: #909399;
|
||||
color: var(--el-text-color-secondary);
|
||||
font-size: 12px;
|
||||
}
|
||||
.test-results {
|
||||
@@ -480,7 +482,7 @@ onMounted(loadList)
|
||||
font-size: 12px;
|
||||
}
|
||||
.test-error {
|
||||
color: #f56c6c;
|
||||
color: var(--el-color-danger);
|
||||
word-break: break-all;
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,493 @@
|
||||
<template>
|
||||
<div class="container-box storage-page" v-loading="loading">
|
||||
<!-- 空间概览 -->
|
||||
<div class="overview-card">
|
||||
<div class="overview-head">
|
||||
<div class="overview-title">
|
||||
<el-icon><Coin /></el-icon>
|
||||
<span>附件空间</span>
|
||||
</div>
|
||||
<el-button link type="primary" @click="openOrders">购买记录</el-button>
|
||||
</div>
|
||||
|
||||
<div class="overview-usage">
|
||||
<span class="used">{{ formatSize(info.used_bytes) }}</span>
|
||||
<span class="total">/ {{ formatSize(info.quota_bytes) }}</span>
|
||||
</div>
|
||||
|
||||
<el-progress
|
||||
:percentage="progressPercent"
|
||||
:status="progressStatus"
|
||||
:stroke-width="10"
|
||||
:show-text="false"
|
||||
class="overview-progress"
|
||||
/>
|
||||
<div class="overview-foot">
|
||||
<span>已用 {{ info.used_percent || 0 }}%,剩余 {{ formatSize(info.remaining_bytes) }}</span>
|
||||
<span v-if="info.expire_time" class="expire">
|
||||
套餐 {{ info.package_name }} 到期:{{ formatDate(info.expire_time) }}(剩 {{ info.days_remaining }} 天)
|
||||
</span>
|
||||
<span v-else class="expire">当前为基础额度 {{ info.base_quota_mb || 500 }}MB</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 套餐 -->
|
||||
<div class="section-title">
|
||||
<h3>扩容套餐</h3>
|
||||
<span class="tip">购买后立即生效;换规格会替换当前套餐,同规格续费到期时间顺延</span>
|
||||
</div>
|
||||
|
||||
<div v-if="packages.length" class="package-grid">
|
||||
<div v-for="pkg in packages" :key="pkg.id" class="package-card">
|
||||
<div class="package-name">{{ pkg.name }}</div>
|
||||
<div class="package-capacity">{{ formatCapacity(pkg.capacity_mb) }}</div>
|
||||
<div class="package-price">
|
||||
<span class="symbol">¥</span>
|
||||
<span class="amount">{{ Number(pkg.price || 0).toFixed(2) }}</span>
|
||||
<span class="unit">/ {{ durationText(pkg.duration_days) }}</span>
|
||||
</div>
|
||||
<div v-if="pkg.remark" class="package-remark">{{ pkg.remark }}</div>
|
||||
<el-button
|
||||
type="primary"
|
||||
class="package-btn"
|
||||
:loading="buyingId === pkg.id"
|
||||
@click="handleBuy(pkg)"
|
||||
>
|
||||
购买
|
||||
</el-button>
|
||||
</div>
|
||||
</div>
|
||||
<el-empty v-else description="暂无可购买的扩容套餐" />
|
||||
|
||||
<!-- 支付弹窗 -->
|
||||
<el-dialog v-model="payVisible" title="扫码支付" width="420px" :close-on-click-modal="false">
|
||||
<div v-if="payParams?.code_url" class="pay-body">
|
||||
<canvas ref="qrRef" class="pay-qr"></canvas>
|
||||
<p class="pay-tip">请使用{{ currentChannelName }}扫码支付</p>
|
||||
<p class="pay-amount">¥{{ Number(payAmount || 0).toFixed(2) }}</p>
|
||||
</div>
|
||||
<div v-else-if="payParams?.redirect_url" class="pay-body">
|
||||
<p class="pay-tip">正在跳转{{ currentChannelName }}收银台…</p>
|
||||
<el-button type="primary" @click="openPayUrl(payParams.redirect_url)">重新打开支付页</el-button>
|
||||
</div>
|
||||
<p class="pay-status">{{ payStatusText }}</p>
|
||||
<template #footer>
|
||||
<el-button @click="handleCancelPay">取消支付</el-button>
|
||||
</template>
|
||||
</el-dialog>
|
||||
|
||||
<!-- 购买记录 -->
|
||||
<el-drawer v-model="ordersVisible" title="购买记录" size="640px">
|
||||
<el-table :data="orders" v-loading="ordersLoading" size="small">
|
||||
<el-table-column prop="order_no" label="订单号" min-width="180" show-overflow-tooltip />
|
||||
<el-table-column prop="package_name" label="套餐" width="120" />
|
||||
<el-table-column label="容量" width="100">
|
||||
<template #default="{ row }">{{ formatCapacity(row.capacity_mb) }}</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="金额" width="90">
|
||||
<template #default="{ row }">¥{{ Number(row.amount || 0).toFixed(2) }}</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="状态" width="90">
|
||||
<template #default="{ row }">
|
||||
<el-tag size="small" :type="storageOrderStatusType(row.status)">
|
||||
{{ storageOrderStatusText(row.status) }}
|
||||
</el-tag>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="有效期" min-width="190">
|
||||
<template #default="{ row }">
|
||||
<span v-if="row.end_time">{{ formatDate(row.start_time) }} ~ {{ formatDate(row.end_time) }}</span>
|
||||
<span v-else>-</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
</el-drawer>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { computed, nextTick, onMounted, onUnmounted, ref } from "vue";
|
||||
import { ElMessage } from "element-plus";
|
||||
import { Coin } from "@element-plus/icons-vue";
|
||||
import QRCode from "qrcode";
|
||||
import { getPaymentChannels } from "@/api/product";
|
||||
import {
|
||||
createStorageOrder,
|
||||
getStorageInfo,
|
||||
getStorageOrder,
|
||||
getStorageOrders,
|
||||
getStoragePackages,
|
||||
} from "@/api/storage";
|
||||
|
||||
const loading = ref(false);
|
||||
const info = ref<Record<string, any>>({});
|
||||
const packages = ref<any[]>([]);
|
||||
|
||||
const buyingId = ref<number | null>(null);
|
||||
const payVisible = ref(false);
|
||||
const payParams = ref<any>(null);
|
||||
const payStatusText = ref("");
|
||||
const payAmount = ref(0);
|
||||
const currentChannelName = ref("");
|
||||
const qrRef = ref<HTMLCanvasElement | null>(null);
|
||||
|
||||
const ordersVisible = ref(false);
|
||||
const orders = ref<any[]>([]);
|
||||
const ordersLoading = ref(false);
|
||||
|
||||
let pollTimer: ReturnType<typeof setInterval> | null = null;
|
||||
let pollCount = 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, 10);
|
||||
return `${d.getFullYear()}-${String(d.getMonth() + 1).padStart(2, "0")}-${String(d.getDate()).padStart(2, "0")}`;
|
||||
};
|
||||
|
||||
const durationText = (days: any) => {
|
||||
const n = Number(days) || 0;
|
||||
if (n === 365) return "年";
|
||||
if (n === 180) return "半年";
|
||||
if (n === 90) return "季";
|
||||
if (n === 30) return "月";
|
||||
return `${n} 天`;
|
||||
};
|
||||
|
||||
const storageOrderStatusText = (s: string) =>
|
||||
({ pending: "待支付", paid: "已支付", cancelled: "已取消", replaced: "已替换" }[s] || s);
|
||||
|
||||
const storageOrderStatusType = (s: string) =>
|
||||
({ pending: "warning", paid: "success", cancelled: "info", replaced: "info" }[s] || "info");
|
||||
|
||||
const loadInfo = async () => {
|
||||
const res = await getStorageInfo();
|
||||
if (res?.code === 200) info.value = res.data || {};
|
||||
};
|
||||
|
||||
const loadPackages = async () => {
|
||||
const res = await getStoragePackages();
|
||||
if (res?.code === 200) packages.value = res.data?.list || [];
|
||||
};
|
||||
|
||||
const loadAll = async () => {
|
||||
loading.value = true;
|
||||
try {
|
||||
await Promise.all([loadInfo(), loadPackages()]);
|
||||
} catch (e: any) {
|
||||
ElMessage.error(e?.message || "加载空间信息失败");
|
||||
} finally {
|
||||
loading.value = false;
|
||||
}
|
||||
};
|
||||
|
||||
const renderQR = async () => {
|
||||
if (!payParams.value?.code_url) return;
|
||||
await nextTick();
|
||||
if (!qrRef.value) return;
|
||||
try {
|
||||
await QRCode.toCanvas(qrRef.value, payParams.value.code_url, { width: 200, margin: 1 });
|
||||
} catch (e) {
|
||||
console.error("二维码生成失败:", e);
|
||||
}
|
||||
};
|
||||
|
||||
const openPayUrl = (url: string) => {
|
||||
if (url) window.open(url, "_blank");
|
||||
};
|
||||
|
||||
const stopPolling = () => {
|
||||
if (pollTimer) {
|
||||
clearInterval(pollTimer);
|
||||
pollTimer = null;
|
||||
}
|
||||
pollCount = 0;
|
||||
};
|
||||
|
||||
const startPolling = (orderNo: string) => {
|
||||
stopPolling();
|
||||
pollTimer = setInterval(async () => {
|
||||
pollCount += 1;
|
||||
if (pollCount > 100) {
|
||||
stopPolling();
|
||||
payStatusText.value = "支付结果确认超时,请稍后在购买记录中查看";
|
||||
return;
|
||||
}
|
||||
try {
|
||||
const res = await getStorageOrder(orderNo);
|
||||
if (res?.code !== 200) return;
|
||||
const status = res.data?.status;
|
||||
if (status === "paid") {
|
||||
stopPolling();
|
||||
payStatusText.value = "支付成功,空间已扩容";
|
||||
ElMessage.success("支付成功,附件空间已扩容");
|
||||
payVisible.value = false;
|
||||
await loadInfo();
|
||||
}
|
||||
} catch {
|
||||
// 网络抖动继续轮询
|
||||
}
|
||||
}, 3000);
|
||||
};
|
||||
|
||||
const handleBuy = async (pkg: any) => {
|
||||
buyingId.value = pkg.id;
|
||||
try {
|
||||
const channelRes = await getPaymentChannels();
|
||||
const channels = channelRes?.code === 200 ? channelRes.data?.list || [] : [];
|
||||
const channel = channels.length ? channels[0].channel : "";
|
||||
|
||||
const res = await createStorageOrder({
|
||||
package_id: pkg.id,
|
||||
channel,
|
||||
pay_type: "",
|
||||
return_url: window.location.origin + window.location.pathname,
|
||||
});
|
||||
if (res?.code !== 200) {
|
||||
ElMessage.error(res?.msg || "下单失败");
|
||||
return;
|
||||
}
|
||||
|
||||
if (res.data?.free) {
|
||||
ElMessage.success("套餐已开通");
|
||||
await loadInfo();
|
||||
return;
|
||||
}
|
||||
|
||||
payParams.value = res.data?.pay_params || null;
|
||||
payAmount.value = Number(res.data?.amount || pkg.price || 0);
|
||||
currentChannelName.value = channels.find((x: any) => x.channel === channel)?.name || channel;
|
||||
payStatusText.value = "请在有效期内完成支付,支付成功后空间自动扩容";
|
||||
payVisible.value = true;
|
||||
await renderQR();
|
||||
if (payParams.value?.redirect_url) openPayUrl(payParams.value.redirect_url);
|
||||
startPolling(res.data.order_no);
|
||||
} catch (e: any) {
|
||||
ElMessage.error(e?.message || "下单失败");
|
||||
} finally {
|
||||
buyingId.value = null;
|
||||
}
|
||||
};
|
||||
|
||||
const handleCancelPay = () => {
|
||||
stopPolling();
|
||||
payVisible.value = false;
|
||||
payParams.value = null;
|
||||
};
|
||||
|
||||
const openOrders = async () => {
|
||||
ordersVisible.value = true;
|
||||
ordersLoading.value = true;
|
||||
try {
|
||||
const res = await getStorageOrders({ page: 1, pageSize: 50 });
|
||||
orders.value = res?.code === 200 ? res.data?.list || [] : [];
|
||||
} catch (e) {
|
||||
orders.value = [];
|
||||
} finally {
|
||||
ordersLoading.value = false;
|
||||
}
|
||||
};
|
||||
|
||||
onMounted(loadAll);
|
||||
onUnmounted(stopPolling);
|
||||
</script>
|
||||
|
||||
<style scoped lang="less">
|
||||
.storage-page {
|
||||
.overview-card {
|
||||
padding: 20px 22px;
|
||||
border: 1px solid var(--yz-border, #e8edf7);
|
||||
border-radius: 12px;
|
||||
background: var(--yz-card-bg, #fff);
|
||||
box-shadow: var(--yz-shadow, 0 2px 12px rgba(31, 61, 130, 0.06));
|
||||
}
|
||||
|
||||
.overview-head {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
|
||||
.overview-title {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
font-size: 16px;
|
||||
font-weight: 600;
|
||||
color: var(--el-text-color-primary);
|
||||
}
|
||||
}
|
||||
|
||||
.overview-usage {
|
||||
margin-top: 18px;
|
||||
display: flex;
|
||||
align-items: baseline;
|
||||
gap: 6px;
|
||||
|
||||
.used {
|
||||
font-size: 28px;
|
||||
font-weight: 700;
|
||||
color: var(--el-text-color-primary);
|
||||
}
|
||||
|
||||
.total {
|
||||
font-size: 14px;
|
||||
color: var(--el-text-color-secondary);
|
||||
}
|
||||
}
|
||||
|
||||
.overview-progress {
|
||||
margin-top: 10px;
|
||||
}
|
||||
|
||||
.overview-foot {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 12px;
|
||||
margin-top: 10px;
|
||||
font-size: 12px;
|
||||
color: var(--el-text-color-secondary);
|
||||
|
||||
.expire {
|
||||
color: var(--el-color-primary);
|
||||
}
|
||||
}
|
||||
|
||||
.section-title {
|
||||
display: flex;
|
||||
align-items: baseline;
|
||||
gap: 10px;
|
||||
margin: 26px 0 14px;
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
.package-grid {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
|
||||
gap: 14px;
|
||||
}
|
||||
|
||||
.package-card {
|
||||
padding: 20px;
|
||||
border: 1px solid var(--el-border-color-lighter);
|
||||
border-radius: 12px;
|
||||
background: var(--el-bg-color);
|
||||
transition: all 0.2s ease;
|
||||
|
||||
&:hover {
|
||||
border-color: var(--el-color-primary-light-7);
|
||||
box-shadow: 0 8px 24px rgba(47, 107, 255, 0.1);
|
||||
}
|
||||
|
||||
.package-name {
|
||||
font-size: 14px;
|
||||
font-weight: 600;
|
||||
color: var(--el-text-color-primary);
|
||||
}
|
||||
|
||||
.package-capacity {
|
||||
margin-top: 8px;
|
||||
font-size: 24px;
|
||||
font-weight: 700;
|
||||
color: var(--el-color-primary);
|
||||
}
|
||||
|
||||
.package-price {
|
||||
margin-top: 6px;
|
||||
color: var(--el-text-color-regular);
|
||||
|
||||
.symbol {
|
||||
font-size: 14px;
|
||||
}
|
||||
|
||||
.amount {
|
||||
font-size: 20px;
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
.unit {
|
||||
font-size: 12px;
|
||||
color: var(--el-text-color-secondary);
|
||||
}
|
||||
}
|
||||
|
||||
.package-remark {
|
||||
margin-top: 6px;
|
||||
font-size: 12px;
|
||||
color: var(--el-text-color-secondary);
|
||||
}
|
||||
|
||||
.package-btn {
|
||||
width: 100%;
|
||||
margin-top: 14px;
|
||||
}
|
||||
}
|
||||
|
||||
.pay-body {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
|
||||
.pay-qr {
|
||||
width: 200px;
|
||||
height: 200px;
|
||||
}
|
||||
|
||||
.pay-tip {
|
||||
margin: 0;
|
||||
font-size: 13px;
|
||||
color: var(--el-text-color-secondary);
|
||||
}
|
||||
|
||||
.pay-amount {
|
||||
margin: 0;
|
||||
font-size: 20px;
|
||||
font-weight: 700;
|
||||
color: var(--el-color-danger);
|
||||
}
|
||||
}
|
||||
|
||||
.pay-status {
|
||||
margin: 12px 0 0;
|
||||
text-align: center;
|
||||
font-size: 12px;
|
||||
color: var(--el-text-color-secondary);
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -46,9 +46,12 @@
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { ref, computed } from "vue";
|
||||
import { useRouter } from "vue-router";
|
||||
import { ElMessage, ElMessageBox } from "element-plus";
|
||||
import { UploadFilled } from "@element-plus/icons-vue";
|
||||
import { uploadFile } from "@/api/file";
|
||||
|
||||
const router = useRouter();
|
||||
import type { UploadInstance, UploadFile, UploadFiles } from "element-plus";
|
||||
|
||||
interface Props {
|
||||
@@ -240,6 +243,28 @@ const submitUpload = async () => {
|
||||
ElMessage.success(message);
|
||||
}
|
||||
if (failCount > 0) {
|
||||
// 附件空间不足(后端业务码 4032):引导购买扩容
|
||||
const quotaRejected = results.find(
|
||||
(r) =>
|
||||
r.status === "rejected" &&
|
||||
Number(r.reason?.error?.response?.data?.code) === 4032,
|
||||
);
|
||||
if (quotaRejected) {
|
||||
const quotaMsg =
|
||||
quotaRejected.reason?.error?.response?.data?.msg ||
|
||||
"附件空间不足,请购买扩容后再上传";
|
||||
ElMessageBox.confirm(quotaMsg, "附件空间不足", {
|
||||
confirmButtonText: "去扩容",
|
||||
cancelButtonText: "知道了",
|
||||
type: "warning",
|
||||
})
|
||||
.then(() => {
|
||||
handleClose();
|
||||
router.push("/basicSettings/storage");
|
||||
})
|
||||
.catch(() => {});
|
||||
return;
|
||||
}
|
||||
ElMessage.warning(`${failCount} 个文件上传失败`);
|
||||
}
|
||||
|
||||
|
||||
@@ -7,7 +7,23 @@
|
||||
<el-icon><Folder /></el-icon>
|
||||
文件管理系统
|
||||
</span>
|
||||
<el-button :icon="Refresh" @click="refushData"> 刷新 </el-button>
|
||||
<div class="header-right">
|
||||
<!-- 附件空间用量:点击进入扩容页 -->
|
||||
<div class="storage-usage" title="附件空间用量,点击扩容" @click="goStorage">
|
||||
<el-progress
|
||||
:percentage="storagePercent"
|
||||
:status="storageStatus"
|
||||
:stroke-width="6"
|
||||
:show-text="false"
|
||||
class="storage-bar"
|
||||
/>
|
||||
<span class="storage-text">
|
||||
空间 {{ storageText }}
|
||||
<span v-if="storagePercent >= 90" class="storage-warn">(即将用尽)</span>
|
||||
</span>
|
||||
</div>
|
||||
<el-button :icon="Refresh" @click="refushData"> 刷新 </el-button>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
@@ -457,6 +473,7 @@
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { ref, computed, onMounted } from "vue";
|
||||
import { useRouter } from "vue-router";
|
||||
import { ElMessage, ElMessageBox } from "element-plus";
|
||||
import {
|
||||
Folder,
|
||||
@@ -496,9 +513,49 @@ import UploadFile from "./components/uploadFile.vue";
|
||||
import MoveFile from "./components/moveFile.vue";
|
||||
import RenameCategory from "./components/renameCategory.vue";
|
||||
import CreateCategory from "./components/createCategory.vue";
|
||||
import { getStorageInfo } from "@/api/storage";
|
||||
// 日期显示统一为:YYYY-MM-DD
|
||||
import { formatDate } from "@/utils/datetime";
|
||||
|
||||
// ---------- 附件空间用量 ----------
|
||||
const router = useRouter();
|
||||
const storageInfo = ref<Record<string, any>>({});
|
||||
|
||||
const storagePercent = computed(() => {
|
||||
const p = Number(storageInfo.value.used_percent) || 0;
|
||||
return Math.min(100, Math.max(0, Math.round(p * 10) / 10));
|
||||
});
|
||||
|
||||
const storageStatus = computed(() => {
|
||||
if (storagePercent.value >= 95) return "exception";
|
||||
if (storagePercent.value >= 80) return "warning";
|
||||
return "";
|
||||
});
|
||||
|
||||
const formatStorageSize = (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 storageText = computed(
|
||||
() =>
|
||||
`${formatStorageSize(storageInfo.value.used_bytes)} / ${formatStorageSize(storageInfo.value.quota_bytes)}`,
|
||||
);
|
||||
|
||||
const loadStorageInfo = async () => {
|
||||
try {
|
||||
const res = await getStorageInfo();
|
||||
if (res?.code === 200) storageInfo.value = res.data || {};
|
||||
} catch {
|
||||
// 空间用量属于辅助信息,失败不影响文件管理
|
||||
}
|
||||
};
|
||||
|
||||
const goStorage = () => router.push("/basicSettings/storage");
|
||||
|
||||
// 分组相关
|
||||
interface Group {
|
||||
id: number;
|
||||
@@ -1247,6 +1304,7 @@ const handleBatchDeletePermanently = () => {
|
||||
// 初始化
|
||||
onMounted(() => {
|
||||
getUserCateData();
|
||||
loadStorageInfo();
|
||||
});
|
||||
</script>
|
||||
|
||||
@@ -1270,6 +1328,39 @@ onMounted(() => {
|
||||
font-size: 13px;
|
||||
color: var(--el-text-color-placeholder);
|
||||
}
|
||||
|
||||
.header-right {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 16px;
|
||||
}
|
||||
|
||||
// 附件空间用量(点击进入扩容页)
|
||||
.storage-usage {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 3px;
|
||||
min-width: 190px;
|
||||
cursor: pointer;
|
||||
|
||||
&:hover .storage-text {
|
||||
color: var(--el-color-primary);
|
||||
}
|
||||
|
||||
.storage-bar {
|
||||
width: 190px;
|
||||
}
|
||||
|
||||
.storage-text {
|
||||
font-size: 12px;
|
||||
color: var(--el-text-color-secondary);
|
||||
transition: color 0.2s ease;
|
||||
}
|
||||
|
||||
.storage-warn {
|
||||
color: var(--el-color-danger);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.group-card,
|
||||
|
||||
Reference in new issue
Block a user