Explorar el Código

修改测试方案

ltwork hace 1 año
padre
commit
f20f398888

+ 23 - 1
BlankApp1/BlankApp1/ViewModels/BasicConfigViewModel/AddOrEditSchViewModel.cs

@@ -27,18 +27,20 @@ namespace PLCTool.ViewModels.BasicConfigViewModel
         private readonly IOptionConfigService _optionConfigService;
         private readonly IBasicPlcTestSchemeService _basicPlcTestSchemeService;
         private readonly IBasicPlcTestSchemeDtlService _basicPlcTestSchemeDtlService;
+        private readonly IBasicDeviceKindService _iBasicDeviceKindService;
         private readonly IMapper _mapper;
         private readonly ILogger _logger;
         private List<OptionConfigDto> _optionConfigs;
         private bas_plc_test_scheme bas_Plc_Test_Scheme;//测试方案
         private int schDtlMainId = 0;//测试方案明细主键id
-        public AddOrEditSchViewModel(IDialogService dialog, IEventAggregator aggregator, IOptionConfigService optionConfigService, IBasicPlcTestSchemeService basicPlcTestSchemeService, IBasicPlcTestSchemeDtlService basicPlcTestSchemeDtlService, IMapper mapper,ILogger logger)
+        public AddOrEditSchViewModel(IDialogService dialog, IEventAggregator aggregator, IOptionConfigService optionConfigService, IBasicPlcTestSchemeService basicPlcTestSchemeService, IBasicPlcTestSchemeDtlService basicPlcTestSchemeDtlService, IBasicDeviceKindService iBasicDeviceKindService, IMapper mapper,ILogger logger)
         {
             _dialog = dialog;
             _aggregator = aggregator;
             _optionConfigService = optionConfigService;
             _basicPlcTestSchemeService = basicPlcTestSchemeService;
             _basicPlcTestSchemeDtlService = basicPlcTestSchemeDtlService;
+            _iBasicDeviceKindService= iBasicDeviceKindService;
             _mapper = mapper;
             _logger = logger;
             CloseCommand = new DelegateCommand(Close);
@@ -51,12 +53,16 @@ namespace PLCTool.ViewModels.BasicConfigViewModel
             DeleteBeforeCommand = new DelegateCommand<Object>(DeleteBefore);
             DeleteInCommand = new DelegateCommand<object>(DeleteIn);
             DeleteOutCommand = new DelegateCommand<object>(DeleteOut);
+            OnLoadCommand = new DelegateCommand(OnLoad);
             BeforeConList = new ObservableCollection<BasPlcItemConfigDto>();
             InConList = new ObservableCollection<BasPlcItemConfigDto>();
             OutConList = new ObservableCollection<BasPlcItemConfigDto>();
+            
             GetConfigOption();
         }
 
+        
+
         #region idialog接口实现
         public string Title { set; get; } = "新增方案";
 
@@ -185,6 +191,10 @@ namespace PLCTool.ViewModels.BasicConfigViewModel
 
         #endregion
         #region 私有方法
+        private void OnLoad()
+        {
+            DeviceKindNameList = _iBasicDeviceKindService.FindAllDeviceKind();
+        }
         private void OpenEditDialog(Object obj, ObservableCollection<BasPlcItemConfigDto> conList)
         {
             int id = Convert.ToInt32(obj);
@@ -679,6 +689,8 @@ namespace PLCTool.ViewModels.BasicConfigViewModel
 
         public DelegateCommand<Object> EditOutCommand { set; get; }
 
+        public DelegateCommand OnLoadCommand { set; get; }
+
         #endregion
         #region 变量绑定
         /// <summary>
@@ -856,6 +868,16 @@ namespace PLCTool.ViewModels.BasicConfigViewModel
             get { return outConList; }
             set { outConList = value; RaisePropertyChanged(); }
         }
+
+        /// <summary>
+        /// 设备类型
+        /// </summary>
+        private List<string> deviceKindNameList;
+        public List<string> DeviceKindNameList
+        {
+            get { return deviceKindNameList; }
+            set { deviceKindNameList = value; RaisePropertyChanged(); }
+        }
         #endregion
 
     }

+ 29 - 36
BlankApp1/BlankApp1/ViewModels/BasicConfigViewModel/BaseConfigViewModel.cs

