Commit 49a74733 by chenwq

feat(reports,tasks): 为报表和任务页面添加入口概览统计卡片

补充了对应的CSS变量与样式定义,更新了页面模板与业务逻辑代码,适配多屏幕尺寸的样式配置,实现根据当前激活入口动态展示对应统计数据的功能。
1 parent 36d719d8
...@@ -5,10 +5,32 @@ ...@@ -5,10 +5,32 @@
<view class="reports-page"> <view class="reports-page">
<view class="reports-layout"> <view class="reports-layout">
<view class="reports-entry-panel"> <view class="reports-entry-panel">
<EntryGrid <view class="reports-entry-overview">
:items="reportEntryConfigs" <view class="reports-entry-overview__header">
:active-key="activeEntryKey" <text class="reports-entry-overview__title">今日概览</text>
@change="onEntryChange" /> <text class="reports-entry-overview__tag">当前:{{ activeEntryLabel }}</text>
</view>
<view class="reports-entry-overview__stats">
<view v-for="(item, index) in activeOverview.items"
:key="index"
class="reports-entry-overview__stat">
<text class="reports-entry-overview__label">{{ item.label }}</text>
<text class="reports-entry-overview__value">{{ item.value }}</text>
</view>
</view>
<view class="reports-entry-overview__progress">
<view class="reports-entry-overview__progress-bar"
:style="{ width: activeOverview.progress + '%' }"></view>
</view>
<text class="reports-entry-overview__desc">{{ activeOverview.desc }}</text>
</view>
<view class="reports-entry-grid-wrap">
<EntryGrid
:items="reportEntryConfigs"
:active-key="activeEntryKey"
@change="onEntryChange" />
</view>
</view> </view>
<view class="reports-content-panel"> <view class="reports-content-panel">
...@@ -29,13 +51,192 @@ import BrandReportPanel from "./components/BrandReportPanel.uvue"; ...@@ -29,13 +51,192 @@ import BrandReportPanel from "./components/BrandReportPanel.uvue";
import ReportOverview from "./components/ReportOverview.uvue"; import ReportOverview from "./components/ReportOverview.uvue";
import StoreReportPanel from "./components/StoreReportPanel.uvue"; import StoreReportPanel from "./components/StoreReportPanel.uvue";
import SummaryReportPanel from "./components/SummaryReportPanel.uvue"; import SummaryReportPanel from "./components/SummaryReportPanel.uvue";
import { BRAND_REPORT_METRICS, type BrandMetric } from "./constants/brandReportData.uts";
import { PERSONAL_REPORT_METRICS, type ReportMetric } from "./constants/overviewReportData.uts";
import { REPORT_ENTRY_CONFIGS, type ReportEntryKey } from "./constants/reportEntries.uts"; import { REPORT_ENTRY_CONFIGS, type ReportEntryKey } from "./constants/reportEntries.uts";
import { STORE_REPORTS, type StoreReport } from "./constants/storeReportData.uts";
import { SUMMARY_REPORT_METRICS, SUMMARY_STORES, type SummaryMetric } from "./constants/summaryReportData.uts";
import reportPageVars from "./styles/index.vars.uts"; import reportPageVars from "./styles/index.vars.uts";
const shellRef = ref(null); const shellRef = ref(null);
const reportEntryConfigs = REPORT_ENTRY_CONFIGS; const reportEntryConfigs = REPORT_ENTRY_CONFIGS;
const activeEntryKey = ref<ReportEntryKey>("personal"); const activeEntryKey = ref<ReportEntryKey>("personal");
type ReportOverviewItem = {
label: string
value: string
}
type ReportEntryOverview = {
items: ReportOverviewItem[]
progress: number
desc: string
}
function getPersonalMetricValue(label: string, fallback: string): string {
for (let i = 0; i < PERSONAL_REPORT_METRICS.length; i++) {
const item = PERSONAL_REPORT_METRICS[i] as ReportMetric;
if (item.label == label) {
return item.value;
}
}
return fallback;
}
function getBrandMetricValue(label: string, fallback: string): string {
for (let i = 0; i < BRAND_REPORT_METRICS.length; i++) {
const item = BRAND_REPORT_METRICS[i] as BrandMetric;
if (item.label == label) {
return item.value;
}
}
return fallback;
}
function getSummaryMetricValue(label: string, fallback: string): string {
for (let i = 0; i < SUMMARY_REPORT_METRICS.length; i++) {
const item = SUMMARY_REPORT_METRICS[i] as SummaryMetric;
if (item.label == label) {
return item.value;
}
}
return fallback;
}
function parseMetricNumber(value: string): number {
const cleaned = value
.replace("¥", "")
.replace(",", "")
.replace("单", "")
.replace("人", "")
.replace("%", "")
.replace("分", "");
const parsed = parseFloat(cleaned);
if (isNaN(parsed)) return 0;
return parsed;
}
function formatRevenue(value: number): string {
return "¥" + `${Math.round(value)}`;
}
function getStoreAverageConversion(): number {
let total = 0;
let count = 0;
for (let i = 0; i < STORE_REPORTS.length; i++) {
const item = STORE_REPORTS[i] as StoreReport;
if (item.conversionRate != "-") {
total = total + parseMetricNumber(item.conversionRate);
count++;
}
}
if (count <= 0) return 0;
return Math.round(total / count);
}
function getStoreTotalRevenue(): string {
let total = 0;
for (let i = 0; i < STORE_REPORTS.length; i++) {
const item = STORE_REPORTS[i] as StoreReport;
total = total + parseMetricNumber(item.revenue);
}
return formatRevenue(total);
}
function getStoreTotalOrders(): string {
let total = 0;
for (let i = 0; i < STORE_REPORTS.length; i++) {
const item = STORE_REPORTS[i] as StoreReport;
total = total + parseMetricNumber(item.orders);
}
return `${Math.round(total)}单`;
}
function createPersonalOverview(): ReportEntryOverview {
const revenue = getPersonalMetricValue("本月销售额", "¥0");
const orders = getPersonalMetricValue("本月订单", "0");
const score = getPersonalMetricValue("最新质检分", "0分");
const conversion = getPersonalMetricValue("转化率", "0%");
const progress = parseMetricNumber(conversion);
return {
items: [
{ label: "销售额", value: revenue } as ReportOverviewItem,
{ label: "订单", value: orders } as ReportOverviewItem,
{ label: "质检分", value: score } as ReportOverviewItem,
{ label: "转化率", value: conversion } as ReportOverviewItem
] as ReportOverviewItem[],
progress: progress,
desc: `个人转化率 ${conversion},本月订单 ${orders}`
} as ReportEntryOverview;
}
function createStoreOverview(): ReportEntryOverview {
const revenue = getStoreTotalRevenue();
const orders = getStoreTotalOrders();
const progress = getStoreAverageConversion();
const conversion = `${progress}%`;
return {
items: [
{ label: "门店数", value: `${STORE_REPORTS.length}` } as ReportOverviewItem,
{ label: "总营收", value: revenue } as ReportOverviewItem,
{ label: "总订单", value: orders } as ReportOverviewItem,
{ label: "平均转化", value: conversion } as ReportOverviewItem
] as ReportOverviewItem[],
progress: progress,
desc: `汇总 ${STORE_REPORTS.length} 家门店,平均转化率 ${conversion}`
} as ReportEntryOverview;
}
function createBrandOverview(): ReportEntryOverview {
const revenue = getBrandMetricValue("品牌总营收(月)", "¥0");
const orders = getBrandMetricValue("品牌订单数", "0单");
const conversion = getBrandMetricValue("品牌转化率", "0%");
const stores = getBrandMetricValue("展业门店", "0家");
const progress = parseMetricNumber(conversion);
return {
items: [
{ label: "品牌营收", value: revenue } as ReportOverviewItem,
{ label: "订单", value: orders } as ReportOverviewItem,
{ label: "转化率", value: conversion } as ReportOverviewItem,
{ label: "展业门店", value: stores } as ReportOverviewItem
] as ReportOverviewItem[],
progress: progress,
desc: `品牌转化率 ${conversion},展业门店 ${stores}`
} as ReportEntryOverview;
}
function createSummaryOverview(): ReportEntryOverview {
const revenue = getSummaryMetricValue("组织总营收", "¥0");
const orders = getSummaryMetricValue("总订单", "0单");
const sales = getSummaryMetricValue("在职销售", "0人");
const score = getSummaryMetricValue("平均质检分", "0分");
const progress = parseMetricNumber(score);
return {
items: [
{ label: "总营收", value: revenue } as ReportOverviewItem,
{ label: "总订单", value: orders } as ReportOverviewItem,
{ label: "销售", value: sales } as ReportOverviewItem,
{ label: "质检分", value: score } as ReportOverviewItem
] as ReportOverviewItem[],
progress: progress,
desc: `汇总 ${SUMMARY_STORES.length} 家门店,平均质检分 ${score}`
} as ReportEntryOverview;
}
const activeEntryLabel = computed((): string => {
if (activeEntryKey.value == "store") return "门店";
if (activeEntryKey.value == "brand") return "品牌";
if (activeEntryKey.value == "summary") return "汇总";
return "个人";
});
const activeOverview = computed((): ReportEntryOverview => {
if (activeEntryKey.value == "store") return createStoreOverview();
if (activeEntryKey.value == "brand") return createBrandOverview();
if (activeEntryKey.value == "summary") return createSummaryOverview();
return createPersonalOverview();
});
const activeEntryComponent = computed((): any => { const activeEntryComponent = computed((): any => {
if (activeEntryKey.value == "store") return StoreReportPanel; if (activeEntryKey.value == "store") return StoreReportPanel;
if (activeEntryKey.value == "brand") return BrandReportPanel; if (activeEntryKey.value == "brand") return BrandReportPanel;
......
...@@ -35,6 +35,111 @@ ...@@ -35,6 +35,111 @@
overflow: hidden; overflow: hidden;
} }
.reports-entry-grid-wrap {
width: 100%;
height: var(--reports-entry-grid-wrap-height, 38px);
flex-shrink: 0;
margin-top: var(--reports-entry-grid-wrap-margin-top, 0px);
box-sizing: border-box;
}
.reports-entry-overview {
display: var(--reports-entry-overview-display, none);
flex-direction: column;
margin: var(--reports-entry-overview-margin, 0px);
padding: var(--reports-entry-overview-padding, 0px);
border-radius: var(--reports-entry-overview-radius, 0px);
background-color: var(--reports-entry-overview-bg, transparent);
box-sizing: border-box;
}
.reports-entry-overview__header {
display: flex;
flex-direction: row;
align-items: center;
justify-content: space-between;
margin-bottom: 12px;
}
.reports-entry-overview__title {
font-size: 14px;
font-weight: 700;
color: var(--reports-text-primary, #111827);
}
.reports-entry-overview__tag {
height: 24px;
line-height: 24px;
padding: 0 9px;
border-radius: 6px;
background-color: #e8f0ff;
color: var(--reports-primary, #2f6af7);
font-size: 12px;
font-weight: 600;
flex-shrink: 0;
margin-left: 8px;
}
.reports-entry-overview__stats {
display: flex;
flex-direction: row;
flex-wrap: wrap;
justify-content: space-between;
}
.reports-entry-overview__stat {
width: 48%;
height: 50px;
display: flex;
flex-direction: column;
align-items: flex-start;
justify-content: center;
border-radius: 8px;
background-color: #ffffff;
border: 1px solid #edf3ff;
margin-bottom: 10px;
padding: 7px 10px;
box-sizing: border-box;
}
.reports-entry-overview__label {
font-size: 12px;
color: var(--reports-text-secondary, #8b97aa);
}
.reports-entry-overview__value {
margin-top: 2px;
font-size: 17px;
line-height: 20px;
font-weight: 700;
color: var(--reports-primary, #2f6af7);
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
.reports-entry-overview__progress {
width: 100%;
height: 7px;
border-radius: 99px;
background-color: #e7ecf3;
overflow: hidden;
}
.reports-entry-overview__progress-bar {
width: 68%;
height: 7px;
border-radius: 99px;
background-color: var(--reports-primary, #2f6af7);
}
.reports-entry-overview__desc {
margin-top: 10px;
font-size: 12px;
line-height: 17px;
color: var(--reports-text-secondary, #8b97aa);
}
.reports-content-panel { .reports-content-panel {
flex: 1; flex: 1;
min-width: 0; min-width: 0;
......
...@@ -17,6 +17,13 @@ export default { ...@@ -17,6 +17,13 @@ export default {
"--reports-entry-min-height": "38px", "--reports-entry-min-height": "38px",
"--reports-entry-margin-right": "0px", "--reports-entry-margin-right": "0px",
"--reports-entry-margin-bottom": "12px", "--reports-entry-margin-bottom": "12px",
"--reports-entry-grid-wrap-height": "38px",
"--reports-entry-grid-wrap-margin-top": "0px",
"--reports-entry-overview-display": "none",
"--reports-entry-overview-margin": "0px",
"--reports-entry-overview-padding": "0px",
"--reports-entry-overview-radius": "0px",
"--reports-entry-overview-bg": "transparent",
"--reports-content-bg": "transparent", "--reports-content-bg": "transparent",
"--reports-content-border": "0px solid transparent", "--reports-content-border": "0px solid transparent",
"--reports-content-radius": "0px", "--reports-content-radius": "0px",
...@@ -51,6 +58,13 @@ export default { ...@@ -51,6 +58,13 @@ export default {
"--reports-entry-min-height": "260px", "--reports-entry-min-height": "260px",
"--reports-entry-margin-right": "20px", "--reports-entry-margin-right": "20px",
"--reports-entry-margin-bottom": "0px", "--reports-entry-margin-bottom": "0px",
"--reports-entry-grid-wrap-height": "218px",
"--reports-entry-grid-wrap-margin-top": "12px",
"--reports-entry-overview-display": "flex",
"--reports-entry-overview-margin": "12px 14px 0",
"--reports-entry-overview-padding": "12px",
"--reports-entry-overview-radius": "10px",
"--reports-entry-overview-bg": "#f8fbff",
"--reports-content-bg": "#f7faff", "--reports-content-bg": "#f7faff",
"--reports-content-border": "1px solid #e6edf8", "--reports-content-border": "1px solid #e6edf8",
"--reports-content-radius": "16px", "--reports-content-radius": "16px",
...@@ -79,6 +93,10 @@ export default { ...@@ -79,6 +93,10 @@ export default {
"landscape-816x393": { "landscape-816x393": {
"--reports-entry-width": "220px", "--reports-entry-width": "220px",
"--reports-entry-height": "100%", "--reports-entry-height": "100%",
"--reports-entry-grid-wrap-height": "196px",
"--reports-entry-grid-wrap-margin-top": "10px",
"--reports-entry-overview-margin": "10px 10px 0",
"--reports-entry-overview-padding": "10px",
"--reports-metric-card-height": "92px", "--reports-metric-card-height": "92px",
"--reports-chart-height": "176px", "--reports-chart-height": "176px",
"--reports-chart-bar-width": "42px", "--reports-chart-bar-width": "42px",
......
...@@ -34,6 +34,110 @@ ...@@ -34,6 +34,110 @@
overflow: hidden; overflow: hidden;
} }
.tasks-entry-grid-wrap {
width: 100%;
height: var(--tasks-entry-grid-wrap-height, 40px);
flex-shrink: 0;
margin-top: var(--tasks-entry-grid-wrap-margin-top, 0px);
box-sizing: border-box;
}
.tasks-entry-overview {
display: var(--tasks-entry-overview-display, none);
flex-direction: column;
margin: var(--tasks-entry-overview-margin, 0px);
padding: var(--tasks-entry-overview-padding, 0px);
border-top: var(--tasks-entry-overview-border-top, 0px solid transparent);
border-radius: var(--tasks-entry-overview-radius, 0px);
background-color: var(--tasks-entry-overview-bg, transparent);
box-sizing: border-box;
}
.tasks-entry-overview__header {
display: flex;
flex-direction: row;
align-items: center;
justify-content: space-between;
margin-bottom: 12px;
}
.tasks-entry-overview__title {
font-size: 14px;
font-weight: 700;
color: var(--tasks-text-primary, #111827);
}
.tasks-entry-overview__tag {
height: 24px;
line-height: 24px;
padding: 0 9px;
border-radius: 6px;
background-color: #e8f0ff;
color: var(--tasks-primary, #2f6af7);
font-size: 12px;
font-weight: 600;
flex-shrink: 0;
margin-left: 8px;
}
.tasks-entry-overview__stats {
display: flex;
flex-direction: row;
flex-wrap: wrap;
justify-content: space-between;
}
.tasks-entry-overview__stat {
width: 48%;
height: 50px;
display: flex;
flex-direction: column;
align-items: flex-start;
justify-content: center;
border-radius: 8px;
background-color: #ffffff;
border: 1px solid #edf3ff;
margin-bottom: 10px;
padding: 7px 10px;
box-sizing: border-box;
}
.tasks-entry-overview__value {
margin-top: 2px;
font-size: 17px;
line-height: 20px;
font-weight: 700;
color: var(--tasks-primary, #2f6af7);
}
.tasks-entry-overview__label {
font-size: 12px;
color: #7b8798;
}
.tasks-entry-overview__progress {
width: 100%;
height: 7px;
border-radius: 99px;
background-color: #e7ecf3;
overflow: hidden;
margin-top: 0px;
}
.tasks-entry-overview__progress-bar {
width: 68%;
height: 7px;
border-radius: 99px;
background-color: var(--tasks-primary, #2f6af7);
}
.tasks-entry-overview__desc {
margin-top: 10px;
font-size: 12px;
line-height: 17px;
color: #8b97aa;
}
.tasks-content-panel { .tasks-content-panel {
flex: 1; flex: 1;
min-width: 0; min-width: 0;
......
...@@ -24,6 +24,14 @@ export default { ...@@ -24,6 +24,14 @@ export default {
"--tasks-entry-panel-min-height": "40px", "--tasks-entry-panel-min-height": "40px",
"--tasks-entry-panel-margin-right": "0px", "--tasks-entry-panel-margin-right": "0px",
"--tasks-entry-panel-margin-bottom": "12px", "--tasks-entry-panel-margin-bottom": "12px",
"--tasks-entry-grid-wrap-height": "40px",
"--tasks-entry-grid-wrap-margin-top": "0px",
"--tasks-entry-overview-display": "none",
"--tasks-entry-overview-margin": "0px",
"--tasks-entry-overview-padding": "0px",
"--tasks-entry-overview-border-top": "0px solid transparent",
"--tasks-entry-overview-radius": "0px",
"--tasks-entry-overview-bg": "transparent",
"--tasks-daily-form-padding": "16px", "--tasks-daily-form-padding": "16px",
"--tasks-daily-field-width": "48%", "--tasks-daily-field-width": "48%",
"--tasks-daily-textarea-height": "60px", "--tasks-daily-textarea-height": "60px",
...@@ -135,6 +143,14 @@ export default { ...@@ -135,6 +143,14 @@ export default {
"--tasks-entry-panel-min-height": "260px", "--tasks-entry-panel-min-height": "260px",
"--tasks-entry-panel-margin-right": "20px", "--tasks-entry-panel-margin-right": "20px",
"--tasks-entry-panel-margin-bottom": "0px", "--tasks-entry-panel-margin-bottom": "0px",
"--tasks-entry-grid-wrap-height": "218px",
"--tasks-entry-grid-wrap-margin-top": "12px",
"--tasks-entry-overview-display": "flex",
"--tasks-entry-overview-margin": "12px 14px 0",
"--tasks-entry-overview-padding": "12px",
"--tasks-entry-overview-border-top": "0px solid transparent",
"--tasks-entry-overview-radius": "10px",
"--tasks-entry-overview-bg": "#f8fbff",
"--tasks-daily-form-padding": "20px", "--tasks-daily-form-padding": "20px",
"--tasks-daily-field-width": "48%", "--tasks-daily-field-width": "48%",
"--tasks-daily-textarea-height": "72px", "--tasks-daily-textarea-height": "72px",
...@@ -244,6 +260,10 @@ export default { ...@@ -244,6 +260,10 @@ export default {
"landscape-816x393": { "landscape-816x393": {
"--tasks-entry-panel-width": "220px", "--tasks-entry-panel-width": "220px",
"--tasks-entry-panel-height": "100%", "--tasks-entry-panel-height": "100%",
"--tasks-entry-grid-wrap-height": "196px",
"--tasks-entry-grid-wrap-margin-top": "10px",
"--tasks-entry-overview-margin": "10px 10px 0",
"--tasks-entry-overview-padding": "10px",
"--tasks-content-padding": "12px", "--tasks-content-padding": "12px",
"--tasks-daily-report-card-width": "100%", "--tasks-daily-report-card-width": "100%",
"--tasks-daily-report-stat-height": "46px", "--tasks-daily-report-stat-height": "46px",
......
...@@ -5,10 +5,32 @@ ...@@ -5,10 +5,32 @@
<view class="tasks-page"> <view class="tasks-page">
<view class="tasks-layout"> <view class="tasks-layout">
<view class="tasks-entry-panel"> <view class="tasks-entry-panel">
<EntryGrid <view class="tasks-entry-overview">
:items="taskEntryConfigs" <view class="tasks-entry-overview__header">
:active-key="activeEntryKey" <text class="tasks-entry-overview__title">今日任务</text>
@change="onEntryChange" /> <text class="tasks-entry-overview__tag">当前:{{ activeEntryLabel }}</text>
</view>
<view class="tasks-entry-overview__stats">
<view v-for="(item, index) in activeOverview.items"
:key="index"
class="tasks-entry-overview__stat">
<text class="tasks-entry-overview__label">{{ item.label }}</text>
<text class="tasks-entry-overview__value">{{ item.value }}</text>
</view>
</view>
<view class="tasks-entry-overview__progress">
<view class="tasks-entry-overview__progress-bar"
:style="{ width: activeOverview.progress + '%' }"></view>
</view>
<text class="tasks-entry-overview__desc">{{ activeOverview.desc }}</text>
</view>
<view class="tasks-entry-grid-wrap">
<EntryGrid
:items="taskEntryConfigs"
:active-key="activeEntryKey"
@change="onEntryChange" />
</view>
</view> </view>
<view class="tasks-content-panel"> <view class="tasks-content-panel">
...@@ -29,6 +51,8 @@ import ReviewPanel from "./components/ReviewPanel.uvue"; ...@@ -29,6 +51,8 @@ import ReviewPanel from "./components/ReviewPanel.uvue";
import StrategyPanel from "./components/StrategyPanel.uvue"; import StrategyPanel from "./components/StrategyPanel.uvue";
import StudyPanel from "./components/StudyPanel.uvue"; import StudyPanel from "./components/StudyPanel.uvue";
import EntryGrid from "@/components/EntryGrid.uvue"; import EntryGrid from "@/components/EntryGrid.uvue";
import { STRATEGY_ITEMS, type StrategyItem } from "./constants/strategyData.uts";
import { PENDING_REVIEW_ITEMS, REVIEWED_ITEMS, type ReviewItem, type ReviewStatus } from "./constants/reviewData.uts";
import { TASK_ENTRY_CONFIGS, type TaskEntryKey } from "./constants/taskEntries.uts"; import { TASK_ENTRY_CONFIGS, type TaskEntryKey } from "./constants/taskEntries.uts";
import taskPageVars from "./styles/index.vars.uts"; import taskPageVars from "./styles/index.vars.uts";
...@@ -37,6 +61,116 @@ const shellRef = ref(null); ...@@ -37,6 +61,116 @@ const shellRef = ref(null);
const taskEntryConfigs = TASK_ENTRY_CONFIGS; const taskEntryConfigs = TASK_ENTRY_CONFIGS;
const activeEntryKey = ref<TaskEntryKey>("daily"); const activeEntryKey = ref<TaskEntryKey>("daily");
type TaskSummaryItem = {
label: string
value: string
}
type TaskOverview = {
items: TaskSummaryItem[]
progress: number
desc: string
}
const DAILY_OVERVIEW = {
items: [
{ label: "待提交", value: "1" } as TaskSummaryItem,
{ label: "已提交", value: "3" } as TaskSummaryItem,
{ label: "待补充", value: "1" } as TaskSummaryItem,
{ label: "完成率", value: "75%" } as TaskSummaryItem
] as TaskSummaryItem[],
progress: 75,
desc: "日报完成率 75%,还有 1 份待提交"
} as TaskOverview;
const STUDY_OVERVIEW = {
items: [
{ label: "学习中", value: "3" } as TaskSummaryItem,
{ label: "已完成", value: "5" } as TaskSummaryItem,
{ label: "待开始", value: "2" } as TaskSummaryItem,
{ label: "平均进度", value: "62%" } as TaskSummaryItem
] as TaskSummaryItem[],
progress: 62,
desc: "学习平均进度 62%,优先完成进行中的课程"
} as TaskOverview;
function getPercent(part: number, total: number): number {
if (total <= 0) return 0;
return Math.round(part * 100 / total);
}
function countStrategyByStatus(statusText: string): number {
let count = 0;
for (let i = 0; i < STRATEGY_ITEMS.length; i++) {
const item = STRATEGY_ITEMS[i] as StrategyItem;
if (item.statusText == statusText) {
count++;
}
}
return count;
}
function countReviewedByStatus(status: ReviewStatus): number {
let count = 0;
for (let i = 0; i < REVIEWED_ITEMS.length; i++) {
const item = REVIEWED_ITEMS[i] as ReviewItem;
if (item.status == status) {
count++;
}
}
return count;
}
function createStrategyOverview(): TaskOverview {
const activeCount = countStrategyByStatus("进行中");
const pendingCount = countStrategyByStatus("待开始");
const doneCount = countStrategyByStatus("已完成");
const total = STRATEGY_ITEMS.length;
const progress = getPercent(doneCount, total);
return {
items: [
{ label: "进行中", value: `${activeCount}` } as TaskSummaryItem,
{ label: "待开始", value: `${pendingCount}` } as TaskSummaryItem,
{ label: "已完成", value: `${doneCount}` } as TaskSummaryItem,
{ label: "完成率", value: `${progress}%` } as TaskSummaryItem
] as TaskSummaryItem[],
progress: progress,
desc: `策略完成率 ${progress}%,当前 ${activeCount} 项进行中`
} as TaskOverview;
}
function createReviewOverview(): TaskOverview {
const pendingCount = PENDING_REVIEW_ITEMS.length;
const passedCount = countReviewedByStatus("passed");
const rejectedCount = countReviewedByStatus("rejected");
const reviewedTotal = REVIEWED_ITEMS.length;
const progress = getPercent(passedCount, reviewedTotal);
return {
items: [
{ label: "待审阅", value: `${pendingCount}` } as TaskSummaryItem,
{ label: "已通过", value: `${passedCount}` } as TaskSummaryItem,
{ label: "已驳回", value: `${rejectedCount}` } as TaskSummaryItem,
{ label: "通过率", value: `${progress}%` } as TaskSummaryItem
] as TaskSummaryItem[],
progress: progress,
desc: `审阅通过率 ${progress}%,当前还有 ${pendingCount} 条待处理`
} as TaskOverview;
}
const activeEntryLabel = computed((): string => {
if (activeEntryKey.value == "study") return "学习";
if (activeEntryKey.value == "strategy") return "策略";
if (activeEntryKey.value == "review") return "审阅";
return "日报";
});
const activeOverview = computed((): TaskOverview => {
if (activeEntryKey.value == "study") return STUDY_OVERVIEW;
if (activeEntryKey.value == "strategy") return createStrategyOverview();
if (activeEntryKey.value == "review") return createReviewOverview();
return DAILY_OVERVIEW;
});
const activeEntryComponent = computed((): any => { const activeEntryComponent = computed((): any => {
if (activeEntryKey.value == "study") return StudyPanel; if (activeEntryKey.value == "study") return StudyPanel;
if (activeEntryKey.value == "strategy") return StrategyPanel; if (activeEntryKey.value == "strategy") return StrategyPanel;
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!