public virtual async Task RenderListAsync(AccountRecord page, int pageIndex = 1) { try { var rows = 20; var gteTime = Convert.ToDateTime(page.DpStartTime.Text); var lteTime = Convert.ToDateTime(page.DpEndTime.Text); var type = (EnumAccountRecordType)Convert.ToInt32(((ComboBoxItem)page.CmbType.SelectedValue).Tag.ToString()); var response = await _onMainHostRequestPlugins.QueryAccountRecorrdAsync(new AccountRecordRequest() { Page = pageIndex, Rows = rows, Type = (int)type, GteTime = gteTime, LteTime = lteTime, AccessToken = AccountCache.Persist.AccessToken }); if (response != null && response.Code == Application.Enums.ApiCodeEnums.ERROR_NOLOGIN) { _onTipRender.ExecuteTip(page.BodyPanel, "登陆失效,请退出重新登陆"); _onRedirectRender.RedirectLogin(); return; } var resp = response.Data; #region 数据绑定 _onControlRender.ThreadExecuteUI(() => { _onControlRender.BindFrameworkElement(page.DataGridOrderList, resp?.Data?.ToList() ?? null); if ((resp?.Data?.Count() ?? 0) <= 0) { page.SpPager.Visibility = Visibility.Collapsed; } else { page.SpPager.Visibility = Visibility.Visible; } var sump = Convert.ToInt32(resp.TotalCount) % rows; var totalPage = Convert.ToInt32(resp?.TotalCount ?? 0) / rows + (sump > 0 ? 1 : 0); page.labTotalPage.Content = $"/{totalPage}"; page.labCurrentPage.Content = $"{pageIndex}"; page.labPrePage.Tag = $"{pageIndex - 1}"; page.labPrePage.IsEnabled = pageIndex > 1; page.labNextPage.Tag = $"{pageIndex + 1}"; page.labNextPage.IsEnabled = (pageIndex + 1) <= totalPage; page.txbJumb.Tag = totalPage; }); #endregion } catch (Exception ex) { TextHelper.Error("RenderList 异常", ex); _onTipRender.ExecuteTip(page.BodyPanel, "查询异常[0001]"); } }
/// <summary> /// 查询渲染订单列表 /// </summary> /// <param name="orderDataRequest"></param> /// <param name="page"></param> /// <returns></returns> public async Task RenderListAsync(CardOrder page, int pageIndex = 1) { try { #region 组装数据 var cardNo = page.txbCardNo.Text.Equals("请输入会员手机号或卡号") ? "" : page.txbCardNo.Text; var orderDataRequest = new Model.CardOrderRequest() { CashId = AccountCache.Persist.CashId, OrderNo = page.txbOrderNo.Text.Trim(), Type = Convert.ToInt32(((ComboBoxItem)page.CmbOrderType.SelectedValue).Tag.ToString()), PageIndex = pageIndex, StartTime = Convert.ToDateTime(page.DpStartTime.Text), EndTime = Convert.ToDateTime(page.DpEndTime.Text), Rows = 8, StoresId = AccountCache.Persist.StoreId, PhoneOrCardNo = cardNo, }; #endregion #region 信息验证 if ((orderDataRequest?.CashId ?? 0) <= 0) { _onControlRender.ThreadExecuteUI(() => { _onTipRender.ExecuteTip(page.BodyPanel, "参数错误"); page.DataGridOrderList.DataContext = new List <CardOrderItemResponse>(); }); return; } #endregion #region 查询订单 var resp = await _onOrderRequest.ExecuteQueryAsync(orderDataRequest); if (!(resp?.IsSuccess ?? false)) { _onControlRender.ThreadExecuteUI(() => { _onTipRender.ExecuteTip(page.BodyPanel, resp?.Msg ?? "查询异常"); page.DataGridOrderList.DataContext = new List <CardOrderItemResponse>(); }); return; } #endregion #region 数据绑定 _onControlRender.ThreadExecuteUI(() => { page.btnExport.IsEnabled = (resp.Data?.Items?.Count ?? 0) > 0; page.btnPrinter.IsEnabled = (resp.Data?.Items?.Count ?? 0) > 0; page.btnRefund.IsEnabled = (resp.Data?.Items?.Count ?? 0) > 0; //if ((resp.Data?.Items?.Count ?? 0) > 0) //{ _onControlRender.BindFrameworkElement(page.DataGridOrderList, resp.Data?.Items ?? null); //} if ((resp.Data?.Items?.Count ?? 0) <= 0) { page.SpPager.Visibility = Visibility.Collapsed; } else { page.SpPager.Visibility = Visibility.Visible; } var sump = Convert.ToInt32(resp.Data?.Total ?? 0) % orderDataRequest.Rows; var totalPage = Convert.ToInt32(resp.Data?.Total ?? 0) / orderDataRequest.Rows + (sump > 0 ? 1 : 0); page.labTotalPage.Content = $"/{totalPage}"; page.labCurrentPage.Content = $"{orderDataRequest.PageIndex}"; page.labPrePage.Tag = $"{orderDataRequest.PageIndex - 1}"; page.labPrePage.IsEnabled = orderDataRequest.PageIndex > 1; page.labNextPage.Tag = $"{orderDataRequest.PageIndex + 1}"; page.labNextPage.IsEnabled = (orderDataRequest.PageIndex + 1) <= totalPage; page.txbJumb.Tag = totalPage; }); #endregion } catch (Exception ex) { TextHelper.Error("RenderList 异常", ex); _onTipRender.ExecuteTip(page.BodyPanel, "查询异常[0001]"); } }