瀏覽代碼

添加修改方案的代码

user_lt 1 年之前
父節點
當前提交
23a4246d6e

+ 2 - 0
BlankApp1/BlankApp1/Common/Appsession.cs

@@ -10,5 +10,7 @@ namespace PLCTool.Common
     public  class Appsession
     {
         public static string UserName = "Admin";
+
     }
+  
 }

+ 17 - 0
BlankApp1/BlankApp1/ViewModels/BasicConfigViewModel/AddDetailViewModel.cs

@@ -70,7 +70,24 @@ namespace PLCTool.ViewModels.BasicConfigViewModel
 
         public void OnDialogOpened(IDialogParameters parameters)
         {
+            var getMsg = parameters.GetValues<BasPlcItemConfigDto>("Key");
+            ///值不为空,表示修改
+            if (getMsg != null)
+            {
+                foreach (var item in getMsg)
+                {
+                    if(item!=null)
+                    {
+                        PLCItem = item.PlcItem;
+                        PLCAddress = item.PlcAddress;
+                        PLCValue = item.PlcValue;
+                        PLCDescribe = item.Remark;
+
+                    }
 
+                }
+
+            }
         }
 
         #endregion

+ 225 - 58
BlankApp1/BlankApp1/ViewModels/BasicConfigViewModel/AddPlanViewModel.cs

@@ -3,6 +3,7 @@ using BizService;
 using BlankApp1.Events;
 using Model.Dto;
 using Model.Entities;
+using NetTaste;
 using Newtonsoft.Json;
 using PLCTool.Common;
 using Prism.Commands;
@@ -12,6 +13,7 @@ using Prism.Services.Dialogs;
 using System;
 using System.Collections.Generic;
 using System.Collections.ObjectModel;
+using System.IdentityModel.Tokens.Jwt;
 using System.Linq;
 using System.Text;
 using System.Threading.Tasks;
@@ -41,15 +43,217 @@ namespace PLCTool.ViewModels.BasicConfigViewModel
             SureCommand = new DelegateCommand<string>(Sure);
             ResetCommand = new DelegateCommand<string>(ResetMethod);
             AddDetailCommand = new DelegateCommand<string>(AddPLCDetail);
+            EditInCommand = new DelegateCommand<object>(EditIn);
+            EditOutCommand = new DelegateCommand<object>(EditOut);
             EditBeforeCommand = new DelegateCommand<Object>(EditBefore);
             DeleteBeforeCommand = new DelegateCommand<Object>(DeleteBefore);
-          
-            BeforeConList = new ObservableCollection<BasPlcItemConfigDto>();
+            DeleteInCommand = new DelegateCommand<object>(DeleteIn);
+            DeleteOutCommand = new DelegateCommand<object>(DeleteOut);
+              BeforeConList = new ObservableCollection<BasPlcItemConfigDto>();
             InConList = new ObservableCollection<BasPlcItemConfigDto>();
             OutConList = new ObservableCollection<BasPlcItemConfigDto>();
             GetConfigOption();
         }
 
