Просмотр исходного кода

feat(planner-cert): W3 规划师培训认证前端(小程序培训中心+管理端三页)

- 小程序:新增 utils/planner-cert.js 自包含 API 封装(7 个规划师端接口,JWT+POST)
- 小程序:新增 pages/guide/training/index.vue 培训认证中心(类别Tab/课时进度/线上课程/线下签到)
- 小程序:新增 pages/guide/training/exam.vue 考核答题页(选项作答/倒计时/结果)
- 小程序:pages.json 注册 training/index、training/exam;service-role-apply 增'进入培训认证中心'入口
- cfc-web:新增 src/api/plannerCert.js(20 个管理端接口封装)
- cfc-web:新增 admin/planner/ 认证看板(分页/筛选/同步课时/初始化/补登)、课程管理(类别+线上课+线下映射 CRUD)、题库管理(试卷+题目整体替换)
- cfc-web:router 注册 3 路由、Layout 增'规划师认证'菜单、permissions 增 planner:cert 权限

校验:mvn compile 通过;cfc-web npm run build 通过;小程序 verify-vue-compile PASS + audit-mp-antipatterns 0 ERROR + audit-duplicate-api-calls 0 error
Sisyphus Agent 3 недель назад
Родитель
Сommit
fd341d90d3

+ 12 - 0
cfc-frontend/pages.json

@@ -225,6 +225,18 @@
           "style": {
             "navigationBarTitleText": "活动详情"
           }
+        },
+        {
+          "path": "training/index",
+          "style": {
+            "navigationBarTitleText": "培训认证中心"
+          }
+        },
+        {
+          "path": "training/exam",
+          "style": {
+            "navigationBarTitleText": "培训认证考核"
+          }
         }
       ]
     },

+ 458 - 0
cfc-frontend/pages/guide/training/exam.vue

@@ -0,0 +1,458 @@
+<template>
+  <view class="exam-container" :style="{ '--font-scale': fontScale }">
+    <!-- 加载中 -->
+    <view v-if="loading" class="loading-box">
+      <text class="loading-text">加载中...</text>
+    </view>
+
+    <!-- 题目区 -->
+    <view v-else-if="questions.length > 0 && !result" class="exam-wrap">
+      <view class="exam-header">
+        <text class="exam-title">{{ paperTitle }}</text>
+        <text class="exam-countdown" v-if="remaining > 0">剩余 {{ remaining }} 分钟</text>
+      </view>
+
+      <scroll-view class="question-list" scroll-y="true">
+        <view class="question-item" v-for="(q, qi) in questions" :key="q.id">
+          <view class="question-no">第 {{ qi + 1 }} 题({{ q.score }} 分)</view>
+          <view class="question-text">{{ q.question }}</view>
+          <view class="options">
+            <view
+              class="option-item"
+              :class="{ selected: selectedAnswers[q.id] === opt.value }"
+              v-for="opt in getOptions(q)"
+              :key="opt.value"
+              @click="selectAnswer(q.id, opt.value)"
+            >
+              <view class="option-radio" :class="{ checked: selectedAnswers[q.id] === opt.value }"></view>
+              <text class="option-label">{{ opt.label }}</text>
+            </view>
+          </view>
+        </view>
+      </scroll-view>
+
+      <view class="exam-footer">
+        <text class="exam-tip" v-if="answeredCount < totalCount">已作答 {{ answeredCount }} / {{ totalCount }} 题</text>
+        <text class="exam-tip" v-else>已全部作答</text>
+        <button class="btn-submit" @click="onSubmit" :disabled="submitting">{{ submitting ? '提交中...' : '提交考核' }}</button>
+      </view>
+    </view>
+
+    <!-- 结果区 -->
+    <view v-else-if="result" class="result-wrap">
+      <view class="result-card">
+        <text class="result-title" :class="result.passed ? 'pass' : 'fail'">
+          {{ result.passed ? '考核通过' : '考核未通过' }}
+        </text>
+        <view class="score-box">
+          <text class="score-num">{{ result.score }}</text>
+          <text class="score-label">分 / {{ result.passScore }} 分(及格线)</text>
+        </view>
+        <view class="result-actions">
+          <button class="btn-retry" @click="onRetry">{{ result.passed ? '返回首页' : '重新考试' }}</button>
+        </view>
+      </view>
+    </view>
+
+    <!-- 空态 -->
+    <view v-else class="empty-box">
+      <text class="empty-text">暂无考题,请联系管理员配置试卷</text>
+    </view>
+  </view>
+</template>
+
+<script>
+import fontScaleMixin from '@/mixins/font-scale.js'
+import { startPlannerExam, submitPlannerExam } from '@/utils/planner-cert.js'
+
+export default {
+  mixins: [fontScaleMixin],
+  data() {
+    return {
+      loading: true,
+      submitting: false,
+      attemptId: null,
+      categoryId: null,
+      paperTitle: '规划师认证考核',
+      questions: [],
+      durationMinutes: 0,
+      remaining: 0,
+      selectedAnswers: {},   // { questionId: optionValue }
+      result: null,
+      timer: null
+    }
+  },
+  computed: {
+    totalCount() {
+      return this.questions.length
+    },
+    answeredCount() {
+      var n = 0
+      for (var i = 0; i < this.questions.length; i++) {
+        if (this.selectedAnswers[this.questions[i].id] !== undefined) n++
+      }
+      return n
+    }
+  },
+  onLoad(options) {
+    // exam 页通过 ?q=<encoded query> 或 ?categoryId= 进入
+    var categoryId = null
+    if (options && options.q) {
+      try {
+        var pairs = decodeURIComponent(options.q).split('&')
+        for (var i = 0; i < pairs.length; i++) {
+          var kv = pairs[i].split('=')
+          if (kv.length === 2 && kv[0] === 'categoryId') categoryId = kv[1]
+        }
+      } catch (e) { categoryId = null }
+    } else if (options && options.categoryId) {
+      categoryId = options.categoryId
+    }
+    this.categoryId = categoryId
+    this.loadExam()
+    this._onLoadFired = true
+  },
+  onShow() {
+    if (this._onLoadFired) {
+      this._onLoadFired = false
+    }
+  },
+  onUnload() {
+    this.clearTimer()
+  },
+  methods: {
+    clearTimer() {
+      if (this.timer) { clearInterval(this.timer); this.timer = null }
+    },
+    async loadExam() {
+      this.loading = true
+      this.result = null
+      this.selectedAnswers = {}
+      try {
+        var body = {}
+        if (this.categoryId) body.categoryId = this.categoryId
+        var res = await startPlannerExam(body)
+        if (res && res.code === 200 && res.data) {
+          var data = res.data
+          this.attemptId = data.attemptId
+          this.questions = (data.questions && Array.isArray(data.questions)) ? data.questions : []
+          this.durationMinutes = Number(data.durationMinutes) || 0
+          this.remaining = this.durationMinutes
+          this.startTimer()
+        } else {
+          uni.showToast({ title: (res && res.message) || '获取考题失败', icon: 'none' })
+        }
+      } catch (e) {
+        console.error('[exam] loadExam', e)
+        uni.showToast({ title: '获取考题失败', icon: 'none' })
+      } finally {
+        this.loading = false
+      }
+    },
+    startTimer() {
+      this.clearTimer()
+      if (this.remaining <= 0) return
+      var self = this
+      this.timer = setInterval(function () {
+        if (self.remaining > 0) {
+          self.remaining = self.remaining - 1
+        }
+        if (self.remaining <= 0) {
+          self.clearTimer()
+          self.onSubmit()
+        }
+      }, 60000)
+    },
+    getOptions(q) {
+      // q.options 兼容多种格式:JSON 字符串、对象 {A:..}、数组、或 "A:...|B:..."
+      var opts = q.options
+      var arr = []
+      if (!opts) return arr
+      try {
+        if (typeof opts === 'string') {
+          var trimmed = opts.replace(/^\s+|\s+$/g, '')
+          if (trimmed.charAt(0) === '{' || trimmed.charAt(0) === '[') {
+            var parsed = JSON.parse(trimmed)
+            return this.getOptions({ options: parsed })
+          }
+          var parts = opts.split('|')
+          for (var i = 0; i < parts.length; i++) {
+            var part = parts[i]
+            var colon = part.indexOf(':')
+            if (colon > 0) {
+              arr.push({ value: part.substring(0, colon).replace(/^\s+|\s+$/g, ''), label: part.substring(colon + 1) })
+            } else {
+              arr.push({ value: String.fromCharCode(65 + i), label: part })
+            }
+          }
+          return arr
+        }
+        if (Array.isArray(opts)) {
+          for (var j = 0; j < opts.length; j++) {
+            var o = opts[j]
+            if (typeof o === 'string') {
+              arr.push({ value: String.fromCharCode(65 + j), label: o })
+            } else {
+              arr.push({ value: String(o.value || o.id || String.fromCharCode(65 + j)), label: String(o.label || o.text || '') })
+            }
+          }
+          return arr
+        }
+        if (typeof opts === 'object') {
+          for (var k in opts) {
+            if (Object.prototype.hasOwnProperty.call(opts, k)) {
+              arr.push({ value: k, label: String(opts[k]) })
+            }
+          }
+          return arr
+        }
+      } catch (e) { console.error('[exam] parseOptions', e) }
+      return arr
+    },
+    selectAnswer(qid, value) {
+      this.$set(this.selectedAnswers, qid, value)
+    },
+    async onSubmit() {
+      if (this.submitting) return
+      var answers = {}
+      for (var i = 0; i < this.questions.length; i++) {
+        var q = this.questions[i]
+        if (this.selectedAnswers[q.id] !== undefined && this.selectedAnswers[q.id] !== null) {
+          answers[String(q.id)] = String(this.selectedAnswers[q.id])
+        }
+      }
+      this.submitting = true
+      this.clearTimer()
+      try {
+        var body = {}
+        if (this.attemptId) body.attemptId = this.attemptId
+        body.answers = answers
+        var res = await submitPlannerExam(body)
+        if (res && res.code === 200) {
+          var d = res.data || {}
+          this.result = {
+            passed: d.passed === true || d.passed === 1,
+            score: d.score || 0,
+            passScore: d.passScore || 60
+          }
+        } else {
+          uni.showToast({ title: (res && res.message) || '提交失败', icon: 'none' })
+          this.submitting = false
+        }
+      } catch (e) {
+        console.error('[exam] submit', e)
+        uni.showToast({ title: '提交失败', icon: 'none' })
+        this.submitting = false
+      }
+    },
+    onRetry() {
+      if (this.result && this.result.passed) {
+        uni.navigateBack()
+        return
+      }
+      this.submitting = false
+      this.loadExam()
+    }
+  }
+}
+</script>
+
+<style lang="scss" scoped>
+.exam-container {
+  min-height: 100vh;
+  background: #f8f8f8;
+  padding: 20rpx;
+}
+
+.loading-box {
+  padding: 120rpx 0;
+  text-align: center;
+}
+
+.loading-text {
+  color: #999;
+  font-size: 28rpx;
+}
+
+.exam-wrap {
+  background: #fff;
+  border-radius: 16rpx;
+  padding: 24rpx;
+  margin-bottom: 20rpx;
+}
+
+.exam-header {
+  display: flex;
+  flex-direction: row;
+  justify-content: space-between;
+  align-items: center;
+  margin-bottom: 24rpx;
+}
+
+.exam-title {
+  font-size: 32rpx;
+  font-weight: 600;
+  color: #333;
+}
+
+.exam-countdown {
+  font-size: 26rpx;
+  color: #F97316;
+  font-weight: 600;
+}
+
+.question-list {
+  height: 600rpx;
+}
+
+.question-item {
+  margin-bottom: 26rpx;
+  padding-bottom: 20rpx;
+  border-bottom: 1rpx solid #f5f5f5;
+}
+
+.question-item:last-child {
+  border-bottom: none;
+}
+
+.question-no {
+  font-size: 24rpx;
+  color: #F97316;
+  margin-bottom: 10rpx;
+}
+
+.question-text {
+  font-size: 28rpx;
+  color: #333;
+  margin-bottom: 16rpx;
+  line-height: 1.4;
+}
+
+.options {
+  display: flex;
+  flex-direction: column;
+}
+
+.option-item {
+  display: flex;
+  flex-direction: row;
+  align-items: center;
+  margin-bottom: 12rpx;
+  padding: 14rpx 18rpx;
+  border: 1rpx solid #e5e7eb;
+  border-radius: 12rpx;
+  background: #fff;
+}
+
+.option-item.selected {
+  border-color: #F97316;
+  background: #fff7ed;
+}
+
+.option-radio {
+  width: 28rpx;
+  height: 28rpx;
+  border: 2rpx solid #cbd5e1;
+  border-radius: 50%;
+  margin-right: 14rpx;
+}
+
+.option-item.selected .option-radio {
+  background: #F97316;
+  border-color: #F97316;
+}
+
+.option-label {
+  font-size: 26rpx;
+  color: #333;
+  flex: 1;
+}
+
+.exam-footer {
+  margin-top: 24rpx;
+  display: flex;
+  flex-direction: row;
+  justify-content: space-between;
+  align-items: center;
+}
+
+.exam-tip {
+  font-size: 24rpx;
+  color: #666;
+}
+
+.btn-submit {
+  background: #F97316;
+  color: #fff;
+  font-size: 30rpx;
+  border-radius: 44rpx;
+  height: 80rpx;
+  line-height: 80rpx;
+  padding: 0 40rpx;
+}
+
+.result-wrap {
+  padding-bottom: 80rpx;
+  text-align: center;
+}
+
+.result-card {
+  background: #fff;
+  border-radius: 24rpx;
+  padding: 40rpx 24rpx;
+  margin: 0 20rpx;
+  text-align: center;
+}
+
+.result-title {
+  font-size: 40rpx;
+  font-weight: 700;
+}
+
+.result-title.pass {
+  color: #10b981;
+}
+
+.result-title.fail {
+  color: #ef4444;
+}
+
+.score-box {
+  margin-top: 20rpx;
+}
+
+.score-num {
+  font-size: 60rpx;
+  font-weight: 700;
+  color: #F97316;
+}
+
+.score-label {
+  font-size: 26rpx;
+  color: #666;
+}
+
+.result-actions {
+  margin-top: 30rpx;
+}
+
+.btn-retry {
+  background: #F97316;
+  color: #fff;
+  font-size: 30rpx;
+  border-radius: 44rpx;
+  height: 88rpx;
+  line-height: 88rpx;
+  width: 60%;
+}
+
+.empty-box {
+  padding: 120rpx 0;
+  text-align: center;
+}
+
+.empty-text {
+  font-size: 26rpx;
+  color: #999;
+}
+</style>

