/// <summary> /// /// </summary> /// <param name="args"></param> /// <returns></returns> protected override async Task OnFileChange(InputFileChangeEventArgs args) { CurrentFile = new UploadFile() { OriginFileName = args.File.Name, Size = args.File.Size, File = args.File, Uploaded = false }; CurrentFile.ValidateId = $"{Id}_{CurrentFile.GetHashCode()}"; if (IsSingle) { // 单图片模式 DefaultFileList?.Clear(); UploadFiles.Clear(); } UploadFiles.Add(CurrentFile); await base.OnFileChange(args); // ValidateFile 后 IsValid 才有值 CurrentFile.IsValid = IsValid; if (OnChange != null) { await OnChange(CurrentFile); } else { await CurrentFile.RequestBase64ImageFileAsync(CurrentFile.File.ContentType, 320, 240); } }
/// <summary> /// OnFileDelete 回调委托 /// </summary> /// <param name="item"></param> /// <returns></returns> protected override async Task <bool> OnFileDelete(UploadFile item) { var ret = await base.OnFileDelete(item); if (ret) { if (IsSingle) { UploadFiles.Clear(); } else { UploadFiles.Remove(item); } if (!string.IsNullOrEmpty(item.ValidateId)) { await JSRuntime.InvokeVoidAsync(null, "bb_tooltip", item.ValidateId, "dispose"); } RemoveItem(); } void RemoveItem() { if (DefaultFileList != null) { if (IsSingle) { DefaultFileList.Clear(); } else { DefaultFileList.Remove(item); } } } return(ret); }
/// <summary> /// 清空上传列表方法 /// </summary> public override void Reset() { DefaultFileList?.Clear(); base.Reset(); }