update:用户端查看证书
This commit is contained in:
parent
104ac4a931
commit
52bc6297d4
@ -222,7 +222,20 @@
|
|||||||
<!-- 按项目分组展示 -->
|
<!-- 按项目分组展示 -->
|
||||||
<div class="project-section" v-for="(projectData, projectIndex) in certificateDisplayList" :key="projectIndex">
|
<div class="project-section" v-for="(projectData, projectIndex) in certificateDisplayList" :key="projectIndex">
|
||||||
<div class="project-title">
|
<div class="project-title">
|
||||||
{{ projectData.projectName }} - {{ projectData.groupName }}
|
{{ projectData.projectName }} - {{ projectData.groupName }} - {{ projectData.projectTypeName }}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- 个人项目运动员证书 -->
|
||||||
|
<div v-if="projectData.athleteCertificateGroups.length > 0" class="certificate-type-section">
|
||||||
|
<div class="section-title">运动员证书</div>
|
||||||
|
<div
|
||||||
|
v-for="group in projectData.athleteCertificateGroups"
|
||||||
|
:key="`${projectData.registrationItemId}_${group.participantName}`"
|
||||||
|
class="certificate-member-row"
|
||||||
|
>
|
||||||
|
<div class="names-list">{{ group.participantName }}</div>
|
||||||
|
<el-button size="small" text type="primary" @click="openCertificates(group.certificates)">查看证书</el-button>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- 项目证书 -->
|
<!-- 项目证书 -->
|
||||||
@ -233,7 +246,7 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- 运动员证书 -->
|
<!-- 运动员证书 -->
|
||||||
<div v-if="projectData.athleteCertificates.length > 0" class="certificate-type-section">
|
<div v-if="projectData.athleteCertificateGroups.length === 0 && projectData.athleteCertificates.length > 0" class="certificate-type-section">
|
||||||
<div class="section-title">运动员证书</div>
|
<div class="section-title">运动员证书</div>
|
||||||
<div class="names-list">{{ projectData.athleteCertificates.map(c => c.participantName).join('、') }}</div>
|
<div class="names-list">{{ projectData.athleteCertificates.map(c => c.participantName).join('、') }}</div>
|
||||||
<el-button size="small" text type="primary" @click="openCertificates(projectData.athleteCertificates)">查看证书</el-button>
|
<el-button size="small" text type="primary" @click="openCertificates(projectData.athleteCertificates)">查看证书</el-button>
|
||||||
@ -1325,6 +1338,57 @@ const isShowCertDialog = ref(false);
|
|||||||
const certLoading = ref(false);
|
const certLoading = ref(false);
|
||||||
const certificateDisplayList = ref([]);
|
const certificateDisplayList = ref([]);
|
||||||
|
|
||||||
|
const splitCertificateProjectTypes = ['个人速度', '个人花样'];
|
||||||
|
|
||||||
|
const normalizeCertificateItemId = (value) => {
|
||||||
|
const normalized = Number(value);
|
||||||
|
return Number.isFinite(normalized) ? normalized : value;
|
||||||
|
};
|
||||||
|
|
||||||
|
const shouldSplitAthleteCertificates = (projectTypeName) => splitCertificateProjectTypes.includes(projectTypeName);
|
||||||
|
|
||||||
|
const splitParticipantNames = (participantName) => {
|
||||||
|
if (!participantName) return [];
|
||||||
|
return String(participantName)
|
||||||
|
.split(/[、,,]/)
|
||||||
|
.map((name) => name.trim())
|
||||||
|
.filter(Boolean);
|
||||||
|
};
|
||||||
|
|
||||||
|
const buildAthleteCertificateGroups = (item, certificates) => {
|
||||||
|
if (!shouldSplitAthleteCertificates(item.projectTypeName)) return [];
|
||||||
|
|
||||||
|
const groups = [];
|
||||||
|
const matchedCertificateIds = new Set();
|
||||||
|
const members = Array.isArray(item.members) ? item.members : [];
|
||||||
|
|
||||||
|
for (const member of members) {
|
||||||
|
const memberCertificates = certificates.filter((cert) => {
|
||||||
|
const participantNames = splitParticipantNames(cert.participantName);
|
||||||
|
return participantNames.includes(member.name);
|
||||||
|
});
|
||||||
|
|
||||||
|
memberCertificates.forEach((cert) => matchedCertificateIds.add(cert.certificateId));
|
||||||
|
|
||||||
|
if (memberCertificates.length > 0) {
|
||||||
|
groups.push({
|
||||||
|
participantName: member.name,
|
||||||
|
certificates: memberCertificates,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const unmatchedCertificates = certificates.filter((cert) => !matchedCertificateIds.has(cert.certificateId));
|
||||||
|
for (const cert of unmatchedCertificates) {
|
||||||
|
groups.push({
|
||||||
|
participantName: cert.participantName || '未匹配运动员',
|
||||||
|
certificates: [cert],
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
return groups;
|
||||||
|
};
|
||||||
|
|
||||||
const openCertificateDialog = async () => {
|
const openCertificateDialog = async () => {
|
||||||
if (!currentRow.value?.registrationId) return;
|
if (!currentRow.value?.registrationId) return;
|
||||||
isShowCertDialog.value = true;
|
isShowCertDialog.value = true;
|
||||||
@ -1365,18 +1429,21 @@ const openCertificateDialog = async () => {
|
|||||||
// 为每个项目组织证书
|
// 为每个项目组织证书
|
||||||
const result = [];
|
const result = [];
|
||||||
for (const item of items) {
|
for (const item of items) {
|
||||||
|
const registrationItemId = normalizeCertificateItemId(item.registrationItemId);
|
||||||
const projectData = {
|
const projectData = {
|
||||||
registrationItemId: item.registrationItemId,
|
registrationItemId,
|
||||||
projectName: item.projectName,
|
projectName: item.projectName,
|
||||||
groupName: item.groupName,
|
groupName: item.groupName,
|
||||||
|
projectTypeName: item.projectTypeName,
|
||||||
projectCertificates: [],
|
projectCertificates: [],
|
||||||
athleteCertificates: [],
|
athleteCertificates: [],
|
||||||
|
athleteCertificateGroups: [],
|
||||||
coachCertificates: [],
|
coachCertificates: [],
|
||||||
leaderCertificates: []
|
leaderCertificates: []
|
||||||
};
|
};
|
||||||
|
|
||||||
// 筛选该项目的证书
|
// 筛选该项目的证书
|
||||||
const projectCerts = certificates.filter(c => c.registrationItemId === item.registrationItemId);
|
const projectCerts = certificates.filter((c) => normalizeCertificateItemId(c.registrationItemId) === registrationItemId);
|
||||||
|
|
||||||
// 根据角色分类
|
// 根据角色分类
|
||||||
for (const cert of projectCerts) {
|
for (const cert of projectCerts) {
|
||||||
@ -1389,9 +1456,15 @@ const openCertificateDialog = async () => {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
projectData.athleteCertificateGroups = buildAthleteCertificateGroups(item, projectData.athleteCertificates);
|
||||||
|
if (projectData.athleteCertificateGroups.length > 0) {
|
||||||
|
projectData.athleteCertificates = [];
|
||||||
|
}
|
||||||
|
|
||||||
// 只有该项目有证书时才添加到列表
|
// 只有该项目有证书时才添加到列表
|
||||||
if (projectData.projectCertificates.length > 0 ||
|
if (projectData.projectCertificates.length > 0 ||
|
||||||
projectData.athleteCertificates.length > 0 ||
|
projectData.athleteCertificates.length > 0 ||
|
||||||
|
projectData.athleteCertificateGroups.length > 0 ||
|
||||||
projectData.coachCertificates.length > 0 ||
|
projectData.coachCertificates.length > 0 ||
|
||||||
projectData.leaderCertificates.length > 0) {
|
projectData.leaderCertificates.length > 0) {
|
||||||
result.push(projectData);
|
result.push(projectData);
|
||||||
@ -1405,8 +1478,10 @@ const openCertificateDialog = async () => {
|
|||||||
registrationItemId: 0,
|
registrationItemId: 0,
|
||||||
projectName: '其他证书',
|
projectName: '其他证书',
|
||||||
groupName: '',
|
groupName: '',
|
||||||
|
projectTypeName: '',
|
||||||
projectCertificates: [],
|
projectCertificates: [],
|
||||||
athleteCertificates: [],
|
athleteCertificates: [],
|
||||||
|
athleteCertificateGroups: [],
|
||||||
coachCertificates: [],
|
coachCertificates: [],
|
||||||
leaderCertificates: []
|
leaderCertificates: []
|
||||||
};
|
};
|
||||||
@ -2366,6 +2441,24 @@ const submitChangeMembers = async () => {
|
|||||||
margin-bottom: 12px;
|
margin-bottom: 12px;
|
||||||
line-height: 1.6;
|
line-height: 1.6;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.certificate-member-row {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: space-between;
|
||||||
|
gap: 12px;
|
||||||
|
padding: 10px 0;
|
||||||
|
border-bottom: 1px solid #e4e7ed;
|
||||||
|
|
||||||
|
&:last-child {
|
||||||
|
padding-bottom: 0;
|
||||||
|
border-bottom: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.names-list {
|
||||||
|
margin-bottom: 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user