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