+ 600 - 0
cfc-frontend/pages/guide/training/index.vue

@@ -0,0 +1,600 @@
+<template>
+  <view class="cert-container" :style="{ '--font-scale': fontScale }">
+    <!-- 加载中 -->
+    <view v-if="loading" class="loading-box">
+      <text class="loading-text">加载中...</text>
+    </view>
+
+    <!-- 类别 Tab -->
+    <view v-else class="cat-tabs">
+      <view
+        class="cat-tab"
+        :class="{ active: activeCat === item.categoryId }"
+        v-for="item in certList"
+        :key="getCatKey(item)"
+        @click="switchCategory(item)"
+      >
+        <text class="cat-tab-name">{{ item.categoryName }}</text>
+        <text class="cat-tab-status" :class="item._statusClass">{{ item._statusText }}</text>
+      </view>
+    </view>
+
+    <!-- 当前类别详情 -->
+    <view v-if="!loading && currentCert" class="cert-detail">
+      <!-- 认证状态卡 -->
+      <view class="status-card">
+        <view class="status-row">
+          <text class="status-label">认证类别</text>
+          <text class="status-value">{{ currentCert.categoryName }}</text>
+        </view>
+        <view class="status-row">
+          <text class="status-label">课时进度</text>
+          <view class="progress-wrap">
+            <progress class="progress-bar" :percent="getPercent(currentCert)" stroke-width="4" activeColor="#F97316" backgroundColor="#EEE" />
+          </view>
+          <text class="status-value">{{ formatHours(currentCert.completedHours) }} / {{ formatHours(currentCert.requiredHours) }} 小时</text>
+        </view>
+        <view class="status-row">
+          <text class="status-label">学习状态</text>
+          <text class="status-value" :class="currentCert._statusClass">{{ currentCert._statusText }}</text>
+        </view>
+        <view class="status-row" v-if="currentCert.examScore !== null && currentCert.examScore !== undefined && currentCert.examScore !== ''">
+          <text class="status-label">考核成绩</text>
+          <text class="status-value">{{ currentCert.examScore }} 分</text>
+        </view>
+        <view class="status-row" v-if="currentCert.certNo">
+          <text class="status-label">证书编号</text>
+          <text class="status-value">{{ currentCert.certNo }}</text>
+        </view>
+        <view class="status-row" v-if="currentCert.expireAt">
+          <text class="status-label">有效期至</text>
+          <text class="status-value">{{ formatDate(currentCert.expireAt) }}</text>
+        </view>
+      </view>
+
+      <!-- 操作区 -->
+      <view class="action-card">
+        <button class="btn-main" :class="{ disabled: !currentCert.canExam }" @click="onStartExam" :disabled="!currentCert.canExam">
+          {{ currentCert.canExam ? '进入考核' : (currentCert.examStatus === 'exam_passed' ? '已通过考核' : '未满足考核条件') }}
+        </button>
+        <text class="action-tip" v-if="!currentCert.canExam">完成全部课时后即可参加考核</text>
+      </view>
+
+      <!-- 线上课程 -->
+      <view class="section-card">
+        <view class="section-header">
+          <text class="section-title">线上课程</text>
+          <text class="section-sub">共 {{ courseList.length }} 门</text>
+        </view>
+        <view v-if="courseList.length === 0" class="empty-box">
+          <text class="empty-text">暂无线上课程</text>
+        </view>
+        <view class="course-item" v-for="c in courseList" :key="getCourseKey(c)">
+          <view class="course-info">
+            <text class="course-title">{{ c.title }}</text>
+            <text class="course-meta">{{ formatHours(c.requiredHours) }} 小时 · {{ c.isRequired === 1 ? '必修' : '选修' }}</text>
+          </view>
+          <text class="course-status" :class="c._cssClass">{{ c._statusText }}</text>
+        </view>
+      </view>
+
+      <!-- 线下培训活动 -->
+      <view class="section-card">
+        <view class="section-header">
+          <text class="section-title">线下培训</text>
+          <text class="section-sub">共 {{ activityList.length }} 场</text>
+        </view>
+        <view v-if="activityList.length === 0" class="empty-box">
+          <text class="empty-text">暂无线下培训活动</text>
+        </view>
+        <view class="activity-item" v-for="a in activityList" :key="getActivityKey(a)">
+          <view class="activity-info">
+            <text class="activity-title">{{ a.title }}</text>
+            <text class="activity-meta">{{ formatDateTime(a.startTime) }}</text>
+          </view>
+          <button
+            class="btn-checkin"
+            :class="{ done: a._checkinStatus === 'done' }"
+            @click="onCheckIn(a)"
+          >{{ a._checkinStatus === 'done' ? '已签到' : '签到' }}</button>
+        </view>
+      </view>
+    </view>
+
+    <view v-if="!loading && !currentCert" class="empty-box">
+      <text class="empty-text">暂无认证记录,请先通过规划师审核</text>
+    </view>
+  </view>
+</template>
+
+<script>
+import {
+  getMyCertifications,
+  getPlannerCourses,
+  getTrainingActivities,
+  checkInTrainingActivity,
+  startPlannerExam
+} from '@/utils/planner-cert.js'
+import fontScaleMixin from '@/mixins/font-scale.js'
+
+export default {
+  mixins: [fontScaleMixin],
+  data() {
+    return {
+      loading: true,
+      certList: [],
+      currentCert: null,
+      activeCat: null,
+      courseList: [],
+      activityList: []
+    }
+  },
+  onLoad(options) {
+    this.loadData()
+    this._onLoadFired = true
+  },
+  onShow() {
+    if (this._onLoadFired) {
+      this._onLoadFired = false
+    } else {
+      this.loadData()
+    }
+  },
+  methods: {
+    async loadData() {
+      this.loading = true
+      try {
+        const res = await getMyCertifications()
+        this.certList = (res && res.data) || []
+        this.decorateCertList()
+        if (this.certList.length > 0) {
+          const first = this.certList[0]
+          this.activeCat = first.categoryId
+          this.currentCert = first
+          await this.loadCategoryData(first.categoryId)
+        } else {
+          this.currentCert = null
+        }
+      } catch (e) {
+        console.error('[training] loadData', e)
+      } finally {
+        this.loading = false
+      }
+    },
+    decorateCertList() {
+      for (let i = 0; i < this.certList.length; i++) {
+        const c = this.certList[i]
+        c._statusClass = this.getStatusClass(c.status)
+        c._statusText = this.getStatusText(c.status)
+      }
+    },
+    async switchCategory(item) {
+      if (this.activeCat === item.categoryId) return
+      this.activeCat = item.categoryId
+      this.currentCert = item
+      await this.loadCategoryData(item.categoryId)
+    },
+    async loadCategoryData(categoryId) {
+      this.courseList = []
+      this.activityList = []
+      // 并行加载课程 + 线下活动(一次各一个请求,无 N+1)
+      try {
+        const [courseRes, actRes] = await Promise.all([
+          getPlannerCourses({ categoryId: categoryId }),
+          getTrainingActivities()
+        ])
+        this.courseList = this.decorateCourses((courseRes && courseRes.data) || [])
+        this.activityList = this.decorateActivities((actRes && actRes.data) || [])
+      } catch (e) {
+        console.error('[training] loadCategoryData', e)
+      }
+    },
+    decorateCourses(list) {
+      const out = []
+      for (let i = 0; i < list.length; i++) {
+        const c = list[i]
+        const pct = c.progressPercent !== null && c.progressPercent !== undefined ? c.progressPercent : 0
+        out.push({
+          id: c.id,
+          title: c.title,
+          requiredHours: c.requiredHours,
+          isRequired: c.isRequired,
+          _cssClass: pct >= 100 ? 'done' : (pct > 0 ? 'doing' : 'todo'),
+          _statusText: pct >= 100 ? '已完成' : (pct > 0 ? '学习中' : '未开始')
+        })
+      }
+      return out
+    },
+    decorateActivities(list) {
+      const out = []
+      for (let i = 0; i < list.length; i++) {
+        const a = list[i]
+        const done = a.checkinStatus === 'done' || a.checkinStatus === 1 || a.checkinStatus === true
+        out.push({
+          activityId: a.activityId,
+          title: a.title,
+          startTime: a.startTime,
+          _checkinStatus: done ? 'done' : 'todo'
+        })
+      }
+      return out
+    },
+    async onCheckIn(item) {
+      if (item._checkinStatus === 'done') return
+      try {
+        const res = await checkInTrainingActivity({ activityId: item.activityId })
+        if (res && res.code === 200 && res.data === true) {
+          item._checkinStatus = 'done'
+          uni.showToast({ title: '签到成功', icon: 'success' })
+          this.refreshCurrent()
+        } else {
+          uni.showToast({ title: (res && res.message) || '签到失败', icon: 'none' })
+        }
+      } catch (e) {
+        console.error('[training] checkIn', e)
+        uni.showToast({ title: '签到失败', icon: 'none' })
+      }
+    },
+    async onStartExam() {
+      if (!this.currentCert || !this.currentCert.canExam) return
+      try {
+        const res = await startPlannerExam({ categoryId: this.activeCat })
+        if (res && res.code === 200 && res.data) {
+          const data = res.data
+          this.navigateToExam(data)
+        } else {
+          uni.showToast({ title: (res && res.message) || '暂无可考卷', icon: 'none' })
+        }
+      } catch (e) {
+        console.error('[training] startExam', e)
+        uni.showToast({ title: '开始考核失败', icon: 'none' })
+      }
+    },
+    navigateToExam(data) {
+      // 跳转考核页(exam page 单独分包)
+      const q = 'attemptId=' + data.attemptId + '&categoryId=' + this.activeCat
+      uni.navigateTo({ url: '/pages/guide/training/exam?q=' + encodeURIComponent(q) })
+    },
+    async refreshCurrent() {
+      try {
+        const res = await getMyCertifications()
+        const list = (res && res.data) || []
+        this.certList = list
+        this.decorateCertList()
+        for (let i = 0; i < list.length; i++) {
+          if (list[i].categoryId === this.activeCat) {
+            this.currentCert = list[i]
+            break
+          }
+        }
+      } catch (e) {
+        console.error('[training] refresh', e)
+      }
+    },
+    getPercent(cert) {
+      if (!cert) return 0
+      const req = Number(cert.requiredHours) || 0
+      const done = Number(cert.completedHours) || 0
+      if (req <= 0) return 0
+      const pct = Math.floor((done / req) * 100)
+      return pct > 100 ? 100 : pct
+    },
+    getStatusText(status) {
+      const map = {
+        pending_cert: '待认证',
+        pending_learning: '学习中',
+        learning_completed: '课时完成',
+        certified: '已认证'
+      }
+      return map[status] || status
+    },
+    getStatusClass(status) {
+      if (status === 'certified') return 'cert-ok'
+      if (status === 'learning_completed') return 'cert-ready'
+      return 'cert-wait'
+    },
+    formatHours(v) {
+      const n = Number(v)
+      if (isNaN(n)) return '0'
+      return (Math.round(n * 10) / 10).toString()
+    },
+    formatDate(v) {
+      if (!v) return '-'
+      const s = String(v)
+      return s.length >= 10 ? s.substring(0, 10) : s
+    },
+    formatDateTime(v) {
+      if (!v) return '-'
+      const s = String(v).replace('T', ' ')
+      return s.length >= 16 ? s.substring(0, 16) : s
+    },
+    getCatKey(item) {
+      return item.categoryId
+    },
+    getCourseKey(c) {
+      return c.id
+    },
+    getActivityKey(a) {
+      return a.activityId
+    }
+  }
+}
+</script>
+
+<style lang="scss" scoped>
+.cert-container {
+  min-height: 100vh;
+  background: #f8f8f8;
+  padding: 20rpx;
+}
+
+.loading-box {
+  padding: 120rpx 0;
+  text-align: center;
+}
+
+.loading-text {
+  color: #999;
+  font-size: 28rpx;
+}
+
+.cat-tabs {
+  display: flex;
+  flex-direction: row;
+  flex-wrap: nowrap;
+  background: #fff;
+  border-radius: 16rpx;
+  padding: 12rpx;
+  margin-bottom: 20rpx;
+}
+
+.cat-tab {
+  flex: 1;
+  display: flex;
+  flex-direction: column;
+  align-items: center;
+  justify-content: center;
+  padding: 16rpx 8rpx;
+  border-radius: 12rpx;
+}
+
+.cat-tab.active {
+  background: #fff7ed;
+}
+
+.cat-tab-name {
+  font-size: 28rpx;
+  color: #333;
+  font-weight: 500;
+}
+
+.cat-tab.active .cat-tab-name {
+  color: #F97316;
+  font-weight: 600;
+}
+
+.cat-tab-status {
+  margin-top: 8rpx;
+  font-size: 22rpx;
+  color: #999;
+}
+
+.cat-tab.active .cat-tab-status {
+  color: #F97316;
+}
+
+.cert-detail {
+  padding-bottom: 40rpx;
+}
+
+.status-card {
+  background: #fff;
+  border-radius: 16rpx;
+  padding: 24rpx;
+  margin-bottom: 20rpx;
+}
+
+.status-row {
+  display: flex;
+  flex-direction: row;
+  align-items: center;
+  justify-content: space-between;
+  padding: 12rpx 0;
+  border-bottom: 1rpx solid #f5f5f5;
+}
+
+.status-row:last-child {
+  border-bottom: none;
+}
+
+.status-label {
+  font-size: 26rpx;
+  color: #666;
+}
+
+.status-value {
+  font-size: 26rpx;
+  color: #333;
+  font-weight: 500;
+}
+
+.progress-wrap {
+  flex: 1;
+  margin: 0 16rpx;
+}
+
+.progress-bar {
+  width: 100%;
+}
+
+.cert-ok {
+  color: #10b981;
+}
+
+.cert-ready {
+  color: #F97316;
+}
+
+.cert-wait {
+  color: #999;
+}
+
+.action-card {
+  background: #fff;
+  border-radius: 16rpx;
+  padding: 24rpx;
+  margin-bottom: 20rpx;
+  display: flex;
+  flex-direction: column;
+  align-items: center;
+}
+
+.btn-main {
+  width: 100%;
+  background: #F97316;
+  color: #fff;
+  font-size: 30rpx;
+  border-radius: 44rpx;
+  height: 88rpx;
+  line-height: 88rpx;
+}
+
+.btn-main.disabled {
+  background: #d1d5db;
+}
+
+.action-tip {
+  margin-top: 16rpx;
+  font-size: 24rpx;
+  color: #999;
+}
+
+.section-card {
+  background: #fff;
+  border-radius: 16rpx;
+  padding: 24rpx;
+  margin-bottom: 20rpx;
+}
+
+.section-header {
+  display: flex;
+  flex-direction: row;
+  align-items: center;
+  justify-content: space-between;
+  margin-bottom: 16rpx;
+}
+
+.section-title {
+  font-size: 30rpx;
+  font-weight: 600;
+  color: #333;
+}
+
+.section-sub {
+  font-size: 24rpx;
+  color: #999;
+}
+
+.course-item {
+  display: flex;
+  flex-direction: row;
+  align-items: center;
+  justify-content: space-between;
+  padding: 20rpx 0;
+  border-bottom: 1rpx solid #f5f5f5;
+}
+
+.course-item:last-child {
+  border-bottom: none;
+}
+
+.course-info {
+  flex: 1;
+  display: flex;
+  flex-direction: column;
+}
+
+.course-title {
+  font-size: 28rpx;
+  color: #333;
+}
+
+.course-meta {
+  margin-top: 8rpx;
+  font-size: 24rpx;
+  color: #999;
+}
+
+.course-status {
+  font-size: 24rpx;
+  margin-left: 16rpx;
+}
+
+.course-status.done {
+  color: #10b981;
+}
+
+.course-status.doing {
+  color: #F97316;
+}
+
+.course-status.todo {
+  color: #999;
+}
+
+.activity-item {
+  display: flex;
+  flex-direction: row;
+  align-items: center;
+  justify-content: space-between;
+  padding: 20rpx 0;
+  border-bottom: 1rpx solid #f5f5f5;
+}
+
+.activity-item:last-child {
+  border-bottom: none;
+}
+
+.activity-info {
+  flex: 1;
+  display: flex;
+  flex-direction: column;
+}
+
+.activity-title {
+  font-size: 28rpx;
+  color: #333;
+}
+
+.activity-meta {
+  margin-top: 8rpx;
+  font-size: 24rpx;
+  color: #999;
+}
+
+.btn-checkin {
+  background: #F97316;
+  color: #fff;
+  font-size: 24rpx;
+  border-radius: 32rpx;
+  height: 64rpx;
+  line-height: 64rpx;
+  padding: 0 28rpx;
+  margin-left: 16rpx;
+}
+
+.btn-checkin.done {
+  background: #e5e7eb;
+  color: #999;
+}
+
+.empty-box {
+  padding: 60rpx 0;
+  text-align: center;
+}
+
+.empty-text {
+  font-size: 26rpx;
+  color: #999;
+}
+</style>

