256 lines
6.4 KiB
C#
256 lines
6.4 KiB
C#
|
|
using CommunityToolkit.Mvvm.ComponentModel;
|
|||
|
|
using CommunityToolkit.Mvvm.Input;
|
|||
|
|
using Models.Ext;
|
|||
|
|
using Models.Models;
|
|||
|
|
using SamplePre.Models.Ext;
|
|||
|
|
using SamplePre.ProcessBll.BLL;
|
|||
|
|
using SamplePre.UIWpf.ParamManager.chirld;
|
|||
|
|
using System;
|
|||
|
|
using System.Collections.Generic;
|
|||
|
|
using System.ComponentModel;
|
|||
|
|
using System.Linq;
|
|||
|
|
using System.Runtime.CompilerServices;
|
|||
|
|
using System.Text;
|
|||
|
|
using System.Threading.Tasks;
|
|||
|
|
using System.Windows;
|
|||
|
|
using System.Windows.Data;
|
|||
|
|
|
|||
|
|
namespace SamplePreSystem.UI.ViewModel.SopManager
|
|||
|
|
{
|
|||
|
|
public partial class ActionManagerViewModel : ObservableObject
|
|||
|
|
{
|
|||
|
|
ActionMangerBll actionMangerBll = new ActionMangerBll();
|
|||
|
|
|
|||
|
|
SOPManagerBll sopBll = new SOPManagerBll();
|
|||
|
|
|
|||
|
|
public ActionManagerViewModel()
|
|||
|
|
{
|
|||
|
|
|
|||
|
|
///获取所有动作
|
|||
|
|
InitActionData();
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// 所有动作列表
|
|||
|
|
/// </summary>
|
|||
|
|
[ObservableProperty]
|
|||
|
|
public List<sys_action_ext> sysActions = new List<sys_action_ext>();
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// 获取所有动作
|
|||
|
|
/// </summary>
|
|||
|
|
public void InitActionData()
|
|||
|
|
{
|
|||
|
|
|
|||
|
|
SysActions = actionMangerBll.QuerySysAction();
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
[ObservableProperty]
|
|||
|
|
public List<sys_action_parm_map_ext> actionParams;
|
|||
|
|
|
|||
|
|
|
|||
|
|
private sys_action_ext _selectItem;
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// 选中的动作行
|
|||
|
|
/// </summary>
|
|||
|
|
public sys_action_ext SelectItem
|
|||
|
|
{
|
|||
|
|
get { return _selectItem; }
|
|||
|
|
set {
|
|||
|
|
|
|||
|
|
SetProperty(ref _selectItem, value);
|
|||
|
|
|
|||
|
|
OnSelectedActionChanged();
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// 选中的参数
|
|||
|
|
/// </summary>
|
|||
|
|
|
|||
|
|
private sys_action_parm_map_ext _selectParam;
|
|||
|
|
|
|||
|
|
public sys_action_parm_map_ext SelectParam
|
|||
|
|
{
|
|||
|
|
get { return _selectParam; }
|
|||
|
|
set {
|
|||
|
|
SetProperty(ref _selectParam, value);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// 查询动作下参数
|
|||
|
|
/// </summary>
|
|||
|
|
/// <param name="processId"></param>
|
|||
|
|
public void GetParmData(string actionId)
|
|||
|
|
{
|
|||
|
|
ActionParams = actionMangerBll.GetProcess_parm_mapByProcessId(actionId);
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// 获取动作下的参数
|
|||
|
|
/// </summary>
|
|||
|
|
private void OnSelectedActionChanged()
|
|||
|
|
{
|
|||
|
|
if (SelectItem == null) return;
|
|||
|
|
//获取动作下的参数
|
|||
|
|
GetParmData(SelectItem.id);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
public void DeleAction()
|
|||
|
|
{
|
|||
|
|
if (SelectItem == null) return;
|
|||
|
|
|
|||
|
|
sys_action_ext action = SelectItem;
|
|||
|
|
|
|||
|
|
if (action.action_unit == "0") return;
|
|||
|
|
|
|||
|
|
if (MessageBox.Show($"确定删除:{action.action_name}", "提示", MessageBoxButton.OKCancel) == MessageBoxResult.OK)
|
|||
|
|
{
|
|||
|
|
//校验动作是否已经被使用
|
|||
|
|
if (CheckAction(action) == false)
|
|||
|
|
{
|
|||
|
|
return;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//删除动作
|
|||
|
|
actionMangerBll.DelSysActionData(action.id);
|
|||
|
|
|
|||
|
|
|
|||
|
|
//=====刷新列表===================
|
|||
|
|
InitActionData();
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
private bool CheckAction(sys_action process)
|
|||
|
|
{
|
|||
|
|
bool isExis = sopBll.IsExisAction(process.id);
|
|||
|
|
|
|||
|
|
if (isExis)
|
|||
|
|
{
|
|||
|
|
MessageBox.Show("该动作已经被使用,不能删除!");
|
|||
|
|
return false;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
return true;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
public void SelectShowParmList()
|
|||
|
|
{
|
|||
|
|
if(SelectItem == null)
|
|||
|
|
{
|
|||
|
|
MessageBox.Show("请先选择动作!");
|
|||
|
|
return;
|
|||
|
|
}
|
|||
|
|
SelectParmListWindow frm = new SelectParmListWindow(SelectItem);
|
|||
|
|
if(frm.ShowDialog() == true)
|
|||
|
|
{
|
|||
|
|
//获取动作下的参数
|
|||
|
|
GetParmData(SelectItem.id);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// 删除参数
|
|||
|
|
/// </summary>
|
|||
|
|
public void DeleParam()
|
|||
|
|
{
|
|||
|
|
if (SelectItem == null || SelectParam == null) return;//SelectItem
|
|||
|
|
|
|||
|
|
sys_action_parm_map_ext process = SelectParam;
|
|||
|
|
int id = process.id;
|
|||
|
|
string parm_name = process.title;
|
|||
|
|
|
|||
|
|
if (MessageBox.Show($"确定删除:{parm_name}", "提示",MessageBoxButton.OKCancel) == MessageBoxResult.OK)
|
|||
|
|
{
|
|||
|
|
|
|||
|
|
actionMangerBll.DelProcessParmMap(id);
|
|||
|
|
|
|||
|
|
GetParmData(process.process_id);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// 新增动作
|
|||
|
|
/// </summary>
|
|||
|
|
/// <param name="sender"></param>
|
|||
|
|
/// <param name="e"></param>
|
|||
|
|
[RelayCommand]
|
|||
|
|
public void BtnAddActionClick()
|
|||
|
|
{
|
|||
|
|
NewActionWindow frm = new NewActionWindow(this);
|
|||
|
|
if (frm.ShowDialog() == true)
|
|||
|
|
{
|
|||
|
|
//刷新列表
|
|||
|
|
|
|||
|
|
InitActionData();
|
|||
|
|
|
|||
|
|
//刷新列表
|
|||
|
|
ListCollectionView view = (ListCollectionView)CollectionViewSource.GetDefaultView(SysActions);//获取数据视图
|
|||
|
|
|
|||
|
|
////分组
|
|||
|
|
//view.SortDescriptions.Add(new SortDescription("action_seqno", ListSortDirection.Ascending));
|
|||
|
|
view.GroupDescriptions.Clear();
|
|||
|
|
view.GroupDescriptions.Add(new PropertyGroupDescription("action_unitname"));
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// 删除动作
|
|||
|
|
/// </summary>
|
|||
|
|
/// <param name="sender"></param>
|
|||
|
|
/// <param name="e"></param>
|
|||
|
|
[RelayCommand]
|
|||
|
|
public void BtnDelActionClick()
|
|||
|
|
{
|
|||
|
|
|
|||
|
|
DeleAction();
|
|||
|
|
|
|||
|
|
//刷新列表
|
|||
|
|
ListCollectionView view = (ListCollectionView)CollectionViewSource.GetDefaultView(SysActions);//获取数据视图
|
|||
|
|
|
|||
|
|
////分组
|
|||
|
|
view.GroupDescriptions.Clear();
|
|||
|
|
view.GroupDescriptions.Add(new PropertyGroupDescription("action_unitname"));
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// 动作下新增参数
|
|||
|
|
/// </summary>
|
|||
|
|
/// <param name="sender"></param>
|
|||
|
|
/// <param name="e"></param>
|
|||
|
|
[RelayCommand]
|
|||
|
|
public void BtnSelectParamClick()
|
|||
|
|
{
|
|||
|
|
|
|||
|
|
SelectShowParmList();
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// 删除动作下参数
|
|||
|
|
/// </summary>
|
|||
|
|
[RelayCommand]
|
|||
|
|
public void BtnDelParmClick()
|
|||
|
|
{
|
|||
|
|
|
|||
|
|
DeleParam();
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
}
|