@@ -28,6 +28,7 @@ namespace PLCTool.ViewModels.BasicConfigViewModel
         private readonly IOptionConfigService _optionConfigService;
         private readonly IBasicPlcTestSchemeService _basicPlcTestSchemeService;
         private readonly IBasicPlcTestSchemeDtlService _basicPlcTestSchemeDtlService;
+        private readonly IBasicDeviceKindService _iBasicDeviceKindService;
         private readonly ILogger _logger;
         private readonly IMapper _mapper;
         private readonly IMenuService _menuService;
@@ -36,12 +37,13 @@ namespace PLCTool.ViewModels.BasicConfigViewModel
         private List<BasicPlcTestSchemeDto> conditionConfig = new List<BasicPlcTestSchemeDto>();//符合条件的方案
 
         private const int PageCount = 1; //每一页显示个数
-        public BaseConfigViewModel(IDialogService dialog, IMenuService menuService, IOptionConfigService optionConfigService, IBasicPlcTestSchemeService basicPlcTestSchemeService, IBasicPlcTestSchemeDtlService basicPlcTestSchemeDtlService ,IMapper mapper, ILogger logger)
+        public BaseConfigViewModel(IDialogService dialog, IMenuService menuService, IOptionConfigService optionConfigService, IBasicPlcTestSchemeService basicPlcTestSchemeService, IBasicPlcTestSchemeDtlService basicPlcTestSchemeDtlService , IBasicDeviceKindService iBasicDeviceKindService, IMapper mapper, ILogger logger)
         {
             _dialog = dialog;
             _optionConfigService = optionConfigService;
             _basicPlcTestSchemeService = basicPlcTestSchemeService;
             _basicPlcTestSchemeDtlService = basicPlcTestSchemeDtlService;
+            _iBasicDeviceKindService = iBasicDeviceKindService;
             _logger = logger;
             _mapper = mapper;
             _menuService = menuService;
@@ -52,17 +54,22 @@ namespace PLCTool.ViewModels.BasicConfigViewModel
             EditCommand = new DelegateCommand<object>(Edit);
             DeleteCommand = new DelegateCommand<object>(Delete);
             CopyCommand = new DelegateCommand<object>(Copy);
+            OnLoadCommand = new DelegateCommand(OnLoad);
             GetConfigOption();
             GetContent();
         }
 
-      
 
 
 
 
-        #region 私有方法
 
+        #region 私有方法
+        private void OnLoad()
+        {
+            DeviceKindNameList = _iBasicDeviceKindService.FindAllDeviceKind();
+           
+        }
         private void Reset(object obj)
         {
             ScheduleName = string.Empty;
@@ -93,9 +100,9 @@ namespace PLCTool.ViewModels.BasicConfigViewModel
             conditionConfig = (from a in allConfigList
                                       where (EndTime == DateTime.MinValue ? true : (a.CreateTime < Convert.ToDateTime(EndTime)) && (Convert.ToDateTime(StartTime) < a.CreateTime))
                                        && (string.IsNullOrEmpty(ScheduleName) ? true : (a.SchemeName == ScheduleName))
-                                        && (string.IsNullOrEmpty(TestName) ? true : (a.ItemName == TestName))
+                            
                                          && (string.IsNullOrEmpty(DeviceKindName) ? true : (a.DeviceKindName == DeviceKindName))
-                                           && (string.IsNullOrEmpty(SelectTest) ? true : (a.ItemType == SelectTest))
+                                       
                                select a).ToList();
             //默认显示的第一页
             conditionConfig = conditionConfig.OrderBy(x => x.SchemeName).ThenBy(x => x.SchemeId).ToList();
@@ -265,37 +272,12 @@ namespace PLCTool.ViewModels.BasicConfigViewModel
             //查找测试项名称
             foreach (var sch in configList)
             {
-                long schId = sch.SchemeId;
-                //在解决方案详细表中查找所有的测试项
-                var items=_basicPlcTestSchemeDtlService.FindAllBySchId(schId);
-                foreach(var item in items)
-                {
-                    BasicPlcTestSchemeDto basicPlcTestSchemeDto = new BasicPlcTestSchemeDto();
-                    basicPlcTestSchemeDto.SchemeId = item.scheme_dtl_id;
-                    basicPlcTestSchemeDto.SchemeName= sch.SchemeName;
-                    basicPlcTestSchemeDto.DeviceKindName= sch.DeviceKindName;
-                    switch(item.item_type)
-                    {
-                        case 0:
-                            basicPlcTestSchemeDto.ItemType = "前置项";
-                            break;
-                        case 1:
-                            basicPlcTestSchemeDto.ItemType = "PLC点位测试项";
-                            break; 
-                        case 2:
-                            basicPlcTestSchemeDto.ItemType = "Robot动作测试";
-                            break;
-                    }
                
-                    basicPlcTestSchemeDto.ItemName=item.item_name;
-                    basicPlcTestSchemeDto.CreateBy=sch.CreateBy;
-                    basicPlcTestSchemeDto.CreateTime = sch.CreateTime;
-                  
-                    allConfigList.Add(basicPlcTestSchemeDto);
-                    conditionConfig.Add(basicPlcTestSchemeDto);
-                   
-                }
-                conditionConfig = conditionConfig.OrderBy(x => x.SchemeName).ThenBy(x => x.SchemeId).ToList();
+
+                allConfigList.Add(sch);
+                conditionConfig.Add(sch);
+
+                conditionConfig = conditionConfig.OrderBy(x => x.DeviceKindName).ThenBy(x => x.SchemeId).ToList();
                 //默认显示的第一页
                 Getpage();
             }
@@ -337,7 +319,9 @@ namespace PLCTool.ViewModels.BasicConfigViewModel
         public DelegateCommand<object> CopyCommand { set; get; }
         public DelegateCommand<string> ExportCommand { set; get; }
 
-  
+        public DelegateCommand OnLoadCommand { set; get; }
+
+
         #endregion
         #region 数据绑定
         /// <summary>
@@ -359,6 +343,15 @@ namespace PLCTool.ViewModels.BasicConfigViewModel
             set { deviceKindName = value; RaisePropertyChanged(); }
         }
         /// <summary>
