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

完成历史预约单页面

parent 47b76129
...@@ -17,6 +17,7 @@ ...@@ -17,6 +17,7 @@
<Data Description="获取人员有效预约单" Key="VisitorAvailableAppointment" ServiceUri="/api/GS.Sub.Vistor/VisitorSelfServiceTerminal/VisitorAvailableAppointment" /> <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="SubmitVisitInfo" ServiceUri="/api/GS.Sub.Vistor/VisitorSelfServiceTerminal/SubmitVisitInfo" />
<Data Description="获取历史来访记录" Key="GetHistoryVisitInfo" ServiceUri="/api/GS.Sub.Vistor/VisitorSelfServiceTerminal/GetHistoryVisitInfo/{idnum}" /> <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> </Datas>
</Structure> </Structure>
</Structures> </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;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
using ViewModels;
namespace GS.Terminal.VisitorSelfService.Logic.Core namespace GS.Terminal.VisitorSelfService.Logic.Core
{ {
...@@ -11,9 +16,95 @@ namespace GS.Terminal.VisitorSelfService.Logic.Core ...@@ -11,9 +16,95 @@ namespace GS.Terminal.VisitorSelfService.Logic.Core
{ {
private IViewModel _BackView; private IViewModel _BackView;
private string _idnum; private string _idnum;
private int _currentpage = 0;
private const int PAGESIZE = 5;
public override void Init() 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) public void ShowView(string idnum, IViewModel backview = null)
......
...@@ -15,7 +15,7 @@ namespace GS.Terminal.VisitorSelfService.Logic.Core ...@@ -15,7 +15,7 @@ namespace GS.Terminal.VisitorSelfService.Logic.Core
{ {
public string _IDNum; public string _IDNum;
private IViewModel _backview; private IViewModel _backview;
private int _currentpage = 1; private int _currentpage = 0;
private const int PAGESIZE = 5; private const int PAGESIZE = 5;
public override void Init() public override void Init()
{ {
......
...@@ -122,6 +122,7 @@ ...@@ -122,6 +122,7 @@
<Compile Include="Program.cs" /> <Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" /> <Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Remote\Models\Appointment.cs" /> <Compile Include="Remote\Models\Appointment.cs" />
<Compile Include="Remote\Models\HistoryAppointment.cs" />
<Compile Include="Remote\Models\HistoryVisitInfo.cs" /> <Compile Include="Remote\Models\HistoryVisitInfo.cs" />
<Compile Include="Remote\Models\WebApiCollectionResponseBody.cs" /> <Compile Include="Remote\Models\WebApiCollectionResponseBody.cs" />
<Compile Include="Remote\Models\WebApiPagingResponseBody.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;
using GalaSoft.MvvmLight.Command;
using GS.Terminal.LogicShell.Interface; using GS.Terminal.LogicShell.Interface;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
...@@ -9,13 +11,66 @@ using System.Threading.Tasks; ...@@ -9,13 +11,66 @@ using System.Threading.Tasks;
namespace ViewModels.Pages.HistoryAppointmentPage 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 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 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; }
}
} }
...@@ -23,42 +23,121 @@ ...@@ -23,42 +23,121 @@
</Grid.RowDefinitions> </Grid.RowDefinitions>
<Grid> <Grid>
<TextBlock Text="历史预约记录查询" FontSize="36" HorizontalAlignment="Left" VerticalAlignment="Center"/> <TextBlock Text="历史预约记录查询" FontSize="36" HorizontalAlignment="Left" VerticalAlignment="Center"/>
<Button Template="{StaticResource CommonButton}" TextBlock.Foreground="#2a2b2d" HorizontalAlignment="Right" Width="160" FontSize="24" Content="返回"/> <Button Template="{StaticResource CommonButton}" TextBlock.Foreground="#2a2b2d"
Command="{Binding BackCommand}"
HorizontalAlignment="Right" Width="160" FontSize="24" Content="返回"/>
</Grid> </Grid>
<StackPanel Grid.Row="1"> <ListView Grid.Row="1" ItemsSource="{Binding Datas}">
<Border BorderThickness="4" BorderBrush="#7Ff38900" <ListView.Template>
Margin="0,50,0,0" Padding="36" <ControlTemplate TargetType="ListView">
Background="#0CF38900" <ScrollViewer HorizontalScrollBarVisibility="Disabled"
CornerRadius="5" Height="410"> Background="Transparent"
<Grid> VerticalScrollBarVisibility="Auto"
<Grid.ColumnDefinitions> Style="{DynamicResource scrollviewerStyle}">
<ColumnDefinition Width="272"/> <ItemsPresenter/>
<ColumnDefinition/> </ScrollViewer>
</Grid.ColumnDefinitions> </ControlTemplate>
<!--照片 姓名--> </ListView.Template>
<StackPanel> <ListView.ItemsPanel>
<Grid> <ItemsPanelTemplate>
<Image Width="200" Height="270"/> <StackPanel/>
</Grid> </ItemsPanelTemplate>
<TextBlock Text="张三" FontSize="42" Margin="0,10,0,0" HorizontalAlignment="Center"/> </ListView.ItemsPanel>
</StackPanel> <ListView.ItemContainerStyle>
<!--基本信息--> <Style TargetType="ListViewItem">
<StackPanel Grid.Column="1"> <Setter Property="Template">
<StackPanel.Resources> <Setter.Value>
<Style TargetType="TextBlock"> <ControlTemplate TargetType="ListViewItem">
<Setter Property="Foreground" Value="#2a2b2d"/> <Border x:Name="PART_BORDER" BorderThickness="4"
</Style> Margin="0,50,0,0" Padding="36"
</StackPanel.Resources> CornerRadius="5" Height="410">
<TextBlock HorizontalAlignment="Right" FontSize="30" Margin="0,26,0,0" Text="2020-7-28 10:10:09"/> <Grid>
<TextBlock HorizontalAlignment="Right" FontSize="30" Margin="0,20,0,0" Text="一号访客机"/> <Grid.ColumnDefinitions>
<TextBlock HorizontalAlignment="Right" FontSize="30" Margin="0,20,0,0" Text="这里是被访人员的姓名以及部门" TextWrapping="NoWrap" TextTrimming="CharacterEllipsis"/> <ColumnDefinition Width="272"/>
<TextBlock HorizontalAlignment="Right" FontSize="30" Margin="0,20,0,0" Text="1333****333"/> <ColumnDefinition/>
<TextBlock HorizontalAlignment="Right" FontSize="40" Margin="0,26,0,0" Text="未离开" FontWeight="Black" Foreground="#f38900"/> </Grid.ColumnDefinitions>
</StackPanel> <!--照片 姓名-->
</Grid> <StackPanel>
</Border> <Grid>
</StackPanel> <Image Source="{Binding Photo}" Stretch="Fill" Width="200" Height="270"/>
<Button Grid.Row="2" FontSize="36" Template="{StaticResource CommonButton}" Height="90" Content="加载更多"/> </Grid>
<TextBlock Text="{Binding VisitorName}" FontSize="42" Margin="0,10,0,0" HorizontalAlignment="Center"/>
</StackPanel>
<!--基本信息-->
<StackPanel Grid.Column="1">
<StackPanel.Resources>
<Style TargetType="TextBlock">
<Setter Property="Foreground" Value="#2a2b2d"/>
</Style>
</StackPanel.Resources>
<TextBlock HorizontalAlignment="Right" FontSize="30" Margin="0,26,0,0" Text="{Binding VisitorIdNum}"/>
<TextBlock HorizontalAlignment="Right" FontSize="30" Margin="0,20,0,0" Text="{Binding Phone}"/>
<TextBlock HorizontalAlignment="Right" FontSize="30" Margin="0,20,0,0" Text="{Binding VisitPerson}" TextWrapping="NoWrap" TextTrimming="CharacterEllipsis"/>
<TextBlock HorizontalAlignment="Right" FontSize="30" Margin="0,20,0,0" >
<Run Text="{Binding StartDate,StringFormat='yyyy年MM月dd日'}"/>
<Run Text=" 到 "/>
<Run Text="{Binding EndDate,StringFormat='yyyy年MM月dd日'}"/>
</TextBlock>
<TextBlock x:Name="PART_STATUS" HorizontalAlignment="Right" FontSize="40" Margin="0,26,0,0" FontWeight="Black" />
</StackPanel>
</Grid>
</Border>
<ControlTemplate.Triggers>
<DataTrigger Binding="{Binding Status}" Value="0">
<!--待审批-->
<Setter Property="Background" TargetName="PART_BORDER" Value="#0CF38900"/>
<Setter Property="BorderBrush" TargetName="PART_BORDER" Value="#7Ff38900"/>
<Setter Property="Text" TargetName="PART_STATUS" Value="审核中"/>
<Setter Property="Foreground" TargetName="PART_STATUS" Value="#f38900"/>
</DataTrigger>
<DataTrigger Binding="{Binding Status}" Value="1">
<!--审核通过-->
<Setter Property="Background" TargetName="PART_BORDER" Value="#0C62ba67"/>
<Setter Property="BorderBrush" TargetName="PART_BORDER" Value="#7F62ba67"/>
<Setter Property="Text" TargetName="PART_STATUS" Value="审核通过"/>
<Setter Property="Foreground" TargetName="PART_STATUS" Value="#62ba67"/>
</DataTrigger>
<DataTrigger Binding="{Binding Status}" Value="2">
<!--审核不通过-->
<Setter Property="Background" TargetName="PART_BORDER" Value="#0Cf50a0f"/>
<Setter Property="BorderBrush" TargetName="PART_BORDER" Value="#7Ff50a0f"/>
<Setter Property="Text" TargetName="PART_STATUS" Value="已拒绝"/>
<Setter Property="Foreground" TargetName="PART_STATUS" Value="#f50a0f"/>
</DataTrigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</ListView.ItemContainerStyle>
</ListView>
<ContentControl Grid.Row="2">
<ContentControl.Template>
<ControlTemplate TargetType="ContentControl">
<Grid>
<Button x:Name="PART_BTN"
Grid.Row="2" FontSize="36" Visibility="Collapsed"
Command="{Binding MoreCommand}"
Template="{StaticResource CommonButton}"
Height="90" Content="加载更多"/>
<TextBlock x:Name="PART_TIP"
Text="没有更多记录了......" HorizontalAlignment="Center"
VerticalAlignment="Center" FontSize="72" Foreground="Gray"/>
</Grid>
<ControlTemplate.Triggers>
<DataTrigger Binding="{Binding IsLastPage}" Value="True">
<Setter Property="Visibility" TargetName="PART_BTN" Value="Collapsed"/>
<Setter Property="Visibility" TargetName="PART_TIP" Value="Visible"/>
</DataTrigger>
<DataTrigger Binding="{Binding IsLastPage}" Value="False">
<Setter Property="Visibility" TargetName="PART_BTN" Value="Visible"/>
<Setter Property="Visibility" TargetName="PART_TIP" Value="Collapsed"/>
</DataTrigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</ContentControl.Template>
</ContentControl>
</Grid> </Grid>
</Border> </Border>
</Page> </Page>
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