+        #region idialog接口实现
+        public string Title { set; get; } = "新增方案";
+
+        public event Action<IDialogResult> RequestClose;
+
+        public bool CanCloseDialog()
+        {
+            return true;
+        }
+
+        public void OnDialogClosed()
+        {
+
+        }
+
+        public void OnDialogOpened(IDialogParameters parameters)
+        {
+            //编辑
+            var getMsg = parameters.GetValues<long>("Key");
+            ///值不为空,表示修改
+            if (getMsg != null)
+            {
+                foreach (var item in getMsg)
+                {
+                    Title = "修改方案";
+                    int id = Convert.ToInt32(item);
+                    //根据 测试方案明细主键ID 查找测试方案id 及方案名和设备名
+                    var findresult=_basicPlcTestSchemeDtlService.Find(id);
+                    if(findresult != null)
+                    {
+                        //根据方案id 在方案表中查找方案名 设备名
+                        int schID =Convert.ToInt32( findresult.scheme_id);
+                        var findSch=_basicPlcTestSchemeService.Find(schID);
+                        if(findSch != null )
+                        {
+                            ScheduleName = findSch.scheme_name;
+                            DeviceName = findSch.device_name;
+                           
+                        }
+                        TestName = findresult.item_name;
+                        //SelectTest = findresult.item_type;
+                        //前置项解析
+                        string preconStr = findresult.precondition.ToString();
+                        JsonModel preconditionModel = JsonConvert.DeserializeObject<JsonModel>(preconStr);
+                        BeforeSelectJudge = preconditionModel.ItemType;
+                        SelectLogic = preconditionModel.ItemLogical;
+                        BeforeDetail = preconditionModel.Description;
+                        BeforeConList.Clear();
+                        foreach(var detail in preconditionModel.DetailInfo)
+                        {
+                            BasPlcItemConfigDto basPlcItemConfigDto = new BasPlcItemConfigDto();
+                            basPlcItemConfigDto.PlcItem=detail.PlcItem;
+                            basPlcItemConfigDto.PlcAddress = detail.PlcAddress;
+                            basPlcItemConfigDto.PlcValue = detail.PlcValue;
+                            basPlcItemConfigDto.Remark = detail.Remark;
+                            beforeConList.Add(basPlcItemConfigDto);
+                        }
+                        //输入项解析
+                        string inStr = findresult.action.ToString();
+                        JsonModel inModel = JsonConvert.DeserializeObject<JsonModel>(inStr);
+                        SelectInJudge = inModel.ItemType;
+                        InSelectLogic = inModel.ItemLogical;
+                        InDetail = inModel.Description;
+                        InConList.Clear();
+                        foreach (var detail in inModel.DetailInfo)
+                        {
+                            BasPlcItemConfigDto basPlcItemConfigDto = new BasPlcItemConfigDto();
+                            basPlcItemConfigDto.PlcItem = detail.PlcItem;
+                            basPlcItemConfigDto.PlcAddress = detail.PlcAddress;
+                            basPlcItemConfigDto.PlcValue = detail.PlcValue;
+                            basPlcItemConfigDto.Remark = detail.Remark;
+                            InConList.Add(basPlcItemConfigDto);
+                        }
+                        //输出项解析
+                        string outStr = findresult.judgement_result.ToString();
+                        JsonModel outModel = JsonConvert.DeserializeObject<JsonModel>(outStr);
+                        SelectOutJudge = outModel.ItemType;
+                        OutSelectLogic = outModel.ItemLogical;
+                        OutDetail = outModel.Description;
+                        OutConList.Clear();
+                        foreach (var detail in outModel.DetailInfo)
+                        {
+                            BasPlcItemConfigDto basPlcItemConfigDto = new BasPlcItemConfigDto();
+                            basPlcItemConfigDto.PlcItem = detail.PlcItem;
+                            basPlcItemConfigDto.PlcAddress = detail.PlcAddress;
+                            basPlcItemConfigDto.PlcValue = detail.PlcValue;
+                            basPlcItemConfigDto.Remark = detail.Remark;
+                            OutConList.Add(basPlcItemConfigDto);
+                        }
+                    }
+
+                }
+
+            }
+        }
+
+        #endregion
+        #region 私有方法
+        private void OpenEditDialog(Object obj, ObservableCollection<BasPlcItemConfigDto> conList)
+        {
+            int id = Convert.ToInt32(obj);
+            var edit = conList.FirstOrDefault(x => x.Id == id);
+            if (edit != null)
+            {
+                DialogParameters parm = new DialogParameters();
+                parm.Add("Key", edit);
+                //弹出详情对话框
+                _dialog.ShowDialog("AddDetailView", parm, async callback =>
+                {
+                    if (callback.Result == ButtonResult.OK)
+                    {
+                        BasPlcItemConfigDto returnValue = callback.Parameters.GetValue<BasPlcItemConfigDto>("ReturnValue");
+                        //更新
+                        var after = conList.FirstOrDefault(x => x.Id == id);
+                        if (after != null)
+                        {
+                            after.PlcItem = returnValue.PlcItem;
+                            after.PlcAddress = returnValue.PlcAddress;
+                            after.PlcValue = returnValue.PlcValue;
+                            after.Remark = returnValue.Remark;
+
+                        }
+                    }
+
+                });
+            }
+        }
+
+        /// <summary>
+        /// 前置条件编辑
+        /// </summary>
+        /// <param name="obj"></param>
+        /// <exception cref="NotImplementedException"></exception>
+        private void EditBefore(Object obj)
+        {
+
+            OpenEditDialog(obj, BeforeConList);
+
+
+        }
+
+        private void EditOut(object obj)
+        {
+            OpenEditDialog(obj, OutConList);
+        }
+
+        private void EditIn(object obj)
+        {
+            OpenEditDialog(obj, InConList);
+        }
+        /// <summary>
+        /// 前置条件删除
+        /// </summary>
+        /// <param name="obj"></param>
+        /// <exception cref="NotImplementedException"></exception>
+        private void DeleteBefore(Object obj)
+        {
+            int id = Convert.ToInt32(obj);
+            MessageBoxResult boxResult = MessageBox.Show("确认删除此条数据?", "确认", MessageBoxButton.OKCancel, MessageBoxImage.Question);
+            if (boxResult == MessageBoxResult.OK)
+            {
+                var del = BeforeConList.FirstOrDefault(x => x.Id == id);
+                if (del != null)
+                {
+                    BeforeConList.Remove(del);
+                }
+
+            }
+        }
+        private void DeleteOut(object obj)
+        {
+            int id = Convert.ToInt32(obj);
+            MessageBoxResult boxResult = MessageBox.Show("确认删除此条数据?", "确认", MessageBoxButton.OKCancel, MessageBoxImage.Question);
+            if (boxResult == MessageBoxResult.OK)
+            {
+                var del = OutConList.FirstOrDefault(x => x.Id == id);
+                if (del != null)
+                {
+                    OutConList.Remove(del);
+                }
+
+            }
+        }
+
+        private void DeleteIn(object obj)
+        {
+            int id = Convert.ToInt32(obj);
+            MessageBoxResult boxResult = MessageBox.Show("确认删除此条数据?", "确认", MessageBoxButton.OKCancel, MessageBoxImage.Question);
+            if (boxResult == MessageBoxResult.OK)
+            {
+                var del = InConList.FirstOrDefault(x => x.Id == id);
+                if (del != null)
+                {
+                    InConList.Remove(del);
+                }
+
+            }
+        }
+
         /// <summary>
         /// 获取配置
         /// </summary>
@@ -80,38 +284,12 @@ namespace PLCTool.ViewModels.BasicConfigViewModel
                 JudgeLogicKinds.Add(logic.ContentOption);
                 InJudgeLogicKinds.Add(logic.ContentOption);
                 OutJudgeLogicKinds.Add(logic.ContentOption);
-               
+
             }
 
         }
-        /// <summary>
-        /// 前置条件编辑
-        /// </summary>
-        /// <param name="obj"></param>
-        /// <exception cref="NotImplementedException"></exception>
-        private void EditBefore(Object obj)
-        {
-            
-        }
-        /// <summary>
-        /// 前置条件删除
-        /// </summary>
-        /// <param name="obj"></param>
-        /// <exception cref="NotImplementedException"></exception>
-        private void DeleteBefore(Object obj)
-        {
-            int id = Convert.ToInt32(obj);
-            MessageBoxResult boxResult = MessageBox.Show("确认删除此条数据?", "确认", MessageBoxButton.OKCancel, MessageBoxImage.Question);
-            if(boxResult == MessageBoxResult.OK)
-            {
-                var del = BeforeConList.FirstOrDefault(x => x.Id == id);
-                if(del != null)
-                {
-                    BeforeConList.Remove(del);  
-                }
 
-            }
-        }
+
         /// <summary>
         /// 新增
         /// </summary>
