tien_nemo

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

2025/ntctien/14567 edit template

See merge request !3
...@@ -123,7 +123,6 @@ ...@@ -123,7 +123,6 @@
123 <div v-for="field in fieldOptions" :key="field.value" class="form-group"> 123 <div v-for="field in fieldOptions" :key="field.value" class="form-group">
124 <label>@{{ field.label }}</label> 124 <label>@{{ field.label }}</label>
125 <input v-model="formData[field.value]" 125 <input v-model="formData[field.value]"
126 - @focus="highlightField(field.value)"
127 @click="onInputClick(field.value)" 126 @click="onInputClick(field.value)"
128 @blur="removeAllFocus()" 127 @blur="removeAllFocus()"
129 128
...@@ -164,10 +163,13 @@ ...@@ -164,10 +163,13 @@
164 }, 163 },
165 mounted() { 164 mounted() {
166 this.loadOCRData(); 165 this.loadOCRData();
167 - 166 + //Thêm event listener để xóa focus khi click ra ngoài
168 - // Thêm event listener để xóa focus khi click ra ngoài
169 document.addEventListener('click', (e) => { 167 document.addEventListener('click', (e) => {
170 - if (!e.target.closest('.left-panel') && !e.target.closest('.bbox')) { 168 + if (
169 + !e.target.closest('.left-panel') &&
170 + !e.target.closest('.bbox') &&
171 + !e.target.closest('select')
172 + ) {
171 this.removeAllFocus(); 173 this.removeAllFocus();
172 } 174 }
173 }); 175 });
...@@ -179,11 +181,9 @@ ...@@ -179,11 +181,9 @@
179 } 181 }
180 }, 182 },
181 methods: { 183 methods: {
182 -
183 // Map field cho box (không set active, chỉ dùng để load data từ DB) 184 // Map field cho box (không set active, chỉ dùng để load data từ DB)
184 mapFieldToBox(index, fieldName, text = null) { 185 mapFieldToBox(index, fieldName, text = null) {
185 if (index == null) return; 186 if (index == null) return;
186 -
187 // Xóa tất cả box có fieldName trùng lặp, chỉ giữ lại box hiện tại 187 // Xóa tất cả box có fieldName trùng lặp, chỉ giữ lại box hiện tại
188 this.ocrData = this.ocrData.filter((box, i) => { 188 this.ocrData = this.ocrData.filter((box, i) => {
189 if (i === index) return true; 189 if (i === index) return true;
...@@ -254,7 +254,6 @@ ...@@ -254,7 +254,6 @@
254 }; 254 };
255 } 255 }
256 }); 256 });
257 -
258 fields = (fieldsByName); 257 fields = (fieldsByName);
259 console.log('Using ocrData for customer_name:', customer_name, customer_coords); 258 console.log('Using ocrData for customer_name:', customer_name, customer_coords);
260 } 259 }
...@@ -292,7 +291,6 @@ ...@@ -292,7 +291,6 @@
292 } 291 }
293 }, 292 },
294 293
295 -
296 deleteBox(index) { 294 deleteBox(index) {
297 const item = this.ocrData[index]; 295 const item = this.ocrData[index];
298 if (item.isManual) { 296 if (item.isManual) {
...@@ -303,7 +301,6 @@ ...@@ -303,7 +301,6 @@
303 o.hideBorder = false; 301 o.hideBorder = false;
304 } 302 }
305 }); 303 });
306 -
307 // Đánh dấu xoá vùng thủ công 304 // Đánh dấu xoá vùng thủ công
308 this.ocrData[index].isDeleted = true; 305 this.ocrData[index].isDeleted = true;
309 this.ocrData[index].showDelete = false; 306 this.ocrData[index].showDelete = false;
...@@ -316,6 +313,7 @@ ...@@ -316,6 +313,7 @@
316 this.manualField = ""; 313 this.manualField = "";
317 this.manualIndex = null; 314 this.manualIndex = null;
318 } 315 }
316 + this.selectingIndex = null;
319 } 317 }
320 }, 318 },
321 319
...@@ -352,8 +350,7 @@ ...@@ -352,8 +350,7 @@
352 }, 350 },
353 351
354 autoMapFieldsFromFormData() { 352 autoMapFieldsFromFormData() {
355 - this.manualBoxData = {}; // reset 353 + this.manualBoxData = {};
356 -
357 if(this.is_template) { 354 if(this.is_template) {
358 this.formData = {}; 355 this.formData = {};
359 } 356 }
...@@ -536,6 +533,7 @@ ...@@ -536,6 +533,7 @@
536 removeAllFocus() { 533 removeAllFocus() {
537 // Reset active index (chỉ mất màu xanh, không xóa box) 534 // Reset active index (chỉ mất màu xanh, không xóa box)
538 this.activeIndex = null; 535 this.activeIndex = null;
536 + this.selectingIndex = null;
539 537
540 // Ẩ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) 538 // Ẩ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)
541 this.ocrData.forEach(item => { 539 this.ocrData.forEach(item => {
......