+        /// 设备类型
+        /// </summary>
+        private List<string> deviceKindNameList;
+        public List<string> DeviceKindNameList
+        {
+            get { return deviceKindNameList; }
+            set { deviceKindNameList = value; RaisePropertyChanged(); }
+        }
+        /// <summary>
         /// 测试项名称
         /// </summary>
         private string testName;

+ 6 - 1
BlankApp1/BlankApp1/ViewModels/BasicConfigViewModel/DeviceViewModel.cs

@@ -336,13 +336,18 @@ namespace PLCTool.ViewModels.BasicConfigViewModel
             set { deviceKindName = value; RaisePropertyChanged(); }
         }
 
-
+        /// <summary>
+        /// 项目名称
+        /// </summary>
         private List<string> projectNameList;
         public List<string> ProjectNameList
         {
             get { return projectNameList; }
             set { projectNameList = value; RaisePropertyChanged(); }
         }
+        /// <summary>
+        /// 设备类型
+        /// </summary>
         private List<string> deviceKindNameList;
         public List<string> DeviceKindNameList
         {

+ 7 - 1
BlankApp1/BlankApp1/Views/BasicConfigView/AddOrEditSchView.xaml

@@ -3,7 +3,8 @@
              xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
              xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
              xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
-             xmlns:local="clr-namespace:PLCTool.Views.BasicConfigView"
+             xmlns:local="clr-namespace:PLCTool.Views.BasicConfigView"         
+             xmlns:b="http://schemas.microsoft.com/xaml/behaviors"
              xmlns:prism="http://prismlibrary.com/" 
              BorderBrush="#CBCBCB" BorderThickness="1"
              Height="600" Width="1000" >
@@ -27,6 +28,11 @@
     </UserControl.Resources>
 
     <Grid>
+        <b:Interaction.Triggers>
+            <b:EventTrigger EventName="Loaded">
+                <b:InvokeCommandAction Command="{Binding OnLoadCommand}"/>
+            </b:EventTrigger>
+        </b:Interaction.Triggers>
         <Grid.RowDefinitions>
 
             <RowDefinition Height="50" />

+ 12 - 13
BlankApp1/BlankApp1/Views/BasicConfigView/BaseConfigView.xaml

@@ -7,9 +7,15 @@
              xmlns:hc="https://handyorg.github.io/handycontrol"
              xmlns:myContr="clr-namespace:BlankApp1.Controls"
              xmlns:wpfdev="https://github.com/WPFDevelopersOrg/WPFDevelopers"
+             xmlns:b="http://schemas.microsoft.com/xaml/behaviors"
              mc:Ignorable="d" 
              d:DesignHeight="450" d:DesignWidth="800">
     <Grid >
+        <b:Interaction.Triggers>
+            <b:EventTrigger EventName="Loaded">
+                <b:InvokeCommandAction Command="{Binding OnLoadCommand}"/>
+            </b:EventTrigger>
+        </b:Interaction.Triggers>
         <Grid.RowDefinitions>
             <RowDefinition Height="40"/>
             <RowDefinition Height="40"/>
@@ -22,18 +28,12 @@
                 <TextBlock Text="测试方案名称:"  Style="{StaticResource NormalTextBlockStyle}" Margin="10,0,5,0"/>
                 <TextBox  Height="28" Width="120" Text="{Binding ScheduleName}" />
             </StackPanel>
-            <StackPanel Orientation="Horizontal">
-                <TextBlock Text="设备类型:"  Style="{StaticResource NormalTextBlockStyle}" Margin="10,0,5,0"/>
-                <TextBox  Height="28" Width="120" Text="{Binding DeviceKindName}"/>
-            </StackPanel>
-            <StackPanel Orientation="Horizontal" >
-                <TextBlock Text="测试项类型:"  Style="{StaticResource NormalTextBlockStyle}" Margin="10,0,5,0"/>
-                <ComboBox  Height="28" Width="120" ItemsSource="{Binding TestKinds}" SelectedItem="{Binding SelectTest}" />
-            </StackPanel>
-            <StackPanel Orientation="Horizontal">
-                <TextBlock Text="测试项名称:"  Style="{StaticResource NormalTextBlockStyle}" Margin="10,0,5,0"/>
-                <TextBox  Height="28" Width="120"  Text="{Binding TestName}"/>
+            <StackPanel Orientation="Horizontal"  Grid.Row="4" HorizontalAlignment="Center">
+                <TextBlock Text="所属设备类型:"  Style="{StaticResource NormalTextBlockStyle}" Margin="10,0,5,0" TextAlignment="Right" Width="80"/>
+                <ComboBox  Height="28" Width="120" ItemsSource="{Binding DeviceKindNameList}" SelectedItem="{Binding DeviceKindName}" />
             </StackPanel>
+         
+         
 
 
         </UniformGrid>
@@ -68,8 +68,7 @@
                 <DataGridTextColumn Header="序号" Width="50" Binding="{Binding SchemeId}" CellStyle="{StaticResource MyDataGridCellStyle}" />
                 <DataGridTextColumn Header="测试方案名称" Binding="{Binding SchemeName}" CellStyle="{StaticResource MyDataGridCellStyle}"/>
                 <DataGridTextColumn Header="设备类型" Binding="{Binding DeviceKindName}" CellStyle="{StaticResource MyDataGridCellStyle}"/>
-                <DataGridTextColumn Header="测试项类型" Binding="{Binding ItemType}" CellStyle="{StaticResource MyDataGridCellStyle}"/>
-                <DataGridTextColumn Header="测试项名称" Binding="{Binding ItemName}" CellStyle="{StaticResource MyDataGridCellStyle}"/>
+               
                 <DataGridTextColumn Header="创建者" Binding="{Binding CreateBy}" CellStyle="{StaticResource MyDataGridCellStyle}"/>
                 <DataGridTextColumn Header="创建时间" Binding="{Binding CreateTime,StringFormat={}{0:yyyy-MM-dd HH:mm:ss}}" CellStyle="{StaticResource MyDataGridCellStyle}"/>
                 <DataGridTemplateColumn Header="操作" Width="180" CellStyle="{StaticResource MyDataGridCellStyle}">

+ 6 - 0
BlankApp1/BlankApp1/Views/BasicConfigView/DeviceKindView.xaml

@@ -7,9 +7,15 @@
              xmlns:hc="https://handyorg.github.io/handycontrol"
              xmlns:myContr="clr-namespace:BlankApp1.Controls"
              xmlns:wpfdev="https://github.com/WPFDevelopersOrg/WPFDevelopers"
+             xmlns:b="http://schemas.microsoft.com/xaml/behaviors"
              mc:Ignorable="d" 
              d:DesignHeight="450" d:DesignWidth="800">
     <Grid >
+        <b:Interaction.Triggers>
+            <b:EventTrigger EventName="Loaded">
+                <b:InvokeCommandAction Command="{Binding OnLoadCommand}"/>
+            </b:EventTrigger>
+        </b:Interaction.Triggers>
         <Grid.RowDefinitions>
             <RowDefinition Height="40"/>
             <RowDefinition Height="40"/>