@@ -126,7 +304,7 @@ namespace PLCTool.ViewModels.BasicConfigViewModel
                 if (callback.Result == ButtonResult.OK)
                 {
                     BasPlcItemConfigDto returnValue = callback.Parameters.GetValue<BasPlcItemConfigDto>("ReturnValue");
-                    switch(str)
+                    switch (str)
                     {
                         case "Before":
                             BeforeConList.Add(returnValue); break;
@@ -140,35 +318,10 @@ namespace PLCTool.ViewModels.BasicConfigViewModel
             });
         }
 
-
-
-
-        #region idialog接口实现
-        public string Title { set; get; } = "弹出窗体";
-
-        public event Action<IDialogResult> RequestClose;
-
-        public bool CanCloseDialog()
-        {
-            return true;
-        }
-
-        public void OnDialogClosed()
-        {
-
-        }
-
-        public void OnDialogOpened(IDialogParameters parameters)
-        {
-
-        }
-
-        #endregion
-        #region 私有方法
         /// <summary>
         /// 初始化
         /// </summary>
-     
+
         /// <summary>
         /// 关闭按钮
         /// </summary>
@@ -243,7 +396,6 @@ namespace PLCTool.ViewModels.BasicConfigViewModel
             schDtlDto.CreateTime = DateTime.Now;
             schDtlDto.UpdateTime = DateTime.Now;
             schDtlDto.UpdateBy = Appsession.UserName;
-
             bas_plc_test_scheme_dtl schDtlEntity = _mapper.Map<BasicPlcTestSchemeDtlDto, bas_plc_test_scheme_dtl>(schDtlDto);
             _basicPlcTestSchemeDtlService.Add(schDtlEntity);
         }
@@ -304,6 +456,21 @@ namespace PLCTool.ViewModels.BasicConfigViewModel
         /// 表格编辑按钮
         /// </summary>
         public DelegateCommand<Object> EditBeforeCommand { set; get; }
+
+        /// <summary>
+        /// 输入项
+        /// </summary>
+        public DelegateCommand<Object> DeleteInCommand { set; get; }
+      
+        public DelegateCommand<Object> EditInCommand { set; get; }
+
+        /// <summary>
+        /// 输出项
+        /// </summary>
+        public DelegateCommand<Object> DeleteOutCommand { set; get; }
+
+        public DelegateCommand<Object> EditOutCommand { set; get; }
+
         #endregion
         #region 变量绑定
         /// <summary>

+ 24 - 3
BlankApp1/BlankApp1/ViewModels/BasicConfigViewModel/BaseConfigViewModel.cs

@@ -63,9 +63,26 @@ namespace PLCTool.ViewModels.BasicConfigViewModel
                 TestKinds.Add(test.ContentOption);
             }
         }
+        /// <summary>
+        /// 编辑
+        /// </summary>
+        /// <param name="obj"></param>
          private void Edit(object obj)
         {
-            
+            //测试方案明细主键ID
+            long id = Convert.ToInt64(obj);
+            DialogParameters parm = new DialogParameters();
+            parm.Add("Key", id);
+            //弹出详情对话框
+            _dialog.ShowDialog("AddPlanView",parm, async callback =>
+            {
+                if (callback.Result == ButtonResult.OK)
+                {
+                    //更新表格,重新获取
+                    GetContent();
+                }
+
+            });
         }
         /// <summary>
         /// 删除操作
@@ -79,7 +96,7 @@ namespace PLCTool.ViewModels.BasicConfigViewModel
             {
                 
                 _basicPlcTestSchemeDtlService.Delete(id);
-                //更新表格,重新获取
+                //更新表格,重新获取
                 GetContent();
             }
         }
@@ -90,7 +107,11 @@ namespace PLCTool.ViewModels.BasicConfigViewModel
             //弹出详情对话框
             _dialog.ShowDialog("AddPlanView", async callback =>
             {
-
+                if (callback.Result == ButtonResult.OK)
+                {
+                    //更新表格,重新获取
+                    GetContent();
+                }
 
             });
         }

+ 12 - 0
BlankApp1/BlankApp1/ViewModels/BasicConfigViewModel/EditSchViewModel.cs

@@ -0,0 +1,12 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace PLCTool.ViewModels.BasicConfigViewModel
+{
+    internal class EditSchViewModel
+    {
+    }
+}

+ 2 - 3
BlankApp1/BlankApp1/Views/BasicConfigView/AddDetailView.xaml

@@ -61,11 +61,10 @@
         </StackPanel>
         <StackPanel Orientation="Horizontal" Grid.Row="5" HorizontalAlignment="Center">
            
-            <Button  Content="取消" Width="80"  Margin="5,0"  Command="{Binding ResetCommand}" Opacity="0.7" Style="{StaticResource NormalButtonStyle}" />
+            <Button  Content="取消" Width="80"  Margin="5,0"  Command="{Binding CancelCommand}" Opacity="0.7" Style="{StaticResource NormalButtonStyle}" />
             <Button  Content="确认" Width="80"  Margin="5,0"  Command="{Binding SureCommand}" Style="{StaticResource NormalButtonStyle}" />
         </StackPanel>
-       
-        <Border Grid.Row="1"  BorderBrush="#CBCBCB" BorderThickness="0,1" />
+
    
     </Grid>
 </UserControl>

+ 20 - 26
BlankApp1/BlankApp1/Views/BasicConfigView/AddPlanView.xaml

@@ -3,18 +3,19 @@
              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"
-          
-              xmlns:prism="http://prismlibrary.com/" BorderBrush="#CBCBCB" BorderThickness="1"
-            Height="600" Width="1000">
-    <prism:Dialog.WindowStyle>
+             xmlns:local="clr-namespace:PLCTool.Views" 
+             xmlns:prism="http://prismlibrary.com/" 
+             BorderBrush="#CBCBCB" BorderThickness="1"
+             Height="600" Width="1000" >
+    <!--<prism:Dialog.WindowStyle>
         <Style TargetType="Window">
             <Setter Property="SizeToContent" Value="WidthAndHeight" />
             <Setter Property="ResizeMode" Value="NoResize" />
             <Setter Property="prism:Dialog.WindowStartupLocation" Value="CenterScreen" />
             <Setter Property="WindowStyle" Value="None" />
