refactor: remove company management
This commit is contained in:
@@ -18,10 +18,12 @@ No test or lint commands are currently configured. When adding tests, use Vitest
|
||||
|
||||
## Project Overview
|
||||
|
||||
This is a React 19 + TypeScript frontend for the Zhejiang Beifan Trace Management Platform (溯源管理平台). It provides:
|
||||
- Public query interface for serial number verification
|
||||
- Admin dashboard for QR code generation and company management
|
||||
- Employee management with automatic employee serial generation
|
||||
This is a React 19 + TypeScript frontend for the Zhejiang Beifan Trace Coding Platform (溯源赋码平台). It provides:
|
||||
- Public query interface for employee permission-code verification
|
||||
- Admin dashboard for work-order statistics
|
||||
- Permission issuance with automatic employee serial generation
|
||||
- Product traceability management and public scan pages
|
||||
- Project work-order management for on-site implementation records
|
||||
- Aftersales work-order management for admins and technicians
|
||||
- User authentication and profile management
|
||||
|
||||
@@ -61,7 +63,7 @@ src/
|
||||
- **Components**: PascalCase (e.g., `LoginPage`, `AdminLayout`)
|
||||
- **Functions/Methods**: camelCase (e.g., `handleLogin`, `loadStats`)
|
||||
- **Constants**: UPPER_SNAKE_CASE (e.g., `API_BASE_URL`)
|
||||
- **Types/Interfaces**: PascalCase (e.g., `User`, `Company`, `ApiResponse<T>`)
|
||||
- **Types/Interfaces**: PascalCase (e.g., `User`, `ProductTrace`, `ApiResponse<T>`)
|
||||
- **Files**: PascalCase for components/pages, lowercase for services/utils
|
||||
|
||||
### TypeScript
|
||||
@@ -87,11 +89,11 @@ src/
|
||||
### API Services
|
||||
- API calls organized by domain in `src/services/api.ts`:
|
||||
- `authApi` - Authentication (login, logout, profile)
|
||||
- `serialApi` - Serial number management
|
||||
- `companyApi` - Company management
|
||||
- `dashboardApi` - Dashboard statistics
|
||||
- `employeeSerialApi` - Employee serial management
|
||||
- `employeeSerialApi` - Employee permission-code management
|
||||
- `productTracesApi` - Product traceability
|
||||
- `aftersalesApi` - Aftersales work orders (admin + public)
|
||||
- `projectOrdersApi` - Project work orders (admin + public)
|
||||
- `employeesApi` - Employee management (admin only): create/list/update/delete/reset password
|
||||
- `usersApi` - Assignable technician/admin picker via `assignable`
|
||||
- Auth token automatically added via axios interceptor
|
||||
@@ -103,23 +105,26 @@ src/
|
||||
- Admin pages wrapped with `<AdminRoutes>` layout component
|
||||
- Use `useNavigate()` for programmatic navigation
|
||||
- Use `useLocation()` to get current path
|
||||
- Public routes (no auth): `/login`, `/query`, `/aftersales/:serialNumber`
|
||||
- `PublicQuery` auto-redirects scanned `zjbf-sh-*` serials to `/aftersales/:serialNumber`
|
||||
- Public routes (no auth): `/login`, `/query`, `/aftersales/:serialNumber`, `/project-orders/:serialNumber`, `/product-traces/:serialNumber`
|
||||
- `PublicQuery` auto-redirects scanned `zjbf-sh-*` serials to `/aftersales/:serialNumber`.
|
||||
- `PublicQuery` auto-redirects scanned `zjbf-xm-*` serials to `/project-orders/:serialNumber`.
|
||||
- Product trace QR codes use `/product-traces/:serialNumber` directly.
|
||||
- Shared public-page chrome (logo + 备案 footer) lives in `components/PublicLayout.tsx`
|
||||
- `/admin/employee-serials` is the employee management page despite the legacy route name.
|
||||
- Technicians should only see/use the aftersales module; admins see all admin menu items.
|
||||
- `/admin/employee-serials` is the 权限下发 page despite the legacy route name.
|
||||
- Technicians should only see/use the aftersales and project work-order modules; admins see all admin menu items.
|
||||
|
||||
### Roles and Employee Management
|
||||
### Roles and Permission Issuance
|
||||
- `UserRole` is limited to `admin` / `technician` / `employee`.
|
||||
- `admin`: full backend access.
|
||||
- `technician`: work-order module access only.
|
||||
- `employee`: no backend login access.
|
||||
- Employee creation fields are name, phone, employee number, position, and role.
|
||||
- Password field is shown and required only for `admin` and `technician`.
|
||||
- Employee creation uses `employeesApi.create`, and the backend automatically creates the employee serial; do not implement a separate "create then assign code" primary flow.
|
||||
- Employee creation uses `employeesApi.create`, and the backend automatically creates the employee permission code; do not implement a separate "create then assign code" primary flow.
|
||||
- Employee rows should display generated `employeeSerials` from the employee list response.
|
||||
- Employee rows should provide a QR-code view for the active employee serial, using `/query?serial=...` as the scan target.
|
||||
- Public employee serial queries should show employee name, phone, employee number, and position.
|
||||
- Do not reintroduce enterprise/company-code management APIs or UI. The old `companyApi`, `serialApi`, `/admin/manage`, `/api/companies`, and `/api/serials` surfaces were removed.
|
||||
|
||||
### Aftersales Conventions
|
||||
- Aftersales serial format is `zjbf-sh-YYMMDDNN` (daily sequence), e.g. `zjbf-sh-26052801`.
|
||||
@@ -127,11 +132,25 @@ src/
|
||||
- `software`: 软件故障
|
||||
- `hardware`: 硬件故障
|
||||
- `maintenance`: 售后维保
|
||||
- Aftersales `companyName` is a customer-company text field only. Do not call company-management APIs or create managed companies from aftersales create/update flows.
|
||||
- Aftersales `companyName` is a customer-company text field only. Do not call or recreate company-management APIs from aftersales create/update flows.
|
||||
- Use label text `现场情况说明` for `issueDescription` in create/detail/public-confirm views.
|
||||
- In admin detail page, use `工单分配` as the UI label for reassign action.
|
||||
- Signature display text should be `客户确认签名`.
|
||||
|
||||
### Product Traceability
|
||||
- Admin route: `/admin/product-traces`.
|
||||
- Public route: `/product-traces/:serialNumber`.
|
||||
- Manual product serial numbers are required.
|
||||
- Form field order must remain: 企业名称、地址、电话、设备信息、质保期、出厂日期、产品序列号、官网链接(可选)、公众号二维码(可选).
|
||||
- Official-account QR code images are uploaded to OSS and stored as backend-managed URLs/keys, not inline base64 in regular form payloads.
|
||||
|
||||
### Project Work Orders
|
||||
- Project order serial format is `zjbf-xm-YYMMDDNN`.
|
||||
- Project orders are for on-site investigation/implementation records.
|
||||
- Completion requires site images and engineer signature, without customer signature.
|
||||
- Site image limit is 18.
|
||||
- Completed project orders use status text `已完成`.
|
||||
|
||||
### State Management
|
||||
- Use React hooks (`useState`, `useEffect`) for local component state
|
||||
- Authentication state persisted in localStorage via authApi
|
||||
|
||||
Reference in New Issue
Block a user