|
|
@@ -212,7 +212,7 @@
|
|
|
|
|
|
<div class="profile-actions">
|
|
|
<el-button type="success" size="large" @click="handleJoinTeam">加入团队</el-button>
|
|
|
- <el-button size="large" plain>维护档案</el-button>
|
|
|
+ <el-button size="large" plain @click="handleEdit">维护档案</el-button>
|
|
|
<el-button size="large" plain>下载履历</el-button>
|
|
|
</div>
|
|
|
</div>
|
|
|
@@ -455,7 +455,7 @@
|
|
|
|
|
|
<template #footer>
|
|
|
<el-button @click="closeDialog">取 消</el-button>
|
|
|
- <el-button type="primary" @click="submitForm" :loading="submitLoading">确 定</el-button>
|
|
|
+ <el-button type="primary" @click="submitExpertForm" :loading="submitLoading">确 定</el-button>
|
|
|
</template>
|
|
|
</Dialog>
|
|
|
|
|
|
@@ -546,6 +546,7 @@ import { DICT_TYPE, getStrDictOptions } from '@/utils/dict'
|
|
|
import { ElTable } from 'element-plus'
|
|
|
|
|
|
const defaultFormData = () => ({
|
|
|
+ id: undefined,
|
|
|
expertName: '',
|
|
|
achievement: '',
|
|
|
echelon: '',
|
|
|
@@ -621,6 +622,35 @@ const closeDialog = () => {
|
|
|
resetForm()
|
|
|
}
|
|
|
|
|
|
+const fillTeamSelection = (teams: any[] = []) => {
|
|
|
+ selectedTeams.value = [...teams]
|
|
|
+ tempSelectedTeams.value = [...teams]
|
|
|
+ tempSelectedTeamMap.value = Object.fromEntries(teams.map((team) => [team.id, team]))
|
|
|
+}
|
|
|
+
|
|
|
+const buildFormDataFromExpertDetail = (detail: any) => {
|
|
|
+ const teams = detail?.teams || []
|
|
|
+ fillTeamSelection(teams)
|
|
|
+ return {
|
|
|
+ id: detail?.id,
|
|
|
+ expertName: detail?.expertName || '',
|
|
|
+ achievement: detail?.achievement || '',
|
|
|
+ echelon: detail?.echelon || '',
|
|
|
+ education: detail?.education || '',
|
|
|
+ specialDirection: detail?.specialDirection || [],
|
|
|
+ softwareSkills: detail?.softwareSkills || [],
|
|
|
+ teamIds: teams.length ? teams.map((team) => team.id) : detail?.teamIds || [],
|
|
|
+ school: detail?.school || '',
|
|
|
+ birthday: detail?.birthday || null,
|
|
|
+ avatar: detail?.avatar || '',
|
|
|
+ deptId: detail?.deptId || '',
|
|
|
+ formerPost: detail?.formerPost || '',
|
|
|
+ jobTitle: detail?.jobTitle || '',
|
|
|
+ professionalTitle: detail?.professionalTitle || '',
|
|
|
+ expertRank: detail?.expertRank || []
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
type CellItem =
|
|
|
| {
|
|
|
type: 'members'
|
|
|
@@ -1042,6 +1072,14 @@ const handleJoinTeam = async () => {
|
|
|
await getTeamOptionsList()
|
|
|
}
|
|
|
|
|
|
+const handleEdit = () => {
|
|
|
+ if (!currentExpertDetail.value) return
|
|
|
+ isEdit.value = true
|
|
|
+ dialogTitle.value = '编辑专家'
|
|
|
+ formData.value = buildFormDataFromExpertDetail(currentExpertDetail.value)
|
|
|
+ dialogVisible.value = true
|
|
|
+}
|
|
|
+
|
|
|
const confirmTeamSelection = async () => {
|
|
|
selectedTeams.value = [...tempSelectedTeams.value]
|
|
|
const teamIds = selectedTeams.value.map((team) => team.id)
|
|
|
@@ -1108,6 +1146,44 @@ const submitForm = async () => {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+const submitExpertForm = async () => {
|
|
|
+ if (!formRef.value) return
|
|
|
+
|
|
|
+ const valid = await formRef.value.validate().catch(() => false)
|
|
|
+ if (!valid) return
|
|
|
+
|
|
|
+ submitLoading.value = true
|
|
|
+ try {
|
|
|
+ const payload = {
|
|
|
+ ...formData.value,
|
|
|
+ avatar:
|
|
|
+ typeof formData.value.avatar === 'string'
|
|
|
+ ? formData.value.avatar
|
|
|
+ : formData.value.avatar?.path || ''
|
|
|
+ }
|
|
|
+
|
|
|
+ if (isEdit.value) {
|
|
|
+ await updateExpert(payload)
|
|
|
+ ElMessage.success('修改成功')
|
|
|
+ if (payload.id) {
|
|
|
+ const detail = await getExpertDetail(payload.id)
|
|
|
+ currentExpertDetail.value = detail
|
|
|
+ activeExpert.value = buildExpertProfile(detail)
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ await createExpert(payload)
|
|
|
+ ElMessage.success('新增成功')
|
|
|
+ }
|
|
|
+
|
|
|
+ closeDialog()
|
|
|
+ await getList()
|
|
|
+ } catch (error) {
|
|
|
+ console.error(error)
|
|
|
+ } finally {
|
|
|
+ submitLoading.value = false
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
const getList = async () => {
|
|
|
loading.value = true
|
|
|
try {
|