This commit is contained in:
2024-12-18 15:50:21 +08:00
parent 684973e6b7
commit b2c54119ea
214 changed files with 65908 additions and 8461 deletions

View File

@@ -0,0 +1,139 @@
using CapMachine.Core;
using CapMachine.Model;
using CapMachine.Wpf.Dtos;
using DryIoc;
using Prism.Commands;
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 CapMachine.Wpf.ViewModels
{
/// <summary>
/// CAN 配置的弹窗
/// </summary>
public class DialogCanRwConfigViewModel:DialogViewModel
{
public DialogCanRwConfigViewModel()
{
Title = "CAN 配置";
}
private string name;
/// <summary>
/// 名称
/// </summary>
public string Name
{
get { return name; }
set { name = value; RaisePropertyChanged(); }
}
private ObservableCollection<ChartTabGroupDto> _ListChartTabGroupDto;
/// <summary>
/// 数据集合
/// </summary>
public ObservableCollection<ChartTabGroupDto> ListChartTabGroupDto
{
get { return _ListChartTabGroupDto; }
set { _ListChartTabGroupDto = value; RaisePropertyChanged(); }
}
private DelegateCommand saveCmd;
/// <summary>
/// 保存命令
/// </summary>
public DelegateCommand SaveCmd
{
set
{
saveCmd = value;
}
get
{
if (saveCmd == null)
{
saveCmd = new DelegateCommand(() => SaveCmdMethod());
}
return saveCmd;
}
}
/// <summary>
/// 保存命令方法
/// </summary>
/// <exception cref="NotImplementedException"></exception>
private void SaveCmdMethod()
{
if (ListChartTabGroupDto.Where(a => a.IsEnable == true).Count() == 0)
{
MessageBox.Show("未发现【启用】的选型,这将要导致没有任何显示!,请检查后再提交");
return;
}
foreach (var item in ListChartTabGroupDto)
{
//FreeSql.Update<ChartTabGroup>()
// .Set(a => a.Name, item.Name)
// .Set(a => a.IsEnable, item.IsEnable)
// .Where(a => a.Index == item.Index)
// .ExecuteAffrows();
}
DialogParameters pars = new DialogParameters
{
{ "NewData", ListChartTabGroupDto.Where(a=>a.IsEnable==true).ToList() }
};
RaiseRequestClose(new DialogResult(ButtonResult.OK, pars));
}
private DelegateCommand cancelCmd;
/// <summary>
/// 保存命令
/// </summary>
public DelegateCommand CancelCmd
{
set
{
cancelCmd = value;
}
get
{
if (cancelCmd == null)
{
cancelCmd = new DelegateCommand(() => CancelCmdMethod());
}
return cancelCmd;
}
}
/// <summary>
/// 取消命令方法
/// </summary>
/// <exception cref="NotImplementedException"></exception>
private void CancelCmdMethod()
{
RaiseRequestClose(new DialogResult(ButtonResult.Cancel));
}
/// <summary>
/// 窗口打开时的传递的参数
/// </summary>
/// <param name="parameters"></param>
public override void OnDialogOpened(IDialogParameters parameters)
{
Name = parameters.GetValue<string>("Name");
}
}
}