fix: жёлтая подсветка пустых значений в циклах + выборочный Применить
- Циклы (item.*, user_*, алиасы): пустые значения '—'/'' теперь подсвечиваются жёлтым маркером (раньше подстановка шла на уровне XML простым replace — подсветка терялась) - Вложенные циклы (users_loop): та же подсветка - Панель «Проверка данных»: чекбоксы «Подставлять: склонения / кр. склон. / адрес / ИНН-КПП-ОГРН / руковод.» — выборочный Применить - get_short_fio/get_initials: не теряют отчество в сокращённом ФИО
This commit is contained in:
+48
-14
@@ -303,6 +303,28 @@ class DokoGenApp:
|
||||
btn_row.pack(fill=tk.X)
|
||||
ttk.Button(btn_row, text="✓ Применить", command=self._verify_apply).pack(side=tk.LEFT, padx=2)
|
||||
ttk.Button(btn_row, text="Очистить", command=self._verify_clear).pack(side=tk.LEFT, padx=2)
|
||||
|
||||
# Выборочное применение: чекбоксы «что подставлять»
|
||||
self._apply_flags = {
|
||||
'declension': tk.BooleanVar(value=True),
|
||||
'short_declension': tk.BooleanVar(value=True),
|
||||
'address': tk.BooleanVar(value=True),
|
||||
'requisites': tk.BooleanVar(value=True),
|
||||
'chief': tk.BooleanVar(value=True),
|
||||
}
|
||||
apply_row = ttk.Frame(right)
|
||||
apply_row.pack(fill=tk.X, pady=(4, 0))
|
||||
ttk.Label(apply_row, text="Подставлять:", font=('', 8)).pack(side=tk.LEFT, padx=(0, 4))
|
||||
ttk.Checkbutton(apply_row, text="склонения", variable=self._apply_flags['declension'],
|
||||
font=('', 8)).pack(side=tk.LEFT)
|
||||
ttk.Checkbutton(apply_row, text="кр. склон.", variable=self._apply_flags['short_declension'],
|
||||
font=('', 8)).pack(side=tk.LEFT)
|
||||
ttk.Checkbutton(apply_row, text="адрес", variable=self._apply_flags['address'],
|
||||
font=('', 8)).pack(side=tk.LEFT)
|
||||
ttk.Checkbutton(apply_row, text="ИНН/КПП/ОГРН", variable=self._apply_flags['requisites'],
|
||||
font=('', 8)).pack(side=tk.LEFT)
|
||||
ttk.Checkbutton(apply_row, text="руковод.", variable=self._apply_flags['chief'],
|
||||
font=('', 8)).pack(side=tk.LEFT)
|
||||
self._verify_result = None
|
||||
|
||||
# ---------- ПРОВЕРКА ДАННЫХ (Морфер / DaData / ИИ) ----------
|
||||
@@ -594,8 +616,15 @@ class DokoGenApp:
|
||||
if not result:
|
||||
return
|
||||
apply_data = result.get('apply', {})
|
||||
flags = getattr(self, '_apply_flags', None)
|
||||
|
||||
def want(key):
|
||||
if flags is None:
|
||||
return True
|
||||
return flags[key].get() if key in flags else True
|
||||
|
||||
idx_map = {'nomn': 1, 'gent': 2, 'datv': 3, 'accs': 4, 'ablt': 5, 'loct': 6}
|
||||
if 'declension' in apply_data:
|
||||
if 'declension' in apply_data and want('declension'):
|
||||
for case, val in apply_data['declension'].items():
|
||||
code = self._CASE_TO_CODE.get(case)
|
||||
if code and code in self.decl_entries:
|
||||
@@ -603,7 +632,7 @@ class DokoGenApp:
|
||||
self.decl_entries[code].insert(0, val)
|
||||
setattr(self.model, f'company_name_{idx_map[code]}', val)
|
||||
self.log("✅ Склонения полного названия применены")
|
||||
if 'short_declension' in apply_data:
|
||||
if 'short_declension' in apply_data and want('short_declension'):
|
||||
for case, val in apply_data['short_declension'].items():
|
||||
code = self._CASE_TO_CODE.get(case)
|
||||
if code and code in self.short_decl_entries:
|
||||
@@ -619,18 +648,23 @@ class DokoGenApp:
|
||||
if comp.get('short_name'):
|
||||
self.short_name_entry.delete(0, tk.END)
|
||||
self.short_name_entry.insert(0, comp['short_name'])
|
||||
mapping = {'address': 'address', 'kpp': 'kpp', 'ogrn': 'ogrn',
|
||||
'ogrn_date': 'ogrn_date', 'inn': 'inn'}
|
||||
for data_key, ui_key in mapping.items():
|
||||
if comp.get(data_key) and ui_key in self._company_entries:
|
||||
self._company_entries[ui_key].delete(0, tk.END)
|
||||
self._company_entries[ui_key].insert(0, comp[data_key])
|
||||
if comp.get('chief_position') and 'chief_position' in self._official_entries:
|
||||
self._official_entries['chief_position'].delete(0, tk.END)
|
||||
self._official_entries['chief_position'].insert(0, comp['chief_position'])
|
||||
if comp.get('chief_fio') and 'chief_fio' in self._official_entries:
|
||||
self._official_entries['chief_fio'].delete(0, tk.END)
|
||||
self._official_entries['chief_fio'].insert(0, comp['chief_fio'])
|
||||
if want('address') and comp.get('address'):
|
||||
if 'address' in self._company_entries:
|
||||
self._company_entries['address'].delete(0, tk.END)
|
||||
self._company_entries['address'].insert(0, comp['address'])
|
||||
if want('requisites'):
|
||||
for data_key, ui_key in {'kpp': 'kpp', 'ogrn': 'ogrn',
|
||||
'ogrn_date': 'ogrn_date', 'inn': 'inn'}.items():
|
||||
if comp.get(data_key) and ui_key in self._company_entries:
|
||||
self._company_entries[ui_key].delete(0, tk.END)
|
||||
self._company_entries[ui_key].insert(0, comp[data_key])
|
||||
if want('chief'):
|
||||
if comp.get('chief_position') and 'chief_position' in self._official_entries:
|
||||
self._official_entries['chief_position'].delete(0, tk.END)
|
||||
self._official_entries['chief_position'].insert(0, comp['chief_position'])
|
||||
if comp.get('chief_fio') and 'chief_fio' in self._official_entries:
|
||||
self._official_entries['chief_fio'].delete(0, tk.END)
|
||||
self._official_entries['chief_fio'].insert(0, comp['chief_fio'])
|
||||
self.log("✅ Реквизиты применены")
|
||||
|
||||
# ---------- ВКЛАДКА "ИНФОРМАЦИОННЫЕ СИСТЕМЫ" ----------
|
||||
|
||||
Reference in New Issue
Block a user