Browse Source

添加测试项

ltwork 1 year ago
parent
commit
2ed8c8fd1c

+ 1 - 1
BlankApp1/BlankApp1/App.xaml.cs

@@ -87,7 +87,7 @@ namespace BlankApp1
             containerRegistry.RegisterDialog<AddOrEditDeviceView, AddOrEditDeviceViewModel>();
             containerRegistry.RegisterDialog<EditItemDetailView, EditItemDetailViewModel>();
             containerRegistry.RegisterDialog<ReadSchView, ReadSchViewModel>();
-
+            containerRegistry.RegisterDialog<AddItemDetailView, AddItemDetailViewModel>();
         }
 
         private IMapper GetMapper(IContainerProvider container)

+ 851 - 0
BlankApp1/BlankApp1/ViewModels/BasicConfigViewModel/AddItemDetailViewModel.cs

@@ -0,0 +1,851 @@
+using AutoMapper;
+using BizService;
+using BlankApp1.Events;
+using DryIoc;
+using Microsoft.Extensions.Logging;
+using Model.Dto;
+using Model.Entities;
+using Newtonsoft.Json;
+using PLCTool.Common;
+using PLCTool.Models;
+using Prism.Commands;
+using Prism.Events;
+using Prism.Mvvm;
+using Prism.Regions;
+using Prism.Services.Dialogs;
+using System;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows;
+
+namespace PLCTool.ViewModels.BasicConfigViewModel
+{
+   
+
+    public class AddItemDetailViewModel : BindableBase , IDialogAware
+    {
+        private readonly IDialogService _dialog;
+        private readonly IEventAggregator _aggregator;
+        private readonly IRegionManager _regionManager;
+        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 AddItemDetailViewModel(IDialogService dialog, IEventAggregator aggregator, IRegionManager regionManager, IOptionConfigService optionConfigService, IBasicPlcTestSchemeService basicPlcTestSchemeService, IBasicPlcTestSchemeDtlService basicPlcTestSchemeDtlService, IBasicDeviceKindService iBasicDeviceKindService, IMapper mapper, ILogger logger)
+        {
+            _dialog = dialog;
+            _aggregator = aggregator;
+            _regionManager = regionManager;
+            _optionConfigService = optionConfigService;
+            _basicPlcTestSchemeService = basicPlcTestSchemeService;
+            _basicPlcTestSchemeDtlService = basicPlcTestSchemeDtlService;
+            _iBasicDeviceKindService = iBasicDeviceKindService;
+            _mapper = mapper;
+            _logger = logger;
+            CloseCommand = new DelegateCommand(Close);
+            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);
+            DeleteInCommand = new DelegateCommand<object>(DeleteIn);
+            DeleteOutCommand = new DelegateCommand<object>(DeleteOut);
+            OnLoadCommand = new DelegateCommand<object>(OnLoad);
+            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<string>("Key");
+            ///值不为空,表示修改,为空表示新增
+            if (getMsg != null)
+            {
+                foreach (var item in getMsg)
+                {
+
+                    DeviceKindName = item;
+
+                }
+            }
+
+
+            var getMsg2 = parameters.GetValues<string>("Key2");
+     
+            if (getMsg != null)
+            {
+                foreach (var item in getMsg2)
+                {
+
+                    ScheduleName = item;
+
+                }
+            }
+            
+        }
+        #endregion
+
+
+    
+
+
+
+        #region 私有方法
+       
+
+        private void OnLoad(object obj)
+        {
+            DeviceKindName = "---";
+            ScheduleName = string.Empty;
+            
+            //清空测试项的内容
+            CleanContent();
+        }
+        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.PlcAddType = returnValue.PlcAddType;
+                            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>
+        private void GetConfigOption()
+        {
+            //获取设备类型
+            var kinds = _iBasicDeviceKindService.FindAllDeviceKind();
+            DeviceKindNameList.Add("---");
+            foreach (var kind in kinds)
+            {
+                DeviceKindNameList.Add(kind);
+            }
+
+            //
+            var configList = _optionConfigService.QueryList();
+            _optionConfigs = _mapper.Map<List<OptionConfig>, List<OptionConfigDto>>(configList);
+            var tests = _optionConfigs.FindAll(x => x.TypeID == 1);
+            TestKinds.Add("---");
+            foreach (var test in tests)
+            {
+                TestKinds.Add(test.ContentOption);
+            }
+
+            //测试项类型
+            BeforeJudgeKinds.Add("---");
+            InJudgeKinds.Add("---");
+            OutJudgeKinds.Add("---");
+            var judges = _optionConfigs.FindAll(x => x.TypeID == 2);
+            foreach (var judge in judges)
+            {
+                BeforeJudgeKinds.Add(judge.ContentOption);
+                InJudgeKinds.Add(judge.ContentOption);
+                OutJudgeKinds.Add(judge.ContentOption);
+            }
+
+            //判定逻辑
+            JudgeLogicKinds.Add("---");
+            InJudgeLogicKinds.Add("---");
+            OutJudgeLogicKinds.Add("---");
+            var logics = _optionConfigs.FindAll(x => x.TypeID == 3);
+            foreach (var logic in logics)
+            {
+                JudgeLogicKinds.Add(logic.ContentOption);
+                InJudgeLogicKinds.Add(logic.ContentOption);
+                OutJudgeLogicKinds.Add(logic.ContentOption);
+
+            }
+
+        }
+
+
+        /// <summary>
+        /// 新增
+        /// </summary>
+        /// <param name="str"></param>
+        private void AddPLCDetail(string str)
+        {
+            DialogParameters parm = new DialogParameters();
+            parm.Add("Key", "");
+            //弹出详情对话框
+            _dialog.ShowDialog("AddDetailView", parm, async callback =>
+            {
+                if (callback.Result == ButtonResult.OK)
+                {
+                    BasPlcItemConfigDto returnValue = callback.Parameters.GetValue<BasPlcItemConfigDto>("ReturnValue");
+                    switch (str)
+                    {
+                        case "Before":
+                            returnValue.Id = BeforeConList.Count + 1;
+                            BeforeConList.Add(returnValue); break;
+                        case "In":
+                            returnValue.Id = InConList.Count + 1;
+                            InConList.Add(returnValue); break;
+                        case "Out":
+                            returnValue.Id = OutConList.Count + 1;
+                            OutConList.Add(returnValue); break;
+                    }
+                }
+
+            });
+        }
+
+        /// <summary>
+        /// 初始化
+        /// </summary>
+
+        /// <summary>
+        /// 关闭按钮
+        /// </summary>
+        private void Close()
+        {
+            //RequestClose?.Invoke(new NavigationResult(new NavigationContext(),true);
+        }
+        /// <summary>
+        /// 确认
+        /// </summary>
+        /// <param name="obj"></param>
+        private void Sure(string obj)
+        {
+            if (string.IsNullOrEmpty(ScheduleName))
+            {
+                MessageBox.Show("请填写测试方案名称!", "提示", MessageBoxButton.OK, MessageBoxImage.Warning);
+                return;
+            }
+            if (string.IsNullOrEmpty(DeviceKindName))
+            {
+                MessageBox.Show("请填写设备类型名称!", "提示", MessageBoxButton.OK, MessageBoxImage.Warning);
+                return;
+            }
+            if (string.IsNullOrEmpty(SelectTest))
+            {
+                MessageBox.Show("请选择测试项类型!", "提示", MessageBoxButton.OK, MessageBoxImage.Warning);
+                return;
+            }
+            if (string.IsNullOrEmpty(TestName))
+            {
+                MessageBox.Show("请填写测试项名称!", "提示", MessageBoxButton.OK, MessageBoxImage.Warning);
+                return;
+            }
+            if (string.IsNullOrEmpty(BeforeSelectJudge))
+            {
+                MessageBox.Show("请填写前置项测试项测试类型!", "提示", MessageBoxButton.OK, MessageBoxImage.Warning);
+                return;
+            }
+            //前置项
+            if (string.IsNullOrEmpty(BeforeSelectJudge))
+            {
+                MessageBox.Show("请填写前置项测试项测试类型!", "提示", MessageBoxButton.OK, MessageBoxImage.Warning);
+                return;
+            }
+            if (string.IsNullOrEmpty(SelectLogic))
+            {
+                MessageBox.Show("请填写前置项判定逻辑!", "提示", MessageBoxButton.OK, MessageBoxImage.Warning);
+                return;
+            }
+            //输入项
+            if (string.IsNullOrEmpty(SelectInJudge))
+            {
+                MessageBox.Show("请填写输入项测试项测试类型!", "提示", MessageBoxButton.OK, MessageBoxImage.Warning);
+                return;
+            }
+            if (string.IsNullOrEmpty(InSelectLogic))
+            {
+                MessageBox.Show("请填写输入项判定逻辑!", "提示", MessageBoxButton.OK, MessageBoxImage.Warning);
+                return;
+            }
+            //输出项
+            if (string.IsNullOrEmpty(SelectOutJudge))
+            {
+                MessageBox.Show("请填写结果项测试项测试类型!", "提示", MessageBoxButton.OK, MessageBoxImage.Warning);
+                return;
+            }
+            if (string.IsNullOrEmpty(OutSelectLogic))
+            {
+                MessageBox.Show("请填写结果项判定逻辑!", "提示", MessageBoxButton.OK, MessageBoxImage.Warning);
+                return;
+            }
+            try
+            {
+               
+                    var finsSche = _basicPlcTestSchemeService.FindByName(ScheduleName);
+                    //测试方案中已有这个名称
+                    if (finsSche != null)
+                    {
+                        long schID = finsSche.scheme_id;
+                        //在测试方案明细表中查找是否有这个测试方案和测试项
+                        var schDtl = _basicPlcTestSchemeDtlService.FindSchDtlIdBySchIdAndItem(schID, TestName);
+                        //在不为空,说明有这个测试方案和测试项了
+                        if (schDtl != null)
+                        {
+                            MessageBoxResult boxResult = MessageBox.Show("此测试方案名称已存在此测试项,请填写其他测试项!", "提示", MessageBoxButton.OK, MessageBoxImage.Warning);
+                            return;
+                        }
+
+                    }
+                    else
+                    {
+                        //增加测试方案到数据库
+                        BasicPlcTestSchemeDto schDto = new BasicPlcTestSchemeDto();
+                        schDto.SchemeName = ScheduleName;
+                        schDto.DeviceKindName = DeviceKindName;
+                        schDto.CreateBy = Appsession.UserName;
+                        schDto.CreateTime = DateTime.Now;
+                        schDto.UpdateTime = DateTime.Now;
+                        schDto.UpdateBy = Appsession.UserName;
+                        bas_plc_test_scheme schEntity = _mapper.Map<BasicPlcTestSchemeDto, bas_plc_test_scheme>(schDto);
+                        _basicPlcTestSchemeService.Add(schEntity);
+
+
+                    }
+
+               
+
+                //查找测试方案id
+                var finsScheHave = _basicPlcTestSchemeService.FindByName(ScheduleName);
+                if (finsScheHave != null)
+                {
+                    long id = finsScheHave.scheme_id;
+                    //增加或修改方案明细表
+                    AddOrEditDetailsToDb(id);
+
+                }
+        
+                RequestClose?.Invoke(new DialogResult(ButtonResult.OK));
+            }
+            catch (Exception ex)
+            {
+                _logger.LogError(ex.ToString());
+            }
+
+
+
+        }
+        /// <summary>
+        /// 清空测试项内容内容
+        /// </summary>
+        private void CleanContent()
+        {
+            //清空已填写的内容
+            TestName = string.Empty;
+            SelectTest = "---";
+            BeforeSelectJudge = "---";
+            SelectLogic = "---";
+            BeforeDetail = string.Empty;
+            //输入项
+            SelectInJudge = "---";
+            InSelectLogic = "---";
+            InDetail = string.Empty;
+            //输出项
+            SelectOutJudge = "---";
+            OutSelectLogic = "---";
+            OutDetail = string.Empty;
+
+            BeforeConList = new ObservableCollection<BasPlcItemConfigDto>();
+            InConList = new ObservableCollection<BasPlcItemConfigDto>();
+            OutConList = new ObservableCollection<BasPlcItemConfigDto>();
+
+        }
+        /// <summary>
+        /// 方案明细添加到数据库
+        /// </summary>
+        private void AddOrEditDetailsToDb(long scheduleId)
+        {
+            //前置项json转化
+            string prefixJsonStr = ModelToJsonToStr(BeforeSelectJudge, SelectLogic, BeforeDetail, BeforeConList);
+            //输入项json转化
+            string inJsonStr = ModelToJsonToStr(SelectInJudge, InSelectLogic, InDetail, InConList);
+            //输出项json转化
+            string outJsonStr = ModelToJsonToStr(SelectOutJudge, OutSelectLogic, OutDetail, OutConList);
+            //添加达到测试主表
+            //增加测试方案
+            BasicPlcTestSchemeDtlDto schDtlDto = new BasicPlcTestSchemeDtlDto();
+            schDtlDto.SchemeId = scheduleId;
+            schDtlDto.ItemName = TestName;
+
+            schDtlDto.ItemType = SelectTest;
+            schDtlDto.Precondition = prefixJsonStr;
+            schDtlDto.PreconditionDescribe = BeforeDetail;
+            schDtlDto.Action = inJsonStr;
+            schDtlDto.ActionDescribe = InDetail;
+            schDtlDto.JudgementResult = outJsonStr;
+            schDtlDto.JudgementResultDescribe = OutDetail;
+            schDtlDto.CreateBy = Appsession.UserName;
+            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);
+            schDtlEntity.item_type = StrToItemType(schDtlDto.ItemType);
+            try
+            {
+                
+                    bool isAddSucc = _basicPlcTestSchemeDtlService.Add(schDtlEntity);
+                    if (isAddSucc)
+                    {
+                        _logger.LogInformation($"新增方案成功。方案名{ScheduleName},测试项{TestName}");
+                        MessageBoxResult boxResult = MessageBox.Show("新增测试项成功!", "提示", MessageBoxButton.OK, MessageBoxImage.Information);
+                    }
+                    else
+                    {
+                        MessageBoxResult boxResult = MessageBox.Show("更新失败", "提示", MessageBoxButton.OK, MessageBoxImage.Warning);
+                        return;
+                    }
+                
+               
+            }
+            catch (Exception ex)
+            {
+                _logger.LogError(ex.ToString());
+            }
+
+
+
+        }
+        /// <summary>
+        /// 转化
+        /// </summary>
+        /// <param name="typeStr"></param>
+        /// <returns></returns>
+        private int StrToItemType(string typeStr)
+        {
+            int itemInt = 0;
+            switch (typeStr)
+            {
+                case "前置项":
+                    itemInt = 0;
+                    break;
+                case "PLC点位测试项":
+                    itemInt = 1;
+                    break;
+                case "Robot动作测试":
+                    itemInt = 2;
+                    break;
+            }
+            return itemInt;
+        }
+        /// <summary>
+        /// mode转json
+        /// </summary>
+        /// <param name="itemType"></param>
+        /// <param name="itemLogical"></param>
+        /// <param name="description"></param>
+        /// <param name="conList"></param>
+        /// <returns></returns>
+
+        private string ModelToJsonToStr(string itemType, string itemLogical, string description, ObservableCollection<BasPlcItemConfigDto> conList)
+        {
+            JsonModel prefixJsonModel = new JsonModel();
+            prefixJsonModel.ItemType = itemType;
+            prefixJsonModel.ItemLogical = itemLogical;
+            prefixJsonModel.Description = description;
+            prefixJsonModel.DetailInfo = new List<DetailPLC>();
+            foreach (var item in conList)
+            {
+                DetailPLC plcItem = new DetailPLC();
+                plcItem.Id = item.Id;
+                plcItem.PlcItem = item.PlcItem;
+                plcItem.PlcAddress = item.PlcAddress;
+                plcItem.PlcAddType = item.PlcAddType;
+                plcItem.PlcValue = item.PlcValue;
+                plcItem.Remark = item.Remark;
+                prefixJsonModel.DetailInfo.Add(plcItem);
+
+            }
+            string prefixJsonStr = JsonConvert.SerializeObject(prefixJsonModel);
+            return prefixJsonStr;
+        }
+
+   
+        /// <summary>
+        /// 重置
+        /// </summary>
+        /// <param name="obj"></param>
+        private void ResetMethod(string obj)
+        {
+            ScheduleName = string.Empty;
+            DeviceKindName = string.Empty;
+            TestName = string.Empty;
+        }
+
+        public void OnNavigatedTo(NavigationContext navigationContext)
+        {
+            ScheduleName = string.Empty;
+        }
+
+        public bool IsNavigationTarget(NavigationContext navigationContext)
+        {
+            return true;
+        }
+
+        public void OnNavigatedFrom(NavigationContext navigationContext)
+        {
+
+        }
+
+
+        #endregion
+
+
+
+        #region 命令绑定
+        public DelegateCommand CloseCommand { set; get; }
+        public DelegateCommand<string> SureCommand { set; get; }
+        public DelegateCommand<string> ResetCommand { set; get; }
+        public DelegateCommand<string> OpenExistCommand { set; get; }
+        
+        /// <summary>
+        /// 新增对话框按钮
+        /// </summary>
+        public DelegateCommand<string> AddDetailCommand { set; get; }
+        /// <summary>
+        /// 表格删除
+        /// </summary>
+        public DelegateCommand<Object> DeleteBeforeCommand { set; get; }
+        /// <summary>
+        /// 表格编辑按钮
+        /// </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; }
+
+        public DelegateCommand<Object> OnLoadCommand { set; get; }
+       
+      
+    
+    
+       
+        public DelegateCommand<object> EditDetailCommand { set; get; }
+     
+ 
+
+        #endregion
+        #region 变量绑定
+        /// <summary>
+        /// 测试方案编码
+        /// </summary>
+        private string scheduleName;
+        public string ScheduleName
+        {
+            get { return scheduleName; }
+            set { scheduleName = value; RaisePropertyChanged(); }
+        }
+        /// <summary>
+        /// 设备类型
+        /// </summary>
+        private string deviceKindName;
+        public string DeviceKindName
+        {
+            get { return deviceKindName; }
+            set { deviceKindName = value; RaisePropertyChanged(); }
+        }
+        /// <summary>
+        /// 测试项名称
+        /// </summary>
+        private string testName;
+        public string TestName
+        {
+            get { return testName; }
+            set { testName = value; RaisePropertyChanged(); }
+        }
+        /// <summary>
+        /// 测试项类型
+        /// </summary>
+        private ObservableCollection<string> testKinds = new ObservableCollection<string>();
+        public ObservableCollection<string> TestKinds
+        {
+            get { return testKinds; }
+            set { testKinds = value; RaisePropertyChanged(); }
+        }
+        /// <summary>
+        /// 
+        /// </summary>
+        private string selectTest;
+        public string SelectTest
+        {
+            get { return selectTest; }
+            set { selectTest = value; RaisePropertyChanged(); }
+        }
+        /// <summary>
+        /// 判定类型(前置项)
+        /// </summary>
+        private ObservableCollection<string> beforeJudgeKinds = new ObservableCollection<string>();
+        public ObservableCollection<string> BeforeJudgeKinds
+        {
+            get { return beforeJudgeKinds; }
+            set { beforeJudgeKinds = value; RaisePropertyChanged(); }
+        }
+        private string beforeSelectJudge;
+        public string BeforeSelectJudge
+        {
+            get { return beforeSelectJudge; }
+            set { beforeSelectJudge = value; RaisePropertyChanged(); }
+        }
+        /// <summary>
+        /// 逻辑判断
+        /// </summary>
+        private ObservableCollection<string> judgeLogicKinds = new ObservableCollection<string>();
+        public ObservableCollection<string> JudgeLogicKinds
+        {
+            get { return judgeLogicKinds; }
+            set { judgeLogicKinds = value; RaisePropertyChanged(); }
+        }
+        private string selectLogic;
+        public string SelectLogic
+        {
+            get { return selectLogic; }
+            set { selectLogic = value; RaisePropertyChanged(); }
+        }
+        private string beforeDetail;
+        public string BeforeDetail
+        {
+            get { return beforeDetail; }
+            set { beforeDetail = value; RaisePropertyChanged(); }
+        }
+
+        private ObservableCollection<BasPlcItemConfigDto> beforeConList;
+        public ObservableCollection<BasPlcItemConfigDto> BeforeConList
+        {
+            get { return beforeConList; }
+            set { beforeConList = value; RaisePropertyChanged(); }
+        }
+
+        /// <summary>
+        /// 判定类型(输入项)
+        /// </summary>
+        private ObservableCollection<string> inJudgeKinds = new ObservableCollection<string>();
+        public ObservableCollection<string> InJudgeKinds
+        {
+            get { return inJudgeKinds; }
+            set { inJudgeKinds = value; RaisePropertyChanged(); }
+        }
+        private string selectInJudge;
+        public string SelectInJudge
+        {
+            get { return selectInJudge; }
+            set { selectInJudge = value; RaisePropertyChanged(); }
+        }
+        /// <summary>
+        /// 逻辑判断
+        /// </summary>
+        private ObservableCollection<string> inJudgeLogicKinds = new ObservableCollection<string>();
+        public ObservableCollection<string> InJudgeLogicKinds
+        {
+            get { return inJudgeLogicKinds; }
+            set { inJudgeLogicKinds = value; RaisePropertyChanged(); }
+        }
+        private string inSelectLogic;
+        public string InSelectLogic
+        {
+            get { return inSelectLogic; }
+            set { inSelectLogic = value; RaisePropertyChanged(); }
+        }
+        private string inDetail;
+        public string InDetail
+        {
+            get { return inDetail; }
+            set { inDetail = value; RaisePropertyChanged(); }
+        }
+
+        private ObservableCollection<BasPlcItemConfigDto> inConList;
+        public ObservableCollection<BasPlcItemConfigDto> InConList
+        {
+            get { return inConList; }
+            set { inConList = value; RaisePropertyChanged(); }
+        }
+        /// <summary>
+        /// 判定类型(结果项)
+        /// </summary>
+        private ObservableCollection<string> outJudgeKinds = new ObservableCollection<string>();
+        public ObservableCollection<string> OutJudgeKinds
+        {
+            get { return outJudgeKinds; }
+            set { outJudgeKinds = value; RaisePropertyChanged(); }
+        }
+        private string selectOutJudge;
+        public string SelectOutJudge
+        {
+            get { return selectOutJudge; }
+            set { selectOutJudge = value; RaisePropertyChanged(); }
+        }
+
+
+        /// <summary>
+        /// 逻辑判断
+        /// </summary>
+        private ObservableCollection<string> outJudgeLogicKinds = new ObservableCollection<string>();
+        public ObservableCollection<string> OutJudgeLogicKinds
+        {
+            get { return outJudgeLogicKinds; }
+            set { outJudgeLogicKinds = value; RaisePropertyChanged(); }
+        }
+        private string outSelectLogic;
+        public string OutSelectLogic
+        {
+            get { return outSelectLogic; }
+            set { outSelectLogic = value; RaisePropertyChanged(); }
+        }
+
+        private string outDetail;
+        public string OutDetail
+        {
+            get { return outDetail; }
+            set { outDetail = value; RaisePropertyChanged(); }
+        }
+        private ObservableCollection<BasPlcItemConfigDto> outConList;
+        public ObservableCollection<BasPlcItemConfigDto> OutConList
+        {
+            get { return outConList; }
+            set { outConList = value; RaisePropertyChanged(); }
+        }
+
+        /// <summary>
+        /// 设备类型
+        /// </summary>
+        private ObservableCollection<string> deviceKindNameList = new ObservableCollection<string>();
+        public ObservableCollection<string> DeviceKindNameList
+        {
+            get { return deviceKindNameList; }
+            set { deviceKindNameList = value; RaisePropertyChanged(); }
+        }
+
+     
+
+        #endregion
+
+    }
+}

