|
|
@@ -0,0 +1,612 @@
|
|
|
+<template>
|
|
|
+ <div class="p-2">
|
|
|
+ <transition :enter-active-class="proxy?.animate.searchAnimate.enter" :leave-active-class="proxy?.animate.searchAnimate.leave">
|
|
|
+ <div v-show="showSearch" class="mb-[10px]">
|
|
|
+ <el-card shadow="hover">
|
|
|
+ <el-form ref="queryFormRef" :model="queryParams" :inline="true">
|
|
|
+ <el-form-item label="批次名称" prop="batchName">
|
|
|
+ <el-input v-model="queryParams.batchName" placeholder="请输入批次名称" clearable @keyup.enter="handleQuery" />
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item>
|
|
|
+ <el-button type="primary" icon="Search" @click="handleQuery">搜索</el-button>
|
|
|
+ <el-button icon="Refresh" @click="resetQuery">重置</el-button>
|
|
|
+ </el-form-item>
|
|
|
+ </el-form>
|
|
|
+ </el-card>
|
|
|
+ </div>
|
|
|
+ </transition>
|
|
|
+
|
|
|
+ <el-card shadow="never">
|
|
|
+ <template #header>
|
|
|
+ <el-row :gutter="10" class="mb8">
|
|
|
+ <el-col :span="1.5">
|
|
|
+ <el-button type="primary" plain icon="Plus" @click="handleAdd" v-hasPermi="['XgStuColBatch:stuColBatch:add']">新增</el-button>
|
|
|
+ </el-col>
|
|
|
+ <el-col :span="1.5">
|
|
|
+ <el-button type="success" plain icon="Edit" :disabled="single" @click="handleUpdate()" v-hasPermi="['XgStuColBatch:stuColBatch:edit']"
|
|
|
+ >修改</el-button
|
|
|
+ >
|
|
|
+ </el-col>
|
|
|
+ <!-- <el-col :span="1.5">
|
|
|
+ <el-button
|
|
|
+ type="danger"
|
|
|
+ plain
|
|
|
+ icon="Delete"
|
|
|
+ :disabled="multiple"
|
|
|
+ @click="handleDelete()"
|
|
|
+ v-hasPermi="['XgStuColBatch:stuColBatch:remove']"
|
|
|
+ >删除</el-button
|
|
|
+ >
|
|
|
+ </el-col> -->
|
|
|
+ <el-col :span="1.5">
|
|
|
+ <el-button type="warning" plain icon="Download" @click="handleExport" v-hasPermi="['XgStuColBatch:stuColBatch:export']">导出</el-button>
|
|
|
+ </el-col>
|
|
|
+ <right-toolbar v-model:showSearch="showSearch" @queryTable="getList"></right-toolbar>
|
|
|
+ </el-row>
|
|
|
+ </template>
|
|
|
+
|
|
|
+ <el-table v-loading="loading" border :data="stuColBatchList" @selection-change="handleSelectionChange">
|
|
|
+ <el-table-column type="selection" width="55" align="center" />
|
|
|
+ <el-table-column label="批次ID" align="center" prop="id" v-if="true" />
|
|
|
+ <el-table-column label="批次名称" align="center" prop="batchName" />
|
|
|
+ <el-table-column label="批次描述" align="center" prop="description" />
|
|
|
+ <el-table-column label="开始时间" align="center" prop="startTime" width="200">
|
|
|
+ <template #default="scope">
|
|
|
+ <span>{{ parseTime(scope.row.startTime, '{y}-{m}-{d} {h}:{i}:{s}') }}</span>
|
|
|
+ </template>
|
|
|
+ </el-table-column>
|
|
|
+ <el-table-column label="结束时间" align="center" prop="endTime" width="200">
|
|
|
+ <template #default="scope">
|
|
|
+ <span>{{ parseTime(scope.row.endTime, '{y}-{m}-{d} {h}:{i}:{s}') }}</span>
|
|
|
+ </template>
|
|
|
+ </el-table-column>
|
|
|
+ <el-table-column label="状态" align="center" prop="status">
|
|
|
+ <template #default="scope">
|
|
|
+ <el-tag :type="scope.row.status === '0' ? 'success' : 'danger'">
|
|
|
+ {{ scope.row.status === '0' ? '正常' : '停用' }}
|
|
|
+ </el-tag>
|
|
|
+ </template>
|
|
|
+ </el-table-column>
|
|
|
+ <el-table-column label="收集类型" align="center" prop="collectionType">
|
|
|
+ <template #default="scope">
|
|
|
+ <el-tag :type="scope.row.collectionType === '1' ? 'primary' : 'info'">
|
|
|
+ {{ scope.row.collectionType === '1' ? '新学期收集' : '其他' }}
|
|
|
+ </el-tag>
|
|
|
+ </template>
|
|
|
+ </el-table-column>
|
|
|
+ <el-table-column label="操作" align="center" width="200" class-name="small-padding fixed-right">
|
|
|
+ <template #default="scope">
|
|
|
+ <el-tooltip content="查看详细" placement="top">
|
|
|
+ <el-button
|
|
|
+ link
|
|
|
+ type="info"
|
|
|
+ plain
|
|
|
+ icon="View"
|
|
|
+ @click="handleView(scope.row)"
|
|
|
+ v-hasPermi="['XgStuColBatch:stuColBatch:query']"
|
|
|
+ ></el-button>
|
|
|
+ </el-tooltip>
|
|
|
+ <el-tooltip content="修改" placement="top">
|
|
|
+ <el-button
|
|
|
+ link
|
|
|
+ type="primary"
|
|
|
+ plain
|
|
|
+ icon="Edit"
|
|
|
+ @click="handleUpdate(scope.row)"
|
|
|
+ v-hasPermi="['XgStuColBatch:stuColBatch:edit']"
|
|
|
+ ></el-button>
|
|
|
+ </el-tooltip>
|
|
|
+ <el-tooltip content="收集范围" placement="top">
|
|
|
+ <el-button
|
|
|
+ link
|
|
|
+ type="warning"
|
|
|
+ plain
|
|
|
+ icon="Setting"
|
|
|
+ @click="handleScope(scope.row)"
|
|
|
+ v-hasPermi="['XgStuColBatch:stuColBatch:scope']"
|
|
|
+ ></el-button>
|
|
|
+ </el-tooltip>
|
|
|
+ <el-tooltip content="删除" placement="top">
|
|
|
+ <el-button
|
|
|
+ link
|
|
|
+ plain
|
|
|
+ type="danger"
|
|
|
+ icon="Delete"
|
|
|
+ @click="handleDelete(scope.row)"
|
|
|
+ v-hasPermi="['XgStuColBatch:stuColBatch:remove']"
|
|
|
+ ></el-button>
|
|
|
+ </el-tooltip>
|
|
|
+ </template>
|
|
|
+ </el-table-column>
|
|
|
+ </el-table>
|
|
|
+
|
|
|
+ <pagination v-show="total > 0" :total="total" v-model:page="queryParams.pageNum" v-model:limit="queryParams.pageSize" @pagination="getList" />
|
|
|
+ </el-card>
|
|
|
+ <!-- 添加或修改学生信息收集批次对话框 -->
|
|
|
+ <el-dialog :title="dialog.title" v-model="dialog.visible" width="500px" append-to-body>
|
|
|
+ <el-form ref="stuColBatchFormRef" :model="form" :rules="rules" label-width="80px">
|
|
|
+ <el-form-item label="批次名称" prop="batchName">
|
|
|
+ <el-input v-model="form.batchName" placeholder="请输入批次名称" />
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item label="批次描述" prop="description">
|
|
|
+ <el-input v-model="form.description" type="textarea" placeholder="请输入内容" />
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item label="开始时间" prop="startTime">
|
|
|
+ <el-date-picker
|
|
|
+ clearable
|
|
|
+ style="width: 100%"
|
|
|
+ v-model="form.startTime"
|
|
|
+ type="datetime"
|
|
|
+ value-format="YYYY-MM-DD HH:mm:ss"
|
|
|
+ placeholder="请选择开始时间"
|
|
|
+ >
|
|
|
+ </el-date-picker>
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item label="结束时间" prop="endTime">
|
|
|
+ <el-date-picker
|
|
|
+ clearable
|
|
|
+ style="width: 100%"
|
|
|
+ v-model="form.endTime"
|
|
|
+ type="datetime"
|
|
|
+ value-format="YYYY-MM-DD HH:mm:ss"
|
|
|
+ placeholder="请选择结束时间"
|
|
|
+ >
|
|
|
+ </el-date-picker>
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item label="状态" prop="status">
|
|
|
+ <el-select v-model="form.status" placeholder="请选择状态">
|
|
|
+ <el-option label="正常" value="0" />
|
|
|
+ <el-option label="停用" value="1" />
|
|
|
+ </el-select>
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item label="收集类型" prop="collectionType">
|
|
|
+ <el-select v-model="form.collectionType" placeholder="请选择收集类型">
|
|
|
+ <el-option label="新学期收集" value="1" />
|
|
|
+ <el-option label="其他" value="2" />
|
|
|
+ </el-select>
|
|
|
+ </el-form-item>
|
|
|
+ </el-form>
|
|
|
+ <template #footer>
|
|
|
+ <div class="dialog-footer">
|
|
|
+ <el-button :loading="buttonLoading" type="primary" @click="submitForm">确 定</el-button>
|
|
|
+ <el-button @click="cancel">取 消</el-button>
|
|
|
+ </div>
|
|
|
+ </template>
|
|
|
+ </el-dialog>
|
|
|
+
|
|
|
+ <!-- 收集范围设置对话框 -->
|
|
|
+ <el-dialog title="设置收集范围" v-model="scopeDialog.visible" width="500px" append-to-body @close="handleScopeDialogClose">
|
|
|
+ <div class="scope-content">
|
|
|
+ <el-tree
|
|
|
+ ref="scopeTreeRef"
|
|
|
+ :data="deptTreeData"
|
|
|
+ show-checkbox
|
|
|
+ default-expand-all
|
|
|
+ node-key="id"
|
|
|
+ :props="{ children: 'children', label: 'label' }"
|
|
|
+ :check-strictly="false"
|
|
|
+ />
|
|
|
+ </div>
|
|
|
+ <template #footer>
|
|
|
+ <div class="dialog-footer">
|
|
|
+ <el-button :loading="scopeButtonLoading" type="primary" @click="submitScope">确 定</el-button>
|
|
|
+ <el-button @click="cancelScope">取 消</el-button>
|
|
|
+ </div>
|
|
|
+ </template>
|
|
|
+ </el-dialog>
|
|
|
+
|
|
|
+ <!-- 查看详细对话框 -->
|
|
|
+ <el-dialog title="批次详细信息" v-model="viewDialog.visible" width="800px" append-to-body>
|
|
|
+ <el-tabs v-model="viewActiveTab" type="border-card">
|
|
|
+ <el-tab-pane label="基本信息" name="basic">
|
|
|
+ <el-descriptions :column="2" border>
|
|
|
+ <el-descriptions-item label="批次ID">{{ viewForm.id }}</el-descriptions-item>
|
|
|
+ <el-descriptions-item label="批次名称">{{ viewForm.batchName }}</el-descriptions-item>
|
|
|
+ <el-descriptions-item label="批次描述" :span="2">{{ viewForm.description || '暂无描述' }}</el-descriptions-item>
|
|
|
+ <el-descriptions-item label="开始时间">{{ parseTime(viewForm.startTime, '{y}-{m}-{d} {h}:{i}:{s}') }}</el-descriptions-item>
|
|
|
+ <el-descriptions-item label="结束时间">{{ parseTime(viewForm.endTime, '{y}-{m}-{d} {h}:{i}:{s}') }}</el-descriptions-item>
|
|
|
+ <el-descriptions-item label="状态">
|
|
|
+ <el-tag :type="viewForm.status === '0' ? 'success' : 'danger'">
|
|
|
+ {{ viewForm.status === '0' ? '正常' : '停用' }}
|
|
|
+ </el-tag>
|
|
|
+ </el-descriptions-item>
|
|
|
+ <el-descriptions-item label="收集类型">
|
|
|
+ <el-tag :type="viewForm.collectionType === '1' ? 'primary' : 'info'">
|
|
|
+ {{ viewForm.collectionType === '1' ? '新学期收集' : '其他' }}
|
|
|
+ </el-tag>
|
|
|
+ </el-descriptions-item>
|
|
|
+ <el-descriptions-item label="创建时间">{{ parseTime(viewForm.createTime, '{y}-{m}-{d} {h}:{i}:{s}') }}</el-descriptions-item>
|
|
|
+ <el-descriptions-item label="更新时间">{{ parseTime(viewForm.updateTime, '{y}-{m}-{d} {h}:{i}:{s}') }}</el-descriptions-item>
|
|
|
+ </el-descriptions>
|
|
|
+ </el-tab-pane>
|
|
|
+ <el-tab-pane label="权限范围" name="scope">
|
|
|
+ <div class="scope-detail-content">
|
|
|
+ <div v-if="scopeDetailList.length === 0" class="no-data">
|
|
|
+ <el-empty description="暂无权限范围配置" />
|
|
|
+ </div>
|
|
|
+ <div v-else>
|
|
|
+ <el-alert title="权限范围说明" type="info" :closable="false" show-icon class="mb-3">
|
|
|
+ <template #default> 该批次配置了 {{ scopeDetailList.length }} 个班级的收集权限,具体如下: </template>
|
|
|
+ </el-alert>
|
|
|
+ <el-table :data="scopeDetailList" border stripe>
|
|
|
+ <el-table-column label="序号" type="index" width="60" align="center" />
|
|
|
+ <el-table-column label="学院名称" prop="collegeName" align="center" />
|
|
|
+ <el-table-column label="专业名称" prop="majorName" align="center" />
|
|
|
+ <el-table-column label="班级名称" prop="className" align="center" />
|
|
|
+ <el-table-column label="配置时间" align="center" width="180">
|
|
|
+ <template #default="scope">
|
|
|
+ <span>{{ parseTime(scope.row.createTime, '{y}-{m}-{d} {h}:{i}:{s}') }}</span>
|
|
|
+ </template>
|
|
|
+ </el-table-column>
|
|
|
+ </el-table>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ </el-tab-pane>
|
|
|
+ </el-tabs>
|
|
|
+ <template #footer>
|
|
|
+ <div class="dialog-footer">
|
|
|
+ <el-button @click="cancelView">关 闭</el-button>
|
|
|
+ </div>
|
|
|
+ </template>
|
|
|
+ </el-dialog>
|
|
|
+ </div>
|
|
|
+</template>
|
|
|
+
|
|
|
+<script setup name="StuColBatch" lang="ts">
|
|
|
+import { listStuColBatch, getStuColBatch, delStuColBatch, addStuColBatch, updateStuColBatch } from '@/api/XgStuColBatch/stuColBatch';
|
|
|
+import { StuColBatchVO, StuColBatchQuery, StuColBatchForm } from '@/api/XgStuColBatch/stuColBatch/types';
|
|
|
+import { setScope, getScope, getScopeDetail } from '@/api/stuColBatchClass/stuColBatchClass';
|
|
|
+import request from '@/utils/request';
|
|
|
+import { ElMessage } from 'element-plus';
|
|
|
+
|
|
|
+const { proxy } = getCurrentInstance() as ComponentInternalInstance;
|
|
|
+
|
|
|
+const stuColBatchList = ref<StuColBatchVO[]>([]);
|
|
|
+const buttonLoading = ref(false);
|
|
|
+const loading = ref(true);
|
|
|
+const showSearch = ref(true);
|
|
|
+const ids = ref<Array<string | number>>([]);
|
|
|
+const single = ref(true);
|
|
|
+const multiple = ref(true);
|
|
|
+const total = ref(0);
|
|
|
+
|
|
|
+const queryFormRef = ref<ElFormInstance>();
|
|
|
+const stuColBatchFormRef = ref<ElFormInstance>();
|
|
|
+
|
|
|
+const dialog = reactive<DialogOption>({
|
|
|
+ visible: false,
|
|
|
+ title: ''
|
|
|
+});
|
|
|
+
|
|
|
+// 收集范围弹窗相关数据
|
|
|
+const scopeDialog = reactive({
|
|
|
+ visible: false
|
|
|
+});
|
|
|
+const scopeButtonLoading = ref(false);
|
|
|
+const currentBatch = ref<StuColBatchVO | null>(null);
|
|
|
+const deptTreeData = ref<any[]>([]);
|
|
|
+const checkedDeptIds = ref<number[]>([]);
|
|
|
+const scopeTreeRef = ref();
|
|
|
+
|
|
|
+// 查看详细弹窗相关数据
|
|
|
+const viewDialog = reactive({
|
|
|
+ visible: false
|
|
|
+});
|
|
|
+const viewForm = ref<StuColBatchVO>({} as StuColBatchVO);
|
|
|
+const viewActiveTab = ref('basic');
|
|
|
+const scopeDetailList = ref<any[]>([]);
|
|
|
+
|
|
|
+const initFormData: StuColBatchForm = {
|
|
|
+ id: undefined,
|
|
|
+ batchName: undefined,
|
|
|
+ description: undefined,
|
|
|
+ startTime: new Date()
|
|
|
+ .toLocaleString('zh-CN', {
|
|
|
+ year: 'numeric',
|
|
|
+ month: '2-digit',
|
|
|
+ day: '2-digit',
|
|
|
+ hour: '2-digit',
|
|
|
+ minute: '2-digit',
|
|
|
+ second: '2-digit',
|
|
|
+ hour12: false
|
|
|
+ })
|
|
|
+ .replace(/\//g, '-'),
|
|
|
+ endTime: undefined,
|
|
|
+ status: '0',
|
|
|
+ collectionType: '1'
|
|
|
+};
|
|
|
+const data = reactive<PageData<StuColBatchForm, StuColBatchQuery>>({
|
|
|
+ form: { ...initFormData },
|
|
|
+ queryParams: {
|
|
|
+ pageNum: 1,
|
|
|
+ pageSize: 10,
|
|
|
+ batchName: undefined,
|
|
|
+ status: undefined,
|
|
|
+ collectionType: undefined,
|
|
|
+ params: {}
|
|
|
+ },
|
|
|
+ rules: {
|
|
|
+ id: [{ required: true, message: '批次ID不能为空', trigger: 'blur' }],
|
|
|
+ batchName: [{ required: true, message: '批次名称不能为空', trigger: 'blur' }],
|
|
|
+ startTime: [{ required: true, message: '开始时间不能为空', trigger: 'blur' }],
|
|
|
+ endTime: [{ required: true, message: '结束时间不能为空', trigger: 'blur' }],
|
|
|
+ status: [{ required: true, message: '状态不能为空', trigger: 'change' }],
|
|
|
+ collectionType: [{ required: true, message: '收集类型 1 - 新学期收集 2 - 其他 不能为空', trigger: 'change' }]
|
|
|
+ }
|
|
|
+});
|
|
|
+
|
|
|
+const { queryParams, form, rules } = toRefs(data);
|
|
|
+
|
|
|
+/** 查询学生信息收集批次列表 */
|
|
|
+const getList = async () => {
|
|
|
+ loading.value = true;
|
|
|
+ const res = await listStuColBatch(queryParams.value);
|
|
|
+ stuColBatchList.value = res.rows;
|
|
|
+ total.value = res.total;
|
|
|
+ loading.value = false;
|
|
|
+};
|
|
|
+
|
|
|
+/** 取消按钮 */
|
|
|
+const cancel = () => {
|
|
|
+ reset();
|
|
|
+ dialog.visible = false;
|
|
|
+};
|
|
|
+
|
|
|
+/** 表单重置 */
|
|
|
+const reset = () => {
|
|
|
+ form.value = { ...initFormData };
|
|
|
+ stuColBatchFormRef.value?.resetFields();
|
|
|
+};
|
|
|
+
|
|
|
+/** 搜索按钮操作 */
|
|
|
+const handleQuery = () => {
|
|
|
+ queryParams.value.pageNum = 1;
|
|
|
+ getList();
|
|
|
+};
|
|
|
+
|
|
|
+/** 重置按钮操作 */
|
|
|
+const resetQuery = () => {
|
|
|
+ queryFormRef.value?.resetFields();
|
|
|
+ handleQuery();
|
|
|
+};
|
|
|
+
|
|
|
+/** 多选框选中数据 */
|
|
|
+const handleSelectionChange = (selection: StuColBatchVO[]) => {
|
|
|
+ ids.value = selection.map((item) => item.id);
|
|
|
+ single.value = selection.length != 1;
|
|
|
+ multiple.value = !selection.length;
|
|
|
+};
|
|
|
+
|
|
|
+/** 新增按钮操作 */
|
|
|
+const handleAdd = () => {
|
|
|
+ reset();
|
|
|
+ dialog.visible = true;
|
|
|
+ dialog.title = '添加学生信息收集批次';
|
|
|
+};
|
|
|
+
|
|
|
+/** 修改按钮操作 */
|
|
|
+const handleUpdate = async (row?: StuColBatchVO) => {
|
|
|
+ reset();
|
|
|
+ const _id = row?.id || ids.value[0];
|
|
|
+ const res = await getStuColBatch(_id);
|
|
|
+ Object.assign(form.value, res.data);
|
|
|
+ dialog.visible = true;
|
|
|
+ dialog.title = '修改学生信息收集批次';
|
|
|
+};
|
|
|
+
|
|
|
+/** 提交按钮 */
|
|
|
+const submitForm = () => {
|
|
|
+ stuColBatchFormRef.value?.validate(async (valid: boolean) => {
|
|
|
+ if (valid) {
|
|
|
+ buttonLoading.value = true;
|
|
|
+ if (form.value.id) {
|
|
|
+ await updateStuColBatch(form.value).finally(() => (buttonLoading.value = false));
|
|
|
+ } else {
|
|
|
+ await addStuColBatch(form.value).finally(() => (buttonLoading.value = false));
|
|
|
+ }
|
|
|
+ proxy?.$modal.msgSuccess('操作成功');
|
|
|
+ dialog.visible = false;
|
|
|
+ await getList();
|
|
|
+ }
|
|
|
+ });
|
|
|
+};
|
|
|
+
|
|
|
+/** 删除按钮操作 */
|
|
|
+const handleDelete = async (row?: StuColBatchVO) => {
|
|
|
+ const _ids = row?.id || ids.value;
|
|
|
+ await proxy?.$modal.confirm('是否确认删除学生信息收集批次编号为"' + row?.batchName + '"的数据项?').finally(() => (loading.value = false));
|
|
|
+ await delStuColBatch(_ids);
|
|
|
+ proxy?.$modal.msgSuccess('删除成功');
|
|
|
+ await getList();
|
|
|
+};
|
|
|
+
|
|
|
+/** 导出按钮操作 */
|
|
|
+const handleExport = () => {
|
|
|
+ proxy?.download(
|
|
|
+ 'XgStuColBatch/stuColBatch/export',
|
|
|
+ {
|
|
|
+ ...queryParams.value
|
|
|
+ },
|
|
|
+ `stuColBatch_${new Date().getTime()}.xlsx`
|
|
|
+ );
|
|
|
+};
|
|
|
+
|
|
|
+/** 收集范围按钮操作 */
|
|
|
+const handleScope = async (row: StuColBatchVO) => {
|
|
|
+ currentBatch.value = row;
|
|
|
+ // 先清空勾选状态
|
|
|
+ checkedDeptIds.value = [];
|
|
|
+
|
|
|
+ await loadDeptTree();
|
|
|
+ await loadCurrentScope(row.id);
|
|
|
+ scopeDialog.visible = true;
|
|
|
+
|
|
|
+ // 使用nextTick确保DOM更新完成后再设置勾选状态
|
|
|
+ await nextTick();
|
|
|
+ if (scopeTreeRef.value && checkedDeptIds.value.length > 0) {
|
|
|
+ scopeTreeRef.value.setCheckedKeys(checkedDeptIds.value);
|
|
|
+ }
|
|
|
+};
|
|
|
+
|
|
|
+/** 加载部门树数据 */
|
|
|
+const loadDeptTree = async () => {
|
|
|
+ try {
|
|
|
+ loading.value = true;
|
|
|
+ const response = await request({
|
|
|
+ url: '/system/user/deptTree',
|
|
|
+ method: 'get',
|
|
|
+ params: {
|
|
|
+ belongDeptId: 101
|
|
|
+ }
|
|
|
+ });
|
|
|
+ if (response && response.code === 200) {
|
|
|
+ deptTreeData.value = response.data || [];
|
|
|
+ }
|
|
|
+ } catch (error) {
|
|
|
+ console.error('获取部门树数据失败:', error);
|
|
|
+ ElMessage.error('获取范围选项失败');
|
|
|
+ } finally {
|
|
|
+ loading.value = false;
|
|
|
+ }
|
|
|
+};
|
|
|
+
|
|
|
+/** 加载当前批次的收集范围 */
|
|
|
+const loadCurrentScope = async (batchId: string | number) => {
|
|
|
+ try {
|
|
|
+ checkedDeptIds.value = [];
|
|
|
+ const response = await getScope(batchId);
|
|
|
+ if (response && response.code === 200) {
|
|
|
+ checkedDeptIds.value = response.data || [];
|
|
|
+ } else {
|
|
|
+ checkedDeptIds.value = [];
|
|
|
+ }
|
|
|
+ } catch (error) {
|
|
|
+ console.error('加载收集范围失败:', error);
|
|
|
+ checkedDeptIds.value = [];
|
|
|
+ }
|
|
|
+};
|
|
|
+
|
|
|
+/** 构建树形数据 */
|
|
|
+const buildTree = (data: any[]) => {
|
|
|
+ // 如果数据已经是树形结构,直接转换格式
|
|
|
+ const convertToTreeNode = (item: any): any => {
|
|
|
+ return {
|
|
|
+ id: item.deptId,
|
|
|
+ label: item.deptName,
|
|
|
+ children: item.children ? item.children.map(convertToTreeNode) : []
|
|
|
+ };
|
|
|
+ };
|
|
|
+
|
|
|
+ return data.map(convertToTreeNode);
|
|
|
+};
|
|
|
+
|
|
|
+/** 提交收集范围 */
|
|
|
+const submitScope = async () => {
|
|
|
+ if (!currentBatch.value) return;
|
|
|
+
|
|
|
+ try {
|
|
|
+ scopeButtonLoading.value = true;
|
|
|
+ const checkedNodes = scopeTreeRef.value.getCheckedNodes();
|
|
|
+ const checkedIds = checkedNodes.map((node: any) => node.id);
|
|
|
+
|
|
|
+ // 调用后端API设置收集范围
|
|
|
+ const response = await setScope(currentBatch.value.id, checkedIds);
|
|
|
+
|
|
|
+ if (response && response.code === 200) {
|
|
|
+ ElMessage.success(response.msg || '收集范围设置成功');
|
|
|
+ scopeDialog.visible = false;
|
|
|
+ // 提交成功后清空状态
|
|
|
+ handleScopeDialogClose();
|
|
|
+ } else {
|
|
|
+ ElMessage.error(response?.msg || '设置收集范围失败');
|
|
|
+ }
|
|
|
+ } catch (error) {
|
|
|
+ console.error('设置收集范围失败:', error);
|
|
|
+ ElMessage.error('设置收集范围失败');
|
|
|
+ } finally {
|
|
|
+ scopeButtonLoading.value = false;
|
|
|
+ }
|
|
|
+};
|
|
|
+
|
|
|
+/** 取消收集范围设置 */
|
|
|
+const cancelScope = () => {
|
|
|
+ scopeDialog.visible = false;
|
|
|
+ currentBatch.value = null;
|
|
|
+ checkedDeptIds.value = [];
|
|
|
+ // 清空树形组件的勾选状态
|
|
|
+ if (scopeTreeRef.value) {
|
|
|
+ scopeTreeRef.value.setCheckedKeys([]);
|
|
|
+ }
|
|
|
+};
|
|
|
+
|
|
|
+/** 处理收集范围弹窗关闭 */
|
|
|
+const handleScopeDialogClose = () => {
|
|
|
+ // 清空相关状态
|
|
|
+ currentBatch.value = null;
|
|
|
+ checkedDeptIds.value = [];
|
|
|
+ // 清空树形组件的勾选状态
|
|
|
+ if (scopeTreeRef.value) {
|
|
|
+ scopeTreeRef.value.setCheckedKeys([]);
|
|
|
+ }
|
|
|
+};
|
|
|
+
|
|
|
+/** 查看详细按钮操作 */
|
|
|
+const handleView = async (row: StuColBatchVO) => {
|
|
|
+ try {
|
|
|
+ // 获取批次基本信息
|
|
|
+ const res = await getStuColBatch(row.id);
|
|
|
+ viewForm.value = res.data;
|
|
|
+
|
|
|
+ // 获取权限范围详细信息
|
|
|
+ await loadScopeDetail(row.id);
|
|
|
+
|
|
|
+ viewDialog.visible = true;
|
|
|
+ viewActiveTab.value = 'basic';
|
|
|
+ } catch (error) {
|
|
|
+ console.error('获取批次详情失败:', error);
|
|
|
+ proxy?.$modal.msgError('获取批次详情失败');
|
|
|
+ }
|
|
|
+};
|
|
|
+
|
|
|
+/** 加载权限范围详细信息 */
|
|
|
+const loadScopeDetail = async (batchId: string | number) => {
|
|
|
+ try {
|
|
|
+ const response = await getScopeDetail(batchId);
|
|
|
+ if (response && response.code === 200) {
|
|
|
+ scopeDetailList.value = response.data || [];
|
|
|
+ } else {
|
|
|
+ scopeDetailList.value = [];
|
|
|
+ }
|
|
|
+ } catch (error) {
|
|
|
+ console.error('加载权限范围详情失败:', error);
|
|
|
+ scopeDetailList.value = [];
|
|
|
+ }
|
|
|
+};
|
|
|
+
|
|
|
+/** 取消查看详细 */
|
|
|
+const cancelView = () => {
|
|
|
+ viewDialog.visible = false;
|
|
|
+ viewForm.value = {} as StuColBatchVO;
|
|
|
+ scopeDetailList.value = [];
|
|
|
+ viewActiveTab.value = 'basic';
|
|
|
+};
|
|
|
+
|
|
|
+onMounted(() => {
|
|
|
+ getList();
|
|
|
+});
|
|
|
+</script>
|
|
|
+
|
|
|
+<style scoped>
|
|
|
+.scope-detail-content {
|
|
|
+ padding: 10px 0;
|
|
|
+}
|
|
|
+
|
|
|
+.no-data {
|
|
|
+ text-align: center;
|
|
|
+ padding: 40px 0;
|
|
|
+}
|
|
|
+
|
|
|
+.mb-3 {
|
|
|
+ margin-bottom: 12px;
|
|
|
+}
|
|
|
+</style>
|