更改校端权限

This commit is contained in:
chenxing
2026-09-07 09:32:38 +08:00
parent 9200fa2135
commit 7e37f2ada6
15 changed files with 461 additions and 120 deletions
+45 -15
View File
@@ -2,7 +2,13 @@
<div class="main-wrapper">
<div class="main-container">
<Alert show-icon>设置说明:拖动排序,被使用的分类不能删除</Alert>
<Button class="mb-5" type="primary" @click="addModuleShow">新增应用类型</Button>
<!-- 多校管理员:学校切换(改名/排序仅对所选学校生效) -->
<Select v-if="multiSchool" v-model="currentSchoolId" class="mb-5 school-select" transfer
placeholder="全部学校(并集)" @on-change="fetchTypeList">
<Option v-for="s in schoolList" :key="s.id" :value="s.id">{{ s.name }}</Option>
</Select>
<Button v-if="!isSchoolMode" class="mb-5" :class="{ 'ml-8': multiSchool }" type="primary"
@click="addModuleShow">新增应用类型</Button>
<draggable class="type_set-wrap fix" tag="ul" v-model="typeList" :group="'appType'" @change="typeSortSave"
item-key="id">
<template #item="{ element }">
@@ -16,7 +22,7 @@
<span>编辑</span>
</div>
<div class="action_delete" @click="removeSave(element)">
<div class="action_delete" v-if="!isSchoolMode" @click="removeSave(element)">
<span>删除</span>
</div>
</div>
@@ -49,16 +55,25 @@
import draggable from 'vuedraggable'
import { debounce } from "lodash";
import MyConfirm from "@/components/MyConfirm";
import { useAppSchoolScope } from "@/utils/hook/useAppSchoolScope";
const { data: typeList, send: sendTypeList } = useRequest(
Apis.AppSettings.appTypeList({
transform: (res: any) => {
return res ?? [];
},
cacheFor: null,
}),
{ initialData: [], immediate: true }
)
// 学校管理员上下文:仅改名/排序(写学校覆盖表);新增/删除类型仅超管(按钮隐藏 + 接口 requireSuper 双挡)
const { isSchoolMode, multiSchool, schoolList, currentSchoolId, requireSchool } = useAppSchoolScope();
const typeList = ref<any[]>([])
async function fetchTypeList() {
try {
const res: any = await Apis.AppSettings.appTypeList({
params: { schoolId: currentSchoolId.value ?? undefined },
cacheFor: null,
});
typeList.value = (res ?? []).slice().sort((a: any, b: any) => (a.sortNo ?? 0) - (b.sortNo ?? 0));
} catch (e: any) {
console.warn(e?.message || "获取应用类型失败");
}
}
fetchTypeList()
const refFormData = useTemplateRef('formData');
const editModal = ref(false);
@@ -80,13 +95,22 @@ async function addModuleShow() {
editModal.value = true;
}
//拖动排序:提交当前顺序的 id 数组
//拖动排序:提交当前顺序的 id 数组(SCHOOL 模式写学校覆盖表快照;多校须先选定学校)
async function typeSortSave() {
if (!requireSchool()) {
// 未选学校:拒绝提交并回拉列表,撤销拖拽造成的本地顺序变化
await fetchTypeList();
return;
}
const ids = (typeList.value ?? []).map((s: any) => s.id);
await Apis.AppSettings.appTypeSort({ data: ids });
await Apis.AppSettings.appTypeSort({
data: ids,
params: currentSchoolId.value != null ? { schoolId: currentSchoolId.value } : undefined,
});
}
async function showSetting(element: any) {
if (!requireSchool()) return;
currentId.value = element.id;
form.value = {
id: element.id,
@@ -106,7 +130,7 @@ async function removeSave(element: any) {
try {
await Apis.AppSettings.deleteType({ pathParams: { id: element.id } });
Message.success("操作成功!");
await sendTypeList();
await fetchTypeList();
} catch (error) {
console.error(error);
@@ -138,11 +162,13 @@ async function onRawEditSave() {
id: currentId.value,
name: form.value.name,
},
// SCHOOL 模式:改名写学校覆盖表(仅该校生效)
params: currentSchoolId.value != null ? { schoolId: currentSchoolId.value } : undefined,
});
}
Message.success("操作成功!");
editModal.value = false;
await sendTypeList();
await fetchTypeList();
} catch (error) {
console.error(error);
} finally {
@@ -163,6 +189,10 @@ function onReset() {
display: flex;
}
.school-select {
width: 180px;
}
.type_set-wrap {
margin: 12px 0 16px;
}