Trang tài liệu Trí Nam

Cho người ta một phần mềm, bạn sẽ làm họ bực mình một ngày - Dạy người ta lập trình, họ sẽ bực mình cả đời

FileUploadControlSchema

Estimated reading: 4 minutes 178 views

Hình ảnh / Demo

Mục đích

Dùng để tạo 1 ô input nhập văn bản nhiều dòng trong form.

Cách dùng

Import

Import vào đầu file .ts cần sử dụng

				
					import { FileUploadControlSchema } from 'tnx-shared';
				
			

Cách dùng cơ bản

FileUploadControlSchema được thêm vào trong this.setting.schema khi khởi tạo form.

				
					...
ngOnInit() {
...
    new FileUploadControlSchema({
        field: 'fileImport',
        label: 'Import từ excel (theo mẫu đã tải về)',
        serviceCode: this.setting.baseService.serviceCode,
        entity: this.setting.baseService.entityName,
        mdWidth: 11,
        autoSaved: true,
        
    }),
  ...
]
...
}
...
				
			

Tùy chỉnh ẩn-hiện các nút action

				
					
    new FileUploadControlSchema({
        field: 'fileImport',
        label: 'Import từ excel (theo mẫu đã tải về)',
        serviceCode: this.setting.baseService.serviceCode,
        entity: this.setting.baseService.entityName,
        mdWidth: 11,
        showDownloadFile: false; // mặc định là true
        showDeleteFile: false;   // mặc định là true
        showPrintFile : false;   // mặc định là true 
    }),
				
			

Cấu hình kích thước upload file

				
					
    new FileUploadControlSchema({
        field: 'fileImport',
        label: 'Import từ excel (theo mẫu đã tải về)',
        serviceCode: this.setting.baseService.serviceCode,
        entity: this.setting.baseService.entityName,
        mdWidth: 11,
        maxFileSize: 1024    // đơn vị byte
    }),
				
			

Thuộc tính

Sự kiện

				
					
  new FileUploadControlSchema({
      field: 'myField',
      label: 'Trường muốn dùng',
      onChanged: (eventData: EventData) => {
        console.log(eventData);
        if (this.model.data.property || <>) {
            evt.formControls['other control name'].hidden = true;
        } else {
        evt.formControls['other control name'].hidden = false;
        }
      },
      // nếu là thành viên ngoài trường thì hiện, không phải thì ẩn đi
      hiddenCheck: (rootModel, currentNode) => {
         return !currentNode.parentNode.parentModel.isThanhVienNgoaiTruong;
      },
  })
				
			
CONTENTS