From 711765234ff5de22d76b2ac9fddcec133464d904 Mon Sep 17 00:00:00 2001 From: chenxing Date: Tue, 15 Sep 2026 18:11:18 +0800 Subject: [PATCH] =?UTF-8?q?feat(app-module):=20=E6=A8=A1=E5=9D=97=E7=AE=A1?= =?UTF-8?q?=E7=90=86=E6=96=B0=E5=A2=9E=E5=9B=BE=E6=A0=87=E5=AD=97=E6=AE=B5?= =?UTF-8?q?=E7=9A=84=E8=A1=A8=E6=A0=BC=E5=88=97=E4=B8=8E=E8=A1=A8=E5=8D=95?= =?UTF-8?q?=E8=A1=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 配合后端 app_module.icon(YschIcons 图标名,非必填): - 表格在「模块名称」后加「图标」列,有值时预览 SvgIcon 并显示图标名原文,无值显示占位 - 新增/编辑弹窗在「模块路径」后加一行「模块图标」输入框(clearable,非必填) - 回显、新增/子模块初始值、两处提交参数均已带上 icon;空串归一为不下发该字段, 后端 edit 逐字段整体赋值,故清空图标可生效 --- src/views/app/ModuleManage.vue | 32 ++++++++++++++++++++++++++++++-- 1 file changed, 30 insertions(+), 2 deletions(-) diff --git a/src/views/app/ModuleManage.vue b/src/views/app/ModuleManage.vue index 0870c4e..93d271d 100644 --- a/src/views/app/ModuleManage.vue +++ b/src/views/app/ModuleManage.vue @@ -29,6 +29,10 @@ + + + @@ -91,6 +95,24 @@ const flatData = computed(() => flattenTree(moduleList.value)); /* ---------------- 表格列 ---------------- */ const columns = [ { title: "模块名称", key: "name", minWidth: 260, slot: "name" }, + { + title: "图标", + key: "icon", + width: 170, + align: "center", + render: (h: any, { row }: any) => { + if (!row.icon) return h("span", { style: { color: "#c5c8ce" } }, "-"); + return h("div", { + style: { display: "flex", alignItems: "center", justifyContent: "center", gap: "6px" }, + title: row.icon, + }, [ + h(SvgIcon, { name: row.icon, size: 16 }), + h("span", { + style: { maxWidth: "110px", overflow: "hidden", textOverflow: "ellipsis", whiteSpace: "nowrap" }, + }, row.icon), + ]); + }, + }, { title: "ID", key: "customId", width: 120, align: "center", render: (h: any, { row }: any) => h("span", row.customId || "-") }, { title: "路径", key: "path", minWidth: 200, render: (h: any, { row }: any) => h("span", row.path || "-") }, { title: "排序号", key: "sortNo", width: 100, align: "center", render: (h: any, { row }: any) => h("span", row.sortNo ?? "-") }, @@ -123,6 +145,7 @@ const form = ref<{ id: number | null; name: string; path: string; + icon: string; customId: number | null; parentId: number | null; sortNo: number | null; @@ -130,6 +153,7 @@ const form = ref<{ id: null, name: '', path: '', + icon: '', customId: null, parentId: null, sortNo: null, @@ -177,6 +201,7 @@ function openEditModal(item: any) { f.id = item?.id ?? null; f.name = item?.name || ''; f.path = item?.path || ''; + f.icon = item?.icon || ''; f.customId = item?.customId != null ? Number(item.customId) : null; f.parentId = item?.parentId ?? null; f.sortNo = item?.sortNo != null ? Number(item.sortNo) : null; @@ -189,13 +214,13 @@ function openEditModal(item: any) { /* ---------------- 新增模块 ---------------- */ function handleAdd() { openingIsChild.value = false; - openEditModal({ id: null, name: '', path: '', customId: null, parentId: null, sortNo: null }); + openEditModal({ id: null, name: '', path: '', icon: '', customId: null, parentId: null, sortNo: null }); } /* ---------------- 新增子模块 ---------------- */ function handleAddChild(parent: any) { openingIsChild.value = true; - openEditModal({ id: null, name: '', path: '', customId: null, parentId: parent.id, sortNo: null }); + openEditModal({ id: null, name: '', path: '', icon: '', customId: null, parentId: parent.id, sortNo: null }); } /* ---------------- 编辑 ---------------- */ @@ -240,6 +265,7 @@ async function onRawSave() { appId: appId.value, name: form.value.name, path: form.value.path, + icon: form.value.icon?.trim() || undefined, customId: form.value.customId == null ? '' : String(form.value.customId), parentId: form.value.parentId ?? undefined, sortNo: form.value.sortNo == null ? undefined : Number(form.value.sortNo), @@ -253,6 +279,8 @@ async function onRawSave() { appId: appId.value, name: form.value.name, path: form.value.path, + // 后端 edit 逐字段整体赋值,字段缺省即置空 → 清空图标能生效 + icon: form.value.icon?.trim() || undefined, customId: form.value.customId == null ? '' : String(form.value.customId), parentId: form.value.parentId ?? undefined, sortNo: form.value.sortNo == null ? undefined : Number(form.value.sortNo),