+ 75 - 223
BlankApp1/BlankApp1/ViewModels/BasicConfigViewModel/AddSchViewModel.cs

@@ -67,15 +67,14 @@ namespace PLCTool.ViewModels.BasicConfigViewModel
             DownCommand = new DelegateCommand<object>(DataDown);
             SaveAllSchCommand = new DelegateCommand<object>(SaveAllSch);
            // EditDetailCommand = new DelegateCommand<object>(DataGridSelectChange);
-            DgSelectChangeCommand = new DelegateCommand<object>(DataGridSelectChange);
+         
             CancelCommand= new DelegateCommand<object>(Cancel);
             DetailCommand = new DelegateCommand<object>(CheckDetail);
             DeleteCommand = new DelegateCommand<object>(Delete);
             BeforeConList = new ObservableCollection<BasPlcItemConfigDto>();
             InConList = new ObservableCollection<BasPlcItemConfigDto>();
             OutConList = new ObservableCollection<BasPlcItemConfigDto>();
-            //获取设备类型
-            DeviceKindNameList = _iBasicDeviceKindService.FindAllDeviceKind();
+            
             GetConfigOption();
         }
 
@@ -125,115 +124,7 @@ namespace PLCTool.ViewModels.BasicConfigViewModel
         {
             _regionManager.Regions["ContentRegion"].RequestNavigate("BaseConfigView");
         }
