|
@@ -7,6 +7,7 @@ using Model.Entities;
|
|
using PLCTool.Common;
|
|
using PLCTool.Common;
|
|
using Prism.Commands;
|
|
using Prism.Commands;
|
|
using Prism.Mvvm;
|
|
using Prism.Mvvm;
|
|
|
|
+using Prism.Regions;
|
|
using Prism.Services.Dialogs;
|
|
using Prism.Services.Dialogs;
|
|
using System;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Collections.Generic;
|
|
@@ -21,7 +22,7 @@ namespace PLCTool.ViewModels.BusinessManageViewModel
|
|
{
|
|
{
|
|
|
|
|
|
|
|
|
|
- public class DeviceTestViewModel : BindableBase
|
|
|
|
|
|
+ public class DeviceTestViewModel : BindableBase, INavigationAware
|
|
{
|
|
{
|
|
private readonly IBasicDeviceService _iBasicDeviceService;
|
|
private readonly IBasicDeviceService _iBasicDeviceService;
|
|
private readonly IBasicDeviceKindService _iBasicDeviceKindService;
|
|
private readonly IBasicDeviceKindService _iBasicDeviceKindService;
|
|
@@ -30,8 +31,10 @@ namespace PLCTool.ViewModels.BusinessManageViewModel
|
|
private readonly IMapper _mapper;
|
|
private readonly IMapper _mapper;
|
|
private readonly IDialogService _dialog;
|
|
private readonly IDialogService _dialog;
|
|
private readonly ILogger _logger;
|
|
private readonly ILogger _logger;
|
|
- private List<BasDeviceWithSchModel> allDeviceList = new List<BasDeviceWithSchModel>();//所有方案
|
|
|
|
|
|
+ private List<BasDeviceWithSchModel> allDeviceAndSchList = new List<BasDeviceWithSchModel>();//所有设备,并带有测试方案
|
|
|
|
+ private List<BasDeviceWithSchModel> allDeviceList = new List<BasDeviceWithSchModel>();//所有设备
|
|
private List<BasDeviceWithSchModel> conditionDevices = new List<BasDeviceWithSchModel>();//符合条件的方案
|
|
private List<BasDeviceWithSchModel> conditionDevices = new List<BasDeviceWithSchModel>();//符合条件的方案
|
|
|
|
+ private string selectProjectName;
|
|
public DeviceTestViewModel(IBasicDeviceService iBasicDeviceService, IBasicDeviceKindService iBasicDeviceKindService, IBasicProjectService iBasicProjectService, IBasicPlcTestSchemeService basicPlcTestSchemeService, IMapper mapper, IDialogService dialog, ILogger logger)
|
|
public DeviceTestViewModel(IBasicDeviceService iBasicDeviceService, IBasicDeviceKindService iBasicDeviceKindService, IBasicProjectService iBasicProjectService, IBasicPlcTestSchemeService basicPlcTestSchemeService, IMapper mapper, IDialogService dialog, ILogger logger)
|
|
{
|
|
{
|
|
_iBasicDeviceService = iBasicDeviceService;
|
|
_iBasicDeviceService = iBasicDeviceService;
|
|
@@ -219,6 +222,7 @@ namespace PLCTool.ViewModels.BusinessManageViewModel
|
|
{
|
|
{
|
|
allDeviceList.Clear();
|
|
allDeviceList.Clear();
|
|
conditionDevices.Clear();
|
|
conditionDevices.Clear();
|
|
|
|
+ allDeviceAndSchList.Clear();
|
|
var devicelist = _iBasicDeviceService.QueryList();
|
|
var devicelist = _iBasicDeviceService.QueryList();
|
|
var allDeviceKinds = _mapper.Map<List<bas_device>, List<BasDeviceDto>>(devicelist);
|
|
var allDeviceKinds = _mapper.Map<List<bas_device>, List<BasDeviceDto>>(devicelist);
|
|
//所有测试方案
|
|
//所有测试方案
|
|
@@ -228,34 +232,54 @@ namespace PLCTool.ViewModels.BusinessManageViewModel
|
|
|
|
|
|
foreach (var item in allDeviceKinds)
|
|
foreach (var item in allDeviceKinds)
|
|
{
|
|
{
|
|
- string deviceKind =_iBasicDeviceKindService.Find((int)item.DeviceKindId)?.devicekind_name;
|
|
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ string projectName = _iBasicProjectService.Find((int)item.ProjectId)?.project_name;
|
|
|
|
+ string deviceKindName = _iBasicDeviceKindService.Find((int)item.DeviceKindId)?.devicekind_name;
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ string deviceKind = _iBasicDeviceKindService.Find((int)item.DeviceKindId)?.devicekind_name;
|
|
//在测试方案中查找此设备类型的所有方案
|
|
//在测试方案中查找此设备类型的所有方案
|
|
- var schs= schDtoList.FindAll(x => x.DeviceKindName == deviceKind);
|
|
|
|
|
|
+ var schs = schDtoList.FindAll(x => x.DeviceKindName == deviceKind);
|
|
//设备方案
|
|
//设备方案
|
|
foreach (var sch in schs)
|
|
foreach (var sch in schs)
|
|
{
|
|
{
|
|
- allDeviceList.Add(new BasDeviceWithSchModel()
|
|
|
|
|
|
+ allDeviceAndSchList.Add(new BasDeviceWithSchModel()
|
|
{
|
|
{
|
|
DeviceId = item.DeviceId,
|
|
DeviceId = item.DeviceId,
|
|
DeviceNo = item.DeviceNo,
|
|
DeviceNo = item.DeviceNo,
|
|
DeviceName = item.DeviceName,
|
|
DeviceName = item.DeviceName,
|
|
- DeviceKindName = _iBasicDeviceKindService.Find((int)item.DeviceKindId)?.devicekind_name,
|
|
|
|
- ProjectName = _iBasicProjectService.Find((int)item.ProjectId)?.project_name,
|
|
|
|
|
|
+ DeviceKindName = deviceKindName,
|
|
|
|
+ ProjectName = projectName,
|
|
SchemeName = sch.SchemeName,
|
|
SchemeName = sch.SchemeName,
|
|
- SchemeId=sch.SchemeId,
|
|
|
|
- }) ;
|
|
|
|
|
|
+ SchemeId = sch.SchemeId,
|
|
|
|
+ });
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+ //只添加选择的项目
|
|
|
|
+ if (projectName == selectProjectName)
|
|
|
|
+ {
|
|
|
|
+ allDeviceList.Add(new BasDeviceWithSchModel()
|
|
|
|
+ {
|
|
|
|
+ DeviceId = item.DeviceId,
|
|
|
|
+ DeviceNo = item.DeviceNo,
|
|
|
|
+ DeviceName = item.DeviceName,
|
|
|
|
+ DeviceKindName = deviceKindName,
|
|
|
|
+ ProjectName = projectName,
|
|
|
|
+
|
|
|
|
+ });
|
|
conditionDevices.Add(new BasDeviceWithSchModel()
|
|
conditionDevices.Add(new BasDeviceWithSchModel()
|
|
{
|
|
{
|
|
DeviceId = item.DeviceId,
|
|
DeviceId = item.DeviceId,
|
|
DeviceNo = item.DeviceNo,
|
|
DeviceNo = item.DeviceNo,
|
|
DeviceName = item.DeviceName,
|
|
DeviceName = item.DeviceName,
|
|
- DeviceKindName = _iBasicDeviceKindService.Find((int)item.DeviceKindId)?.devicekind_name,
|
|
|
|
- ProjectName = _iBasicProjectService.Find((int)item.ProjectId)?.project_name,
|
|
|
|
- SchemeName = sch.SchemeName,
|
|
|
|
- SchemeId = sch.SchemeId,
|
|
|
|
|
|
+ DeviceKindName = deviceKindName,
|
|
|
|
+ ProjectName = projectName,
|
|
|
|
+
|
|
});
|
|
});
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
|
|
+
|
|
}
|
|
}
|
|
conditionDevices = conditionDevices.OrderBy(x => x.DeviceId).ToList();
|
|
conditionDevices = conditionDevices.OrderBy(x => x.DeviceId).ToList();
|
|
Getpage();
|
|
Getpage();
|
|
@@ -285,6 +309,30 @@ namespace PLCTool.ViewModels.BusinessManageViewModel
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ public void OnNavigatedTo(NavigationContext navigationContext)
|
|
|
|
+ {
|
|
|
|
+ //编辑
|
|
|
|
+ var getMsg = navigationContext.Parameters.GetValues<string>("Key");
|
|
|
|
+ ///值不为空,表示修改,为空表示新增
|
|
|
|
+ if (getMsg != null)
|
|
|
|
+ {
|
|
|
|
+ foreach (var item in getMsg)
|
|
|
|
+ {
|
|
|
|
+ selectProjectName= item;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public bool IsNavigationTarget(NavigationContext navigationContext)
|
|
|
|
+ {
|
|
|
|
+ return true;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public void OnNavigatedFrom(NavigationContext navigationContext)
|
|
|
|
+ {
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+
|
|
#endregion
|
|
#endregion
|
|
#region 命令绑定
|
|
#region 命令绑定
|
|
|
|
|