203 lines
6.7 KiB
C#
203 lines
6.7 KiB
C#
using DM_Weight.Models;
|
|
using DM_Weight.select;
|
|
using DM_Weight.util;
|
|
using Newtonsoft.Json;
|
|
using Prism.Commands;
|
|
using Prism.Mvvm;
|
|
using Prism.Regions;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Configuration;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace DM_Weight.ViewModels
|
|
{
|
|
public class ApplyListWindowViewModel : BindableBase, INavigationAware
|
|
{
|
|
public static List<OrderTakeSelect> StaticSelects = new()
|
|
{
|
|
new OrderTakeSelect
|
|
{
|
|
Code = "DrugName",
|
|
Name = "药品名称"
|
|
},
|
|
new OrderTakeSelect
|
|
{
|
|
Code = "PyCode",
|
|
Name = "拼音码"
|
|
},
|
|
new OrderTakeSelect
|
|
{
|
|
Code = "DrugBarcode",
|
|
Name = "药品条码"
|
|
},
|
|
new OrderTakeSelect
|
|
{
|
|
Code = "DrugId",
|
|
Name = "药品编码"
|
|
}
|
|
};
|
|
|
|
private List<OrderTakeSelect> _selects = StaticSelects;
|
|
|
|
public List<OrderTakeSelect> Selects
|
|
{
|
|
get { return _selects; }
|
|
set
|
|
{
|
|
SetProperty(ref _selects, value);
|
|
}
|
|
}
|
|
private OrderTakeSelect _selectedItem = StaticSelects[0];
|
|
|
|
private string? _searchValue;
|
|
|
|
/// <summary>
|
|
/// 查询条件 查询字段值
|
|
/// </summary>
|
|
public string? SearchValue
|
|
{
|
|
get { return _searchValue; }
|
|
set
|
|
{
|
|
SetProperty(ref _searchValue, value);
|
|
RequestData();
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// 查询条件 查询字段
|
|
/// </summary>
|
|
public OrderTakeSelect SelectedItem
|
|
{
|
|
get { return _selectedItem; }
|
|
set
|
|
{
|
|
SetProperty(ref _selectedItem, value);
|
|
RequestData();
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// 请领单状态
|
|
/// </summary>
|
|
private List<DrugPleaseState> _drugPleaseStateList = new List<DrugPleaseState>() {
|
|
new DrugPleaseState
|
|
{
|
|
StateName="已创建",
|
|
StateValue=0
|
|
},
|
|
new DrugPleaseState
|
|
{
|
|
StateName="审核通过",
|
|
StateValue=1
|
|
},
|
|
new DrugPleaseState
|
|
{
|
|
StateName="已出库",
|
|
StateValue=2
|
|
},
|
|
new DrugPleaseState
|
|
{
|
|
StateName="已入库",
|
|
StateValue=3
|
|
}
|
|
};
|
|
public List<DrugPleaseState>? DrugPleaseStateList
|
|
{
|
|
get => _drugPleaseStateList;
|
|
set
|
|
{
|
|
SetProperty(ref _drugPleaseStateList, value);
|
|
RequestData();
|
|
}
|
|
}
|
|
private DrugPleaseState? _drugPleaseState;
|
|
public DrugPleaseState _DrugPleaseState
|
|
{
|
|
get => _drugPleaseState;
|
|
set
|
|
{
|
|
SetProperty(ref _drugPleaseState, value);
|
|
RequestData();
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// 处方、请领中间表
|
|
/// </summary>
|
|
private List<CollectDrug> _collectDrugLst;
|
|
public List<CollectDrug> CollectDrugLst
|
|
{
|
|
get => _collectDrugLst; set { SetProperty(ref _collectDrugLst, value); }
|
|
}
|
|
|
|
private CollectDrug _selectCollectDrug;
|
|
public CollectDrug SelectCollectDrug { get => _selectCollectDrug; set { SetProperty(ref _selectCollectDrug, value); } }
|
|
|
|
|
|
private void RequestData()
|
|
{
|
|
if (CollectDrugLst != null)
|
|
{
|
|
CollectDrugLst.Clear();
|
|
}
|
|
CollectDrugLst = SqlSugarHelper.Db.Queryable<CollectDrug>()
|
|
.Includes<DrugPleaseClaim>(cd => cd.drugPleaseClaim)
|
|
.Includes<DrugInfo>(cd => cd.drugInfo)
|
|
.InnerJoin<DrugPleaseClaim>((cd,dp)=>cd.DrugPleaseClaimId==dp.PleaseNo)
|
|
.Where(cd => cd.MachineId.Equals(ConfigurationManager.AppSettings["machineId"] ?? "DM3"))
|
|
.WhereIF(!String.IsNullOrEmpty(SearchValue) && SelectedItem.Code.Equals("DrugId"), (cd) => cd.drugInfo.DrugId.ToString() == SearchValue)
|
|
.WhereIF(!String.IsNullOrEmpty(SearchValue) && SelectedItem.Code.Equals("DrugName"), (cd) => cd.drugInfo.DrugName.Contains(SearchValue))
|
|
.WhereIF(!String.IsNullOrEmpty(SearchValue) && SelectedItem.Code.Equals("PyCode"), (cd) => cd.drugInfo.PyCode.Contains(SearchValue))
|
|
.WhereIF(!String.IsNullOrEmpty(SearchValue) && SelectedItem.Code.Equals("DrugBarcode"), (cd) => cd.drugInfo.DrugBarcode.Contains(SearchValue))
|
|
.WhereIF((_DrugPleaseState!=null&& _DrugPleaseState.StateValue>=0),(cd,dp)=>dp.State==_DrugPleaseState.StateValue)
|
|
.GroupBy(cd=>cd.DrugPleaseClaimId)
|
|
.GroupBy(cd => cd.DrugId)
|
|
.OrderByDescending(cd => cd.Createdate)
|
|
.OrderByDescending(cd => cd.DrugId)
|
|
.ToList();
|
|
if (CollectDrugLst != null && CollectDrugLst.Count > 0)
|
|
{
|
|
|
|
for (int i = 0; i < CollectDrugLst.Count; i++)
|
|
{
|
|
CollectDrugLst[i].ManuNoList = new List<DrugPleaseManuNo>();
|
|
DrugPleaseClaim drugManuNoStr = SqlSugarHelper.Db.Queryable<DrugPleaseClaim>().Where(dp => dp.PleaseNo == CollectDrugLst[i].DrugPleaseClaimId && dp.DrugId == CollectDrugLst[i].DrugId).First();
|
|
|
|
CollectDrugLst[i].Quantity = drugManuNoStr.GetQuantity;
|
|
if (!string.IsNullOrEmpty(drugManuNoStr._DrugManuNos))
|
|
{
|
|
CollectDrugLst[i].ManuNoList = JsonConvert.DeserializeObject<List<DrugPleaseManuNo>>(drugManuNoStr._DrugManuNos);
|
|
|
|
}
|
|
}
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// 刷新
|
|
/// </summary>
|
|
public DelegateCommand Query
|
|
{
|
|
get => new DelegateCommand(() =>
|
|
{
|
|
RequestData();
|
|
});
|
|
}
|
|
|
|
|
|
public void OnNavigatedTo(NavigationContext navigationContext)
|
|
{
|
|
RequestData();
|
|
}
|
|
|
|
public bool IsNavigationTarget(NavigationContext navigationContext)
|
|
{
|
|
return true;
|
|
}
|
|
|
|
public void OnNavigatedFrom(NavigationContext navigationContext)
|
|
{
|
|
}
|
|
}
|
|
}
|