-        /// <summary>
-        ///  测试方案明细主键ID 查找测试方案id 及方案名
-        /// </summary>
-        /// <param name="schDtlId"></param>
-        private void GetDetaiMsg(int schDtlId)
-        {
-            //根据 测试方案明细主键ID 查找测试方案id 及方案名和设备名
-            var findEntity = _basicPlcTestSchemeDtlService.Find(schDtlId);
-            var findresult = _mapper.Map<bas_plc_test_scheme_dtl, BasicPlcTestSchemeDtlDto>(findEntity);
-            if (findresult != null)
-            {
-                //根据方案id 在方案表中查找方案名 设备名
-                int schID = Convert.ToInt32(findresult.SchemeId);
-                //测试方案
-                bas_Plc_Test_Scheme = _basicPlcTestSchemeService.Find(schID);
-                if (bas_Plc_Test_Scheme != null)
-                {
-                    ScheduleName = bas_Plc_Test_Scheme.scheme_name;
-                    DeviceKindName = bas_Plc_Test_Scheme.devicekind_name;
-
-                }
-                TestName = findresult.ItemName;
-                SelectTest = findresult.ItemType;
-                //前置项解析
-                string preconStr = findresult.Precondition.ToString();
-                if (!string.IsNullOrEmpty(preconStr))
-                {
-                    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.Id = detail.Id;
-                        basPlcItemConfigDto.PlcItem = detail.PlcItem;
-                        basPlcItemConfigDto.PlcAddress = detail.PlcAddress;
-                        basPlcItemConfigDto.PlcAddType = detail.PlcAddType;
-                        basPlcItemConfigDto.PlcValue = detail.PlcValue;
-                        basPlcItemConfigDto.Remark = detail.Remark;
-                        BeforeConList.Add(basPlcItemConfigDto);
-                    }
-                }
-
-                //输入项解析
-                string inStr = findresult.Action.ToString();
-                if (!string.IsNullOrEmpty(inStr))
-                {
-                    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.Id = detail.Id;
-                        basPlcItemConfigDto.PlcItem = detail.PlcItem;
-                        basPlcItemConfigDto.PlcAddress = detail.PlcAddress;
-                        basPlcItemConfigDto.PlcAddType = detail.PlcAddType;
-                        basPlcItemConfigDto.PlcValue = detail.PlcValue;
-                        basPlcItemConfigDto.Remark = detail.Remark;
-                        InConList.Add(basPlcItemConfigDto);
-                    }
-                }
-
-                //输出项解析
-                string outStr = findresult.JudgementResult.ToString();
-                if (!string.IsNullOrEmpty(outStr))
-                {
-                    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.Id = detail.Id;
-                        basPlcItemConfigDto.PlcItem = detail.PlcItem;
-                        basPlcItemConfigDto.PlcAddress = detail.PlcAddress;
-                        basPlcItemConfigDto.PlcAddType = detail.PlcAddType;
-                        basPlcItemConfigDto.PlcValue = detail.PlcValue;
-                        basPlcItemConfigDto.Remark = detail.Remark;
-                        OutConList.Add(basPlcItemConfigDto);
-                    }
-                }
-
-            }
-        }
-        /// <summary>
-        /// 选中datadagridView某一行
-        /// </summary>
-        /// <param name="obj"></param>
-        private void DataGridSelectChange(object obj)
-        {
-            SelectItemModel selectItemModel = (SelectItemModel)obj;
-            if(selectItemModel!=null)
-            {
-                int schDtlId = Convert.ToInt32(selectItemModel.SchDtlId);
-                schDtlMainId = schDtlId;//全局变量赋值,测试方案明细id
-                GetDetaiMsg(schDtlId);
-
-            }
-            
-        }
-       
-
+ 
         /// <summary>
         /// 保存所有测试项
         /// </summary>
