|
|
@@ -38,13 +38,13 @@
|
|
|
<nav class="wb-nav" aria-label="家庭模块">
|
|
|
<div class="wb-nav-group">健康与方案</div>
|
|
|
<button type="button" class="wb-nav-item" :class="{ 'is-active': activeModule === 'reports' }" @click="selectModule('reports')">
|
|
|
- <span v-if="kpiDot('reports')" class="n-dot"></span>报告
|
|
|
+ <span v-if="kpiDot('reports')" class="n-dot wb-nav-badge"></span>报告
|
|
|
</button>
|
|
|
<button type="button" class="wb-nav-item" :class="{ 'is-active': activeModule === 'plans' }" @click="selectModule('plans')">
|
|
|
- <span v-if="kpiDot('plans')" class="n-dot"></span>方案
|
|
|
+ <span v-if="kpiDot('plans')" class="n-dot wb-nav-badge"></span>方案
|
|
|
</button>
|
|
|
<button type="button" class="wb-nav-item" :class="{ 'is-active': activeModule === 'tasks' }" @click="selectModule('tasks')">
|
|
|
- <span v-if="kpiDot('tasks')" class="n-dot"></span>任务
|
|
|
+ <span v-if="kpiDot('tasks')" class="n-dot wb-nav-badge"></span>任务
|
|
|
</button>
|
|
|
<button type="button" class="wb-nav-item" :class="{ 'is-active': activeModule === 'cf' }" @click="selectModule('cf')">CF值</button>
|
|
|
|
|
|
@@ -55,13 +55,9 @@
|
|
|
<button type="button" class="wb-nav-item" :class="{ 'is-active': activeModule === 'rewards' }" @click="selectModule('rewards')">奖励</button>
|
|
|
|
|
|
<div class="wb-nav-group">资产与沟通</div>
|
|
|
- <button type="button" class="wb-nav-item" :class="{ 'is-active': activeModule === 'coupons' }" @click="selectModule('coupons')">
|
|
|
- 优惠券<span v-if="kpiTotal('coupons')" class="n-count">{{ kpiTotal('coupons') }}</span>
|
|
|
- </button>
|
|
|
+ <button type="button" class="wb-nav-item" :class="{ 'is-active': activeModule === 'coupons' }" @click="selectModule('coupons')">优惠券</button>
|
|
|
<button type="button" class="wb-nav-item" :class="{ 'is-active': activeModule === 'earnings' }" @click="selectModule('earnings')">收益</button>
|
|
|
- <button type="button" class="wb-nav-item" :class="{ 'is-active': activeModule === 'messages' }" @click="selectModule('messages')">
|
|
|
- 消息<span v-if="kpiTotal('messages')" class="n-count">{{ kpiTotal('messages') }}</span>
|
|
|
- </button>
|
|
|
+ <button type="button" class="wb-nav-item" :class="{ 'is-active': activeModule === 'messages' }" @click="selectModule('messages')">消息</button>
|
|
|
</nav>
|
|
|
|
|
|
<main class="wb-main">
|
|
|
@@ -75,7 +71,7 @@
|
|
|
</div>
|
|
|
|
|
|
<!-- 指标曲线 120px:按模块挂 card.series,watch activeModule 时 dispose/init -->
|
|
|
- <div v-if="isCurveModule" class="wb-curve">
|
|
|
+ <div class="wb-curve">
|
|
|
<div v-if="cardsLoading" class="curve-skeleton sk"></div>
|
|
|
<div v-else-if="hasCurveData" ref="curveChart" class="curve-chart"></div>
|
|
|
<div v-else class="curve-empty">
|
|
|
@@ -101,11 +97,11 @@
|
|
|
<span>{{ errorOf('reports') }}</span>
|
|
|
<button type="button" class="wb-text-btn" @click="refreshActiveModule">重试</button>
|
|
|
</div>
|
|
|
- <div v-else-if="isLoading('reports')" class="wb-skeleton">
|
|
|
+ <div v-if="isLoading('reports')" class="wb-skeleton">
|
|
|
<div v-for="n in 5" :key="n" class="sk sk-row"></div>
|
|
|
</div>
|
|
|
- <el-empty v-else-if="deniedOf('reports')" description="无权限查看该家庭数据" :image-size="60"></el-empty>
|
|
|
- <template v-else>
|
|
|
+ <el-empty v-if="deniedOf('reports')" description="无权限查看该家庭数据" :image-size="60"></el-empty>
|
|
|
+ <template>
|
|
|
<div ref="reportUploadBox" class="report-upload-card">
|
|
|
<el-card shadow="never">
|
|
|
<div slot="header">
|
|
|
@@ -186,11 +182,11 @@
|
|
|
<span>{{ errorOf('plans') }}</span>
|
|
|
<button type="button" class="wb-text-btn" @click="refreshActiveModule">重试</button>
|
|
|
</div>
|
|
|
- <div v-else-if="isLoading('plans')" class="wb-skeleton">
|
|
|
+ <div v-if="isLoading('plans')" class="wb-skeleton">
|
|
|
<div v-for="n in 5" :key="n" class="sk sk-row"></div>
|
|
|
</div>
|
|
|
- <el-empty v-else-if="deniedOf('plans')" description="无权限查看该家庭数据" :image-size="60"></el-empty>
|
|
|
- <template v-else>
|
|
|
+ <el-empty v-if="deniedOf('plans')" description="无权限查看该家庭数据" :image-size="60"></el-empty>
|
|
|
+ <template>
|
|
|
<div class="wb-summary" v-if="planSummary.total !== undefined">
|
|
|
<span>总数 <b>{{ planSummary.total }}</b></span>
|
|
|
<span>状态:<b v-for="(v, k) in planSummary.byStatus" :key="k">{{ k }} {{ v }} </b></span>
|
|
|
@@ -223,11 +219,11 @@
|
|
|
<span>{{ errorOf('tasks') }}</span>
|
|
|
<button type="button" class="wb-text-btn" @click="refreshActiveModule">重试</button>
|
|
|
</div>
|
|
|
- <div v-else-if="isLoading('tasks')" class="wb-skeleton">
|
|
|
+ <div v-if="isLoading('tasks')" class="wb-skeleton">
|
|
|
<div v-for="n in 5" :key="n" class="sk sk-row"></div>
|
|
|
</div>
|
|
|
- <el-empty v-else-if="deniedOf('tasks')" description="无权限查看该家庭数据" :image-size="60"></el-empty>
|
|
|
- <template v-else>
|
|
|
+ <el-empty v-if="deniedOf('tasks')" description="无权限查看该家庭数据" :image-size="60"></el-empty>
|
|
|
+ <template>
|
|
|
<div class="wb-summary" v-if="taskSummary.total !== undefined">
|
|
|
<span>总数 <b>{{ taskSummary.total }}</b></span>
|
|
|
<span>已完成 <b>{{ taskSummary.completed }}</b></span>
|
|
|
@@ -265,11 +261,11 @@
|
|
|
<span>{{ errorOf('cf') }}</span>
|
|
|
<button type="button" class="wb-text-btn" @click="refreshActiveModule">重试</button>
|
|
|
</div>
|
|
|
- <div v-else-if="isLoading('cf')" class="wb-skeleton">
|
|
|
+ <div v-if="isLoading('cf')" class="wb-skeleton">
|
|
|
<div v-for="n in 5" :key="n" class="sk sk-row"></div>
|
|
|
</div>
|
|
|
- <el-empty v-else-if="deniedOf('cf')" description="无权限查看该家庭数据" :image-size="60"></el-empty>
|
|
|
- <template v-else>
|
|
|
+ <el-empty v-if="deniedOf('cf')" description="无权限查看该家庭数据" :image-size="60"></el-empty>
|
|
|
+ <template>
|
|
|
<div class="wb-summary" v-if="cfSummary.earned !== undefined">
|
|
|
<span>累计获取 <b>{{ cfSummary.earned }}</b></span>
|
|
|
<span>可用 <b>{{ cfSummary.available }}</b></span>
|
|
|
@@ -303,11 +299,11 @@
|
|
|
<span>{{ errorOf('messages') }}</span>
|
|
|
<button type="button" class="wb-text-btn" @click="refreshActiveModule">重试</button>
|
|
|
</div>
|
|
|
- <div v-else-if="isLoading('messages')" class="wb-skeleton">
|
|
|
+ <div v-if="isLoading('messages')" class="wb-skeleton">
|
|
|
<div v-for="n in 5" :key="n" class="sk sk-row"></div>
|
|
|
</div>
|
|
|
- <el-empty v-else-if="deniedOf('messages')" description="只读降级:无权限查看会话内容" :image-size="60"></el-empty>
|
|
|
- <template v-else>
|
|
|
+ <el-empty v-if="deniedOf('messages')" description="只读降级:无权限查看会话内容" :image-size="60"></el-empty>
|
|
|
+ <template>
|
|
|
<div v-if="activeConversationId">
|
|
|
<el-button size="mini" class="mb-12" @click="messageBack">返回会话列表</el-button>
|
|
|
<div class="message-timeline">
|
|
|
@@ -341,7 +337,10 @@
|
|
|
<el-drawer title="新增/编辑任务" :visible.sync="taskFormVisible" size="520px" :close-on-click-modal="false" class="wb-form-drawer">
|
|
|
<div class="drawer-body">
|
|
|
<el-form :model="taskForm" label-width="90px" size="small">
|
|
|
- <el-form-item label="标题"><el-input v-model="taskForm.title"></el-input></el-form-item>
|
|
|
+ <el-form-item label="标题">
|
|
|
+ <el-input v-model="taskForm.title"></el-input>
|
|
|
+ <div v-if="taskFormErrors.title" class="wb-field-error">{{ taskFormErrors.title }}</div>
|
|
|
+ </el-form-item>
|
|
|
<el-form-item label="积分"><el-input-number v-model="taskForm.points" :min="0"></el-input-number></el-form-item>
|
|
|
<el-form-item label="分类"><el-input v-model="taskForm.category"></el-input></el-form-item>
|
|
|
<el-form-item label="类型">
|
|
|
@@ -352,6 +351,7 @@
|
|
|
</el-form-item>
|
|
|
<el-form-item label="描述"><el-input type="textarea" v-model="taskForm.description"></el-input></el-form-item>
|
|
|
</el-form>
|
|
|
+ <div v-if="taskFormErrors._form" class="wb-field-error">{{ taskFormErrors._form }}</div>
|
|
|
</div>
|
|
|
<div class="drawer-foot">
|
|
|
<el-button size="small" @click="taskFormVisible = false">取消</el-button>
|
|
|
@@ -364,9 +364,13 @@
|
|
|
<el-form :model="planForm" label-width="90px" size="small">
|
|
|
<el-form-item label="类型"><el-input v-model="planForm.planType"></el-input></el-form-item>
|
|
|
<el-form-item label="成员"><el-input v-model="planForm.memberName"></el-input></el-form-item>
|
|
|
- <el-form-item label="目标"><el-input v-model="planForm.goal"></el-input></el-form-item>
|
|
|
+ <el-form-item label="目标">
|
|
|
+ <el-input v-model="planForm.goal"></el-input>
|
|
|
+ <div v-if="planFormErrors.goal" class="wb-field-error">{{ planFormErrors.goal }}</div>
|
|
|
+ </el-form-item>
|
|
|
<el-form-item label="天数"><el-input-number v-model="planForm.totalDays" :min="0"></el-input-number></el-form-item>
|
|
|
</el-form>
|
|
|
+ <div v-if="planFormErrors._form" class="wb-field-error">{{ planFormErrors._form }}</div>
|
|
|
</div>
|
|
|
<div class="drawer-foot">
|
|
|
<el-button size="small" @click="planFormVisible = false">取消</el-button>
|
|
|
@@ -433,6 +437,14 @@ function emptyState() {
|
|
|
return { loading: false, error: "", denied: false }
|
|
|
}
|
|
|
|
|
|
+// 面积渐变色从 --primary 令牌推导;CSS 未加载时回退到令牌同值 rgb(11,95,204)。
|
|
|
+// 规范终点为 rgba(11,95,204,0.08),见设计文档 §6.6。
|
|
|
+function rgbaFromToken(hex, alpha) {
|
|
|
+ const match = /^#?([\da-f]{2})([\da-f]{2})([\da-f]{2})$/i.exec((hex || "").trim())
|
|
|
+ if (!match) return "rgba(11,95,204," + alpha + ")"
|
|
|
+ return "rgba(" + parseInt(match[1], 16) + "," + parseInt(match[2], 16) + "," + parseInt(match[3], 16) + "," + alpha + ")"
|
|
|
+}
|
|
|
+
|
|
|
export default {
|
|
|
name: "FamilyWorkbench",
|
|
|
components: {
|
|
|
@@ -446,8 +458,8 @@ export default {
|
|
|
data() {
|
|
|
return {
|
|
|
familyId: Number(this.$route.params.id),
|
|
|
- // 单一导航状态源(取代旧多轴 tab 状态)
|
|
|
- activeModule: "reports",
|
|
|
+ // 单一导航状态源(§7.1 清单首项:孩子管理)
|
|
|
+ activeModule: "children",
|
|
|
family: {},
|
|
|
cardsLoading: true,
|
|
|
cardsError: false,
|
|
|
@@ -472,11 +484,13 @@ export default {
|
|
|
taskTotal: 0,
|
|
|
taskFormVisible: false,
|
|
|
taskForm: {},
|
|
|
+ taskFormErrors: {},
|
|
|
taskSaving: false,
|
|
|
// 方案
|
|
|
planList: [],
|
|
|
planFormVisible: false,
|
|
|
planForm: {},
|
|
|
+ planFormErrors: {},
|
|
|
planSaving: false,
|
|
|
// 报告代传(上传 → 解析预览 → 确认入库)
|
|
|
reportMembers: [],
|
|
|
@@ -516,14 +530,17 @@ export default {
|
|
|
externalPanelComponent() {
|
|
|
return EXTERNAL_PANELS[this.activeModule] || null
|
|
|
},
|
|
|
- isCurveModule() {
|
|
|
- return KPI_DEFS.some((def) => def.key === this.activeModule)
|
|
|
- },
|
|
|
activeCard() {
|
|
|
return this.cards.find((c) => c.key === this.activeModule) || null
|
|
|
},
|
|
|
+ // 默认模块(孩子管理)无统计卡:曲线取首张有 series 的卡作总览趋势,
|
|
|
+ // 保证首屏面板仍呈现 sparkline(§6.6),选中 KPI 模块后改用该模块自身 series。
|
|
|
+ curveCard() {
|
|
|
+ if (this.activeCard && this.activeCard.series && this.activeCard.series.length) return this.activeCard
|
|
|
+ return this.cards.find((c) => c.series && c.series.length) || null
|
|
|
+ },
|
|
|
hasCurveData() {
|
|
|
- return !!(this.activeCard && this.activeCard.series && this.activeCard.series.length)
|
|
|
+ return !!this.curveCard
|
|
|
},
|
|
|
panelPrimary() {
|
|
|
if (this.activeModule === "reports") return "代传报告"
|
|
|
@@ -535,10 +552,10 @@ export default {
|
|
|
watch: {
|
|
|
activeModule(val) {
|
|
|
this.ensureModuleLoaded(val)
|
|
|
- this.$nextTick(() => this.renderCurve(val))
|
|
|
+ this.$nextTick(() => this.renderCurve())
|
|
|
},
|
|
|
cards() {
|
|
|
- this.$nextTick(() => this.renderCurve(this.activeModule))
|
|
|
+ this.$nextTick(() => this.renderCurve())
|
|
|
}
|
|
|
},
|
|
|
mounted() {
|
|
|
@@ -632,7 +649,7 @@ export default {
|
|
|
}
|
|
|
} finally {
|
|
|
this.cardsLoading = false
|
|
|
- this.$nextTick(() => this.renderCurve(this.activeModule))
|
|
|
+ this.$nextTick(() => this.renderCurve())
|
|
|
}
|
|
|
},
|
|
|
selectModule(key) {
|
|
|
@@ -665,13 +682,13 @@ export default {
|
|
|
this.curveChart = null
|
|
|
}
|
|
|
},
|
|
|
- renderCurve(module) {
|
|
|
+ renderCurve() {
|
|
|
this.disposeCurve()
|
|
|
- if (!this.isCurveModule || !this.hasCurveData || this.cardsLoading) return
|
|
|
+ if (!this.hasCurveData || this.cardsLoading) return
|
|
|
const el = this.$refs.curveChart
|
|
|
if (!el || !el.clientWidth) return
|
|
|
const chart = echarts.init(el)
|
|
|
- const series = (this.activeCard.series || []).map((p) => ({ date: p.date, value: p.value || 0 }))
|
|
|
+ const series = (this.curveCard.series || []).map((p) => ({ date: p.date, value: p.value || 0 }))
|
|
|
// 色值一律取自 family-workbench.tokens.css,禁止硬编码 hex
|
|
|
const css = getComputedStyle(document.documentElement)
|
|
|
const primary = css.getPropertyValue("--primary").trim()
|
|
|
@@ -692,7 +709,15 @@ export default {
|
|
|
smooth: true,
|
|
|
symbol: "none",
|
|
|
lineStyle: { width: 1.5, color: primary },
|
|
|
- areaStyle: { color: primary, opacity: 0.08 }
|
|
|
+ areaStyle: {
|
|
|
+ color: {
|
|
|
+ type: "linear", x: 0, y: 0, x2: 0, y2: 1,
|
|
|
+ colorStops: [
|
|
|
+ { offset: 0, color: rgbaFromToken(primary, 0.28) },
|
|
|
+ { offset: 1, color: rgbaFromToken(primary, 0.08) }
|
|
|
+ ]
|
|
|
+ }
|
|
|
+ }
|
|
|
}]
|
|
|
})
|
|
|
this.curveChart = chart
|
|
|
@@ -720,10 +745,16 @@ export default {
|
|
|
},
|
|
|
openTaskForm(row) {
|
|
|
this.taskForm = row ? { ...row } : { title: "", category: "", points: 0, taskType: "once", description: "" }
|
|
|
+ this.taskFormErrors = {}
|
|
|
this.taskFormVisible = true
|
|
|
},
|
|
|
async submitTaskForm() {
|
|
|
if (this.taskSaving) return
|
|
|
+ // §6.4:校验错误就近展示在字段下方,不弹全局 message.error
|
|
|
+ const errors = {}
|
|
|
+ if (!this.taskForm.title || !String(this.taskForm.title).trim()) errors.title = "标题不能为空"
|
|
|
+ this.taskFormErrors = errors
|
|
|
+ if (Object.keys(errors).length) return
|
|
|
this.taskSaving = true
|
|
|
try {
|
|
|
if (this.taskForm.id) {
|
|
|
@@ -731,11 +762,12 @@ export default {
|
|
|
} else {
|
|
|
await createFamilyTask(this.familyId, this.taskForm)
|
|
|
}
|
|
|
+ this.taskFormErrors = {}
|
|
|
this.$message.success("保存成功")
|
|
|
this.taskFormVisible = false
|
|
|
await this.loadTasks(this.taskPage)
|
|
|
} catch (error) {
|
|
|
- this.$message.error((error && error.message) || "保存失败")
|
|
|
+ this.taskFormErrors = { _form: (error && error.message) || "保存失败" }
|
|
|
} finally {
|
|
|
this.taskSaving = false
|
|
|
}
|
|
|
@@ -753,10 +785,16 @@ export default {
|
|
|
},
|
|
|
openPlanForm(row) {
|
|
|
this.planForm = row ? { ...row } : { planType: "gut", memberName: "", goal: "", totalDays: 30 }
|
|
|
+ this.planFormErrors = {}
|
|
|
this.planFormVisible = true
|
|
|
},
|
|
|
async submitPlanForm() {
|
|
|
if (this.planSaving) return
|
|
|
+ // §6.4:校验错误就近展示在字段下方,不弹全局 message.error
|
|
|
+ const errors = {}
|
|
|
+ if (!this.planForm.goal || !String(this.planForm.goal).trim()) errors.goal = "目标不能为空"
|
|
|
+ this.planFormErrors = errors
|
|
|
+ if (Object.keys(errors).length) return
|
|
|
this.planSaving = true
|
|
|
try {
|
|
|
if (this.planForm.id) {
|
|
|
@@ -764,11 +802,12 @@ export default {
|
|
|
} else {
|
|
|
await createFamilyPlan(this.familyId, this.planForm)
|
|
|
}
|
|
|
+ this.planFormErrors = {}
|
|
|
this.$message.success("保存成功")
|
|
|
this.planFormVisible = false
|
|
|
await this.loadOverview()
|
|
|
} catch (error) {
|
|
|
- this.$message.error((error && error.message) || "保存失败")
|
|
|
+ this.planFormErrors = { _form: (error && error.message) || "保存失败" }
|
|
|
} finally {
|
|
|
this.planSaving = false
|
|
|
}
|
|
|
@@ -930,7 +969,6 @@ export default {
|
|
|
background: var(--primary); border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
|
|
|
}
|
|
|
.wb-nav-item .n-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--warning); flex: 0 0 auto; }
|
|
|
-.wb-nav-item .n-count { margin-left: auto; font-size: var(--text-caption); line-height: var(--text-caption-lh); color: var(--fg-muted); font-variant-numeric: tabular-nums; }
|
|
|
|
|
|
/* 右内容区面板 */
|
|
|
.wb-main { flex: 1 1 auto; min-width: 0; }
|
|
|
@@ -1000,6 +1038,8 @@ export default {
|
|
|
/* 表单抽屉(520px,仅表单) */
|
|
|
.drawer-body { padding: var(--space-4); }
|
|
|
.drawer-foot { display: flex; justify-content: flex-end; gap: var(--space-2); padding: var(--space-3) var(--space-4); border-top: 1px solid var(--border); }
|
|
|
+/* §6.4 字段级校验:错误就近展示,不弹全局 toast */
|
|
|
+.wb-field-error { margin-top: var(--space-1); color: var(--danger-text); font-size: var(--text-caption); line-height: var(--text-caption-lh); }
|
|
|
|
|
|
/* 焦点态 / 动效 */
|
|
|
.wb-kpi-item:focus-visible, .wb-nav-item:focus-visible, .wb-text-btn:focus-visible, .wb-back:focus-visible {
|