123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117 |
- using AntDesign;
- using Microsoft.AspNetCore.Components;
- using System;
- using System.Collections;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text.Json;
- using System.Threading.Tasks;
- using wispro.sp.entity;
- using wispro.sp.web.Services;
- namespace wispro.sp.web.Models
- {
- public class CreateAppealModel
- {
- public PerformanceItem Item { get; set; }
- public AppealType AppealType { get; set; }
- public List<InputField> inputFields { get; set; }
- public List<InputFieldValue> inputFieldValues { get; set; }
- public AppealRecord AppealRecord { get; set; }
- public List<UploadFileItem> FileList { get; set; }
- //public System.Collections.Hashtable _GroupInputValues { get; set; }
- //public List<InputFieldValue> noMultiValues { get; set; }
-
- public CreateAppealModel() { }
- public async Task Init(AppealTypeService _atService,PerformanceItem item,AppealType appealType)
- {
- FileList = new List<UploadFileItem>();
- Item = item;
- AppealType = appealType;
- AppealRecord = new AppealRecord();
- AppealRecord.TypeId = appealType.Id;
- AppealRecord.ItemId = item.Id;
- AppealRecord.State = 0;
- if (AppealType != null)
- {
- inputFieldValues = new List<InputFieldValue>();
- inputFields =await _atService.GetInputFields(AppealType.Id, 0);
- foreach (var field in inputFields)
- {
- if (!string.IsNullOrEmpty(field.MapObjectField) && !string.IsNullOrEmpty(field.MapObjectFieldLabel))
- {
- List<InputFieldValue> temValues = new List<InputFieldValue>();
- string[] pList = field.MapObjectField.Split(new char[] { '.'});
- string[] plList = field.MapObjectFieldLabel.Split(new char[] { '.' });
- var pInfo = Item.GetType().GetProperty(pList[0]);
- var o = pInfo.GetValue(item);
- if (Array.IndexOf(o.GetType().GetInterfaces(), typeof(IEnumerable)) > -1)
- {
- List<string> Values = new List<string>();
- List<string> Labels = new List<string>();
- var objList = o as IEnumerable;
- foreach (var obj in objList)
- {
- var objValue = obj;
- var objLabel = obj;
- for (int i = 1; i < pList.Length; i++)
- {
- objValue = objValue.GetType().GetProperty(pList[i]).GetValue(objValue);
- }
- for (int i = 1; i < plList.Length; i++)
- {
- objLabel = objLabel.GetType().GetProperty(plList[i]).GetValue(objLabel);
- }
- var fValue = new InputFieldValue();
- fValue.InputField = field;
- fValue.InputFieldId = field.Id;
- fValue.Label = objLabel.ToString();
- if (objValue != null)
- {
- fValue.Value = objValue.ToString();
- }
- inputFieldValues.Add(fValue);
- temValues.Add(fValue);
- }
- }
- else
- {
- var fValue = new InputFieldValue();
- fValue.InputField = field;
- fValue.InputFieldId = field.Id;
- inputFieldValues.Add(fValue);
- }
- }
- else
- {
- var fValue = new InputFieldValue();
- fValue.InputField = field;
- fValue.InputFieldId = field.Id;
- inputFieldValues.Add(fValue);
- }
- }
- }
-
- }
-
- }
- }
|