Hệ thống pháp luật

BỘ Y TẾ
-------

CỘNG HÒA XÃ HỘI CHỦ NGHĨA VIỆT NAM
Độc lập - Tự do - Hạnh phúc
---------------

Số: 32/2019/TT-BYT

Hà Nội, ngày 16 tháng 12 năm 2019

 

THÔNG TƯ

SỬA ĐỔI, BỔ SUNG KHOẢN 4 ĐIỀU 4 VÀ PHỤ LỤC SỐ 01-MP THÔNG TƯ SỐ 06/2011/TT-BYT NGÀY 25 THÁNG 01 NĂM 2011 CỦA BỘ TRƯỞNG BỘ Y TẾ QUY ĐỊNH VỀ QUẢN LÝ MỸ PHẨM

Căn cứ Nghị định số 75/2017/NĐ-CP ngày 20 tháng 6 năm 2017 của Chính phủ quy định chức năng, nhiệm vụ, quyền hạn và cơ cấu tổ chức của Bộ Y tế;

Căn cứ Nghị định số 69/2018/NĐ-CP ngày 15 tháng 5 năm 2018 của Chính phủ quy định chi tiết một số điều của Luật Quản lý ngoại thương;

Thực hiện Hiệp định Đối tác Toàn diện và Tiến bộ xuyên Thái Bình Dương (CPTPP) ký ngày 08 tháng 3 năm 2018;

Theo đề nghị của Cục trưởng Cục Quản lý Dược,

Bộ trưởng Bộ Y tế ban hành Thông tư sửa đổi, bổ sung Khoản 4 Điều 4 và Phụ lục số 01-MP Thông tư số 06/2011/TT-BYT ngày 25 tháng 01 năm 2011 của Bộ trưởng Bộ Y tế quy định về quản lý mỹ phẩm.

Điều 1. Sửa đổi, bổ sung Khoản 4 Điều 4 Thông tư số 06/2011/TT-BYT ngày 25 tháng 01 năm 2011 của Bộ trưởng Bộ Y tế quy định về quản lý mỹ phẩm (sau đây viết tắt là Thông tư số 06/2011/TT-BYT)

Sửa đổi, bổ sung Khoản 4 Điều 4 Thông tư số 06/2011/TT-BYT như sau:

“4. Giấy chứng nhận lưu hành tự do (CFS):

a) Trường hợp công bố sản phẩm mỹ phẩm nhập khẩu từ các nước không phải là thành viên CPTPP thì phải có CFS đáp ứng các yêu cầu sau:

- CFS do nước xuất khẩu mỹ phẩm vào Việt Nam cấp là bản chính, còn hạn. Trường hợp CFS không nêu thời hạn thì phải là bản được cấp trong vòng 24 tháng kể từ ngày cấp.

- CFS phải được hợp pháp hoá lãnh sự theo quy định của pháp luật, trừ trường hợp được miễn hợp pháp hoá lãnh sự theo các điều ước quốc tế mà Việt Nam là thành viên.

- CFS phải có tối thiểu các thông tin theo quy định tại Điều 36 Luật Quản lý Ngoại thươngKhoản 3 Điều 10 Nghị định số 69/2018/NĐ-CP ngày 15 tháng 5 năm 2018 của Chính phủ quy định chi tiết một số điều của Luật Quản lý ngoại thương.

b) Trường hợp công bố sản phẩm mỹ phẩm được lưu hành và xuất khẩu từ các nước thành viên CPTPP (Nước thành viên CPTPP là bất kỳ Nhà nước hoặc lãnh thổ hải quan riêng nào mà Hiệp định CPTPP đã được phê chuẩn và có hiệu lực) thì không phải có CFS.”

Điều 2. Sửa đổi, bổ sung Phụ lục số 01-MP ban hành kèm theo Thông tư số 06/2011/TT-BYT

Phụ lục số 01-MP ban hành kèm theo Thông tư số 06/2011/TT-BYT được sửa đổi, bổ sung theo Phụ lục được ban hành kèm theo Thông tư này.

Điều 3. Quy định chuyển tiếp

a) Hồ sơ công bố sản phẩm mỹ phẩm nhập khẩu từ các nước thành viên CPTPP nộp từ ngày Hiệp định CPTPP có hiệu lực thi hành tại Việt Nam (14/01/2019) được thực hiện theo quy định tại Thông tư này.

b) Hồ sơ công bố sản phẩm mỹ phẩm có kèm theo mẫu quy định tại Phụ lục số 01-MP Thông tư số 06/2011/TT-BYT nộp trước ngày Thông tư này có hiệu lực thì thực hiện theo Thông tư số 06/2011/TT-BYT, trừ trường hợp cơ sở đề nghị thực hiện theo quy định tại Thông tư này.

Điều 4. Hiệu lực thi hành

Thông tư này có hiệu lực thi hành kể từ ngày 01 tháng 02 năm 2020.

Điều 5. Trách nhiệm thi hành

1. Cục trưởng Cục Quản lý Dược chịu trách nhiệm tổ chức, thực hiện Thông tư này.

2. Chánh Văn phòng Bộ, Chánh Thanh tra Bộ, Thủ trưởng các đơn vị thuộc và trực thuộc Bộ Y tế, Giám đốc Sở Y tế tỉnh, thành phố trực thuộc Trung ương và các tổ chức, cá nhân có liên quan chịu trách nhiệm thi hành Thông tư này.

Trong quá trình thực hiện Thông tư này, nếu có vướng mắc, cơ quan tổ chức, cá nhân gửi ý kiến về Bộ Y tế (Cục Quản lý Dược - Bộ Y tế, địa chỉ: 138A Giảng Võ, Ba Đình, Hà Nội) để xem xét, giải quyết./.

 


Nơi nhận:
- Thủ tướng, các Phó Thủ tướng Chính ph;
- Văn phòng Trung ương và các Ban của Đảng;
- Văn phòng Tng Bí Thư;
- Văn phòng Quốc hội;
- Văn phòng Chủ tịch nước;
- Văn phòng Chính phủ (Phòng Công báo; Cổng thông tin điện t Chính ph; Cục KSTTHC);
- Bộ Tư pháp (Cục Kiểm tra VBQPPL);
- Các Bộ, cơ quan ngang Bộ, Cơ quan thuộc Chính phủ;
- Bộ trưởng Bộ Y tế (để báo cáo);
- Các Thứ trưng Bộ Y tế (để chđạo thực hiện);
- UBND các tnh, thành phtrực thuộc Trung ương;
- SY tế các tỉnh, thành phố trực thuộc Trung ương;
- Các Vụ, Cục, Tổng cục, Văn phòng Bộ, Thanh tra Bộ;
- Cổng thông tin điện tử Bộ Y tế;
- Lưu: VT, PC, Cục QLD (05 bản).

KT. BỘ TRƯỞNG
THỨ TRƯỞNG




