CreateAppealModel.cs 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  1. using AntDesign;
  2. using Microsoft.AspNetCore.Components;
  3. using System;
  4. using System.Collections;
  5. using System.Collections.Generic;
  6. using System.Linq;
  7. using System.Text.Json;
  8. using System.Threading.Tasks;
  9. using wispro.sp.entity;
  10. using wispro.sp.web.Services;
  11. namespace wispro.sp.web.Models
  12. {
  13. public class CreateAppealModel
  14. {
  15. public PerformanceItem Item { get; set; }
  16. public AppealType AppealType { get; set; }
  17. public List<InputField> inputFields { get; set; }
  18. public List<InputFieldValue> inputFieldValues { get; set; }
  19. public AppealRecord AppealRecord { get; set; }
  20. public List<UploadFileItem> FileList { get; set; }
  21. public CaseCoefficientStatistics cssObject { get; set; }
  22. //public System.Collections.Hashtable _GroupInputValues { get; set; }
  23. //public List<InputFieldValue> noMultiValues { get; set; }
  24. public CreateAppealModel() { }
  25. public async Task Init(AppealTypeService _atService,PerformanceItem item,AppealType appealType)
  26. {
  27. FileList = new List<UploadFileItem>();
  28. AppealType = appealType;
  29. AppealRecord = new AppealRecord();
  30. AppealRecord.TypeId = appealType.Id;
  31. if (item == null)
  32. {
  33. Item = new PerformanceItem();
  34. }
  35. else
  36. {
  37. Item = item;
  38. }
  39. AppealRecord.ItemId = Item.Id;
  40. AppealRecord.State = 0;
  41. if (AppealType != null)
  42. {
  43. inputFieldValues = new List<InputFieldValue>();
  44. inputFields =await _atService.GetInputFields(AppealType.Id, 0);
  45. foreach (var field in inputFields)
  46. {
  47. if (!string.IsNullOrEmpty(field.MapObjectField) && !string.IsNullOrEmpty(field.MapObjectFieldLabel))
  48. {
  49. List<InputFieldValue> temValues = new List<InputFieldValue>();
  50. string[] pList = field.MapObjectField.Split(new char[] { '.'});
  51. string[] plList = field.MapObjectFieldLabel.Split(new char[] { '.' });
  52. var pInfo = Item.GetType().GetProperty(pList[0]);
  53. var o = pInfo.GetValue(item);
  54. if (Array.IndexOf(o.GetType().GetInterfaces(), typeof(IEnumerable)) > -1)
  55. {
  56. List<string> Values = new List<string>();
  57. List<string> Labels = new List<string>();
  58. var objList = o as IEnumerable;
  59. foreach (var obj in objList)
  60. {
  61. var objValue = obj;
  62. var objLabel = obj;
  63. for (int i = 1; i < pList.Length; i++)
  64. {
  65. objValue = objValue.GetType().GetProperty(pList[i]).GetValue(objValue);
  66. }
  67. for (int i = 1; i < plList.Length; i++)
  68. {
  69. objLabel = objLabel.GetType().GetProperty(plList[i]).GetValue(objLabel);
  70. }
  71. var fValue = new InputFieldValue();
  72. fValue.InputField = field;
  73. fValue.InputFieldId = field.Id;
  74. fValue.Label = objLabel.ToString();
  75. if (objValue != null)
  76. {
  77. fValue.Value = objValue.ToString();
  78. }
  79. inputFieldValues.Add(fValue);
  80. temValues.Add(fValue);
  81. }
  82. }
  83. else
  84. {
  85. var fValue = new InputFieldValue();
  86. fValue.InputField = field;
  87. fValue.InputFieldId = field.Id;
  88. inputFieldValues.Add(fValue);
  89. }
  90. }
  91. else
  92. {
  93. var fValue = new InputFieldValue();
  94. fValue.InputField = field;
  95. fValue.InputFieldId = field.Id;
  96. inputFieldValues.Add(fValue);
  97. }
  98. }
  99. }
  100. }
  101. }
  102. }