Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
73d80507d9 | ||
|
|
7f9d3830ad | ||
|
|
fcb695664b |
No files matched your search
+15
@@ -55,6 +55,21 @@ public class XgConductScoreClassStudentVo {
|
||||
*/
|
||||
private XgConductScoreDetailVo existingScore;
|
||||
|
||||
/**
|
||||
* 待审核记录ID。有值表示该月修改已提交、尚未审核
|
||||
*/
|
||||
private Long pendingAuditId;
|
||||
|
||||
/**
|
||||
* 待审核的新分数
|
||||
*/
|
||||
private BigDecimal pendingScore;
|
||||
|
||||
/**
|
||||
* 待审核的新备注
|
||||
*/
|
||||
private String pendingRemark;
|
||||
|
||||
/**
|
||||
* 创建者
|
||||
*/
|
||||
|
||||
+7
@@ -112,4 +112,11 @@ public interface IXgConductScoreAuditService {
|
||||
*/
|
||||
Boolean batchInsertAudits(List<XgConductScoreAudit> auditList);
|
||||
|
||||
/**
|
||||
* 保存一条待审核记录。该学生当月已有记录时更新原记录并重新置为待审核,避免唯一约束导致再次提交失败。
|
||||
*
|
||||
* @param audit 待审核记录
|
||||
*/
|
||||
void saveOrUpdatePending(XgConductScoreAudit audit);
|
||||
|
||||
}
|
||||
+73
-1
@@ -1,12 +1,13 @@
|
||||
package org.dromara.xg.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import org.springframework.dao.DuplicateKeyException;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.dromara.common.core.exception.ServiceException;
|
||||
import org.dromara.common.core.utils.MapstructUtils;
|
||||
import org.dromara.common.core.utils.ObjectUtils;
|
||||
import org.dromara.common.core.utils.StringUtils;
|
||||
import org.dromara.common.mybatis.core.page.PageQuery;
|
||||
import org.dromara.common.mybatis.core.page.TableDataInfo;
|
||||
@@ -289,6 +290,77 @@ public class XgConductScoreAuditServiceImpl implements IXgConductScoreAuditServi
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* 同一学生、学年、学期、月份只保留一条未删除审核记录。
|
||||
* 待审核时覆盖新分数;已通过或已驳回时清空审核信息并重新置为待审核。
|
||||
*/
|
||||
@Override
|
||||
public void saveOrUpdatePending(XgConductScoreAudit audit) {
|
||||
if (audit.getDeleted() == null) {
|
||||
audit.setDeleted(0);
|
||||
}
|
||||
validEntityBeforeSave(audit);
|
||||
try {
|
||||
XgConductScoreAudit existing = findPeriodAudit(audit);
|
||||
if (existing == null) {
|
||||
xgConductScoreAuditMapper.insert(audit);
|
||||
return;
|
||||
}
|
||||
reopenPending(existing.getId(), audit);
|
||||
} catch (DuplicateKeyException ex) {
|
||||
XgConductScoreAudit existing = findPeriodAudit(audit);
|
||||
if (existing == null) {
|
||||
throw ex;
|
||||
}
|
||||
reopenPending(existing.getId(), audit);
|
||||
}
|
||||
}
|
||||
|
||||
private XgConductScoreAudit findPeriodAudit(XgConductScoreAudit audit) {
|
||||
LambdaQueryWrapper<XgConductScoreAudit> lqw = Wrappers.lambdaQuery();
|
||||
lqw.eq(XgConductScoreAudit::getStudentId, audit.getStudentId())
|
||||
.eq(XgConductScoreAudit::getAcademicYear, audit.getAcademicYear())
|
||||
.eq(XgConductScoreAudit::getSemester, audit.getSemester())
|
||||
.eq(XgConductScoreAudit::getMonth, audit.getMonth())
|
||||
.eq(XgConductScoreAudit::getDeleted, 0)
|
||||
.orderByAsc(XgConductScoreAudit::getAuditStatus)
|
||||
.orderByDesc(XgConductScoreAudit::getId)
|
||||
.last("LIMIT 1");
|
||||
return xgConductScoreAuditMapper.selectOne(lqw);
|
||||
}
|
||||
|
||||
private void reopenPending(Long auditId, XgConductScoreAudit audit) {
|
||||
Date now = new Date();
|
||||
LambdaUpdateWrapper<XgConductScoreAudit> update = Wrappers.lambdaUpdate();
|
||||
update.eq(XgConductScoreAudit::getId, auditId)
|
||||
.set(XgConductScoreAudit::getClassId, audit.getClassId())
|
||||
.set(XgConductScoreAudit::getOldScore, audit.getOldScore())
|
||||
.set(XgConductScoreAudit::getNewScore, audit.getNewScore())
|
||||
.set(XgConductScoreAudit::getApplyUserId, audit.getApplyUserId())
|
||||
.set(XgConductScoreAudit::getApplyUserName, audit.getApplyUserName())
|
||||
.set(XgConductScoreAudit::getApplyTime, audit.getApplyTime() != null ? audit.getApplyTime() : now)
|
||||
.set(XgConductScoreAudit::getApplyReason, audit.getApplyReason())
|
||||
.set(XgConductScoreAudit::getAuditStatus, 0)
|
||||
.set(XgConductScoreAudit::getUpdateBy, audit.getApplyUserId())
|
||||
.set(XgConductScoreAudit::getUpdateTime, now);
|
||||
// 备注和审核人允许为空,显式写成 SQL,避免更新策略把 null 丢掉
|
||||
if (audit.getOldRemark() == null) {
|
||||
update.setSql("old_remark = null");
|
||||
} else {
|
||||
update.set(XgConductScoreAudit::getOldRemark, audit.getOldRemark());
|
||||
}
|
||||
if (audit.getNewRemark() == null) {
|
||||
update.setSql("new_remark = null");
|
||||
} else {
|
||||
update.set(XgConductScoreAudit::getNewRemark, audit.getNewRemark());
|
||||
}
|
||||
update.setSql("audit_user_id = null")
|
||||
.setSql("audit_user_name = null")
|
||||
.setSql("audit_time = null")
|
||||
.setSql("audit_remark = null");
|
||||
xgConductScoreAuditMapper.update(null, update);
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存前的数据校验
|
||||
*/
|
||||
|
||||
+30
-15
@@ -409,8 +409,10 @@ public class XgConductScoreServiceImpl implements IXgConductScoreService {
|
||||
List<String> failList = new ArrayList<>();
|
||||
int successCount = 0;
|
||||
int failCount = 0;
|
||||
|
||||
List<XgConductScoreAudit> auditList = new ArrayList<>();
|
||||
String applyUserName = StringUtils.blankToDefault(LoginHelper.getNickname(), LoginHelper.getUsername());
|
||||
if (StringUtils.isBlank(applyUserName)) {
|
||||
applyUserName = "班主任";
|
||||
}
|
||||
|
||||
for (var item : bo.getScores()) {
|
||||
try {
|
||||
@@ -440,9 +442,9 @@ public class XgConductScoreServiceImpl implements IXgConductScoreService {
|
||||
continue;
|
||||
}
|
||||
|
||||
// 检查是否有实际的修改(分数或备注不同)
|
||||
boolean hasScoreChange = !item.getScore().equals(existingRecord.getScore());
|
||||
boolean hasRemarkChange = !ObjectUtils.equals(item.getRemark(), existingRecord.getRemark());
|
||||
// compareTo 按数值比较,避免 85 和 85.00 被当成不同分数
|
||||
boolean hasScoreChange = !scoreEquals(item.getScore(), existingRecord.getScore());
|
||||
boolean hasRemarkChange = !remarkEquals(item.getRemark(), existingRecord.getRemark());
|
||||
|
||||
if (!hasScoreChange && !hasRemarkChange) {
|
||||
failList.add("学生ID:" + item.getStudentId() + " - 无实际修改内容");
|
||||
@@ -450,7 +452,7 @@ public class XgConductScoreServiceImpl implements IXgConductScoreService {
|
||||
continue;
|
||||
}
|
||||
|
||||
// 创建审核记录
|
||||
// 创建审核记录。已有当月审核时更新原记录,不再新增,避免唯一约束冲突
|
||||
XgConductScoreAudit audit = new XgConductScoreAudit();
|
||||
audit.setTenantId(tenantId);
|
||||
audit.setStudentId(item.getStudentId());
|
||||
@@ -463,14 +465,14 @@ public class XgConductScoreServiceImpl implements IXgConductScoreService {
|
||||
audit.setNewScore(item.getScore());
|
||||
audit.setNewRemark(item.getRemark());
|
||||
audit.setApplyUserId(teacherId);
|
||||
audit.setApplyUserName(LoginHelper.getUsername());
|
||||
audit.setApplyUserName(applyUserName);
|
||||
audit.setApplyTime(new Date());
|
||||
audit.setApplyReason("班主任修改操行分");
|
||||
audit.setAuditStatus(0); // 待审核
|
||||
audit.setAuditStatus(0);
|
||||
audit.setDeleted(0);
|
||||
audit.setCreateBy(teacherId);
|
||||
audit.setCreateTime(new Date());
|
||||
|
||||
auditList.add(audit);
|
||||
auditService.saveOrUpdatePending(audit);
|
||||
successCount++;
|
||||
|
||||
} catch (Exception e) {
|
||||
@@ -480,11 +482,6 @@ public class XgConductScoreServiceImpl implements IXgConductScoreService {
|
||||
}
|
||||
}
|
||||
|
||||
// 批量提交审核
|
||||
if (!auditList.isEmpty()) {
|
||||
auditService.batchInsertAudits(auditList);
|
||||
}
|
||||
|
||||
XgConductScoreBatchResultVo result = new XgConductScoreBatchResultVo();
|
||||
result.setSuccessCount(successCount);
|
||||
result.setFailCount(failCount);
|
||||
@@ -556,6 +553,13 @@ public class XgConductScoreServiceImpl implements IXgConductScoreService {
|
||||
existingScore.setScore(BigDecimal.valueOf(((Number) row.get("existing_score")).doubleValue()));
|
||||
}
|
||||
existingScore.setRemark((String) row.get("existing_remark"));
|
||||
if (row.get("pending_audit_id") != null) {
|
||||
studentVo.setPendingAuditId(((Number) row.get("pending_audit_id")).longValue());
|
||||
if (row.get("pending_score") != null) {
|
||||
studentVo.setPendingScore(new BigDecimal(row.get("pending_score").toString()));
|
||||
}
|
||||
studentVo.setPendingRemark(row.get("pending_remark") == null ? null : row.get("pending_remark").toString());
|
||||
}
|
||||
if (row.get("existing_create_time") instanceof java.time.LocalDateTime) {
|
||||
existingScore
|
||||
.setCreateTime(DateUtils.toDate((java.time.LocalDateTime) row.get("existing_create_time")));
|
||||
@@ -699,6 +703,17 @@ public class XgConductScoreServiceImpl implements IXgConductScoreService {
|
||||
* @param teacherId 班主任ID
|
||||
* @return 是否有权限
|
||||
*/
|
||||
private boolean scoreEquals(BigDecimal left, BigDecimal right) {
|
||||
if (left == null || right == null) {
|
||||
return left == right;
|
||||
}
|
||||
return left.compareTo(right) == 0;
|
||||
}
|
||||
|
||||
private boolean remarkEquals(String left, String right) {
|
||||
return StringUtils.trimToEmpty(left).equals(StringUtils.trimToEmpty(right));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean checkTeacherPermission(Long classId, Long teacherId) {
|
||||
return baseMapper.checkTeacherClass(teacherId, classId);
|
||||
|
||||
+10
-1
@@ -326,7 +326,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
cs_current.id AS score_id,
|
||||
cs_current.score AS existing_score,
|
||||
cs_current.remark AS existing_remark,
|
||||
cs_current.create_time AS existing_create_time
|
||||
cs_current.create_time AS existing_create_time,
|
||||
au.id AS pending_audit_id,
|
||||
au.new_score AS pending_score,
|
||||
au.new_remark AS pending_remark
|
||||
FROM (
|
||||
SELECT
|
||||
c.id AS class_id,
|
||||
@@ -347,6 +350,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
AND cs_current.semester = #{semester}
|
||||
AND cs_current.month = #{month}
|
||||
AND cs_current.deleted = 0
|
||||
LEFT JOIN xg_conduct_score_audit au ON s.id = au.student_id
|
||||
AND au.academic_year = #{academicYear}
|
||||
AND au.semester = #{semester}
|
||||
AND au.month = #{month}
|
||||
AND au.deleted = 0
|
||||
AND au.audit_status = 0
|
||||
LEFT JOIN (
|
||||
SELECT
|
||||
cs_inner.student_id,
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
## 假期留宿
|
||||
|
||||
学生和管理员只选日期。保存时开始日写成当天 08:00:00,结束日写成最后一晚的次日 08:00:00。已经是次日 08:00:00 的记录再次保存时不再加一天。待审、已通过可以按寝室号搜索,列表按开始日期升序。
|
||||
学生和管理员只选日期。保存时开始日写成当天 08:00:00,结束日写成最后一晚的次日 08:00:00。已经是次日 08:00:00 的记录再次保存时不再加一天。待审、已通过可以按寝室号搜索,列表按开始日期升序。申请不再填写原因类型,只保留留宿原因文字。
|
||||
|
||||
## 寝室点名
|
||||
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
|------|------|
|
||||
| holidayType | 假期类型 |
|
||||
| applyStartDate / applyEndDate | 留宿起止时间 |
|
||||
| stayReason | 留宿原因 |
|
||||
| stayReason | 留宿原因(自由填写,不再采集原因类型) |
|
||||
| studentPhone | 学生联系电话(档案无电话时须前端手动填写) |
|
||||
| emergencyContact | 紧急联系人 |
|
||||
| emergencyPhone | 紧急联系电话 |
|
||||
|
||||
@@ -47,6 +47,7 @@
|
||||
| 接口名称 | 请求方式 | 路径 | 权限字符 | 功能描述 |
|
||||
| -------- | -------- | ---- | -------- | -------- |
|
||||
| 批量录入操行分 | POST | /api/xg/conduct-score/batch | xg:conduct:score:batchAdd | 批量保存操行分 |
|
||||
| 批量提交修改审核 | POST | /api/xg/conduct-score/batch-update | xg:conductScore:batchUpdate | 已录入分数的修改只写审核表,审核通过后才改正式分数 |
|
||||
| 班主任班级学生 | GET | /api/xg/conduct-score/class-students | xg:conduct:score:classStudents | 获取班主任班级学生列表 |
|
||||
| 学期平均分统计 | GET | /api/xg/conduct-score/semester-average | xg:conduct:score:semester | 查询学期平均分 |
|
||||
| 导出学期统计 | GET | /api/xg/conduct-score/export-semester | xg:conduct:score:export | 导出学期统计数据 |
|
||||
@@ -165,6 +166,18 @@
|
||||
}
|
||||
```
|
||||
|
||||
### 2.1 批量提交修改审核
|
||||
|
||||
#### 接口信息
|
||||
- **请求方式**: POST
|
||||
- **接口路径**: `/api/xg/conduct-score/batch-update`
|
||||
- **权限字符**: `xg:conductScore:batchUpdate`
|
||||
- **接口描述**: 班主任修改已录入的操行分。正式分数不变,生成或更新待审核记录,管理员审核通过后才写入正式表。
|
||||
|
||||
同一学生、同一学年、学期、月份只保留一条未删除审核记录。当月没有审核记录时新增;已经是待审核时覆盖新分数和新备注;已经通过或驳回时,清空原审核人并把该记录重新置为待审核。
|
||||
|
||||
班级学生列表会返回 `pendingAuditId`、`pendingScore`、`pendingRemark`。录入页据此在刷新后显示「审核中」,正式分数仍是 `existingScore.score`。
|
||||
|
||||
### 3. 班主任班级学生列表
|
||||
|
||||
#### 接口信息
|
||||
@@ -215,6 +228,9 @@
|
||||
"remark": "表现良好",
|
||||
"createTime": "2024-09-01 09:00:00"
|
||||
},
|
||||
"pendingAuditId": 1234567890123456790,
|
||||
"pendingScore": 86.00,
|
||||
"pendingRemark": "更正分数",
|
||||
"lastScore": 90.00,
|
||||
"lastMonth": 8
|
||||
}
|
||||
|
||||
@@ -82,11 +82,7 @@
|
||||
</view>
|
||||
<view class="info-row">
|
||||
<text class="label">留宿原因:</text>
|
||||
<u-tag
|
||||
:text="getStayReasonTypeText(item.stayReasonType)"
|
||||
:type="getStayReasonTypeTagType(item.stayReasonType)"
|
||||
size="mini"
|
||||
></u-tag>
|
||||
<text class="value">{{ item.stayReason || '-' }}</text>
|
||||
</view>
|
||||
<view class="info-row">
|
||||
<text class="label">联系电话:</text>
|
||||
@@ -150,7 +146,6 @@ export default {
|
||||
|
||||
// 字典数据
|
||||
dictHolidayType: [],
|
||||
dictStayReasonType: [],
|
||||
};
|
||||
},
|
||||
|
||||
@@ -164,7 +159,6 @@ export default {
|
||||
async loadDictData() {
|
||||
try {
|
||||
this.dictHolidayType = await getDict('xg_holiday_type');
|
||||
this.dictStayReasonType = await getDict('xg_stay_reason_type');
|
||||
} catch (error) {
|
||||
console.error('加载字典数据失败:', error);
|
||||
}
|
||||
@@ -258,22 +252,6 @@ export default {
|
||||
return getDictTagType(this.dictHolidayType, value, fallbackMap);
|
||||
},
|
||||
|
||||
// 获取留宿原因类型文本
|
||||
getStayReasonTypeText(value) {
|
||||
return getDictLabel(this.dictStayReasonType, value) || '-';
|
||||
},
|
||||
|
||||
// 获取留宿原因类型标签类型
|
||||
getStayReasonTypeTagType(value) {
|
||||
const fallbackMap = {
|
||||
1: 'primary', // 学习
|
||||
2: 'warning', // 实习
|
||||
3: 'success', // 工作
|
||||
4: 'info', // 其他
|
||||
};
|
||||
return getDictTagType(this.dictStayReasonType, value, fallbackMap);
|
||||
},
|
||||
|
||||
// 查看详情 - 暂不开发
|
||||
// handleView(row) {
|
||||
// console.log('查看详情:', row);
|
||||
|
||||
@@ -57,20 +57,6 @@
|
||||
</view>
|
||||
</u-form-item>
|
||||
|
||||
<u-form-item label="原因类型" prop="stayReasonType">
|
||||
<view @click="openReasonPicker" style="width: 100%">
|
||||
<u-input
|
||||
v-model="stayReasonTypeLabel"
|
||||
placeholder="请选择原因类型"
|
||||
readonly
|
||||
border="none"
|
||||
suffix-icon="arrow-down"
|
||||
suffix-icon-style="color: #c8c9cc;"
|
||||
style="pointer-events: none"
|
||||
/>
|
||||
</view>
|
||||
</u-form-item>
|
||||
|
||||
<u-form-item label="留宿原因" prop="stayReason" required>
|
||||
<u-textarea
|
||||
v-model="form.stayReason"
|
||||
@@ -112,15 +98,6 @@
|
||||
@close="showHolidayPicker = false"
|
||||
></u-picker>
|
||||
|
||||
<u-picker
|
||||
:show="showReasonPicker"
|
||||
:columns="reasonColumns"
|
||||
keyName="label"
|
||||
@confirm="onReasonConfirm"
|
||||
@cancel="showReasonPicker = false"
|
||||
@close="showReasonPicker = false"
|
||||
></u-picker>
|
||||
|
||||
<u-datetime-picker
|
||||
:show="showDatePicker"
|
||||
v-model="dateValue"
|
||||
@@ -142,14 +119,11 @@ export default {
|
||||
return {
|
||||
submitting: false,
|
||||
showHolidayPicker: false,
|
||||
showReasonPicker: false,
|
||||
showDatePicker: false,
|
||||
dateField: 'start',
|
||||
dateValue: Number(new Date()),
|
||||
holidayTypeDict: [],
|
||||
stayReasonTypeDict: [],
|
||||
holidayTypeLabel: '',
|
||||
stayReasonTypeLabel: '',
|
||||
dormLoading: false,
|
||||
dormText: '',
|
||||
hasDorm: false,
|
||||
@@ -158,7 +132,6 @@ export default {
|
||||
holidayType: '',
|
||||
applyStartDate: '',
|
||||
applyEndDate: '',
|
||||
stayReasonType: 'other',
|
||||
stayReason: '',
|
||||
studentPhone: '',
|
||||
emergencyContact: '',
|
||||
@@ -171,20 +144,11 @@ export default {
|
||||
computed: {
|
||||
holidayColumns() {
|
||||
return [this.holidayTypeDict || []];
|
||||
},
|
||||
reasonColumns() {
|
||||
return [this.stayReasonTypeDict || []];
|
||||
}
|
||||
},
|
||||
async onLoad() {
|
||||
try {
|
||||
this.holidayTypeDict = (await getDict('xg_holiday_type')) || [];
|
||||
this.stayReasonTypeDict = (await getDict('xg_stay_reason_type')) || [];
|
||||
const reason = this.stayReasonTypeDict.find((d) => String(d.value) === 'other');
|
||||
if (reason) {
|
||||
this.stayReasonTypeLabel = reason.label;
|
||||
this.form.stayReasonType = reason.value;
|
||||
}
|
||||
const stuRes = await request({
|
||||
url: '/studentMsg/studentMsg/currentUserInfo',
|
||||
method: 'GET'
|
||||
@@ -239,13 +203,6 @@ export default {
|
||||
}
|
||||
this.showHolidayPicker = true;
|
||||
},
|
||||
openReasonPicker() {
|
||||
if (!this.stayReasonTypeDict.length) {
|
||||
uni.showToast({ title: '原因类型加载中,请稍后', icon: 'none' });
|
||||
return;
|
||||
}
|
||||
this.showReasonPicker = true;
|
||||
},
|
||||
openDate(field) {
|
||||
this.dateField = field;
|
||||
const current = field === 'start' ? this.form.applyStartDate : this.form.applyEndDate;
|
||||
@@ -260,14 +217,6 @@ export default {
|
||||
}
|
||||
this.showHolidayPicker = false;
|
||||
},
|
||||
onReasonConfirm(e) {
|
||||
const item = (e.value && e.value[0]) || null;
|
||||
if (item) {
|
||||
this.form.stayReasonType = item.value;
|
||||
this.stayReasonTypeLabel = item.label;
|
||||
}
|
||||
this.showReasonPicker = false;
|
||||
},
|
||||
onDateConfirm(e) {
|
||||
const ts = e && e.value !== undefined ? e.value : e;
|
||||
const d = new Date(Number(ts));
|
||||
|
||||
@@ -124,6 +124,20 @@ export function conductScoreCheckPermission(query: any) {
|
||||
});
|
||||
}
|
||||
|
||||
// 导入操行分数据
|
||||
export function conductScoreImportData(data: FormData, params: { academicYear: number; semester: number; classId: string }) {
|
||||
return request({
|
||||
url: '/xg/conduct-score/importData',
|
||||
method: 'post',
|
||||
params,
|
||||
data,
|
||||
headers: {
|
||||
repeatSubmit: false
|
||||
},
|
||||
timeout: 300000
|
||||
});
|
||||
}
|
||||
|
||||
// 获取学生详细记录(按月份)
|
||||
export function conductScoreGetStudentRecords(studentId: any, academicYear: any, semester: any, tenantId: any) {
|
||||
return request({
|
||||
|
||||
@@ -103,11 +103,6 @@
|
||||
<el-form-item label="留宿原因" prop="stayReason">
|
||||
<el-input v-model="queryParams.stayReason" placeholder="请输入留宿原因" clearable @keyup.enter="handleQuery" />
|
||||
</el-form-item>
|
||||
<el-form-item label="留宿原因类型" prop="stayReasonType">
|
||||
<el-select v-model="queryParams.stayReasonType" placeholder="请选择留宿原因类型" clearable>
|
||||
<el-option v-for="dict in xg_stay_reason_type" :key="dict.value" :label="dict.label" :value="dict.value" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="学生联系电话" prop="studentPhone">
|
||||
<el-input v-model="queryParams.studentPhone" placeholder="请输入学生联系电话" clearable @keyup.enter="handleQuery" />
|
||||
</el-form-item>
|
||||
@@ -360,7 +355,6 @@
|
||||
<el-table-column label="留宿原因" align="center" min-width="120">
|
||||
<template #default="scope">
|
||||
<div class="reason-cell">
|
||||
<dict-tag :options="xg_stay_reason_type" :value="scope.row.stayReasonType" />
|
||||
<div class="reason-text" v-if="scope.row.stayReason" :title="scope.row.stayReason">
|
||||
{{ scope.row.stayReason.length > 20 ? scope.row.stayReason.substring(0, 20) + '...' : scope.row.stayReason }}
|
||||
</div>
|
||||
@@ -441,10 +435,6 @@
|
||||
<span class="detail-label">假期:</span>
|
||||
<dict-tag :options="xg_holiday_type" :value="stay.holidayType" />
|
||||
</div>
|
||||
<div class="detail-item" v-if="stay.stayReasonType">
|
||||
<span class="detail-label">原因:</span>
|
||||
<dict-tag :options="xg_stay_reason_type" :value="stay.stayReasonType" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="period-actions">
|
||||
@@ -617,13 +607,6 @@
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="12">
|
||||
<el-form-item label="留宿原因类型" prop="stayReasonType">
|
||||
<el-select v-model="form.stayReasonType" placeholder="请选择留宿原因类型" style="width: 100%">
|
||||
<el-option v-for="dict in xg_stay_reason_type" :key="dict.value" :label="dict.label" :value="dict.value"></el-option>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
</el-row>
|
||||
|
||||
<el-row :gutter="20">
|
||||
@@ -883,7 +866,7 @@ const initFormData: HolidayStayForm = {
|
||||
applyStartDate: undefined,
|
||||
applyEndDate: undefined,
|
||||
stayReason: undefined,
|
||||
stayReasonType: 'other', // 默认其他原因
|
||||
stayReasonType: undefined,
|
||||
studentPhone: undefined,
|
||||
emergencyContact: undefined,
|
||||
emergencyPhone: undefined,
|
||||
|
||||
@@ -442,13 +442,6 @@
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="12">
|
||||
<el-form-item label="留宿原因类型" prop="stayReasonType">
|
||||
<el-select v-model="form.stayReasonType" placeholder="请选择留宿原因类型" style="width: 100%">
|
||||
<el-option v-for="dict in xg_stay_reason_type" :key="dict.value" :label="dict.label" :value="dict.value"></el-option>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
</el-row>
|
||||
|
||||
<el-row :gutter="20">
|
||||
@@ -717,7 +710,7 @@ const initFormData: HolidayStayForm = {
|
||||
applyStartDate: undefined,
|
||||
applyEndDate: undefined,
|
||||
stayReason: undefined,
|
||||
stayReasonType: 'other', // 默认其他原因
|
||||
stayReasonType: undefined,
|
||||
studentPhone: undefined,
|
||||
emergencyContact: undefined,
|
||||
emergencyPhone: undefined,
|
||||
|
||||
@@ -155,70 +155,6 @@
|
||||
</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">模板包含5列:月份、学号、学生姓名、分数、备注</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"
|
||||
@@ -290,9 +226,12 @@
|
||||
<el-input v-model="scope.row.remark" size="small" placeholder="输入备注(可选)" maxlength="500" show-word-limit />
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column v-if="columns[6].visible" key="status" label="状态" align="center" width="120">
|
||||
<el-table-column v-if="columns[6].visible" key="status" label="状态" align="center" width="140">
|
||||
<template #default="scope">
|
||||
<el-tag :type="getStudentStatusTagType(scope.row)" size="small">{{ getStudentStatus(scope.row) }}</el-tag>
|
||||
<div v-if="scope.row.pendingAuditId" style="margin-top: 2px; font-size: 12px; line-height: 1.2; color: #e6a23c">
|
||||
待审 {{ Number(scope.row.pendingScore) }}
|
||||
</div>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column v-if="columns[7].visible" key="lastScore" label="上月分数" align="center" width="100">
|
||||
@@ -316,19 +255,75 @@
|
||||
|
||||
<!-- 调试信息(开发环境显示) -->
|
||||
<div v-else style="padding: 20px; text-align: center; color: #909399">正在加载班级数据...</div>
|
||||
|
||||
<!-- 导入数据弹窗放在班级循环外,避免每个 Tab 各生成一个上传组件 -->
|
||||
<el-dialog
|
||||
v-model="importModalVisible"
|
||||
title="导入操行分数据"
|
||||
width="500px"
|
||||
append-to-body
|
||||
:close-on-click-modal="false"
|
||||
destroy-on-close
|
||||
@closed="handleImportDialogClosed"
|
||||
>
|
||||
<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"
|
||||
:disabled="importUpload.isUploading"
|
||||
:auto-upload="false"
|
||||
:on-change="handleImportFileChange"
|
||||
:on-remove="handleImportFileRemove"
|
||||
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">模板包含5列:月份、学号、学生姓名、分数、备注</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>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts" name="ConductScoreInput">
|
||||
import { ref, reactive, onMounted, computed, getCurrentInstance, toRefs, nextTick } from 'vue';
|
||||
import { ref, reactive, onMounted, computed, getCurrentInstance, toRefs } 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, conductScoreBatchUpdate } from '@/api/xg/conductScore';
|
||||
import { conductScoreClassStudents, conductScoreBatchAdd, conductScoreBatchUpdate, conductScoreImportData } from '@/api/xg/conductScore';
|
||||
|
||||
// 获取当前实例
|
||||
const { proxy } = getCurrentInstance() as any;
|
||||
@@ -522,15 +517,17 @@ const getStudentStatus = (student) => {
|
||||
}
|
||||
|
||||
if (hasExistingScore && hasCurrentScore) {
|
||||
// 比较分数和备注是否变化
|
||||
// 比较分数和备注是否变化。未保存的改动显示待审核;已提交且尚未审完显示审核中
|
||||
const scoreChanged = Number(student.score) !== Number(student.existingScore.score);
|
||||
const remarkChanged = String(student.remark || '').trim() !== String(student.existingScore.remark || '').trim();
|
||||
|
||||
if (scoreChanged || remarkChanged) {
|
||||
return '待审核';
|
||||
} else {
|
||||
return '已录入';
|
||||
}
|
||||
if (student.pendingAuditId !== null && student.pendingAuditId !== undefined && student.pendingAuditId !== '') {
|
||||
return '审核中';
|
||||
}
|
||||
return '已录入';
|
||||
}
|
||||
|
||||
return '未录入';
|
||||
@@ -547,6 +544,7 @@ const getStudentStatusTagType = (student) => {
|
||||
case '已录入':
|
||||
return 'success';
|
||||
case '待审核':
|
||||
case '审核中':
|
||||
return 'warning';
|
||||
default:
|
||||
return 'info';
|
||||
@@ -772,17 +770,11 @@ const handleSaveAll = () => {
|
||||
type: auditStudents.length > 0 ? 'warning' : 'success',
|
||||
dangerouslyUseHTMLString: true
|
||||
}).then(() => {
|
||||
// 分批处理直接保存和审核
|
||||
if (directSaveStudents.length > 0) {
|
||||
saveBatchData(directSaveStudents, 'add');
|
||||
}
|
||||
if (auditStudents.length > 0) {
|
||||
saveBatchData(auditStudents, 'update');
|
||||
}
|
||||
submitScoreBatches(directSaveStudents, auditStudents);
|
||||
});
|
||||
};
|
||||
|
||||
const saveBatchData = async (students, operationType = 'add') => {
|
||||
const saveBatchData = async (students, operationType = 'add', refresh = true) => {
|
||||
try {
|
||||
const batchData = {
|
||||
academicYear: queryParams.academicYear,
|
||||
@@ -817,7 +809,9 @@ const saveBatchData = async (students, operationType = 'add') => {
|
||||
}
|
||||
}
|
||||
|
||||
getList();
|
||||
if (refresh) {
|
||||
await getList();
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('保存数据失败:', error);
|
||||
const operationName = operationType === 'update' ? '提交审核' : '保存';
|
||||
@@ -825,6 +819,18 @@ const saveBatchData = async (students, operationType = 'add') => {
|
||||
}
|
||||
};
|
||||
|
||||
const submitScoreBatches = async (directStudents, auditStudents) => {
|
||||
const jobs = [];
|
||||
if (directStudents.length > 0) {
|
||||
jobs.push(saveBatchData(directStudents, 'add', false));
|
||||
}
|
||||
if (auditStudents.length > 0) {
|
||||
jobs.push(saveBatchData(auditStudents, 'update', false));
|
||||
}
|
||||
await Promise.allSettled(jobs);
|
||||
await getList();
|
||||
};
|
||||
|
||||
// 批量录入弹窗数据与确认保存
|
||||
const batchModalVisible = ref(false);
|
||||
const batchModalForm = reactive({
|
||||
@@ -835,10 +841,9 @@ const batchModalForm = reactive({
|
||||
// 导入数据相关
|
||||
const importModalVisible = ref(false);
|
||||
const importUploadRef = ref<any>();
|
||||
const importFileList = ref<any[]>([]);
|
||||
const importUpload = reactive({
|
||||
isUploading: false,
|
||||
headers: globalHeaders(),
|
||||
url: ''
|
||||
isUploading: false
|
||||
});
|
||||
|
||||
const confirmBatchModalSave = () => {
|
||||
@@ -888,34 +893,17 @@ const confirmBatchModalSave = () => {
|
||||
|
||||
batchModalVisible.value = false;
|
||||
|
||||
// 分批处理
|
||||
if (directSaveStudents.length > 0) {
|
||||
const directSaveData = directSaveStudents.map((stu) => ({
|
||||
studentId: stu.studentId,
|
||||
score: batchModalForm.score,
|
||||
remark: batchModalForm.remark || ''
|
||||
}));
|
||||
saveBatchData(directSaveData, 'add');
|
||||
}
|
||||
|
||||
if (auditStudents.length > 0) {
|
||||
const auditData = auditStudents.map((stu) => ({
|
||||
studentId: stu.studentId,
|
||||
score: batchModalForm.score,
|
||||
remark: batchModalForm.remark || ''
|
||||
}));
|
||||
saveBatchData(auditData, 'update');
|
||||
}
|
||||
|
||||
// 显示操作结果
|
||||
let message = '批量操作完成:';
|
||||
if (directSaveStudents.length > 0) {
|
||||
message += `保存 ${directSaveStudents.length} 个学生`;
|
||||
}
|
||||
if (auditStudents.length > 0) {
|
||||
message += `${directSaveStudents.length > 0 ? ',' : ''}提交 ${auditStudents.length} 个修改学生审核`;
|
||||
}
|
||||
ElMessage.success(message);
|
||||
const directSaveData = directSaveStudents.map((stu) => ({
|
||||
studentId: stu.studentId,
|
||||
score: batchModalForm.score,
|
||||
remark: batchModalForm.remark || ''
|
||||
}));
|
||||
const auditData = auditStudents.map((stu) => ({
|
||||
studentId: stu.studentId,
|
||||
score: batchModalForm.score,
|
||||
remark: batchModalForm.remark || ''
|
||||
}));
|
||||
submitScoreBatches(directSaveData, auditData);
|
||||
};
|
||||
|
||||
const handleRefresh = () => {
|
||||
@@ -995,6 +983,7 @@ const handleImportData = () => {
|
||||
ElMessage.warning('请先选择要导入数据的班级');
|
||||
return;
|
||||
}
|
||||
importFileList.value = [];
|
||||
importModalVisible.value = true;
|
||||
};
|
||||
|
||||
@@ -1002,74 +991,69 @@ 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());
|
||||
|
||||
// 如果选择了特定班级,则只导入该班级数据
|
||||
if (activeTab.value) {
|
||||
params.append('classId', activeTab.value);
|
||||
}
|
||||
|
||||
return `${baseUrl}?${params.toString()}`;
|
||||
const handleImportFileChange = (_uploadFile, fileList) => {
|
||||
importFileList.value = fileList;
|
||||
};
|
||||
|
||||
const handleImportFileUploadProgress = () => {
|
||||
importUpload.isUploading = true;
|
||||
const handleImportFileRemove = (_uploadFile, fileList) => {
|
||||
importFileList.value = fileList;
|
||||
};
|
||||
|
||||
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 handleImportDialogClosed = () => {
|
||||
importFileList.value = [];
|
||||
};
|
||||
|
||||
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('上传组件未初始化');
|
||||
const submitImportFile = async () => {
|
||||
if (importUpload.isUploading) {
|
||||
return;
|
||||
}
|
||||
|
||||
ElMessage({
|
||||
const rawFile = [...importFileList.value].reverse().find((file) => file?.raw)?.raw;
|
||||
if (!rawFile) {
|
||||
ElMessage.warning('请先选择要导入的文件');
|
||||
return;
|
||||
}
|
||||
if (queryParams.academicYear == null || queryParams.semester == null) {
|
||||
ElMessage.warning('请先选择学年和学期');
|
||||
return;
|
||||
}
|
||||
if (!activeTab.value) {
|
||||
ElMessage.warning('请先选择要导入数据的班级');
|
||||
return;
|
||||
}
|
||||
|
||||
const formData = new FormData();
|
||||
formData.append('file', rawFile);
|
||||
|
||||
importUpload.isUploading = true;
|
||||
const loadingMessage = 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;
|
||||
}
|
||||
});
|
||||
try {
|
||||
const response: any = await conductScoreImportData(formData, {
|
||||
academicYear: queryParams.academicYear,
|
||||
semester: queryParams.semester,
|
||||
classId: activeTab.value
|
||||
});
|
||||
importUploadRef.value?.clearFiles?.();
|
||||
importFileList.value = [];
|
||||
importModalVisible.value = false;
|
||||
ElMessageBox.alert(
|
||||
"<div style='overflow: auto;overflow-x: hidden;max-height: 70vh;padding: 10px 20px 0;'>" + (response?.msg || '导入完成') + '</div>',
|
||||
'导入结果',
|
||||
{ dangerouslyUseHTMLString: true }
|
||||
);
|
||||
getList();
|
||||
} catch (error) {
|
||||
console.error('文件上传失败:', error);
|
||||
} finally {
|
||||
loadingMessage.close();
|
||||
importUpload.isUploading = false;
|
||||
}
|
||||
};
|
||||
|
||||
// 生命周期
|
||||
|
||||
Reference in new issue
Block a user