Commit cccd6a16 authored by 姜春辉's avatar 姜春辉

完成历史预约单页面

parent 47b76129
......@@ -17,6 +17,7 @@
<Data Description="获取人员有效预约单" Key="VisitorAvailableAppointment" ServiceUri="/api/GS.Sub.Vistor/VisitorSelfServiceTerminal/VisitorAvailableAppointment" />
<Data Description="提交预约单到访" Key="SubmitVisitInfo" ServiceUri="/api/GS.Sub.Vistor/VisitorSelfServiceTerminal/SubmitVisitInfo" />
<Data Description="获取历史来访记录" Key="GetHistoryVisitInfo" ServiceUri="/api/GS.Sub.Vistor/VisitorSelfServiceTerminal/GetHistoryVisitInfo/{idnum}" />
<Data Description="获取历史预约单" Key="GetHistoryAppointment" ServiceUri="/api/GS.Sub.Vistor/VisitorSelfServiceTerminal/GetHistoryAppointment/{idnum}" />
</Datas>
</Structure>
</Structures>
......
using GS.Terminal.LogicShell.Interface;
using GalaSoft.MvvmLight.Threading;
using GS.Terminal.LogicShell.Interface;
using GS.Terminal.VisitorSelfService.Logic.Remote;
using GS.Terminal.VisitorSelfService.Logic.Remote.Models;
using GS.Terminal.VisitorSelfService.Logic.ThirdAddon;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using ViewModels;
namespace GS.Terminal.VisitorSelfService.Logic.Core
{
......@@ -11,9 +16,95 @@ namespace GS.Terminal.VisitorSelfService.Logic.Core
{
private IViewModel _BackView;
private string _idnum;
private int _currentpage = 0;
private const int PAGESIZE = 5;
public override void Init()
{
VM.OnBackClick += VM_OnBackClick;
VM.OnNavigateInto += VM_OnNavigateInto;
VM.OnNavigateOut += VM_OnNavigateOut;
VM.OnMoreClick += VM_OnMoreClick;
}
private void VM_OnMoreClick()
{
_currentpage++;
MainShell.ShowLoading("加载中...");
search().ContinueWith(task =>
{
MainShell.HideLoading();
if (!task.Result)
_currentpage--;
});
}
private void VM_OnNavigateOut(IViewModel obj)
{
VM.Datas = new System.Collections.ObjectModel.ObservableCollection<ViewModels.Pages.HistoryAppointmentPage.HistoryAppointmentItem>();
_idnum = "";
_BackView = null;
}
private void VM_OnNavigateInto(IViewModel obj)
{
Handlers.GetHandler<HeadHandler>().Start();
_currentpage = 0;
VM_OnMoreClick();
}
private void VM_OnBackClick()
{
ThirdAddon.LogicShell.ShowView(_BackView ?? vmLocator.HistoryMenuPage);
}
private async Task<bool> search()
{
var serviceUri = LocalSetting.ServiceList.GetSerivceUri("GetHistoryAppointment");
serviceUri = serviceUri.Replace("{idnum}", _idnum);
var response = await WebApi.PostAsync<WebApiPagingResponseBody<HistoryAppointment>>(serviceUri, new
{
paging = new
{
currentIndex = _currentpage,
pageSize = PAGESIZE
}
});
if (response != null)
{
if (response.Status)
{
if (response.paging != null)//如果服务端没有返回分页信息,那就通过返回的记录数判断是否是最后一页
{
VM.IsLastPage = response.paging.currentIndex == response.paging.totalPage;
}
else
{
VM.IsLastPage = !(response.records != null && response.records.Count == 0);
}
foreach (var item in response.records ?? new List<HistoryAppointment>())
{
DispatcherHelper.CheckBeginInvokeOnUI(() =>
{
VM.Datas.Add(new ViewModels.Pages.HistoryAppointmentPage.HistoryAppointmentItem
{
Id = item.id,
VisitorIdNum = item.visitorIdNum,
VisitorName = item.visitorName,
VisitPerson = item.visitPerson,
Phone = item.visitorPhone,
Status = item.status,
StartDate = item.startDate,
EndDate = item.endDate,
Photo = Tools.ProductPhotoUrl(item.photo)
});
});
}
return true;
}
}
ThirdAddon.MainShell.ShowPrompt("通讯异常.");
return false;
}
public void ShowView(string idnum, IViewModel backview = null)
......
......@@ -15,7 +15,7 @@ namespace GS.Terminal.VisitorSelfService.Logic.Core
{
public string _IDNum;
private IViewModel _backview;
private int _currentpage = 1;
private int _currentpage = 0;
private const int PAGESIZE = 5;
public override void Init()
{
......
......@@ -122,6 +122,7 @@
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Remote\Models\Appointment.cs" />
<Compile Include="Remote\Models\HistoryAppointment.cs" />
<Compile Include="Remote\Models\HistoryVisitInfo.cs" />
<Compile Include="Remote\Models\WebApiCollectionResponseBody.cs" />
<Compile Include="Remote\Models\WebApiPagingResponseBody.cs" />
......
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace GS.Terminal.VisitorSelfService.Logic.Remote.Models
{
public class HistoryAppointment
{
public int id { get; set; }
public string photo { get; set; }
public string visitorName { get; set; }
public string visitorIdNum { get; set; }
public string visitorPhone { get; set; }
public string visitPerson { get; set; }
public DateTime visitTime { get; set; }
public DateTime startDate { get; set; }
public DateTime endDate { get; set; }
public int status { get; set; }
}
}
using GalaSoft.MvvmLight;
using GalaSoft.MvvmLight.Command;
using GS.Terminal.LogicShell.Interface;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
......@@ -9,13 +11,66 @@ using System.Threading.Tasks;
namespace ViewModels.Pages.HistoryAppointmentPage
{
public partial class ViewModel : ViewModelBase, IViewModel
public partial class ViewModel : ViewModelBase, IViewModel, IViewModelBehavior
{
public string ViewID => "d686b0af-2936-4f96-b965-0e0fd54d5b43";
public event Action<IViewModel> OnNavigateInto;
public void NavigateInto(IViewModel from)
{
OnNavigateInto?.Invoke(from);
}
public event Action<IViewModel> OnNavigateOut;
public void NavigateOut(IViewModel to)
{
OnNavigateOut?.Invoke(to);
}
public event Action OnBackClick;
public RelayCommand BackCommand => new RelayCommand(() =>
{
OnBackClick?.Invoke();
});
public event Action OnMoreClick;
public RelayCommand MoreCommand => new RelayCommand(() =>
{
OnMoreClick?.Invoke();
});
private ObservableCollection<HistoryAppointmentItem> _Datas;
public ObservableCollection<HistoryAppointmentItem> Datas
{
get { return _Datas ?? ( _Datas = new ObservableCollection<HistoryAppointmentItem>()); }
set { _Datas = value; RaisePropertyChanged("Datas"); }
}
private bool _IsLastPage;
public bool IsLastPage
{
get { return _IsLastPage; }
set { _IsLastPage = value; RaisePropertyChanged("IsLastPage"); }
}
public void Reset()
{
}
}
public class HistoryAppointmentItem
{
public int Id { get; set; }
public string VisitorName { get; set; }
public string VisitorIdNum { get; set; }
public string Phone { get; set; }
public string Photo { get; set; }
public string VisitPerson { get; set; }
public DateTime StartDate { get; set; }
public DateTime EndDate { get; set; }
public int Status { get; set; }
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment