Bläddra i källkod

chore: 拆分字典中的枚举与字典

喵你个旺呀 1 år sedan
förälder
incheckning
e9cd0b2b4d

+ 1 - 1
Admin.NET/Admin.NET.Core/SeedData/SysDictDataSeedData.cs

@@ -22,7 +22,7 @@ public class SysDictDataSeedData : ISqlSugarEntitySeedData<SysDictData>
             new SysDictData{ Id=1300000000101, DictTypeId=1300000000101, Value="输入框", Code="Input", OrderNo=100, Remark="输入框", Status=StatusEnum.Enable, CreateTime=DateTime.Parse("2022-02-10 00:00:00") },
             new SysDictData{ Id=1300000000102, DictTypeId=1300000000101, Value="外键", Code="fk", OrderNo=100, Remark="外键", Status=StatusEnum.Enable, CreateTime=DateTime.Parse("2022-02-10 00:00:00") },
             new SysDictData{ Id=1300000000103, DictTypeId=1300000000101, Value="时间选择", Code="DatePicker", OrderNo=100, Remark="时间选择", Status=StatusEnum.Enable, CreateTime=DateTime.Parse("2022-02-10 00:00:00") },
-            new SysDictData{ Id=1300000000104, DictTypeId=1300000000101, Value="选择器", Code="Select", OrderNo=100, Remark="选择器", Status=StatusEnum.Enable, CreateTime=DateTime.Parse("2022-02-10 00:00:00") },
+            new SysDictData{ Id=1300000000104, DictTypeId=1300000000101, Value="字典选择器", Code="Select", OrderNo=100, Remark="字典选择器", Status=StatusEnum.Enable, CreateTime=DateTime.Parse("2022-02-10 00:00:00") },
             new SysDictData{ Id=1300000000105, DictTypeId=1300000000101, Value="数字输入框", Code="InputNumber", OrderNo=100, Remark="数字输入框", Status=StatusEnum.Enable, CreateTime=DateTime.Parse("2022-02-10 00:00:00") },
             new SysDictData{ Id=1300000000106, DictTypeId=1300000000101, Value="文本域", Code="InputTextArea", OrderNo=100, Remark="文本域", Status=StatusEnum.Enable, CreateTime=DateTime.Parse("2022-02-10 00:00:00") },
             new SysDictData{ Id=1300000000107, DictTypeId=1300000000101, Value="上传", Code="Upload", OrderNo=100, Remark="上传", Status=StatusEnum.Enable, CreateTime=DateTime.Parse("2022-02-10 00:00:00") },

+ 7 - 11
Admin.NET/Admin.NET.Web.Entry/wwwroot/template/index.vue.vm

@@ -162,14 +162,14 @@
         else if(@column.EffectType == "Select"){
           @:<el-table-column prop="@column.LowerPropertyName" label="@column.ColumnComment" @(column.WhetherSortable == "Y" ? "sortable='custom'" : "") show-overflow-tooltip="" >
             @:<template #default="scope">
-              @:<el-tag :type="di('@(@column.DictTypeCode)', scope.row.@(@column.LowerPropertyName))?.tagType"> {{di("@(@column.DictTypeCode)", scope.row.@(@column.LowerPropertyName))?.value}} </el-tag>
+              @:<dict-label :value="scope.row.@column.LowerPropertyName" code="@column.DictTypeCode" prop-label="value" prop-value="code" />
             @:</template>
           @:</el-table-column>
         }
         else if(@column.EffectType == "EnumSelector"){
           @:<el-table-column prop="@column.LowerPropertyName" label="@column.ColumnComment" @(column.WhetherSortable == "Y" ? "sortable='custom'" : "") show-overflow-tooltip="" >
             @:<template #default="scope">
-              @:<el-tag :type="dv('@(@column.DictTypeCode)', scope.row.@(@column.LowerPropertyName))?.tagType"> {{dv('@(@column.DictTypeCode)', scope.row.@column.LowerPropertyName)?.name}}</el-tag>
+              @:<dict-label :value="scope.row.@column.LowerPropertyName" code="@column.DictTypeCode"/>
             @:</template>
           @:</el-table-column>
         }
