feat: refine suffix management layout and column ordering

- column sort dialog: reorder via arrows (persisted via new
  POST /dirs/:id/columns/order), precise column insertion after a
  selected position (create column accepts after_id), value columns
  shown in blue text inside the dialog
- workspace cells: edit only after entering the row's 编辑 mode,
  then double-click the cell (matching legacy interaction)
- collapsible global sidebar with edge handle (state persisted);
  suffix panel directory collapses independently; independent
  scrollbars for directory and workspace; 5px gap to the sidebar
- suffix page drops the internal-console heading block and the
  内部管理台 topbar label; 退出 moves to the sidebar footer
  (same line as the admin email, 5px from the edge); brand subtitle
  统一授权管理平台 removed
- integration test covers column reorder/precise insert/dedupe
This commit is contained in:
lianjianwei2024
2026-10-30 13:20:12 +08:00
parent dd9d5470c2
commit 2d9dcba800
6 changed files with 248 additions and 13 deletions

View File

@@ -21,3 +21,14 @@
@media(max-width:1100px){.module-form.license-form{grid-template-columns:repeat(2,minmax(0,1fr))}.module-form.license-form>.el-button{grid-column:1/-1}.product-create-form,.module-account-form{grid-template-columns:repeat(2,minmax(0,1fr))}.settings-grid{grid-template-columns:minmax(0,1fr)}}
@media(max-width:900px){.customer-create-form{grid-template-columns:repeat(2,minmax(0,1fr))}.module-form>.el-button{justify-self:start}.license-toolbar{align-items:flex-start;flex-direction:column}.module-filters{width:100%}.module-filters .el-input{flex:1;width:auto}.audit-module .audit-filters{grid-template-columns:repeat(2,minmax(0,1fr))}}
@media(max-width:620px){.module-create{padding:15px}.module-settings-form>.el-button{width:100%}.integration-panel .onboarding-section{padding:15px}.integration-panel .onboarding-section ol{padding-left:18px}.module-form,.customer-create-form,.product-create-form,.module-form.license-form,.module-account-form{grid-template-columns:minmax(0,1fr);gap:13px}.module-form.license-form>.el-button,.module-account-form>.el-button{grid-column:auto;justify-self:stretch}.module-toolbar,.module-section-heading{align-items:flex-start;flex-direction:column}.module-filter,.module-filters{width:100%;align-items:stretch}.module-filter .el-input,.module-filters .el-input,.module-filters .el-select{width:100%}.module-filters{display:grid;grid-template-columns:1fr}.module-pagination{align-items:flex-start;flex-direction:column}.module-pagination .el-pagination{padding-left:0}.module-table .module-pagination{padding:0 12px 12px}.audit-module .audit-filters{grid-template-columns:minmax(0,1fr)}.module-account-form .el-form-item{margin-bottom:0}.trust-key-card{padding:12px}.license-detail{grid-template-columns:1fr;gap:6px}.license-detail dd{margin-bottom:10px}}
/* 全局侧栏折叠(决策:授权管理平台可收起隐藏) */
.admin-workspace{position:relative}
.admin-workspace.nav-collapsed .sidebar{width:0;flex-basis:0;padding:0;overflow:hidden;border-right:0}
.nav-fold{position:absolute;left:242px;top:50%;transform:translateY(-50%);z-index:40;width:20px;height:56px;border:1px solid #d8dfe8;border-left:0;border-radius:0 6px 6px 0;background:#fff;color:#526173;cursor:pointer;display:grid;place-items:center;font-size:13px}
.nav-fold:hover{color:#1769e0;border-color:#1769e0}
.admin-workspace.nav-collapsed .nav-fold{left:0;border-radius:0 6px 6px 0}
.admin-workspace .sidebar-footer{display:flex;align-items:center;gap:8px}
.footer-email{flex:1;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.side-logout{margin-left:auto;margin-right:5px;border:0;background:none;cursor:pointer;color:#96a5b6;font-size:12px;padding:2px 4px;flex:0 0 auto}
.side-logout:hover{color:#fff}
.content.content-suffix{padding-left:5px;padding-top:16px}

View File

@@ -15,7 +15,8 @@ export const renameSuffixDir = (id:number, name:string) => api.put<{data:SuffixD
export const moveSuffixDir = (id:number, dir:number) => api.post(`/suffix-admin/dirs/${id}/move`, { dir })
export const deleteSuffixDir = (id:number) => api.delete(`/suffix-admin/dirs/${id}`)
export const getSuffixPage = (id:number) => api.get<{data:SuffixPage}>(`/suffix-admin/dirs/${id}/page`)
export const createSuffixColumn = (dirId:number, name:string, is_value:boolean) => api.post<{data:SuffixColumn}>(`/suffix-admin/dirs/${dirId}/columns`, { name, is_value })
export const createSuffixColumn = (dirId:number, name:string, is_value:boolean, after_id = 0) => api.post<{data:SuffixColumn}>(`/suffix-admin/dirs/${dirId}/columns`, { name, is_value, after_id })
export const reorderSuffixColumns = (dirId:number, ids:number[]) => api.post<{data:{ok:boolean;ordered:number}}>(`/suffix-admin/dirs/${dirId}/columns/order`, { ids })
export const deleteSuffixColumn = (id:number) => api.delete(`/suffix-admin/columns/${id}`)
export const saveSuffixCell = (dir_id:number, suffix_id:number, column_id:number, value:string) => api.put('/suffix-admin/cells', { dir_id, suffix_id, column_id, value })
export const setSuffixAnchor = (dirId:number, suffix_id:number, on:boolean) => api.post(`/suffix-admin/dirs/${dirId}/anchor`, { suffix_id, on })

File diff suppressed because one or more lines are too long

View File

@@ -6,7 +6,7 @@ import {
deleteSuffix, deleteSuffixColumn, deleteSuffixDir, deleteSuffixFile, deleteSuffixGroup,
formatSuffixSize, getSuffixOverview, getSuffixPage, getSuffixTree, moveSuffix, moveSuffixDir,
moveSuffixGroup, parseValueCell, readSuffixFile, renameSuffix, renameSuffixDir,
renameSuffixGroup, saveSuffixCell, setSuffixAnchor, suffixFileUrl, uploadSuffixFile,
renameSuffixGroup, reorderSuffixColumns, saveSuffixCell, setSuffixAnchor, suffixFileUrl, uploadSuffixFile,
type SuffixColumn, type SuffixDir, type SuffixFile, type SuffixPage,
} from '../suffix-admin'
@@ -72,6 +72,11 @@ async function selectNode(sel: Selection) {
}
}
async function loadSheet() {
if (selected.value.kind !== 'dir') return
page.value = (await getSuffixPage(selected.value.id)).data.data
}
// ---- 目录树 ----
const rootDir = computed(() => dirs.value.find((d) => d.parent_id === 0 || d.parent_id === null) || null)
@@ -301,6 +306,58 @@ async function openAddColumn() {
colDialog.visible = true
}
// ---- 列排序(可调整顺序,也可精准插入新列) ----
const colOrder = reactive({ visible: false, ids: [] as number[], newName: '', newValue: false, afterId: 0, saving: false })
const valColCount = computed(() => pageColumns.value.filter((c) => c.is_value).length)
function openColOrder() {
if (selected.value.kind !== 'dir' || !page.value) return
colOrder.ids = page.value.columns.map((c) => c.id)
colOrder.newName = ''
colOrder.newValue = false
colOrder.afterId = 0
colOrder.visible = true
}
async function moveColOrder(id: number, dir: number) {
const sel = selected.value
if (sel.kind !== 'dir' || !page.value) return
const ids = colOrder.ids
const i = ids.indexOf(id)
const j = i + dir
if (i < 0 || j < 0 || j >= ids.length) return
;[ids[i], ids[j]] = [ids[j], ids[i]]
try {
await reorderSuffixColumns(sel.id, ids)
await loadSheet()
} catch (e) {
ElMessage.error(e instanceof Error ? e.message : '排序失败')
}
}
async function submitColOrder() {
if (colOrder.saving || selected.value.kind !== 'dir' || !page.value) return
const name = colOrder.newName.trim()
if (!name) {
ElMessage.warning('请填写列名')
return
}
colOrder.saving = true
try {
const afterId = colOrder.afterId || 0
const created = (await createSuffixColumn(selected.value.id, name, colOrder.newValue, afterId)).data.data
colOrder.visible = false
await loadSheet()
ElMessage.success(colOrder.newValue ? `已在列排序位置添加值列「${created.name}」` : `已添加列「${created.name}」`)
} catch (e) {
ElMessage.error(e instanceof Error ? e.message : '列创建失败')
} finally {
colOrder.saving = false
}
}
async function submitColumn() {
if (selected.value.kind !== 'dir' || colDialog.saving) return
const name = colDialog.name.trim()
@@ -346,6 +403,10 @@ function cellDisplay(sid: number, col: SuffixColumn):string {
}
function startCellEdit(sid: number, col: SuffixColumn) {
if (!editRows.value.has(sid)) {
ElMessage.warning('先点这一行的「编辑」,再双击单元格')
return
}
const raw = page.value?.cells[cellKey(sid, col.id)] || ''
const p = parseValueCell(raw)
editing.sid = sid
@@ -520,8 +581,9 @@ onMounted(() => {
<template v-else-if="page">
<div class="bar">
<strong>{{ selectedDirName }}</strong>
<span class="bar-note">点「+ 添加列」加列;勾选「值设置」的列,点单元格即可填 锚点+值。</span>
<span class="bar-note">先点这一行的「编辑」,再双击单元格修改;值列可填 锚点 / 值。</span>
<span class="grow"></span>
<el-button size="small" @click="openColOrder">列排序</el-button>
<el-button size="small" type="primary" plain @click="openAddColumn">+ 添加列</el-button>
</div>
<div v-loading="pageLoading" class="sheet-wrap">
@@ -555,7 +617,9 @@ onMounted(() => {
v-for="col in pageColumns"
:key="col.id"
class="cell"
@click="startCellEdit(row.sid, col)"
:class="{ locked: !editRows.has(row.sid) }"
@dblclick="startCellEdit(row.sid, col)"
:title="editRows.has(row.sid) ? '双击编辑' : '先点这一行的「编辑」,再双击单元格'"
>
<template v-if="editing.sid === row.sid && editing.cid === col.id">
<span class="cell-editor" @click.stop>
@@ -602,6 +666,34 @@ onMounted(() => {
<el-button type="primary" :loading="colDialog.saving" @click="submitColumn">确定</el-button>
</template>
</el-dialog>
<el-dialog v-model="colOrder.visible" title="列排序" width="480px">
<div class="col-order-hint">拖动调整列的左右顺序;值列以蓝色字体显示。也可以在这里精准添加列:填列名、勾选值设置,新列会插到选中列的后面(未选中则加到最右)。</div>
<div class="col-order-list">
<div
v-for="(cid, i) in colOrder.ids"
:key="cid"
class="col-order-row"
:class="{ selected: colOrder.afterId === cid }"
@click="colOrder.afterId = cid"
>
<span class="co-idx">{{ i + 1 }}</span>
<span class="co-name" :class="{ value: pageColumns.find((c) => c.id === cid)?.is_value }">{{ pageColumns.find((c) => c.id === cid)?.name }}</span>
<span v-if="pageColumns.find((c) => c.id === cid)?.is_value" class="co-vtag">值</span>
<span class="grow"></span>
<button type="button" class="op" :disabled="i === 0" @click.stop="moveColOrder(cid, -1)">↑</button>
<button type="button" class="op" :disabled="i === colOrder.ids.length - 1" @click.stop="moveColOrder(cid, 1)">↓</button>
</div>
</div>
<div class="col-order-add">
<el-input v-model="colOrder.newName" placeholder="新列名(精准插入到选中列之后)" maxlength="190" />
<el-checkbox v-model="colOrder.newValue">值设置</el-checkbox>
<el-button type="primary" :loading="colOrder.saving" @click="submitColOrder">添加列</el-button>
</div>
<template #footer>
<el-button @click="colOrder.visible = false">关闭</el-button>
</template>
</el-dialog>
</div>
</template>
@@ -628,6 +720,19 @@ onMounted(() => {
.bar{display:flex;align-items:center;gap:12px;padding:0 0 10px}
.bar strong{font-size:15px}
.bar-note{color:#8a97a8;font-size:12px}
/* 列排序弹框 */
.col-order-hint{color:#8a97a8;font-size:12px;margin-bottom:10px;line-height:1.6}
.col-order-list{max-height:46vh;overflow:auto;border:1px solid #e5eaf0;border-radius:6px}
.col-order-row{display:flex;align-items:center;gap:8px;padding:7px 10px;border-bottom:1px solid #eef1f5;cursor:pointer;font-size:13px}
.col-order-row:hover{background:#f7faff}
.col-order-row.selected{background:#eaf2fd}
.co-idx{flex:0 0 24px;color:#9aa7b6;font-size:12px}
.co-name{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.co-name.value{color:#1769e0;font-weight:600}
.co-vtag{font-style:normal;background:#e6f5ee;color:#16845b;border-radius:3px;font-size:10px;padding:0 4px}
.col-order-add{display:flex;align-items:center;gap:10px;margin-top:12px}
.col-order-add .el-input{flex:1}
td.cell.locked{cursor:default}
.grow{flex:1}
.sheet-wrap{border:1px solid #e5eaf0;border-radius:6px;overflow:auto;max-height:68vh;background:#fff}
.group-block{border-bottom:1px solid #eef1f5}