+        
         </Style>
-    </prism:Dialog.WindowStyle>
+    </prism:Dialog.WindowStyle>-->
     <UserControl.Resources>
         <Style TargetType="TextBlock" x:Key="textBlockStyle">
             <Setter Property="Width" Value="80"/>
@@ -27,21 +28,14 @@
 
     <Grid>
         <Grid.RowDefinitions>
-            <RowDefinition Height="30"/>
+          
             <RowDefinition Height="50" />
             <RowDefinition />
             <RowDefinition />
             <RowDefinition />
         </Grid.RowDefinitions>
-        <Grid Grid.Row="0"  Cursor="Hand" >
-            <StackPanel Orientation="Horizontal" Margin="10,5,0,0">
-                <TextBlock Text="新增测试方案" FontSize="15"/>
-            </StackPanel>
-            <StackPanel HorizontalAlignment="Right" Margin="10,0,0,0">
-                <Button    Command="{Binding CloseCommand}" Background="Transparent" Content="✕" BorderThickness="0"  Cursor="Hand" />
-            </StackPanel>
-        </Grid>
-        <StackPanel Orientation="Horizontal" Grid.Row="1" Margin="10">
+   
+        <StackPanel Orientation="Horizontal" Grid.Row="0" Margin="10">
             <StackPanel Orientation="Horizontal">
                 <TextBlock Text="测试方案名称:"  Style="{StaticResource NormalTextBlockStyle}" Margin="10,0,5,0"/>
                 <TextBox  Height="28" Width="120" Text="{Binding ScheduleName}" />
@@ -61,8 +55,8 @@
             <Button  Content="确认" Width="80"  Margin="5,0"  Command="{Binding SureCommand}" Style="{StaticResource NormalButtonStyle}" />
             <Button  Content="重置" Width="80"  Margin="5,0"  Command="{Binding ResetCommand}" Style="{StaticResource NormalButtonStyle}" />
         </StackPanel>
-        <Border Grid.Row="1"  BorderBrush="#CBCBCB" BorderThickness="0,1" />
-        <Grid Grid.Row="2">
+        <Border Grid.Row="0"  BorderBrush="#CBCBCB" BorderThickness="0,1" />
+        <Grid Grid.Row="1">
             <Grid.ColumnDefinitions>
                 <ColumnDefinition Width="80"/>
                 <ColumnDefinition/>
@@ -150,7 +144,7 @@
 
             </Grid>
         </Grid>
-        <Grid Grid.Row="3">
+        <Grid Grid.Row="2">
             <Grid.ColumnDefinitions>
                 <ColumnDefinition Width="80"/>
                 <ColumnDefinition/>
@@ -213,14 +207,14 @@
                                 <DataTemplate>
                                     <UniformGrid Columns="2">
                                         <Button  Width="auto" Background="Transparent" HorizontalContentAlignment ="Left" Foreground="Black" Height="25" BorderThickness="0"
-     Command="{Binding DataContext.EditBeforeCommand, RelativeSource={RelativeSource Mode=FindAncestor,AncestorType=DataGrid}}" CommandParameter="{Binding Id}" Cursor="Hand" Margin="0,0,10,0" >
+     Command="{Binding DataContext.EditInCommand, RelativeSource={RelativeSource Mode=FindAncestor,AncestorType=DataGrid}}" CommandParameter="{Binding Id}" Cursor="Hand" Margin="0,0,10,0" >
 
                                             <StackPanel Orientation="Horizontal">
                                                 <TextBlock  Text="编辑" VerticalAlignment="Center" Foreground="Blue"/>
                                             </StackPanel>
                                         </Button>
                                         <Button  Width="auto" Background="Transparent" HorizontalContentAlignment ="Left" Foreground="Black" Height="25" BorderThickness="0"
-     Command="{Binding DataContext.DeleteBeforeCommand, RelativeSource={RelativeSource Mode=FindAncestor,AncestorType=DataGrid}}" CommandParameter="{Binding Id}"   Cursor="Hand" >
+     Command="{Binding DataContext.DeleteInCommand, RelativeSource={RelativeSource Mode=FindAncestor,AncestorType=DataGrid}}" CommandParameter="{Binding Id}"   Cursor="Hand" >
 
                                             <StackPanel Orientation="Horizontal">
                                                 <TextBlock  Text="删除" VerticalAlignment="Center" Foreground="Blue"/>
@@ -238,8 +232,8 @@
 
             </Grid>
         </Grid>
-        <Border Grid.Row="3"  BorderBrush="#CBCBCB" BorderThickness="0,1,0,0" />
-        <Grid Grid.Row="4">
+        <Border Grid.Row="2"  BorderBrush="#CBCBCB" BorderThickness="0,1,0,0" />
+        <Grid Grid.Row="3">
             <Grid.ColumnDefinitions>
                 <ColumnDefinition Width="80"/>
                 <ColumnDefinition/>
@@ -302,14 +296,14 @@
                                 <DataTemplate>
                                     <UniformGrid Columns="2">
                                         <Button  Width="auto" Background="Transparent" HorizontalContentAlignment ="Left" Foreground="Black" Height="25" BorderThickness="0"
-     Command="{Binding DataContext.EditBeforeCommand, RelativeSource={RelativeSource Mode=FindAncestor,AncestorType=DataGrid}}" CommandParameter="{Binding Id}" Cursor="Hand" Margin="0,0,10,0" >
+     Command="{Binding DataContext.EditOutCommand, RelativeSource={RelativeSource Mode=FindAncestor,AncestorType=DataGrid}}" CommandParameter="{Binding Id}" Cursor="Hand" Margin="0,0,10,0" >
 
                                             <StackPanel Orientation="Horizontal">
                                                 <TextBlock  Text="编辑" VerticalAlignment="Center" Foreground="Blue"/>
                                             </StackPanel>
                                         </Button>
                                         <Button  Width="auto" Background="Transparent" HorizontalContentAlignment ="Left" Foreground="Black" Height="25" BorderThickness="0"
