Phase 1: OKR模板 — 两步弹窗(O+KR结构) + 14个CMA模板 + okr_templates表 + API
MapCanvasDialogs.vue: - 节点编辑弹窗改为两步交互(模板选择→O+KR编辑) - 第一步:按维度展示对应模板(财务4/客户3/流程4/学习3) - 第二步:编辑O名称+描述+3个KR(名称/目标值/权重) - 14个CMA标准模板硬编码在前端 - 支持添加/删除KR、自定义目标跳过模板 MapCanvas.vue: - 传递 editingLayerKey 到弹窗 - onSaveDialog 适配新 O+KR 数据结构 - onNodeSave 存储 krs 和 template_name 字段 Backend: - OKRTemplate 模型 (okr_templates 表) - okr_templates API: GET(按维度筛选) + POST(用户自定义) + increment use_count - seed_okr_templates.py 迁移脚本(建表+14条种子数据) - 在 main.py 注册新路由
This commit is contained in:
@@ -1,47 +1,114 @@
|
||||
<template>
|
||||
<!-- 节点编辑弹窗 -->
|
||||
<MyDialog :model-value="showNodeDialog" @update:model-value="$emit('update:showNodeDialog', $event)" :title="isEditing ? '编辑目标' : '添加目标'" :width="520">
|
||||
<div class="mc-dialog-body">
|
||||
<div class="mc-form-item">
|
||||
<label>目标名称 <span class="mc-required">*</span></label>
|
||||
<input v-model="form.name" class="mc-input" placeholder="请输入目标名称" ref="dialogNameRef" />
|
||||
</div>
|
||||
<div class="mc-form-item">
|
||||
<label>描述</label>
|
||||
<textarea v-model="form.description" class="mc-input mc-textarea" rows="3" placeholder="目标描述(可选)"></textarea>
|
||||
</div>
|
||||
<div class="mc-form-item">
|
||||
<label>图标</label>
|
||||
<div class="mc-icon-picker">
|
||||
<button v-for="(ico, key) in iconOptions" :key="key"
|
||||
class="mc-icon-btn" :class="{ active: form.icon === key }"
|
||||
@click="form.icon = key" :title="ico">{{ iconEmoji(key) }}</button>
|
||||
<!-- ==========================================================
|
||||
第一步:选择模板弹窗
|
||||
========================================================== -->
|
||||
<MyDialog :model-value="showNodeDialog" @update:model-value="$emit('update:showNodeDialog', $event)" :title="dialogTitle" :width="620">
|
||||
<div v-if="dialogStep === 1" class="mc-template-step">
|
||||
<div class="mc-step-hint">步骤 1/2 — 选择目标模板(或自定义)</div>
|
||||
|
||||
<!-- 维度名称显示 -->
|
||||
<div class="mc-dim-label">{{ dimensionName }}</div>
|
||||
|
||||
<!-- 模板列表 -->
|
||||
<div class="mc-tmpl-list">
|
||||
<div
|
||||
v-for="(tmpl, idx) in filteredTemplates"
|
||||
:key="idx"
|
||||
class="mc-tmpl-card"
|
||||
:class="{ selected: selectedTemplateIdx === idx }"
|
||||
@click="selectedTemplateIdx = idx"
|
||||
>
|
||||
<div class="mc-tmpl-header">
|
||||
<span class="mc-tmpl-name">{{ tmpl.name }}</span>
|
||||
<span v-if="selectedTemplateIdx === idx" class="mc-tmpl-check">✓</span>
|
||||
</div>
|
||||
<div class="mc-tmpl-desc">{{ tmpl.description }}</div>
|
||||
<div class="mc-tmpl-krs">
|
||||
<span v-for="(kr, ki) in tmpl.preset_krs" :key="ki" class="mc-tmpl-kr-tag">
|
||||
{{ kr.name }}
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="mc-form-item">
|
||||
<label>目标值 <span class="mc-hint">(CMA字段)</span></label>
|
||||
<input v-model="form.targetValue" class="mc-input" type="number" placeholder="目标值" />
|
||||
</div>
|
||||
<div class="mc-row">
|
||||
<input v-model="form.currentValue" class="mc-input mc-input-half" type="number" placeholder="当前值" />
|
||||
<input v-model="form.unit" class="mc-input mc-input-half" placeholder="单位(如%、万元)" />
|
||||
</div>
|
||||
<div class="mc-row">
|
||||
<input v-model="form.owner" class="mc-input" placeholder="责任人" />
|
||||
</div>
|
||||
<div class="mc-form-item">
|
||||
<label>指标类型</label>
|
||||
<label class="mc-radio-label"><input type="radio" v-model="form.isLeading" :value="false" /> 滞后指标(结果)</label>
|
||||
<label class="mc-radio-label"><input type="radio" v-model="form.isLeading" :value="true" /> 领先指标(驱动)</label>
|
||||
|
||||
<!-- 无模板提示(理论上不会出现,留防御) -->
|
||||
<div v-if="filteredTemplates.length === 0" class="mc-tmpl-empty">
|
||||
当前维度没有预设模板,请直接自定义
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- ==========================================================
|
||||
第二步:编辑 O + KR
|
||||
========================================================== -->
|
||||
<div v-if="dialogStep === 2" class="mc-okr-step">
|
||||
<div class="mc-step-hint">步骤 2/2 — 编辑目标与关键结果</div>
|
||||
|
||||
<div class="mc-form-item">
|
||||
<label>🎯 目标名称 <span class="mc-required">*</span></label>
|
||||
<input v-model="form.o_name" class="mc-input" placeholder="请输入目标名称" />
|
||||
</div>
|
||||
<div class="mc-form-item">
|
||||
<label>📝 目标描述</label>
|
||||
<textarea v-model="form.o_description" class="mc-input mc-textarea" rows="2" placeholder="目标描述(可选)"></textarea>
|
||||
</div>
|
||||
|
||||
<div class="mc-kr-section">
|
||||
<div class="mc-kr-header">
|
||||
<span>关键结果({{ form.krs.length }}条)</span>
|
||||
<el-button size="small" type="primary" plain @click="addKr">+ 添加KR</el-button>
|
||||
</div>
|
||||
|
||||
<div v-for="(kr, ki) in form.krs" :key="ki" class="mc-kr-row">
|
||||
<div class="mc-kr-row-top">
|
||||
<span class="mc-kr-index">#{{ ki + 1 }}</span>
|
||||
<input v-model="kr.name" class="mc-input mc-kr-name" placeholder="KR名称" />
|
||||
<el-button v-if="form.krs.length > 1" size="small" text type="danger" @click="removeKr(ki)">×</el-button>
|
||||
</div>
|
||||
<div class="mc-kr-row-bottom">
|
||||
<div class="mc-kr-field">
|
||||
<label>目标值</label>
|
||||
<input v-model="kr.target_value" class="mc-input mc-kr-input" placeholder="如 ≥18%" />
|
||||
</div>
|
||||
<div class="mc-kr-field">
|
||||
<label>权重</label>
|
||||
<select v-model="kr.weight" class="mc-input mc-kr-input">
|
||||
<option value="10">10%</option>
|
||||
<option value="20">20%</option>
|
||||
<option value="25">25%</option>
|
||||
<option value="30">30%</option>
|
||||
<option value="33">33%</option>
|
||||
<option value="40">40%</option>
|
||||
<option value="50">50%</option>
|
||||
<option value="60">60%</option>
|
||||
<option value="70">70%</option>
|
||||
<option value="80">80%</option>
|
||||
<option value="100">100%</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<template #footer>
|
||||
<el-button size="small" @click="$emit('update:showNodeDialog', false)">取消</el-button>
|
||||
<el-button size="small" type="primary" @click="$emit('save-node-dialog')">保存</el-button>
|
||||
<div v-if="dialogStep === 1" class="mc-footer-buttons">
|
||||
<el-button size="small" @click="onCancel">取消</el-button>
|
||||
<el-button size="small" plain @click="skipTemplate">✏️ 自定义目标</el-button>
|
||||
<el-button size="small" type="primary" :disabled="selectedTemplateIdx === null" @click="nextStep">
|
||||
下一步
|
||||
</el-button>
|
||||
</div>
|
||||
<div v-if="dialogStep === 2" class="mc-footer-buttons">
|
||||
<el-button size="small" @click="prevStep">上一步</el-button>
|
||||
<el-button size="small" @click="onCancel">取消</el-button>
|
||||
<el-button size="small" type="primary" @click="onSave">保存</el-button>
|
||||
</div>
|
||||
</template>
|
||||
</MyDialog>
|
||||
|
||||
<!-- KPI因果链推荐弹窗 -->
|
||||
<!-- ==========================================================
|
||||
KPI 因果链推荐弹窗(不变)
|
||||
========================================================== -->
|
||||
<MyDialog :model-value="showCausalityDialog" @update:model-value="$emit('update:showCausalityDialog', $event)" title="KPI因果链推荐" :width="680">
|
||||
<div style="max-height:400px;overflow-y:auto;">
|
||||
<div v-if="causalityLoading" style="text-align:center;padding:20px;color:#999;">加载中...</div>
|
||||
@@ -64,7 +131,9 @@
|
||||
</template>
|
||||
</MyDialog>
|
||||
|
||||
<!-- 版本历史弹窗 -->
|
||||
<!-- ==========================================================
|
||||
版本历史弹窗(不变)
|
||||
========================================================== -->
|
||||
<MyDialog :model-value="showVersions" @update:model-value="$emit('update:showVersions', $event)" title="版本历史" :width="620">
|
||||
<div style="max-height:400px;overflow-y:auto;">
|
||||
<table class="mc-table" v-if="versions.length > 0">
|
||||
@@ -81,7 +150,9 @@
|
||||
</div>
|
||||
</MyDialog>
|
||||
|
||||
<!-- KPI详情浮层 -->
|
||||
<!-- ==========================================================
|
||||
KPI 详情浮层(不变)
|
||||
========================================================== -->
|
||||
<MyDialog :model-value="showKpiDetail" @update:model-value="$emit('update:showKpiDetail', $event)" :title="'KPI详情'" :width="560">
|
||||
<div style="max-height:360px;overflow-y:auto;">
|
||||
<div v-if="kpiDetailList.length === 0" style="text-align:center;color:#999;padding:20px;">
|
||||
@@ -121,7 +192,9 @@
|
||||
</template>
|
||||
</MyDialog>
|
||||
|
||||
<!-- 行动方案列表弹窗 -->
|
||||
<!-- ==========================================================
|
||||
行动方案列表弹窗(不变)
|
||||
========================================================== -->
|
||||
<MyDialog :model-value="showPlanPopup" @update:model-value="$emit('update:showPlanPopup', $event)" :title="'行动方案'" :width="600">
|
||||
<div style="max-height:400px;overflow-y:auto;">
|
||||
<div v-if="planPopupList.length === 0" style="text-align:center;color:#999;padding:20px;">
|
||||
@@ -145,3 +218,557 @@
|
||||
</template>
|
||||
</MyDialog>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { ref, computed, watch } from "vue"
|
||||
|
||||
// ── Props ──
|
||||
const props = defineProps<{
|
||||
showNodeDialog: boolean
|
||||
showCausalityDialog: boolean
|
||||
showVersions: boolean
|
||||
showKpiDetail: boolean
|
||||
showPlanPopup: boolean
|
||||
isEditing: boolean
|
||||
form: any // 保持兼容
|
||||
causalityLoading: boolean
|
||||
causalityRecommendations: any[]
|
||||
versions: any[]
|
||||
kpiDetailObjName: string
|
||||
kpiDetailList: any[]
|
||||
planPopupObjName: string
|
||||
planPopupList: any[]
|
||||
editingLayerKey?: string // 当前编辑的维度key
|
||||
}>()
|
||||
|
||||
// ── Emits ──
|
||||
const emit = defineEmits<{
|
||||
(e: 'update:showNodeDialog', v: boolean): void
|
||||
(e: 'update:showCausalityDialog', v: boolean): void
|
||||
(e: 'update:showVersions', v: boolean): void
|
||||
(e: 'update:showKpiDetail', v: boolean): void
|
||||
(e: 'update:showPlanPopup', v: boolean): void
|
||||
(e: 'save-node-dialog', data: any): void
|
||||
(e: 'apply-causality', rec: any): void
|
||||
(e: 'apply-all-causality'): void
|
||||
(e: 'rollback-version', id: number): void
|
||||
(e: 'edit-kpi-obj'): void
|
||||
(e: 'quick-create-plan'): void
|
||||
}>()
|
||||
|
||||
// ── 14 个 CMA 标准模板(硬编码) ──
|
||||
const CMA_TEMPLATES = {
|
||||
finance: [
|
||||
{
|
||||
name: "扩大收入规模",
|
||||
description: "通过新市场开拓、新产品线、新客户群实现收入增长",
|
||||
dimension: "finance",
|
||||
preset_krs: [
|
||||
{ name: "营收增长率≥20%", target_value: "≥20%", weight: 40 },
|
||||
{ name: "新客户收入占比≥15%", target_value: "≥15%", weight: 30 },
|
||||
{ name: "客单价提升≥10%", target_value: "≥10%", weight: 30 },
|
||||
],
|
||||
},
|
||||
{
|
||||
name: "优化成本结构",
|
||||
description: "通过成本降低和费用管控提升盈利能力",
|
||||
dimension: "finance",
|
||||
preset_krs: [
|
||||
{ name: "毛利率提升≥3%", target_value: "≥3%", weight: 40 },
|
||||
{ name: "管理费用率≤15%", target_value: "≤15%", weight: 30 },
|
||||
{ name: "销售费用率≤10%", target_value: "≤10%", weight: 30 },
|
||||
],
|
||||
},
|
||||
{
|
||||
name: "提升资产效率",
|
||||
description: "提高资产周转速度,释放沉淀资金",
|
||||
dimension: "finance",
|
||||
preset_krs: [
|
||||
{ name: "库存周转天数≤45天", target_value: "≤45天", weight: 34 },
|
||||
{ name: "应收账款周转天数≤45天", target_value: "≤45天", weight: 33 },
|
||||
{ name: "总资产周转率≥1.0", target_value: "≥1.0", weight: 33 },
|
||||
],
|
||||
},
|
||||
{
|
||||
name: "保障现金流安全",
|
||||
description: "确保经营现金流为正,防范流动性风险",
|
||||
dimension: "finance",
|
||||
preset_krs: [
|
||||
{ name: "现金比率≥20%", target_value: "≥20%", weight: 34 },
|
||||
{ name: "经营现金流为正", target_value: "为正", weight: 33 },
|
||||
{ name: "自由现金流≥0", target_value: "≥0", weight: 33 },
|
||||
],
|
||||
},
|
||||
],
|
||||
customer: [
|
||||
{
|
||||
name: "产品领先",
|
||||
description: "提供行业最优的产品质量和功能",
|
||||
dimension: "customer",
|
||||
preset_krs: [
|
||||
{ name: "产品合格率≥99%", target_value: "≥99%", weight: 34 },
|
||||
{ name: "NPS净推荐值≥60", target_value: "≥60", weight: 33 },
|
||||
{ name: "市场份额提升≥2%", target_value: "≥2%", weight: 33 },
|
||||
],
|
||||
},
|
||||
{
|
||||
name: "客户亲密",
|
||||
description: "建立深度客户关系,提升客户粘性",
|
||||
dimension: "customer",
|
||||
preset_krs: [
|
||||
{ name: "客户满意度≥90%", target_value: "≥90%", weight: 34 },
|
||||
{ name: "大客户留存率≥95%", target_value: "≥95%", weight: 33 },
|
||||
{ name: "服务响应时间≤2小时", target_value: "≤2小时", weight: 33 },
|
||||
],
|
||||
},
|
||||
{
|
||||
name: "卓越运营",
|
||||
description: "以最优的价格和最高的便利性服务客户",
|
||||
dimension: "customer",
|
||||
preset_krs: [
|
||||
{ name: "价格竞争力行业TOP3", target_value: "TOP3", weight: 34 },
|
||||
{ name: "按时交付率≥98%", target_value: "≥98%", weight: 33 },
|
||||
{ name: "客户投诉率≤1%", target_value: "≤1%", weight: 33 },
|
||||
],
|
||||
},
|
||||
],
|
||||
process: [
|
||||
{
|
||||
name: "运营高效顺畅",
|
||||
description: "优化供应链和交付流程,提升运营效率",
|
||||
dimension: "process",
|
||||
preset_krs: [
|
||||
{ name: "交付及时率≥95%", target_value: "≥95%", weight: 34 },
|
||||
{ name: "库存周转≤45天", target_value: "≤45天", weight: 33 },
|
||||
{ name: "流程自动化率≥30%", target_value: "≥30%", weight: 33 },
|
||||
],
|
||||
},
|
||||
{
|
||||
name: "客户管理有序",
|
||||
description: "建立标准化客户管理流程",
|
||||
dimension: "process",
|
||||
preset_krs: [
|
||||
{ name: "新客获取成本下降≥10%", target_value: "≥10%", weight: 34 },
|
||||
{ name: "客户流失率≤5%", target_value: "≤5%", weight: 33 },
|
||||
{ name: "客户线索转化率≥20%", target_value: "≥20%", weight: 33 },
|
||||
],
|
||||
},
|
||||
{
|
||||
name: "创新驱动增长",
|
||||
description: "通过产品和服务创新驱动业务增长",
|
||||
dimension: "process",
|
||||
preset_krs: [
|
||||
{ name: "新产品收入占比≥15%", target_value: "≥15%", weight: 34 },
|
||||
{ name: "研发投入占比≥5%", target_value: "≥5%", weight: 33 },
|
||||
{ name: "年度创新提案≥12项", target_value: "≥12项", weight: 33 },
|
||||
],
|
||||
},
|
||||
{
|
||||
name: "合规稳健运营",
|
||||
description: "确保合规运营,防范法律和税务风险",
|
||||
dimension: "process",
|
||||
preset_krs: [
|
||||
{ name: "合规事件0起", target_value: "0起", weight: 34 },
|
||||
{ name: "审计通过率100%", target_value: "100%", weight: 33 },
|
||||
{ name: "税务申报及时率100%", target_value: "100%", weight: 33 },
|
||||
],
|
||||
},
|
||||
],
|
||||
learning: [
|
||||
{
|
||||
name: "团队能力升级",
|
||||
description: "提升员工核心技能和关键岗位胜任度",
|
||||
dimension: "learning",
|
||||
preset_krs: [
|
||||
{ name: "关键岗位培训完成率100%", target_value: "100%", weight: 34 },
|
||||
{ name: "认证持有率≥80%", target_value: "≥80%", weight: 33 },
|
||||
{ name: "人均培训时长≥40小时/年", target_value: "≥40小时/年", weight: 33 },
|
||||
],
|
||||
},
|
||||
{
|
||||
name: "数字系统赋能",
|
||||
description: "通过数字化系统提升工作效率",
|
||||
dimension: "learning",
|
||||
preset_krs: [
|
||||
{ name: "系统覆盖率≥90%", target_value: "≥90%", weight: 34 },
|
||||
{ name: "数据自动化率≥70%", target_value: "≥70%", weight: 33 },
|
||||
{ name: "报表自动生成率≥80%", target_value: "≥80%", weight: 33 },
|
||||
],
|
||||
},
|
||||
{
|
||||
name: "组织协同对齐",
|
||||
description: "建立高绩效文化和战略共识",
|
||||
dimension: "learning",
|
||||
preset_krs: [
|
||||
{ name: "员工满意度≥85%", target_value: "≥85%", weight: 34 },
|
||||
{ name: "战略认知度≥80%", target_value: "≥80%", weight: 33 },
|
||||
{ name: "跨部门协作评分≥4分", target_value: "≥4分", weight: 33 },
|
||||
],
|
||||
},
|
||||
],
|
||||
}
|
||||
|
||||
// ── 维度中文名映射 ──
|
||||
const DIMENSION_LABELS: Record<string, string> = {
|
||||
finance: "💰 财务层",
|
||||
customer: "👥 客户层",
|
||||
process: "⚙️ 内部流程层",
|
||||
learning: "📚 学习成长层",
|
||||
}
|
||||
|
||||
// ── 状态 ──
|
||||
const dialogStep = ref(1) // 1 = 模板选择, 2 = O+KR编辑
|
||||
const selectedTemplateIdx = ref<number | null>(null)
|
||||
const usedTemplate = ref<any | null>(null)
|
||||
|
||||
// 内部表单(O+KR结构)
|
||||
const form = ref<{
|
||||
o_name: string
|
||||
o_description: string
|
||||
krs: { name: string; target_value: string; weight: string }[]
|
||||
}>({
|
||||
o_name: "",
|
||||
o_description: "",
|
||||
krs: [],
|
||||
})
|
||||
|
||||
// ── 计算属性 ──
|
||||
const dimensionName = computed(() => {
|
||||
const key = props.editingLayerKey || "finance"
|
||||
return DIMENSION_LABELS[key] || key
|
||||
})
|
||||
|
||||
const filteredTemplates = computed(() => {
|
||||
const key = props.editingLayerKey || "finance"
|
||||
return (CMA_TEMPLATES as any)[key] || []
|
||||
})
|
||||
|
||||
const dialogTitle = computed(() => {
|
||||
return props.isEditing ? "编辑目标" : "添加目标"
|
||||
})
|
||||
|
||||
// ── 方法 ──
|
||||
function resetForm() {
|
||||
dialogStep.value = 1
|
||||
selectedTemplateIdx.value = null
|
||||
usedTemplate.value = null
|
||||
form.value = {
|
||||
o_name: "",
|
||||
o_description: "",
|
||||
krs: [],
|
||||
}
|
||||
}
|
||||
|
||||
function skipTemplate() {
|
||||
dialogStep.value = 2
|
||||
selectedTemplateIdx.value = null
|
||||
usedTemplate.value = null
|
||||
form.value = {
|
||||
o_name: "",
|
||||
o_description: "",
|
||||
krs: [
|
||||
{ name: "", target_value: "", weight: "33" },
|
||||
{ name: "", target_value: "", weight: "33" },
|
||||
{ name: "", target_value: "", weight: "34" },
|
||||
],
|
||||
}
|
||||
}
|
||||
|
||||
function nextStep() {
|
||||
if (selectedTemplateIdx.value === null) return
|
||||
const tmpl = filteredTemplates.value[selectedTemplateIdx.value]
|
||||
if (!tmpl) return
|
||||
usedTemplate.value = tmpl
|
||||
dialogStep.value = 2
|
||||
form.value = {
|
||||
o_name: tmpl.name,
|
||||
o_description: tmpl.description,
|
||||
krs: tmpl.preset_krs.map((kr: any) => ({
|
||||
name: kr.name,
|
||||
target_value: kr.target_value,
|
||||
weight: String(kr.weight),
|
||||
})),
|
||||
}
|
||||
}
|
||||
|
||||
function prevStep() {
|
||||
dialogStep.value = 1
|
||||
selectedTemplateIdx.value = null
|
||||
}
|
||||
|
||||
function addKr() {
|
||||
form.value.krs.push({ name: "", target_value: "", weight: "33" })
|
||||
}
|
||||
|
||||
function removeKr(idx: number) {
|
||||
form.value.krs.splice(idx, 1)
|
||||
}
|
||||
|
||||
function onSave() {
|
||||
if (!form.value.o_name?.trim()) {
|
||||
// 简单提示 — 父组件会检测
|
||||
return
|
||||
}
|
||||
// 构造完整数据发给父组件
|
||||
emit("save-node-dialog", {
|
||||
o_name: form.value.o_name.trim(),
|
||||
o_description: form.value.o_description.trim(),
|
||||
template_name: usedTemplate.value?.name || null,
|
||||
dimension: props.editingLayerKey,
|
||||
krs: form.value.krs.map((kr, i) => ({
|
||||
name: kr.name,
|
||||
target_value: kr.target_value,
|
||||
weight: parseInt(kr.weight) || 33,
|
||||
sort_order: i + 1,
|
||||
})),
|
||||
// 兼容旧字段(父组件 onNodeSave 需要 name)
|
||||
name: form.value.o_name.trim(),
|
||||
description: form.value.o_description.trim(),
|
||||
})
|
||||
}
|
||||
|
||||
function onCancel() {
|
||||
emit("update:showNodeDialog", false)
|
||||
resetForm()
|
||||
}
|
||||
|
||||
// 监听弹窗打开 → 重置状态
|
||||
watch(
|
||||
() => props.showNodeDialog,
|
||||
(val) => {
|
||||
if (!val) {
|
||||
resetForm()
|
||||
}
|
||||
}
|
||||
)
|
||||
|
||||
// ── 以下方法保持向后兼容(其他弹窗使用) ──
|
||||
function getKpiLevel(item: any): string {
|
||||
if (!item.actual || !item.target) return "gray"
|
||||
const ratio = item.actual / item.target
|
||||
if (ratio >= 0.9) return "green"
|
||||
if (ratio >= 0.7) return "yellow"
|
||||
return "red"
|
||||
}
|
||||
function badgeIcon(level: string): string {
|
||||
return level === "green" ? "🟢" : level === "yellow" ? "🟡" : level === "red" ? "🔴" : "⚪"
|
||||
}
|
||||
function fmtKpiVal(v: any): string {
|
||||
if (v == null) return "—"
|
||||
return typeof v === "number" ? v.toFixed(2) : String(v)
|
||||
}
|
||||
function planStatusLabel(s: string): string {
|
||||
const m: Record<string, string> = { pending: "待处理", in_progress: "进行中", completed: "已完成", cancelled: "已取消" }
|
||||
return m[s] || s
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
/* ── 步骤提示 ── */
|
||||
.mc-step-hint {
|
||||
font-size: 13px;
|
||||
color: #909399;
|
||||
margin-bottom: 14px;
|
||||
padding-bottom: 8px;
|
||||
border-bottom: 1px dashed #e4e7ed;
|
||||
}
|
||||
.mc-dim-label {
|
||||
font-size: 15px;
|
||||
font-weight: 600;
|
||||
color: #303133;
|
||||
margin-bottom: 12px;
|
||||
}
|
||||
|
||||
/* ── 模板选择 ── */
|
||||
.mc-tmpl-list {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 8px;
|
||||
max-height: 360px;
|
||||
overflow-y: auto;
|
||||
}
|
||||
.mc-tmpl-card {
|
||||
border: 1px solid #e4e7ed;
|
||||
border-radius: 6px;
|
||||
padding: 10px 14px;
|
||||
cursor: pointer;
|
||||
transition: all 0.2s;
|
||||
}
|
||||
.mc-tmpl-card:hover {
|
||||
border-color: #409eff;
|
||||
background: #ecf5ff;
|
||||
}
|
||||
.mc-tmpl-card.selected {
|
||||
border-color: #409eff;
|
||||
background: #ecf5ff;
|
||||
}
|
||||
.mc-tmpl-header {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
}
|
||||
.mc-tmpl-name {
|
||||
font-weight: 600;
|
||||
font-size: 14px;
|
||||
color: #303133;
|
||||
}
|
||||
.mc-tmpl-check {
|
||||
color: #409eff;
|
||||
font-weight: bold;
|
||||
font-size: 16px;
|
||||
}
|
||||
.mc-tmpl-desc {
|
||||
font-size: 12px;
|
||||
color: #909399;
|
||||
margin-top: 4px;
|
||||
}
|
||||
.mc-tmpl-krs {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 4px;
|
||||
margin-top: 6px;
|
||||
}
|
||||
.mc-tmpl-kr-tag {
|
||||
font-size: 11px;
|
||||
background: #f0f9eb;
|
||||
color: #67c23a;
|
||||
padding: 2px 6px;
|
||||
border-radius: 3px;
|
||||
}
|
||||
.mc-tmpl-empty {
|
||||
text-align: center;
|
||||
color: #999;
|
||||
padding: 30px 0;
|
||||
}
|
||||
|
||||
/* ── O+KR 编辑 ── */
|
||||
.mc-form-item {
|
||||
margin-bottom: 12px;
|
||||
}
|
||||
.mc-form-item label {
|
||||
display: block;
|
||||
font-size: 13px;
|
||||
font-weight: 500;
|
||||
color: #606266;
|
||||
margin-bottom: 4px;
|
||||
}
|
||||
.mc-required {
|
||||
color: #f56c6c;
|
||||
}
|
||||
.mc-input {
|
||||
width: 100%;
|
||||
border: 1px solid #dcdfe6;
|
||||
border-radius: 4px;
|
||||
padding: 6px 10px;
|
||||
font-size: 13px;
|
||||
outline: none;
|
||||
transition: border-color 0.2s;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
.mc-input:focus {
|
||||
border-color: #409eff;
|
||||
}
|
||||
.mc-textarea {
|
||||
resize: vertical;
|
||||
font-family: inherit;
|
||||
}
|
||||
|
||||
/* ── KR 区域 ── */
|
||||
.mc-kr-section {
|
||||
margin-top: 8px;
|
||||
}
|
||||
.mc-kr-header {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
margin-bottom: 8px;
|
||||
font-size: 13px;
|
||||
font-weight: 500;
|
||||
color: #606266;
|
||||
}
|
||||
.mc-kr-row {
|
||||
border: 1px solid #e4e7ed;
|
||||
border-radius: 6px;
|
||||
padding: 10px 12px;
|
||||
margin-bottom: 8px;
|
||||
}
|
||||
.mc-kr-row-top {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
margin-bottom: 6px;
|
||||
}
|
||||
.mc-kr-index {
|
||||
font-weight: 600;
|
||||
color: #409eff;
|
||||
font-size: 13px;
|
||||
min-width: 22px;
|
||||
}
|
||||
.mc-kr-name {
|
||||
flex: 1;
|
||||
}
|
||||
.mc-kr-row-bottom {
|
||||
display: flex;
|
||||
gap: 12px;
|
||||
}
|
||||
.mc-kr-field {
|
||||
flex: 1;
|
||||
}
|
||||
.mc-kr-field label {
|
||||
display: block;
|
||||
font-size: 11px;
|
||||
color: #909399;
|
||||
margin-bottom: 2px;
|
||||
}
|
||||
.mc-kr-input {
|
||||
font-size: 12px;
|
||||
}
|
||||
|
||||
/* ── 底部按钮 ── */
|
||||
.mc-footer-buttons {
|
||||
display: flex;
|
||||
justify-content: flex-end;
|
||||
gap: 8px;
|
||||
}
|
||||
|
||||
/* ── 以下保持旧样式(其他弹窗使用) ── */
|
||||
.mc-dialog-body { padding: 0; }
|
||||
.mc-row { display: flex; gap: 8px; margin-bottom: 12px; }
|
||||
.mc-input-half { flex: 1; }
|
||||
.mc-icon-picker { display: flex; gap: 6px; }
|
||||
.mc-icon-btn {
|
||||
width: 32px; height: 32px;
|
||||
border: 1px solid #dcdfe6;
|
||||
border-radius: 4px;
|
||||
background: #fff;
|
||||
cursor: pointer;
|
||||
font-size: 16px;
|
||||
}
|
||||
.mc-icon-btn.active { border-color: #409eff; background: #ecf5ff; }
|
||||
.mc-radio-label { margin-right: 12px; font-size: 13px; color: #606266; cursor: pointer; }
|
||||
.mc-table { width: 100%; border-collapse: collapse; }
|
||||
.mc-table th, .mc-table td { padding: 8px 10px; border-bottom: 1px solid #ebeef5; text-align: left; font-size: 13px; }
|
||||
.mc-table th { background: #f5f7fa; font-weight: 500; color: #606266; }
|
||||
|
||||
/* KPI详情卡片 */
|
||||
.kpi-detail-card { padding: 10px 0; border-bottom: 1px solid #f0f0f0; }
|
||||
.kpi-detail-top { display: flex; align-items: center; gap: 8px; margin-bottom: 4px; }
|
||||
.kpi-detail-badge { font-size: 14px; }
|
||||
.kpi-detail-code { font-size: 12px; color: #909399; }
|
||||
.kpi-detail-name { font-size: 14px; font-weight: 500; }
|
||||
.kpi-detail-values { display: flex; gap: 16px; }
|
||||
.kdv-item { font-size: 12px; color: #606266; }
|
||||
.kdv-label { color: #909399; margin-right: 4px; }
|
||||
.kdv-val { font-weight: 500; }
|
||||
|
||||
/* 行动方案卡片 */
|
||||
.plan-popup-card { padding: 10px 0; border-bottom: 1px solid #f0f0f0; }
|
||||
.plan-popup-top { display: flex; align-items: center; gap: 8px; }
|
||||
.plan-popup-status { font-size: 11px; padding: 1px 6px; border-radius: 3px; }
|
||||
.pps-pending { background: #fdf6ec; color: #e6a23c; }
|
||||
.pps-in_progress { background: #ecf5ff; color: #409eff; }
|
||||
.pps-completed { background: #f0f9eb; color: #67c23a; }
|
||||
.pps-cancelled { background: #fef0f0; color: #f56c6c; }
|
||||
.plan-popup-title { font-size: 13px; font-weight: 500; }
|
||||
.plan-popup-meta { display: flex; gap: 12px; margin-top: 4px; font-size: 12px; color: #909399; }
|
||||
</style>
|
||||
|
||||
@@ -120,6 +120,7 @@
|
||||
:kpi-detail-list="kpiDetailList"
|
||||
:plan-popup-obj-name="planPopupObjName"
|
||||
:plan-popup-list="planPopupList"
|
||||
:editing-layer-key="editingLayerKey"
|
||||
@update:show-node-dialog="v => showNodeDialog = v"
|
||||
@update:show-causality-dialog="v => showCausalityDialog = v"
|
||||
@update:show-versions="v => showVersions = v"
|
||||
@@ -195,7 +196,20 @@ const editingNodeData = ref<any>(null)
|
||||
const editingLayerKey = ref('')
|
||||
const dialogRefreshKey = ref(0)
|
||||
const dialogForm = reactive({ name: '', description: '', icon: 'target', targetValue: null, currentValue: null, unit: '%', owner: '', isLeading: false, kpis: [] as string[] })
|
||||
function onSaveDialog() {
|
||||
function onSaveDialog(data: any) {
|
||||
// 新格式:O+KR 结构(来自两步弹窗)
|
||||
if (data.o_name) {
|
||||
if (!data.o_name?.trim()) { ElMessage.warning('请输入目标名称'); return }
|
||||
onNodeSave({
|
||||
...data,
|
||||
name: data.o_name.trim(),
|
||||
description: data.o_description?.trim() || '',
|
||||
layer: editingLayerKey.value,
|
||||
icon: 'target',
|
||||
})
|
||||
return
|
||||
}
|
||||
// 旧格式兼容(保留)
|
||||
if (!dialogForm.name?.trim()) { ElMessage.warning('请输入目标名称'); return }
|
||||
onNodeSave({ ...dialogForm, name: dialogForm.name.trim(), layer: editingLayerKey.value })
|
||||
showNodeDialog.value = false
|
||||
@@ -544,6 +558,9 @@ function onNodeSave(data: any) {
|
||||
layer: layer,
|
||||
kpis: data.kpis || [],
|
||||
icon: data.icon || 'target',
|
||||
// O+KR 扩展字段
|
||||
krs: data.krs || [], // 关键结果数组 [{name, target_value, weight, sort_order}]
|
||||
template_name: data.template_name || null, // 来源模板名
|
||||
}
|
||||
|
||||
if (editingNodeData.value?._index != null && editingNodeData.value._dimKey === layer) {
|
||||
@@ -569,6 +586,7 @@ function onNodeSave(data: any) {
|
||||
}
|
||||
|
||||
editingNodeData.value = null
|
||||
showNodeDialog.value = false
|
||||
debouncedSaveCanvas()
|
||||
nextTick(triggerRecalc)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user