009_DI-Elec/newFront/c#前端/SWS.CAD/ViewModels/DialogPreCheckInViewModel.cs
2025-09-04 18:28:02 +08:00

182 lines
9.6 KiB
C#

using Prism.Events;
using Prism.Services.Dialogs;
using SWS.CAD.Event;
using SWS.CAD.ViewModels.myViewModelBase;
using SWS.Commons;
using SWS.Model;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using Unity;
using static Bricscad.Quad.QuadSelectionData;
namespace SWS.CAD.ViewModels
{
public class DialogPreCheckInViewModel : DialogBase, IDialogAware
{
private ObservableCollection<propertyModel> _listPro = new ObservableCollection<propertyModel>();
/// <summary>
/// 属性列表
/// </summary>
public ObservableCollection<propertyModel> listPro
{
get { return _listPro; }
set
{
_listPro = value;
RaisePropertyChanged(nameof(listPro));
}
}
IEventAggregator eventAggregator;
public DialogPreCheckInViewModel()
{
title = "检入";
eventAggregator = GlobalObject.container.Resolve<IEventAggregator>();
eventAggregator.GetEvent<checkInResultEvent>().Subscribe(CheckInResult, ThreadOption.UIThread, true);
}
public string Title => "";
public event Action<IDialogResult> RequestClose;
public bool CanCloseDialog()
{
return true;
}
public void OnDialogClosed()
{
}
private string _TagNumber;
/// <summary>
/// 选中的位号
/// </summary>
public string TagNumber
{
get { return _TagNumber; }
set { _TagNumber = value; RaisePropertyChanged(nameof(TagNumber)); }
}
private List<string> handles = new List<string>();
private ec_drawing_file objDwg;
public async void OnDialogOpened(IDialogParameters parameters)
{
objDwg = parameters.GetValue<ec_drawing_file>(GlobalObject.dialogPar.info.ToString());
handles = parameters.GetValue<List<string>>(GlobalObject.dialogPar.para1.ToString());
var lines= parameters.GetValue<string>(GlobalObject.dialogPar.para2.ToString());
#region
ObservableCollection<propertyModel> listPropertys = new ObservableCollection<propertyModel>();
var model = new propertyModel() { Id = "DrawingNo", DisplayText = "图号", GroupName = "常用", PropertyValue = "", ControlTypeName = PROPERTYType.TextBox,IsBasicGroup=true }; listPropertys.Add(model);
model = new propertyModel() { Id = "DrawingFile", DisplayText = "图名", GroupName = "常用", PropertyValue = objDwg.DrawingFileName, ControlTypeName = PROPERTYType.TextBox, IsEnable = false, IsBasicGroup = true }; listPropertys.Add(model);
model = new propertyModel() { Id = "PageNos", DisplayText = "页码", GroupName = "常用", PropertyValue = "", ControlTypeName = PROPERTYType.TextBox, IsBasicGroup = true }; listPropertys.Add(model);
model = new propertyModel() { Id = "Cables", DisplayText = "电缆位号", GroupName = "常用", PropertyValue = "", ControlTypeName = PROPERTYType.TextBox, IsBasicGroup = true }; listPropertys.Add(model);
model = new propertyModel() { Id = "IsMaterial", DisplayText = "是否影响填料函", GroupName = "常用", PropertyValue = "", ControlTypeName = PROPERTYType.CheckBox, IsBasicGroup = true }; listPropertys.Add(model);
model = new propertyModel() { Id = "Remark", DisplayText = "修改内容", GroupName = "常用", PropertyValue = "", ControlTypeName = PROPERTYType.TextBox , IsBasicGroup = true }; listPropertys.Add(model);
//List<KeyValueModel> listType=new List<KeyValueModel>();
//listType.Add(new KeyValueModel() { Key = "新增", Value = "新增" });
//listType.Add(new KeyValueModel() { Key = "修改", Value = "修改" });
//listType.Add(new KeyValueModel() { Key = "删除", Value = "删除" });
Dictionary<string, string> listType = new Dictionary<string, string>();
listType.Add("新增", "新增");
listType.Add("修改", "修改");
listType.Add("删除", "删除");
model = new propertyModel() { Id = "Type", DisplayText = "修改属性", GroupName = "常用", PropertyValue = "", ControlTypeName = PROPERTYType.ComboBox, Item = listType, IsBasicGroup = true }; listPropertys.Add(model);
model = new propertyModel() { Id = "cloud", DisplayText = "关联云线", GroupName = "常用", PropertyValue = lines, ControlTypeName = PROPERTYType.TextBox , IsBasicGroup = true }; listPropertys.Add(model);
model = new propertyModel() { Id = "CreateTime", DisplayText = "日期", GroupName = "常用", PropertyValue = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), ControlTypeName = PROPERTYType.TextBox, IsEnable = false, IsBasicGroup = true }; listPropertys.Add(model);
model = new propertyModel() { Id = "CreateUserID", DisplayText = "系统修改人", GroupName = "常用", PropertyValue = GlobalObject.userInfo.userId, ControlTypeName = PROPERTYType.TextBox, IsEnable = false, IsBasicGroup = true }; listPropertys.Add(model);
model = new propertyModel() { Id = "IsProcess", DisplayText = "是否影响生产设计", GroupName = "常用", PropertyValue = "", ControlTypeName = PROPERTYType.CheckBox, IsBasicGroup = true }; listPropertys.Add(model);
//List<KeyValueModel> listOtherDwg = new List<KeyValueModel>();
//foreach (var name in GlobalObject.AllDwgName)
//{
// listOtherDwg.Add(new KeyValueModel() { Key = name, Value=name });
//}
Dictionary<string, string> listOtherDwg = new Dictionary<string, string>();
foreach (var name in GlobalObject.AllDwgName)
{
listOtherDwg.Add(name, name);
}
model = new propertyModel() { Id = "otherDwgIds", DisplayText = "涉及其他图纸名字", GroupName = "常用", PropertyValue = "", ControlTypeName = PROPERTYType.MultiSelectComboBox, Item = listOtherDwg , IsBasicGroup = true }; listPropertys.Add(model);
//List<KeyValueModel> listUser = new List<KeyValueModel>();
//if (objDwg.AllUsersCanEdit != null)
//{
// foreach (var user in objDwg.AllUsersCanEdit)
// {
// listUser.Add(new KeyValueModel() { Key = user, Value = user });
// }
//}
Dictionary<string, string> listUser = new Dictionary<string, string>();
if (objDwg.AllUsersCanEdit != null)
{
foreach (var user in objDwg.AllUsersCanEdit)
{
listUser.Add(user, user);
}
}
model = new propertyModel() { Id = "NoticeUser", DisplayText = "平台通知对方", GroupName = "常用", PropertyValue = "", ControlTypeName = PROPERTYType.MultiSelectComboBox, Item = listUser, IsBasicGroup = true }; listPropertys.Add(model);
model = new propertyModel() { Id = "ApproveByAdmin", DisplayText = "需要生产设计主管确认", GroupName = "常用", PropertyValue = "", ControlTypeName = PROPERTYType.CheckBox, IsBasicGroup = true }; listPropertys.Add(model);
listPro = listPropertys;
#endregion
}
public override void ExecuteOKCommandAsync(object para)
{
ec_drawing_syn syn = new ec_drawing_syn();
syn.FolderId = objDwg.FolderId;
syn.DrawingFileID = objDwg.DrawingFileID;
syn.DrawingNo = listPro[0].PropertyValue;
syn.DrawingFile = listPro[1].PropertyValue;
syn.PageNos = listPro[2].PropertyValue;
syn.Cables = listPro[3].PropertyValue;
if (string.IsNullOrEmpty(listPro[4].PropertyValue))
{ syn.IsMaterial = 0; }
else { syn.IsMaterial = bool.Parse(listPro[4].PropertyValue) ? 1 : 0; }
syn.Remark = listPro[5].PropertyValue;
syn.Type = listPro[6].PropertyValue;
syn.cloud = listPro[7].PropertyValue;
syn.CreateTime = DateTime.Parse(listPro[8].PropertyValue);
syn.CreateUserID = listPro[9].PropertyValue;
if (string.IsNullOrEmpty(listPro[10].PropertyValue))
{ syn.IsProcess = 0; }
else { syn.IsProcess = bool.Parse(listPro[10].PropertyValue) ? 1 : 0; }
syn.otherDwgIds = listPro[11].PropertyValue;
//syn.DrawingNo = listPro[12].PropertyValue;
if (string.IsNullOrEmpty(listPro[13].PropertyValue))
{ syn.ApproveByAdmin = 0; }
else { syn.ApproveByAdmin = bool.Parse(listPro[13].PropertyValue) ? 1 : 0; }
CheckInModel model = new CheckInModel();
model.handles = handles;
model.dwgObj = objDwg;
model.syn = syn;
eventAggregator.GetEvent<checkInEvent>().Publish(model);
}
private void CheckInResult(bool flag)
{
if (flag)
{
IDialogParameters resPara = new Prism.Services.Dialogs.DialogParameters();
//resPara.Add(GlobalObject.dialogPar.info.ToString(), TagNumber);
RequestClose.Invoke(new DialogResult(ButtonResult.Yes, resPara));
}
}
public override void ExecuteCloseCommand(object parameter)
{
if (parameter as string == "ClickNo")
{
DialogResult res = new DialogResult(ButtonResult.No);
RequestClose.Invoke(res);
}
else
{
RequestClose.Invoke(new DialogResult(ButtonResult.Cancel));
}
this.Dispose();
}
}
}