This commit is contained in:
zlwu committed 2026-01-09 18:04:36 +08:00
1 parent aec39f984b
commit e772cd1435
55 files changed
+4466 -652

No files matched your search

+178
View File
@@ -0,0 +1,178 @@
# 人员录入功能说明
## 📋 功能概述
人员录入功能支持录入正式工、临时工、外聘工三种类型的人员信息,包含完整的增删改查、导入导出功能。
## 🔧 功能特性
### 核心功能
- ✅ 人员信息录入(姓名、性别、职务、部门、手机号、工号)
- ✅ 工号自动生成(正式工0XXXXX、临时工LXXXXX、外聘工WXXXXX)
- ✅ 增删改查操作
- ✅ 数据同步(自动同步sys_user和sys_user_role表)
- ✅ 导入导出Excel功能
- ✅ 部门树形选择
### 工号规则
| 人员类型 | 工号格式 | 示例 |
|---------|---------|------|
| 正式工 | 0XXXXX | 000001 |
| 临时工 | LXXXXX | L00001 |
| 外聘工 | WXXXXX | W00001 |
## 📁 文件结构
```
backend/ruoyi-modules/ruoyi-rs/
├── domain/
│ ├── RsStaffInfo.java # 实体类
│ ├── vo/
│ │ ├── RsStaffInfoVo.java # 视图对象
│ │ └── RsStaffInfoImportVo.java # 导入VO
│ └── bo/
│ └── RsStaffInfoBo.java # 业务对象
├── mapper/
│ ├── RsStaffInfoMapper.java # 数据访问层接口
│ └── RsStaffInfoMapper.xml # MyBatis映射文件
├── service/
│ ├── IRsStaffInfoService.java # 服务接口
│ └── impl/
│ └── RsStaffInfoServiceImpl.java # 服务实现
├── listener/
│ └── RsStaffInfoImportListener.java # 导入监听器
└── controller/
└── RsStaffInfoController.java # 控制器
web/src/views/rs/staff-info/
├── index.vue # 主页面
└── README.md # 说明文档
web/src/api/rs/staffInfo/
├── index.ts # API接口
└── types.ts # 类型定义
```
## 🔌 API接口
### 主要接口
- `GET /staff/staffInfo/list` - 查询人员列表
- `POST /staff/staffInfo/listByDeptId` - 根据部门查询人员列表
- `GET /staff/staffInfo/{id}` - 获取人员详情
- `POST /staff/staffInfo` - 新增人员
- `PUT /staff/staffInfo` - 修改人员
- `DELETE /staff/staffInfo/{ids}` - 删除人员
- `GET /staff/staffInfo/deptTree` - 获取部门树
- `POST /staff/staffInfo/importData` - 导入人员数据
- `POST /staff/staffInfo/importTemplate` - 下载导入模板
- `POST /staff/staffInfo/export` - 导出人员数据
## 📊 数据同步逻辑
### 新增人员时同步操作
1. 在`rs_staff_info`表插入人员记录
2. 自动生成工号(根据人员类型)
3. 在`sys_user`表创建用户记录
4. 在`sys_user_role`表添加角色(4和1938120323613728770)
### 修改人员时同步操作
1. 更新`rs_staff_info`表记录
2. 同步更新`sys_user`表的对应字段
### 删除人员时同步操作
1. 逻辑删除`rs_staff_info`表记录
2. 逻辑删除`sys_user`表对应记录
3. 级联删除`sys_user_role`表记录
## 📥 导入导出功能
### 导入模板格式
```excel
| 姓名 | 性别 | 职务 | 部门名称 | 手机号 | 人员类型 |
|------|------|------|----------|--------|----------|
| 张三 | 男 | 讲师 | 计算机学院 | 13800138000 | 正式工 |
```
### 模板特性
- **性别列**:下拉选择(男/女)
- **人员类型列**:下拉选择(正式工/临时工/外聘工)
- **数据验证**:自动校验必填字段和格式
### 导入验证规则
- 姓名:必填
- 性别:必填,必须是"男"或"女"
- 部门名称:必填,必须存在于系统中
- 手机号:必填,11位数字格式,且系统中唯一
- 人员类型:必填,必须是"正式工"、"临时工"或"外聘工"
## 🎨 前端页面布局
### 页面结构
```
├── 左侧部门树
│ ├── 部门搜索框
│ └── 部门树形结构
└── 右侧内容区域
├── 搜索表单
│ ├── 姓名、工号、手机号等查询条件
│ └── 时间范围选择
├── 操作按钮栏
│ ├── 新增、修改、删除按钮
│ └── 导入、导出按钮
└── 数据表格
├── 工号、姓名、性别等列
└── 操作列(修改、删除、详情)
```
### 交互逻辑
1. **部门选择**:点击左侧部门树节点,右侧显示该部门人员
2. **搜索过滤**:支持多条件组合查询
3. **批量操作**:支持批量删除
4. **导入导出**:完整的Excel导入导出流程
## 🔧 使用说明
### 1. 访问页面
在系统菜单中配置人员录入功能入口,路径为:`/rs/staff-info`
### 2. 新增人员
1. 选择左侧部门节点
2. 点击"新增"按钮
3. 填写人员信息
4. 系统自动生成工号
5. 点击"确定"保存
### 3. 导入人员
1. 选择左侧部门节点
2. 点击"更多" → "导入数据"
3. 下载导入模板
4. 按照模板格式填写数据
5. 上传Excel文件
6. 查看导入结果
### 4. 导出人员
1. 设置查询条件(可选)
2. 点击"更多" → "导出数据"
3. 系统自动下载Excel文件
## ⚠️ 注意事项
1. **部门选择**:导入和新增操作前必须先选择部门节点
2. **数据唯一性**:手机号在整个系统中必须唯一
3. **工号生成**:工号自动生成,无需手动填写
4. **角色分配**:新增人员自动分配默认角色
5. **权限控制**:不同操作需要相应权限
## 🔄 数据流转
```
用户操作 → 前端页面 → API接口 → 控制器 → 服务层 → 数据访问层 → 数据库
↑ ↓
导入文件 ← Excel处理 ← 导入监听器 ← 业务验证 ← 数据转换 ← 自动生成工号
↑ ↓
导出文件 ← Excel生成 ← 模板下载 ← 查询结果 ← 条件筛选 ← 用户查询
```
## 📞 技术支持
如有问题,请联系开发团队或查看系统日志获取详细错误信息。
File diff suppressed because it is too large. Load diff
@@ -73,12 +73,7 @@
collapse-tags-tooltip
@change="handleQuery"
>
<el-option
v-for="status in student_status"
:key="status.value"
:label="status.label"
:value="status.value"
/>
<el-option v-for="status in student_status" :key="status.value" :label="status.label" :value="status.value" />
</el-select>
</el-form-item>
</el-col>
@@ -108,6 +103,20 @@
<el-col :span="1.5">
<el-button icon="Refresh" @click="handleRefresh">刷新</el-button>
</el-col>
<el-col :span="1.5">
<el-dropdown class="mt-[1px]">
<el-button>
更多
<el-icon class="el-icon--right"><ArrowDown /></el-icon>
</el-button>
<template #dropdown>
<el-dropdown-menu>
<el-dropdown-item icon="Download" @click="handleImportTemplate">下载模板</el-dropdown-item>
<el-dropdown-item icon="Top" @click="handleImportData">导入数据</el-dropdown-item>
</el-dropdown-menu>
</template>
</el-dropdown>
</el-col>
<RightToolbar v-model:show-search="showSearch" :columns="columns" :search="true" @query-table="getList"></RightToolbar>
</el-row>
</template>
@@ -120,8 +129,8 @@
v-model="batchModalForm.score"
:min="0"
:max="100"
:precision="2"
:step="0.5"
:precision="0"
:step="1"
size="small"
placeholder="输入分数"
style="width: 100%"
@@ -146,6 +155,70 @@
</template>
</el-dialog>
<!-- 导入数据弹窗 -->
<el-dialog
v-model="importModalVisible"
title="导入操行分数据"
width="500px"
append-to-body
:close-on-click-modal="false"
destroy-on-close
>
<div class="mb-4">
<div class="text-sm text-gray-600 mb-2">
<strong>当前录入条件:</strong>
{{ queryParams.academicYear - 1 }}-{{ queryParams.academicYear }}学年
{{ queryParams.semester === 1 ? '第一学期' : '第二学期' }}
{{ queryParams.month }}月
{{ activeTab ? `(${classTabs.find((tab) => tab.classId.toString() === activeTab)?.className})` : '' }}
</div>
<div class="text-sm text-red-600 mb-3">
<el-icon class="mr-1"><InfoFilled /></el-icon>
如果学生已有该月份的分数记录,将被Excel中的数据覆盖
</div>
</div>
<el-upload
ref="importUploadRef"
:limit="1"
accept=".xlsx, .xls"
:headers="importUpload.headers"
:action="getImportUrl()"
:disabled="importUpload.isUploading"
:on-progress="handleImportFileUploadProgress"
:on-success="handleImportFileSuccess"
:on-error="handleImportFileError"
:auto-upload="false"
drag
>
<el-icon class="el-icon--upload">
<i-ep-upload-filled />
</el-icon>
<div class="el-upload__text">将文件拖到此处,或<em>点击上传</em></div>
<template #tip>
<div class="text-center el-upload__tip">
<div class="el-upload__tip" style="color: #409eff; margin-bottom: 5px">模板包含4列:学号、学生姓名、分数、备注</div>
<div class="el-upload__tip" style="color: red">仅处理班主任负责班级的学生数据,学号不存在或姓名不匹配的数据将被跳过</div>
<span>仅允许导入xls、xlsx格式文件。</span>
<el-link
type="primary"
:underline="false"
style="font-size: 12px; vertical-align: baseline; margin-left: 10px"
@click="handleImportTemplate"
>
下载模板
</el-link>
</div>
</template>
</el-upload>
<template #footer>
<div class="dialog-footer">
<el-button @click="importModalVisible = false">取消</el-button>
<el-button type="primary" @click="submitImportFile" :loading="importUpload.isUploading">确定导入</el-button>
</div>
</template>
</el-dialog>
<el-table
v-if="currentClassStudents && currentClassStudents.length > 0"
v-loading="tabLoading"
@@ -189,7 +262,7 @@
</el-table-column>
<el-table-column v-if="columns[3].visible" key="score" label="分数" align="center" width="150">
<template #default="scope">
<el-input-number v-model="scope.row.score" :min="0" :max="100" :precision="2" :step="0.5" size="small" placeholder="输入分数" />
<el-input-number v-model="scope.row.score" :min="0" :max="100" :precision="0" :step="1" size="small" placeholder="输入分数" />
</template>
</el-table-column>
<el-table-column v-if="columns[4].visible" key="evaluation" label="评判结果" align="center" width="100">
@@ -250,9 +323,11 @@
</template>
<script setup lang="ts" name="ConductScoreInput">
import { ref, reactive, onMounted, computed, getCurrentInstance, toRefs } from 'vue';
import { ref, reactive, onMounted, computed, getCurrentInstance, toRefs, nextTick } from 'vue';
import ElMessage from 'element-plus/es/components/message/index';
import ElMessageBox from 'element-plus/es/components/message-box/index';
import { ArrowDown, InfoFilled } from '@element-plus/icons-vue';
import { globalHeaders } from '@/utils/request';
// API接口
import { conductScoreClassStudents, conductScoreBatchAdd } from '@/api/xg/conductScore';
@@ -265,7 +340,20 @@ const { student_status } = toRefs<any>(proxy?.useDict('student_status'));
// 响应式数据
const queryParams = reactive({
academicYear: new Date().getFullYear(),
academicYear: (() => {
const now = new Date();
const currentYear = now.getFullYear();
const currentMonth = now.getMonth() + 1; // 1-12
const currentDate = now.getDate();
// 判断是否在9月1日之后(包括9月1日)
// 如果是9月之后,或者是9月1日及之后,则属于下一学年
if (currentMonth > 9 || (currentMonth === 9 && currentDate >= 1)) {
return currentYear + 1; // 下一学年,如2026年9月1日后,选中2026-2027学年(值为2027)
} else {
return currentYear; // 当前学年,如2026年9月1日前,选中2025-2026学年(值为2026)
}
})(),
semester: 1,
month: new Date().getMonth() + 1,
studentNo: '',
@@ -355,10 +443,14 @@ const queryFormRef = ref();
// 选项数据
const yearOptions = computed(() => {
const currentYear = new Date().getFullYear();
return Array.from({ length: 8 }, (_, i) => ({
label: `${currentYear - 7 + i}年`,
value: currentYear - 7 + i
}));
// 生成9个学年选项(往前7个 + 当前1个 + 往后多生成1个)
return Array.from({ length: 9 }, (_, i) => {
const yearValue = currentYear - 7 + i;
return {
label: `${yearValue - 1}-${yearValue}学年`,
value: yearValue
};
});
});
const semesterOptions = [
@@ -601,6 +693,15 @@ const batchModalForm = reactive({
remark: ''
});
// 导入数据相关
const importModalVisible = ref(false);
const importUploadRef = ref<any>();
const importUpload = reactive({
isUploading: false,
headers: globalHeaders(),
url: ''
});
const confirmBatchModalSave = () => {
// 批量录入弹窗填写的分数/备注将应用到所有已勾选的学生(包含已录入的,视为覆盖)
const targets = selectedStudents.value || [];
@@ -662,6 +763,90 @@ const handleSelectionChange = (selection) => {
selectedStudents.value = selection;
};
// 导入相关方法
const handleImportData = () => {
if (!activeTab.value) {
ElMessage.warning('请先选择要导入数据的班级');
return;
}
importModalVisible.value = true;
};
const handleImportTemplate = () => {
proxy?.download('xg/conduct-score/importTemplate', {}, `操行分导入模板_${new Date().getTime()}.xlsx`);
};
const getImportUrl = () => {
const baseUrl = import.meta.env.VITE_APP_BASE_API + '/xg/conduct-score/importData';
const params = new URLSearchParams();
params.append('academicYear', queryParams.academicYear.toString());
params.append('semester', queryParams.semester.toString());
params.append('month', queryParams.month.toString());
// 如果选择了特定班级,则只导入该班级数据
if (activeTab.value) {
params.append('classId', activeTab.value);
}
return `${baseUrl}?${params.toString()}`;
};
const handleImportFileUploadProgress = () => {
importUpload.isUploading = true;
};
const handleImportFileSuccess = (response) => {
importModalVisible.value = false;
importUpload.isUploading = false;
importUploadRef.value[0]?.clearFiles();
ElMessage.closeAll();
ElMessageBox.alert("<div style='overflow: auto;overflow-x: hidden;max-height: 70vh;padding: 10px 20px 0;'>" + response.msg + '</div>', '导入结果', {
dangerouslyUseHTMLString: true
});
// 刷新数据
getList();
};
const handleImportFileError = (error) => {
importUpload.isUploading = false;
importUploadRef.value[0]?.clearFiles();
ElMessage.closeAll();
console.error('文件上传失败:', error);
ElMessage.error('导入失败,请检查文件格式或网络连接');
};
const submitImportFile = () => {
if (!importUploadRef.value || !importUploadRef.value[0]) {
ElMessage.error('上传组件未初始化');
return;
}
ElMessage({
message: '正在导入数据,请耐心等待...',
type: 'info',
duration: 0,
zIndex: 4000
});
importUpload.isUploading = true;
// 使用 nextTick 确保组件已完全挂载
nextTick(() => {
try {
importUploadRef.value[0]?.submit();
} catch (error) {
console.error('Submit error:', error);
ElMessage.error('上传失败:' + error.message);
importUpload.isUploading = false;
}
});
};
// 生命周期
onMounted(() => {
getList();
@@ -184,7 +184,11 @@
width="100"
:show-overflow-tooltip="true"
/>
<el-table-column v-if="columns[5].visible" key="academicYear" label="学年" align="center" prop="academicYear" width="80" />
<el-table-column v-if="columns[5].visible" key="academicYear" label="学年" align="center" width="120">
<template #default="scope">
{{ scope.row.academicYear ? `${scope.row.academicYear - 1}-${scope.row.academicYear}学年` : '-' }}
</template>
</el-table-column>
<el-table-column v-if="columns[6].visible" key="semester" label="学期" align="center" prop="semester" width="80">
<template #default="scope">
{{ scope.row.semester === 1 ? '第一学期' : '第二学期' }}
@@ -345,7 +349,20 @@ const { xg_class_status } = toRefs<any>(proxy?.useDict('xg_class_status'));
const queryParams = reactive({
pageNum: 1,
pageSize: 10,
academicYear: new Date().getFullYear(),
academicYear: (() => {
const now = new Date();
const currentYear = now.getFullYear();
const currentMonth = now.getMonth() + 1; // 1-12
const currentDate = now.getDate();
// 判断是否在9月1日之后(包括9月1日)
// 如果是9月之后,或者是9月1日及之后,则属于下一学年
if (currentMonth > 9 || (currentMonth === 9 && currentDate >= 1)) {
return currentYear + 1; // 下一学年,如2026年9月1日后,选中2026-2027学年(值为2027)
} else {
return currentYear; // 当前学年,如2026年9月1日前,选中2025-2026学年(值为2026)
}
})(),
semester: 1,
month: new Date().getMonth() + 1, // 默认当前月份
studentName: '',
@@ -428,11 +445,14 @@ const modalMode = ref<'single' | 'batch'>('single');
// 选项数据
const yearOptions = computed(() => {
const currentYear = new Date().getFullYear();
// 历史8年:从 currentYear - 7 到 currentYear
return Array.from({ length: 8 }, (_, i) => ({
label: `${currentYear - 7 + i}年`,
value: currentYear - 7 + i
}));
// 生成9个学年选项(往前7个 + 当前1个 + 往后多生成1个)
return Array.from({ length: 9 }, (_, i) => {
const yearValue = currentYear - 7 + i;
return {
label: `${yearValue - 1}-${yearValue}学年`,
value: yearValue
};
});
});
const semesterOptions = [
@@ -916,7 +936,8 @@ const handleExport = () => {
{
...queryParams,
...proxy?.addDateRange(queryParams, dateRange.value),
includeEvaluation: true // 添加标识,表示需要包含评判结果
includeEvaluation: true, // 添加标识,表示需要包含评判结果
academicYearFormat: 'friendly' // 添加标识,表示需要将学年格式化为友好形式(如2025-2026学年)
},
`conduct_score_${new Date().getTime()}.xlsx`
)
@@ -44,7 +44,7 @@
<transition enter-active-class="animate__animated animate__fadeIn" leave-active-class="animate__animated animate__fadeOut">
<div v-show="showSearch" class="mb-[10px]">
<el-card shadow="hover">
<el-form ref="queryFormRef" :model="queryParams">
<el-form ref="queryFormRef" :model="queryParams" label-width="80px">
<el-row :gutter="20">
<el-col :span="6">
<el-form-item label="学年" prop="academicYear">
@@ -357,7 +357,20 @@ const { xg_class_status } = toRefs<any>(proxy?.useDict('xg_class_status'));
const queryParams = reactive({
pageNum: 1,
pageSize: 10,
academicYear: new Date().getFullYear(),
academicYear: (() => {
const now = new Date();
const currentYear = now.getFullYear();
const currentMonth = now.getMonth() + 1; // 1-12
const currentDate = now.getDate();
// 判断是否在9月1日之后(包括9月1日)
// 如果是9月之后,或者是9月1日及之后,则属于下一学年
if (currentMonth > 9 || (currentMonth === 9 && currentDate >= 1)) {
return currentYear + 1; // 下一学年,如2026年9月1日后,选中2026-2027学年(值为2027)
} else {
return currentYear; // 当前学年,如2026年9月1日前,选中2025-2026学年(值为2026)
}
})(),
semester: 1,
className: '',
studentName: '',
@@ -431,11 +444,14 @@ const monthlyRecords = ref([]);
// 选项数据
const yearOptions = computed(() => {
const currentYear = new Date().getFullYear();
// 历史8年:从 currentYear - 7 到 currentYear
return Array.from({ length: 8 }, (_, i) => ({
label: `${currentYear - 7 + i}年`,
value: currentYear - 7 + i
}));
// 生成9个学年选项(往前7个 + 当前1个 + 往后多生成1个)
return Array.from({ length: 9 }, (_, i) => {
const yearValue = currentYear - 7 + i;
return {
label: `${yearValue - 1}-${yearValue}学年`,
value: yearValue
};
});
});
const semesterOptions = [
@@ -898,7 +914,8 @@ const handleExport = () => {
'xg/conduct-score/export-semester',
{
...queryParams,
...proxy?.addDateRange(queryParams, dateRange.value)
...proxy?.addDateRange(queryParams, dateRange.value),
academicYearFormat: 'friendly' // 添加标识,表示需要将学年格式化为友好形式(如2025-2026学年)
},
`semester_statistics_${new Date().getTime()}.xlsx`
)
@@ -188,10 +188,10 @@
<el-table-column label="操作" fixed="right" width="240" class-name="small-padding fixed-width">
<template #default="scope">
<el-tooltip content="修改" placement="top">
<el-button link type="primary" icon="Edit" @click="handleUpdate(scope.row)"></el-button>
<el-button v-hasPermi="['stu:studentMsg:update']" link type="primary" icon="Edit" @click="handleUpdate(scope.row)"></el-button>
</el-tooltip>
<el-tooltip content="删除" placement="top">
<el-button link type="danger" icon="Delete" @click="handleDelete(scope.row)"></el-button>
<el-button v-hasPermi="['stu:studentMsg:delete']" link type="danger" icon="Delete" @click="handleDelete(scope.row)"></el-button>
</el-tooltip>
<!--
<el-tooltip content="重置密码" placement="top">