Trương Quốc Cường

 

PHỤ LỤC

MẪU PHIẾU CÔNG BỐ SẢN PHẨM MỸ PHẨM

Phụ lục số 01 -MP

 

PHẦN DÀNH CHO CƠ QUAN QUẢN LÝ (FOR OFFICIAL USE)

Ngày cấp (Date acknowledged):

Số công bố (Product Notification No):

Phiếu công bố có giá trị 05 năm kể từ ngày cấp.

 

 

PHIẾU CÔNG BỐ SẢN PHẨM MỸ PHẨM
TEMPLATE FOR NOTIFICATION OF COSMETIC PRODUCT

R Đánh dấu vào ô thích hợp (Tick where applicable)

THÔNG TIN SẢN PHẨM
PARTICULARS OF PRODUCT

1. Tên nhãn hàng và tên sản phẩm (Name of brand & product):

1.1. Nhãn hàng (Brand)

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

1.2. Tên sản phẩm (Product Name)

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

1.3. Danh sách các dạng hoặc màu (List of Variants or Shade). Tên (Names)

 

2. Dạng sản phẩm (Product type(s))

□ Kem, nhũ tương, sữa, gel hoặc dầu dùng trên da (tay, mặt, chân,....)

Creams, emulsions, lotions, gels and oils for skin (hands, face, feet, etc)

□ Mặt nạ (chỉ trừ sản phẩm làm bong da nguồn gốc hóa học)

Face masks (with the exception of chemical peeling products)

□ Các chất phủ màu (lỏng, nhão, bột)

Tinted bases (liquids, pastes, powders)

□ Các phẩn trang điểm, phấn dùng sau khi tắm, bột vệ sinh,....

Make-up powders, after-bath powder, hygienic powders, etc.

□ Xà phòng tắm, xà phòng khử mùi,

Toilet soaps, deodorant soaps, etc

□ Nước hoa, nước thơm dùng vệ sinh,....

Perfumes, toilet waters and eau de Cologne

□ Các sản phẩm để tắm hoặc gội (muối, xà phòng, dầu, gel,....)

Bath or shower preparations (salts, foams, oils, gels, etc)

□ Sản phẩm tẩy lông

Depilatories

□ Chất khử mùi và chống mùi

Deodorants and anti-perspirants

□ Các sản phẩm chăm sóc tóc

Hair care products

- Nhuộm và tẩy tóc

Hair tints and bleaches

- Thuốc uốn tóc, duỗi tóc, giữ nếp tóc

Products for waving, straightening and fixing

- Các sản phẩm định dạng tóc

Setting products

- Các sản phẩm làm sạch (sữa, bột, dầu gội)

Cleansing products (lotions, powders, shampoos)

- Sản phẩm cung cấp chất dinh dưỡng cho tóc (sữa, kem, dầu)

Conditioning products (lotions, creams, oils)

- Các sản phẩm tạo kiểu tóc (sữa, keo xịt tóc, sáp)

Hairdressing products (lotions, lacquers, brilliantines)

□ Sản phẩm dùng cạo râu (kem, xà phòng, sữa,....)

Shaving product (creams, foams, lotions, etc)

□ Các sản phẩm trang điểm và tẩy trang dùng cho mặt và mắt

Products for making-up and removing make-up from the face and the eyes

□ Các sản phẩm dùng cho môi

Products intendedfor application to the lips

□ Các sản phẩm để chăm sóc răng và miệng

Products for care of the teeth and the mouth

□ Các sản phẩm dùng để chăm sóc và tô điểm cho móng tay, móng chân

Products for nail care and make-up

□ Các sản phẩm dùng để vệ sinh bên ngoài

Products for external intimate hygiene

□ Các sản phẩm chống nắng

Sunbathing products

□ Sản phẩm làm sạm da mà không cần tắm nắng

Products for tanning without sun

□ Sản phẩm làm trắng da

Skin whitening products

□ Sản phẩm chống nhăn da

Anti-wrinkle products

□ Sản phẩm khác (đề nghị ghi rõ)

Others (please specify)

3. Mục đích sử dụng (Intended use)

 

4. Dạng trình bày (Product presentation(s))

□ Dạng đơn lẻ (Single product)

□ Một nhóm các màu (A range of colours)

□ Bảng các màu trong một dạng sản phẩm (Palette(s) in a range of one product type)

□ Các sản phẩm phối hợp trong một bộ sản phẩm (Combination products in a single kit)

□ Các dạng khác (đề nghị ghi rõ). Others (please specify)

THÔNG TIN VỀ CÔNG TY SẢN XUẤT/ĐÓNG GÓI/XUẤT KHẨU

(Đề nghị đính kèm danh sách riêng nếu như có nhiều hơn một công ty sản xuất/ đóng gói để tạo ra một sản phẩm hoàn chỉnh)

PARTICULARS OF MANUFACTURER(S)/ASSEMBLER(S)/EXPORTER

(Please attach in a separate sheet if there are more than one manufacturer/assembler)

5. Tên Công ty sản xuất (Name of manufacturer):

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Địa chỉ Công ty sản xuất (nước sản xuất) (Address of manufacturer (state country)):

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Country

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Tel

 

 

 

 

 

 

 

 

 

 

 

 

 

Fax:

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

6. Tên công ty đóng gói (Đề nghị đánh dấu vào mục thích hợp. Có thể đánh dấu nhiều hơn 01 ô) (Name of assembler (Please tick accordingly. May tick more than one box)):

□ Đóng gói chính Primary assembler  □ Đóng gói thứ cấp Secondary assembler

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Địa chỉ của công ty đóng gói (Address of assembler (state country)):

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Country

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Tel

 

 

 

 

 

 

 

 

 

 

 

 

 

Fax:

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

7. Tên công ty xuất khẩu (Đề nghị đánh dấu vào mục thích hợp, Chỉ áp dụng đối với sản phẩm mỹ phẩm nhập khẩu) (Name of exporter (Please tick accordingly. Only apply to imported cosmetic products)):

Sản phẩm mỹ phẩm được lưu hành tự do tại nước xuất khẩu: □ Có/Yes □ Không/No (Cosmetic product(s) are free sold in the exporting country)

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Địa chỉ của công ty đóng gói (Address of assembler (state country)):

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Country

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Tel

 

 

 

 

 

 

 

 

 

 

 

 

 

Fax:

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

THÔNG TIN VỀ TỔ CHỨC, CÁ NHÂN CHỊU TRÁCH NHIỆM ĐƯA SẢN PHẨM MỸ PHẨM RA THỊ TRƯỜNG

PARTICULARS OF LOCAL COMPANY RESPONSIBLE FOR PLACING THE COSMETIC PRODUCT IN THE MARKET

8. Tên công ty (Name of company):

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Địa chỉ công ty (Address of company):

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Tel

 

 

 

 

 

 

 

 

 

 

 

 

 

