From 9f7ab62a066f125c39d20deb816bb479d056ecd4 Mon Sep 17 00:00:00 2001 From: lik Date: Tue, 10 Nov 2026 12:02:07 +0800 Subject: [PATCH] =?UTF-8?q?feat(attendants):=20=E6=94=AF=E6=8C=81=E9=99=AA?= =?UTF-8?q?=E8=AF=8A=E5=B8=88=E9=98=B6=E6=AE=B5=E4=B8=8E=E7=AD=89=E7=BA=A7?= =?UTF-8?q?=E5=B1=95=E7=A4=BA=E5=8F=8A=E8=BD=AC=E6=AD=A3=E8=B0=83=E7=BA=A7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 列表新增阶段/等级列,实习/正式与青铜~钻石及星级可见 - 新增阶段与等级弹窗,调用 /employee/:id/level 完成转正、调级与设星 --- src/api/employee.ts | 10 +++ src/types/api.ts | 6 ++ src/utils/format.ts | 18 ++++++ src/views/attendants/index.vue | 109 ++++++++++++++++++++++++++++++++- 4 files changed, 140 insertions(+), 3 deletions(-) diff --git a/src/api/employee.ts b/src/api/employee.ts index fba035f..51e47c5 100644 --- a/src/api/employee.ts +++ b/src/api/employee.ts @@ -33,4 +33,14 @@ export const employeeApi = { method: 'PATCH', body: { status }, }), + + /** 实习转正 / 调级 / 钻石设星 */ + updateLevel: ( + id: string, + body: { stage?: 'intern' | 'certified'; grade?: string; star?: number } + ) => + request<{ employee: Employee }>(`/health/employee/${id}/level`, { + method: 'PATCH', + body, + }), } diff --git a/src/types/api.ts b/src/types/api.ts index e5f5568..c704e75 100644 --- a/src/types/api.ts +++ b/src/types/api.ts @@ -191,6 +191,12 @@ export type Employee = { languages?: string[] isOnline?: boolean orderCount?: number + /** 陪诊师阶段:intern=实习,certified=正式 */ + stage?: 'intern' | 'certified' + /** 等级仅用于展示与排序,不参与权限判定 */ + grade?: 'bronze' | 'silver' | 'gold' | 'diamond' + /** 星级仅钻石等级有效(0-5) */ + star?: number } emergencyContact?: { name?: string diff --git a/src/utils/format.ts b/src/utils/format.ts index 550c064..f1d0021 100644 --- a/src/utils/format.ts +++ b/src/utils/format.ts @@ -102,6 +102,24 @@ export const EMPLOYEE_STATUS_VARIANTS: Record = { suspended: 'warning', } +/** 陪诊师阶段:实习只看单,转正后才能接单 */ +export const ATTENDANT_STAGE_LABELS: Record = { + intern: '实习', + certified: '正式', +} + +export const ATTENDANT_STAGE_VARIANTS: Record = { + intern: 'info', + certified: 'success', +} + +export const ATTENDANT_GRADE_LABELS: Record = { + bronze: '青铜', + silver: '白银', + gold: '黄金', + diamond: '钻石', +} + export const ACCOUNT_STATUS_LABELS: Record = { normal: '正常', lock: '已锁定', diff --git a/src/views/attendants/index.vue b/src/views/attendants/index.vue index 357383c..82cf7b9 100644 --- a/src/views/attendants/index.vue +++ b/src/views/attendants/index.vue @@ -109,9 +109,21 @@ + + @@ -477,6 +532,9 @@ import type { AttendantApplication, Employee } from '~/types/api' import { exportCsv } from '~/utils/csv' import { fetchAllPages } from '~/utils/paging' import { + ATTENDANT_GRADE_LABELS, + ATTENDANT_STAGE_LABELS, + ATTENDANT_STAGE_VARIANTS, EMPLOYEE_STATUS_LABELS, EMPLOYEE_STATUS_VARIANTS, ROLE_LABELS, @@ -509,6 +567,7 @@ const fields = [ { key: 'contact', label: '联系方式' }, { key: 'role', label: '角色' }, { key: 'status', label: '状态' }, + { key: 'level', label: '阶段 / 等级' }, { key: 'service', label: '服务数据' }, { key: 'area', label: '服务区域 / 擅长' }, { key: 'action', label: '操作' }, @@ -557,7 +616,7 @@ const exportEmployees = async () => { ) exportCsv( `attendants-${today()}.csv`, - ['工号', '姓名', '手机号', '邮箱', '角色', '职称/部门', '状态', '工作年限', '累计接单', '服务区域', '擅长领域', '简介'], + ['工号', '姓名', '手机号', '邮箱', '角色', '职称/部门', '状态', '工作年限', '服务区域', '擅长领域', '简介'], items.map((item) => [ item.employeeNo || '', item.profile?.name || '', @@ -567,7 +626,6 @@ const exportEmployees = async () => { [item.work?.title, item.work?.department].filter(Boolean).join(' / '), EMPLOYEE_STATUS_LABELS[item.status || ''] || item.status || '', item.work?.workYears ?? 0, - item.attendantInfo?.orderCount ?? 0, (item.attendantInfo?.serviceAreas || []).join('、'), (item.attendantInfo?.specialties || []).join('、'), item.introduction || '', @@ -614,6 +672,51 @@ const form = reactive({ const statusVisible = ref(false) const statusTarget = ref(null) +// ==================== 阶段与等级 ==================== +const stageOf = (item: Employee) => (item.attendantInfo?.stage === 'intern' ? 'intern' : 'certified') +const gradeOf = (item: Employee) => item.attendantInfo?.grade || 'bronze' +const starOf = (item: Employee) => Number(item.attendantInfo?.star) || 0 + +const levelVisible = ref(false) +const levelSaving = ref(false) +const levelTarget = ref(null) +const levelForm = reactive<{ stage: 'intern' | 'certified'; grade: string; star: number }>({ + stage: 'intern', + grade: 'bronze', + star: 0, +}) + +const openLevel = (employee: Employee) => { + levelTarget.value = employee + levelForm.stage = employee.attendantInfo?.stage === 'intern' ? 'intern' : 'certified' + levelForm.grade = employee.attendantInfo?.grade || 'bronze' + levelForm.star = Number(employee.attendantInfo?.star) || 0 + levelVisible.value = true +} + +const confirmLevel = async () => { + const target = levelTarget.value + if (!target || levelSaving.value) return + + levelSaving.value = true + try { + const payload: { stage: 'intern' | 'certified'; grade: string; star?: number } = { + stage: levelForm.stage, + grade: levelForm.grade, + } + // 星级只对钻石有效:其他等级不传,服务端会把旧星级归零 + if (levelForm.grade === 'diamond') payload.star = Number(levelForm.star) || 0 + await employeeApi.updateLevel(target._id, payload) + notify.success('阶段与等级已更新') + levelVisible.value = false + await load() + } catch { + // 请求层已统一提示 + } finally { + levelSaving.value = false + } +} + // ==================== 入驻审核 ==================== const appFields = [ { key: 'person', label: '申请人' },