Просмотр исходного кода

!1126 增加代码生成菜单图标选择
Merge pull request !1126 from IMaster/N/A

zuohuaijun 1 год назад
Родитель
Сommit
158e23bd2a

+ 7 - 1
Admin.NET/Admin.NET.Core/Entity/SysCodeGen.cs

@@ -1,4 +1,4 @@
-// Admin.NET 项目的版权、商标、专利和其他相关权利均受相应法律法规的保护。使用本项目应遵守相关法律法规和许可证的要求。
+// Admin.NET 项目的版权、商标、专利和其他相关权利均受相应法律法规的保护。使用本项目应遵守相关法律法规和许可证的要求。
 //
 // 本项目主要遵循 MIT 许可证和 Apache 许可证(版本 2.0)进行分发和使用。许可证位于源代码树根目录中的 LICENSE-MIT 和 LICENSE-APACHE 文件。
 //
@@ -92,6 +92,12 @@ public partial class SysCodeGen : EntityBase
     public bool GenerateMenu { get; set; } = true;
 
     /// <summary>
+    /// 菜单图标
+    /// </summary>
+    [SugarColumn(ColumnDescription = "菜单图标", Length = 32)]
+    public string MenuIcon { get; set; } = "ele-Menu";
+
+    /// <summary>
     /// 菜单编码
     /// </summary>
     [SugarColumn(ColumnDescription = "菜单编码")]

+ 3 - 2
Admin.NET/Admin.NET.Core/Service/CodeGen/SysCodeGenService.cs

@@ -361,7 +361,7 @@ public class SysCodeGenService : IDynamicApiController, ITransient
             File.WriteAllText(targetPathList[i], tResult, Encoding.UTF8);
         }
         if (input.GenerateMenu)
-            await AddMenu(input.TableName, input.BusName, input.MenuPid ?? 0, tableFieldList);
+            await AddMenu(input.TableName, input.BusName, input.MenuPid ?? 0, input.MenuIcon, tableFieldList);
         // 非ZIP压缩返回空
         if (!input.GenerateType.StartsWith('1'))
             return null;
@@ -408,7 +408,7 @@ public class SysCodeGenService : IDynamicApiController, ITransient
     /// <param name="pid"></param>
     /// <param name="tableFieldList"></param>
     /// <returns></returns>
-    private async Task AddMenu(string className, string busName, long pid, List<CodeGenConfig> tableFieldList)
+    private async Task AddMenu(string className, string busName, long pid, string menuIcon, List<CodeGenConfig> tableFieldList)
     {
         var pPath = string.Empty;
         // 若 pid=0 为顶级则创建菜单目录
@@ -454,6 +454,7 @@ public class SysCodeGenService : IDynamicApiController, ITransient
             Title = busName + "管理",
             Name = className[..1].ToLower() + className[1..],
             Type = MenuTypeEnum.Menu,
+            Icon = menuIcon,
             Path = pPath + "/" + className.ToLower(),
             Component = "/main/" + className[..1].ToLower() + className[1..] + "/index",
         };

+ 20 - 2
Web/src/views/system/codeGen/component/editCodeGenDialog.vue

@@ -73,6 +73,11 @@
 						</el-form-item>
 					</el-col>
 					<el-col :xs="24" :sm="12" :md="12" :lg="12" :xl="12" class="mb20">
+						<el-form-item label="菜单图标" prop="menuIcon">
+							<IconSelector v-model="state.ruleForm.menuIcon" :size="getGlobalComponentSize" placeholder="菜单图标" type="all" />
+						</el-form-item>
+					</el-col>
+					<el-col :xs="24" :sm="12" :md="12" :lg="12" :xl="12" class="mb20">
 						<el-form-item label="父级菜单" prop="menuPid">
 							<el-cascader
 								:options="state.menuData"
@@ -112,7 +117,7 @@
 					</el-col>
 					<el-col :xs="24" :sm="12" :md="12" :lg="12" :xl="12" class="mb20">
 						<el-form-item label="支持打印" prop="printType">
-							<el-select v-model="state.ruleForm.printType" filterable class="w100">
+							<el-select v-model="state.ruleForm.printType" filterable class="w100" @change="printTypeChanged" >
 								<el-option v-for="item in state.printTypeList" :key="item.value" :label="item.value" :value="item.code" />
 							</el-select>
 						</el-form-item>
@@ -137,7 +142,9 @@
 </template>
 
 <script lang="ts" setup name="sysEditCodeGen">
-import { onMounted, reactive, ref } from 'vue';
+import { computed, onMounted, reactive, ref } from 'vue';
+import IconSelector from '/@/components/iconSelector/index.vue';
+import other from '/@/utils/other';
 
 import { getAPI } from '/@/utils/axios-utils';
 import { SysCodeGenApi, SysDictDataApi, SysMenuApi, SysPrintApi } from '/@/api-services/api';
@@ -198,6 +205,17 @@ const tableChanged = (item: any) => {
 	state.ruleForm.busName = item.tableComment;
 };
 
+// print改变
+const printTypeChanged = () => {
+	if (state.ruleForm.printType === '') return;
+	if (state.ruleForm.printType == 'off') state.ruleForm.printName = '';
+};
+
+// 获取全局组件大小
+const getGlobalComponentSize = computed(() => {
+	return other.globalComponentSize();
+});
+
 // 打开弹窗
 const openDialog = (row: any) => {
 	state.ruleForm = JSON.parse(JSON.stringify(row));