fix(frontend): export promotion evidence csv
This commit is contained in:
@@ -17,6 +17,7 @@
|
||||
:value="person.extPartyId"
|
||||
/>
|
||||
</el-select>
|
||||
<el-button :icon="Download" :disabled="!evidence || !extPartyId.trim()" @click="exportEvidenceCsv">导出证据包</el-button>
|
||||
<el-button type="danger" :icon="Refresh" :loading="loading" @click="loadAll">刷新</el-button>
|
||||
</div>
|
||||
</section>
|
||||
@@ -131,8 +132,9 @@
|
||||
</template>
|
||||
|
||||
<script setup name="CompetencyGrowth" lang="ts">
|
||||
import { Refresh } from '@element-plus/icons-vue';
|
||||
import { Download, Refresh } from '@element-plus/icons-vue';
|
||||
import { ElMessage } from 'element-plus';
|
||||
import FileSaver from 'file-saver';
|
||||
import { computed, onMounted, ref, watch } from 'vue';
|
||||
import { listPracticeScenarios } from '@/api/aihr/practice';
|
||||
import {
|
||||
@@ -228,6 +230,38 @@ const createManualAssignment = async () => {
|
||||
}
|
||||
};
|
||||
|
||||
const csvCell = (value: unknown) => `"${String(value ?? '').replaceAll('"', '""')}"`;
|
||||
|
||||
const appendCsvRow = (rows: string[], ...values: unknown[]) => {
|
||||
rows.push(values.map(csvCell).join(','));
|
||||
};
|
||||
|
||||
const exportEvidenceCsv = () => {
|
||||
const party = extPartyId.value.trim();
|
||||
if (!evidence.value || !party) {
|
||||
ElMessage.warning('请先选择或输入员工');
|
||||
return;
|
||||
}
|
||||
const rows: string[] = [];
|
||||
const personName = selectedPerson.value?.personName || party;
|
||||
appendCsvRow(rows, 'section', 'field', 'value');
|
||||
appendCsvRow(rows, 'summary', 'employee', personName);
|
||||
appendCsvRow(rows, 'summary', 'ext_party_id', party);
|
||||
appendCsvRow(rows, 'summary', 'current_level', evidence.value.currentLevel);
|
||||
appendCsvRow(rows, 'summary', 'assessment_score', evidence.value.assessmentScore);
|
||||
appendCsvRow(rows, 'summary', 'training_minutes', evidence.value.trainingMinutes);
|
||||
appendCsvRow(rows, 'summary', 'contribution', evidence.value.contribution);
|
||||
appendCsvRow(rows, 'summary', 'completed', evidence.value.completed);
|
||||
appendCsvRow(rows, 'summary', 'pending_review', evidence.value.pendingReview);
|
||||
profile.value?.growthPath.forEach((stage) => appendCsvRow(rows, 'growth_path', `${stage.level} ${stage.status}`, `${stage.progress}% ${stage.evidence}`));
|
||||
evidence.value.dimensions.forEach((item) => appendCsvRow(rows, 'dimension', item.label, `${item.value} ${item.note}`));
|
||||
evidence.value.evidenceItems.forEach((item, index) => appendCsvRow(rows, 'evidence_item', index + 1, item));
|
||||
evidence.value.latestRecords.forEach((item) => appendCsvRow(rows, 'latest_record', item.scene, `${item.score} ${item.status} ${item.time} ${item.summary}`));
|
||||
evidence.value.assignments.forEach((item) => appendCsvRow(rows, 'assignment', item.scenarioName, `${item.status} ${item.createTime} ${item.reason}`));
|
||||
FileSaver.saveAs(new Blob([`\uFEFF${rows.join('\n')}`], { type: 'text/csv;charset=utf-8' }), `aihr-promotion-evidence-${party}.csv`);
|
||||
ElMessage.success('成长证据包 CSV 已导出');
|
||||
};
|
||||
|
||||
watch(selectedProjectCode, async () => {
|
||||
extPartyId.value = '';
|
||||
await loadOrgSnapshot();
|
||||
@@ -279,7 +313,7 @@ onMounted(() => {
|
||||
|
||||
.head-actions {
|
||||
display: grid;
|
||||
grid-template-columns: 220px 280px auto;
|
||||
grid-template-columns: 220px 280px auto auto;
|
||||
gap: 10px;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user