@@ -242,7 +133,11 @@ namespace PLCTool.ViewModels.BasicConfigViewModel
         private void SaveAllSch(object obj)
         {
             //先保存一下当前测试项
-            Sure(string.Empty);
+            if (!string.IsNullOrEmpty(TestName))
+            {
+                MessageBox.Show("请先保存当前测试项!", "提示", MessageBoxButton.OK, MessageBoxImage.Warning);
+                return;
+            }
             //可能调整了测试项的顺序,所以先删除所有测试项
             var findSche = _basicPlcTestSchemeService.FindByName(ScheduleName);
             if (findSche != null)
@@ -414,7 +309,11 @@ namespace PLCTool.ViewModels.BasicConfigViewModel
 
         private void OnLoad(object obj)
         {
-            
+            DeviceKindName = "---";
+            ScheduleName = string.Empty;
+            SchProjectList = new ObservableCollection<SelectItemModel>();
+            //清空测试项的内容
+            CleanContent();
         }
         private void OpenEditDialog(Object obj, ObservableCollection<BasPlcItemConfigDto> conList)
         {
@@ -523,16 +422,28 @@ namespace PLCTool.ViewModels.BasicConfigViewModel
         /// </summary>
         private void GetConfigOption()
         {
+            //获取设备类型
+            var kinds = _iBasicDeviceKindService.FindAllDeviceKind();
+            DeviceKindNameList.Add("---");
+            foreach (var kind in kinds)
+            {
+                DeviceKindNameList.Add(kind);
+            }
+           
+            //
             var configList = _optionConfigService.QueryList();
             _optionConfigs = _mapper.Map<List<OptionConfig>, List<OptionConfigDto>>(configList);
             var tests = _optionConfigs.FindAll(x => x.TypeID == 1);
-            TestKinds = new List<string>();
+            TestKinds.Add("---");
             foreach (var test in tests)
             {
                 TestKinds.Add(test.ContentOption);
             }
 
             //测试项类型
+            BeforeJudgeKinds.Add("---");
+            InJudgeKinds.Add("---");
+            OutJudgeKinds.Add("---");
             var judges = _optionConfigs.FindAll(x => x.TypeID == 2);
             foreach (var judge in judges)
             {
@@ -542,6 +453,9 @@ namespace PLCTool.ViewModels.BasicConfigViewModel
             }
 
             //判定逻辑
+            JudgeLogicKinds.Add("---");
+            InJudgeLogicKinds.Add("---");
+            OutJudgeLogicKinds.Add("---");
             var logics = _optionConfigs.FindAll(x => x.TypeID == 3);
             foreach (var logic in logics)
             {
@@ -696,21 +610,7 @@ namespace PLCTool.ViewModels.BasicConfigViewModel
                     }
 
                 }
-                else
-                {
-                    //更新测试方案名称
-                    if (Title == "编辑方案")
-                    {
-                        if (bas_Plc_Test_Scheme != null)
-                        {
-                            bas_Plc_Test_Scheme.scheme_name = ScheduleName;
-                            bas_Plc_Test_Scheme.devicekind_name = DeviceKindName;
-                            _basicPlcTestSchemeService.Edit(bas_Plc_Test_Scheme);
-                        }
-
-                    }
-
-                }
+             
                 //查找测试方案id
                 var finsScheHave = _basicPlcTestSchemeService.FindByName(ScheduleName);
                 if (finsScheHave != null)
@@ -722,11 +622,8 @@ namespace PLCTool.ViewModels.BasicConfigViewModel
                 }
                 //更新已有的测试项
                 GetExistSchs();
-                //清空已填写的内容
-         
-                BeforeConList =new ObservableCollection<BasPlcItemConfigDto>();
-                InConList = new ObservableCollection<BasPlcItemConfigDto>();
-                OutConList = new ObservableCollection<BasPlcItemConfigDto>();
+                //清空上次的内容
+                CleanContent();
             }
             catch (Exception ex)
             {
@@ -736,7 +633,31 @@ namespace PLCTool.ViewModels.BasicConfigViewModel
       
 
         }
