using AntDesign; using Microsoft.AspNetCore.Components; using Microsoft.AspNetCore.Components.Forms; using Microsoft.Extensions.Configuration; 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; private List _Staffs; [Inject] protected AppealTypeService _atService { get; set; } [Inject] IUserService _UserService { get; set; } [Inject] protected IHttpService _httpClient{get;set;} [Inject] protected IConfiguration _configuration { get; set; } #region 文件上传控件设定 //List fileList = new List(); Dictionary attrs ; 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 = $"{_configuration.GetValue("APIUrl")}AttachFiles/Download?id={result[0].Id}"; }); } catch { } } private async Task RemoveFile(UploadFileItem fileinfo) { try { var result = fileinfo.GetResponse>(); return await _httpClient.Get($"{_configuration.GetValue("APIUrl")}AttachFiles/Delete?id={result[0].Id}"); } catch { return false; } } #endregion protected override async void OnInitialized() { attrs = new Dictionary { {"Action", $"{_configuration.GetValue("APIUrl")}AttachFiles/PostFile" }, {"Name", "files" }, {"Multiple", false } }; _Model = base.Options ?? new CreateAppealModel(); //if(!string.IsNullOrEmpty(_Model.AppealType.ReviewerExpress)) //{ _Staffs =await _UserService.GetReviewers(_Model.AppealRecord.ItemId, _Model.AppealType.Id); //} //else //{ // _Staffs =await _UserService.GetAll(); //} base.OnInitialized(); feedbackRef = base.FeedbackRef; StateHasChanged(); } string _ErrorMessage; private async void OnFinish() { await base.OnFeedbackOkAsync(new ModalClosingEventArgs() { Cancel = true }); } private void OnCancel() { base.OnFeedbackCancelAsync(new ModalClosingEventArgs() { Cancel = true }); //_ = feedbackRef.CloseAsync(); } } }