fix: 参数配置教师操作学生应用和退回
This commit is contained in:
@@ -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,
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user