using AntDesign; using AntDesign.TableModels; using Microsoft.AspNetCore.Components; using Microsoft.AspNetCore.Components.Web; using System; using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; using wispro.sp.web.Services; namespace wispro.sp.web.Pages { public partial class CustomerList { private List _Customers =new List(); IEnumerable selectedRows; ITable table; int _pageIndex = 1; int _pageSize = 10; int _total = 0; bool _loading = false; entity.Customer Editing = null; bool _visible = false; bool _isAdd = false; [Inject]OrganizationService orgService { get; set; } protected override async System.Threading.Tasks.Task OnInitializedAsync() { _loading = true; _Customers = await orgService.GetAllCustomer(); //await System.Threading.Thread.Sleep(); //List data = await Http.GetFromJsonAsync>($"http://localhost:39476/api/StaffGrade/GetAll"); _loading = false; _total = _Customers.Count; } private void HandlePageChange(PaginationEventArgs args) { if (_pageIndex != args.Page) { _pageIndex = args.Page; } if (_pageSize != args.PageSize) { _pageSize = args.PageSize; } } Dictionary OnRow(RowData row) { Dictionary ret = new Dictionary(); ret.Add("id", row.Data.Id); ret.Add("onclick", ((Action)delegate { //_message.Info($"row {row.Data.Grade} was clicked"); })); return ret; } public void RemoveSelection(int id) { //var selected = selectedRows.Where(x => x.Id != id); //selectedRows = selected; } private void Delete(int id) { var DelCustumer = _Customers.Where(x => x.Id == id).FirstOrDefault(); if (DelCustumer != null) { Editing = DelCustumer; _isAdd = false; _visible = true; } else { } _total = _Customers.Count; } private void Edit(int id) { Editing = _Customers.Where(x => x.Id == id).FirstOrDefault(); if (Editing != null) { _isAdd = false; _visible = true; } else { } _total = _Customers.Count; } private void AddNew() { Editing = new entity.Customer(); //_isAdd = true; _visible = true; } private async Task HandleOk(MouseEventArgs e) { //var data = await Http.PostAsJsonAsync($"http://localhost:39476/api/StaffGrade/Save", EditingStaff); //if (data.IsSuccessStatusCode) //{ // ApiSaveResponse result = await data.Content.ReadFromJsonAsync(); // await Task.Delay(1000); // if (result.Success) // { // await _message.Success("数据已保存!"); // } // else // { // await _message.Error($"{result.ErrorMessage}"); // } //} //else //{ // await _message.Error($"请求发生错误 {data.StatusCode}"); //} _visible = false; } private void HandleCancel(MouseEventArgs e) { _visible = false; } } }