123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336 |
- using AntDesign;
- using Microsoft.AspNetCore.Components;
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text.Json;
- using System.Threading.Tasks;
- using wispro.sp.entity;
- namespace wispro.sp.web.Components
- {
- public partial class InputValueSetting
- {
- List<wispro.sp.entity.EnumnDescription<wispro.sp.entity.workflowDefine.EnumFieldType>> FieldTypes
- = entity.EnumHelper.getEnumDescriptionDic<wispro.sp.entity.workflowDefine.EnumFieldType>();
-
- entity.workflowDefine.InputValueSetting EditObj;
- [Parameter]
- public share.ActionObject EditAction { get; set; }
- IDictionary<string, (bool edit, entity.workflowDefine.InputValueSetting data)> editCache = new Dictionary<string, (bool edit, entity.workflowDefine.InputValueSetting data)>();
- private List<entity.workflowDefine.InputValueSetting > GetChildItem(share.InputValueSettingObject setting)
- {
- if(setting.Children == null)
- {
- setting.Children = new List<entity.workflowDefine.InputValueSetting>();
- }
- return setting.Children;
- //return DataSource.Where<entity.workflowDefine.InputValueSetting>(p => p.ParentSetting == setting).ToList();
- }
- void AddNew(entity.workflowDefine.InputValueSetting setting)
- {
- JsonSerializerOptions options = new() { IgnoreNullValues = true };
- //Console.WriteLine($"AddNew Begin:{System.Text.Json.JsonSerializer.Serialize(EditAction,options)}");
- //Console.WriteLine($"setting:{System.Text.Json.JsonSerializer.Serialize(setting, options)}");
- var newObj = new entity.workflowDefine.InputValueSetting()
- {
- valueType = entity.workflowDefine.EnumFieldType.Text,
- DisplayName = "新添栏位",
- //ParentSetting = setting
-
- };
- EditObj = newObj;
- //Console.WriteLine(System.Text.Json.JsonSerializer.Serialize(EditObj,options));
- //Console.WriteLine($"newObj:{System.Text.Json.JsonSerializer.Serialize(newObj, options)}");
- if (setting != null)
- {
- foreach(var ss in EditAction.InputValueSettingObjects)
- {
- if(ss.InputValueSetting == setting )
- {
- if(ss.Children == null)
- {
- ss.Children = new List<entity.workflowDefine.InputValueSetting>();
- }
- ss.Children.Add(newObj);
- break;
- }
- }
- }
- else
- {
- share.InputValueSettingObject newSettingobj = new share.InputValueSettingObject();
- newSettingobj.InputValueSetting = EditObj;
- EditAction.InputValueSettingObjects.Add(newSettingobj);
- if (EditAction.NewInputValueSettingObjects == null)
- {
- EditAction.NewInputValueSettingObjects = new List<share.InputValueSettingObject>();
- }
- EditAction.NewInputValueSettingObjects.Add(newSettingobj);
- }
- //Console.WriteLine($"AddNew End:{System.Text.Json.JsonSerializer.Serialize(EditAction, options)}");
- }
- async void Delete(entity.workflowDefine.InputValueSetting setting)
- {
- //Console.WriteLine($"begin Delete:{ System.Text.Json.JsonSerializer.Serialize(EditAction)}");
- //Console.WriteLine($"Delete Setting:{ System.Text.Json.JsonSerializer.Serialize(setting)}");
- foreach (var temObj in EditAction.InputValueSettingObjects)
- {
- if (temObj.InputValueSetting.DisplayName == setting.DisplayName )
- {
- EditAction.InputValueSettingObjects.Remove(temObj);
- }
- bool isFound = false;
- if (temObj.Children != null)
- {
- foreach (var iv in temObj.Children)
- {
- if (iv.DisplayName == setting.DisplayName)
- {
- temObj.Children.Remove(iv);
- isFound = true;
- break;
- }
- }
- }
- if (isFound)
- {
- break;
- }
- }
- if (EditAction.NewInputValueSettingObjects != null)
- {
- foreach (var temObj in EditAction.NewInputValueSettingObjects)
- {
- if (temObj.InputValueSetting.DisplayName == setting.DisplayName)
- {
- EditAction.NewInputValueSettingObjects.Remove(temObj);
- }
- bool isFound = false;
- if (temObj.Children != null)
- {
- foreach (var iv in temObj.Children)
- {
- if (iv.DisplayName == setting.DisplayName)
- {
- temObj.Children.Remove(iv);
- isFound = true;
- break;
- }
- }
- }
- if (isFound)
- {
- break;
- }
- }
- }
- if (EditAction.UpdateInputValueSettingObjects != null)
- {
- foreach (var temObj in EditAction.UpdateInputValueSettingObjects)
- {
- if (temObj.InputValueSetting.DisplayName == setting.DisplayName)
- {
- EditAction.UpdateInputValueSettingObjects.Remove(temObj);
- }
- bool isFound = false;
- if (temObj.Children != null)
- {
- foreach (var iv in temObj.Children)
- {
- if (iv.DisplayName == setting.DisplayName)
- {
- temObj.Children.Remove(iv);
- isFound = true;
- break;
- }
- }
- }
- if (isFound)
- {
- break;
- }
- }
- }
- if (setting.Id > 0)
- {
- //添加从数据库中删除代码;
- await wfService.DeleteInputValueSetting(setting.Id);
- }
- //Console.WriteLine($"End Delete:{ System.Text.Json.JsonSerializer.Serialize(EditAction)}");
- }
- async void Delete(share.InputValueSettingObject setting)
- {
- //Console.WriteLine($"Begin Delete:{ System.Text.Json.JsonSerializer.Serialize(EditAction)}");
- //Console.WriteLine($"Delete Setting:{ System.Text.Json.JsonSerializer.Serialize(setting)}");
- //此处添加删除代码
- if (EditAction.InputValueSettingObjects.Contains(setting))
- {
- EditAction.InputValueSettingObjects.Remove(setting);
- }
- else
- {
- foreach (var temObj in EditAction.InputValueSettingObjects)
- {
- if (temObj.Children != null && temObj.Children.Contains ( setting.InputValueSetting))
- {
- temObj.Children.Remove(setting.InputValueSetting);
- break;
- }
- }
- }
- if (EditAction.NewInputValueSettingObjects != null)
- {
- if (EditAction.NewInputValueSettingObjects.Contains(setting))
- {
- EditAction.NewInputValueSettingObjects.Remove(setting);
- }
- else
- {
- foreach (var temObj in EditAction.NewInputValueSettingObjects)
- {
- if (temObj.Children != null && temObj.Children.Contains(setting.InputValueSetting))
- {
- temObj.Children.Remove(setting.InputValueSetting);
- break;
- }
- }
- }
- }
- if (EditAction.UpdateInputValueSettingObjects != null)
- {
- if (EditAction.UpdateInputValueSettingObjects.Contains(setting))
- {
- EditAction.UpdateInputValueSettingObjects.Remove(setting);
- }
- else
- {
- foreach (var temObj in EditAction.UpdateInputValueSettingObjects)
- {
- if (temObj.Children != null && temObj.Children.Contains(setting.InputValueSetting))
- {
- temObj.Children.Remove(setting.InputValueSetting);
- break;
- }
- }
- }
- }
- if (setting.InputValueSetting.Id > 0)
- {
- //添加从数据库中删除代码;
- await wfService.DeleteInputValueSetting(setting.InputValueSetting.Id);
- }
- //Console.WriteLine($"End Delete:{ System.Text.Json.JsonSerializer.Serialize(EditAction)}");
- StateHasChanged();
- }
- void Edit(entity.workflowDefine.InputValueSetting setting)
- {
- EditObj = setting;
- }
- void Save(entity.workflowDefine.InputValueSetting setting)
- {
-
- if (setting.Id > 0)
- {
- var temObj = EditAction.InputValueSettingObjects.FirstOrDefault(p => p.InputValueSetting.Id == setting.Id);
- if (temObj != null)
- {
- if (EditAction.UpdateInputValueSettingObjects == null)
- {
- EditAction.UpdateInputValueSettingObjects = new List<share.InputValueSettingObject>();
-
- }
- if (!EditAction.UpdateInputValueSettingObjects.Contains(temObj))
- {
- EditAction.UpdateInputValueSettingObjects.Add(temObj);
- }
- }
- }
- EditObj = null;
- StateHasChanged();
- }
- async Task OnCancel(entity.workflowDefine.InputValueSetting setting)
- {
- if(setting.Id == 0)
- {
- foreach(var temobj in EditAction.InputValueSettingObjects)
- {
- if(temobj.InputValueSetting == setting)
- {
- EditAction.InputValueSettingObjects.Remove(temobj);
- break;
- }
- }
- foreach (var temobj in EditAction.NewInputValueSettingObjects )
- {
- if (temobj.InputValueSetting == setting)
- {
- EditAction.NewInputValueSettingObjects.Remove(temobj);
- break;
- }
- }
- }
- else
- {
- foreach (var temobj in EditAction.UpdateInputValueSettingObjects)
- {
- if (temobj.InputValueSetting == setting)
- {
- EditAction.UpdateInputValueSettingObjects.Remove(temobj);
- break;
- }
- }
- setting = await wfService.getInputValueSteeingById(setting.Id);
- }
- EditObj = null;
- }
- [Inject]
- Services.WorkflowService wfService { get; set; }
- }
-
- }
|