fix(admin): 菜单管理去掉上移/下移,排序改由 sort_order 维护(产品已淘汰即时应序)
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
<script setup lang="ts">
|
||||
import { computed, onMounted, reactive, ref } from 'vue'
|
||||
import { ElMessage, ElMessageBox } from 'element-plus'
|
||||
import { createMenu, deleteMenu, loadMenuManageTree, reorderMenus, updateMenu } from './menu-manage-api'
|
||||
import { createMenu, deleteMenu, loadMenuManageTree, updateMenu } from './menu-manage-api'
|
||||
import {
|
||||
createMenuForm,
|
||||
flattenMenuNodes,
|
||||
@@ -10,7 +10,6 @@ import {
|
||||
menuParentChangeReason,
|
||||
menuTypeLabel,
|
||||
nextSiblingSort,
|
||||
siblingOrderAfterMove,
|
||||
validateMenuManageForm,
|
||||
type MenuManageForm,
|
||||
type MenuManageNode,
|
||||
@@ -108,20 +107,6 @@ async function removeMenu(node: MenuManageNode) {
|
||||
}
|
||||
}
|
||||
|
||||
/** 同级上移/下移并提交排序;到达边界则忽略。 */
|
||||
async function moveMenuRow(node: MenuManageNode, dir: -1 | 1) {
|
||||
const flat = flattenMenuNodes(rows.value)
|
||||
const group = flat.filter((n) => (n.parentId ?? null) === (node.parentId ?? null)).map((n) => n.id)
|
||||
const ordered = siblingOrderAfterMove(group, node.id, dir)
|
||||
if (ordered.join(',') === group.join(',')) return
|
||||
try {
|
||||
await reorderMenus(ordered)
|
||||
await loadMenus()
|
||||
} catch (error) {
|
||||
ElMessage.error(error instanceof Error ? error.message : '排序保存失败')
|
||||
}
|
||||
}
|
||||
|
||||
onMounted(loadMenus)
|
||||
</script>
|
||||
|
||||
@@ -150,12 +135,6 @@ onMounted(loadMenus)
|
||||
</el-table-column>
|
||||
<el-table-column prop="createdAt" label="创建时间" min-width="150" />
|
||||
<el-table-column prop="sortOrder" label="排序" width="90" />
|
||||
<el-table-column label="移动" width="130">
|
||||
<template #default="{ row }">
|
||||
<el-button link type="primary" @click="moveMenuRow(row, -1)">上移</el-button>
|
||||
<el-button link type="primary" @click="moveMenuRow(row, 1)">下移</el-button>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="操作" width="160" fixed="right">
|
||||
<template #default="{ row }">
|
||||
<el-button link type="primary" @click="openEdit(row)">编辑</el-button>
|
||||
|
||||
@@ -62,9 +62,11 @@ test('test_task_252_menus_list_invalid_input_rejected', () => {
|
||||
})
|
||||
|
||||
test('test_task_252_menus_list_dependency_failure_returns_actionable_message', () => {
|
||||
// 依赖:排序提交走 /column/reorder,失败有「排序保存失败」提示。
|
||||
// 依赖:排序能力收敛到 sort_order 字段(列表/编辑弹窗维护),页面不再提供上移/下移即时排序。
|
||||
const api = readSource('src/pages/account/menu-manage-api.ts')
|
||||
assert.match(api, /column\/reorder/, '排序走 column/reorder')
|
||||
assert.match(api, /column\/reorder/, 'adapter 仍支持 column/reorder')
|
||||
const page = readSource('src/pages/account/MenusPage.vue')
|
||||
assert.match(page, /排序保存失败/, '排序失败提示“排序保存失败”')
|
||||
assert.equal(/上移|下移/.test(page), false, '页面无上移/下移')
|
||||
assert.match(page, /menuForm\.sortOrder/, '编辑弹窗维护 sort_order')
|
||||
assert.equal(/moveMenuRow/.test(page), false, '无 moveMenuRow 残码')
|
||||
})
|
||||
|
||||
@@ -45,12 +45,14 @@ test('test_task_058_menu_sort_invalid_input_rejected', () => {
|
||||
})
|
||||
|
||||
test('test_task_058_menu_sort_dependency_failure_returns_actionable_message', () => {
|
||||
// 依赖失败/排序走 adapter:POST /column/reorder 提交 ordered_ids,页面不内联请求。
|
||||
// 依赖失败:排序走 adapter(POST /column/reorder 提交 ordered_ids),页面不内联请求;
|
||||
// 页面上移/下移已按产品决策移除,排序改由 sort_order 字段维护。
|
||||
const api = readSource('src/pages/account/menu-manage-api.ts')
|
||||
assert.match(api, /reorderMenus|reorderColumns/)
|
||||
assert.match(api, /column\/reorder/)
|
||||
assert.match(api, /ordered_ids|orderedIds/)
|
||||
const page = readSource('src/pages/account/MenusPage.vue')
|
||||
assert.match(page, /siblingOrderAfterMove|reorderMenus|reorderColumns/)
|
||||
assert.equal(/上移|下移/.test(page), false, '菜单页不再提供上移/下移按钮')
|
||||
assert.equal(/http\.post/.test(page), false, '页面不内联排序请求')
|
||||
assert.match(page, /sortOrder/, '排序通过 sort_order 字段维护')
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user