From 44799362c1305b2edd499b6458f84a1fef794d2f Mon Sep 17 00:00:00 2001 From: wasrusgen Date: Thu, 14 May 2026 14:51:25 +0300 Subject: [PATCH] feat: client picker in measurement form, address geocoding, edit-client 4-field addr MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - measurements.js: replace manual name/phone inputs with client picker overlay (search by ФИО or phone, sorted alphabetically, picks from /api/clients) - clients.js: new-client and edit-client forms now use 4 split address fields (город, улица, дом, кв./офис) with geocode validation on save - clients.js: add splitAddress() helper to pre-fill edit form from stored address - clients.js: voice engine refactored (continuous=false + auto-restart, no duplication) - clients.js: note block view/edit toggle (textarea closes after save) - podbor.css: styles for picker overlay, picker-row, chosen-card, addr-grid, geo-status - backend main.py: _handle_client_create and _handle_client_update accept gps_lat/gps_lng - index.html: cache bump → v=20260514i Co-Authored-By: Claude Opus 4.7 (1M context) --- backend-py/app/main.py | 12 ++ miniapp/assets/clients.js | 187 ++++++++++++++++++++++++------ miniapp/assets/measurements.js | 201 +++++++++++++++++++++++++++------ miniapp/assets/podbor.css | 184 ++++++++++++++++++++++++++++++ miniapp/index.html | 26 ++--- 5 files changed, 528 insertions(+), 82 deletions(-) diff --git a/backend-py/app/main.py b/backend-py/app/main.py index 36cba41..2458acf 100644 --- a/backend-py/app/main.py +++ b/backend-py/app/main.py @@ -2119,6 +2119,8 @@ def _handle_client_create(body: dict[str, Any]) -> dict[str, Any]: note = (body.get("note") or "").strip() contract_no = (body.get("contract_no") or "").strip() contract_date = (body.get("contract_date") or "").strip() + gps_lat = body.get("gps_lat") + gps_lng = body.get("gps_lng") # Валидация if not full_name: @@ -2152,6 +2154,8 @@ def _handle_client_create(body: dict[str, Any]) -> dict[str, Any]: client_no=str(client_no), contract_no=contract_no, contract_date=contract_date, + gps_lat=gps_lat, + gps_lng=gps_lng, )) # Сохраняем заметку в ClientNotes если она передана @@ -2303,6 +2307,8 @@ def _handle_client_update(body: dict[str, Any]) -> dict[str, Any]: new_address = body.get("address") new_contract_no = body.get("contract_no") new_contract_date = body.get("contract_date") + new_gps_lat = body.get("gps_lat") + new_gps_lng = body.get("gps_lng") if new_name and len(new_name) < 2: return {"error": "bad_name", "msg": "Имя слишком короткое"} @@ -2337,6 +2343,8 @@ def _handle_client_update(body: dict[str, Any]) -> dict[str, Any]: address_col = col_idx("address") contract_no_col = col_idx("contract_no") contract_date_col = col_idx("contract_date") + gps_lat_col = col_idx("gps_lat") + gps_lng_col = col_idx("gps_lng") updated = 0 for i, r in enumerate(rows[1:], start=2): @@ -2357,6 +2365,10 @@ def _handle_client_update(body: dict[str, Any]) -> dict[str, Any]: ws.update_cell(i, contract_no_col, new_contract_no.strip()) if isinstance(new_contract_date, str) and contract_date_col: ws.update_cell(i, contract_date_col, new_contract_date.strip()) + if new_gps_lat is not None and gps_lat_col: + ws.update_cell(i, gps_lat_col, new_gps_lat) + if new_gps_lng is not None and gps_lng_col: + ws.update_cell(i, gps_lng_col, new_gps_lng) updated += 1 sheets.log_event("client_updated", tg_id, {"client_key": client_key, "updated": updated}) diff --git a/miniapp/assets/clients.js b/miniapp/assets/clients.js index 2ceae9e..63f8274 100644 --- a/miniapp/assets/clients.js +++ b/miniapp/assets/clients.js @@ -58,12 +58,27 @@ const Clients = (function () {
- + Адрес * +
+ + + + +
+ +
- + Адрес +
+ + + + +
+ +