-     Command="{Binding DataContext.DeleteBeforeCommand, RelativeSource={RelativeSource Mode=FindAncestor,AncestorType=DataGrid}}" CommandParameter="{Binding Id}"   Cursor="Hand" >
+     Command="{Binding DataContext.DeleteOutCommand, RelativeSource={RelativeSource Mode=FindAncestor,AncestorType=DataGrid}}" CommandParameter="{Binding Id}"   Cursor="Hand" >
 
                                             <StackPanel Orientation="Horizontal">
                                                 <TextBlock  Text="删除" VerticalAlignment="Center" Foreground="Blue"/>
@@ -327,6 +321,6 @@
 
             </Grid>
         </Grid>
-        <Border Grid.Row="4"  BorderBrush="#CBCBCB" BorderThickness="0,1,0,0" />
+        <Border Grid.Row="3"  BorderBrush="#CBCBCB" BorderThickness="0,1,0,0" />
     </Grid>
 </UserControl>

+ 9 - 0
BlankApp1/BlankApp1/Views/BasicConfigView/AddPlanView.xaml.cs

@@ -24,5 +24,14 @@ namespace PLCTool.Views
         {
             InitializeComponent();
         }
+
+        private void UserControl_MouseMove(object sender, MouseEventArgs e)
+        {
+            if (e.LeftButton == MouseButtonState.Pressed)
+            {
+
+            }
+                //this.DragMove();
+        }
     }
 }

+ 318 - 0
BlankApp1/BlankApp1/Views/BasicConfigView/EditSchView.xaml

