1
huangxiaoqiang
2025-10-21 6c663b92b0078aa89657df22ec188dff65599f04
项目代码/WMS/WIDESEA_WMSServer/WIDESEA_WMSServer/Controllers/System/Sys_DictionaryController.cs
@@ -1,6 +1,7 @@
锘縰sing Newtonsoft.Json;
using System.ComponentModel;
using System.Reflection;
using WIDESEA_Common;
using WIDESEA_Core.Caches;
using WIDESEA_Core.Enums;
@@ -340,6 +341,152 @@
                        result = new VueDictionaryDTO { DicNo = key, Config = "", Data = data };
                    }
                    break;
                case "StatusChangeType":
                    {
                        List<object> data = new List<object>();
                        #region StatusChangeTypeEnum
                        {
                            Type type = typeof(StatusChangeTypeEnum);
                            List<int> enums = Enum.GetValues(typeof(StatusChangeTypeEnum)).Cast<int>().ToList();
                            int index = 0;
                            foreach (var item in enums)
                            {
                                FieldInfo? fieldInfo = typeof(StatusChangeTypeEnum).GetField(((StatusChangeTypeEnum)item).ToString());
                                DescriptionAttribute? description = fieldInfo.GetCustomAttribute<DescriptionAttribute>();
                                if (description != null)
                                {
                                    data.Add(new { key = item.ToString(), value = description.Description });
                                }
                                else
                                {
                                    data.Add(new { key = item.ToString(), value = item.ToString() });
                                }
                                index++;
                            }
                        }
                        #endregion
                        result = new VueDictionaryDTO { DicNo = key, Config = "", Data = data };
                    }
                    break;
                case "operateTypeEnum":
                    {
                        List<object> data = new List<object>();
                        #region operateTypeEnum
                        {
                            Type type = typeof(OperateTypeEnum);
                            List<int> enums = Enum.GetValues(typeof(OperateTypeEnum)).Cast<int>().ToList();
                            int index = 0;
                            foreach (var item in enums)
                            {
                                FieldInfo? fieldInfo = typeof(OperateTypeEnum).GetField(((OperateTypeEnum)item).ToString());
                                DescriptionAttribute? description = fieldInfo.GetCustomAttribute<DescriptionAttribute>();
                                if (description != null)
                                {
                                    data.Add(new { key = item.ToString(), value = description.Description });
                                }
                                else
                                {
                                    data.Add(new { key = item.ToString(), value = item.ToString() });
                                }
                                index++;
                            }
                        }
                        #endregion
                        result = new VueDictionaryDTO { DicNo = key, Config = "", Data = data };
                    }
                    break;
                case "LocationState":
                    {
                        List<object> data = new List<object>();
                        #region LocationEnum
                        {
                            Type type = typeof(LocationEnum);
                            List<int> enums = Enum.GetValues(typeof(LocationEnum)).Cast<int>().ToList();
                            int index = 0;
                            foreach (var item in enums)
                            {
                                FieldInfo? fieldInfo = typeof(LocationEnum).GetField(((LocationEnum)item).ToString());
                                DescriptionAttribute? description = fieldInfo.GetCustomAttribute<DescriptionAttribute>();
                                if (description != null)
                                {
                                    data.Add(new { key = item.ToString(), value = description.Description });
                                }
                                else
                                {
                                    data.Add(new { key = item.ToString(), value = item.ToString() });
                                }
                                index++;
                            }
                        }
                        #endregion
                        result = new VueDictionaryDTO { DicNo = key, Config = "", Data = data };
                    }
                    break;
                case "StockStateEmun":
                    {
                        List<object> data = new List<object>();
                        #region StockStateEmun
                        {
                            Type type = typeof(StockStateEmun);
                            List<int> enums = Enum.GetValues(typeof(StockStateEmun)).Cast<int>().ToList();
                            int index = 0;
                            foreach (var item in enums)
                            {
                                FieldInfo? fieldInfo = typeof(StockStateEmun).GetField(((StockStateEmun)item).ToString());
                                DescriptionAttribute? description = fieldInfo.GetCustomAttribute<DescriptionAttribute>();
                                if (description != null)
                                {
                                    data.Add(new { key = item.ToString(), value = description.Description });
                                }
                                else
                                {
                                    data.Add(new { key = item.ToString(), value = item.ToString() });
                                }
                                index++;
                            }
                        }
                        #endregion
                        result = new VueDictionaryDTO { DicNo = key, Config = "", Data = data };
                    }
                    break;
                case "EnableEnum":
                    {
                        List<object> data = new List<object>();
                        #region EnableEnum
                        {
                            Type type = typeof(EnableEnum);
                            List<int> enums = Enum.GetValues(typeof(EnableEnum)).Cast<int>().ToList();
                            int index = 0;
                            foreach (var item in enums)
                            {
                                FieldInfo? fieldInfo = typeof(EnableEnum).GetField(((EnableEnum)item).ToString());
                                DescriptionAttribute? description = fieldInfo.GetCustomAttribute<DescriptionAttribute>();
                                if (description != null)
                                {
                                    data.Add(new { key = item.ToString(), value = description.Description });
                                }
                                else
                                {
                                    data.Add(new { key = item.ToString(), value = item.ToString() });
                                }
                                index++;
                            }
                        }
                        #endregion
                        result = new VueDictionaryDTO { DicNo = key, Config = "", Data = data };
                    }
                    break;
            }
            return result;
        }