Fax:

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Số giấy phép kinh doanh/Số giấy phép hoạt động

Business Registration Number/License to Operate Number

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

THÔNG TIN VỀ NGƯỜI ĐẠI DIỆN THEO PHÁP LUẬT CỦA CÔNG TY
PARTICULARS OF PERSON REPRESENTING THE LOCAL COMPANY

9. Họ và tên (Name of person):

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Tel

 

 

 

 

 

 

 

 

 

 

 

 

 

Fax:

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Chức vụ ở công ty (Designation in the company):

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

THÔNG TIN VỀ CÔNG TY NHẬP KHẨU

PARTICULARS OF IMPORTER

10. Tên công ty nhập khẩu (Name of importer):

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Địa chỉ công ty nhập khẩu (Address of importer):

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Tel

 

 

 

 

 

 

 

 

 

 

 

 

 

Fax:

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

DANH SÁCH THÀNH PHẦN

PRODUCT INGREDIENT LIST

11. Đề nghị kiểm tra ô sau đây (Please check the following boxes):

□ Tôi đã kiểm tra bản sửa đổi từ Phụ lục II đến Phụ lục VII của danh mục các thành phần mỹ phẩm ASEAN như được công bố trên bản sửa đổi gần đây nhất của Hiệp định mỹ phẩm ASEAN. Tôi xin xác nhận rằng sản phẩm được đề cập đến trong bản công bố này không chứa bất cứ một thành phần bị cấm nào và cũng tuân thủ với danh mục hạn chế và các điều kiện quy định trong các phụ lục.

I have examined the latest revisions of the Annexes II to VII of the ASEAN Cosmetic Ingredient Listing as published in the latest amendment of the ASEAN Cosmetic Directive and confirmed that the product in this notification does not contain any prohibited substances and is in compliance with the restrictions and conditions stipulated in the Annexes.

□ Tôi đảm nhận trách nhiệm trả lời và hợp tác toàn diện với cơ quan có thẩm quyền về bất kỳ hoạt động kiểm soát sau khi bán hàng khi có yêu cầu bởi cơ quan có thẩm quyền.

I undertake to respond to and cooperate fully with the regulatory authority with regard to any subsequent post-marketing activity initiated by the authority.

Danh sách thành phần đầy đủ (Product full ingredient list)

(Yêu cầu ghi đầy đủ danh sách thành phần và tỉ lệ % của những chất có giới hạn về nồng độ, hàm lượng sử dụng trong mỹ phẩm - To submit ingredient list with percentages of restricted ingredients)

No

Tên đầy đủ thành phần (tên danh pháp quốc tế hoặc sử dụng tên khoa học chuẩn đã được công nhận)

Full Ingredient name (use INCI or approved nomenclature in standard references)

Tỉ lệ % của những chất có giới hạn về nồng độ, hàm lượng

1

 

 

2

 

 

3

 

 

4

 

 

5

 

 

6

 

 

7

 

 

8

 

 

9

 

 

...

 

 

CAM KẾT (DECLARATION)

1. Thay mặt cho công ty, tôi xin cam kết sản phẩm được đề cập trong đơn công bố này đạt được tất cả các yêu cầu trong Hướng dẫn Mỹ phẩm ASEAN và các phụ lục của nó.

I hereby declare on behalf of my company that the product in the notification meets all the requirements of the ASEAN Cosmetic Directive, its Annexes and Appendices.

2. Tôi xin chịu trách nhiệm tuân thủ các điều khoản sau đây (I undertake to abide by the following conditions):

i. Đảm bảo có sẵn để cung cấp các thông tin kỹ thuật và tính an toàn khi cơ quan có thẩm quyền yêu cầu và có đầy đủ hồ sơ về các sản phẩm đã được phân phối để báo cáo trong trường hợp sản phẩm phải thu hồi.

Ensure that the product's technical and safety information is made readily available to the regulatory authority concerned (“the Authority”) and to keep records of the distribution of the products for product recall purposes;

ii. Phải thông báo ngay cho cơ quan có thẩm quyền về các tác dụng phụ nghiêm trọng gây chết người hoặc đe dọa tính mạng của sản phẩm bằng điện thoại, fax, thư điện tử hoặc văn bản trước 07 ngày kể từ ngày biết thông tin.

Notify the Authority of fatal or life threatening serious adverse event[1]  as soon as possible by telephone, facsimile transmission, email or in writing, and in any case, no later than 7 calendar days after first knowledge;

iii. Phải hoàn thành báo cáo tác dụng phụ của sản phẩm (theo mẫu quy định) trong vòng 08 ngày làm việc kể từ ngày thông báo cho cơ quan có thẩm quyền về những tác dụng phụ nghiêm trọng như đã nêu trong mục 2 ii nói trên và cung cấp bất cứ thông tin nào theo yêu cầu của cơ quan có thẩm quyền.

Complete the Adverse Cosmetic Event Report Form[2] within 8 calendar days from the date of my notification to the Authority in para 2 ii. above, and to provide any other information as may be requested by the Authority;

iv. Thông báo ngay cho cơ quan có thẩm quyền về các phản ứng phụ nghiêm trọng nhưng không gây chết người hoặc đe dọa đến tính mạng của sản phẩm và trong bất cứ trường hợp nào, việc báo cáo (sử dụng mẫu báo cáo) về tác dụng phụ phải được tiến hành trước 15 ngày kể từ ngày biết về tác dụng phụ này.

Report to the Authority of all other serious adverse events that are not fatal or life threatening as soon as possible, and in any case, no later than 15 calendar days after first knowledge, using the Adverse Cosmetic Event Report Form;

v. Công bố với cơ quan có thẩm quyền khi có bất cứ sự thay đổi nào trong bản công bố này.

Notify the Authority of any change in the particulars submitted in this notification;

3. Tôi xin cam đoan rằng những thông tin được đưa ra trong bản công bố này là đúng sự thật. Tất cả các tài liệu, các thông tin liên quan đến nội dung công bố sẽ được cung cấp và các tài liệu đính kèm là bản hợp pháp hoặc sao y bản chính.

I declare that the particulars given in this notification are true, all data, and information of relevance in relation to the notification have been supplied and that the documents enclosed are authentic or true copies.

4. Tôi hiểu rằng tôi sẽ có trách nhiệm để đảm bảo tất cả các lô sản phẩm của chúng tôi đều đáp ứng các yêu cầu pháp luật, và tuân thủ tất cả tiêu chuẩn và chỉ tiêu sản phẩm đã được công bố với cơ quan có thẩm quyền.

I understand that I shall be responsible for ensuring that each consignment of my product continues to meet all the legal requirements, and conforms to all the standards and specifications of the product that I have declared to the Authority.

