diff --git a/src/api/pt/neConfigApply.ts b/src/api/pt/neConfigApply.ts index a27f2000..5fdca195 100644 --- a/src/api/pt/neConfigApply.ts +++ b/src/api/pt/neConfigApply.ts @@ -1,12 +1,24 @@ import { request } from '@/plugins/http-fetch'; - +/** + * 班级学生列表 (仅教师操作) + * @param params 数据 {userName} + * @returns object + */ +export function getPtClassStudents(params?: Record) { + return request({ + url: `/pt/neConfigApply/students`, + params, + method: 'get', + }); +} + /** * 网元参数配置应用申请列表 * @param params 数据 {neType,paramName} * @returns object */ -export function getPtNeConfigApply(params: Record) { +export function getPtNeConfigApplyList(params: Record) { return request({ url: `/pt/neConfigApply/list`, params, @@ -39,5 +51,3 @@ export function updatePtNeConfigApply(data: Record) { data: data, }); } - - \ No newline at end of file diff --git a/src/views/configManage/configParamTreeTable/hooks/useConfigList.ts b/src/views/configManage/configParamTreeTable/hooks/useConfigList.ts index c9669b0e..40c1b393 100644 --- a/src/views/configManage/configParamTreeTable/hooks/useConfigList.ts +++ b/src/views/configManage/configParamTreeTable/hooks/useConfigList.ts @@ -112,9 +112,9 @@ export default function useConfigList({ /**当前页数 */ current: 1, /**每页条数 */ - pageSize: 20, + pageSize: 10, /**默认的每页条数 */ - defaultPageSize: 20, + defaultPageSize: 10, /**指定每页可以显示多少条 */ pageSizeOptions: ['10', '20', '50', '100'], /**只有一页时是否隐藏分页器 */ diff --git a/src/views/configManage/configParamTreeTable/hooks/usePtOptions.ts b/src/views/configManage/configParamTreeTable/hooks/usePtOptions.ts index fd8479bb..a7fe8e25 100644 --- a/src/views/configManage/configParamTreeTable/hooks/usePtOptions.ts +++ b/src/views/configManage/configParamTreeTable/hooks/usePtOptions.ts @@ -20,7 +20,7 @@ export default function usePtOptions({ t, fnActiveConfigNode }: any) { restLoading: false, applyLoading: false, }); - /**保存网元下所有配置为示例配置 */ + /**(管理员)保存网元下所有配置为示例配置 */ function ptConfigSave(neType: string) { ptConfigState.saveLoading = true; ptSaveAsDefault(neType, '001') @@ -39,6 +39,7 @@ export default function usePtOptions({ t, fnActiveConfigNode }: any) { }) .finally(() => { ptConfigState.saveLoading = false; + fnActiveConfigNode('#'); }); } @@ -66,13 +67,34 @@ export default function usePtOptions({ t, fnActiveConfigNode }: any) { } /**配置下方应用(学生)申请撤回和(管理/教师)应用退回 */ - function ptConfigApply(neType: string, status: '0' | '1' |'2'| '3' ) { + function ptConfigApply( + neType: string, + status: '0' | '1' | '2' | '3', + student?: string + ) { let result: any; - if (status === '2') { - result = updatePtNeConfigApply({ neType, status: '2' }); + if (status === '2' || status === '3') { + let from: { + neType: string; + status: string; + student?: string; + backInfo?: string; + } = { + neType, + status: '2', + }; + if (student) { + if (status === '2') { + from = { neType, status, student }; + } + if (status === '3') { + from = { neType, status, student, backInfo: '请重新检查配置' }; + } + } + result = updatePtNeConfigApply(from); } - if (status === '0') { - result = stuPtNeConfigApply({ neType, status: '0' }); + if (status === '0' || status === '1') { + result = stuPtNeConfigApply({ neType, status }); } if (!result) return; ptConfigState.applyLoading = true; @@ -99,8 +121,18 @@ export default function usePtOptions({ t, fnActiveConfigNode }: any) { /**学生账号 */ student: string | undefined; /**学生可选择列表 */ - studentOptions: { value: string; label: string; status: string }[]; - studentOptionsDef: { value: string; label: string; status: string }[]; + studentOptions: { + value: string; + label: string; + applyId: string; + applyStatus: string; + }[]; + studentOptionsDef: { + value: string; + label: string; + applyId: string; + applyStatus: string; + }[]; }>({ student: undefined, studentOptions: [], @@ -110,21 +142,7 @@ export default function usePtOptions({ t, fnActiveConfigNode }: any) { // 仅教师加载 if (hasRoles(['teacher'])) { onMounted(() => { - // 初始学生列表 - getPtClassStudents().then(res => { - if (!Array.isArray(res.data) || res.data.length <= 0) { - return; - } - classState.studentOptions = []; - for (const s of res.data) { - classState.studentOptions.push({ - value: s.userName, - label: s.userName, - status: s.applyStatus, - }); - } - Object.assign(classState.studentOptionsDef, classState.studentOptions); - }); + classStudents(); // 初始学生列表 }); } @@ -140,28 +158,36 @@ export default function usePtOptions({ t, fnActiveConfigNode }: any) { Object.assign(classState.studentOptions, classState.studentOptionsDef); return; } - function fake() { - getPtClassStudents({ userName: val }).then(res => { - classState.studentOptions = []; - for (const s of res.data) { - classState.studentOptions.push({ - value: s.userName, - label: s.userName, - status: s.applyStatus, - }); - } - }); - } - timeout = setTimeout(fake, 500); + timeout = setTimeout(() => classStudents(val), 500); + } + + /**班级学生列表 */ + function classStudents(val?: string) { + getPtClassStudents({ userName: val }).then(res => { + classState.studentOptions = []; + if (!Array.isArray(res.data) || res.data.length <= 0) { + return; + } + for (const s of res.data) { + classState.studentOptions.push({ + value: s.userName, + label: s.userName, + applyId: s.applyId, + applyStatus: s.applyStatus, + }); + } + if (val) { + Object.assign(classState.studentOptionsDef, classState.studentOptions); + } + }); } - // 学生状态 const studentStatus = computed(() => { const item = classState.studentOptions.find( s => s.value === classState.student ); - if (item) return item.status; + if (item) return item.applyStatus; return ''; }); @@ -172,6 +198,6 @@ export default function usePtOptions({ t, fnActiveConfigNode }: any) { ptConfigApply, classState, studentStatus, - studentSearch, + studentSearch, }; } diff --git a/src/views/configManage/configParamTreeTable/index.vue b/src/views/configManage/configParamTreeTable/index.vue index e76c521d..f2fe486f 100644 --- a/src/views/configManage/configParamTreeTable/index.vue +++ b/src/views/configManage/configParamTreeTable/index.vue @@ -440,14 +440,14 @@ onMounted(() => { @search="studentSearch" @change="fnActiveConfigNode('#')" > -