提交
This commit is contained in:
1 parent
dacfdc9ff6
commit
f9676f8759
906 files changed
+533306
-12946
No files matched your search
@@ -13,6 +13,7 @@ from app.core.data_scope import apply_data_scope
|
||||
from app.core.database import get_db
|
||||
from app.core.menu_guard import require_admin_or_super_admin, require_menu_code
|
||||
from app.core.response import success_response, error_response
|
||||
from app.core.attachment_biz import resolve_upload_folder
|
||||
from app.core.storage import storage
|
||||
from app.crud import tenant as tenant_svc
|
||||
from app.crud import dict_type as dict_type_svc
|
||||
@@ -74,13 +75,21 @@ async def list_users_for_select(
|
||||
_user: dict = Depends(require_admin_or_super_admin),
|
||||
db: Session = Depends(get_db),
|
||||
):
|
||||
"""返回用户下拉选项(label=昵称,value=用户ID),供流程设计器审批人选择使用。"""
|
||||
"""返回用户下拉选项(label=昵称,value=用户ID,附带 nickName/userNo),供审批人选择等场景使用。"""
|
||||
tenant_no = _user.get("tenant_no", "")
|
||||
q = db.query(SysUser).filter(SysUser.del_flag == 0, SysUser.status == "1")
|
||||
if tenant_no:
|
||||
q = q.filter(SysUser.tenant_no == tenant_no)
|
||||
rows = q.order_by(SysUser.create_time.desc()).all()
|
||||
out = [{"label": (r.nick_name or r.user_no or ""), "value": r.id} for r in rows]
|
||||
out = [
|
||||
{
|
||||
"label": (r.nick_name or r.user_no or ""),
|
||||
"value": r.id,
|
||||
"nickName": r.nick_name or "",
|
||||
"userNo": r.user_no or "",
|
||||
}
|
||||
for r in rows
|
||||
]
|
||||
return success_response(out)
|
||||
|
||||
|
||||
@@ -1315,14 +1324,18 @@ def _format_file_size(size_bytes: int) -> str:
|
||||
async def upload_attachment(
|
||||
file: UploadFile = File(...),
|
||||
folder: Optional[str] = Form(""),
|
||||
biz_type: Optional[str] = Form(None, alias="bizType"),
|
||||
user: dict = Depends(require_admin_or_super_admin),
|
||||
db: Session = Depends(get_db),
|
||||
):
|
||||
if not file or not file.filename:
|
||||
return error_response(400, "请选择文件")
|
||||
try:
|
||||
effective_folder = resolve_upload_folder(
|
||||
folder=folder or "", biz_type=biz_type or ""
|
||||
)
|
||||
file_content = await file.read()
|
||||
full_url = storage.upload_file(file_content, file.filename, folder or "")
|
||||
full_url = storage.upload_file(file_content, file.filename, effective_folder)
|
||||
base_url = settings.MINIO_BASE_URL.rstrip("/") if settings.MINIO_BASE_URL else ""
|
||||
if base_url and full_url.startswith(base_url + "/"):
|
||||
file_url = full_url[len(base_url) + 1:]
|
||||
@@ -1340,8 +1353,9 @@ async def upload_attachment(
|
||||
file_suffix=file_ext,
|
||||
file_size=file_size,
|
||||
file_type=file_type,
|
||||
biz_type=(biz_type or "").strip(),
|
||||
user_id=user.get("user_id"),
|
||||
ext1=folder or None,
|
||||
ext1=effective_folder or None,
|
||||
)
|
||||
return success_response({
|
||||
"id": record.id,
|
||||
@@ -1350,6 +1364,7 @@ async def upload_attachment(
|
||||
"fileSize": record.file_size,
|
||||
"fileSizeDisplay": _format_file_size(record.file_size or 0),
|
||||
"fileType": record.file_type,
|
||||
"bizType": record.biz_type or "",
|
||||
})
|
||||
except Exception as e:
|
||||
db.rollback()
|
||||
|
||||
+24
-8
@@ -7,6 +7,7 @@ from typing import Any, Dict, List
|
||||
from urllib.parse import quote
|
||||
|
||||
from fastapi import APIRouter, Depends, File, Form, UploadFile
|
||||
from sqlalchemy import or_
|
||||
from sqlalchemy.orm import Session
|
||||
|
||||
from app.core.database import get_db
|
||||
@@ -31,6 +32,7 @@ from app.crud.crm.product import (
|
||||
get_category,
|
||||
get_product,
|
||||
list_categories,
|
||||
list_category_tree,
|
||||
list_product_options,
|
||||
list_products,
|
||||
product_no_exists,
|
||||
@@ -322,7 +324,15 @@ async def category_tree(
|
||||
"""获取产品分类树"""
|
||||
try:
|
||||
tenant_no = get_tenant_no(db, _user)
|
||||
rows = list_categories(db, tenant_no)
|
||||
payload = body or {}
|
||||
category_name = payload.get("categoryName") or payload.get("category_name")
|
||||
status = payload.get("status")
|
||||
rows = list_category_tree(
|
||||
db,
|
||||
tenant_no,
|
||||
category_name=category_name,
|
||||
status=status,
|
||||
)
|
||||
return success_response(rows)
|
||||
except ValueError as e:
|
||||
return error_response(400, str(e))
|
||||
@@ -430,7 +440,6 @@ async def customer_update(
|
||||
|
||||
data = body.model_dump(exclude_unset=True)
|
||||
customer_id = data.pop("id")
|
||||
|
||||
if "customer_name" in data:
|
||||
if customer_name_exists(db, data["customer_name"], tenant_no, exclude_id=customer_id):
|
||||
return error_response(400, "客户名称已存在")
|
||||
@@ -737,7 +746,7 @@ async def product_import(
|
||||
for idx, row in enumerate(rows, start=2):
|
||||
row_errors: List[str] = []
|
||||
try:
|
||||
# 列: 产品编号、产品名称、分类名称、规格型号、单位、标准单价、成本价、状态、包装规格、备注
|
||||
# 列: 产品编号、产品名称、分类名称、规格型号、单位、标准单价、成本价、状态、备注
|
||||
product_no = str(row[0]).strip() if row[0] else None
|
||||
product_name = str(row[1]).strip() if row[1] else ""
|
||||
category_name = str(row[2]).strip() if row[2] else None
|
||||
@@ -750,8 +759,7 @@ async def product_import(
|
||||
status = "on"
|
||||
elif status == "0":
|
||||
status = "off"
|
||||
package_spec = str(row[8]).strip() if row[8] else None
|
||||
remark = str(row[9]).strip() if row[9] else None
|
||||
remark = str(row[8]).strip() if row[8] else None
|
||||
|
||||
# 必填校验
|
||||
if not product_name:
|
||||
@@ -786,7 +794,6 @@ async def product_import(
|
||||
price=price,
|
||||
cost_price=cost_price,
|
||||
status=status,
|
||||
package_spec=package_spec,
|
||||
remark=remark,
|
||||
)
|
||||
success_count += 1
|
||||
@@ -859,7 +866,6 @@ async def product_import_template(
|
||||
"标准单价",
|
||||
"成本价",
|
||||
"状态(on上架/off下架)",
|
||||
"包装规格",
|
||||
"备注",
|
||||
]
|
||||
ws.append(headers)
|
||||
@@ -1390,6 +1396,9 @@ async def contact_list(
|
||||
rows, total = list_contacts(
|
||||
db, tenant_no, page=page, page_size=page_size,
|
||||
keyword=body.keyword if body else None,
|
||||
contact_name=body.contact_name if body else None,
|
||||
mobile=body.mobile if body else None,
|
||||
position=body.position if body else None,
|
||||
customer_id=body.customer_id if body else None,
|
||||
is_key=body.is_key if body else None,
|
||||
is_primary=body.is_primary if body else None,
|
||||
@@ -3670,6 +3679,7 @@ async def clue_follow_list(
|
||||
page=body.page,
|
||||
page_size=body.pageSize,
|
||||
)
|
||||
enrich_clue_user_names(db, rows)
|
||||
return success_response({
|
||||
"list": rows,
|
||||
"total": total,
|
||||
@@ -3693,7 +3703,12 @@ async def clue_follow_create(
|
||||
try:
|
||||
tenant_no = get_tenant_no(db, _user)
|
||||
user_id = _user.get("user_id", "") or _user.get("id", "")
|
||||
user_name = _user.get("nick_name", "") or _user.get("user_name", "")
|
||||
user_name = (
|
||||
_user.get("real_name", "")
|
||||
or _user.get("nick_name", "")
|
||||
or _user.get("user_name", "")
|
||||
or _user.get("username", "")
|
||||
)
|
||||
result = create_clue_follow(
|
||||
db,
|
||||
tenant_no,
|
||||
@@ -3982,6 +3997,7 @@ async def clue_follow_detail(
|
||||
detail = get_clue_follow(db, follow_id)
|
||||
if not detail:
|
||||
return error_response(404, "跟进记录不存在")
|
||||
enrich_clue_user_names(db, [detail])
|
||||
return success_response(detail)
|
||||
except ValueError as e:
|
||||
return error_response(400, str(e))
|
||||
|
||||
@@ -590,13 +590,15 @@ def register_quote_routes(router):
|
||||
):
|
||||
try:
|
||||
tenant_no = get_tenant_no(db, _user)
|
||||
user_id = _user.get("user_id", "") or _user.get("id", "")
|
||||
approve_quote(
|
||||
db,
|
||||
body.id,
|
||||
tenant_no=tenant_no,
|
||||
approval_result=body.approvalResult,
|
||||
approval_opinion=body.approvalOpinion,
|
||||
remark=body.remark,
|
||||
approval_opinion=body.approvalOpinion or "",
|
||||
remark=body.remark or "",
|
||||
user_id=user_id,
|
||||
)
|
||||
return success_response(None, message="审批成功")
|
||||
except ValueError as e:
|
||||
@@ -612,7 +614,14 @@ def register_quote_routes(router):
|
||||
):
|
||||
try:
|
||||
tenant_no = get_tenant_no(db, _user)
|
||||
withdraw_approval(db, body.quoteId, tenant_no=tenant_no, remark=body.remark)
|
||||
user_id = _user.get("user_id", "") or _user.get("id", "")
|
||||
withdraw_approval(
|
||||
db,
|
||||
body.quoteId,
|
||||
tenant_no=tenant_no,
|
||||
remark=body.remark or "",
|
||||
user_id=user_id,
|
||||
)
|
||||
return success_response(None, message="撤回成功")
|
||||
except ValueError as e:
|
||||
return error_response(400, str(e))
|
||||
|
||||
Reference in new issue
Block a user