From 321b01f949f4c4b44b0c2d43539af900fecc5a07 Mon Sep 17 00:00:00 2001
From: fengyuan_yang <1976974459@qq.com>
Date: Mon, 13 Apr 2026 17:14:45 +0800
Subject: [PATCH] =?UTF-8?q?2026-04-13=20=E7=B3=BB=E7=BB=9F=E8=8F=9C?=
=?UTF-8?q?=E5=8D=95=E8=AE=BE=E7=BD=AE=E9=A1=B5=E9=9D=A2=E5=9C=A8=E3=80=90?=
=?UTF-8?q?=E6=B7=BB=E5=8A=A0=E3=80=91=E5=AF=B9=E8=AF=9D=E6=A1=86=E4=B8=AD?=
=?UTF-8?q?=EF=BC=9A=201=E3=80=81=E2=80=9C=E4=B8=8A=E7=BA=A7=E8=8F=9C?=
=?UTF-8?q?=E5=8D=95=E2=80=9D=E7=A7=BB=E5=88=B0=E6=9C=80=E4=B8=8A=E9=9D=A2?=
=?UTF-8?q?=EF=BC=9B=202=E3=80=81=E6=A0=B9=E6=8D=AE=E7=94=A8=E6=88=B7?=
=?UTF-8?q?=E9=80=89=E7=9A=84=E4=B8=8A=E7=BA=A7=E8=8F=9C=E5=8D=95=E7=9A=84?=
=?UTF-8?q?menuId=E4=BD=9C=E4=B8=BAparentId=E5=8E=BB=E6=9F=A5=E6=9C=80?=
=?UTF-8?q?=E5=A4=A7=E7=9A=84menuId+1=EF=BC=8C=E8=B5=8B=E5=80=BC=E7=BB=99?=
=?UTF-8?q?=E7=9B=AE=E5=BD=95=E7=BC=96=E7=A0=81=EF=BC=9B=203=E3=80=81?=
=?UTF-8?q?=E2=80=9C=E7=9B=AE=E5=BD=95=E7=BC=96=E7=A0=81=E2=80=9D=E4=B8=8D?=
=?UTF-8?q?=E5=85=81=E8=AE=B8=E6=9C=89=E5=85=B6=E5=AE=83=E5=AD=97=E7=AC=A6?=
=?UTF-8?q?=EF=BC=8C=E5=BF=85=E9=A1=BB=E6=98=AF=E7=BA=AF=E6=95=B0=E5=AD=97?=
=?UTF-8?q?=E7=BB=84=E6=88=90=EF=BC=9B?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
src/views/modules/sys/menu-add-or-update.vue | 29 ++++++++++++++++----
1 file changed, 23 insertions(+), 6 deletions(-)
diff --git a/src/views/modules/sys/menu-add-or-update.vue b/src/views/modules/sys/menu-add-or-update.vue
index c66207c..ed04724 100644
--- a/src/views/modules/sys/menu-add-or-update.vue
+++ b/src/views/modules/sys/menu-add-or-update.vue
@@ -11,12 +11,6 @@
{{ type }}
-
-
-
-
-
-
+
+
+
+
+
+
@@ -119,6 +119,10 @@
typeName:'名称'
},
dataRule: {
+ menuId: [
+ { required: true, message: '目录编号不能为空', trigger: 'blur' },
+ { pattern: /^\d+$/, message: '目录编号必须是纯数字', trigger: 'blur' }
+ ],
name: [
{ required: true, message: '菜单名称不能为空', trigger: 'blur' }
],
@@ -154,6 +158,7 @@
code:'编号'
},
menuList: [],
+ flatMenuList: [],
menuListTreeProps: {
label: 'name',
children: 'children'
@@ -172,6 +177,7 @@
method: 'get',
params: this.$http.adornParams()
}).then(({data}) => {
+ this.flatMenuList = data.menuList || []
this.menuList = treeDataTranslate(data.menuList, 'menuId')
}).then(() => {
this.visible = true
@@ -224,6 +230,17 @@
this.dataForm.parentId = data.menuId
this.dataForm.parentName = data.name
this.treeVisible = false
+
+ // 在添加时,根据用户选的上级菜单的menuId作为parentId去查最大的menuId+1,赋值给目录编码
+ if (!this.dataForm.id) {
+ let children = this.flatMenuList.filter(item => item.parentId === data.menuId)
+ if (children.length > 0) {
+ let maxId = Math.max(...children.map(item => Number(item.menuId)))
+ this.dataForm.menuId = String(maxId + 1)
+ } else {
+ this.dataForm.menuId = String(data.menuId) + '01'
+ }
+ }
},
// 菜单树设置当前选中节点
menuListTreeSetCurrentNode () {