-     
+        /// <summary>
+        /// 清空测试项内容内容
+        /// </summary>
+        private void CleanContent()
+        {
+            //清空已填写的内容
+            TestName = string.Empty;
+            SelectTest = "---";
+            BeforeSelectJudge = "---";
+            SelectLogic = "---";
+            BeforeDetail = string.Empty;
+            //输入项
+            SelectInJudge = "---";
+            InSelectLogic = "---";
+            InDetail = string.Empty;
+            //输出项
+            SelectOutJudge = "---";
+            OutSelectLogic = "---";
+            OutDetail = string.Empty;
+
+            BeforeConList = new ObservableCollection<BasPlcItemConfigDto>();
+            InConList = new ObservableCollection<BasPlcItemConfigDto>();
+            OutConList = new ObservableCollection<BasPlcItemConfigDto>();
+
+        }
         /// <summary>
         /// 方案明细添加到数据库
         /// </summary>
@@ -784,34 +705,7 @@ namespace PLCTool.ViewModels.BasicConfigViewModel
                         return;
                     }
                 }
-                else
-                {
-                    if (Title == "编辑方案")
-                    {
-                        //修改 必须给主键SchemeDtlId值
-                        //var schDtl = _basicPlcTestSchemeDtlService.FindSchDtlIdBySchIdAndItem(scheduleId, TestName);
-                        // if (schDtl != null)
-                        {
-                            schDtlDto.SchemeDtlId = schDtlMainId;
-                            bas_plc_test_scheme_dtl schDtlEntityEdit = _mapper.Map<BasicPlcTestSchemeDtlDto, bas_plc_test_scheme_dtl>(schDtlDto);
-                            //ItemType 转化
-                            schDtlEntityEdit.item_type = StrToItemType(schDtlDto.ItemType);
-                            bool isSucc = _basicPlcTestSchemeDtlService.Edit(schDtlEntityEdit);
-                            if (isSucc)
-                            {
-                                _logger.LogInformation($"更新方案成功。方案名{ScheduleName},测试项{TestName}");
-                                MessageBoxResult boxResult = MessageBox.Show("保存成功", "提示", MessageBoxButton.OK, MessageBoxImage.Information);
-                            }
-                            else
-                            {
-                                MessageBoxResult boxResult = MessageBox.Show("保存失败", "提示", MessageBoxButton.OK, MessageBoxImage.Warning);
-                                return;
-                            }
-
-                        }
-
-                    }
-                }
+               
             }
             catch(Exception ex)
             {
@@ -887,49 +781,7 @@ namespace PLCTool.ViewModels.BasicConfigViewModel
 
         public void OnNavigatedTo(NavigationContext navigationContext)
         {
-            //编辑
-            var getMsg = navigationContext.Parameters.GetValues<string>("Key");
-            ///值不为空,表示修改,为空表示新增
-            if (getMsg != null)
-            {
-                foreach (var item in getMsg)
-                {
-                    try
-                    {
-
-                        Title = "编辑方案";
-                        ScheduleName = item.ToString();
-                        //获取已经有的测试项
-                        GetExistSchs();
-                        //展示第一个测试项详情
-                        var findSch = _basicPlcTestSchemeService.FindByNameAndType(ScheduleName, DeviceKindName);
-                        if (findSch != null)
-                        {
-                            long schID = findSch.scheme_id;
-                            int schDtlId = (int)_basicPlcTestSchemeDtlService.FindAllBySchId(schID)?.OrderBy(x => x.scheme_dtl_id)?.First()?.scheme_dtl_id;
-
-                            schDtlMainId = schDtlId;//全局变量赋值,测试方案明细id
-                            GetDetaiMsg(schDtlId);
-                        }
-
-                    }
-                    catch (Exception ex)
-                    {
-                        _logger.LogError(ex.ToString());
-                    }
-
-
-                }
-            }
-
-            var getMsg2 = navigationContext.Parameters.GetValues<string>("Key2");
-            if (getMsg2 != null)
-            {
-                foreach (var item in getMsg2)
-                {
-                    DeviceKindName = item;
-                }
-            }
+            ScheduleName = string.Empty;
         }
 
         public bool IsNavigationTarget(NavigationContext navigationContext)
@@ -1024,8 +876,8 @@ namespace PLCTool.ViewModels.BasicConfigViewModel
         /// <summary>
         /// 测试项类型
         /// </summary>
-        private List<string> testKinds = new List<string>();
-        public List<string> TestKinds
+        private ObservableCollection<string> testKinds = new ObservableCollection<string>();
+        public ObservableCollection<string> TestKinds
         {
             get { return testKinds; }
             set { testKinds = value; RaisePropertyChanged(); }
@@ -1042,8 +894,8 @@ namespace PLCTool.ViewModels.BasicConfigViewModel
         /// <summary>
         /// 判定类型(前置项)
         /// </summary>
-        private List<string> beforeJudgeKinds = new List<string>();
-        public List<string> BeforeJudgeKinds
+        private ObservableCollection<string> beforeJudgeKinds = new ObservableCollection<string>();
+        public ObservableCollection<string> BeforeJudgeKinds
         {
             get { return beforeJudgeKinds; }
             set { beforeJudgeKinds = value; RaisePropertyChanged(); }
@@ -1057,8 +909,8 @@ namespace PLCTool.ViewModels.BasicConfigViewModel
         /// <summary>
         /// 逻辑判断
         /// </summary>
-        private List<string> judgeLogicKinds = new List<string>();
-        public List<string> JudgeLogicKinds
+        private ObservableCollection<string> judgeLogicKinds = new ObservableCollection<string>();
+        public ObservableCollection<string> JudgeLogicKinds
         {
             get { return judgeLogicKinds; }
             set { judgeLogicKinds = value; RaisePropertyChanged(); }
@@ -1086,8 +938,8 @@ namespace PLCTool.ViewModels.BasicConfigViewModel
         /// <summary>
         /// 判定类型(输入项)
         /// </summary>
-        private List<string> inJudgeKinds = new List<string>();
-        public List<string> InJudgeKinds
+        private ObservableCollection<string> inJudgeKinds = new ObservableCollection<string>();
+        public ObservableCollection<string> InJudgeKinds
         {
             get { return inJudgeKinds; }
             set { inJudgeKinds = value; RaisePropertyChanged(); }
@@ -1101,8 +953,8 @@ namespace PLCTool.ViewModels.BasicConfigViewModel
         /// <summary>
         /// 逻辑判断
         /// </summary>
-        private List<string> inJudgeLogicKinds = new List<string>();
-        public List<string> InJudgeLogicKinds
+        private ObservableCollection<string> inJudgeLogicKinds = new ObservableCollection<string>();
+        public ObservableCollection<string> InJudgeLogicKinds
         {
             get { return inJudgeLogicKinds; }
             set { inJudgeLogicKinds = value; RaisePropertyChanged(); }
@@ -1129,8 +981,8 @@ namespace PLCTool.ViewModels.BasicConfigViewModel
         /// <summary>
         /// 判定类型(结果项)
         /// </summary>
-        private List<string> outJudgeKinds = new List<string>();
-        public List<string> OutJudgeKinds
+        private ObservableCollection<string> outJudgeKinds = new ObservableCollection<string>();
+        public ObservableCollection<string> OutJudgeKinds
         {
             get { return outJudgeKinds; }
             set { outJudgeKinds = value; RaisePropertyChanged(); }
@@ -1146,8 +998,8 @@ namespace PLCTool.ViewModels.BasicConfigViewModel
         /// <summary>
         /// 逻辑判断
         /// </summary>
-        private List<string> outJudgeLogicKinds = new List<string>();
-        public List<string> OutJudgeLogicKinds
+        private ObservableCollection<string> outJudgeLogicKinds = new ObservableCollection<string>();
+        public ObservableCollection<string> OutJudgeLogicKinds
         {
             get { return outJudgeLogicKinds; }
             set { outJudgeLogicKinds = value; RaisePropertyChanged(); }
@@ -1175,8 +1027,8 @@ namespace PLCTool.ViewModels.BasicConfigViewModel
         /// <summary>
         /// 设备类型
         /// </summary>
-        private List<string> deviceKindNameList;
-        public List<string> DeviceKindNameList
+        private ObservableCollection<string> deviceKindNameList = new ObservableCollection<string>();
+        public ObservableCollection<string> DeviceKindNameList
         {
             get { return deviceKindNameList; }
             set { deviceKindNameList = value; RaisePropertyChanged(); }

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

@@ -66,11 +66,35 @@ namespace PLCTool.ViewModels.BasicConfigViewModel
             DeleteCommand = new DelegateCommand<object>(Delete);
             QueryCommand = new DelegateCommand<object>(Query);
             EditCommand = new DelegateCommand<object>(EditSchDtl);
+            AddItemCommand = new DelegateCommand<object>(AddSchDtl);
               //获取设备类型
             DeviceKindNameList = _iBasicDeviceKindService.FindAllDeviceKind();
             
         }
 
+        private void AddSchDtl(object obj)
+        {
+            object[] multiObj = obj as object[];
+
+            //测试方案明细主键ID
+            string deviceKindName = (string)multiObj[0];
+            string scheduleName = (string)multiObj[1];
+            DialogParameters parm = new DialogParameters();
+            parm.Add("Key", deviceKindName);
+            parm.Add("Key2", scheduleName);
+           
+            //弹出详情对话框
+            _dialog.ShowDialog("AddItemDetailView", parm, async callback =>
+            {
+                if (callback.Result == ButtonResult.OK)
+                {
+                    //获取已经有的测试项
+                    GetExistSchs();
+                }
+
+            });
+        }
+
         private void EditSchDtl(object obj)
         {
             long schDtlId = Convert.ToInt64(obj);
@@ -443,7 +467,9 @@ namespace PLCTool.ViewModels.BasicConfigViewModel
 
         public DelegateCommand<object> QueryCommand { set; get; }
         public DelegateCommand<object> EditCommand { set; get; }
+        public DelegateCommand<object> AddItemCommand { set; get; }
         
+
         #endregion
         #region 变量绑定
         /// <summary>

+ 376 - 0
BlankApp1/BlankApp1/Views/BasicConfigView/AddItemDetailView.xaml

@@ -0,0 +1,376 @@
+<UserControl x:Class="PLCTool.Views.BasicConfigView.AddItemDetailView"
+             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:b="http://schemas.microsoft.com/xaml/behaviors"
+             xmlns:prism="http://prismlibrary.com/" 
+             BorderBrush="#CBCBCB" BorderThickness="1"
+             Height="600" Width="1100" >
+
+    <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>
+
+        <Style x:Key="CenterAlignedGroupBoxStyle" TargetType="{x:Type GroupBox}">
+            <Setter Property="Template">
+                <Setter.Value>
+                    <ControlTemplate TargetType="GroupBox">
+                        <Grid>
+                            <Grid.RowDefinitions>
+                                <RowDefinition Height="Auto"/>
+                                <RowDefinition Height="*"/>
+                            </Grid.RowDefinitions>
+                            <Border Grid.Row="0" Background="BlueViolet" CornerRadius="5" Padding="5">
+                                <TextBlock Text="{TemplateBinding Header}" HorizontalAlignment="Right"/>
+                            </Border>
+                            <ContentControl Grid.Row="1" Content="{TemplateBinding Content}"/>
+                        </Grid>
+                    </ControlTemplate>
+                </Setter.Value>
+            </Setter>
+        </Style>
+    </UserControl.Resources>
+
+    <Grid>
+        <b:Interaction.Triggers>
+            <b:EventTrigger EventName="Loaded">
+                <b:InvokeCommandAction Command="{Binding OnLoadCommand}" CommandParameter="{Binding ElementName=tt}"/>
+            </b:EventTrigger>
+        </b:Interaction.Triggers>
+        <ScrollViewer Template="{StaticResource MyScrollViewer}" VerticalScrollBarVisibility="Auto">
+            <Grid >
+
+                <Grid.RowDefinitions>
+                    <RowDefinition Height="50" />
+                    <RowDefinition  />
+                   
+
+                </Grid.RowDefinitions>
+
+                <DockPanel  Grid.Row="0" Margin="10" LastChildFill="False">
+                    <StackPanel Orientation="Horizontal"  Grid.Row="4" HorizontalAlignment="Center">
+                        <TextBlock Text="设备类型:"  Style="{StaticResource NormalTextBlockStyle}" Margin="10,0,5,0"  Width="60"/>
+                        <ComboBox  Height="28" Width="120" ItemsSource="{Binding DeviceKindNameList}" SelectedItem="{Binding DeviceKindName}" />
+                    </StackPanel>
+                    <StackPanel Orientation="Horizontal">
+                        <TextBlock Text="测试方案名称:"  Style="{StaticResource NormalTextBlockStyle}" Margin="10,0,5,0"/>
+                        <TextBox  Height="28" Width="120" Text="{Binding ScheduleName}" >
+
+                        </TextBox>
+                    </StackPanel>
+                    <Button  Content="取消" Width="80"  Margin="5,0"  Command="{Binding CancelCommand}" Style="{StaticResource NormalButtonStyle}" DockPanel.Dock="Right" />
+                    <Button  Content="确认" Width="80"  Margin="5,0"  Command="{Binding SureCommand}" Style="{StaticResource NormalButtonStyle}" DockPanel.Dock="Right" />
+
+                </DockPanel>
+                <Border Grid.Row="0"  BorderBrush="#CBCBCB" BorderThickness="0,1" />
+
+
+                <Border  Grid.Row="1" BorderBrush="#CBCBCB"  BorderThickness="1" Margin="5" >
+
+                    <Grid>
+                        <Grid.RowDefinitions>
+                            <RowDefinition Height="50"/>
+                            <RowDefinition Height="50"/>
+                            <RowDefinition/>
+                            <RowDefinition/>
+                            <RowDefinition/>
+                            <RowDefinition Height="50"/>
+                        </Grid.RowDefinitions>
+                        <StackPanel Grid.Row="0" Orientation="Horizontal">
+                            <StackPanel Orientation="Horizontal" >
+                                <TextBlock Text="▊"  TextAlignment="Center" VerticalAlignment="Center" Foreground="#409EFF" Margin="5,0,5,0"/>
+                                <TextBlock Text="测试方案明细"  Style="{StaticResource NormalTextBlockStyle}" Margin="0,0,5,0"/>
+                            </StackPanel>
+                        </StackPanel>
+                        <StackPanel Grid.Row="1" Orientation="Horizontal">
+
+                            <StackPanel Orientation="Horizontal">
+                                <TextBlock Text="测试项名称:"  Style="{StaticResource NormalTextBlockStyle}" Margin="10,0,5,0"/>
+                                <TextBox  Height="28" Width="160"  Text="{Binding TestName}"/>
+                            </StackPanel>
+
+                            <StackPanel Orientation="Horizontal" >
+                                <TextBlock Text="测试项类型:"  Style="{StaticResource NormalTextBlockStyle}" Margin="10,0,5,0"/>
+                                <ComboBox  Height="28" Width="160" ItemsSource="{Binding TestKinds}" SelectedItem="{Binding SelectTest}" />
+                            </StackPanel>
+                        </StackPanel>
+
+                        <Border Grid.Row="1"  BorderBrush="#CBCBCB" BorderThickness="1" />
+                        <ScrollViewer Grid.Row="2">
+                            <Grid >
+                                <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}" />
+                                            <TextBox x:Name="txtBefore"  TextWrapping="Wrap"  Text="{Binding BeforeDetail }"  AcceptsReturn="True" KeyDown="txtBefore_KeyDown"/>
+
+                                        </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" Padding="0" >
+                                        <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>
+                        </ScrollViewer>
+                        <ScrollViewer Grid.Row="3">
+                            <Grid >
+                                <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}" />
+                                            <TextBox x:Name="txtIn"  TextWrapping="Wrap"  Text="{Binding InDetail,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}"  AcceptsReturn="True" KeyDown="txtIn_KeyDown"/>
+
+                                        </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" Padding="0" >
+                                        <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.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.DeleteInCommand, 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>
+                        </ScrollViewer>
+
+                        <Border Grid.Row="3"  BorderBrush="#CBCBCB" BorderThickness="0,1,0,0" />
+
+                        <ScrollViewer Grid.Row="4">
+                            <Grid >
+                                <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}" />
+
+                                            <TextBox x:Name="txtOut"  TextWrapping="Wrap"  Text="{Binding OutDetail,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}"  AcceptsReturn="True" KeyDown="txtOut_KeyDown"/>
+
+                                        </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" Padding="0" >
+                                        <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.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.DeleteOutCommand, 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>
+                        </ScrollViewer>
+                        <Border Grid.Row="4"  BorderBrush="#CBCBCB" BorderThickness="0,1" />
+                     
+                    </Grid>
+
+                </Border>
+              
+
+            </Grid>
+        </ScrollViewer>
+
+
+
+
+    </Grid>
+</UserControl>

+ 43 - 0
BlankApp1/BlankApp1/Views/BasicConfigView/AddItemDetailView.xaml.cs

@@ -0,0 +1,43 @@
+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>
+    /// AddItemDetailView.xaml 的交互逻辑
+    /// </summary>
+    public partial class AddItemDetailView : UserControl
+    {
+        public AddItemDetailView()
+        {
+            InitializeComponent();
+        }
+
+        private void txtBefore_KeyDown(object sender, KeyEventArgs e)
+        {
+
+        }
+
+        private void txtIn_KeyDown(object sender, KeyEventArgs e)
+        {
+
+        }
+
+        private void txtOut_KeyDown(object sender, KeyEventArgs e)
+        {
+
+        }
+    }
+}

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

@@ -5,6 +5,7 @@
              xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
              xmlns:local="clr-namespace:PLCTool.Views.BasicConfigView"
              xmlns:b="http://schemas.microsoft.com/xaml/behaviors"
+              xmlns:cvt="clr-namespace:PLCTool.Controls.Convert"
              xmlns:prism="http://prismlibrary.com/" 
              BorderBrush="#CBCBCB" BorderThickness="1"
              Height="700" Width="1100" >
@@ -36,6 +37,7 @@
                 </Setter.Value>
             </Setter>
         </Style>
+        <cvt:TwoParConverter x:Key="TwoParConverter"/>
     </UserControl.Resources>
 
     <Grid>
@@ -88,6 +90,14 @@
                             <TextBlock Text="测试项类型:"  Style="{StaticResource NormalTextBlockStyle}" Margin="10,0,5,0"/>
                             <ComboBox  Height="28" Width="160" ItemsSource="{Binding TestKinds}" SelectedItem="{Binding SelectTest}" />
                         </StackPanel>
+                        <Button  Content="新增测试项" Width="80"  Margin="5,0"  Command="{Binding AddItemCommand}" Style="{StaticResource NormalButtonStyle}" DockPanel.Dock="Right" >
+                            <Button.CommandParameter>
+                                <MultiBinding Converter="{ StaticResource ResourceKey=TwoParConverter}">
+                                    <Binding Path="DeviceKindName"  ></Binding>
+                                    <Binding Path="ScheduleName"></Binding>
+                                </MultiBinding>
+                            </Button.CommandParameter>
+                        </Button>
                         <Button  Content="查询" Width="80"  Margin="5,0"  Command="{Binding QueryCommand}" Style="{StaticResource NormalButtonStyle}" DockPanel.Dock="Right" />
                         <Button  Content="重置" Width="80"  Margin="5,0"  Command="{Binding ResetCommand}" Style="{StaticResource NormalButtonStyle}" DockPanel.Dock="Right" />
                     </StackPanel>