|
@@ -63,7 +63,7 @@
|
|
|
<el-input v-model="customSearchForm.phone" placeholder="请输入手机号码" clearable @keyup.enter="handleSearch('custom')" />
|
|
<el-input v-model="customSearchForm.phone" placeholder="请输入手机号码" clearable @keyup.enter="handleSearch('custom')" />
|
|
|
</el-form-item>
|
|
</el-form-item>
|
|
|
<el-form-item>
|
|
<el-form-item>
|
|
|
- <el-button type="primary" icon="Search" @click="handleSearch('custom')">搜索</el-button>
|
|
|
|
|
|
|
+ <el-button type="primary" icon="Search" @click="fetchCustomAdminsWithScope('custom')">搜索</el-button>
|
|
|
<el-button icon="Refresh" @click="handleReset('custom')">重置</el-button>
|
|
<el-button icon="Refresh" @click="handleReset('custom')">重置</el-button>
|
|
|
</el-form-item>
|
|
</el-form-item>
|
|
|
</el-form>
|
|
</el-form>
|
|
@@ -85,7 +85,23 @@
|
|
|
{{ scope.row.gender == 0 ? '男' : '女' }}
|
|
{{ scope.row.gender == 0 ? '男' : '女' }}
|
|
|
</template>
|
|
</template>
|
|
|
</el-table-column>
|
|
</el-table-column>
|
|
|
- <el-table-column prop="scope" label="管理范围" align="center" />
|
|
|
|
|
|
|
+ <el-table-column prop="scope" label="管理范围" align="center">
|
|
|
|
|
+ <template #default="scope">
|
|
|
|
|
+ <el-tooltip
|
|
|
|
|
+ v-if="scope.row.authSourceNames && scope.row.authSourceNames.length > 2"
|
|
|
|
|
+ :content="scope.row.authSourceNames.join(',')"
|
|
|
|
|
+ placement="top"
|
|
|
|
|
+ >
|
|
|
|
|
+ <span>
|
|
|
|
|
+ {{ scope.row.authSourceNames.slice(0, 2).join(',')
|
|
|
|
|
+ }}{{ scope.row.authSourceNames.length > 2 ? ' 等' + scope.row.authSourceNames.length + '个' : '' }}
|
|
|
|
|
+ </span>
|
|
|
|
|
+ </el-tooltip>
|
|
|
|
|
+ <span v-else>
|
|
|
|
|
+ {{ scope.row.authSourceNames?.join(',') || '-' }}
|
|
|
|
|
+ </span>
|
|
|
|
|
+ </template>
|
|
|
|
|
+ </el-table-column>
|
|
|
<el-table-column prop="remark" label="备注" align="center" />
|
|
<el-table-column prop="remark" label="备注" align="center" />
|
|
|
<el-table-column label="操作" align="center" width="200" class-name="small-padding fixed-width">
|
|
<el-table-column label="操作" align="center" width="200" class-name="small-padding fixed-width">
|
|
|
<template #default="scope">
|
|
<template #default="scope">
|
|
@@ -163,12 +179,13 @@
|
|
|
</template>
|
|
</template>
|
|
|
|
|
|
|
|
<script setup lang="ts">
|
|
<script setup lang="ts">
|
|
|
-import { ref, reactive, onMounted } from 'vue';
|
|
|
|
|
|
|
+import { ref, reactive, onMounted, watch } from 'vue';
|
|
|
import AdminDialog from './components/AdminDialog.vue';
|
|
import AdminDialog from './components/AdminDialog.vue';
|
|
|
import ScopeDialog from './components/ScopeDialog.vue';
|
|
import ScopeDialog from './components/ScopeDialog.vue';
|
|
|
import { ElMessage, ElMessageBox } from 'element-plus';
|
|
import { ElMessage, ElMessageBox } from 'element-plus';
|
|
|
import { listStudentManager, delStudentManager, listActiveClassTeachers } from '@/api/xgStudentManager/studentManager';
|
|
import { listStudentManager, delStudentManager, listActiveClassTeachers } from '@/api/xgStudentManager/studentManager';
|
|
|
import type { StudentManagerQuery } from '@/api/xgStudentManager/studentManager/types';
|
|
import type { StudentManagerQuery } from '@/api/xgStudentManager/studentManager/types';
|
|
|
|
|
+import service from '@/utils/request';
|
|
|
|
|
|
|
|
// 暴露组件以修复导出问题
|
|
// 暴露组件以修复导出问题
|
|
|
defineExpose({});
|
|
defineExpose({});
|
|
@@ -221,7 +238,6 @@ async function fetchAdmins(type: string) {
|
|
|
...searchForm,
|
|
...searchForm,
|
|
|
managerType
|
|
managerType
|
|
|
});
|
|
});
|
|
|
-
|
|
|
|
|
// 更新对应类型的管理员数据
|
|
// 更新对应类型的管理员数据
|
|
|
if (type === 'school') {
|
|
if (type === 'school') {
|
|
|
schoolAdmins.value = res.rows || [];
|
|
schoolAdmins.value = res.rows || [];
|
|
@@ -256,9 +272,34 @@ function getSearchForm(type: string) {
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+// 获取自定义管理员及其管理范围
|
|
|
|
|
+async function fetchCustomAdminsWithScope() {
|
|
|
|
|
+ await fetchAdmins('custom');
|
|
|
|
|
+ // 遍历 customAdmins,异步获取每个管理员的authSource
|
|
|
|
|
+ for (const admin of customAdmins.value) {
|
|
|
|
|
+ try {
|
|
|
|
|
+ const res = await service({
|
|
|
|
|
+ url: '/xgStudentManagerSource/studentManagerSource//authSourceNames',
|
|
|
|
|
+ method: 'get',
|
|
|
|
|
+ params: { managerId: admin.id }
|
|
|
|
|
+ });
|
|
|
|
|
+ admin.authSourceNames = res?.data || [];
|
|
|
|
|
+ } catch (e) {
|
|
|
|
|
+ admin.authSourceNames = [];
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+// 监听tab切换,切到custom时自动加载管理范围
|
|
|
|
|
+watch(activeTab, (val) => {
|
|
|
|
|
+ if (val === 'custom') {
|
|
|
|
|
+ fetchCustomAdminsWithScope();
|
|
|
|
|
+ }
|
|
|
|
|
+});
|
|
|
|
|
+
|
|
|
onMounted(() => {
|
|
onMounted(() => {
|
|
|
fetchAdmins('school');
|
|
fetchAdmins('school');
|
|
|
- fetchAdmins('custom');
|
|
|
|
|
|
|
+ fetchCustomAdminsWithScope();
|
|
|
fetchAdmins('teacher');
|
|
fetchAdmins('teacher');
|
|
|
});
|
|
});
|
|
|
|
|
|
|
@@ -321,7 +362,11 @@ function onScope(type: string, admin: any) {
|
|
|
function onDialogSubmit(admin: any) {
|
|
function onDialogSubmit(admin: any) {
|
|
|
// 表单已在对话框组件内处理API调用
|
|
// 表单已在对话框组件内处理API调用
|
|
|
// 刷新列表数据
|
|
// 刷新列表数据
|
|
|
- fetchAdmins(activeTab.value);
|
|
|
|
|
|
|
+ if (activeTab.value === 'custom') {
|
|
|
|
|
+ fetchCustomAdminsWithScope();
|
|
|
|
|
+ } else {
|
|
|
|
|
+ fetchAdmins(activeTab.value);
|
|
|
|
|
+ }
|
|
|
dialogVisible.value = false;
|
|
dialogVisible.value = false;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -331,6 +376,7 @@ async function onScopeSubmit(scope: any) {
|
|
|
// 成功后刷新数据并提示
|
|
// 成功后刷新数据并提示
|
|
|
ElMessage.success('管理范围分配成功');
|
|
ElMessage.success('管理范围分配成功');
|
|
|
fetchAdmins(scopeType.value);
|
|
fetchAdmins(scopeType.value);
|
|
|
|
|
+ fetchCustomAdminsWithScope();
|
|
|
scopeDialogVisible.value = false;
|
|
scopeDialogVisible.value = false;
|
|
|
} catch (error) {
|
|
} catch (error) {
|
|
|
ElMessage.error('管理范围分配失败');
|
|
ElMessage.error('管理范围分配失败');
|
|
@@ -353,7 +399,9 @@ function getListByType(type: string) {
|
|
|
|
|
|
|
|
// 过滤
|
|
// 过滤
|
|
|
function filteredAdmins(type: string) {
|
|
function filteredAdmins(type: string) {
|
|
|
- console.log(getListByType(type).value);
|
|
|
|
|
|
|
+ if (type === 'custom') {
|
|
|
|
|
+ return customAdmins.value;
|
|
|
|
|
+ }
|
|
|
return getListByType(type).value;
|
|
return getListByType(type).value;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -376,7 +424,11 @@ function handleReset(type: string) {
|
|
|
teacherSearchForm.phone = '';
|
|
teacherSearchForm.phone = '';
|
|
|
break;
|
|
break;
|
|
|
}
|
|
}
|
|
|
- fetchAdmins(type);
|
|
|
|
|
|
|
+ if (type === 'custom') {
|
|
|
|
|
+ fetchCustomAdminsWithScope();
|
|
|
|
|
+ } else {
|
|
|
|
|
+ fetchAdmins(type);
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
</script>
|
|
</script>
|
|
|
|
|
|