Files
zcglxt/app/models/transfer.py
Claude e71181f0a3 fix: 修复多个关键问题
- 修复前端路由守卫:未登录时不显示提示,直接跳转登录页
- 修复API拦截器:401错误不显示提示,直接跳转
- 增强验证码显示:图片尺寸从120x40增加到200x80
- 增大验证码字体:从28号增加到48号
- 优化验证码字符:排除易混淆的0和1
- 减少干扰线:从5条减少到3条,添加背景色优化
- 增强登录API日志:添加详细的调试日志
- 增强验证码生成和验证日志
- 优化异常处理和错误追踪

影响文件:
- src/router/index.ts
- src/api/request.ts
- app/services/auth_service.py
- app/api/v1/auth.py
- app/schemas/user.py

测试状态:
- 前端构建通过
- 后端语法检查通过
- 验证码显示效果优化完成

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-01-25 00:26:21 +08:00

83 lines
4.4 KiB
Python

"""
资产调拨相关数据模型
"""
from datetime import datetime, date
from sqlalchemy import Column, BigInteger, String, Integer, Text, ForeignKey, DateTime, Date, Index
from sqlalchemy.orm import relationship
from app.db.base import Base
class AssetTransferOrder(Base):
"""资产调拨单表"""
__tablename__ = "asset_transfer_orders"
id = Column(BigInteger, primary_key=True, index=True)
order_code = Column(String(50), unique=True, nullable=False, index=True, comment="调拨单号")
source_org_id = Column(BigInteger, ForeignKey("organizations.id"), nullable=False, comment="调出网点ID")
target_org_id = Column(BigInteger, ForeignKey("organizations.id"), nullable=False, index=True, comment="调入网点ID")
transfer_type = Column(String(20), nullable=False, index=True, comment="调拨类型(internal/external)")
title = Column(String(200), nullable=False, comment="标题")
asset_count = Column(Integer, default=0, nullable=False, comment="资产数量")
apply_user_id = Column(BigInteger, ForeignKey("users.id"), nullable=False, index=True, comment="申请人ID")
apply_time = Column(DateTime, nullable=False, comment="申请时间")
approval_status = Column(String(20), default="pending", nullable=False, index=True, comment="审批状态")
approval_user_id = Column(BigInteger, ForeignKey("users.id"), nullable=True, comment="审批人ID")
approval_time = Column(DateTime, nullable=True, comment="审批时间")
approval_remark = Column(Text, nullable=True, comment="审批备注")
execute_status = Column(String(20), default="pending", nullable=False, index=True, comment="执行状态")
execute_user_id = Column(BigInteger, ForeignKey("users.id"), nullable=True, comment="执行人ID")
execute_time = Column(DateTime, nullable=True, comment="执行时间")
remark = Column(Text, nullable=True, comment="备注")
created_at = Column(DateTime, default=datetime.utcnow, nullable=False)
updated_at = Column(DateTime, default=datetime.utcnow, onupdate=datetime.utcnow, nullable=False)
# 关系
source_organization = relationship("Organization", foreign_keys=[source_org_id])
target_organization = relationship("Organization", foreign_keys=[target_org_id])
apply_user = relationship("User", foreign_keys=[apply_user_id])
approval_user = relationship("User", foreign_keys=[approval_user_id])
execute_user = relationship("User", foreign_keys=[execute_user_id])
items = relationship("AssetTransferItem", back_populates="order", cascade="all, delete-orphan")
# 索引
__table_args__ = (
Index("idx_transfer_orders_code", "order_code"),
Index("idx_transfer_orders_source_org", "source_org_id"),
Index("idx_transfer_orders_target_org", "target_org_id"),
)
def __repr__(self):
return f"<AssetTransferOrder(id={self.id}, order_code={self.order_code}, transfer_type={self.transfer_type})>"
class AssetTransferItem(Base):
"""资产调拨单明细表"""
__tablename__ = "asset_transfer_items"
id = Column(BigInteger, primary_key=True, index=True)
order_id = Column(BigInteger, ForeignKey("asset_transfer_orders.id", ondelete="CASCADE"), nullable=False, comment="调拨单ID")
asset_id = Column(BigInteger, ForeignKey("assets.id"), nullable=False, comment="资产ID")
asset_code = Column(String(50), nullable=False, comment="资产编码")
source_organization_id = Column(BigInteger, ForeignKey("organizations.id"), nullable=False, comment="调出网点ID")
target_organization_id = Column(BigInteger, ForeignKey("organizations.id"), nullable=False, comment="调入网点ID")
transfer_status = Column(String(20), default="pending", nullable=False, index=True, comment="调拨状态")
created_at = Column(DateTime, default=datetime.utcnow, nullable=False)
# 关系
order = relationship("AssetTransferOrder", back_populates="items")
asset = relationship("Asset")
source_organization = relationship("Organization", foreign_keys=[source_organization_id])
target_organization = relationship("Organization", foreign_keys=[target_organization_id])
# 索引
__table_args__ = (
Index("idx_transfer_items_order", "order_id"),
Index("idx_transfer_items_asset", "asset_id"),
Index("idx_transfer_items_status", "transfer_status"),
)
def __repr__(self):
return f"<AssetTransferItem(id={self.id}, order_id={self.order_id}, asset_code={self.asset_code})>"