fix: 参数配置教师操作学生应用和退回

This commit is contained in:
TsMask
2024-07-18 15:04:51 +08:00
parent 4d755cea5d
commit c35a5a9c33
4 changed files with 86 additions and 50 deletions

View File

@@ -1,12 +1,24 @@
import { request } from '@/plugins/http-fetch';
/**
* 班级学生列表 (仅教师操作)
* @param params 数据 {userName}
* @returns object
*/
export function getPtClassStudents(params?: Record<string, any>) {
return request({
url: `/pt/neConfigApply/students`,
params,
method: 'get',
});
}
/**
* 网元参数配置应用申请列表
* @param params 数据 {neType,paramName}
* @returns object
*/
export function getPtNeConfigApply(params: Record<string, any>) {
export function getPtNeConfigApplyList(params: Record<string, any>) {
return request({
url: `/pt/neConfigApply/list`,
params,
@@ -39,5 +51,3 @@ export function updatePtNeConfigApply(data: Record<string, any>) {
data: data,
});
}

View File

@@ -112,9 +112,9 @@ export default function useConfigList({
/**当前页数 */
current: 1,
/**每页条数 */
pageSize: 20,
pageSize: 10,
/**默认的每页条数 */
defaultPageSize: 20,
defaultPageSize: 10,
/**指定每页可以显示多少条 */
pageSizeOptions: ['10', '20', '50', '100'],
/**只有一页时是否隐藏分页器 */

View File

@@ -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,
};
}

View File

@@ -440,14 +440,14 @@ onMounted(() => {
@search="studentSearch"
@change="fnActiveConfigNode('#')"
>
<template #option="{ value, label, status }">
<template #option="{ value, label, applyStatus }">
<span>{{ label }} </span>
<a-tag
v-if="status === '0'"
v-if="applyStatus === '0'"
color="processing"
style="position: absolute; right: 0;}"
>
{{ status && '申请' }}
{{ applyStatus && '申请' }}
</a-tag>
</template>
</a-select>
@@ -464,13 +464,13 @@ onMounted(() => {
"
>
<a-button
@click="ptConfigApply(treeState.neType, '2')"
@click="ptConfigApply(treeState.neType, '2', classState.student)"
:loading="ptConfigState.applyLoading"
>
应用
</a-button>
<a-button
@click="ptConfigApply(treeState.neType, '3')"
@click="ptConfigApply(treeState.neType, '3', classState.student)"
:loading="ptConfigState.applyLoading"
>
退回