diff --git a/src/api/pt/neClass.ts b/src/api/pt/neClass.ts new file mode 100644 index 00000000..448edee5 --- /dev/null +++ b/src/api/pt/neClass.ts @@ -0,0 +1,14 @@ +import { request } from '@/plugins/http-fetch'; + +/** + * 班级学生列表 (仅教师操作) + * @param params 数据 {neType,paramName} + * @returns object + */ +export function getPtClassStudents(params: Record) { + return request({ + url: `/pt/class/students`, + params, + method: 'get', + }); +} diff --git a/src/views/configManage/configParamTreeTable/hooks/usePtOptions.ts b/src/views/configManage/configParamTreeTable/hooks/usePtOptions.ts index 7c66cebb..0a91d1f9 100644 --- a/src/views/configManage/configParamTreeTable/hooks/usePtOptions.ts +++ b/src/views/configManage/configParamTreeTable/hooks/usePtOptions.ts @@ -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, }; } diff --git a/src/views/configManage/configParamTreeTable/index.vue b/src/views/configManage/configParamTreeTable/index.vue index 74487adc..effe74d1 100644 --- a/src/views/configManage/configParamTreeTable/index.vue +++ b/src/views/configManage/configParamTreeTable/index.vue @@ -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[]>([]); @@ -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 }" > - + { :not-found-content="null" :options="classState.studentOptions" @search="studentSearch" - @change="studentChange" + @change="fnActiveConfigNode('#')" > - - (管理员)载入网元配置为示例配置 + + (管理员/教师) 应用到网元 - - (学生)重置为班级示例/(教师)重置为系统示例 + + (管理员)载入网元配置为系统示例 - - (学生)申请应用当前网元配置 + + (教师)重置为系统示例 + + + (学生)重置为教师示例 + + + (学生)申请应用到 {{ treeState.neType }} @@ -458,12 +488,13 @@ onMounted(() => { v-show="collapsible" > - + + { 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) " /> @@ -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) + " > {{ t('common.addText') }} @@ -668,7 +704,7 @@ onMounted(() => { @@ -679,7 +715,10 @@ onMounted(() => {