diff --git a/backend/app/api/customers.py b/backend/app/api/customers.py index 9cca076..d516300 100644 --- a/backend/app/api/customers.py +++ b/backend/app/api/customers.py @@ -50,7 +50,6 @@ async def list_customers( industry: Optional[str] = Query(None), service: Optional[str] = Query(None), manager_id: Optional[str] = Query(None), - customer_type: Optional[str] = Query(None), page: int = Query(1, ge=1), page_size: int = Query(100, ge=1, le=1000), current_user: dict = Depends(get_current_user), @@ -61,8 +60,6 @@ async def list_customers( base_query = select(Customer) - if customer_type: - base_query = base_query.where(Customer.customer_type == customer_type) if industry: base_query = base_query.where(Customer.industry.ilike(f"%{industry}%")) if service: @@ -92,7 +89,7 @@ async def list_customers( # Paginate offset = (page - 1) * page_size - query = base_query.order_by(Customer.customer_type, Customer.name).offset(offset).limit(page_size) + query = base_query.order_by(Customer.name).offset(offset).limit(page_size) result = await db.execute(query) items = result.scalars().all() diff --git a/backend/app/main.py b/backend/app/main.py index 52b6997..028c2ef 100644 --- a/backend/app/main.py +++ b/backend/app/main.py @@ -42,10 +42,6 @@ async def lifespan(app: FastAPI): await conn.run_sync(lambda c: c.exec_driver_sql( "ALTER TABLE customers ADD COLUMN IF NOT EXISTS last_visit_manager_id UUID" )) - # v0.9 — customer_type for unit vs individual - await conn.run_sync(lambda c: c.exec_driver_sql( - "ALTER TABLE customers ADD COLUMN IF NOT EXISTS customer_type VARCHAR(20) DEFAULT 'unit'" - )) # New columns for v0.4 await conn.run_sync(lambda c: c.exec_driver_sql( "ALTER TABLE visits ADD COLUMN IF NOT EXISTS companion_names TEXT[] DEFAULT '{}'" diff --git a/backend/app/models/customer.py b/backend/app/models/customer.py index 4f47b68..1e6a654 100644 --- a/backend/app/models/customer.py +++ b/backend/app/models/customer.py @@ -11,7 +11,6 @@ class Customer(Base): id: Mapped[uuid.UUID] = mapped_column(UUID(as_uuid=True), primary_key=True, default=uuid.uuid4) name: Mapped[str] = mapped_column(String(200), index=True) - customer_type: Mapped[str] = mapped_column(String(20), default="unit") # unit / individual industry: Mapped[str] = mapped_column(String(100), default="") address: Mapped[str] = mapped_column(String(500), default="") in_use_services: Mapped[str] = mapped_column(Text, default="") diff --git a/backend/app/schemas/customer.py b/backend/app/schemas/customer.py index a5f8e72..d779751 100644 --- a/backend/app/schemas/customer.py +++ b/backend/app/schemas/customer.py @@ -45,7 +45,6 @@ class ContactOut(BaseModel): # ── Customer ── class CustomerCreate(BaseModel): name: str - customer_type: str = "unit" industry: str = "" address: str = "" in_use_services: str = "" @@ -57,7 +56,6 @@ class CustomerCreate(BaseModel): class CustomerUpdate(BaseModel): name: Optional[str] = None - customer_type: Optional[str] = None industry: Optional[str] = None address: Optional[str] = None in_use_services: Optional[str] = None @@ -69,7 +67,6 @@ class CustomerUpdate(BaseModel): class CustomerOut(BaseModel): id: uuid.UUID name: str - customer_type: str = "unit" industry: str address: str in_use_services: str @@ -87,7 +84,6 @@ class CustomerOut(BaseModel): class CustomerListOut(BaseModel): id: uuid.UUID name: str - customer_type: str = "unit" industry: str in_use_services: str primary_manager_name: Optional[str] = None diff --git a/frontend/src/views/desktop/CustomerManage.vue b/frontend/src/views/desktop/CustomerManage.vue index fd359f6..3b4cfd0 100644 --- a/frontend/src/views/desktop/CustomerManage.vue +++ b/frontend/src/views/desktop/CustomerManage.vue @@ -15,7 +15,6 @@ const search = ref('') const filterIndustry = ref('') const filterService = ref('') const filterManagerId = ref('') -const customerType = ref('unit') // 'unit' or 'individual' const customers = ref([]) const currentPage = ref(1) const pageSize = ref(25) @@ -24,7 +23,7 @@ const dialogVisible = ref(false) const dialogTitle = ref('新建客户') const editId = ref('') const form = ref({ - name: '', customer_type: 'unit', industry: '', address: '', in_use_services: '', + name: '', industry: '', address: '', in_use_services: '', fee_amount: '', fee_unit: '元/月', remarks: '', contacts: [] as any[], @@ -69,7 +68,6 @@ async function loadCustomers() { if (filterIndustry.value) params.industry = filterIndustry.value if (filterService.value) params.service = filterService.value if (filterManagerId.value) params.manager_id = filterManagerId.value - if (customerType.value) params.customer_type = customerType.value const res = await customersApi.list(params) customers.value = res.data.items total.value = res.data.total @@ -103,7 +101,7 @@ function parseMonthlyFee(fee: string) { } function resetForm() { - form.value = { name: '', customer_type: customerType.value, industry: '', address: '', in_use_services: '', fee_amount: '', fee_unit: '元/月', remarks: '', contacts: [], assignee_id: '' } + form.value = { name: '', industry: '', address: '', in_use_services: '', fee_amount: '', fee_unit: '元/月', remarks: '', contacts: [], assignee_id: '' } feeCustomUnit.value = '' existingContacts.value = [] } @@ -130,7 +128,7 @@ async function openEdit(customer: any) { const res = await customersApi.get(customer.id) const c = res.data resetForm() - form.value.name = c.name; form.value.customer_type = c.customer_type || 'unit'; form.value.industry = c.industry; form.value.address = c.address + form.value.name = c.name; form.value.industry = c.industry; form.value.address = c.address form.value.in_use_services = c.in_use_services; form.value.remarks = c.remarks || '' parseMonthlyFee(c.monthly_fee) existingContacts.value = c.contacts || [] @@ -143,7 +141,7 @@ async function handleSubmit() { const monthly_fee = buildMonthlyFee() try { if (editId.value) { - const body: any = { name: form.value.name, customer_type: form.value.customer_type, industry: form.value.industry, address: form.value.address, in_use_services: form.value.in_use_services, monthly_fee, remarks: form.value.remarks } + const body: any = { name: form.value.name, industry: form.value.industry, address: form.value.address, in_use_services: form.value.in_use_services, monthly_fee, remarks: form.value.remarks } if (form.value.assignee_id) body.assignee_id = form.value.assignee_id await customersApi.update(editId.value, body) for (const c of form.value.contacts) { @@ -151,7 +149,7 @@ async function handleSubmit() { } ElMessage.success('已更新') } else { - await customersApi.create({ name: form.value.name, customer_type: form.value.customer_type, industry: form.value.industry, address: form.value.address, in_use_services: form.value.in_use_services, monthly_fee, remarks: form.value.remarks, contacts: form.value.contacts, assignee_id: form.value.assignee_id || undefined }) + await customersApi.create({ name: form.value.name, industry: form.value.industry, address: form.value.address, in_use_services: form.value.in_use_services, monthly_fee, remarks: form.value.remarks, contacts: form.value.contacts, assignee_id: form.value.assignee_id || undefined }) ElMessage.success('已创建') } dialogVisible.value = false @@ -331,14 +329,6 @@ async function handleImport() {
- -
- - 单位客户 - 个人用户 - -
- @@ -373,12 +363,7 @@ async function handleImport() { - - - - + @@ -404,8 +389,7 @@ async function handleImport() { - - -