From 08cf048bde66d53af9d4dad43a76abf754b62193 Mon Sep 17 00:00:00 2001
From: zjf <1799650030@qq.com>
Date: Mon, 20 Oct 2025 17:03:08 +0800
Subject: [PATCH] =?UTF-8?q?=E8=B6=85=E5=B8=82=E6=8A=A5=E8=A1=A8?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.editorconfig | 37 ++-------
.gitattributes | 49 ++---------
.gitignore | 64 ++++++++------
src/views/admin/system/menu/index.vue | 83 +++++++++++++++++--
.../jsxs/components/ProductRankingTable.vue | 1 +
.../report/jsxs/components/SalesChart.vue | 1 +
.../report/jsxs/components/SummaryCard.vue | 1 +
.../report/jsxs/components/index.ts | 1 +
.../report/jsxs/constants/index.ts | 1 +
.../supermarketerp/report/jsxs/utils/index.ts | 1 +
src/views/supermarketerp/report/jxc/FLOW.md | 1 +
src/views/supermarketerp/report/jxc/README.md | 1 +
12 files changed, 140 insertions(+), 101 deletions(-)
diff --git a/.editorconfig b/.editorconfig
index 40cb7d5c..81e23358 100644
--- a/.editorconfig
+++ b/.editorconfig
@@ -1,38 +1,15 @@
-# EditorConfig is awesome: https://EditorConfig.org
-
-# 表示是最顶层的配置文件
root = true
-# 对所有文件生效
[*]
charset = utf-8
end_of_line = lf
-insert_final_newline = true
-trim_trailing_whitespace = true
-
-# 对 JS、TS、Vue 文件的配置
-[*.{js,jsx,ts,tsx,vue}]
-indent_style = tab
-indent_size = 2
-
-# 对 JSON、YAML 文件的配置
-[*.{json,yml,yaml}]
-indent_style = tab
-indent_size = 2
-
-# 对 Markdown 文件的配置
-[*.md]
+insert_final_newline = false
trim_trailing_whitespace = false
+indent_style = space
+indent_size = 2
+[*.{js,ts,vue,json}]
+indent_size = 2
-
-
-
-
-
-
-
-
-
-
-
+[*.md]
+trim_trailing_whitespace = false
\ No newline at end of file
diff --git a/.gitattributes b/.gitattributes
index d7de1a23..a56dfc61 100644
--- a/.gitattributes
+++ b/.gitattributes
@@ -1,45 +1,12 @@
-# 设置默认行为,以防人们没有设置 core.autocrlf
-* text=auto
-
-# 明确声明你想要始终规范化并在检出时转换为原生行结束符的文本文件
-*.vue text eol=lf
+# 禁用行尾转换
+* text=auto eol=lf
*.js text eol=lf
*.ts text eol=lf
-*.jsx text eol=lf
-*.tsx text eol=lf
+*.vue text eol=lf
*.json text eol=lf
-*.css text eol=lf
-*.scss text eol=lf
-*.sass text eol=lf
-*.html text eol=lf
-*.htm text eol=lf
-*.xml text eol=lf
-*.md text eol=lf
-*.yml text eol=lf
-*.yaml text eol=lf
-
-# 明确声明你不想规范化并希望原样保留的文件
-*.png binary
-*.jpg binary
-*.jpeg binary
-*.gif binary
-*.ico binary
-*.svg binary
-*.eot binary
-*.ttf binary
-*.woff binary
-*.woff2 binary
-*.otf binary
-
-
-
-
-
-
-
-
-
-
-
-
+# 禁用空白行处理
+*.js -whitespace
+*.ts -whitespace
+*.vue -whitespace
+*.json -whitespace
\ No newline at end of file
diff --git a/.gitignore b/.gitignore
index e5d97f37..30119dd5 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,34 +1,48 @@
-.DS_Store
-node_modules
-/dist
-docker/dist
+# Cursor
+.cursor/
+.cursorrules
+.cursorignore
+# IDE
+.vscode/
+.idea/
-# local env files
-.env
-.env.development
-.env.prod
-.env.dev-local
-.env.*.local
+# 临时文件
+*.tmp
+*.temp
-# Log files
+# 日志文件
+*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
-pnpm-debug.log*
-# Editor directories and files
-.idea
-.vscode
-*.suo
-*.ntvs*
-*.njsproj
-*.sln
-*.sw?
+# 依赖目录
+node_modules/
+.pnpm-store/
-# lock
-package-lock.json
-yarn.lock
-pnpm-lock.yaml
+# 构建输出
+dist/
+build/
-.env.development
+.env.local
+.env.development.local
+.env.test.local
+
+
+# 操作系统文件
+.DS_Store
+Thumbs.db
+
+# 编辑器文件
+*.swp
+*.swo
+*~
+
+# 测试覆盖率
+coverage/
+.nyc_output/
+
+# 缓存文件
+.cache/
+.parcel-cache/
\ No newline at end of file
diff --git a/src/views/admin/system/menu/index.vue b/src/views/admin/system/menu/index.vue
index e7a84d98..1c44795d 100644
--- a/src/views/admin/system/menu/index.vue
+++ b/src/views/admin/system/menu/index.vue
@@ -40,6 +40,7 @@
lazy
:load="load"
:tree-props="{ children: 'children', hasChildren: 'hasChildren' }"
+ @expand-change="handleExpandChange"
>
@@ -107,6 +108,8 @@ const tableRef = ref()
const menuDialogRef = ref()
const showSearch = ref(true)
const queryRef = ref()
+// 保存已展开的节点ID
+const expandedRowIds = ref>(new Set())
const state: BasicTableProps = reactive({
createdIsNeed: false,
pageList: pageList,
@@ -136,6 +139,10 @@ const expandRowKeys = computed(() => {
// 打开新增菜单弹窗
const onOpenAddMenu = (type?: string, row?: any) => {
+ // 如果是添加子菜单,记录父节点ID,以便刷新后自动展开
+ if (row && row.id) {
+ expandedRowIds.value.add(row.id)
+ }
menuDialogRef.value.openDialog(type, row)
}
// 打开编辑菜单弹窗
@@ -149,11 +156,24 @@ const deleteMenuDisabled = (row: any) => {
}
// 清空搜索条件
-const resetQuery = () => {
+const resetQuery = async () => {
queryRef.value.resetFields()
state.queryForm.parentId = "-1"
state.dataList = []
- getDataList()
+ await getDataList()
+ // 恢复展开状态
+ await restoreExpandedRows()
+}
+
+// 监听展开/折叠事件
+const handleExpandChange = (row: any, expanded: boolean) => {
+ if (expanded) {
+ // 展开时记录
+ expandedRowIds.value.add(row.id)
+ } else {
+ // 折叠时移除
+ expandedRowIds.value.delete(row.id)
+ }
}
const load = (row: any, treeNode: unknown, resolve: (date: any[]) => void) => {
@@ -186,15 +206,64 @@ const tableList = computed(() => {
return list
})
-const query = () => {
+// 恢复展开状态(支持多级展开)
+const restoreExpandedRows = async () => {
+ await nextTick()
+ if (!tableRef.value || expandedRowIds.value.size === 0) return
+
+ // 递归加载并展开节点
+ const loadAndExpandRows = async (list: any[]) => {
+ for (const row of list || []) {
+ if (expandedRowIds.value.has(row.id)) {
+ // 如果节点有子节点且未加载,先加载子节点
+ if (row.hasChildren && (!row.children || row.children.length === 0)) {
+ try {
+ const res = await pageList({ parentId: row.id })
+ const childrenList = res.data
+ if (Array.isArray(childrenList) && childrenList.length > 0) {
+ setHasChildren(childrenList)
+ row.children = childrenList
+ }
+ } catch (error) {
+ console.error('加载子节点失败:', error)
+ }
+ }
+
+ // 展开该节点
+ try {
+ tableRef.value.toggleRowExpansion(row, true)
+ // 等待 DOM 更新,确保子节点渲染完成
+ await nextTick()
+ } catch (error) {
+ console.error('展开节点失败:', error)
+ }
+
+ // 如果有子节点,递归处理
+ if (row.children && row.children.length > 0) {
+ await loadAndExpandRows(row.children)
+ }
+ }
+ }
+ }
+
+ await loadAndExpandRows(state.dataList)
+}
+
+const query = async () => {
state.dataList = []
if (state.queryForm.menuName) {
state.queryForm.parentId = ""
+ // 搜索时清空展开记录
+ expandedRowIds.value.clear()
} else {
state.queryForm.parentId = "-1"
}
- getDataList()
+ await getDataList()
+ // 刷新后恢复展开状态
+ if (!state.queryForm.menuName) {
+ await restoreExpandedRows()
+ }
}
// 删除操作
const handleDelete = async (row: any) => {
@@ -206,7 +275,11 @@ const handleDelete = async (row: any) => {
try {
await delObj(row.id)
- getDataList()
+ // 删除后刷新数据
+ state.dataList = []
+ await getDataList()
+ // 恢复展开状态
+ await restoreExpandedRows()
useMessage().success(t("common.delSuccessText"))
} catch (err: any) {
useMessage().error(err.msg)
diff --git a/src/views/supermarketerp/report/jsxs/components/ProductRankingTable.vue b/src/views/supermarketerp/report/jsxs/components/ProductRankingTable.vue
index 5848b78a..fe2491fa 100644
--- a/src/views/supermarketerp/report/jsxs/components/ProductRankingTable.vue
+++ b/src/views/supermarketerp/report/jsxs/components/ProductRankingTable.vue
@@ -353,3 +353,4 @@ const handleCurrentChange = (page: number) => {
+
diff --git a/src/views/supermarketerp/report/jsxs/components/SalesChart.vue b/src/views/supermarketerp/report/jsxs/components/SalesChart.vue
index 133b7dbb..fcb8a1ee 100644
--- a/src/views/supermarketerp/report/jsxs/components/SalesChart.vue
+++ b/src/views/supermarketerp/report/jsxs/components/SalesChart.vue
@@ -203,3 +203,4 @@ defineExpose({
+
diff --git a/src/views/supermarketerp/report/jsxs/components/SummaryCard.vue b/src/views/supermarketerp/report/jsxs/components/SummaryCard.vue
index aeb3dda9..6fa56fae 100644
--- a/src/views/supermarketerp/report/jsxs/components/SummaryCard.vue
+++ b/src/views/supermarketerp/report/jsxs/components/SummaryCard.vue
@@ -219,3 +219,4 @@ const trendClass = computed(() => {
+
diff --git a/src/views/supermarketerp/report/jsxs/components/index.ts b/src/views/supermarketerp/report/jsxs/components/index.ts
index 912b0484..24690fab 100644
--- a/src/views/supermarketerp/report/jsxs/components/index.ts
+++ b/src/views/supermarketerp/report/jsxs/components/index.ts
@@ -24,3 +24,4 @@ export { default as ProductRankingTable } from './ProductRankingTable.vue';
+
diff --git a/src/views/supermarketerp/report/jsxs/constants/index.ts b/src/views/supermarketerp/report/jsxs/constants/index.ts
index 0a2db5be..7e3de217 100644
--- a/src/views/supermarketerp/report/jsxs/constants/index.ts
+++ b/src/views/supermarketerp/report/jsxs/constants/index.ts
@@ -224,3 +224,4 @@ export const SUCCESS_MESSAGES = {
+
diff --git a/src/views/supermarketerp/report/jsxs/utils/index.ts b/src/views/supermarketerp/report/jsxs/utils/index.ts
index d0d954ca..edf6d8db 100644
--- a/src/views/supermarketerp/report/jsxs/utils/index.ts
+++ b/src/views/supermarketerp/report/jsxs/utils/index.ts
@@ -213,3 +213,4 @@ export const TABLE_CONFIG = {
+
diff --git a/src/views/supermarketerp/report/jxc/FLOW.md b/src/views/supermarketerp/report/jxc/FLOW.md
index f24c9ae0..ad791b96 100644
--- a/src/views/supermarketerp/report/jxc/FLOW.md
+++ b/src/views/supermarketerp/report/jxc/FLOW.md
@@ -140,3 +140,4 @@ API调用失败
+
diff --git a/src/views/supermarketerp/report/jxc/README.md b/src/views/supermarketerp/report/jxc/README.md
index 94de970d..27e09c50 100644
--- a/src/views/supermarketerp/report/jxc/README.md
+++ b/src/views/supermarketerp/report/jxc/README.md
@@ -132,3 +132,4 @@ exportInventoryInOutExcel(params)
+