You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Aucma.Scada/Aucma.Scada.UI/viewModel/RecordViewModel.cs

105 lines
2.6 KiB
C#

using GalaSoft.MvvmLight;
using GalaSoft.MvvmLight.Command;
using HighWayIot.Log4net;
using HighWayIot.Repository.domain;
using HighWayIot.Repository.service;
using HighWayIot.Repository.service.Impl;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Aucma.Scada.UI.viewModel
{
public class RecordViewModel: ViewModelBase
{
private LogHelper logHelper = LogHelper.Instance;
private ISysUserInfoService sysUserInfoService = new SysUserInfoServiceImpl();
public RecordViewModel()
{
}
private String search = String.Empty;
public String Search
{
get { return search; }
set { search = value; RaisePropertyChanged(); }
}
private ObservableCollection<SysUserInfo> gridModelList;
//前端使用的属性
public ObservableCollection<SysUserInfo> GridModelList
{
get { return gridModelList; }
set { gridModelList = value; RaisePropertyChanged(); }
}
/// <summary>
/// 查询事件
/// </summary>
private RelayCommand _queryCommand;
public RelayCommand QueryCommand
{
get
{
if (_queryCommand == null)
_queryCommand = new RelayCommand(Query);
return _queryCommand;
}
set { _queryCommand = value; RaisePropertyChanged(nameof(QueryCommand)); }
}
public void Query()
{
var models = sysUserInfoService.GetUserInfos();
if (!string.IsNullOrEmpty(Search))
{
models = models.Where(x => x.userName.Contains(Search)).ToList();
}
GridModelList = new ObservableCollection<SysUserInfo>();
if (models != null)
{
models.ForEach(
arg =>
{
GridModelList.Add(arg);
}
);
}
}
/// <summary>
/// 重置
/// </summary>
private RelayCommand _resetCommand;
public RelayCommand ResetCommand
{
get
{
if (_resetCommand == null)
_resetCommand = new RelayCommand(Reset);
return _resetCommand;
}
set { _resetCommand = value; RaisePropertyChanged(nameof(ResetCommand)); }
}
public void Reset()
{
Search = String.Empty;
this.Query();
}
}
}