@@ -0,0 +1,318 @@
+<UserControl x:Class="PLCTool.Views.BasicConfigView.EditSchView"
+             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
+             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:prism="http://prismlibrary.com/" 
+                         BorderBrush="#CBCBCB" BorderThickness="1"
+                         Height="600" Width="1000" >
+
+    <UserControl.Resources>
+        <Style TargetType="TextBlock" x:Key="textBlockStyle">
+            <Setter Property="Width" Value="80"/>
+            <Setter Property="FontSize" Value="12"/>
+            <Setter Property="VerticalAlignment" Value="Center"/>
+            <Setter Property="TextAlignment" Value="Right"/>
+            <Setter Property="Margin" Value="0,0,5,0"/>
+        </Style>
+    </UserControl.Resources>
+
+    <Grid>
+        <Grid.RowDefinitions>
+
+            <RowDefinition Height="50" />
+            <RowDefinition />
+            <RowDefinition />
+            <RowDefinition />
+        </Grid.RowDefinitions>
+
+        <StackPanel Orientation="Horizontal" Grid.Row="0" Margin="10">
+            <StackPanel Orientation="Horizontal">
+                <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 DeviceName}"/>
+            </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>
+            <Button  Content="确认" Width="80"  Margin="5,0"  Command="{Binding SureCommand}" Style="{StaticResource NormalButtonStyle}" />
+            <Button  Content="重置" Width="80"  Margin="5,0"  Command="{Binding ResetCommand}" Style="{StaticResource NormalButtonStyle}" />
+        </StackPanel>
+        <Border Grid.Row="0"  BorderBrush="#CBCBCB" BorderThickness="0,1" />
+        <Grid Grid.Row="1">
+            <Grid.ColumnDefinitions>
+                <ColumnDefinition Width="80"/>
+                <ColumnDefinition/>
+                <ColumnDefinition Width="1.3*"/>
+            </Grid.ColumnDefinitions>
+            <TextBlock Grid.Column="0" Text="前置项" Style="{StaticResource NormalTextBlockStyle}" TextAlignment="Center">
+            </TextBlock>
+            <Border Grid.Column="1"  BorderBrush="#CBCBCB" BorderThickness="1,0" />
+            <Grid Grid.Column="1">
+                <Grid.RowDefinitions>
+                    <RowDefinition/>
+                    <RowDefinition/>
+                    <RowDefinition Height="2*"/>
+                </Grid.RowDefinitions>
+                <Grid Grid.Row="0">
+                    <StackPanel Orientation="Horizontal" >
+                        <TextBlock Text="测试项类型:"  Style="{StaticResource textBlockStyle}"/>
+                        <ComboBox  Height="28" Width="150" ItemsSource="{Binding BeforeJudgeKinds}" SelectedItem="{Binding BeforeSelectJudge}" />
+                    </StackPanel>
+                </Grid>
+                <Grid Grid.Row="1"  >
+                    <StackPanel Orientation="Horizontal" >
+                        <TextBlock Text="明细判定逻辑:"  Style="{StaticResource textBlockStyle}"/>
+                        <ComboBox  Height="28" Width="150" ItemsSource="{Binding JudgeLogicKinds}" SelectedItem="{Binding SelectLogic}"/>
+                    </StackPanel>
+                </Grid>
+                <Grid Grid.Row="2">
+                    <DockPanel LastChildFill="True" >
+                        <TextBlock Text="前置项描述:"   Style="{StaticResource textBlockStyle}" />
+                        <RichTextBox  Margin="0,5,5,5" >
+                            <FlowDocument>
+                                <Paragraph>
+                                    <Run Text="{Binding BeforeDetail,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}"/>
+                                </Paragraph>
+                            </FlowDocument>
+
+                        </RichTextBox>
+                    </DockPanel>
+                </Grid>
+            </Grid>
+            <Grid Grid.Column="2" >
+                <Grid.RowDefinitions>
+                    <RowDefinition Height="30"/>
+                    <RowDefinition/>
+                </Grid.RowDefinitions>
+                <DockPanel LastChildFill="False">
+                    <TextBlock Text="前置项明细:"   Style="{StaticResource textBlockStyle}" />
+                    <Button  Content="新增" Height="22" Width="60"  Margin="5,0"  Command="{Binding AddDetailCommand}" CommandParameter="Before" Style="{StaticResource NormalButtonStyle}" DockPanel.Dock="Right"  />
+                </DockPanel>
+                <DataGrid Grid.Row="1"  ColumnWidth="*" AutoGenerateColumns="False" HeadersVisibility="All" CanUserAddRows="False"  SelectionUnit="FullRow" SelectionMode="Single"   RowHeaderWidth="0" HorizontalScrollBarVisibility="Disabled"
+                  ColumnHeaderStyle="{StaticResource ColumnHeaderStyle}" x:Name="DeviceDataGrid" RowHeaderStyle="{StaticResource RowHeaderStyle}" RowStyle="{StaticResource DataGridRowtyle}"  AlternationCount="2"
+                    ItemsSource="{Binding BeforeConList}"  IsReadOnly="True" >
+                    <DataGrid.Columns >
+                        <DataGridTextColumn Header="序号" Width="40" Binding="{Binding Id}" CellStyle="{StaticResource MyDataGridCellStyle}" />
+                        <DataGridTextColumn Header="PLC地址" Binding="{Binding PlcAddress}" CellStyle="{StaticResource MyDataGridCellStyle}" />
+                        <DataGridTextColumn Header="PLC变量名" Binding="{Binding PlcItem}" CellStyle="{StaticResource MyDataGridCellStyle}"/>
+                        <DataGridTextColumn Header="判定值" Binding="{Binding PlcValue}" CellStyle="{StaticResource MyDataGridCellStyle}"/>
+                        <DataGridTemplateColumn Header="操作" Width="160"  CellStyle="{StaticResource MyDataGridCellStyle}">
+                            <DataGridTemplateColumn.CellTemplate>
+                                <DataTemplate>
+                                    <UniformGrid Columns="2">
+                                        <Button  Width="auto" Background="Transparent" HorizontalContentAlignment ="Left" Foreground="Black" Height="25" BorderThickness="0"
+                Command="{Binding DataContext.EditBeforeCommand, RelativeSource={RelativeSource Mode=FindAncestor,AncestorType=DataGrid}}" CommandParameter="{Binding Id}" Cursor="Hand" Margin="0,0,10,0" >
+
+                                            <StackPanel Orientation="Horizontal">
+                                                <TextBlock  Text="编辑" VerticalAlignment="Center" Foreground="Blue"/>
+                                            </StackPanel>
+                                        </Button>
+                                        <Button  Width="auto" Background="Transparent" HorizontalContentAlignment ="Left" Foreground="Black" Height="25" BorderThickness="0"
+                Command="{Binding DataContext.DeleteBeforeCommand, RelativeSource={RelativeSource Mode=FindAncestor,AncestorType=DataGrid}}" CommandParameter="{Binding Id}"   Cursor="Hand" >
+
+                                            <StackPanel Orientation="Horizontal">
+                                                <TextBlock  Text="删除" VerticalAlignment="Center" Foreground="Blue"/>
+                                            </StackPanel>
+                                        </Button>
+
+                                    </UniformGrid>
+                                </DataTemplate>
+                            </DataGridTemplateColumn.CellTemplate>
+                        </DataGridTemplateColumn>
+
+                    </DataGrid.Columns>
+
+                </DataGrid>
+
+            </Grid>
+        </Grid>
+        <Grid Grid.Row="2">
+            <Grid.ColumnDefinitions>
+                <ColumnDefinition Width="80"/>
+                <ColumnDefinition/>
+                <ColumnDefinition Width="1.3*"/>
+            </Grid.ColumnDefinitions>
+            <TextBlock Grid.Column="0" Text="输入项" Style="{StaticResource NormalTextBlockStyle}" TextAlignment="Center">
+            </TextBlock>
+            <Border Grid.Column="1"  BorderBrush="#CBCBCB" BorderThickness="1,0" />
+            <Grid Grid.Column="1">
+                <Grid.RowDefinitions>
+                    <RowDefinition/>
+                    <RowDefinition/>
+                    <RowDefinition Height="2*"/>
+                </Grid.RowDefinitions>
+                <Grid Grid.Row="0">
+                    <StackPanel Orientation="Horizontal" >
+                        <TextBlock Text="测试项类型:"  Style="{StaticResource textBlockStyle}"/>
+                        <ComboBox  Height="28" Width="150" ItemsSource="{Binding InJudgeKinds}" SelectedItem="{Binding SelectInJudge}" />
+                    </StackPanel>
+                </Grid>
+                <Grid Grid.Row="1"  >
+                    <StackPanel Orientation="Horizontal" >
+                        <TextBlock Text="明细判定逻辑:"  Style="{StaticResource textBlockStyle}"/>
+                        <ComboBox  Height="28" Width="150" ItemsSource="{Binding InJudgeLogicKinds}" SelectedItem="{Binding InSelectLogic}"/>
+                    </StackPanel>
+                </Grid>
+                <Grid Grid.Row="2">
+                    <DockPanel LastChildFill="True" >
+                        <TextBlock Text="输入项描述:"   Style="{StaticResource textBlockStyle}" />
+                        <RichTextBox  Margin="0,5,5,5" >
+                            <FlowDocument>
+                                <Paragraph>
+                                    <Run Text="{Binding InDetail,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}"/>
+                                </Paragraph>
+                            </FlowDocument>
+
+                        </RichTextBox>
+                    </DockPanel>
+                </Grid>
+            </Grid>
+            <Grid Grid.Column="2" >
+                <Grid.RowDefinitions>
+                    <RowDefinition Height="30"/>
+                    <RowDefinition/>
+                </Grid.RowDefinitions>
+                <DockPanel LastChildFill="False">
+                    <TextBlock Text="输入项明细:"   Style="{StaticResource textBlockStyle}" />
+                    <Button  Content="新增" Height="22" Width="60"  Margin="5,0"  Command="{Binding AddDetailCommand}" CommandParameter="In" Style="{StaticResource NormalButtonStyle}" DockPanel.Dock="Right"  />
+                </DockPanel>
+                <DataGrid Grid.Row="1"  ColumnWidth="*" AutoGenerateColumns="False" HeadersVisibility="All" CanUserAddRows="False"  SelectionUnit="FullRow" SelectionMode="Single"   RowHeaderWidth="0" HorizontalScrollBarVisibility="Disabled"
+       ColumnHeaderStyle="{StaticResource ColumnHeaderStyle}" RowHeaderStyle="{StaticResource RowHeaderStyle}" RowStyle="{StaticResource DataGridRowtyle}"  AlternationCount="2"
+         ItemsSource="{Binding InConList}"  IsReadOnly="True" >
+                    <DataGrid.Columns >
+                        <DataGridTextColumn Header="序号" Width="40" Binding="{Binding Id}" CellStyle="{StaticResource MyDataGridCellStyle}" />
+                        <DataGridTextColumn Header="PLC地址" Binding="{Binding PlcAddress}" CellStyle="{StaticResource MyDataGridCellStyle}" />
+                        <DataGridTextColumn Header="PLC变量名" Binding="{Binding PlcItem}" CellStyle="{StaticResource MyDataGridCellStyle}"/>
+                        <DataGridTextColumn Header="判定值" Binding="{Binding PlcValue}" CellStyle="{StaticResource MyDataGridCellStyle}"/>
+                        <DataGridTemplateColumn Header="操作" Width="160"  CellStyle="{StaticResource MyDataGridCellStyle}">
+                            <DataGridTemplateColumn.CellTemplate>
+                                <DataTemplate>
+                                    <UniformGrid Columns="2">
+                                        <Button  Width="auto" Background="Transparent" HorizontalContentAlignment ="Left" Foreground="Black" Height="25" BorderThickness="0"
+     Command="{Binding DataContext.EditBeforeCommand, RelativeSource={RelativeSource Mode=FindAncestor,AncestorType=DataGrid}}" CommandParameter="{Binding Id}" Cursor="Hand" Margin="0,0,10,0" >
+
+                                            <StackPanel Orientation="Horizontal">
+                                                <TextBlock  Text="编辑" VerticalAlignment="Center" Foreground="Blue"/>
+                                            </StackPanel>
+                                        </Button>
+                                        <Button  Width="auto" Background="Transparent" HorizontalContentAlignment ="Left" Foreground="Black" Height="25" BorderThickness="0"
+     Command="{Binding DataContext.DeleteBeforeCommand, RelativeSource={RelativeSource Mode=FindAncestor,AncestorType=DataGrid}}" CommandParameter="{Binding Id}"   Cursor="Hand" >
+
+                                            <StackPanel Orientation="Horizontal">
+                                                <TextBlock  Text="删除" VerticalAlignment="Center" Foreground="Blue"/>
+                                            </StackPanel>
+                                        </Button>
+
+                                    </UniformGrid>
+                                </DataTemplate>
+                            </DataGridTemplateColumn.CellTemplate>
+                        </DataGridTemplateColumn>
+
+                    </DataGrid.Columns>
+
+                </DataGrid>
+
+            </Grid>
+        </Grid>
+        <Border Grid.Row="2"  BorderBrush="#CBCBCB" BorderThickness="0,1,0,0" />
+        <Grid Grid.Row="3">
+            <Grid.ColumnDefinitions>
+                <ColumnDefinition Width="80"/>
+                <ColumnDefinition/>
+                <ColumnDefinition Width="1.3*"/>
+            </Grid.ColumnDefinitions>
+            <TextBlock Grid.Column="0" Text="结果项" Style="{StaticResource NormalTextBlockStyle}" TextAlignment="Center">
+            </TextBlock>
+            <Border Grid.Column="1"  BorderBrush="#CBCBCB" BorderThickness="1,0" />
+            <Grid Grid.Column="1">
+                <Grid.RowDefinitions>
+                    <RowDefinition/>
+                    <RowDefinition/>
+                    <RowDefinition Height="2*"/>
+                </Grid.RowDefinitions>
+                <Grid Grid.Row="0">
+                    <StackPanel Orientation="Horizontal" >
+                        <TextBlock Text="测试项类型:"  Style="{StaticResource textBlockStyle}"/>
+                        <ComboBox  Height="28" Width="150" ItemsSource="{Binding OutJudgeKinds}" SelectedItem="{Binding SelectOutJudge}" />
+                    </StackPanel>
+                </Grid>
+                <Grid Grid.Row="1"  >
+                    <StackPanel Orientation="Horizontal" >
+                        <TextBlock Text="明细判定逻辑:"  Style="{StaticResource textBlockStyle}"/>
+                        <ComboBox  Height="28" Width="150" ItemsSource="{Binding OutJudgeLogicKinds}" SelectedItem="{Binding OutSelectLogic}"/>
+                    </StackPanel>
+                </Grid>
+                <Grid Grid.Row="2">
+                    <DockPanel LastChildFill="True" >
+                        <TextBlock Text="结果项描述:"   Style="{StaticResource textBlockStyle}" />
+                        <RichTextBox  Margin="0,5,5,5" >
+                            <FlowDocument>
+                                <Paragraph>
+                                    <Run Text="{Binding OutDetail,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}"/>
+                                </Paragraph>
+                            </FlowDocument>
+
+                        </RichTextBox>
+                    </DockPanel>
+                </Grid>
+            </Grid>
+            <Grid Grid.Column="2" >
+                <Grid.RowDefinitions>
+                    <RowDefinition Height="30"/>
+                    <RowDefinition/>
+                </Grid.RowDefinitions>
+                <DockPanel LastChildFill="False">
+                    <TextBlock Text="前置项明细:"   Style="{StaticResource textBlockStyle}" />
+                    <Button  Content="新增" Height="22" Width="60"  Margin="5,0"  Command="{Binding AddDetailCommand}" CommandParameter="Out" Style="{StaticResource NormalButtonStyle}" DockPanel.Dock="Right"  />
+                </DockPanel>
+                <DataGrid Grid.Row="1"  ColumnWidth="*" AutoGenerateColumns="False" HeadersVisibility="All" CanUserAddRows="False"  SelectionUnit="FullRow" SelectionMode="Single"   RowHeaderWidth="0" HorizontalScrollBarVisibility="Disabled"
+       ColumnHeaderStyle="{StaticResource ColumnHeaderStyle}"  RowHeaderStyle="{StaticResource RowHeaderStyle}" RowStyle="{StaticResource DataGridRowtyle}"  AlternationCount="2"
+         ItemsSource="{Binding OutConList}"  IsReadOnly="True" >
+                    <DataGrid.Columns >
+                        <DataGridTextColumn Header="序号" Width="40" Binding="{Binding Id}" CellStyle="{StaticResource MyDataGridCellStyle}" />
+                        <DataGridTextColumn Header="PLC地址" Binding="{Binding PlcAddress}" CellStyle="{StaticResource MyDataGridCellStyle}" />
+                        <DataGridTextColumn Header="PLC变量名" Binding="{Binding PlcItem}" CellStyle="{StaticResource MyDataGridCellStyle}"/>
+                        <DataGridTextColumn Header="判定值" Binding="{Binding PlcValue}" CellStyle="{StaticResource MyDataGridCellStyle}"/>
+                        <DataGridTemplateColumn Header="操作" Width="160"  CellStyle="{StaticResource MyDataGridCellStyle}">
+                            <DataGridTemplateColumn.CellTemplate>
+                                <DataTemplate>
+                                    <UniformGrid Columns="2">
+                                        <Button  Width="auto" Background="Transparent" HorizontalContentAlignment ="Left" Foreground="Black" Height="25" BorderThickness="0"
+     Command="{Binding DataContext.EditBeforeCommand, RelativeSource={RelativeSource Mode=FindAncestor,AncestorType=DataGrid}}" CommandParameter="{Binding Id}" Cursor="Hand" Margin="0,0,10,0" >
+
+                                            <StackPanel Orientation="Horizontal">
+                                                <TextBlock  Text="编辑" VerticalAlignment="Center" Foreground="Blue"/>
+                                            </StackPanel>
+                                        </Button>
+                                        <Button  Width="auto" Background="Transparent" HorizontalContentAlignment ="Left" Foreground="Black" Height="25" BorderThickness="0"
+     Command="{Binding DataContext.DeleteBeforeCommand, RelativeSource={RelativeSource Mode=FindAncestor,AncestorType=DataGrid}}" CommandParameter="{Binding Id}"   Cursor="Hand" >
+
+                                            <StackPanel Orientation="Horizontal">
+                                                <TextBlock  Text="删除" VerticalAlignment="Center" Foreground="Blue"/>
+                                            </StackPanel>
+                                        </Button>
+
+                                    </UniformGrid>
+                                </DataTemplate>
+                            </DataGridTemplateColumn.CellTemplate>
+                        </DataGridTemplateColumn>
+
+                    </DataGrid.Columns>
+
+                </DataGrid>
+
+            </Grid>
+        </Grid>
+        <Border Grid.Row="3"  BorderBrush="#CBCBCB" BorderThickness="0,1,0,0" />
+    </Grid>
+</UserControl>

