feat: 教师选择学生进行切换查看学生配置数据信息
This commit is contained in:
14
src/api/pt/neClass.ts
Normal file
14
src/api/pt/neClass.ts
Normal file
@@ -0,0 +1,14 @@
|
||||
import { request } from '@/plugins/http-fetch';
|
||||
|
||||
/**
|
||||
* 班级学生列表 (仅教师操作)
|
||||
* @param params 数据 {neType,paramName}
|
||||
* @returns object
|
||||
*/
|
||||
export function getPtClassStudents(params: Record<string, any>) {
|
||||
return request({
|
||||
url: `/pt/class/students`,
|
||||
params,
|
||||
method: 'get',
|
||||
});
|
||||
}
|
||||
@@ -2,6 +2,7 @@ import { getPtClassStudents } from '@/api/pt/neClass';
|
||||
import { ptSaveAsDefault, ptResetAsDefault } from '@/api/pt/neConfig';
|
||||
import { stuPtNeConfigApply } from '@/api/pt/neConfigApply';
|
||||
import { RESULT_CODE_SUCCESS } from '@/constants/result-constants';
|
||||
import { hasRoles } from '@/plugins/auth-user';
|
||||
import { message } from 'ant-design-vue/lib';
|
||||
import { onMounted, reactive } from 'vue';
|
||||
|
||||
@@ -10,7 +11,7 @@ import { onMounted, reactive } from 'vue';
|
||||
* @param param 父级传入 {t}
|
||||
* @returns
|
||||
*/
|
||||
export default function usePtOptions({t}:any) {
|
||||
export default function usePtOptions({ t }: any) {
|
||||
/**保存网元下所有配置为示例配置 */
|
||||
function ptConfigSave(neType: string) {
|
||||
ptSaveAsDefault(neType, '001').then(res => {
|
||||
@@ -124,21 +125,18 @@ export default function usePtOptions({t}:any) {
|
||||
timeout = setTimeout(fake, 500);
|
||||
}
|
||||
|
||||
/**学生选择改变 */
|
||||
function studentChange(e: any) {
|
||||
console.log(e);
|
||||
// 仅教师加载
|
||||
if (hasRoles(['teacher'])) {
|
||||
onMounted(() => {
|
||||
initStudentList();
|
||||
});
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
initStudentList();
|
||||
});
|
||||
|
||||
return {
|
||||
ptConfigSave,
|
||||
ptConfigReset,
|
||||
ptConfigApply,
|
||||
classState,
|
||||
studentChange,
|
||||
studentSearch,
|
||||
};
|
||||
}
|
||||
|
||||
@@ -14,13 +14,12 @@ import useConfigArrayChild from './hooks/useConfigArrayChild';
|
||||
import { DataNode } from 'ant-design-vue/lib/tree';
|
||||
import { getAllNeConfig } from '@/api/ne/neConfig';
|
||||
import { getPtNeConfigData } from '@/api/pt/neConfig';
|
||||
import { hasRoles } from '@/plugins/auth-user';
|
||||
const neInfoStore = useNeInfoStore();
|
||||
const { t } = useI18n();
|
||||
const { ruleVerification, getConfigSMFByUPFIds, SMFByUPFIdOptions } =
|
||||
useOptions({ t });
|
||||
|
||||
|
||||
|
||||
/**网元参数 */
|
||||
let neSelectOptions = ref<Record<string, any>[]>([]);
|
||||
|
||||
@@ -103,12 +102,20 @@ function fnActiveConfigNode(key: string | number) {
|
||||
treeState.selectNode = JSON.parse(JSON.stringify(param));
|
||||
|
||||
// 获取网元端的配置数据
|
||||
getPtNeConfigData({
|
||||
const query: {
|
||||
neType: string;
|
||||
paramName: string | number;
|
||||
student: string | undefined;
|
||||
} = {
|
||||
neType: treeState.neType,
|
||||
paramName: treeState.selectNode.paramName,
|
||||
}).then(res => {
|
||||
paramName: key,
|
||||
student: undefined,
|
||||
};
|
||||
if (hasRoles(['teacher'])) {
|
||||
query.student = classState.student;
|
||||
}
|
||||
getPtNeConfigData(query).then(res => {
|
||||
if (res.code === RESULT_CODE_SUCCESS && Array.isArray(res.data)) {
|
||||
treeState.selectLoading = false;
|
||||
const ruleArr = param.paramData;
|
||||
const dataArr = res.data;
|
||||
if (param.paramType === 'list') {
|
||||
@@ -191,6 +198,9 @@ function fnActiveConfigNode(key: string | number) {
|
||||
|
||||
arrayEditClose();
|
||||
}
|
||||
setTimeout(() => {
|
||||
treeState.selectLoading = false;
|
||||
}, 300);
|
||||
} else {
|
||||
message.warning({
|
||||
content: `${param.paramDisplay} ${t(
|
||||
@@ -323,9 +333,8 @@ const {
|
||||
ptConfigReset,
|
||||
ptConfigApply,
|
||||
classState,
|
||||
studentChange,
|
||||
studentSearch,
|
||||
} = usePtOptions({ t,treeState });
|
||||
} = usePtOptions({ t, treeState });
|
||||
|
||||
const { tablePagination, listState, listEdit, listEditClose, listEditOk } =
|
||||
useConfigList({ t, treeState, ruleVerification });
|
||||
@@ -414,7 +423,7 @@ onMounted(() => {
|
||||
:body-style="{ marginBottom: '24px', paddingBottom: 0 }"
|
||||
>
|
||||
<a-row :gutter="16">
|
||||
<a-col :lg="6" :md="12" :xs="24">
|
||||
<a-col :lg="8" :md="12" :xs="24" v-roles:has="['teacher']">
|
||||
<a-form-item label="(教师)查看学生" name="neType ">
|
||||
<a-select
|
||||
v-model:value="classState.student"
|
||||
@@ -427,21 +436,42 @@ onMounted(() => {
|
||||
:not-found-content="null"
|
||||
:options="classState.studentOptions"
|
||||
@search="studentSearch"
|
||||
@change="studentChange"
|
||||
@change="fnActiveConfigNode('#')"
|
||||
></a-select>
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
<a-col :lg="6" :md="12" :xs="24">
|
||||
<a-form-item>
|
||||
<a-space :size="8">
|
||||
<a-button @click="ptConfigSave(treeState.neType)">
|
||||
(管理员)载入网元配置为示例配置
|
||||
<a-button
|
||||
v-roles:has="['admin', 'teacher']"
|
||||
:disabled="!!classState.student"
|
||||
>
|
||||
(管理员/教师) 应用到网元
|
||||
</a-button>
|
||||
<a-button @click="ptConfigReset(treeState.neType)">
|
||||
(学生)重置为班级示例/(教师)重置为系统示例
|
||||
<a-button
|
||||
@click="ptConfigSave(treeState.neType)"
|
||||
v-roles:has="['admin']"
|
||||
>
|
||||
(管理员)载入网元配置为系统示例
|
||||
</a-button>
|
||||
<a-button @click="ptConfigApply(treeState.neType, '0')">
|
||||
(学生)申请应用当前网元配置
|
||||
<a-button
|
||||
@click="ptConfigReset(treeState.neType)"
|
||||
v-roles:has="['teacher']"
|
||||
>
|
||||
(教师)重置为系统示例
|
||||
</a-button>
|
||||
<a-button
|
||||
@click="ptConfigReset(treeState.neType)"
|
||||
v-roles:has="['student']"
|
||||
>
|
||||
(学生)重置为教师示例
|
||||
</a-button>
|
||||
<a-button
|
||||
@click="ptConfigApply(treeState.neType, '0')"
|
||||
v-roles:has="['student']"
|
||||
>
|
||||
(学生)申请应用到 {{ treeState.neType }}
|
||||
</a-button>
|
||||
</a-space>
|
||||
</a-form-item>
|
||||
@@ -458,12 +488,13 @@ onMounted(() => {
|
||||
v-show="collapsible"
|
||||
>
|
||||
<!-- 网元类型 -->
|
||||
<a-card
|
||||
size="small"
|
||||
:bordered="false"
|
||||
:title="t('views.configManage.configParamForm.treeTitle')"
|
||||
:loading="treeState.loading"
|
||||
>
|
||||
<a-card size="small" :bordered="false" :loading="treeState.loading">
|
||||
<template #title>
|
||||
{{ t('views.configManage.configParamForm.treeTitle') }}
|
||||
<span v-roles:has="['teacher']" class="student-name">
|
||||
{{ classState.student }}
|
||||
</span>
|
||||
</template>
|
||||
<a-form layout="vertical" autocomplete="off">
|
||||
<a-form-item name="neId ">
|
||||
<a-select
|
||||
@@ -628,7 +659,9 @@ onMounted(() => {
|
||||
class="editable-cell__icon"
|
||||
@click="listEdit(record)"
|
||||
v-if="
|
||||
!['read-only', 'read', 'ro'].includes(record.access)
|
||||
!['read-only', 'read', 'ro'].includes(
|
||||
record.access
|
||||
) && !(hasRoles(['teacher']) && classState.student)
|
||||
"
|
||||
/>
|
||||
</div>
|
||||
@@ -660,7 +693,10 @@ onMounted(() => {
|
||||
type="primary"
|
||||
@click.prevent="arrayAdd()"
|
||||
size="small"
|
||||
v-if="treeState.selectNode.paramPerms.includes('post')"
|
||||
v-if="
|
||||
treeState.selectNode.paramPerms.includes('post') &&
|
||||
!(hasRoles(['teacher']) && classState.student)
|
||||
"
|
||||
>
|
||||
<template #icon> <PlusOutlined /> </template>
|
||||
{{ t('common.addText') }}
|
||||
@@ -668,7 +704,7 @@ onMounted(() => {
|
||||
<TableColumnsDnd
|
||||
type="ghost"
|
||||
:cache-id="treeState.selectNode.key"
|
||||
:columns="treeState.selectNode.paramPerms.includes('get') ? [...arrayState.columns.filter((s:any)=>s.key !== 'index')] : arrayState.columns"
|
||||
:columns="(treeState.selectNode.paramPerms.includes('get') || (hasRoles(['teacher']) && classState.student)) ? [...arrayState.columns.filter((s:any)=>s.key !== 'index')] : arrayState.columns"
|
||||
v-model:columns-dnd="arrayState.columnsDnd"
|
||||
></TableColumnsDnd>
|
||||
</a-space>
|
||||
@@ -679,7 +715,10 @@ onMounted(() => {
|
||||
<template v-if="column?.key === 'index'">
|
||||
<a-space :size="16" align="center">
|
||||
<a-tooltip
|
||||
v-if="treeState.selectNode.paramPerms.includes('put')"
|
||||
v-if="
|
||||
treeState.selectNode.paramPerms.includes('put') &&
|
||||
!(hasRoles(['teacher']) && classState.student)
|
||||
"
|
||||
>
|
||||
<template #title>{{ t('common.editText') }}</template>
|
||||
<a-button type="link" @click.prevent="arrayEdit(text)">
|
||||
@@ -687,7 +726,10 @@ onMounted(() => {
|
||||
</a-button>
|
||||
</a-tooltip>
|
||||
<a-tooltip
|
||||
v-if="treeState.selectNode.paramPerms.includes('delete')"
|
||||
v-if="
|
||||
treeState.selectNode.paramPerms.includes('delete') &&
|
||||
!(hasRoles(['teacher']) && classState.student)
|
||||
"
|
||||
>
|
||||
<template #title>{{ t('common.deleteText') }}</template>
|
||||
<a-button type="link" @click.prevent="arrayDelete(text)">
|
||||
@@ -968,4 +1010,11 @@ onMounted(() => {
|
||||
align-items: center;
|
||||
}
|
||||
}
|
||||
|
||||
// 学生账号
|
||||
.student-name {
|
||||
font-size: 18px;
|
||||
color: var(--ant-primary-color);
|
||||
margin-left: 12px;
|
||||
}
|
||||
</style>
|
||||
|
||||
Reference in New Issue
Block a user