fix: fix some bug in finance pages

This commit is contained in:
2025-09-21 01:11:03 +08:00
parent c4aef881bc
commit 3857661086
3 changed files with 3 additions and 13 deletions
+1 -2
View File
@@ -5,7 +5,7 @@ from finance.models import Department
class ProjectGroup(models.Model): class ProjectGroup(models.Model):
"""项目组模型""" """项目组模型"""
name = models.CharField(max_length=100, unique=True, verbose_name="项目组名称") name = models.CharField(max_length=100, verbose_name="项目组名称")
department = models.ForeignKey(Department, on_delete=models.CASCADE, verbose_name="所属部门") department = models.ForeignKey(Department, on_delete=models.CASCADE, verbose_name="所属部门")
description = models.TextField(blank=True, null=True, verbose_name="项目组描述") description = models.TextField(blank=True, null=True, verbose_name="项目组描述")
created_at = models.DateTimeField(auto_now_add=True, verbose_name="创建时间") created_at = models.DateTimeField(auto_now_add=True, verbose_name="创建时间")
@@ -30,7 +30,6 @@ class Personnel(models.Model):
name = models.CharField(max_length=50, verbose_name="姓名") name = models.CharField(max_length=50, verbose_name="姓名")
student_id = models.CharField( student_id = models.CharField(
max_length=20, max_length=20,
unique=True,
verbose_name="学号", verbose_name="学号",
validators=[RegexValidator( validators=[RegexValidator(
regex=r'^\d{8,12}$', regex=r'^\d{8,12}$',
-9
View File
@@ -44,15 +44,6 @@ class PersonnelWriteSerializer(serializers.ModelSerializer):
'is_active', 'phone', 'qq', 'email', 'description' 'is_active', 'phone', 'qq', 'email', 'description'
] ]
def validate_student_id(self, value):
"""验证学号唯一性"""
if self.instance and self.instance.student_id == value:
return value
if Personnel.objects.filter(student_id=value).exists():
raise serializers.ValidationError("该学号已存在")
return value
def validate_project_group(self, value): def validate_project_group(self, value):
"""验证项目组是否属于选定的部门""" """验证项目组是否属于选定的部门"""
if value and hasattr(self, 'initial_data'): if value and hasattr(self, 'initial_data'):
+2 -2
View File
@@ -295,7 +295,7 @@ export default {
); );
// 构建详细信息 // 构建详细信息
let detailInfo = `<div style="max-width: 400px;"> let detailInfo = `<div>
<h3 style="margin: 0 0 15px 0; color: #409eff;">${date} - ${seriesName}</h3> <h3 style="margin: 0 0 15px 0; color: #409eff;">${date} - ${seriesName}</h3>
<p style="margin: 0 0 10px 0; font-size: 18px; font-weight: bold; color: ${seriesName === '收入' ? '#67c23a' : '#f56c6c'};"> <p style="margin: 0 0 10px 0; font-size: 18px; font-weight: bold; color: ${seriesName === '收入' ? '#67c23a' : '#f56c6c'};">
总计: ¥${value.toFixed(2)} 总计: ¥${value.toFixed(2)}
@@ -328,7 +328,7 @@ export default {
showClose: true, showClose: true,
closeOnClickModal: true, closeOnClickModal: true,
closeOnPressEscape: true closeOnPressEscape: true
}); }).catch(() => { /* 关闭时不做操作,否则会炸 */ });
}); });
// 添加鼠标悬停时显示数据标签 // 添加鼠标悬停时显示数据标签