tien_nemo

Merge branch '2025/ntctien/14567_edit_template' into 'dev'

2025/ntctien/14567 edit template

See merge request !3
......@@ -123,7 +123,6 @@
<div v-for="field in fieldOptions" :key="field.value" class="form-group">
<label>@{{ field.label }}</label>
<input v-model="formData[field.value]"
@focus="highlightField(field.value)"
@click="onInputClick(field.value)"
@blur="removeAllFocus()"
......@@ -164,10 +163,13 @@
},
mounted() {
this.loadOCRData();
// Thêm event listener để xóa focus khi click ra ngoài
//Thêm event listener để xóa focus khi click ra ngoài
document.addEventListener('click', (e) => {
if (!e.target.closest('.left-panel') && !e.target.closest('.bbox')) {
if (
!e.target.closest('.left-panel') &&
!e.target.closest('.bbox') &&
!e.target.closest('select')
) {
this.removeAllFocus();
}
});
......@@ -179,11 +181,9 @@
}
},
methods: {
// Map field cho box (không set active, chỉ dùng để load data từ DB)
mapFieldToBox(index, fieldName, text = null) {
if (index == null) return;
// Xóa tất cả box có fieldName trùng lặp, chỉ giữ lại box hiện tại
this.ocrData = this.ocrData.filter((box, i) => {
if (i === index) return true;
......@@ -254,7 +254,6 @@
};
}
});
fields = (fieldsByName);
console.log('Using ocrData for customer_name:', customer_name, customer_coords);
}
......@@ -292,7 +291,6 @@
}
},
deleteBox(index) {
const item = this.ocrData[index];
if (item.isManual) {
......@@ -303,7 +301,6 @@
o.hideBorder = false;
}
});
// Đánh dấu xoá vùng thủ công
this.ocrData[index].isDeleted = true;
this.ocrData[index].showDelete = false;
......@@ -316,6 +313,7 @@
this.manualField = "";
this.manualIndex = null;
}
this.selectingIndex = null;
}
},
......@@ -352,8 +350,7 @@
},
autoMapFieldsFromFormData() {
this.manualBoxData = {}; // reset
this.manualBoxData = {};
if(this.is_template) {
this.formData = {};
}
......@@ -536,6 +533,7 @@
removeAllFocus() {
// Reset active index (chỉ mất màu xanh, không xóa box)
this.activeIndex = null;
this.selectingIndex = null;
// Ẩn hoàn toàn các box manual được tạo từ DB (không phải quét chọn thủ công)
this.ocrData.forEach(item => {
......