feat: 配置数据导出成表格,多语言翻译

This commit is contained in:
TsMask
2024-08-01 16:07:17 +08:00
parent ada1f388fc
commit 630c63e23f
5 changed files with 133 additions and 21 deletions

View File

@@ -39,6 +39,21 @@ export function ptContrastAsDefault(params: Record<string, any>) {
});
}
/**
* 配置数据导出Excel
* @param student 仅教师 student
* @returns object
*/
export function ptExport(student: string|undefined) {
return request({
url: `/pt/neConfigData/export`,
method: 'get',
params: { student },
responseType: 'blob',
timeout: 180_000,
});
}
/**
* 网元参数配置信息
* @param params 数据 {neType,paramName}

View File

@@ -502,6 +502,23 @@ export default {
updateItemTip: "Confirm updating the data item with Index [{num}]?",
delItemTip: "Confirm deleting the data item with Index [{num}]?",
arrayMore: "Expand",
ptDiff: 'Comparison Example',
ptDiffExample: 'Example Configuration',
ptDiffSelf: 'Current Individuals',
ptDiffLoad: 'Load More',
ptDiffMerge: 'Comparative Differences',
ptDiffRest: 'Restore this version',
ptHistory: 'History',
ptReset: 'Reset To Example',
ptLoad: 'Load Current Configuration',
ptExport: "Export Excel",
ptExportTip: "Exporting NE Configuration Data to an Excel file",
ptApplyShow: 'View Student',
ptApply: 'request',
ptApplyNE: 'Application To NE',
ptApplyStu: 'Application To {ne}',
ptApplyStuRack: 'Return Request',
ptApplyStuNE: 'Application Request',
},
},
dashboard: {

View File

@@ -502,6 +502,23 @@ export default {
updateItemTip: "确认更新Index为 【{num}】 的数据项?",
delItemTip: "确认删除Index为 【{num}】 的数据项?",
arrayMore: "展开",
ptDiff: '对比示例',
ptDiffExample: '示例配置',
ptDiffSelf: '当前个人',
ptDiffLoad: '加载更多',
ptDiffMerge: '差异对比',
ptDiffRest: '还原此版本',
ptHistory: '历史记录',
ptReset: '重置为示例',
ptLoad: '载入当前网元配置',
ptExport: "导出Excel",
ptExportTip: "导出网元配置数据到Excel文件中",
ptApplyShow: '查看学生',
ptApply: '申请',
ptApplyNE: '应用配置到网元',
ptApplyStu: '申请配置应用到 {ne}',
ptApplyStuRack: '退回该学生配置',
ptApplyStuNE: '应用该学生配置',
},
},
dashboard: {

View File

@@ -231,7 +231,7 @@ onMounted(() => {
}"
>
<a-button @click="fnGetList()" :loading="state.loading">
加载更多
{{ t('views.configManage.configParamForm.ptDiffLoad') }}
</a-button>
</div>
</template>
@@ -239,7 +239,9 @@ onMounted(() => {
<a-list-item>
<template #actions>
<a-tooltip>
<template #title>差异对比</template>
<template #title>
{{ t('views.configManage.configParamForm.ptDiffMerge') }}
</template>
<a-button type="primary" @click.prevent="fnMergeCellOpen(item)">
<template #icon><MergeCellsOutlined /></template>
</a-button>
@@ -286,7 +288,7 @@ onMounted(() => {
@click.prevent="fnMergeCellRestore('old')"
>
<template #icon><MergeCellsOutlined /></template>
还原此版本
{{ t('views.configManage.configParamForm.ptDiffRest') }}
</a-button>
</div>
<div>
@@ -296,7 +298,7 @@ onMounted(() => {
@click.prevent="fnMergeCellRestore('new')"
>
<template #icon><MergeCellsOutlined /></template>
还原此版本
{{ t('views.configManage.configParamForm.ptDiffRest') }}
</a-button>
</div>
</div>

View File

@@ -8,7 +8,7 @@ import {
defineAsyncComponent,
} from 'vue';
import { PageContainer } from 'antdv-pro-layout';
import { message } from 'ant-design-vue/lib';
import { message, Modal } from 'ant-design-vue/lib';
import { DataNode } from 'ant-design-vue/lib/tree';
import useI18n from '@/hooks/useI18n';
import TableColumnsDnd from '@/components/TableColumnsDnd/index.vue';
@@ -20,8 +20,13 @@ import useConfigList from './hooks/useConfigList';
import useConfigArray from './hooks/useConfigArray';
import useConfigArrayChild from './hooks/useConfigArrayChild';
import { getAllNeConfig } from '@/api/ne/neConfig';
import { getPtNeConfigData, ptContrastAsDefault } from '@/api/pt/neConfig';
import {
getPtNeConfigData,
ptContrastAsDefault,
ptExport,
} from '@/api/pt/neConfig';
import { isSystemAdmin, hasRoles } from '@/plugins/auth-user';
import saveAs from 'file-saver';
const neInfoStore = useNeInfoStore();
const { t } = useI18n();
const { ruleVerification, getConfigSMFByUPFIds, SMFByUPFIdOptions } =
@@ -401,7 +406,7 @@ function openOpeateDrawer() {
// 数据与示例比较
const dataDiffState = reactive({
visible: false,
title: '对比示例',
title: t('views.configManage.configParamForm.ptDiff'),
exampleData: '',
data: '',
});
@@ -421,6 +426,35 @@ function fnDataDiff() {
});
}
// 数据导出Excel
function fnDataExport() {
Modal.confirm({
title: t('common.tipTitle'),
content: t('views.configManage.configParamForm.ptExportTip'),
onOk() {
const hide = message.loading(t('common.loading'), 0);
ptExport(classState.student)
.then(res => {
if (res.code === RESULT_CODE_SUCCESS) {
message.success({
content: t('common.operateOk'),
duration: 2,
});
saveAs(res.data, `config_data_${Date.now()}.xlsx`);
} else {
message.error({
content: `${res.msg}`,
duration: 2,
});
}
})
.finally(() => {
hide();
});
},
});
}
onMounted(() => {
// 获取网元网元列表
neInfoStore.fnNelist().then(res => {
@@ -469,7 +503,10 @@ onMounted(() => {
>
<a-row :gutter="16">
<a-col :lg="8" :md="12" :xs="24" v-roles:has="['teacher']">
<a-form-item label="(教师)查看学生" name="neType ">
<a-form-item
:label="t('views.configManage.configParamForm.ptApplyShow')"
name="neType "
>
<a-select
v-model:value="classState.student"
show-search
@@ -488,9 +525,12 @@ onMounted(() => {
<a-tag
v-if="applyStatus === '0'"
color="processing"
style="position: absolute; right: 0;}"
style="position: absolute; right: 0"
>
{{ applyStatus && '申请' }}
{{
applyStatus &&
t('views.configManage.configParamForm.ptApply')
}}
</a-tag>
</template>
</a-select>
@@ -499,6 +539,7 @@ onMounted(() => {
<a-col :lg="6" :md="12" :xs="24">
<a-form-item>
<a-space :size="8">
<!-- 教师查看学生 -->
<template
v-if="
hasRoles(['teacher']) &&
@@ -512,7 +553,7 @@ onMounted(() => {
"
:loading="ptConfigState.applyLoading"
>
应用该学生配置
{{ t('views.configManage.configParamForm.ptApplyStuNE') }}
</a-button>
<a-button
@click="
@@ -520,7 +561,7 @@ onMounted(() => {
"
:loading="ptConfigState.applyLoading"
>
退回该学生配置
{{ t('views.configManage.configParamForm.ptApplyStuRack') }}
</a-button>
</template>
@@ -530,14 +571,14 @@ onMounted(() => {
@click="ptConfigApply(treeState.neType, '2')"
:loading="ptConfigState.applyLoading"
>
应用配置到网元
{{ t('views.configManage.configParamForm.ptApplyNE') }}
</a-button>
<a-button
@click="ptConfigSave(treeState.neType)"
:loading="ptConfigState.saveLoading"
v-roles:has="['admin']"
>
载入当前网元配置
{{ t('views.configManage.configParamForm.ptLoad') }}
</a-button>
<a-button
@click="ptConfigReset(treeState.neType)"
@@ -545,21 +586,33 @@ onMounted(() => {
:loading="ptConfigState.restLoading"
v-roles:has="['teacher']"
>
重置为示例
{{ t('views.configManage.configParamForm.ptReset') }}
</a-button>
<a-button @click="fnDataExport()" v-roles:has="['teacher']">
{{ t('views.configManage.configParamForm.ptExport') }}
</a-button>
<!-- 学生 -->
<a-button
@click="ptConfigReset(treeState.neType)"
:loading="ptConfigState.restLoading"
v-roles:has="['student']"
>
重置为示例
{{ t('views.configManage.configParamForm.ptReset') }}
</a-button>
<a-button
@click="ptConfigApply(treeState.neType, '0')"
:loading="ptConfigState.applyLoading"
v-roles:has="['student']"
>
申请配置应用到 {{ treeState.neType }}
{{
t('views.configManage.configParamForm.ptApplyStu', {
ne: treeState.neType,
})
}}
</a-button>
<a-button @click="fnDataExport()" v-roles:has="['student']">
{{ t('views.configManage.configParamForm.ptExport') }}
</a-button>
</a-space>
</a-form-item>
@@ -634,7 +687,9 @@ onMounted(() => {
<a-space :size="8" align="center" v-show="!treeState.selectLoading">
<span v-roles:has="['teacher', 'student']">
<a-tooltip>
<template #title>与示例比较</template>
<template #title>
{{ t('views.configManage.configParamForm.ptDiff') }}
</template>
<a-button
type="default"
size="small"
@@ -647,7 +702,9 @@ onMounted(() => {
</a-tooltip>
</span>
<a-tooltip>
<template #title>历史记录</template>
<template #title>
{{ t('views.configManage.configParamForm.ptHistory') }}
</template>
<a-button
type="default"
size="small"
@@ -1133,8 +1190,12 @@ onMounted(() => {
justify-content: space-between;
"
>
<div style="flex: 1; text-align: center">示例配置</div>
<div style="flex: 1; text-align: center">当前个人</div>
<div style="flex: 1; text-align: center">
{{ t('views.configManage.configParamForm.ptDiffExample') }}
</div>
<div style="flex: 1; text-align: center">
{{ t('views.configManage.configParamForm.ptDiffSelf') }}
</div>
</div>
<CodemirrorEditeDiff
:old-area="dataDiffState.exampleData"