@@ -228,10 +228,7 @@
   @:import { codeToName, getConstType } from "/@@/utils/constHelper";
   } 
   @if(@Model.TableField.Any(x=>x.EffectType == "Select") || @Model.TableField.Any(x=>x.EffectType == "EnumSelector")){
-  @:import { getDictDataItem as di, getDictDataList as dl } from '/@@/utils/dict-utils';
-  }
-  @if(@Model.TableField.Any(x=>x.EffectType == "EnumSelector")){
-  @:import { getDictLabelByVal as dv } from '/@@/utils/dict-utils';
+  @:import { getDictDataList as dl } from '/@@/utils/dict-utils';
   }
   @if(@Model.TableField.Any(x=>x.EffectType == "DatePicker")){
   @:import { formatDate } from '/@@/utils/formatTime';
@@ -244,6 +241,9 @@
   @:import { SysPrint } from '/@@/api-services/models';
   }
 
+  @if(@Model.TableField.Any(x=>x.EffectType == "EnumSelector" || x.EffectType == "Select")){
+  @:import { DictLabel } from "/@@/components/table/dictLabel.vue";
+  }
   import printDialog from '/@@/views/system/print/component/hiprint/preview.vue'
   import editDialog from '/@@/views/@(@Model.PagePath)/@(@Model.LowerClassName)/component/editDialog.vue'
   import { page@(@Model.ClassName), delete@(@Model.ClassName) } from '/@@/api/@(@Model.PagePath)/@(@Model.LowerClassName)';
@@ -256,10 +256,6 @@
   @:import { get@(@column.FkEntityName)@(@column.PropertyName)Dropdown } from '/@@/api/@(@Model.PagePath)/@(@Model.LowerClassName)';
   }
   }
-  @if(@Model.QueryWhetherList.Any(x=>x.EffectType == "EnumSelector")){
-	@:import { SysEnumApi } from '/@@/api-services/api';
-  @:import commonFunction from '/@@/utils/commonFunction';
-	}
 
   @if(haveLikeCdt){
   @:const showAdvanceQueryUI = ref(false);
@@ -284,7 +280,7 @@
   });
 
   const print@(@Model.ClassName)Title = ref("");
-  const edit@(@Model.ClassName)Title = ref("");
+  const edit@(@Model.ClassName)Title = ref("")
 
   // 改变高级查询的控件显示状态
   const changeAdvanceQueryUI = () => {

+ 10 - 3
Web/src/views/system/codeGen/component/genConfigDialog.vue

@@ -36,7 +36,14 @@
 				<el-table-column prop="dictTypeCode" label="字典" width="180" show-overflow-tooltip>
 					<template #default="scope">
 						<el-select v-model="scope.row.dictTypeCode" class="m-2" :disabled="effectTypeEnable(scope.row)">
-							<el-option v-for="item in state.dictTypeCodeList" :key="item.code" :label="item.name" :value="item.code" />
+							<el-option
+							v-for="item in scope.row.effectType == 'Select' ? state.dictDataAll :
+								scope.row.effectType == 'EnumSelector' ? state.allEnumSelector :
+								scope.row.effectType == 'ConstSelector' ? allConstSelector :
+								state.dictTypeCodeList" 
+							:key="item.code"
+							:label="item.name" 
+							:value="item.code" />
 						</el-select>
 					</template>
 				</el-table-column>
@@ -130,8 +137,8 @@ onMounted(async () => {
 	state.effectTypeList = res.data.result;
 
 	var res1 = await getAPI(SysDictTypeApi).apiSysDictTypeListGet();
-	state.dictTypeCodeList = res1.data.result;
-	state.dictDataAll = res1.data.result;
+	state.dictTypeCodeList = res1.data.result.filter(x => !x.code.endsWith("Enum"));
+	state.dictDataAll = state.dictTypeCodeList;
 
 	var res2 = await getAPI(SysDictDataApi).apiSysDictDataDataListCodeGet('code_gen_query_type');
 	state.queryTypeList = res2.data.result;