+ 11 - 1
cfc-frontend/pages/profile/service-role-apply.vue

@@ -21,6 +21,9 @@
         <button v-if="applyStatus === 'approved'" class="btn-center" @click="goToCenter">
           进入服务商中心
         </button>
+        <button v-if="applyStatus === 'approved'" class="btn-train" @click="goToTrainingCenter">
+          进入培训认证中心
+        </button>
         <button v-if="applyStatus === 'approved'" class="btn-add-role" @click="handleAddRole">
           申请其他角色
         </button>
@@ -432,6 +435,9 @@ export default {
         uni.redirectTo({ url: '/pages/vendor/center' })
       }
     },
+    goToTrainingCenter() {
+      uni.navigateTo({ url: '/pages/guide/training/index' })
+    },
     handleAddRole() {
       // 保留 applyRecord(用于标记已通过角色),仅切到表单视图;身份证沿用历史预填不重传
       this.showStatusView = false
@@ -531,7 +537,7 @@ export default {
   flex-direction: column;
   gap: 20rpx;
 }
-.btn-reapply, .btn-center, .btn-back {
+.btn-reapply, .btn-center, .btn-train, .btn-back {
   width: 100%;
   height: 88rpx;
   line-height: 88rpx;
@@ -548,6 +554,10 @@ export default {
   background: linear-gradient(135deg, $status-success, $status-success-light-3);
   color: $app-surface;
 }
+.btn-train {
+  background: linear-gradient(135deg, $accent-indigo, $accent-indigo-deep);
+  color: $app-surface;
+}
 .btn-back {
   background: $facade-fill-gray-100;
   color: $facade-text-slate;

+ 122 - 0
cfc-frontend/utils/planner-cert.js

@@ -0,0 +1,122 @@
+/* ==============================================================
+ * utils/planner-cert.js - 规划师培训认证中心 API 封装
+ * 统一接口:POST /api/planner/certification/my, /courses, /training-activities, /exam/*
+ *
+ * ⚠️ 自包含实现:不依赖 utils/api.js 的 request()(其未导出),
+ *    直接基于 config.API_BASE_URL + uni.request,附带 JWT Authorization。
+ *    所有接口均 POST,与后端 @PostMapping 约定一致。
+ * ============================================================== */
+import config from '@/config.js'
+
+const BASE_URL = config.API_BASE_URL
+
+/**
+ * 轻量 POST 请求封装(规划师认证专用)
+ * - 自动附带 Authorization: Bearer <token>
+ * - 空字符串 ID 字段过滤(防止后端 Long.valueOf("") 抛异常)
+ * - resolve(res.data)(无论 code),由调用方判 res.code === 200
+ * @param {string} url
+ * @param {Object} body
+ * @returns {Promise<Object>} res.data
+ */
+function post(url, body) {
+  const token = uni.getStorageSync('token')
+  const data = body || {}
+  // 过滤空字符串 ID 字段
+  const clean = {}
+  let filtered = false
+  for (const k in data) {
+    if (Object.prototype.hasOwnProperty.call(data, k)) {
+      const v = data[k]
+      if (v === '' && /(?:Id|ID|_id)$/.test(k)) {
+        filtered = true
+        continue
+      }
+      clean[k] = v
+    }
+  }
+  const finalBody = filtered ? clean : data
+
+  return new Promise((resolve, reject) => {
+    uni.request({
+      url: BASE_URL + url,
+      method: 'POST',
+      data: finalBody,
+      header: {
+        'Content-Type': 'application/json',
+        'Authorization': token ? 'Bearer ' + token : ''
+      },
+      success: (res) => {
+        if (res.statusCode === 401 || (res.data && res.data.code === 401)) {
+          reject(res.data || { code: 401, message: '登录已失效' })
+          return
+        }
+        resolve(res.data || { code: -1, message: '响应为空' })
+      },
+      fail: (err) => {
+        reject({ code: -1, message: (err && err.errMsg) || '网络错误' })
+      }
+    })
+  })
+}
+
+/**
+ * 获取我的全部类别认证状态
+ * POST /api/planner/certification/my
+ * @returns {Promise<Array<{categoryId,categoryCode,categoryName,requiredHours,completedHours,learningStatus,examStatus,examScore,certNo,certifiedAt,expireAt,status,canExam,canService}>>}
+ */
+export const getMyCertifications = () =>
+  post('/api/planner/certification/my', {})
+
+/**
+ * 获取某类别的线上课程列表
+ * POST /api/planner/courses
+ * @param {Object} params - { categoryId }
+ * @returns {Promise<Array<{id,title,requiredHours,isRequired,progressPercent}>>}
+ */
+export const getPlannerCourses = (params) =>
+  post('/api/planner/courses', params || {})
+
+/**
+ * 获取线下培训活动列表
+ * POST /api/planner/training-activities
+ * @returns {Promise<Array<{activityId,title,startTime,categoryId,categoryName,durationHours,checkinStatus}>>}
+ */
+export const getTrainingActivities = () =>
+  post('/api/planner/training-activities', {})
+
+/**
+ * 线下培训活动签到
+ * POST /api/planner/training-activities/check-in
+ * @param {Object} params - { activityId }
+ * @returns {Promise<Boolean>}
+ */
+export const checkInTrainingActivity = (params) =>
+  post('/api/planner/training-activities/check-in', params || {})
+
+/**
+ * 开始考核
+ * POST /api/planner/exam/start
+ * @param {Object} params - { categoryId }
+ * @returns {Promise<{attemptId,paperId,durationMinutes,questionCount,questions:[{id,question,options,score}]}>}
+ */
+export const startPlannerExam = (params) =>
+  post('/api/planner/exam/start', params || {})
+
+/**
+ * 提交考核答案
+ * POST /api/planner/exam/submit
+ * @param {Object} params - { attemptId, answers }
+ * @returns {Promise<{attemptId,score,passed,passScore}>}
+ */
+export const submitPlannerExam = (params) =>
+  post('/api/planner/exam/submit', params || {})
+
+/**
+ * 获取考核结果(最近一次)
+ * POST /api/planner/exam/result
+ * @param {Object} params - { categoryId }
+ * @returns {Promise<{examStatus,examScore,examAttempts,certifiedAt}>}
+ */
+export const getExamResult = (params) =>
+  post('/api/planner/exam/result', params || {})

+ 112 - 0
cfc-web/src/api/plannerCert.js

@@ -0,0 +1,112 @@
+import request from '@/utils/request';
+
+// ============ 规划师培训认证管理 API(W3)============
+// 契约:docs/superpowers/specs/2026-10-22-planner-learning-assessment-gate-design.md §8/§9
+// 全部 POST;管理端 5 个 Controller 共 20 端点
+// 参考现有 API 文件风格(org.js / assessment.js)
+
+// ---- 认证类别 CRUD (/api/admin/planner-cert-categories) ----
+// 类别列表(全量,不含分页)
+export function plannerCertCategoryList() {
+  return request({ url: '/api/admin/planner-cert-categories/list', method: 'post', data: {} });
+}
+// 新建类别
+export function plannerCertCategoryCreate(data) {
+  return request({ url: '/api/admin/planner-cert-categories/create', method: 'post', data });
+}
+// 更新类别
+export function plannerCertCategoryUpdate(data) {
+  return request({ url: '/api/admin/planner-cert-categories/update', method: 'post', data });
+}
+// 删除类别
+export function plannerCertCategoryDelete(data) {
+  return request({ url: '/api/admin/planner-cert-categories/delete', method: 'post', data }); // { id }
+}
+
+// ---- 线上课程 CRUD (/api/admin/planner-courses) ----
+// 课程列表(按类别,categoryId 可空)— 后端 @RequestParam,走 query
+export function plannerCourseList(categoryId) {
+  return request({ url: '/api/admin/planner-courses/list', method: 'post', params: categoryId ? { categoryId } : {} }); // { categoryId? }
+}
+// 新建课程
+export function plannerCourseCreate(data) {
+  return request({ url: '/api/admin/planner-courses/create', method: 'post', data });
+}
+// 更新课程
+export function plannerCourseUpdate(data) {
+  return request({ url: '/api/admin/planner-courses/update', method: 'post', data });
+}
+// 删除课程(query 参数 id)
+export function plannerCourseDelete(id) {
+  return request({ url: '/api/admin/planner-courses/delete', method: 'post', params: { id } });
+}
+
+// ---- 线下课映射 CRUD (/api/admin/planner-offline-course-map) ----
+// 线下课映射列表
+export function plannerOfflineCourseList() {
+  return request({ url: '/api/admin/planner-offline-course-map/list', method: 'post', data: {} });
+}
+// 新建线下课映射
+export function plannerOfflineCourseCreate(data) {
+  return request({ url: '/api/admin/planner-offline-course-map/create', method: 'post', data });
+}
+// 更新线下课映射
+export function plannerOfflineCourseUpdate(data) {
+  return request({ url: '/api/admin/planner-offline-course-map/update', method: 'post', data });
+}
+// 删除线下课映射
+export function plannerOfflineCourseDelete(id) {
+  return request({ url: '/api/admin/planner-offline-course-map/delete', method: 'post', params: { id } });
+}
+
+// ---- 认证看板 (/api/admin/planner-certifications) ----
+// 认证看板列表(分页 + 筛选)— 后端 @RequestParam,走 query
+export function plannerCertificationList(params) {
+  return request({
+    url: '/api/admin/planner-certifications/list',
+    method: 'post',
+    params: params || {} // { status?, categoryId?, page?, size? }
+  });
+}
+// 手动同步线上课时(单条)
+export function plannerCertificationSyncHours(data) {
+  return request({ url: '/api/admin/planner-certifications/sync-hours', method: 'post', data }); // { userId, courseId, hours, progressPercent? }
+}
+// 批量手动同步线上课时
+export function plannerCertificationBatchSync(data) {
+  return request({ url: '/api/admin/planner-certifications/sync-hours/batch', method: 'post', data }); // { rows: [...] }
+}
+// 初始化某规划师全部类别认证
+export function plannerCertificationInitByUser(data) {
+  return request({ url: '/api/admin/planner-certifications/init-by-user', method: 'post', data }); // { userId }
+}
+// 全量补登(存量兼容,仅平台角色)
+export function plannerCertificationBackfill() {
+  return request({ url: '/api/admin/planner-certifications/backfill', method: 'post', data: {} });
+}
+
+// ---- 考核管理 (/api/admin/planner-exam) ----
+// 试卷列表(按类别)
+export function plannerExamPapers(categoryId) {
+  return request({ url: '/api/admin/planner-exam/papers', method: 'post', params: { categoryId } });
+}
+// 新增试卷
+export function plannerExamPaperCreate(data) {
+  return request({ url: '/api/admin/planner-exam/paper/create', method: 'post', data });
+}
+// 更新试卷
+export function plannerExamPaperUpdate(data) {
+  return request({ url: '/api/admin/planner-exam/paper/update', method: 'post', data });
+}
+// 删除试卷
+export function plannerExamPaperDelete(id) {
+  return request({ url: '/api/admin/planner-exam/paper/delete', method: 'post', params: { id } });
+}
+// 题目列表(按试卷)
+export function plannerExamQuestions(paperId) {
+  return request({ url: '/api/admin/planner-exam/questions', method: 'post', params: { paperId } });
+}
+// 保存题目(整体替换):{ paperId, questions: [{ question, options, answer, score, orderIndex }] }
+export function plannerExamQuestionsSave(data) {
+  return request({ url: '/api/admin/planner-exam/questions/save', method: 'post', data });
+}

+ 19 - 0
cfc-web/src/router/index.js

@@ -975,6 +975,25 @@ const routes = [
         name: 'OrgDashboard',
         component: () => import('@/views/admin/org/Dashboard.vue'),
         meta: { title: '组织大屏', perm: 'org:*' }
+      },
+      // ========== 规划师培训认证管理(W3)==========
+      {
+        path: 'planner-cert-dashboard',
+        name: 'PlannerCertDashboard',
+        component: () => import('@/views/admin/planner/PlannerCertDashboard.vue'),
+        meta: { title: '认证看板', perm: 'planner:cert' }
+      },
+      {
+        path: 'planner-course-manage',
+        name: 'PlannerCourseManage',
+        component: () => import('@/views/admin/planner/PlannerCourseManage.vue'),
+        meta: { title: '课程管理', perm: 'planner:cert' }
+      },
+      {
+        path: 'planner-exam-manage',
+        name: 'PlannerExamManage',
+        component: () => import('@/views/admin/planner/PlannerExamManage.vue'),
+        meta: { title: '题库管理', perm: 'planner:cert' }
       }
     ]
   }

+ 3 - 3
cfc-web/src/utils/permissions.js

@@ -10,12 +10,12 @@ const ROLE_PERMISSIONS = {
   // 超管:全部权限
   admin: ['*'],
   // 运营:审核全量、活动全量、任务全量、家庭/商城/知识/测评只读、组织管理
-  operator: ['dashboard', 'audit:*', 'activity:*', 'task:*', 'assessment:read', 'family:read', 'commerce:read', 'articles:read', 'knowledge:read', 'plan:*', 'org:*'],
+  operator: ['dashboard', 'audit:*', 'activity:*', 'task:*', 'assessment:read', 'family:read', 'commerce:read', 'articles:read', 'knowledge:read', 'plan:*', 'org:*', 'planner:cert'],
   // 财务:财务/退款/提现、订单只读、CF值、商城营销、业务管理、组织管理
-  finance: ['dashboard', 'finance:*', 'audit:withdraw', 'audit:refund', 'commerce:read', 'commerce:orders:read', 'biz:*', 'cf-value:*', 'org:*'],
+  finance: ['dashboard', 'finance:*', 'audit:withdraw', 'audit:refund', 'commerce:read', 'commerce:orders:read', 'biz:*', 'cf-value:*', 'org:*', 'planner:cert'],
   // 管家:家庭客服 + 规划师 + 营养师权限并集(getEffectivePermissions 中自动并入 teacher/nutritionist)
   butler: ['dashboard', 'family:*', 'task:*', 'reward:*', 'service:*', 'growth:*', 'biz:*',
-           'assessment:dan', 'health:*', 'diet:*', 'report:audit', 'plan:*'],
+           'assessment:dan', 'health:*', 'diet:*', 'report:audit', 'plan:*', 'planner:cert'],
   // 知识管理员
   knowledge_admin: ['dashboard', 'articles:*', 'knowledge:*'],
   // 成长规划师

+ 8 - 0
cfc-web/src/views/Layout.vue

@@ -299,6 +299,14 @@ export default {
             { path: '/growth-plans', label: '成长计划', icon: 'el-icon-document', perm: 'growth:plans' },
           ]},
 
+        // ===== 规划师培训认证(W3:认证看板/课程管理/题库管理)=====
+        { title: '规划师认证', icon: 'el-icon-medal', perm: 'planner:cert',
+          children: [
+            { path: '/planner-cert-dashboard', label: '认证看板', icon: 'el-icon-data-line', perm: 'planner:cert' },
+            { path: '/planner-course-manage', label: '课程管理', icon: 'el-icon-notebook-2', perm: 'planner:cert' },
+            { path: '/planner-exam-manage', label: '题库管理', icon: 'el-icon-edit-outline', perm: 'planner:cert' },
+          ]},
+
         // ===== 9. 系统配置 (system:*,权限拆分 system:base/config:member/config:dimension/config:health) =====
         { title: '系统配置', icon: 'el-icon-s-tools', perm: 'system:*',
           children: [

+ 255 - 0
cfc-web/src/views/admin/planner/PlannerCertDashboard.vue

@@ -0,0 +1,255 @@
+<template>
+  <div class="planner-cert-dashboard">
+    <!-- 顶部操作 -->
+    <div class="toolbar">
+      <div class="filters">
+        <el-select v-model="query.status" placeholder="认证状态" clearable style="width:160px" @change="loadData(1)">
+          <el-option label="待认证" value="pending_cert" />
+          <el-option label="已认证" value="certified" />
+        </el-select>
+        <el-select v-model="query.categoryId" placeholder="认证类别" clearable style="width:180px" @change="loadData(1)">
+          <el-option v-for="c in categories" :key="c.id" :label="c.name" :value="c.id" />
+        </el-select>
+        <el-button type="primary" icon="el-icon-refresh" @click="loadData(1)">刷新</el-button>
+      </div>
+      <div class="actions">
+        <el-button icon="el-icon-magic-stick" :loading="backfillLoading" @click="onBackfill">存量补登</el-button>
+      </div>
+    </div>
+
+    <!-- 列表 -->
+    <el-table :data="rows" v-loading="loading" border stripe>
+      <el-table-column prop="userId" label="用户ID" width="90" />
+      <el-table-column label="认证类别" width="120">
+        <template slot-scope="{ row }">{{ categoryName(row.categoryId) }}</template>
+      </el-table-column>
+      <el-table-column prop="requiredHours" label="要求课时" width="100" />
+      <el-table-column prop="completedHours" label="已完成课时" width="110" />
+      <el-table-column label="学习状态" width="110">
+        <template slot-scope="{ row }">
+          <el-tag size="small" :type="row.learningStatus === 'learning_completed' ? 'success' : 'warning'">
+            {{ learningStatusText(row.learningStatus) }}
+          </el-tag>
+        </template>
+      </el-table-column>
+      <el-table-column label="考核状态" width="110">
+        <template slot-scope="{ row }">
+          <el-tag size="small" :type="examTagType(row.examStatus)">{{ examStatusText(row.examStatus) }}</el-tag>
+        </template>
+      </el-table-column>
+      <el-table-column prop="examScore" label="考核分" width="90">
+        <template slot-scope="{ row }">{{ row.examScore != null ? row.examScore : '-' }}</template>
+      </el-table-column>
+      <el-table-column label="证书状态" width="110">
+        <template slot-scope="{ row }">
+          <el-tag size="small" :type="row.status === 'certified' ? 'success' : 'info'">
+            {{ row.status === 'certified' ? '已认证' : '待认证' }}
+          </el-tag>
+        </template>
+      </el-table-column>
+      <el-table-column prop="certNo" label="证书编号" min-width="140" show-overflow-tooltip />
+      <el-table-column label="更新日期" width="170">
+        <template slot-scope="{ row }">{{ formatTime(row.updatedAt) }}</template>
+      </el-table-column>
+      <el-table-column label="操作" width="200" fixed="right">
+        <template slot-scope="{ row }">
+          <el-button type="text" size="small" @click="openSync(row)">同步课时</el-button>
+          <el-button type="text" size="small" @click="onInitByUser(row)">初始化</el-button>
+        </template>
+      </el-table-column>
+    </el-table>
+
+    <!-- 分页 -->
+    <el-pagination
+      class="pagination"
+      background
+      layout="total, sizes, prev, pager, next"
+      :total="total"
+      :page-sizes="[10, 20, 50]"
+      :page-size="query.size"
+      :current-page="query.page"
+      @current-change="p => loadData(p)"
+      @size-change="s => { query.size = s; loadData(1) }"
+    />
+
+    <!-- 手动同步课时 dialog -->
+    <el-dialog title="手动同步线上课时" :visible.sync="syncDialogVisible" width="420px">
+      <el-form label-width="110px">
+        <el-form-item label="用户ID">
+          <el-input v-model="syncForm.userId" disabled />
+        </el-form-item>
+        <el-form-item label="课程ID">
+          <el-input v-model="syncForm.courseId" placeholder="planner_courses.id" />
+        </el-form-item>
+        <el-form-item label="课时(小时)">
+          <el-input-number v-model="syncForm.hours" :min="0" :step="0.5" />
+        </el-form-item>
+        <el-form-item label="进度(%)">
+          <el-input-number v-model="syncForm.progressPercent" :min="0" :max="100" :step="10" />
+        </el-form-item>
+      </el-form>
+      <span slot="footer">
+        <el-button @click="syncDialogVisible = false">取消</el-button>
+        <el-button type="primary" :loading="syncLoading" @click="onSync">确定</el-button>
+      </span>
+    </el-dialog>
+  </div>
+</template>
+
+<script>
+import {
+  plannerCertificationList,
+  plannerCertificationSyncHours,
+  plannerCertificationInitByUser,
+  plannerCertificationBackfill,
+  plannerCertCategoryList
+} from '@/api/plannerCert'
+
+export default {
+  name: 'PlannerCertDashboard',
+  data() {
+    return {
+      loading: false,
+      rows: [],
+      total: 0,
+      categories: [],
+      query: { status: '', categoryId: null, page: 1, size: 10 },
+      syncDialogVisible: false,
+      syncLoading: false,
+      backfillLoading: false,
+      syncForm: { userId: null, courseId: null, hours: 1, progressPercent: 100 }
+    }
+  },
+  created() {
+    this.loadCategories()
+    this.loadData(1)
+  },
+  methods: {
+    formatTime(t) {
+      return t ? String(t).replace('T', ' ').substring(0, 19) : '-'
+    },
+    categoryName(id) {
+      const c = this.categories.find(x => x.id === id)
+      return c ? c.name : (id || '-')
+    },
+    learningStatusText(s) {
+      const map = { pending_learning: '学习中', learning_completed: '课时完成' }
+      return map[s] || (s || '-')
+    },
+    examStatusText(s) {
+      const map = { none: '未考核', exam_passed: '已通过', exam_failed: '未通过' }
+      return map[s] || (s || '-')
+    },
+    examTagType(s) {
+      if (s === 'exam_passed') return 'success'
+      if (s === 'exam_failed') return 'danger'
+      return 'info'
+    },
+    async loadCategories() {
+      try {
+        const res = await plannerCertCategoryList()
+        this.categories = (res && res.data) || []
+      } catch (e) {
+        this.categories = []
+      }
+    },
+    async loadData(page) {
+      this.loading = true
+      this.query.page = page || this.query.page
+      try {
+        const res = await plannerCertificationList({
+          status: this.query.status || undefined,
+          categoryId: this.query.categoryId || undefined,
+          page: this.query.page,
+          size: this.query.size
+        })
+        const data = (res && res.data) || {}
+        this.rows = data.records || []
+        this.total = data.total || 0
+      } catch (e) {
+        this.rows = []
+        this.total = 0
+      } finally {
+        this.loading = false
+      }
+    },
+    openSync(row) {
+      this.syncForm = { userId: row.userId, courseId: null, hours: 1, progressPercent: 100 }
+      this.syncDialogVisible = true
+    },
+    async onSync() {
+      if (!this.syncForm.courseId) {
+        this.$message.warning('请输入课程ID')
+        return
+      }
+      this.syncLoading = true
+      try {
+        await plannerCertificationSyncHours({
+          userId: this.syncForm.userId,
+          courseId: this.syncForm.courseId,
+          hours: this.syncForm.hours,
+          progressPercent: this.syncForm.progressPercent
+        })
+        this.$message.success('同步成功')
+        this.syncDialogVisible = false
+        this.loadData()
+      } catch (e) {
+        // 拦截器已提示
+      } finally {
+        this.syncLoading = false
+      }
+    },
+    async onInitByUser(row) {
+      try {
+        await this.$confirm('确认初始化该规划师全部类别认证记录?', '提示', { type: 'warning' })
+      } catch (e) {
+        return
+      }
+      try {
+        await plannerCertificationInitByUser({ userId: row.userId })
+        this.$message.success('初始化成功')
+        this.loadData()
+      } catch (e) {
+        // 拦截器已提示
+      }
+    },
+    async onBackfill() {
+      try {
+        await this.$confirm('确认对存量规划师执行认证补登?该操作幂等,可重复执行。', '提示', { type: 'warning' })
+      } catch (e) {
+        return
+      }
+      this.backfillLoading = true
+      try {
+        await plannerCertificationBackfill()
+        this.$message.success('补登完成')
+        this.loadData()
+      } catch (e) {
+        // 拦截器已提示
+      } finally {
+        this.backfillLoading = false
+      }
+    }
+  }
+}
+</script>
+
+<style scoped>
+.planner-cert-dashboard {
+  padding: 16px;
+}
+.toolbar {
+  display: flex;
+  justify-content: space-between;
+  align-items: center;
+  margin-bottom: 16px;
+}
+.filters {
+  display: flex;
+  gap: 8px;
+}
+.pagination {
+  margin-top: 16px;
+  text-align: right;
+}
+</style>

+ 387 - 0
cfc-web/src/views/admin/planner/PlannerCourseManage.vue

@@ -0,0 +1,387 @@
+<template>
+  <div class="planner-course-manage">
+    <el-tabs v-model="activeTab" type="border-card">
+      <!-- ========== 认证类别 ========== -->
+      <el-tab-pane label="认证类别" name="category">
+        <div class="pane-toolbar">
+          <el-button type="primary" icon="el-icon-plus" @click="openCategoryDialog()">新增类别</el-button>
+        </div>
+        <el-table :data="categories" v-loading="catLoading" border stripe>
+          <el-table-column prop="id" label="ID" width="70" />
+          <el-table-column prop="code" label="编码" width="130" />
+          <el-table-column prop="name" label="名称" width="150" />
+          <el-table-column prop="description" label="描述" min-width="180" show-overflow-tooltip />
+          <el-table-column prop="requiredHours" label="要求课时" width="100" />
+          <el-table-column label="基础类" width="90">
+            <template slot-scope="{ row }">{{ row.isBase === 1 ? '是' : '否' }}</template>
+          </el-table-column>
+          <el-table-column label="状态" width="90">
+            <template slot-scope="{ row }">
+              <el-tag size="small" :type="row.status === 1 ? 'success' : 'info'">{{ row.status === 1 ? '启用' : '停用' }}</el-tag>
+            </template>
+          </el-table-column>
+          <el-table-column prop="orderIndex" label="排序" width="70" />
+          <el-table-column label="操作" width="160">
+            <template slot-scope="{ row }">
+              <el-button type="text" size="small" @click="openCategoryDialog(row)">编辑</el-button>
+              <el-button type="text" size="small" style="color:#F56C6C" @click="onCategoryDelete(row)">删除</el-button>
+            </template>
+          </el-table-column>
+        </el-table>
+      </el-tab-pane>
+
+      <!-- ========== 线上课程 ========== -->
+      <el-tab-pane label="线上课程" name="course">
+        <div class="pane-toolbar">
+          <el-select v-model="courseFilterCategory" placeholder="选择认证类别" clearable style="width:200px" @change="loadCourses">
+            <el-option v-for="c in categories" :key="c.id" :label="c.name" :value="c.id" />
+          </el-select>
+          <el-button type="primary" icon="el-icon-plus" @click="openCourseDialog()">新增课程</el-button>
+        </div>
+        <el-table :data="courses" v-loading="courseLoading" border stripe>
+          <el-table-column prop="id" label="ID" width="70" />
+          <el-table-column label="类别" width="130">
+            <template slot-scope="{ row }">{{ categoryName(row.categoryId) }}</template>
+          </el-table-column>
+          <el-table-column prop="xiaoeResourceId" label="小鹅通资源ID" width="150" show-overflow-tooltip />
+          <el-table-column prop="title" label="课程标题" min-width="200" show-overflow-tooltip />
+          <el-table-column prop="requiredHours" label="课时" width="90" />
+          <el-table-column label="必修" width="80">
+            <template slot-scope="{ row }">{{ row.isRequired === 1 ? '是' : '否' }}</template>
+          </el-table-column>
+          <el-table-column label="状态" width="90">
+            <template slot-scope="{ row }">
+              <el-tag size="small" :type="row.status === 1 ? 'success' : 'info'">{{ row.status === 1 ? '启用' : '停用' }}</el-tag>
+            </template>
+          </el-table-column>
+          <el-table-column label="操作" width="160">
+            <template slot-scope="{ row }">
+              <el-button type="text" size="small" @click="openCourseDialog(row)">编辑</el-button>
+              <el-button type="text" size="small" style="color:#F56C6C" @click="onCourseDelete(row)">删除</el-button>
+            </template>
+          </el-table-column>
+        </el-table>
+      </el-tab-pane>
+
+      <!-- ========== 线下课映射 ========== -->
+      <el-tab-pane label="线下课映射" name="offline">
+        <div class="pane-toolbar">
+          <el-button type="primary" icon="el-icon-plus" @click="openOfflineDialog()">新增映射</el-button>
+        </div>
+        <el-table :data="offlineList" v-loading="offlineLoading" border stripe>
+          <el-table-column prop="id" label="ID" width="70" />
+          <el-table-column label="类别" width="130">
+            <template slot-scope="{ row }">{{ categoryName(row.categoryId) }}</template>
+          </el-table-column>
+          <el-table-column prop="activityId" label="活动ID" width="110" />
+          <el-table-column prop="durationHours" label="课时(小时)" width="120" />
+          <el-table-column label="必修" width="80">
+            <template slot-scope="{ row }">{{ row.isRequired === 1 ? '是' : '否' }}</template>
+          </el-table-column>
+          <el-table-column label="状态" width="90">
+            <template slot-scope="{ row }">
+              <el-tag size="small" :type="row.status === 1 ? 'success' : 'info'">{{ row.status === 1 ? '启用' : '停用' }}</el-tag>
+            </template>
+          </el-table-column>
+          <el-table-column label="操作" width="160">
+            <template slot-scope="{ row }">
+              <el-button type="text" size="small" @click="openOfflineDialog(row)">编辑</el-button>
+              <el-button type="text" size="small" style="color:#F56C6C" @click="onOfflineDelete(row)">删除</el-button>
+            </template>
+          </el-table-column>
+        </el-table>
+      </el-tab-pane>
+    </el-tabs>
+
+    <!-- 类别 dialog -->
+    <el-dialog :title="catForm.id ? '编辑类别' : '新增类别'" :visible.sync="catDialogVisible" width="480px">
+      <el-form label-width="110px">
+        <el-form-item label="编码"><el-input v-model="catForm.code" placeholder="如 planner" /></el-form-item>
+        <el-form-item label="名称"><el-input v-model="catForm.name" /></el-form-item>
+        <el-form-item label="描述"><el-input v-model="catForm.description" type="textarea" /></el-form-item>
+        <el-form-item label="要求课时"><el-input-number v-model="catForm.requiredHours" :min="0" :step="0.5" /></el-form-item>
+        <el-form-item label="基础类">
+          <el-switch v-model="catForm.isBase" :active-value="1" :inactive-value="0" />
+        </el-form-item>
+        <el-form-item label="排序"><el-input-number v-model="catForm.orderIndex" :min="0" /></el-form-item>
+        <el-form-item label="状态">
+          <el-switch v-model="catForm.status" :active-value="1" :inactive-value="0" />
+        </el-form-item>
+      </el-form>
+      <span slot="footer">
+        <el-button @click="catDialogVisible = false">取消</el-button>
+        <el-button type="primary" :loading="catSaving" @click="onCategorySave">确定</el-button>
+      </span>
+    </el-dialog>
+
+    <!-- 课程 dialog -->
+    <el-dialog :title="courseForm.id ? '编辑课程' : '新增课程'" :visible.sync="courseDialogVisible" width="480px">
+      <el-form label-width="110px">
+        <el-form-item label="认证类别">
+          <el-select v-model="courseForm.categoryId" placeholder="选择类别" style="width:100%">
+            <el-option v-for="c in categories" :key="c.id" :label="c.name" :value="c.id" />
+          </el-select>
+        </el-form-item>
+        <el-form-item label="小鹅通资源ID"><el-input v-model="courseForm.xiaoeResourceId" /></el-form-item>
+        <el-form-item label="课程标题"><el-input v-model="courseForm.title" /></el-form-item>
+        <el-form-item label="课时(小时)"><el-input-number v-model="courseForm.requiredHours" :min="0" :step="0.5" /></el-form-item>
+        <el-form-item label="排序"><el-input-number v-model="courseForm.orderIndex" :min="0" /></el-form-item>
+        <el-form-item label="必修">
+          <el-switch v-model="courseForm.isRequired" :active-value="1" :inactive-value="0" />
+        </el-form-item>
+        <el-form-item label="状态">
+          <el-switch v-model="courseForm.status" :active-value="1" :inactive-value="0" />
+        </el-form-item>
+      </el-form>
+      <span slot="footer">
+        <el-button @click="courseDialogVisible = false">取消</el-button>
+        <el-button type="primary" :loading="courseSaving" @click="onCourseSave">确定</el-button>
+      </span>
+    </el-dialog>
+
+    <!-- 线下课映射 dialog -->
+    <el-dialog :title="offlineForm.id ? '编辑映射' : '新增映射'" :visible.sync="offlineDialogVisible" width="480px">
+      <el-form label-width="110px">
+        <el-form-item label="认证类别">
+          <el-select v-model="offlineForm.categoryId" placeholder="选择类别" style="width:100%">
+            <el-option v-for="c in categories" :key="c.id" :label="c.name" :value="c.id" />
+          </el-select>
+        </el-form-item>
+        <el-form-item label="活动ID"><el-input-number v-model="offlineForm.activityId" :min="1" /></el-form-item>
+        <el-form-item label="课时(小时)"><el-input-number v-model="offlineForm.durationHours" :min="0" :step="0.5" /></el-form-item>
+        <el-form-item label="必修">
+          <el-switch v-model="offlineForm.isRequired" :active-value="1" :inactive-value="0" />
+        </el-form-item>
+        <el-form-item label="状态">
+          <el-switch v-model="offlineForm.status" :active-value="1" :inactive-value="0" />
+        </el-form-item>
+      </el-form>
+      <span slot="footer">
+        <el-button @click="offlineDialogVisible = false">取消</el-button>
+        <el-button type="primary" :loading="offlineSaving" @click="onOfflineSave">确定</el-button>
+      </span>
+    </el-dialog>
+  </div>
+</template>
+
+<script>
+import {
+  plannerCertCategoryList,
+  plannerCertCategoryCreate,
+  plannerCertCategoryUpdate,
+  plannerCertCategoryDelete,
+  plannerCourseList,
+  plannerCourseCreate,
+  plannerCourseUpdate,
+  plannerCourseDelete,
+  plannerOfflineCourseList,
+  plannerOfflineCourseCreate,
+  plannerOfflineCourseUpdate,
+  plannerOfflineCourseDelete
+} from '@/api/plannerCert'
+
+export default {
+  name: 'PlannerCourseManage',
+  data() {
+    return {
+      activeTab: 'category',
+      // 类别
+      catLoading: false,
+      catSaving: false,
+      categories: [],
+      catDialogVisible: false,
+      catForm: {},
+      // 课程
+      courseLoading: false,
+      courseSaving: false,
+      courseFilterCategory: null,
+      courses: [],
+      courseDialogVisible: false,
+      courseForm: {},
+      // 线下课映射
+      offlineLoading: false,
+      offlineSaving: false,
+      offlineList: [],
+      offlineDialogVisible: false,
+      offlineForm: {}
+    }
+  },
+  created() {
+    this.loadCategories()
+    this.loadCourses()
+    this.loadOffline()
+  },
+  methods: {
+    categoryName(id) {
+      const c = this.categories.find(x => x.id === id)
+      return c ? c.name : (id || '-')
+    },
+    async loadCategories() {
+      this.catLoading = true
+      try {
+        const res = await plannerCertCategoryList()
+        this.categories = (res && res.data) || []
+      } catch (e) {
+        this.categories = []
+      } finally {
+        this.catLoading = false
+      }
+    },
+    async loadCourses() {
+      this.courseLoading = true
+      try {
+        const res = await plannerCourseList(this.courseFilterCategory)
+        this.courses = (res && res.data) || []
+      } catch (e) {
+        this.courses = []
+      } finally {
+        this.courseLoading = false
+      }
+    },
+    async loadOffline() {
+      this.offlineLoading = true
+      try {
+        const res = await plannerOfflineCourseList()
+        this.offlineList = (res && res.data) || []
+      } catch (e) {
+        this.offlineList = []
+      } finally {
+        this.offlineLoading = false
+      }
+    },
+    // ---- 类别 ----
+    openCategoryDialog(row) {
+      this.catForm = row
+        ? Object.assign({}, row, { isBase: row.isBase == null ? 0 : row.isBase, status: row.status == null ? 1 : row.status })
+        : { code: '', name: '', description: '', requiredHours: 1, isBase: 0, orderIndex: 0, status: 1 }
+      this.catDialogVisible = true
+    },
+    async onCategorySave() {
+      this.catSaving = true
+      try {
+        if (this.catForm.id) {
+          await plannerCertCategoryUpdate(this.catForm)
+        } else {
+          await plannerCertCategoryCreate(this.catForm)
+        }
+        this.$message.success('保存成功')
+        this.catDialogVisible = false
+        this.loadCategories()
+      } catch (e) {
+        // 拦截器已提示
+      } finally {
+        this.catSaving = false
+      }
+    },
+    async onCategoryDelete(row) {
+      try {
+        await this.$confirm('确认删除该类别?', '提示', { type: 'warning' })
+      } catch (e) {
+        return
+      }
+      try {
+        await plannerCertCategoryDelete({ id: row.id })
+        this.$message.success('删除成功')
+        this.loadCategories()
+      } catch (e) {
+        // 拦截器已提示
+      }
+    },
+    // ---- 课程 ----
+    openCourseDialog(row) {
+      this.courseForm = row
+        ? Object.assign({}, row, { isRequired: row.isRequired == null ? 1 : row.isRequired, status: row.status == null ? 1 : row.status })
+        : { categoryId: this.courseFilterCategory, xiaoeResourceId: '', title: '', requiredHours: 1, orderIndex: 0, isRequired: 1, status: 1 }
+      this.courseDialogVisible = true
+    },
+    async onCourseSave() {
+      if (!this.courseForm.categoryId) {
+        this.$message.warning('请选择认证类别')
+        return
+      }
+      this.courseSaving = true
+      try {
+        if (this.courseForm.id) {
+          await plannerCourseUpdate(this.courseForm)
+        } else {
+          await plannerCourseCreate(this.courseForm)
+        }
+        this.$message.success('保存成功')
+        this.courseDialogVisible = false
+        this.loadCourses()
+      } catch (e) {
+        // 拦截器已提示
+      } finally {
+        this.courseSaving = false
+      }
+    },
+    async onCourseDelete(row) {
+      try {
+        await this.$confirm('确认删除该课程?', '提示', { type: 'warning' })
+      } catch (e) {
+        return
+      }
+      try {
+        await plannerCourseDelete(row.id)
+        this.$message.success('删除成功')
+        this.loadCourses()
+      } catch (e) {
+        // 拦截器已提示
+      }
+    },
+    // ---- 线下课映射 ----
+    openOfflineDialog(row) {
+      this.offlineForm = row
+        ? Object.assign({}, row, { isRequired: row.isRequired == null ? 1 : row.isRequired, status: row.status == null ? 1 : row.status })
+        : { categoryId: null, activityId: null, durationHours: 1, isRequired: 1, status: 1 }
+      this.offlineDialogVisible = true
+    },
+    async onOfflineSave() {
+      if (!this.offlineForm.categoryId || !this.offlineForm.activityId) {
+        this.$message.warning('请选择类别并填写活动ID')
+        return
+      }
+      this.offlineSaving = true
+      try {
+        if (this.offlineForm.id) {
+          await plannerOfflineCourseUpdate(this.offlineForm)
+        } else {
+          await plannerOfflineCourseCreate(this.offlineForm)
+        }
+        this.$message.success('保存成功')
+        this.offlineDialogVisible = false
+        this.loadOffline()
+      } catch (e) {
+        // 拦截器已提示
+      } finally {
+        this.offlineSaving = false
+      }
+    },
+    async onOfflineDelete(row) {
+      try {
+        await this.$confirm('确认删除该映射?', '提示', { type: 'warning' })
+      } catch (e) {
+        return
+      }
+      try {
+        await plannerOfflineCourseDelete(row.id)
+        this.$message.success('删除成功')
+        this.loadOffline()
+      } catch (e) {
+        // 拦截器已提示
+      }
+    }
+  }
+}
+</script>
+
+<style scoped>
+.planner-course-manage {
+  padding: 16px;
+}
+.pane-toolbar {
+  display: flex;
+  gap: 12px;
+  margin-bottom: 16px;
+}
+</style>

+ 356 - 0
cfc-web/src/views/admin/planner/PlannerExamManage.vue

@@ -0,0 +1,356 @@
+<template>
+  <div class="planner-exam-manage">
+    <!-- 左侧:类别选择 + 试卷列表 -->
+    <div class="exam-layout">
+      <div class="left-panel">
+        <div class="panel-header">
+          <span>认证类别</span>
+        </div>
+        <el-select v-model="categoryId" placeholder="选择类别" style="width:100%" @change="loadPapers">
+          <el-option v-for="c in categories" :key="c.id" :label="c.name" :value="c.id" />
+        </el-select>
+
+        <div class="panel-header" style="margin-top:20px">
+          <span>试卷列表</span>
+          <el-button type="text" size="small" icon="el-icon-plus" @click="openPaperDialog()">新增</el-button>
+        </div>
+        <el-table :data="papers" v-loading="paperLoading" border size="small">
+          <el-table-column prop="title" label="试卷标题" min-width="140" show-overflow-tooltip />
+          <el-table-column prop="passScore" label="及格分" width="80" />
+          <el-table-column prop="durationMinutes" label="时长(分)" width="90" />
+          <el-table-column label="操作" width="140">
+            <template slot-scope="{ row }">
+              <el-button type="text" size="small" @click="selectPaper(row)">题目</el-button>
+              <el-button type="text" size="small" @click="openPaperDialog(row)">编辑</el-button>
+              <el-button type="text" size="small" style="color:#F56C6C" @click="onPaperDelete(row)">删除</el-button>
+            </template>
+          </el-table-column>
+        </el-table>
+      </div>
+
+      <!-- 右侧:题库维护 -->
+      <div class="right-panel">
+        <div class="panel-header">
+          <span>{{ currentPaper ? ('题库:' + currentPaper.title) : '题库维护' }}</span>
+          <el-button v-if="currentPaper" type="primary" size="small" icon="el-icon-plus" @click="addQuestion">添加题目</el-button>
+        </div>
+        <div v-if="!currentPaper" class="placeholder">请先选择左侧试卷,维护该试卷题目</div>
+        <el-table v-else :data="questions" v-loading="questionLoading" border size="small">
+          <el-table-column label="#" width="50">
+            <template slot-scope="{ row }">{{ row.orderIndex }}</template>
+          </el-table-column>
+          <el-table-column prop="question" label="题干" min-width="220" show-overflow-tooltip />
+          <el-table-column prop="options" label="选项" min-width="180" show-overflow-tooltip />
+          <el-table-column prop="answer" label="答案" width="90" />
+          <el-table-column prop="score" label="分值" width="70" />
+          <el-table-column label="操作" width="120">
+            <template slot-scope="{ row, $index }">
+              <el-button type="text" size="small" @click="editQuestion(row, $index)">编辑</el-button>
+              <el-button type="text" size="small" style="color:#F56C6C" @click="removeQuestion($index)">删除</el-button>
+            </template>
+          </el-table-column>
+        </el-table>
+        <div v-if="currentPaper" class="save-bar">
+          <el-button type="primary" :loading="saving" @click="saveQuestions">保存题库</el-button>
+          <span class="save-hint">保存为整体替换该试卷全部题目</span>
+        </div>
+      </div>
+    </div>
+
+    <!-- 试卷 dialog -->
+    <el-dialog :title="paperForm.id ? '编辑试卷' : '新增试卷'" :visible.sync="paperDialogVisible" width="480px">
+      <el-form label-width="110px">
+        <el-form-item label="试卷标题"><el-input v-model="paperForm.title" /></el-form-item>
+        <el-form-item label="及格分"><el-input-number v-model="paperForm.passScore" :min="0" :max="100" /></el-form-item>
+        <el-form-item label="时长(分钟)"><el-input-number v-model="paperForm.durationMinutes" :min="1" /></el-form-item>
+        <el-form-item label="状态">
+          <el-switch v-model="paperForm.status" :active-value="1" :inactive-value="0" />
+        </el-form-item>
+      </el-form>
+      <span slot="footer">
+        <el-button @click="paperDialogVisible = false">取消</el-button>
+        <el-button type="primary" :loading="paperSaving" @click="onPaperSave">确定</el-button>
+      </span>
+    </el-dialog>
+
+    <!-- 题目 dialog -->
+    <el-dialog :title="qFormIndex >= 0 ? '编辑题目' : '添加题目'" :visible.sync="questionDialogVisible" width="520px">
+      <el-form label-width="90px">
+        <el-form-item label="题干">
+          <el-input v-model="qForm.question" type="textarea" :rows="2" />
+        </el-form-item>
+        <el-form-item label="选项">
+          <div v-for="(opt, i) in qForm.optionsArr" :key="i" class="opt-row">
+            <el-input v-model="qForm.optionsArr[i]" placeholder="选项内容(不带 A/B/C/D 前缀,自动映射)" />
+            <el-button type="text" icon="el-icon-close" @click="qForm.optionsArr.splice(i, 1)" />
+          </div>
+          <el-button type="text" size="small" icon="el-icon-plus" @click="qForm.optionsArr.push('')">添加选项</el-button>
+        </el-form-item>
+        <el-form-item label="答案">
+          <el-select v-model="qForm.answer" placeholder="选择正确答案字母" style="width:200px">
+            <el-option v-for="(opt, i) in qForm.optionsArr" :key="i" :label="String.fromCharCode(65 + i)" :value="String.fromCharCode(65 + i)" />
+          </el-select>
+        </el-form-item>
+        <el-form-item label="分值"><el-input-number v-model="qForm.score" :min="1" /></el-form-item>
+      </el-form>
+      <span slot="footer">
+        <el-button @click="questionDialogVisible = false">取消</el-button>
+        <el-button type="primary" @click="confirmQuestion">确定</el-button>
+      </span>
+    </el-dialog>
+  </div>
+</template>
+
+<script>
+import {
+  plannerCertCategoryList,
+  plannerExamPapers,
+  plannerExamPaperCreate,
+  plannerExamPaperUpdate,
+  plannerExamPaperDelete,
+  plannerExamQuestions,
+  plannerExamQuestionsSave
+} from '@/api/plannerCert'
+
+export default {
+  name: 'PlannerExamManage',
+  data() {
+    return {
+      categories: [],
+      categoryId: null,
+      papers: [],
+      paperLoading: false,
+      currentPaper: null,
+      questions: [],
+      questionLoading: false,
+      saving: false,
+      // 试卷 dialog
+      paperDialogVisible: false,
+      paperSaving: false,
+      paperForm: {},
+      // 题目 dialog
+      questionDialogVisible: false,
+      qForm: { question: '', optionsArr: ['', '', '', ''], answer: '', score: 5 },
+      qFormIndex: -1
+    }
+  },
+  created() {
+    this.loadCategories()
+  },
+  methods: {
+    async loadCategories() {
+      try {
+        const res = await plannerCertCategoryList()
+        this.categories = (res && res.data) || []
+        if (this.categories.length > 0) {
+          this.categoryId = this.categories[0].id
+          this.loadPapers()
+        }
+      } catch (e) {
+        this.categories = []
+      }
+    },
+    async loadPapers() {
+      if (!this.categoryId) {
+        this.papers = []
+        return
+      }
+      this.paperLoading = true
+      try {
+        const res = await plannerExamPapers(this.categoryId)
+        this.papers = (res && res.data) || []
+      } catch (e) {
+        this.papers = []
+      } finally {
+        this.paperLoading = false
+      }
+    },
+    async selectPaper(row) {
+      this.currentPaper = row
+      this.questions = []
+      this.questionLoading = true
+      try {
+        const res = await plannerExamQuestions(row.id)
+        const list = (res && res.data) || []
+        this.questions = list.map(q => Object.assign({}, q, {
+          optionsArr: this.parseOptions(q.options)
+        }))
+      } catch (e) {
+        this.questions = []
+      } finally {
+        this.questionLoading = false
+      }
+    },
+    parseOptions(options) {
+      // 后端存 "A:...|B:...|C:...|D:...";转纯内容数组
+      if (!options) return ['', '', '', '']
+      const s = String(options)
+      const parts = s.split('|').filter(Boolean)
+      return parts.map(p => {
+        const colon = p.indexOf(':')
+        return colon > 0 ? p.substring(colon + 1) : p
+      })
+    },
+    serializeOptions(arr) {
+      return (arr || []).map((o, i) => String.fromCharCode(65 + i) + ':' + o).join('|')
+    },
+    // ---- 试卷 ----
+    openPaperDialog(row) {
+      this.paperForm = row
+        ? Object.assign({}, row, { status: row.status == null ? 1 : row.status })
+        : { categoryId: this.categoryId, title: '', passScore: 60, durationMinutes: 30, questionCount: 0, status: 1 }
+      this.paperDialogVisible = true
+    },
+    async onPaperSave() {
+      if (!this.paperForm.title) {
+        this.$message.warning('请输入试卷标题')
+        return
+      }
+      this.paperSaving = true
+      try {
+        if (this.paperForm.id) {
+          await plannerExamPaperUpdate(this.paperForm)
+        } else {
+          await plannerExamPaperCreate(this.paperForm)
+        }
+        this.$message.success('保存成功')
+        this.paperDialogVisible = false
+        this.loadPapers()
+      } catch (e) {
+        // 拦截器已提示
+      } finally {
+        this.paperSaving = false
+      }
+    },
+    async onPaperDelete(row) {
+      try {
+        await this.$confirm('确认删除该试卷及其题目?', '提示', { type: 'warning' })
+      } catch (e) {
+        return
+      }
+      try {
+        await plannerExamPaperDelete(row.id)
+        this.$message.success('删除成功')
+        if (this.currentPaper && this.currentPaper.id === row.id) {
+          this.currentPaper = null
+          this.questions = []
+        }
+        this.loadPapers()
+      } catch (e) {
+        // 拦截器已提示
+      }
+    },
+    // ---- 题目 ----
+    addQuestion() {
+      this.qForm = { question: '', optionsArr: ['', '', '', ''], answer: '', score: 5 }
+      this.qFormIndex = -1
+      this.questionDialogVisible = true
+    },
+    editQuestion(row, index) {
+      this.qForm = {
+        question: row.question,
+        optionsArr: (row.optionsArr && row.optionsArr.length > 0) ? row.optionsArr.slice() : ['', '', '', ''],
+        answer: row.answer,
+        score: row.score
+      }
+      this.qFormIndex = index
+      this.questionDialogVisible = true
+    },
+    confirmQuestion() {
+      if (!this.qForm.question) {
+        this.$message.warning('请输入题干')
+        return
+      }
+      if (!this.qForm.answer) {
+        this.$message.warning('请选择正确答案')
+        return
+      }
+      const payload = {
+        question: this.qForm.question,
+        options: this.serializeOptions(this.qForm.optionsArr),
+        answer: this.qForm.answer,
+        score: this.qForm.score || 5,
+        orderIndex: this.qFormIndex >= 0 ? this.questions[this.qFormIndex].orderIndex : this.questions.length + 1
+      }
+      if (this.qFormIndex >= 0) {
+        this.$set(this.questions, this.qFormIndex, Object.assign({}, this.questions[this.qFormIndex], payload, {
+          optionsArr: this.qForm.optionsArr.slice()
+        }))
+      } else {
+        this.questions.push(Object.assign({}, payload, { optionsArr: this.qForm.optionsArr.slice() }))
+      }
+      this.questionDialogVisible = false
+    },
+    removeQuestion(index) {
+      this.questions.splice(index, 1)
+      this.questions = this.questions.map((q, i) => Object.assign({}, q, { orderIndex: i + 1 }))
+    },
+    async saveQuestions() {
+      if (!this.currentPaper) return
+      this.saving = true
+      try {
+        const questions = this.questions.map(q => ({
+          question: q.question,
+          options: q.options,
+          answer: q.answer,
+          score: q.score,
+          orderIndex: q.orderIndex
+        }))
+        await plannerExamQuestionsSave({ paperId: this.currentPaper.id, questions })
+        this.$message.success('题库已保存')
+      } catch (e) {
+        // 拦截器已提示
+      } finally {
+        this.saving = false
+      }
+    }
+  }
+}
+</script>
+
+<style scoped>
+.planner-exam-manage {
+  padding: 16px;
+}
+.exam-layout {
+  display: flex;
+  gap: 16px;
+}
+.left-panel {
+  width: 420px;
+  flex-shrink: 0;
+}
+.right-panel {
+  flex: 1;
+  min-width: 0;
+}
+.panel-header {
+  display: flex;
+  justify-content: space-between;
+  align-items: center;
+  font-weight: 600;
+  margin-bottom: 10px;
+  color: #303133;
+}
+.placeholder {
+  color: #909399;
+  padding: 60px 0;
+  text-align: center;
+}
+.save-bar {
+  margin-top: 16px;
+  display: flex;
+  align-items: center;
+  gap: 12px;
+}
+.save-hint {
+  color: #909399;
+  font-size: 12px;
+}
+.opt-row {
+  display: flex;
+  gap: 8px;
+  margin-bottom: 8px;
+  align-items: center;
+}
+</style>