feat: 添加导出所有学生配置功能,优化提示信息
This commit is contained in:
@@ -1,5 +1,12 @@
|
||||
<script setup lang="ts">
|
||||
import { reactive, ref, onMounted, toRaw, watch, defineAsyncComponent } from 'vue';
|
||||
import {
|
||||
reactive,
|
||||
ref,
|
||||
onMounted,
|
||||
toRaw,
|
||||
watch,
|
||||
defineAsyncComponent,
|
||||
} from 'vue';
|
||||
import { PageContainer } from 'antdv-pro-layout';
|
||||
import { ProModal } from 'antdv-pro-modal';
|
||||
import { message, Modal } from 'ant-design-vue/es';
|
||||
@@ -18,8 +25,10 @@ import {
|
||||
getPtNeConfigData,
|
||||
ptContrastAsDefault,
|
||||
ptExport,
|
||||
ptExportAll,
|
||||
} from '@/api/pt/neConfig';
|
||||
import { isSystemAdmin, hasRoles } from '@/plugins/auth-user';const neInfoStore = useNeInfoStore();
|
||||
import { isSystemAdmin, hasRoles } from '@/plugins/auth-user';
|
||||
const neInfoStore = useNeInfoStore();
|
||||
import saveAs from 'file-saver';
|
||||
const { t } = useI18n();
|
||||
const { ruleVerification, smfByUPFIdLoadData, smfByUPFIdOptions } = useOptions({
|
||||
@@ -232,35 +241,42 @@ function fnGetNeConfig() {
|
||||
|
||||
treeState.loading = true;
|
||||
// 获取数据
|
||||
getAllNeConfig(neType).then(res => {
|
||||
if (res.code === RESULT_CODE_SUCCESS && Array.isArray(res.data)) {
|
||||
const arr = [];
|
||||
for (const item of res.data) {
|
||||
let paramPerms: string[] = [];
|
||||
if (item.paramPerms) {
|
||||
paramPerms = item.paramPerms.split(',');
|
||||
} else {
|
||||
paramPerms = ['post', 'put', 'delete'];
|
||||
getAllNeConfig(neType)
|
||||
.then(res => {
|
||||
if (res.code === RESULT_CODE_SUCCESS && Array.isArray(res.data)) {
|
||||
const arr = [];
|
||||
for (const item of res.data) {
|
||||
let paramPerms: string[] = [];
|
||||
if (item.paramPerms) {
|
||||
paramPerms = item.paramPerms.split(',');
|
||||
} else {
|
||||
paramPerms = ['post', 'put', 'delete'];
|
||||
}
|
||||
arr.push({
|
||||
...item,
|
||||
children: undefined,
|
||||
title: item.paramDisplay,
|
||||
key: item.paramName,
|
||||
paramPerms,
|
||||
});
|
||||
}
|
||||
treeState.data = arr;
|
||||
treeState.loading = false;
|
||||
// 取首个tag
|
||||
if (res.data.length > 0) {
|
||||
const item = JSON.parse(JSON.stringify(treeState.data[0]));
|
||||
treeState.selectNode = item;
|
||||
treeState.selectLoading = false;
|
||||
fnActiveConfigNode(item.key);
|
||||
}
|
||||
arr.push({
|
||||
...item,
|
||||
children: undefined,
|
||||
title: item.paramDisplay,
|
||||
key: item.paramName,
|
||||
paramPerms,
|
||||
});
|
||||
}
|
||||
treeState.data = arr;
|
||||
treeState.loading = false;
|
||||
// 取首个tag
|
||||
if (res.data.length > 0) {
|
||||
const item = JSON.parse(JSON.stringify(treeState.data[0]));
|
||||
treeState.selectNode = item;
|
||||
treeState.selectLoading = false;
|
||||
fnActiveConfigNode(item.key);
|
||||
})
|
||||
.finally(() => {
|
||||
// 仅教师加载
|
||||
if (hasRoles(['teacher'])) {
|
||||
classStudents(neType);
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
/**对话框对象信息状态类型 */
|
||||
@@ -344,6 +360,7 @@ const {
|
||||
studentStatus,
|
||||
studentSearch,
|
||||
studentChange,
|
||||
classStudents,
|
||||
} = usePtOptions({ t, fnActiveConfigNode });
|
||||
|
||||
const { tablePagination, listState, listEdit, listEditClose, listEditOk } =
|
||||
@@ -450,6 +467,35 @@ function fnDataExport() {
|
||||
});
|
||||
}
|
||||
|
||||
// 数据导出Excel
|
||||
function fnDataExportAll() {
|
||||
Modal.confirm({
|
||||
title: t('common.tipTitle'),
|
||||
content: t('views.configManage.configParamForm.ptExportTip'),
|
||||
onOk() {
|
||||
const hide = message.loading(t('common.loading'), 0);
|
||||
ptExportAll()
|
||||
.then(res => {
|
||||
if (res.code === RESULT_CODE_SUCCESS) {
|
||||
message.success({
|
||||
content: t('common.operateOk'),
|
||||
duration: 2,
|
||||
});
|
||||
saveAs(res.data, `students_config_data_${Date.now()}.zip`);
|
||||
} else {
|
||||
message.error({
|
||||
content: `${res.msg}`,
|
||||
duration: 2,
|
||||
});
|
||||
}
|
||||
})
|
||||
.finally(() => {
|
||||
hide();
|
||||
});
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
// 获取网元网元列表
|
||||
neInfoStore.fnNelist().then(res => {
|
||||
@@ -500,7 +546,7 @@ onMounted(() => {
|
||||
<a-col :lg="8" :md="12" :xs="24" v-roles:has="['teacher']">
|
||||
<a-form-item
|
||||
:label="t('views.configManage.configParamForm.ptApplyShow')"
|
||||
name="neType "
|
||||
name="student "
|
||||
>
|
||||
<a-select
|
||||
v-model:value="classState.student"
|
||||
@@ -512,7 +558,7 @@ onMounted(() => {
|
||||
:filter-option="false"
|
||||
:not-found-content="null"
|
||||
:options="classState.studentOptions"
|
||||
@search="studentSearch"
|
||||
@search="(v:any)=> studentSearch(treeState.neType, v)"
|
||||
@change="studentChange"
|
||||
>
|
||||
<template #option="{ value, label, applyStatus }">
|
||||
@@ -586,6 +632,9 @@ onMounted(() => {
|
||||
<a-button @click="fnDataExport()" v-roles:has="['teacher']">
|
||||
{{ t('views.configManage.configParamForm.ptExport') }}
|
||||
</a-button>
|
||||
<a-button @click="fnDataExportAll()" v-roles:has="['teacher']">
|
||||
{{ t('views.configManage.configParamForm.ptExportAll') }}
|
||||
</a-button>
|
||||
|
||||
<!-- 学生 -->
|
||||
<a-button
|
||||
|
||||
Reference in New Issue
Block a user