5. Tôi hiểu rằng trong trường hợp có tranh chấp pháp luật, tôi không được quyền sử dụng bản công bố chất lượng sản phẩm đã được cơ quan có thẩm quyền chấp nhận nếu sản phẩm của chúng tôi không đạt được các yêu cầu về tiêu chuẩn, chỉ tiêu mà chúng tôi đã công bố.

I understand that I cannot place reliance on the acceptance of my product notification by the authority in any legal proceedings concerning my product, in the event that my product has failed to conform to any of the standards or specifications that I had previously declared to the Authority.

_________________________________________________________________________

Tên và chữ ký của người đại diện theo pháp luật của công ty

[Name and Signature of person representing the local company]

 

 

 

__________________

Dấu của công ty

[Company stamp]

 

 

__________________

Ngày

[Date]

 



lồng nhau (bên trong) hay không const memberID = 0; const vbID = '381e515553b2da1e876de2e1922ac5b8'; // State management cho phân tích let isAnalyzing = false; // Có đang phân tích không let currentAnalyzingAddress = null; // Address đang được phân tích let currentAnalyzingElement = null; // Element đang được phân tích let currentAnalyzingBadge = null; // Badge của element đang phân tích let isPanelOpen = false; // Panel phân tích có đang mở không console.log('Tiện ích loaded - memberID:', memberID, 'vbID:', vbID); function isInViewportAndTabNoiDung(element) { const rect = element.getBoundingClientRect(); const buffer = 1500; // Buffer to preload content below the viewport (approx. 50+ lines) const viewHeight = window.innerHeight || document.documentElement.clientHeight; const isInViewport = rect.top < viewHeight + buffer && rect.bottom >= 0; const isInTabNoiDung = $(element).closest('#tab_noi_dung_vb').length > 0; return isInViewport && isInTabNoiDung; } function getAddress(element) { const validTags = ['trichyeu', 'cancu', 'phan', 'chuong', 'muc', 'tieumuc', 'dieu', 'khoan', 'diem']; const $parent = $(element).closest(validTags.join(',')); if (!$parent.length) { return null; } let addr = $parent.attr('address'); if (!addr && $parent.prop('tagName').toLowerCase() === 'trichyeu') { addr = 'trichyeu'; $parent.attr('address', addr); } return addr || null; } function processTnplClasses($element) { const tnplKeysInLine = new Set(); // key = slug hoặc text (thường là slug) $element.find('tnpl').each(function () { const $tnpl = $(this); const tnplSlug = ($tnpl.attr('slug') || '').trim().toLowerCase(); const tnplKey = tnplSlug || $tnpl.text().trim().toLowerCase(); // Đã xử lý trong cùng dòng => bỏ if (tnplKeysInLine.has(tnplKey)) { return; } tnplKeysInLine.add(tnplKey); let tnplExists = false; // Chỉ duyệt các tnpl đã được tô màu (class on) $('tnpl.on').each(function () { const $existingTnpl = $(this); const existingSlug = ($existingTnpl.attr('slug') || '').trim().toLowerCase(); const existingKey = existingSlug || $existingTnpl.text().trim().toLowerCase(); if ( existingKey === tnplKey && isInViewportAndTabNoiDung($existingTnpl[0]) ) { tnplExists = true; return false; // break each } }); if (!tnplExists) { $tnpl.addClass('on'); } }); } function processQueue() { while (pendingRequests < maxConcurrentRequests && requestQueue.length > 0) { const task = requestQueue.shift(); pendingRequests++; task() .always(() => { pendingRequests--; processQueue(); }); } } function processVisibleParagraphs() { try { $('#tab_noi_dung_vb p:not([is-posted="1"])').each(function () { let $element = $(this); if (isInViewportAndTabNoiDung(this)) { $element.attr('is-posted', '1'); $element.addClass('loading-content'); let p_innerHTML = $element.html(); let address = null; if (cac_cau_hinh.loai_noi_dung.includes('docs')) { address = getAddress($element); } const isSubP = $element.parents('p').length > 0; if (isSubP && !allow_sub_p) { $element.removeClass('loading-content'); return; // Không gửi nếu không cho phép } const postData = { p_content: p_innerHTML, cac_cau_hinh, address }; if (isSubP && allow_sub_p) { postData.sub_p = 1; } requestQueue.push(() => $.ajax({ url: '//tnpl' + (Math.floor(Math.random() * 10) + 1) + '.hethongphapluat.com/tien-ich/tim.tien.ich.php', type: 'POST', data: postData, success: function(response) { $element.html(response); processTnplClasses($element); // Đợi CTTD và các tiện ích load xong rồi mới attach badge if (memberID === 4 && typeof attachPhanTichBadge === 'function') { setTimeout(function() { // $element chính là thẻ p, kiểm tra và attach badge trực tiếp const $parent = $element.closest('phan, chuong, muc, tieumuc, dieu, khoan, diem'); if ($parent.length > 0 && $parent.find('.badge-phan-tich[data-for="' + $parent.attr('address') + '"]').length === 0) { const address = $parent.attr('address'); $element.attr('data-address', address); // Lấy tên loại thẻ cho tooltip const parentType = getParentTypeName($parent.prop('tagName').toLowerCase()); // Append badge VÀO PARENT (dieu, khoan,...) thay vì vào

để tránh xung đột CTTD const $badge = $('Phân tích'); $parent.append($badge); // Thêm class để CSS set position: relative CHỈ cho element có badge $parent.addClass('has-phan-tich-badge'); } // Xử lý các p con (nếu có sub-p) attachPhanTichBadge($element); }, 300); // Đợi 300ms để CTTD render xong } }, complete: function() { $element.removeClass('loading-content'); } }) ); processQueue(); } }); } catch(e) { console.error('Lỗi processVisibleParagraphs:', e); } } $(window).on('scroll resize', function () { processVisibleParagraphs(); }); console.log('Bắt đầu processVisibleParagraphs lần đầu...'); processVisibleParagraphs(); console.log('processVisibleParagraphs lần đầu hoàn thành'); // Chức năng phân tích điều luật (chỉ cho member_id = 4) if (memberID === 4) { // Modal cảnh báo function showWarningModal(message) { // Tạo modal nếu chưa có if ($('#warningModal').length === 0) { const modalHTML = `

