@page "/StaffGrade" @inject HttpClient Http @using AntDesign.TableModels @inject MessageService _message @using System.ComponentModel @using wispro.sp.share @if (staffGrades == null) {
} else {
代理人系数

}

@if (_isAdd) { } else { @context.Grade }
@using System.Text.Json; @code { private List staffGrades; IEnumerable selectedRows; ITable table; int _pageIndex = 1; int _pageSize = 10; int _total = 0; bool _loading = false; wispro.sp.entity.StaffGrade EditingStaff = null; bool _visible = false; bool _isAdd = false; protected override async Task OnInitializedAsync() { _loading = true; List data = await Http.GetFromJsonAsync>($"http://localhost:39476/api/StaffGrade/GetAll"); _loading = false; staffGrades = data; _total = data.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 rList = staffGrades.Where(x => x.Id == id).ToList(); if (rList.Count() > 0) { EditingStaff = rList[0]; _visible = true; } else { } _total = staffGrades.Count; } private void Edit(int id) { var rList = staffGrades.Where(x => x.Id == id).ToList(); if (rList.Count() > 0) { EditingStaff = rList[0]; _visible = true; } else { } _total = staffGrades.Count; } 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) { _message.Success("数据已保存!"); } else { _message.Error($"{result.ErrorMessage}"); } } else { _message.Error($"请求发生错误 {data.StatusCode}"); } _visible = false; } private void HandleCancel(MouseEventArgs e) { Console.WriteLine(e); _visible = false; } }