using AntDesign; using Microsoft.AspNetCore.Components; using Microsoft.AspNetCore.Components.Forms; using System; using System.Collections.Generic; using System.Linq; using System.Net.Http; using System.Net.Http.Json; using System.Text.Json; using System.Threading.Tasks; using wispro.sp.entity; using wispro.sp.web.Models; using wispro.sp.web.Services; namespace wispro.sp.web.Components { public partial class CreateAppeal { private CreateAppealModel _Model; private IFeedbackRef feedbackRef; [Inject] protected AppealTypeService _atService { get; set; } [Inject] protected HttpClient _httpClient{get;set;} #region 文件上传控件设定 //List fileList = new List(); Dictionary attrs = new Dictionary { {"Action", "http://localhost:39476/api/AttachFiles/PostFile" }, {"Name", "files" }, {"Multiple", false } }; void HandleChange(UploadInfo fileinfo) { try { _Model.FileList.Where(file => file.State == UploadState.Success && !string.IsNullOrWhiteSpace(file.Response)).ForEach(file => { var result = file.GetResponse>(); file.Url = $"http://localhost:39476/api/AttachFiles/Download?id={result[0].Id}"; }); } catch { } } private async Task RemoveFile(UploadFileItem fileinfo) { try { var result = fileinfo.GetResponse>(); return await _httpClient.GetFromJsonAsync($"http://localhost:39476/api/AttachFiles/Delete?id={result[0].Id}"); } catch { return false; } } #endregion protected override async void OnInitialized() { _Model = base.Options ?? new CreateAppealModel(); //Console.WriteLine($"Success:{JsonSerializer.Serialize(_Model)}"); base.OnInitialized(); feedbackRef = base.FeedbackRef; } string _ErrorMessage; private async void OnFinish() { await base.OnFeedbackOkAsync(new ModalClosingEventArgs() { Cancel = true }); } private void OnCancel() { base.OnFeedbackCancelAsync(new ModalClosingEventArgs() { Cancel = true }); //_ = feedbackRef.CloseAsync(); } //private void OnFinishFailed(EditContext editContext) //{ // Console.WriteLine($"Failed:{JsonSerializer.Serialize(Model)}"); //} } }