更改校端权限

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
+40 -18
View File
@@ -1,18 +1,26 @@
<template>
<AppForm v-model="visible" :initForm="detailData" :categoryList="categoryList" :isEdit="true" :loading="submitting"
@submit="handleSubmit" @cancel="visible = false" @reset-secret="handleResetSecret" />
:schoolMode="isSchoolMode" @submit="handleSubmit" @cancel="visible = false" @reset-secret="handleResetSecret" />
</template>
<script setup lang="ts">
import { ref } from "vue";
import AppForm from "./AppForm.vue";
import MyConfirm from '@/components/MyConfirm'
import { UserRoleEnum } from "@/types";
import { useDefaultStore } from "@/store";
/* ---------- 对外暴露 ---------- */
const visible = ref(false);
const categoryList = ref<any[]>([]);
// 编辑模式:从 appList 中根据 id 取出详情回填(无独立详情接口)
const store = useDefaultStore();
const isSchoolMode = store.userRole === UserRoleEnum.School;
// 多校管理员当前所选学校(单校/超管为 undefined,后端按 scope 自动解析)
const props = defineProps<{ schoolId?: number | null }>();
// 编辑模式:从 appList 中根据 id 取出详情回填(无独立详情接口;SCHOOL 模式列表已合并覆盖值)
const detailData = ref<Record<string, any>>({});
const currentId = ref<number | null>(null);
@@ -21,12 +29,16 @@ let onSuccessCallback: (() => void) | null = null;
// useForm 托管提交——currentId 是 ref,闭包内 .value 在 sendForm 时取当前值
const { form, loading: submitting, send: sendForm, onSuccess, onError } = useForm(
(dto) => Apis.AppSettings.editApp({ pathParams: { id: currentId.value }, data: dto }),
(dto) => Apis.AppSettings.editApp({
pathParams: { id: currentId.value },
data: dto,
params: props.schoolId != null ? { schoolId: props.schoolId } : undefined,
}),
{ initialForm: { id: null, name: '', categoryId: undefined, desc: '', clients: [], pcUrl: '', pcIcon: '', appUrl: '', appIcon: '', officialAccountUrl: '', dingtalkUrl: '' }, resetAfterSubmiting: true }
);
onSuccess(() => {
Message.success('编辑应用成功!');
Message.success(isSchoolMode ? '保存成功(仅对本校生效)!' : '编辑应用成功!');
visible.value = false;
onSuccessCallback?.();
});
@@ -54,23 +66,33 @@ function open(id: number, row: any, categories: any[], onSuccess?: () => void) {
/* ---------- 提交:由 useForm 接管 loading 与异常处理 ---------- */
async function handleSubmit(formData: Record<string, any>) {
if (!currentId.value) return;
form.value = {
id: currentId.value,
name: formData.name,
categoryId: formData.categoryId,
desc: formData.desc,
clients: formData.clients,
pcUrl: formData.pcUrl,
pcIcon: formData.pcIcon,
appUrl: formData.appUrl,
appIcon: formData.appIcon,
officialAccountUrl: formData.officialAccountUrl,
dingtalkUrl: formData.dingtalkUrl,
};
if (isSchoolMode) {
// 学校模式:仅 名称/描述/Pc图标 三字段写学校覆盖表,其余字段一律不提交
form.value = {
id: currentId.value,
name: formData.name,
desc: formData.desc,
pcIcon: formData.pcIcon,
};
} else {
form.value = {
id: currentId.value,
name: formData.name,
categoryId: formData.categoryId,
desc: formData.desc,
clients: formData.clients,
pcUrl: formData.pcUrl,
pcIcon: formData.pcIcon,
appUrl: formData.appUrl,
appIcon: formData.appIcon,
officialAccountUrl: formData.officialAccountUrl,
dingtalkUrl: formData.dingtalkUrl,
};
}
await sendForm();
}
/* ---------- 重置密钥(非表单提交,直接 MyConfirm + await) ---------- */
/* ---------- 重置密钥(非表单提交,直接 MyConfirm + await;学校模式入口已隐藏) ---------- */
async function handleResetSecret() {
if (!currentId.value) return;
try {