fix(培训课程):优化培训课程
This commit is contained in:
1 parent
e378e8b7fd
commit
aae041a0b4
19 files changed
+777
-188
No files matched your search
@@ -88,67 +88,6 @@
|
||||
</t-table>
|
||||
</div>
|
||||
|
||||
<!-- 月度培训计划与审批:经理/人事审批决策(通过/调整/驳回),课长可见本部门计划 -->
|
||||
<div class="panel-box">
|
||||
<div class="panel-box__header">
|
||||
<span class="panel-box__title plan-title-row">
|
||||
月度培训计划与审批({{ monthPlansYear }})
|
||||
<t-select
|
||||
v-model="monthPlansYear"
|
||||
class="year-select"
|
||||
:options="yearOptions"
|
||||
@change="loadMonthPlans"
|
||||
/>
|
||||
</span>
|
||||
<div class="panel-box__actions">
|
||||
<t-button v-if="isHr" variant="outline" :loading="rolling" @click="onRollMonthPlans">月底滚动未完成计划</t-button>
|
||||
<t-button variant="outline" @click="loadMonthPlans">刷新</t-button>
|
||||
</div>
|
||||
</div>
|
||||
<t-table
|
||||
:data="monthPlans"
|
||||
:columns="monthPlanColumns"
|
||||
row-key="id"
|
||||
size="small"
|
||||
:loading="monthPlansLoading"
|
||||
>
|
||||
<template #dept_id="{ row }">{{ deptMap[row.dept_id] || row.dept_id || '-' }}</template>
|
||||
<template #start_at="{ row }">{{ fmtStartAt(row.start_at) }}</template>
|
||||
<template #status="{ row }">
|
||||
<t-tag v-if="row.status === 'approved'" theme="success" variant="light" size="small">已通过</t-tag>
|
||||
<t-tag v-else-if="row.status === 'rejected'" theme="danger" variant="light" size="small">已驳回</t-tag>
|
||||
<t-tag v-else-if="row.status === 'submitted'" theme="warning" variant="light" size="small">待审批</t-tag>
|
||||
<t-tag v-else-if="row.status === 'rolled'" theme="primary" variant="light" size="small">已滚动</t-tag>
|
||||
<t-tag v-else theme="default" variant="light" size="small">草稿</t-tag>
|
||||
</template>
|
||||
<template #reject_reason="{ row }">{{ row.reject_reason || '-' }}</template>
|
||||
<template #op="{ row }">
|
||||
<template v-if="canApprove && (row.status === 'submitted' || row.status === 'draft')">
|
||||
<t-button variant="text" theme="success" size="small" @click="onApprove(row, 'pass')">通过</t-button>
|
||||
<t-button variant="text" theme="warning" size="small" @click="onApprove(row, 'adjust')">调整</t-button>
|
||||
<t-button variant="text" theme="danger" size="small" @click="onApprove(row, 'reject')">驳回</t-button>
|
||||
</template>
|
||||
</template>
|
||||
</t-table>
|
||||
</div>
|
||||
|
||||
<!-- 审批意见弹窗(调整/驳回需填审批意见) -->
|
||||
<t-dialog v-model:visible="approveVisible" :header="approveTitle" width="420">
|
||||
<t-textarea
|
||||
v-model="approveReason"
|
||||
:autosize="{ minRows: 3 }"
|
||||
placeholder="请输入审批意见(调整/驳回建议注明原因)"
|
||||
/>
|
||||
<template #footer>
|
||||
<t-button variant="outline" @click="approveVisible = false">取消</t-button>
|
||||
<t-button
|
||||
:theme="approveAction === 'reject' ? 'danger' : 'primary'"
|
||||
:loading="approving"
|
||||
@click="onConfirmApprove"
|
||||
>确认</t-button>
|
||||
</template>
|
||||
</t-dialog>
|
||||
|
||||
<!-- 提报需求弹窗(编辑态复用:部门按提报人自动获取) -->
|
||||
<t-dialog v-model:visible="demandFormVisible" :header="demandDialogTitle" width="560">
|
||||
<t-form :data="demandForm" label-width="90" @submit="onSaveDemand">
|
||||
@@ -264,7 +203,6 @@ import * as XLSX from 'xlsx'
|
||||
import { DEMAND_TEMPLATE_KEY, downloadTrainingTemplate } from '../trainingTemplates'
|
||||
import { apiErrorMessage } from '@/utils/request'
|
||||
import {
|
||||
approveMonthPlan,
|
||||
broadcastTrainingNotification,
|
||||
confirmDemand,
|
||||
deleteDemand,
|
||||
@@ -274,12 +212,9 @@ import {
|
||||
listDepts,
|
||||
listLecturers,
|
||||
listMembers,
|
||||
listMonthPlans,
|
||||
rollMonthPlans,
|
||||
saveDemand,
|
||||
type TrainingDept,
|
||||
type TrainingDemand,
|
||||
type TrainingMonthPlan,
|
||||
type TrainingLecturerOption,
|
||||
type TrainingMember,
|
||||
unwrap,
|
||||
@@ -289,10 +224,6 @@ const props = defineProps<{ roles: string[]; admin?: boolean }>()
|
||||
|
||||
// 计划管理(录入/推送/排课):人事/课长(roles 已按权限组展开,经理自动命中课长)
|
||||
const canManage = computed(() => props.admin || props.roles.some((r) => r === 'hr' || r === 'supervisor'))
|
||||
// 审批决策:经理(exec)/人事 — 与后端 ApproveMonthPlan 的 requireRoles 口径一致
|
||||
const canApprove = computed(() => props.admin || props.roles.some((r) => r === 'hr' || r === 'exec'))
|
||||
// 月底滚动等运营动作仅人事
|
||||
const isHr = computed(() => props.admin || props.roles.includes('hr'))
|
||||
|
||||
const now = new Date()
|
||||
const currentYear = now.getFullYear()
|
||||
@@ -468,98 +399,12 @@ const loadFormOptions = async () => {
|
||||
const loadAll = async () => {
|
||||
loading.value = true
|
||||
try {
|
||||
await Promise.all([loadDemands(), loadMonthPlans()])
|
||||
await loadDemands()
|
||||
} finally {
|
||||
loading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
// ---- 月度培训计划与审批 ----
|
||||
|
||||
const monthPlans = ref<TrainingMonthPlan[]>([])
|
||||
const monthPlansLoading = ref(false)
|
||||
const monthPlansYear = ref(currentYear)
|
||||
|
||||
const monthPlanColumns = [
|
||||
{ colKey: 'title', title: '计划主题' },
|
||||
{ colKey: 'month', title: '月份', width: 64 },
|
||||
{ colKey: 'dept_id', title: '部门', width: 110 },
|
||||
{ colKey: 'start_at', title: '开始时间', width: 130 },
|
||||
{ colKey: 'location', title: '地点', width: 100 },
|
||||
{ colKey: 'status', title: '状态', width: 84 },
|
||||
{ colKey: 'reject_reason', title: '审批意见', width: 150 },
|
||||
{ colKey: 'op', title: '操作', width: 170 },
|
||||
]
|
||||
|
||||
const fmtStartAt = (v: string | null) => (v ? String(v).slice(0, 16).replace('T', ' ') : '-')
|
||||
|
||||
const loadMonthPlans = async () => {
|
||||
monthPlansLoading.value = true
|
||||
try {
|
||||
const res = await listMonthPlans({ year: monthPlansYear.value, page_size: 200 })
|
||||
monthPlans.value = unwrap(res) || []
|
||||
} catch (e: any) {
|
||||
MessagePlugin.error(apiErrorMessage(e, '月度计划加载失败'))
|
||||
} finally {
|
||||
monthPlansLoading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
// 审批决策:通过直达;调整/驳回弹窗填审批意见
|
||||
const approveVisible = ref(false)
|
||||
const approving = ref(false)
|
||||
const approveAction = ref<'pass' | 'adjust' | 'reject'>('pass')
|
||||
const approveRow = ref<TrainingMonthPlan | null>(null)
|
||||
const approveReason = ref('')
|
||||
const approveTitle = computed(() => {
|
||||
const name = approveRow.value?.title || ''
|
||||
if (approveAction.value === 'reject') return `驳回计划:${name}`
|
||||
if (approveAction.value === 'adjust') return `调整意见:${name}`
|
||||
return `通过计划:${name}`
|
||||
})
|
||||
|
||||
const onConfirmApprove = async () => {
|
||||
const row = approveRow.value
|
||||
if (!row) return
|
||||
approving.value = true
|
||||
try {
|
||||
await approveMonthPlan(row.id, approveAction.value, approveReason.value.trim())
|
||||
MessagePlugin.success(approveAction.value === 'pass' ? '已通过该月度计划' : '审批意见已提交')
|
||||
approveVisible.value = false
|
||||
loadMonthPlans()
|
||||
} catch (e: any) {
|
||||
MessagePlugin.error(apiErrorMessage(e, '审批失败,请稍后重试'))
|
||||
} finally {
|
||||
approving.value = false
|
||||
}
|
||||
}
|
||||
|
||||
const onApprove = (row: TrainingMonthPlan, action: 'pass' | 'adjust' | 'reject') => {
|
||||
approveRow.value = row
|
||||
approveAction.value = action
|
||||
approveReason.value = ''
|
||||
if (action === 'pass') {
|
||||
onConfirmApprove()
|
||||
return
|
||||
}
|
||||
approveVisible.value = true
|
||||
}
|
||||
|
||||
// 月底滚动(人事):未完成计划滚动生成下月计划
|
||||
const rolling = ref(false)
|
||||
const onRollMonthPlans = async () => {
|
||||
rolling.value = true
|
||||
try {
|
||||
const res = await rollMonthPlans(monthPlansYear.value, new Date().getMonth() + 1)
|
||||
MessagePlugin.success(`已滚动 ${unwrap(res)?.rolled ?? 0} 条未完成计划到下月`)
|
||||
loadMonthPlans()
|
||||
} catch (e: any) {
|
||||
MessagePlugin.error(apiErrorMessage(e, '滚动失败,请稍后重试'))
|
||||
} finally {
|
||||
rolling.value = false
|
||||
}
|
||||
}
|
||||
|
||||
const onOpenDemandForm = () => {
|
||||
demandForm.value = {
|
||||
id: '',
|
||||
|
||||
Reference in new issue
Block a user