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

@@ -37,6 +37,7 @@ func registerSuffixRoutes(secured *gin.RouterGroup, a *BusinessAPI) {
s.DELETE("/dirs/:id", a.deleteSuffixDir) s.DELETE("/dirs/:id", a.deleteSuffixDir)
s.GET("/dirs/:id/page", a.suffixDirPage) s.GET("/dirs/:id/page", a.suffixDirPage)
s.POST("/dirs/:id/columns", a.createSuffixColumn) s.POST("/dirs/:id/columns", a.createSuffixColumn)
s.POST("/dirs/:id/columns/order", a.reorderSuffixColumns)
s.POST("/dirs/:id/anchor", a.setSuffixAnchor) s.POST("/dirs/:id/anchor", a.setSuffixAnchor)
s.DELETE("/columns/:id", a.deleteSuffixColumn) s.DELETE("/columns/:id", a.deleteSuffixColumn)
s.PUT("/cells", a.saveSuffixCell) s.PUT("/cells", a.saveSuffixCell)
@@ -305,6 +306,7 @@ func (a *BusinessAPI) createSuffixColumn(c *gin.Context) {
var in struct { var in struct {
Name string `json:"name"` Name string `json:"name"`
IsValue bool `json:"is_value"` IsValue bool `json:"is_value"`
AfterID uint64 `json:"after_id"`
} }
if c.ShouldBindJSON(&in) != nil { if c.ShouldBindJSON(&in) != nil {
apiError(c, 400, "invalid_request", "参数无效") apiError(c, 400, "invalid_request", "参数无效")
@@ -321,12 +323,31 @@ func (a *BusinessAPI) createSuffixColumn(c *gin.Context) {
apiError(c, 409, "duplicate_name", "这个目录里已有同名列") apiError(c, 409, "duplicate_name", "这个目录里已有同名列")
return return
} }
var order sql.NullInt64 sortAt := -1
_ = a.db.QueryRowContext(c, if in.AfterID > 0 {
"SELECT MAX(sort_order) FROM suffix_columns WHERE dir_id=?", dirID).Scan(&order) var afterSort int
var afterDir uint64
if err := a.db.QueryRowContext(c,
"SELECT sort_order,dir_id FROM suffix_columns WHERE id=?", in.AfterID).Scan(&afterSort, &afterDir); err != nil || afterDir != dirID {
apiError(c, 404, "not_found", "插入位置的列不存在")
return
}
if _, err := a.db.ExecContext(c,
"UPDATE suffix_columns SET sort_order=sort_order+1 WHERE dir_id=? AND sort_order>?",
dirID, afterSort); err != nil {
apiError(c, 500, "internal_error", "列创建失败")
return
}
sortAt = afterSort
} else {
var order sql.NullInt64
_ = a.db.QueryRowContext(c,
"SELECT MAX(sort_order) FROM suffix_columns WHERE dir_id=?", dirID).Scan(&order)
sortAt = int(order.Int64)
}
res, err := a.db.ExecContext(c, res, err := a.db.ExecContext(c,
"INSERT INTO suffix_columns(dir_id,name,is_value,sort_order) VALUES(?,?,?,?)", "INSERT INTO suffix_columns(dir_id,name,is_value,sort_order) VALUES(?,?,?,?)",
dirID, name, in.IsValue, order.Int64+1) dirID, name, in.IsValue, sortAt+1)
if err != nil { if err != nil {
apiError(c, 500, "internal_error", "列创建失败") apiError(c, 500, "internal_error", "列创建失败")
return return
@@ -335,6 +356,65 @@ func (a *BusinessAPI) createSuffixColumn(c *gin.Context) {
c.JSON(201, gin.H{"data": gin.H{"id": id, "name": name, "is_value": in.IsValue}}) c.JSON(201, gin.H{"data": gin.H{"id": id, "name": name, "is_value": in.IsValue}})
} }
func (a *BusinessAPI) reorderSuffixColumns(c *gin.Context) {
dirID, _ := strconv.ParseUint(c.Param("id"), 10, 64)
var in struct {
IDs []uint64 `json:"ids"`
}
if c.ShouldBindJSON(&in) != nil || len(in.IDs) == 0 {
apiError(c, 400, "invalid_request", "ids 必须为非空数组")
return
}
// 校验:id 必须属于该目录且不可重复;没传进来的列按原顺序补到末尾,防漏传错位。
owned := map[uint64]int{}
rows, err := a.db.QueryContext(c,
"SELECT id,sort_order FROM suffix_columns WHERE dir_id=? ORDER BY sort_order ASC,id ASC", dirID)
if err != nil {
apiError(c, 500, "internal_error", "列加载失败")
return
}
original := []uint64{}
for rows.Next() {
var cid uint64
var so int
if err := rows.Scan(&cid, &so); err != nil {
rows.Close()
apiError(c, 500, "internal_error", "列加载失败")
return
}
owned[cid] = so
original = append(original, cid)
}
rows.Close()
seen := map[uint64]bool{}
for _, cid := range in.IDs {
if _, ok := owned[cid]; !ok {
apiError(c, 404, "not_found", fmt.Sprintf("列不属于该目录: %d", cid))
return
}
if seen[cid] {
apiError(c, 400, "invalid_request", "ids 重复")
return
}
seen[cid] = true
}
final := []uint64{}
final = append(final, in.IDs...)
for _, cid := range original {
if !seen[cid] {
final = append(final, cid)
}
}
for i, cid := range final {
if _, err := a.db.ExecContext(c,
"UPDATE suffix_columns SET sort_order=? WHERE id=?", i, cid); err != nil {
apiError(c, 500, "internal_error", "排序失败")
return
}
}
c.JSON(200, gin.H{"data": gin.H{"ok": true, "ordered": len(final)}})
}
func (a *BusinessAPI) deleteSuffixColumn(c *gin.Context) { func (a *BusinessAPI) deleteSuffixColumn(c *gin.Context) {
id, _ := strconv.ParseUint(c.Param("id"), 10, 64) id, _ := strconv.ParseUint(c.Param("id"), 10, 64)
res, err := a.db.ExecContext(c, "DELETE FROM suffix_columns WHERE id=?", id) res, err := a.db.ExecContext(c, "DELETE FROM suffix_columns WHERE id=?", id)

View File

@@ -157,10 +157,46 @@ func TestSuffixAdminIntegration(t *testing.T) {
if w.Code != 201 { if w.Code != 201 {
t.Fatalf("建值列 status=%d body=%s", w.Code, w.Body.String()) t.Fatalf("建值列 status=%d body=%s", w.Code, w.Body.String())
} }
valueColID := uint64(getJSON(w)["data"].(map[string]any)["id"].(float64))
w = authed(http.MethodPost, fmt.Sprintf("/api/v1/suffix-admin/dirs/%d/columns", dirID), `{"name":"招标人","is_value":false}`) w = authed(http.MethodPost, fmt.Sprintf("/api/v1/suffix-admin/dirs/%d/columns", dirID), `{"name":"招标人","is_value":false}`)
if w.Code != 409 { if w.Code != 409 {
t.Fatalf("同目录重名列 status=%d, want 409", w.Code) t.Fatalf("同目录重名列 status=%d, want 409", w.Code)
} }
// 精准插入:插到 招标人 之后
w = authed(http.MethodPost, fmt.Sprintf("/api/v1/suffix-admin/dirs/%d/columns", dirID),
fmt.Sprintf(`{"name":"插队列","is_value":false,"after_id":%d}`, plainColID))
if w.Code != 201 {
t.Fatalf("精准插列 status=%d body=%s", w.Code, w.Body.String())
}
insertedID := uint64(getJSON(w)["data"].(map[string]any)["id"].(float64))
w = authed(http.MethodGet, fmt.Sprintf("/api/v1/suffix-admin/dirs/%d/page", dirID), "")
pageCols := getJSON(w)["data"].(map[string]any)["columns"].([]any)
if pageCols[1].(map[string]any)["id"].(float64) != float64(insertedID) {
t.Fatal("精准插列应落在 招标人 之后(第2位)")
}
// 列排序:插队列移回末位 → 顺序变为 招标人,工料机类型,插队列
w = authed(http.MethodPost, fmt.Sprintf("/api/v1/suffix-admin/dirs/%d/columns/order", dirID),
fmt.Sprintf(`{"ids":[%d,%d,%d]}`, plainColID, valueColID, insertedID))
if w.Code != 200 {
t.Fatalf("列排序 status=%d body=%s", w.Code, w.Body.String())
}
// 漏传列:没传的按原顺序补到末尾 → 顺序不变(招标人,工料机类型,插队列)
w = authed(http.MethodPost, fmt.Sprintf("/api/v1/suffix-admin/dirs/%d/columns/order", dirID),
fmt.Sprintf(`{"ids":[%d,%d]}`, plainColID, valueColID))
if w.Code != 200 {
t.Fatalf("漏传列补尾 status=%d body=%s", w.Code, w.Body.String())
}
// 外列 → 404
w = authed(http.MethodPost, fmt.Sprintf("/api/v1/suffix-admin/dirs/%d/columns/order", dirID),
`{"ids":[999999]}`)
if w.Code != 404 {
t.Fatalf("外列 status=%d, want 404", w.Code)
}
w = authed(http.MethodGet, fmt.Sprintf("/api/v1/suffix-admin/dirs/%d/page", dirID), "")
orderedCols := getJSON(w)["data"].(map[string]any)["columns"].([]any)
if orderedCols[0].(map[string]any)["name"] != "招标人" || orderedCols[1].(map[string]any)["name"] != "工料机类型" || orderedCols[2].(map[string]any)["name"] != "插队列" {
t.Fatalf("排序后顺序不符: %v", orderedCols)
}
w = authed(http.MethodPut, "/api/v1/suffix-admin/cells", w = authed(http.MethodPut, "/api/v1/suffix-admin/cells",
fmt.Sprintf(`{"dir_id":%d,"suffix_id":%d,"column_id":%d,"value":"普通文本"}`, dirID, suffixID, plainColID)) fmt.Sprintf(`{"dir_id":%d,"suffix_id":%d,"column_id":%d,"value":"普通文本"}`, dirID, suffixID, plainColID))
if w.Code == 404 || w.Code == 400 { if w.Code == 404 || w.Code == 400 {
@@ -171,9 +207,10 @@ func TestSuffixAdminIntegration(t *testing.T) {
w = authed(http.MethodGet, fmt.Sprintf("/api/v1/suffix-admin/dirs/%d/page", dirID), "") w = authed(http.MethodGet, fmt.Sprintf("/api/v1/suffix-admin/dirs/%d/page", dirID), "")
page := getJSON(w)["data"].(map[string]any) page := getJSON(w)["data"].(map[string]any)
cols := page["columns"].([]any) cols := page["columns"].([]any)
if len(cols) != 2 { if len(cols) != 3 {
t.Fatalf("列数=%d, want 2", len(cols)) t.Fatalf("列数=%d, want 3", len(cols))
} }
// 排序后顺序:招标人,工料机类型,插队列;第二列=值列
if !cols[1].(map[string]any)["is_value"].(bool) { if !cols[1].(map[string]any)["is_value"].(bool) {
t.Fatal("第二列应为值列") t.Fatal("第二列应为值列")
} }

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: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: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}} @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 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 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 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 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 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 }) 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, deleteSuffix, deleteSuffixColumn, deleteSuffixDir, deleteSuffixFile, deleteSuffixGroup,
formatSuffixSize, getSuffixOverview, getSuffixPage, getSuffixTree, moveSuffix, moveSuffixDir, formatSuffixSize, getSuffixOverview, getSuffixPage, getSuffixTree, moveSuffix, moveSuffixDir,
moveSuffixGroup, parseValueCell, readSuffixFile, renameSuffix, renameSuffixDir, moveSuffixGroup, parseValueCell, readSuffixFile, renameSuffix, renameSuffixDir,
renameSuffixGroup, saveSuffixCell, setSuffixAnchor, suffixFileUrl, uploadSuffixFile, renameSuffixGroup, reorderSuffixColumns, saveSuffixCell, setSuffixAnchor, suffixFileUrl, uploadSuffixFile,
type SuffixColumn, type SuffixDir, type SuffixFile, type SuffixPage, type SuffixColumn, type SuffixDir, type SuffixFile, type SuffixPage,
} from '../suffix-admin' } 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) 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 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() { async function submitColumn() {
if (selected.value.kind !== 'dir' || colDialog.saving) return if (selected.value.kind !== 'dir' || colDialog.saving) return
const name = colDialog.name.trim() const name = colDialog.name.trim()
@@ -346,6 +403,10 @@ function cellDisplay(sid: number, col: SuffixColumn):string {
} }
function startCellEdit(sid: number, col: SuffixColumn) { function startCellEdit(sid: number, col: SuffixColumn) {
if (!editRows.value.has(sid)) {
ElMessage.warning('先点这一行的「编辑」,再双击单元格')
return
}
const raw = page.value?.cells[cellKey(sid, col.id)] || '' const raw = page.value?.cells[cellKey(sid, col.id)] || ''
const p = parseValueCell(raw) const p = parseValueCell(raw)
editing.sid = sid editing.sid = sid
@@ -520,8 +581,9 @@ onMounted(() => {
<template v-else-if="page"> <template v-else-if="page">
<div class="bar"> <div class="bar">
<strong>{{ selectedDirName }}</strong> <strong>{{ selectedDirName }}</strong>
<span class="bar-note">点「+ 添加列」加列;勾选「值设置」的列,点单元格即可填 锚点+值。</span> <span class="bar-note">先点这一行的「编辑」,再双击单元格修改;值列可填 锚点 / 值。</span>
<span class="grow"></span> <span class="grow"></span>
<el-button size="small" @click="openColOrder">列排序</el-button>
<el-button size="small" type="primary" plain @click="openAddColumn">+ 添加列</el-button> <el-button size="small" type="primary" plain @click="openAddColumn">+ 添加列</el-button>
</div> </div>
<div v-loading="pageLoading" class="sheet-wrap"> <div v-loading="pageLoading" class="sheet-wrap">
@@ -555,7 +617,9 @@ onMounted(() => {
v-for="col in pageColumns" v-for="col in pageColumns"
:key="col.id" :key="col.id"
class="cell" 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"> <template v-if="editing.sid === row.sid && editing.cid === col.id">
<span class="cell-editor" @click.stop> <span class="cell-editor" @click.stop>
@@ -602,6 +666,34 @@ onMounted(() => {
<el-button type="primary" :loading="colDialog.saving" @click="submitColumn">确定</el-button> <el-button type="primary" :loading="colDialog.saving" @click="submitColumn">确定</el-button>
</template> </template>
</el-dialog> </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> </div>
</template> </template>
@@ -628,6 +720,19 @@ onMounted(() => {
.bar{display:flex;align-items:center;gap:12px;padding:0 0 10px} .bar{display:flex;align-items:center;gap:12px;padding:0 0 10px}
.bar strong{font-size:15px} .bar strong{font-size:15px}
.bar-note{color:#8a97a8;font-size:12px} .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} .grow{flex:1}
.sheet-wrap{border:1px solid #e5eaf0;border-radius:6px;overflow:auto;max-height:68vh;background:#fff} .sheet-wrap{border:1px solid #e5eaf0;border-radius:6px;overflow:auto;max-height:68vh;background:#fff}
.group-block{border-bottom:1px solid #eef1f5} .group-block{border-bottom:1px solid #eef1f5}