+ 28 - 0
BlankApp1/BlankApp1/Views/BasicConfigView/EditSchView.xaml.cs

@@ -0,0 +1,28 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows;
+using System.Windows.Controls;
+using System.Windows.Data;
+using System.Windows.Documents;
+using System.Windows.Input;
+using System.Windows.Media;
+using System.Windows.Media.Imaging;
+using System.Windows.Navigation;
+using System.Windows.Shapes;
+
+namespace PLCTool.Views.BasicConfigView
+{
+    /// <summary>
+    /// EditSchView.xaml 的交互逻辑
+    /// </summary>
+    public partial class EditSchView : UserControl
+    {
+        public EditSchView()
+        {
+            InitializeComponent();
+        }
+    }
+}

+ 27 - 8
BlankApp1/Model/Dto/BasPlcItemConfigDto.cs

@@ -1,4 +1,5 @@
-using System;
+using Model.Entities;
+using System;
 using System.Collections.Generic;
 using System.Linq;
 using System.Text;
@@ -6,7 +7,7 @@ using System.Threading.Tasks;
 
 namespace Model.Dto
 {
-    public  class BasPlcItemConfigDto
+    public  class BasPlcItemConfigDto:BaseDto
     {
         public long Id { get; set; }
 
@@ -22,22 +23,40 @@ namespace Model.Dto
         /// Default:
         /// Nullable:True
         /// </summary>           
-        public string PlcItem { get; set; }
-
+        private  string plcItem { get; set; }
+        public string PlcItem
+        {
+            get { return plcItem; }
+            set { plcItem = value; OnPropertyChanged(); }
+        }
         /// <summary>
         /// Desc:
         /// Default:
         /// Nullable:True
         /// </summary>           
-        public string PlcAddress { get; set; }
+        private string plcAddress { get; set; }
+        public string PlcAddress
+        {
+            get { return plcAddress; }
+            set { plcAddress = value; OnPropertyChanged(); }
+        }
 
-        public string PlcValue { get; set; }
+        private  string plcValue { get; set; }
+        public string PlcValue
+        {
+            get { return plcValue; }
+            set { plcValue = value; OnPropertyChanged(); }
+        }
         /// <summary>
         /// Desc:
         /// Default:
         /// Nullable:True
         /// </summary>           
-        public string Remark { get; set; }
-
+        private  string remark { get; set; }
+        public string Remark
+        {
+            get { return remark; }
+            set { remark = value; OnPropertyChanged(); }
+        }
     }
 }