`; $('body').append(modalHTML); } $('#warningModalBody').html('

' + message + '

'); $('#warningModal').modal('show'); } // Hàm lấy tên tiếng Việt của thẻ function getParentTypeName(tagName) { const typeNames = { 'phan': 'Phần', 'chuong': 'Chương', 'muc': 'Mục', 'tieumuc': 'Tiểu mục', 'dieu': 'Điều', 'khoan': 'Khoản', 'diem': 'Điểm' }; return typeNames[tagName] || 'Nội dung'; } function attachPhanTichBadge($container) { const validTags = 'phan, chuong, muc, tieumuc, dieu, khoan, diem'; $container.find('p').each(function() { const $p = $(this); const $parent = $p.closest(validTags); if ($parent.length > 0) { const address = $parent.attr('address'); // Kiểm tra đã có badge cho parent này chưa if ($parent.find('.badge-phan-tich[data-for="' + address + '"]').length === 0) { // Lưu address vào data attribute $p.attr('data-address', address); // Lấy tên loại thẻ cho tooltip const parentType = getParentTypeName($parent.prop('tagName').toLowerCase()); // Append badge vào PARENT, không vào

const $badge = $('Phân tích'); $parent.append($badge); // Thêm class để CSS set position: relative CHỈ cho element có badge $parent.addClass('has-phan-tich-badge'); } } }); } // Helper: Escape HTML entities function escapeHtml(text) { const map = { '&': '&', '<': '<', '>': '>', '"': '"', "'": ''' }; return String(text).replace(/[&<>"']/g, function(m) { return map[m]; }); } // Helper: Convert Markdown to HTML (đơn giản) function markdownToHtml(markdown) { if (!markdown) return ''; let html = markdown; // Headers html = html.replace(/^### (.*$)/gim, '

$1
'); html = html.replace(/^## (.*$)/gim, '

$1

'); html = html.replace(/^# (.*$)/gim, '

$1

'); // Bold html = html.replace(/\*\*(.*?)\*\*/g, '$1'); // Italic html = html.replace(/\*(.*?)\*/g, '$1'); // Blockquote html = html.replace(/^> (.*$)/gim, '
$1
'); html = html.replace(/^> (.*$)/gim, '
$1
'); // Lists (unordered) html = html.replace(/^\- (.*$)/gim, '
  • $1
  • '); html = html.replace(/(
  • .*<\/li>)/s, '
      $1
    '); // Lists (ordered) html = html.replace(/^\d+\. (.*$)/gim, '
  • $1
  • '); // Line breaks và paragraphs html = html.split('\n\n').map(para => { para = para.trim(); if (para.startsWith('')) { return para; } if (para) { return '

    ' + para.replace(/\n/g, '
    ') + '

    '; } return ''; }).join('\n'); // Clean up multiple line breaks html = html.replace(/\n{3,}/g, '\n\n'); return html; } // Panel fixed position function closePhanTichPanel() { const $panel = $('#phanTichPanel'); if ($panel.length) { $panel.removeClass('show'); setTimeout(() => { $panel.remove(); }, 300); } // Reset highlight và badge khi đóng panel if (currentAnalyzingElement) { currentAnalyzingElement.removeClass('highlight-border-persistent'); } if (currentAnalyzingBadge) { currentAnalyzingBadge.text('Phân tích').removeClass('analyzing'); currentAnalyzingBadge.data('analyzing', false); currentAnalyzingBadge.data('hovering', false); currentAnalyzingBadge.css({display: 'none'}); // Ẩn badge khi đóng } // Reset tất cả các element khác (trong trường hợp có nhiều) $('#tab_noi_dung_vb .highlight-border-persistent').removeClass('highlight-border-persistent'); $('#tab_noi_dung_vb .badge-phan-tich-container.analyzing').each(function() { $(this).text('Phân tích').removeClass('analyzing').data('analyzing', false); }); // Check: có CTTD pointer đang mở không? const $visiblePointers = $('.pointer:visible'); const hadCTTDOpen = $visiblePointers.length > 0; if (hadCTTDOpen) { // CÓ CTTD đang mở → giữ rightdocinfo ẩn console.log('ℹ️ CTTD pointer is visible, keeping rightdocinfo hidden'); } else { // KHÔNG có CTTD → SHOW lại rightdocinfo const $rightdocinfo = $('#rightdocinfo'); if ($rightdocinfo.length > 0) { $rightdocinfo.show(); console.log('✅ Showing rightdocinfo back (no CTTD pointer)'); } } // Reset state isAnalyzing = false; currentAnalyzingAddress = null; currentAnalyzingElement = null; currentAnalyzingBadge = null; isPanelOpen = false; // Đánh dấu panel đã đóng console.log('✅ Panel closed, state reset, isPanelOpen = false'); } // Panel đã song song với rightdocinfo → không cần MutationObserver nữa console.log('✅ Panel running in standalone mode (parallel to rightdocinfo)'); // Resize event để update panel dimensions khi browser resize let resizeTimer; $(window).on('resize', function() { clearTimeout(resizeTimer); resizeTimer = setTimeout(function() { if (isPanelOpen && $('#phanTichPanel').length > 0) { updatePanelDimensions(); console.log('✅ Panel dimensions updated on window resize'); } }, 250); // Debounce 250ms }); // Function để detect và áp dụng dimensions từ rightdocinfo function updatePanelDimensions() { const $panel = $('#phanTichPanel'); const $rightdocinfo = $('#rightdocinfo'); const $docRightCol = $('#doc-right-col'); if ($panel.length === 0) return; // Ưu tiên: doc-right-col > rightdocinfo let $reference = $docRightCol.length > 0 ? $docRightCol : $rightdocinfo; // Nếu reference bị ẩn (display:none), tạm show để get dimensions let wasHidden = false; if ($reference.length > 0 && !$reference.is(':visible')) { wasHidden = true; $reference.css('visibility', 'hidden').show(); } if ($reference.length > 0) { const refWidth = $reference.outerWidth(); const refOffset = $reference.offset(); if (refWidth && refOffset) { // Tính vị trí right từ edge màn hình const windowWidth = $(window).width(); const rightPosition = windowWidth - (refOffset.left + refWidth); $panel.css({ 'width': refWidth + 'px', 'right': rightPosition + 'px' }); console.log('✅ Panel dimensions updated:', { width: refWidth + 'px', right: rightPosition + 'px', reference: $reference.attr('id') }); } else { console.warn('⚠️ Could not get dimensions from reference element'); } // Restore trạng thái hidden nếu cần if (wasHidden) { $reference.hide().css('visibility', ''); } } else { console.warn('⚠️ No reference element found for panel dimensions'); } } function openPhanTichPanel(address, vbID) { console.log('openPhanTichPanel called with address:', address); console.log('Current state - isAnalyzing:', isAnalyzing, 'currentAnalyzingAddress:', currentAnalyzingAddress); // Kiểm tra nếu đang phân tích element khác if (isAnalyzing && currentAnalyzingAddress && currentAnalyzingAddress !== address) { const currentName = getElementDisplayName(currentAnalyzingAddress); console.warn('Already analyzing:', currentAnalyzingAddress, 'Cannot analyze:', address); showWarningModal('Vui lòng chờ phân tích ' + currentName + ' hoàn tất...'); return; } // Nếu đang phân tích cùng element → không làm gì if (isAnalyzing && currentAnalyzingAddress === address) { console.log('Already analyzing this element, ignoring duplicate request'); return; } // Panel sẽ fixed position append vào body const $rightdocinfo = $('#rightdocinfo'); // KHÔNG ẨN CTTD pointer - cho phép CTTD và panel cùng tồn tại console.log('Panel opening, CTTD pointer can stay visible'); // ẨN rightdocinfo để tiết kiệm không gian if ($rightdocinfo.length > 0) { $rightdocinfo.hide(); console.log('Hidden rightdocinfo to save space'); } // XÓA highlight persistent của TẤT CẢ elements cũ trước $('#tab_noi_dung_vb .highlight-border-persistent').removeClass('highlight-border-persistent'); console.log('Removed all previous highlight-border-persistent'); // Tìm element đang được phân tích và badge của nó const $element = $('[address="' + address + '"]'); const $badge = $element.find('.badge-phan-tich-container[data-for="' + address + '"]').first(); // Set state isAnalyzing = true; currentAnalyzingAddress = address; currentAnalyzingElement = $element; currentAnalyzingBadge = $badge; console.log('State set:', { isAnalyzing: isAnalyzing, currentAnalyzingAddress: currentAnalyzingAddress, elementFound: $element.length > 0, badgeFound: $badge.length > 0 }); // Thêm highlight persistent cho element MỚI này $element.addClass('highlight-border-persistent'); // Thay đổi badge thành "Đang phân tích..." và giữ hiển thị if ($badge.length > 0) { $badge.text('Đang phân tích...').addClass('analyzing'); // Giữ badge hiển thị và ở đúng vị trí $badge.data('analyzing', true); $badge.data('hovering', true); // Prevent auto-hide console.log('Badge set to analyzing state'); // Đảm bảo badge hiển thị ở đúng vị trí (vì dùng position: fixed) showPhanTichBadgeForParent($element); } // Tạo panel nếu chưa có - fixed position append vào body if ($('#phanTichPanel').length === 0) { const panelHTML = `
    Phân tích điều luật
    Đang phân tích...

    Đang phân tích...

    `; // Append vào body (fixed position không cần container cụ thể) $('body').append(panelHTML); // Detect width từ rightdocinfo và áp dụng cho panel updatePanelDimensions(); // Trigger show và set flag setTimeout(() => { $('#phanTichPanel').addClass('show'); isPanelOpen = true; console.log('✅ Panel opened (fixed position), isPanelOpen = true'); }, 10); } else { $('#phanTichPanelBody').html(`
    Đang phân tích...

    Đang phân tích...

    `); // Update dimensions khi re-open updatePanelDimensions(); $('#phanTichPanel').addClass('show'); isPanelOpen = true; console.log('✅ Panel re-opened (fixed position), isPanelOpen = true'); } // Bind nút đóng và ESC $(document).off('click.closePhanTich').on('click.closePhanTich', '.close-phan-tich', function() { closePhanTichPanel(); }); $(document).off('keyup.closePhanTich').on('keyup.closePhanTich', function(e) { if (e.key === 'Escape') closePhanTichPanel(); }); // Bind nút refresh - phân tích lại $(document).off('click.refreshPhanTich').on('click.refreshPhanTich', '.btn-refresh-phan-tich', function(e) { e.preventDefault(); e.stopPropagation(); const $btn = $(this); const $icon = $btn.find('i'); // Disable button và thêm animation $btn.prop('disabled', true); $icon.addClass('fa-spin'); console.log('🔄 Refresh: Phân tích lại address:', address); // Show loading trong panel $('#phanTichPanelBody').html(`
    Đang phân tích lại...

    Đang xóa cache và phân tích lại...

    `); // Gọi API xóa cache trước deletePhanTichCache(address, vbID, function(deleteSuccess) { if (deleteSuccess) { console.log('✅ Cache deleted, now re-analyzing...'); // Sau khi xóa cache, gọi lại API phân tích callPhanTichAPI(address, vbID, function() { // Enable lại button $btn.prop('disabled', false); $icon.removeClass('fa-spin'); }); } else { console.error('❌ Failed to delete cache'); $('#phanTichPanelBody').html(` `); $btn.prop('disabled', false); $icon.removeClass('fa-spin'); } }); }); // Gọi API phân tích (dùng function helper) callPhanTichAPI(address, vbID); } // Helper: Gọi API phân tích (tách riêng để dùng lại) function callPhanTichAPI(address, vbID, callback) { const randomServer = Math.floor(Math.random() * 10) + 1; $.ajax({ url: '//tnpl' + randomServer + '.hethongphapluat.com/tien-ich/phan.tich.dieu.luat.php', type: 'POST', contentType: 'application/json', timeout: 300000, // 5 phút data: JSON.stringify({ address: address, vb_id: vbID }), success: function(response) { console.log('Analysis complete for:', address, response); // Reset badge về trạng thái bình thường (nhưng vẫn hiển thị) if (currentAnalyzingBadge) { currentAnalyzingBadge.text('Phân tích').removeClass('analyzing'); currentAnalyzingBadge.data('analyzing', false); console.log('Badge reset to normal state'); } // Reset state analyzing để có thể phân tích element khác isAnalyzing = false; console.log('State reset: isAnalyzing = false, can analyze other elements now'); if (response.ok) { // Render kết quả phân tích let html = ''; html += '
    '; html += '
    ' + escapeHtml(response.ten_van_ban) + '
    '; if (response.so_hieu) { html += 'Số hiệu: ' + escapeHtml(response.so_hieu) + '
    '; } html += 'Điều khoản: ' + escapeHtml(response.address) + ''; if (response.from_cache) { html += ' Cache'; } html += '
    '; html += '
    ' + markdownToHtml(response.phan_tich) + '
    '; if (response.usage) { html += '
    '; html += 'Thống kê: '; html += 'Input tokens: ' + (response.usage.promptTokenCount || 0) + ', '; html += 'Output tokens: ' + (response.usage.candidatesTokenCount || 0); html += '
    '; } $('#phanTichPanelBody').html(html); } else { $('#phanTichPanelBody').html(` `); } if (callback) callback(); }, error: function(xhr, status, error) { console.error('Analysis error:', error); // Reset badge về trạng thái bình thường if (currentAnalyzingBadge) { currentAnalyzingBadge.text('Phân tích').removeClass('analyzing'); currentAnalyzingBadge.data('analyzing', false); } // Reset state analyzing isAnalyzing = false; let errorMsg = error; if (xhr.responseJSON && xhr.responseJSON.error) { errorMsg = xhr.responseJSON.error; } $('#phanTichPanelBody').html(` `); if (callback) callback(); } }); } // Helper: Xóa cache phân tích function deletePhanTichCache(address, vbID, callback) { const randomServer = Math.floor(Math.random() * 10) + 1; $.ajax({ url: '//tnpl' + randomServer + '.hethongphapluat.com/tien-ich/delete.phan.tich.cache.php', type: 'POST', contentType: 'application/json', timeout: 10000, data: JSON.stringify({ address: address, vb_id: vbID }), success: function(response) { console.log('Delete cache response:', response); if (callback) callback(response.ok || false); }, error: function(xhr, status, error) { console.error('Delete cache error:', error); if (callback) callback(false); } }); } // Helper: Lấy tên hiển thị của element từ address function getElementDisplayName(address) { if (!address) return 'nội dung'; const $element = $('[address="' + address + '"]'); if ($element.length === 0) return address; // Parse address: vd "dieu_3_khoan_29" -> "Khoản 29 Điều 3" // Address format: lớn đến nhỏ (phan > chuong > muc > dieu > khoan > diem) const parts = address.split('_'); const displayParts = []; for (let i = 0; i < parts.length; i += 2) { if (i + 1 < parts.length) { const type = getParentTypeName(parts[i]); const num = parts[i + 1]; displayParts.push(type + ' ' + num); } } // Reverse để hiển thị từ nhỏ đến lớn: "Khoản 29 Điều 3" (thay vì "Điều 3 Khoản 29") return displayParts.reverse().join(' '); } function openPhanTichModal(address, vbID) { // Tạo modal nếu chưa có if ($('#modalPhanTich').length === 0) { const modalHTML = ` `; $('body').append(modalHTML); } // Reset và hiển thị modal với loading $('#modalPhanTichBody').html(`
    Đang phân tích...

    Đang phân tích...

    `); $('#modalPhanTich').modal('show'); // AJAX request const randomServer = Math.floor(Math.random() * 10) + 1; $.ajax({ url: '//tnpl' + randomServer + '.hethongphapluat.com/tien-ich/phan.tich.dieu.luat.php', type: 'POST', contentType: 'application/json', data: JSON.stringify({ address: address, vb_id: vbID }), success: function(response) { if (response.ok) { // Render kết quả phân tích let html = ''; // Header thông tin văn bản html += '
    '; html += '
    ' + escapeHtml(response.ten_van_ban) + '
    '; if (response.so_hieu) { html += 'Số hiệu: ' + escapeHtml(response.so_hieu) + '
    '; } html += 'Điều khoản: ' + escapeHtml(response.address) + ''; html += '
    '; // Nội dung phân tích (Markdown -> HTML) html += '
    '; html += markdownToHtml(response.phan_tich); html += '
    '; // Thông tin usage (nếu có) if (response.usage) { html += '
    '; html += 'Thống kê: '; html += 'Input tokens: ' + (response.usage.promptTokenCount || 0) + ', '; html += 'Output tokens: ' + (response.usage.candidatesTokenCount || 0); html += '
    '; } $('#modalPhanTichBody').html(html); } else { $('#modalPhanTichBody').html(` `); } }, error: function(xhr, status, error) { let errorMsg = error; if (xhr.responseJSON && xhr.responseJSON.error) { errorMsg = xhr.responseJSON.error; } $('#modalPhanTichBody').html(` `); } }); } // Helpers: show/hide badge cho parent element (dieu, khoan,...) với position: fixed function showPhanTichBadgeForParent($parent) { // Lấy badge CỦA CHÍNH parent này (match data-for với address của parent) const parentAddress = $parent.attr('address'); const $badge = $parent.find('.badge-phan-tich-container[data-for="' + parentAddress + '"]').first(); if ($badge.length === 0) { console.warn('No badge found for parent:', parentAddress); return; } // Ẩn TẤT CẢ các badge khác để tránh overlap $('.badge-phan-tich-container').not($badge).each(function() { const $otherBadge = $(this); // Chỉ ẩn badge KHÔNG đang analyzing if (!$otherBadge.data('analyzing')) { $otherBadge.css({display: 'none'}); } }); // Show badge tạm để tính width $badge.css({display: 'inline-block', opacity: 0, visibility: 'hidden'}); const badgeWidth = $badge.outerWidth(); // Tính toán vị trí fixed dựa trên offset của parent const offset = $parent.offset(); const scrollTop = $(window).scrollTop(); const scrollLeft = $(window).scrollLeft(); // Position badge top-right của parent và show $badge.css({ display: 'inline-block', visibility: 'visible', opacity: 1, top: (offset.top - scrollTop) + 'px', left: (offset.left + $parent.outerWidth() - badgeWidth - scrollLeft - 5) + 'px' // -5px padding }); console.log('Showing badge for:', parentAddress, 'at position:', $badge.css('top'), $badge.css('left')); $parent.addClass('highlight-border'); } function hidePhanTichBadgeForParent($parent) { const $badge = $parent.find('.badge-phan-tich-container').first(); if ($badge.length === 0) return; $badge.css({display: 'none', opacity: 0}); $parent.removeClass('highlight-border'); } // Biến lưu element đang hover let currentHoveredElement = null; let hoverDebounceTimer = null; // Dùng mousemove để track chính xác element nào đang được hover $(document).on('mousemove', '#tab_noi_dung_vb', function(e) { // Tìm element gần nhất (phan, chuong, muc, dieu, khoan, diem) tại vị trí chuột const $target = $(e.target).closest('phan, chuong, muc, tieumuc, dieu, khoan, diem'); if ($target.length === 0) { // Không hover vào element nào return; } const address = $target.attr('address'); // Nếu đang hover vào cùng element → skip if (currentHoveredElement && currentHoveredElement[0] === $target[0]) { return; } // Clear debounce timer cũ if (hoverDebounceTimer) { clearTimeout(hoverDebounceTimer); } // Debounce để tránh trigger quá nhiều hoverDebounceTimer = setTimeout(function() { // Element thay đổi console.log('Hover changed to:', address); // Set flag hovering cho element mới $target.data('hovering', true); // Cancel timeout nếu có const timeoutId = $target.data('hideTimeout'); if (timeoutId) { clearTimeout(timeoutId); } // Ẩn badge của TẤT CẢ elements khác $('#tab_noi_dung_vb phan, #tab_noi_dung_vb chuong, #tab_noi_dung_vb muc, #tab_noi_dung_vb tieumuc, #tab_noi_dung_vb dieu, #tab_noi_dung_vb khoan, #tab_noi_dung_vb diem') .not($target) .each(function() { const $el = $(this); // Chỉ xóa highlight-border, KHÔNG xóa highlight-border-persistent $el.removeClass('highlight-border'); // Ẩn badge nếu KHÔNG đang analyzing const $badge = $el.find('.badge-phan-tich-container'); if ($badge.length && !$badge.data('analyzing')) { $badge.css({display: 'none'}); } }); // Attach badge nếu chưa có if (address && $target.find('.badge-phan-tich-container[data-for="' + address + '"]').length === 0) { const parentType = getParentTypeName($target.prop('tagName').toLowerCase()); const $badge = $('Phân tích'); console.log('Creating badge for address:', address, 'parentType:', parentType); $target.append($badge); $target.addClass('has-phan-tich-badge'); } // Show badge cho element này if ($target.find('.badge-phan-tich-container').length > 0) { showPhanTichBadgeForParent($target); } // Update current hovered element currentHoveredElement = $target; }, 50); // Debounce 50ms }); // Event delegation cho hover ra khỏi #tab_noi_dung_vb $(document).on('mouseleave', '#tab_noi_dung_vb', function(e) { // Clear current hovered element currentHoveredElement = null; // Ẩn tất cả badge không đang analyzing sau một khoảng thời gian setTimeout(function() { if (currentHoveredElement === null) { // Chỉ ẩn nếu thực sự không hover vào element nào $('#tab_noi_dung_vb phan, #tab_noi_dung_vb chuong, #tab_noi_dung_vb muc, #tab_noi_dung_vb tieumuc, #tab_noi_dung_vb dieu, #tab_noi_dung_vb khoan, #tab_noi_dung_vb diem') .each(function() { const $el = $(this); const $badge = $el.find('.badge-phan-tich-container'); if ($badge.length && !$badge.data('analyzing')) { $badge.css({display: 'none'}); } }); console.log('Mouse left tab_noi_dung_vb, hiding all badges'); } }, 300); }); // Event delegation cho hover ra khỏi parent (giữ lại cho badge behavior) $(document).on('mouseleave', '#tab_noi_dung_vb phan, #tab_noi_dung_vb chuong, #tab_noi_dung_vb muc, #tab_noi_dung_vb tieumuc, #tab_noi_dung_vb dieu, #tab_noi_dung_vb khoan, #tab_noi_dung_vb diem', function(e) { const $parent = $(this); const parentAddress = $parent.attr('address'); const $badge = $parent.find('.badge-phan-tich-container[data-for="' + parentAddress + '"]').first(); // Set flag parent not hovering $parent.data('hovering', false); // Nếu badge đang analyzing thì KHÔNG ẩn, GIỮ hiển thị if ($badge.length > 0 && $badge.data('analyzing')) { console.log('Badge is analyzing, keep visible'); return; } // Delay để có thời gian di chuột vào badge const timeoutId = setTimeout(() => { // Chỉ ẩn nếu cả parent và badge đều không hover và không analyzing if ($badge.length > 0 && !$parent.data('hovering') && !$badge.data('hovering') && !$badge.data('analyzing')) { hidePhanTichBadgeForParent($parent); } }, 300); // Tăng lên 300ms $parent.data('hideTimeout', timeoutId); }); // Hover vào badge → giữ hiển thị $(document).on('mouseenter', '.badge-phan-tich-container', function(e) { e.stopPropagation(); const $badge = $(this); const $parent = $badge.parent(); $badge.data('hovering', true); // Cancel timeout của parent const timeoutId = $parent.data('hideTimeout'); if (timeoutId) { clearTimeout(timeoutId); } }); // Hover ra khỏi badge → ẩn nếu không hover parent $(document).on('mouseleave', '.badge-phan-tich-container', function(e) { const $badge = $(this); $badge.data('hovering', false); const $parent = $badge.parent(); // Nếu badge đang analyzing thì KHÔNG ẩn, GIỮ hiển thị if ($badge.data('analyzing') || $badge.hasClass('analyzing')) { console.log('Badge is analyzing on mouseleave, keep visible'); return; } setTimeout(() => { // Chỉ ẩn nếu cả parent và badge đều không hover và không analyzing if (!$parent.data('hovering') && !$badge.data('hovering') && !$badge.data('analyzing') && !$badge.hasClass('analyzing')) { hidePhanTichBadgeForParent($parent); } }, 300); }); // Event delegation cho hover vào badge → hiện tooltip $(document).on('mouseenter', '.badge-phan-tich, .badge-phan-tich-container, .badge-phan-tich-fixed', function() { const $badge = $(this); const parentType = $badge.attr('data-parent-type') || 'Nội dung'; if ($badge.find('.badge-tooltip').length === 0) { const $tooltip = $('Phân tích chi tiết nội dung ' + parentType + ' này'); $badge.append($tooltip); setTimeout(() => $tooltip.addClass('show'), 10); } }); // Event delegation cho hover ra khỏi badge → ẩn tooltip $(document).on('mouseleave', '.badge-phan-tich, .badge-phan-tich-container, .badge-phan-tich-fixed', function() { const $tooltip = $(this).find('.badge-tooltip'); if ($tooltip.length > 0) { $tooltip.removeClass('show'); setTimeout(() => $tooltip.remove(), 300); } }); // Event delegation cho click badge → mở panel $(document).on('click', '.badge-phan-tich, .badge-phan-tich-container, .badge-phan-tich-fixed', function(e) { e.preventDefault(); e.stopPropagation(); const $badge = $(this); console.log('Badge clicked! Element:', $badge[0]); console.log('Badge parent:', $badge.parent().prop('tagName'), $badge.parent().attr('address')); console.log('Badge data-for:', $badge.attr('data-for')); console.log('Badge data-parent-type:', $badge.attr('data-parent-type')); // Nếu badge đang analyzing thì không cho click if ($badge.hasClass('analyzing') || $badge.data('analyzing')) { console.log('Badge is analyzing, click ignored'); return; } // Lấy address từ data-for attribute const address = $badge.attr('data-for'); console.log('Will analyze address:', address, 'vbID:', vbID); if (address && vbID) { openPhanTichPanel(address, vbID); } else { console.error('Missing address or vbID', {address, vbID}); showWarningModal('Không tìm thấy địa chỉ điều luật hoặc ID văn bản!'); } }); // Ẩn badge khi click vào CTTD $(document).on('click', 'cttd.chuthichtudong span, dctk span, dctd span', function(e) { console.log('CTTD clicked'); // Ẩn TẤT CẢ badge KHÔNG đang analyzing $('.badge-phan-tich-container').each(function() { const $badge = $(this); if (!$badge.data('analyzing') && !$badge.hasClass('analyzing')) { $badge.css({display: 'none'}); console.log('Hiding badge:', $badge.attr('data-for')); } }); }); // Update badge position khi scroll hoặc resize (vì dùng position: fixed) function updateBadgePositions() { $('.badge-phan-tich-container:visible').each(function() { const $badge = $(this); const $parent = $badge.parent(); // Cập nhật position nếu parent đang hover HOẶC badge đang analyzing if ($parent.length && ($parent.is(':hover') || $badge.data('analyzing'))) { // Re-calculate position const offset = $parent.offset(); const scrollTop = $(window).scrollTop(); const scrollLeft = $(window).scrollLeft(); const badgeWidth = $badge.outerWidth(); $badge.css({ top: (offset.top - scrollTop) + 'px', left: (offset.left + $parent.outerWidth() - badgeWidth - scrollLeft - 5) + 'px' }); } }); } $(window).on('scroll', updateBadgePositions); $(window).on('resize', updateBadgePositions); } });