UIapi fix
This commit is contained in:
parent
ef7d3759f6
commit
731b1fc4b7
@ -268,31 +268,32 @@ class ImportApp(QMainWindow):
|
|||||||
self.map_table.setCellWidget(i, 2, combo)
|
self.map_table.setCellWidget(i, 2, combo)
|
||||||
|
|
||||||
def autofill_mapping(self):
|
def autofill_mapping(self):
|
||||||
"""Простое автосопоставление по подстроке (без учета регистра)."""
|
"""Автосопоставление только при полном совпадении названия поля JSON и колонки Excel."""
|
||||||
rows = self.map_table.rowCount()
|
rows = self.map_table.rowCount()
|
||||||
|
matched = 0
|
||||||
for i in range(rows):
|
for i in range(rows):
|
||||||
json_field = self.map_table.item(i, 0).text()
|
json_field = self.map_table.item(i, 0).text().strip()
|
||||||
jf_key = json_field.split(".")[-1].lower()
|
|
||||||
best = ""
|
|
||||||
score_best = 0
|
|
||||||
for h in self.headers:
|
|
||||||
hl = h.lower()
|
|
||||||
score = 0
|
|
||||||
if hl == jf_key:
|
|
||||||
score = 3
|
|
||||||
elif jf_key in hl or hl in jf_key:
|
|
||||||
score = 2
|
|
||||||
elif hl.replace(" ", "") == jf_key.replace("_", ""):
|
|
||||||
score = 1
|
|
||||||
if score > score_best:
|
|
||||||
score_best = score
|
|
||||||
best = h
|
|
||||||
combo = self.map_table.cellWidget(i, 2)
|
combo = self.map_table.cellWidget(i, 2)
|
||||||
if combo and best:
|
if not combo:
|
||||||
idx = combo.findText(best)
|
continue
|
||||||
|
|
||||||
|
# точное совпадение (с учётом регистра)
|
||||||
|
if json_field in self.headers:
|
||||||
|
idx = combo.findText(json_field)
|
||||||
if idx >= 0:
|
if idx >= 0:
|
||||||
combo.setCurrentIndex(idx)
|
combo.setCurrentIndex(idx)
|
||||||
self.log("✨ Выполнено автосопоставление.")
|
matched += 1
|
||||||
|
# допускаем вариант без учёта регистра (если нужно)
|
||||||
|
else:
|
||||||
|
for h in self.headers:
|
||||||
|
if h.lower() == json_field.lower():
|
||||||
|
idx = combo.findText(h)
|
||||||
|
if idx >= 0:
|
||||||
|
combo.setCurrentIndex(idx)
|
||||||
|
matched += 1
|
||||||
|
break
|
||||||
|
|
||||||
|
self.log(f"✨ Автосопоставление завершено: найдено точных совпадений {matched}")
|
||||||
|
|
||||||
# ---------- Excel ----------
|
# ---------- Excel ----------
|
||||||
def load_excel(self):
|
def load_excel(self):
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user