feat(suffix): 支持根目录重命名、列宽保存、锚定值与文件发布
This commit is contained in:
23
AGENTS.md
Normal file
23
AGENTS.md
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
# 项目协作约定(长期记忆)
|
||||||
|
|
||||||
|
- 本项目是新开发软件,尚未交付真实用户:**不需要考虑旧数据 / 旧接口 / 旧存储路径的向后兼容**,直接切换到目标设计即可(例:附件存储目录从 suffix-templates 切到 attachments 时无需保留回退逻辑)。
|
||||||
|
- 每次动手改代码前,先与用户核对任务清单,确认后再开工(用户定的铁律)。
|
||||||
|
- 填 cos4 后缀管理数据时:**每一层先出草稿**(完整目录树 + 锚定行 + 每目录字段表「列名→填入值」),用户确认后才执行。
|
||||||
|
- **重复明细条目只填一行代表**(如 AttrInfoItem/AddiInfoItem 在 XML 里重复多次,数据里填一条即可),但必须**记住 XML 的数据层级结构**(元素嵌套关系)。
|
||||||
|
- **层级不同就各建目录,字段相同就克隆字段配置**(同一元素在多处出现,如 SummaryOfCost 挂在 建设项目/建筑安装工程费/单项工程 下,各自建目录,锚定行同名,字段列复制)。
|
||||||
|
- **自嵌套元素**(如 AddiInfoItem 套 AddiInfoItem,标准中「支持树形结构」的明细元素):目录下建**同名子目录、克隆同样字段**,树里表达一层嵌套即可,租户端按真实数据递归展开。
|
||||||
|
- **枚举字段的值设置列(2026-10-31 用户定稿:横向含义列)**:枚举属性表达为**每个含义一列**——列名=含义词,勾选值设置(is_value=true),格子存 `{"a":"字段名","v":"代码"}`(锚点=该枚举的属性英文名,值=该含义在此格式下的代码);属性本体列另建、普通列(格子=属性英文名),名用短名或标准中文解释。N 个含义 = N 个含义列 + 1 个本体列(N+1 处字段名)。值设置含义列组整体排在**锚定行右边、其他字段列左边**;同目录多枚举按组连排(各组含义列→各本体列→普通字段列)。不同地区代码不同时,各后缀行填各自代码。工料机汇总已全量改造:Kind(9 含义列:人工费~其他 + 本体「类型」)、ExtKind(3:普通工料/人工降效/机具降效 + 本体「扩展属性」)、Provider(3:乙供/甲供/甲招乙供 + 本体「供料方式」)。Class 工料机归属、PriceSource 价格来源是自由文本,保持普通列。
|
||||||
|
- **列名取名规则(全列统一)**:列名一律取 2025 标准属性表该属性的「中文解释」原词(如 Kind→汇总类型、LockKind→锁定类别),不自造、不用英文名当列名;值设置列与普通列同规。格子值:值设置列存 `{"a":含义串,"v":代码串}`;普通列存两家实际导出的属性英文名。**值设置列判定**:标准里属性为 Integer 且注释给出「1=xx;2=xx」枚举 → 值设置列;自由文本(如 Class 工料机归属、PriceSource 价格来源)→ 普通列。OCR 丢中文名时用 2018 版全文交叉补(Volume=册),仍缺的语境推定并标「待核」。
|
||||||
|
- **填数据不走脚本**:直接在管理台界面上操作(浏览器自动化),目录 → 字段(列)→ 字段名称(单元格值)按此顺序填。
|
||||||
|
|
||||||
|
## cos4 后缀管理数据规律(2026-10-30 与用户共同确立)
|
||||||
|
|
||||||
|
- **蓝本**:以广联达、易达两家实际导出的 cos4 文件为唯一蓝本(样例:`后台需要导入的项目/广联达导出最新架子.COS4`、`1易达导出骨架.cos4`;cos4=ZIP,内含 Project.xml + 若干单位工程 xml)。
|
||||||
|
- **目录=XML元素**:后台「按信息价目录」树的每个目录对应 cos4 里的一个 XML 元素;目录的**锚定行**填该元素的英文名(如 建设项目→ConstructionProject);目录中文名取自 DBJ/T 15-145-2025 第 6 章对应表(参考资料在 AdminCost/参考资料/规范与COS4/)。
|
||||||
|
- **列=元素属性**:目录里的列 = 该元素的属性;列名用 2025 标准属性表的「中文解释」;单元格值 = **两家实际导出的属性英文名**,并以**两家字段的并集**为准——不是标准全集,也不是单家。
|
||||||
|
- **以实际为准 + 提醒**:填入值一律以两家实际导出为准,不按标准拼写改(例:两家都把 BuildUnit 拼成 `BulidUnit`,按错的填);与标准不一致(拼写差异、某家缺失、标准有但两家都没导出)时必须向用户提醒。已知差异:建设单位/法定代表人两家都拼错(BulidUnit/BulidAuthorizer);`BulidAuthorizer` 仅易达导出;标准表 6.2.1 的 4 个价格指数字段(ProjectIndex/LabourPriceIndex/MaterialPriceIndex/MachinePriceIndex)两家均未导出,故不建列。
|
||||||
|
- **进度**:建设项目(ConstructionProject)已补全 22 列 + cos4 行 22 格(2026-10-30)。cos 行(老格式)留空,后续单独讨论。
|
||||||
|
- **操作注意**:用 curl 调后端 API 填中文时,必须把 JSON 写进 UTF-8 文件用 `--data-binary @file` 发送;中文放命令行参数会被 Windows 代码页转成乱码(EFBFBD)。
|
||||||
|
- **同名属性按锚定行分别查原表(2026-10-31 用户铁律)**:同一英文属性(如 Kind/Specialty/CalculationKind/EfficiencyKind/IncFeeKind)在不同锚定行(元素)下的中文解释与枚举值**可能完全不同**,填值设置前必须逐表核对原出处(md 表 → 2018 版交叉 → 原 PDF)。已实证差异:Specialty 专业类别在 WorkElement=12 项 / UnitWorks=21 项 / **Norm=19 项**(含 城市轨道交通(建筑)=8、城市轨道交通(安装)=16、建筑与装饰修缮=12、安装修缮=13、传统建筑(古建筑)=15、地下管廊建筑=17、地下管廊安装=18、古驿道=21,2=仿古建筑 OCR 缺按 2018 补);EfficiencyKind 降效类型 2025=3 项(1需计算降效费用的基础定额/2不需计算…/3降效费用定额,**与 2018 的 4 项不同**);IncFeeKind 2025=3 项(1需计算子目增加费的基础定额/2不需计算…/3子目增加费定额);Volume=册。汇总类型 Kind/章节类型 ChapterKind/锁定类别/取费类型/费用归属/单价计算方式/合价计算方式/子目类型 各锚定行同义。
|
||||||
|
- **列名核对工具**:审计脚本做法——从 2025 版 md 解析每元素属性表(注意 OCR 陷阱:属性名常在「序号」列且序号列可能为空、长属性名折行连写(TechnicalAndEcono-+micIndex)、中文解释词序颠倒),与库内 列名/格子值 按锚定行逐一比对;解析器分隔行守卫不能误杀空序号行。
|
||||||
|
- **枚举映射核实来源**:2025 版 OCR 的枚举注缺失时,用同目录 2018 版全文(DBJT15-145-2018_全文含表格.md)交叉核对(文本干净)。已核实:降效类型 EfficiencyKind(1降效基础定额/2非降效定额/3按市场价计算降效费用定额/4按定额价计算降效费用定额)、子目增加费类型 IncFeeKind(1子目增加费基础定额/2非子目增加费定额/3子目增加费用计算定额)、快速计算的 Kind=汇总类型(1汇总条目/2不汇总条目)、Volume=册(册号,无分册填0)。唯一残留待核:Norm 的 Chapter 列中文名两版文字均缺失,按语境暂记「章(待核)」(2025 原始 PDF 4793785.pdf 本地不存在,需要时向用户索取)。
|
||||||
@@ -175,8 +175,10 @@ func (o *Operations) Middleware() gin.HandlerFunc {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Uploads have their own 64 MiB streaming bound; other JSON routes get a 64 KiB ceiling.
|
// Uploads have their own streaming bounds (releases 64 MiB; suffix templates
|
||||||
if !(path == "/api/v1/products/:id/releases" && c.Request.Method == "POST") {
|
// bound in their handler); other JSON routes get a 64 KiB ceiling.
|
||||||
|
if !(path == "/api/v1/products/:id/releases" && c.Request.Method == "POST") &&
|
||||||
|
!(path == "/api/v1/suffix-admin/suffixes/:id/files" && c.Request.Method == "POST") {
|
||||||
if c.Request.ContentLength > 64<<10 {
|
if c.Request.ContentLength > 64<<10 {
|
||||||
apiError(c, 413, "body_too_large", "Request body too large")
|
apiError(c, 413, "body_too_large", "Request body too large")
|
||||||
c.Abort()
|
c.Abort()
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ import (
|
|||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
)
|
)
|
||||||
|
|
||||||
const RequiredSchemaVersion = 17
|
const RequiredSchemaVersion = 21
|
||||||
|
|
||||||
func RegisterReadiness(r *gin.Engine, db *sql.DB) {
|
func RegisterReadiness(r *gin.Engine, db *sql.DB) {
|
||||||
r.GET("/api/v1/health/ready", func(c *gin.Context) {
|
r.GET("/api/v1/health/ready", func(c *gin.Context) {
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ import (
|
|||||||
"encoding/hex"
|
"encoding/hex"
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"net/http"
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"regexp"
|
"regexp"
|
||||||
@@ -42,6 +43,8 @@ func registerSuffixRoutes(secured *gin.RouterGroup, a *BusinessAPI) {
|
|||||||
s.PATCH("/columns/:id", a.updateSuffixColumn)
|
s.PATCH("/columns/:id", a.updateSuffixColumn)
|
||||||
s.DELETE("/columns/:id", a.deleteSuffixColumn)
|
s.DELETE("/columns/:id", a.deleteSuffixColumn)
|
||||||
s.PUT("/cells", a.saveSuffixCell)
|
s.PUT("/cells", a.saveSuffixCell)
|
||||||
|
s.GET("/col-widths", a.suffixColWidths)
|
||||||
|
s.PUT("/col-widths", a.saveSuffixColWidth)
|
||||||
s.GET("/overview", a.suffixOverview)
|
s.GET("/overview", a.suffixOverview)
|
||||||
s.POST("/groups", a.createSuffixGroup)
|
s.POST("/groups", a.createSuffixGroup)
|
||||||
s.PUT("/groups/:id", a.renameSuffixGroup)
|
s.PUT("/groups/:id", a.renameSuffixGroup)
|
||||||
@@ -54,6 +57,7 @@ func registerSuffixRoutes(secured *gin.RouterGroup, a *BusinessAPI) {
|
|||||||
s.POST("/suffixes/:id/files", a.uploadSuffixFile)
|
s.POST("/suffixes/:id/files", a.uploadSuffixFile)
|
||||||
s.DELETE("/files/:id", a.deleteSuffixFile)
|
s.DELETE("/files/:id", a.deleteSuffixFile)
|
||||||
s.GET("/files/:id/download", a.downloadSuffixFile)
|
s.GET("/files/:id/download", a.downloadSuffixFile)
|
||||||
|
s.POST("/files/:id/publish", a.publishSuffixFile)
|
||||||
}
|
}
|
||||||
|
|
||||||
func suffixTrimName(raw string, max int) (string, bool) {
|
func suffixTrimName(raw string, max int) (string, bool) {
|
||||||
@@ -61,8 +65,6 @@ func suffixTrimName(raw string, max int) (string, bool) {
|
|||||||
return name, name != "" && utf8.RuneCountInString(name) <= max
|
return name, name != "" && utf8.RuneCountInString(name) <= max
|
||||||
}
|
}
|
||||||
|
|
||||||
const suffixRootNameValue = "按信息价的目录"
|
|
||||||
|
|
||||||
// ---- 目录树 ----
|
// ---- 目录树 ----
|
||||||
|
|
||||||
type suffixDirRow struct {
|
type suffixDirRow struct {
|
||||||
@@ -101,9 +103,6 @@ func (a *BusinessAPI) suffixTree(c *gin.Context) {
|
|||||||
dirs[p].Children++
|
dirs[p].Children++
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if len(dirs) > 0 {
|
|
||||||
dirs[0].Name = suffixRootNameValue
|
|
||||||
}
|
|
||||||
c.JSON(200, gin.H{"data": gin.H{"dirs": dirs}})
|
c.JSON(200, gin.H{"data": gin.H{"dirs": dirs}})
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -127,7 +126,7 @@ func (a *BusinessAPI) createSuffixDir(c *gin.Context) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
if in.ParentID == 0 {
|
if in.ParentID == 0 {
|
||||||
apiError(c, 403, "forbidden", "只能建在「按信息价的目录」之内")
|
apiError(c, 403, "forbidden", "只能建在根目录之内")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if !a.dirExists(c, in.ParentID) {
|
if !a.dirExists(c, in.ParentID) {
|
||||||
@@ -158,10 +157,6 @@ func (a *BusinessAPI) dirIsRoot(c *gin.Context, id uint64) bool {
|
|||||||
|
|
||||||
func (a *BusinessAPI) renameSuffixDir(c *gin.Context) {
|
func (a *BusinessAPI) renameSuffixDir(c *gin.Context) {
|
||||||
id, _ := strconv.ParseUint(c.Param("id"), 10, 64)
|
id, _ := strconv.ParseUint(c.Param("id"), 10, 64)
|
||||||
if a.dirIsRoot(c, id) {
|
|
||||||
apiError(c, 403, "forbidden", "根目录名称固定,不能改名")
|
|
||||||
return
|
|
||||||
}
|
|
||||||
var in struct {
|
var in struct {
|
||||||
Name string `json:"name"`
|
Name string `json:"name"`
|
||||||
}
|
}
|
||||||
@@ -250,15 +245,15 @@ func (a *BusinessAPI) suffixDirPage(c *gin.Context) {
|
|||||||
colRows.Close()
|
colRows.Close()
|
||||||
|
|
||||||
type suffixLine struct {
|
type suffixLine struct {
|
||||||
ID uint64 `json:"id"`
|
ID uint64 `json:"id"`
|
||||||
GroupID uint64 `json:"group_id"`
|
GroupID uint64 `json:"group_id"`
|
||||||
GroupName string `json:"group_name"`
|
GroupName string `json:"group_name"`
|
||||||
Name string `json:"name"`
|
Name string `json:"name"`
|
||||||
Anchor bool `json:"anchor"`
|
AnchorValue string `json:"anchor_value"`
|
||||||
}
|
}
|
||||||
suffixes := []suffixLine{}
|
suffixes := []suffixLine{}
|
||||||
sfxRows, err := a.db.QueryContext(c,
|
sfxRows, err := a.db.QueryContext(c,
|
||||||
"SELECT s.id,s.group_id,g.name,s.name, EXISTS(SELECT 1 FROM suffix_dir_anchors x WHERE x.dir_id=? AND x.suffix_id=s.id)"+
|
"SELECT s.id,s.group_id,g.name,s.name, COALESCE((SELECT x.value FROM suffix_dir_anchors x WHERE x.dir_id=? AND x.suffix_id=s.id),'')"+
|
||||||
" FROM suffixes s JOIN suffix_groups g ON g.id=s.group_id"+
|
" FROM suffixes s JOIN suffix_groups g ON g.id=s.group_id"+
|
||||||
" ORDER BY g.sort_order ASC,g.id ASC,s.sort_order ASC,s.id ASC", dirID)
|
" ORDER BY g.sort_order ASC,g.id ASC,s.sort_order ASC,s.id ASC", dirID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -267,7 +262,7 @@ func (a *BusinessAPI) suffixDirPage(c *gin.Context) {
|
|||||||
}
|
}
|
||||||
for sfxRows.Next() {
|
for sfxRows.Next() {
|
||||||
var r suffixLine
|
var r suffixLine
|
||||||
if err := sfxRows.Scan(&r.ID, &r.GroupID, &r.GroupName, &r.Name, &r.Anchor); err != nil {
|
if err := sfxRows.Scan(&r.ID, &r.GroupID, &r.GroupName, &r.Name, &r.AnchorValue); err != nil {
|
||||||
sfxRows.Close()
|
sfxRows.Close()
|
||||||
apiError(c, 500, "internal_error", "后缀加载失败")
|
apiError(c, 500, "internal_error", "后缀加载失败")
|
||||||
return
|
return
|
||||||
@@ -422,30 +417,73 @@ func (a *BusinessAPI) reorderSuffixColumns(c *gin.Context) {
|
|||||||
c.JSON(200, gin.H{"data": gin.H{"ok": true, "ordered": len(final)}})
|
c.JSON(200, gin.H{"data": gin.H{"ok": true, "ordered": len(final)}})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 列更新:name 与 width 至少传一个;重命名在同一目录内查重。
|
||||||
func (a *BusinessAPI) updateSuffixColumn(c *gin.Context) {
|
func (a *BusinessAPI) updateSuffixColumn(c *gin.Context) {
|
||||||
id, _ := strconv.ParseUint(c.Param("id"), 10, 64)
|
id, _ := strconv.ParseUint(c.Param("id"), 10, 64)
|
||||||
var in struct {
|
var in struct {
|
||||||
Width *int `json:"width"`
|
Name *string `json:"name"`
|
||||||
|
Width *int `json:"width"`
|
||||||
}
|
}
|
||||||
if c.ShouldBindJSON(&in) != nil || in.Width == nil {
|
if c.ShouldBindJSON(&in) != nil || (in.Name == nil && in.Width == nil) {
|
||||||
apiError(c, 400, "invalid_request", "width 必填")
|
apiError(c, 400, "invalid_request", "name 或 width 至少传一个")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
w := *in.Width
|
if in.Name != nil {
|
||||||
if w < 0 || w > 2000 {
|
name, ok := suffixTrimName(*in.Name, 190)
|
||||||
apiError(c, 400, "invalid_request", "列宽须为 0–2000(0=自适应)")
|
if !ok {
|
||||||
return
|
apiError(c, 400, "invalid_request", "列名须为 1–190 字")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
var dirID uint64
|
||||||
|
if err := a.db.QueryRowContext(c,
|
||||||
|
"SELECT dir_id FROM suffix_columns WHERE id=?", id).Scan(&dirID); err != nil {
|
||||||
|
apiError(c, 404, "not_found", "列不存在")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
var dup int
|
||||||
|
if a.db.QueryRowContext(c,
|
||||||
|
"SELECT 1 FROM suffix_columns WHERE dir_id=? AND name=? AND id<>?", dirID, name, id).Scan(&dup) == nil {
|
||||||
|
apiError(c, 409, "duplicate_name", "这个目录里已有同名列")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if _, err := a.db.ExecContext(c, "UPDATE suffix_columns SET name=? WHERE id=?", name, id); err != nil {
|
||||||
|
apiError(c, 500, "internal_error", "列重命名失败")
|
||||||
|
return
|
||||||
|
}
|
||||||
}
|
}
|
||||||
res, err := a.db.ExecContext(c, "UPDATE suffix_columns SET width=? WHERE id=?", w, id)
|
if in.Width != nil {
|
||||||
if err != nil || rowsAffected(res) == 0 {
|
w := *in.Width
|
||||||
|
if w < 0 || w > 2000 {
|
||||||
|
apiError(c, 400, "invalid_request", "列宽须为 0–2000(0=自适应)")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if _, err := a.db.ExecContext(c, "UPDATE suffix_columns SET width=? WHERE id=?", w, id); err != nil {
|
||||||
|
apiError(c, 500, "internal_error", "列宽保存失败")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
var out suffixColumnRow
|
||||||
|
if err := a.db.QueryRowContext(c,
|
||||||
|
"SELECT id,name,is_value,width FROM suffix_columns WHERE id=?", id).
|
||||||
|
Scan(&out.ID, &out.Name, &out.IsValue, &out.Width); err != nil {
|
||||||
apiError(c, 404, "not_found", "列不存在")
|
apiError(c, 404, "not_found", "列不存在")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
c.JSON(200, gin.H{"data": gin.H{"id": id, "width": w}})
|
c.JSON(200, gin.H{"data": out})
|
||||||
}
|
}
|
||||||
|
|
||||||
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)
|
||||||
|
var filled int
|
||||||
|
if err := a.db.QueryRowContext(c,
|
||||||
|
"SELECT COUNT(*) FROM suffix_cells WHERE column_id=? AND value<>''", id).Scan(&filled); err != nil {
|
||||||
|
apiError(c, 500, "internal_error", "删除失败")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if filled > 0 {
|
||||||
|
apiError(c, 409, "column_has_data", "该列已有数据,不能删除")
|
||||||
|
return
|
||||||
|
}
|
||||||
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)
|
||||||
if err != nil || rowsAffected(res) == 0 {
|
if err != nil || rowsAffected(res) == 0 {
|
||||||
apiError(c, 404, "not_found", "列不存在")
|
apiError(c, 404, "not_found", "列不存在")
|
||||||
@@ -494,20 +532,27 @@ func (a *BusinessAPI) saveSuffixCell(c *gin.Context) {
|
|||||||
c.JSON(200, gin.H{"data": gin.H{"ok": true}})
|
c.JSON(200, gin.H{"data": gin.H{"ok": true}})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 锚定行存值:value 非空 upsert,空串删除(未锚定)。
|
||||||
func (a *BusinessAPI) setSuffixAnchor(c *gin.Context) {
|
func (a *BusinessAPI) setSuffixAnchor(c *gin.Context) {
|
||||||
dirID, _ := strconv.ParseUint(c.Param("id"), 10, 64)
|
dirID, _ := strconv.ParseUint(c.Param("id"), 10, 64)
|
||||||
var in struct {
|
var in struct {
|
||||||
SuffixID uint64 `json:"suffix_id"`
|
SuffixID uint64 `json:"suffix_id"`
|
||||||
On bool `json:"on"`
|
Value string `json:"value"`
|
||||||
}
|
}
|
||||||
if c.ShouldBindJSON(&in) != nil {
|
if c.ShouldBindJSON(&in) != nil {
|
||||||
apiError(c, 400, "invalid_request", "参数无效")
|
apiError(c, 400, "invalid_request", "参数无效")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
value := strings.TrimSpace(in.Value)
|
||||||
|
if utf8.RuneCountInString(value) > 190 {
|
||||||
|
apiError(c, 400, "invalid_request", "锚定值最多 190 字")
|
||||||
|
return
|
||||||
|
}
|
||||||
var exec error
|
var exec error
|
||||||
if in.On {
|
if value != "" {
|
||||||
_, exec = a.db.ExecContext(c,
|
_, exec = a.db.ExecContext(c,
|
||||||
"INSERT IGNORE INTO suffix_dir_anchors(dir_id,suffix_id) VALUES(?,?)", dirID, in.SuffixID)
|
"INSERT INTO suffix_dir_anchors(dir_id,suffix_id,value) VALUES(?,?,?)"+
|
||||||
|
" ON DUPLICATE KEY UPDATE value=VALUES(value)", dirID, in.SuffixID, value)
|
||||||
} else {
|
} else {
|
||||||
_, exec = a.db.ExecContext(c,
|
_, exec = a.db.ExecContext(c,
|
||||||
"DELETE FROM suffix_dir_anchors WHERE dir_id=? AND suffix_id=?", dirID, in.SuffixID)
|
"DELETE FROM suffix_dir_anchors WHERE dir_id=? AND suffix_id=?", dirID, in.SuffixID)
|
||||||
@@ -519,6 +564,79 @@ func (a *BusinessAPI) setSuffixAnchor(c *gin.Context) {
|
|||||||
c.JSON(200, gin.H{"data": gin.H{"ok": true}})
|
c.JSON(200, gin.H{"data": gin.H{"ok": true}})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ---- 固定列列宽(序号/后缀/操作等,基本设置与目录工作区各一套,全部可自由设置) ----
|
||||||
|
|
||||||
|
// 默认值与前端 FIXED_COL_DEFAULTS 保持一致;0=自适应(导入文件为 0 时占满剩余宽度)。
|
||||||
|
var suffixColWidthDefaults = map[string]map[string]int{
|
||||||
|
"basic": {"idx": 50, "suffix": 50, "files": 0, "ops": 150},
|
||||||
|
"workspace": {"idx": 50, "suffix": 50, "ops": 80, "anchor": 300},
|
||||||
|
}
|
||||||
|
|
||||||
|
func (a *BusinessAPI) suffixColWidths(c *gin.Context) {
|
||||||
|
out := map[string]map[string]int{}
|
||||||
|
for scope, keys := range suffixColWidthDefaults {
|
||||||
|
out[scope] = map[string]int{}
|
||||||
|
for k, def := range keys {
|
||||||
|
out[scope][k] = def
|
||||||
|
}
|
||||||
|
}
|
||||||
|
rows, err := a.db.QueryContext(c, "SELECT scope,col_key,width FROM suffix_col_widths")
|
||||||
|
if err != nil {
|
||||||
|
apiError(c, 500, "internal_error", "列宽加载失败")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
defer rows.Close()
|
||||||
|
for rows.Next() {
|
||||||
|
var scope, key string
|
||||||
|
var w int
|
||||||
|
if rows.Scan(&scope, &key, &w) == nil {
|
||||||
|
if keys, ok := out[scope]; ok {
|
||||||
|
if _, known := keys[key]; known && w >= 0 {
|
||||||
|
keys[key] = w
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if err := rows.Err(); err != nil {
|
||||||
|
apiError(c, 500, "internal_error", "列宽加载失败")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
c.JSON(200, gin.H{"data": gin.H{"widths": out}})
|
||||||
|
}
|
||||||
|
|
||||||
|
func (a *BusinessAPI) saveSuffixColWidth(c *gin.Context) {
|
||||||
|
var in struct {
|
||||||
|
Scope string `json:"scope"`
|
||||||
|
Key string `json:"key"`
|
||||||
|
Width *int `json:"width"`
|
||||||
|
}
|
||||||
|
if c.ShouldBindJSON(&in) != nil || in.Width == nil {
|
||||||
|
apiError(c, 400, "invalid_request", "参数无效")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
keys, ok := suffixColWidthDefaults[in.Scope]
|
||||||
|
if !ok {
|
||||||
|
apiError(c, 400, "invalid_request", "scope 只能是 basic 或 workspace")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if _, known := keys[in.Key]; !known {
|
||||||
|
apiError(c, 400, "invalid_request", "未知的固定列 key")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
w := *in.Width
|
||||||
|
if w < 0 || w > 2000 {
|
||||||
|
apiError(c, 400, "invalid_request", "列宽须为 0–2000(0=自适应)")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if _, err := a.db.ExecContext(c,
|
||||||
|
"INSERT INTO suffix_col_widths(scope,col_key,width) VALUES(?,?,?)"+
|
||||||
|
" ON DUPLICATE KEY UPDATE width=VALUES(width)", in.Scope, in.Key, w); err != nil {
|
||||||
|
apiError(c, 500, "internal_error", "列宽保存失败")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
c.JSON(200, gin.H{"data": gin.H{"scope": in.Scope, "key": in.Key, "width": w}})
|
||||||
|
}
|
||||||
|
|
||||||
// ---- 基本设置:分组 + 后缀 + 模板文件 ----
|
// ---- 基本设置:分组 + 后缀 + 模板文件 ----
|
||||||
|
|
||||||
type suffixFileRow struct {
|
type suffixFileRow struct {
|
||||||
@@ -526,6 +644,7 @@ type suffixFileRow struct {
|
|||||||
FileName string `json:"file_name"`
|
FileName string `json:"file_name"`
|
||||||
FileSize int64 `json:"file_size"`
|
FileSize int64 `json:"file_size"`
|
||||||
CreatedAt string `json:"created_at"`
|
CreatedAt string `json:"created_at"`
|
||||||
|
Published bool `json:"published"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (a *BusinessAPI) suffixOverview(c *gin.Context) {
|
func (a *BusinessAPI) suffixOverview(c *gin.Context) {
|
||||||
@@ -583,7 +702,7 @@ func (a *BusinessAPI) suffixOverview(c *gin.Context) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
fRows, err := a.db.QueryContext(c,
|
fRows, err := a.db.QueryContext(c,
|
||||||
"SELECT id,suffix_id,file_name,file_size,created_at FROM suffix_files ORDER BY id ASC")
|
"SELECT id,suffix_id,file_name,file_size,created_at,published FROM suffix_files ORDER BY id ASC")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
apiError(c, 500, "internal_error", "文件加载失败")
|
apiError(c, 500, "internal_error", "文件加载失败")
|
||||||
return
|
return
|
||||||
@@ -592,7 +711,7 @@ func (a *BusinessAPI) suffixOverview(c *gin.Context) {
|
|||||||
for fRows.Next() {
|
for fRows.Next() {
|
||||||
var f suffixFileRow
|
var f suffixFileRow
|
||||||
var sid uint64
|
var sid uint64
|
||||||
if err := fRows.Scan(&f.ID, &sid, &f.FileName, &f.FileSize, &f.CreatedAt); err != nil {
|
if err := fRows.Scan(&f.ID, &sid, &f.FileName, &f.FileSize, &f.CreatedAt, &f.Published); err != nil {
|
||||||
apiError(c, 500, "internal_error", "文件加载失败")
|
apiError(c, 500, "internal_error", "文件加载失败")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@@ -904,12 +1023,13 @@ type suffixTemplateRootError struct{}
|
|||||||
|
|
||||||
func (suffixTemplateRootError) Error() string { return "模板存储目录未配置" }
|
func (suffixTemplateRootError) Error() string { return "模板存储目录未配置" }
|
||||||
|
|
||||||
|
// 附件统一落盘在 PACKAGE_STORAGE_ROOT/attachments/<后缀id>/ 下(新软件,无旧目录兼容负担)。
|
||||||
func suffixTemplateRoot() (string, error) {
|
func suffixTemplateRoot() (string, error) {
|
||||||
base := strings.TrimSpace(os.Getenv("PACKAGE_STORAGE_ROOT"))
|
base := strings.TrimSpace(os.Getenv("PACKAGE_STORAGE_ROOT"))
|
||||||
if base == "" {
|
if base == "" {
|
||||||
return "", suffixTemplateRootError{}
|
return "", suffixTemplateRootError{}
|
||||||
}
|
}
|
||||||
return filepath.Join(base, "suffix-templates"), nil
|
return filepath.Join(base, "attachments"), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func suffixUniqueName(dir string, name string) string {
|
func suffixUniqueName(dir string, name string) string {
|
||||||
@@ -928,6 +1048,8 @@ func suffixUniqueName(dir string, name string) string {
|
|||||||
|
|
||||||
func (a *BusinessAPI) uploadSuffixFile(c *gin.Context) {
|
func (a *BusinessAPI) uploadSuffixFile(c *gin.Context) {
|
||||||
suffixID, _ := strconv.ParseUint(c.Param("id"), 10, 64)
|
suffixID, _ := strconv.ParseUint(c.Param("id"), 10, 64)
|
||||||
|
// base64 上传体放宽到 128MB + 少量 JSON 包装开销(该路由已在全局 64KiB JSON 上限中豁免)。
|
||||||
|
c.Request.Body = http.MaxBytesReader(c.Writer, c.Request.Body, suffixUploadMax+(64<<10))
|
||||||
var in struct {
|
var in struct {
|
||||||
FileName string `json:"file_name"`
|
FileName string `json:"file_name"`
|
||||||
Size int64 `json:"size"`
|
Size int64 `json:"size"`
|
||||||
@@ -1009,7 +1131,7 @@ func (a *BusinessAPI) uploadSuffixFile(c *gin.Context) {
|
|||||||
}})
|
}})
|
||||||
}
|
}
|
||||||
|
|
||||||
// 只认模板根目录以内的路径,越界一律不删。
|
// 只认模板根目录以内的路径,越界一律不删;删完后顺手回收空的后缀目录。
|
||||||
func (a *BusinessAPI) removeDiskFiles(c *gin.Context, relPaths []string) {
|
func (a *BusinessAPI) removeDiskFiles(c *gin.Context, relPaths []string) {
|
||||||
root, err := suffixTemplateRoot()
|
root, err := suffixTemplateRoot()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -1019,11 +1141,34 @@ func (a *BusinessAPI) removeDiskFiles(c *gin.Context, relPaths []string) {
|
|||||||
abs := filepath.Join(root, filepath.FromSlash(rel))
|
abs := filepath.Join(root, filepath.FromSlash(rel))
|
||||||
clean := filepath.Clean(abs)
|
clean := filepath.Clean(abs)
|
||||||
if strings.HasPrefix(clean, filepath.Clean(root)+string(filepath.Separator)) {
|
if strings.HasPrefix(clean, filepath.Clean(root)+string(filepath.Separator)) {
|
||||||
_ = os.Remove(clean)
|
if os.Remove(clean) == nil {
|
||||||
|
_ = os.Remove(filepath.Dir(clean))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (a *BusinessAPI) publishSuffixFile(c *gin.Context) {
|
||||||
|
id, _ := strconv.ParseUint(c.Param("id"), 10, 64)
|
||||||
|
var in struct {
|
||||||
|
On bool `json:"on"`
|
||||||
|
}
|
||||||
|
if c.ShouldBindJSON(&in) != nil {
|
||||||
|
apiError(c, 400, "invalid_request", "参数无效")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
on := 0
|
||||||
|
if in.On {
|
||||||
|
on = 1
|
||||||
|
}
|
||||||
|
res, err := a.db.ExecContext(c, "UPDATE suffix_files SET published=? WHERE id=?", on, id)
|
||||||
|
if err != nil || rowsAffected(res) == 0 {
|
||||||
|
apiError(c, 404, "not_found", "文件不存在")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
c.JSON(200, gin.H{"data": gin.H{"id": id, "published": in.On}})
|
||||||
|
}
|
||||||
|
|
||||||
func (a *BusinessAPI) deleteSuffixFile(c *gin.Context) {
|
func (a *BusinessAPI) deleteSuffixFile(c *gin.Context) {
|
||||||
id, _ := strconv.ParseUint(c.Param("id"), 10, 64)
|
id, _ := strconv.ParseUint(c.Param("id"), 10, 64)
|
||||||
var rel string
|
var rel string
|
||||||
|
|||||||
@@ -11,6 +11,8 @@ import (
|
|||||||
"net/http"
|
"net/http"
|
||||||
"net/http/httptest"
|
"net/http/httptest"
|
||||||
"os"
|
"os"
|
||||||
|
"path/filepath"
|
||||||
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
@@ -33,7 +35,7 @@ func TestSuffixAdminIntegration(t *testing.T) {
|
|||||||
if err = db.Ping(); err != nil {
|
if err = db.Ping(); err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
for _, table := range []string{"suffix_files", "suffix_dir_anchors", "suffix_cells", "suffix_columns", "suffixes", "suffix_groups", "suffix_dirs"} {
|
for _, table := range []string{"suffix_files", "suffix_dir_anchors", "suffix_cells", "suffix_columns", "suffixes", "suffix_groups", "suffix_dirs", "suffix_col_widths"} {
|
||||||
if _, err = db.Exec("DELETE FROM " + table); err != nil {
|
if _, err = db.Exec("DELETE FROM " + table); err != nil {
|
||||||
t.Fatalf("清理 %s: %v", table, err)
|
t.Fatalf("清理 %s: %v", table, err)
|
||||||
}
|
}
|
||||||
@@ -55,7 +57,8 @@ func TestSuffixAdminIntegration(t *testing.T) {
|
|||||||
|
|
||||||
router := NewRouter()
|
router := NewRouter()
|
||||||
RegisterBusiness(router, db)
|
RegisterBusiness(router, db)
|
||||||
t.Setenv("PACKAGE_STORAGE_ROOT", t.TempDir())
|
storageRoot := t.TempDir()
|
||||||
|
t.Setenv("PACKAGE_STORAGE_ROOT", storageRoot)
|
||||||
do := func(method, path, body string) *httptest.ResponseRecorder {
|
do := func(method, path, body string) *httptest.ResponseRecorder {
|
||||||
var reader *strings.Reader
|
var reader *strings.Reader
|
||||||
if body == "" {
|
if body == "" {
|
||||||
@@ -166,6 +169,16 @@ func TestSuffixAdminIntegration(t *testing.T) {
|
|||||||
if w.Code != 403 {
|
if w.Code != 403 {
|
||||||
t.Fatalf("删根 status=%d, want 403", w.Code)
|
t.Fatalf("删根 status=%d, want 403", w.Code)
|
||||||
}
|
}
|
||||||
|
// 根目录支持重命名
|
||||||
|
w = authed(http.MethodPut, fmt.Sprintf("/api/v1/suffix-admin/dirs/%d", rootID), `{"name":"建设项目"}`)
|
||||||
|
if w.Code != 200 {
|
||||||
|
t.Fatalf("改根名 status=%d body=%s", w.Code, w.Body.String())
|
||||||
|
}
|
||||||
|
w = authed(http.MethodGet, "/api/v1/suffix-admin/tree", "")
|
||||||
|
dirs = getJSON(w)["data"].(map[string]any)["dirs"].([]any)
|
||||||
|
if dirs[0].(map[string]any)["name"] != "建设项目" {
|
||||||
|
t.Fatalf("改根名后=%v", dirs[0].(map[string]any)["name"])
|
||||||
|
}
|
||||||
|
|
||||||
// 列(值设置勾选)+ 单元格 + 锚定
|
// 列(值设置勾选)+ 单元格 + 锚定
|
||||||
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}`)
|
||||||
@@ -235,9 +248,84 @@ func TestSuffixAdminIntegration(t *testing.T) {
|
|||||||
t.Fatal("第二列应为值列")
|
t.Fatal("第二列应为值列")
|
||||||
}
|
}
|
||||||
|
|
||||||
// 锚定开与关
|
// 列重命名:成功、同目录重名 409、空名 400
|
||||||
|
w = authed(http.MethodPatch, fmt.Sprintf("/api/v1/suffix-admin/columns/%d", plainColID), `{"name":"招标单位"}`)
|
||||||
|
if w.Code != 200 {
|
||||||
|
t.Fatalf("重命名列 status=%d body=%s", w.Code, w.Body.String())
|
||||||
|
}
|
||||||
|
if name := getJSON(w)["data"].(map[string]any)["name"].(string); name != "招标单位" {
|
||||||
|
t.Fatalf("重命名后 name=%q, want 招标单位", name)
|
||||||
|
}
|
||||||
|
w = authed(http.MethodPatch, fmt.Sprintf("/api/v1/suffix-admin/columns/%d", plainColID), `{"name":"工料机类型"}`)
|
||||||
|
if w.Code != 409 {
|
||||||
|
t.Fatalf("重名列 status=%d, want 409", w.Code)
|
||||||
|
}
|
||||||
|
w = authed(http.MethodPatch, fmt.Sprintf("/api/v1/suffix-admin/columns/%d", plainColID), `{"name":" "}`)
|
||||||
|
if w.Code != 400 {
|
||||||
|
t.Fatalf("空名列 status=%d, want 400", w.Code)
|
||||||
|
}
|
||||||
|
|
||||||
|
// 列有值不可删除:普通列已存「普通文本」
|
||||||
|
w = authed(http.MethodDelete, fmt.Sprintf("/api/v1/suffix-admin/columns/%d", plainColID), "")
|
||||||
|
if w.Code != 409 {
|
||||||
|
t.Fatalf("删有值列 status=%d, want 409", w.Code)
|
||||||
|
}
|
||||||
|
// 空列可直接删除
|
||||||
|
w = authed(http.MethodDelete, fmt.Sprintf("/api/v1/suffix-admin/columns/%d", insertedID), "")
|
||||||
|
if w.Code != 200 {
|
||||||
|
t.Fatalf("删空列 status=%d body=%s", w.Code, w.Body.String())
|
||||||
|
}
|
||||||
|
// 清空单元格后即可删除
|
||||||
|
w = authed(http.MethodPut, "/api/v1/suffix-admin/cells",
|
||||||
|
fmt.Sprintf(`{"dir_id":%d,"suffix_id":%d,"column_id":%d,"value":""}`, dirID, suffixID, plainColID))
|
||||||
|
if w.Code != 200 {
|
||||||
|
t.Fatalf("清空单元格 status=%d body=%s", w.Code, w.Body.String())
|
||||||
|
}
|
||||||
|
w = authed(http.MethodDelete, fmt.Sprintf("/api/v1/suffix-admin/columns/%d", plainColID), "")
|
||||||
|
if w.Code != 200 {
|
||||||
|
t.Fatalf("清空后删列 status=%d body=%s", w.Code, w.Body.String())
|
||||||
|
}
|
||||||
|
|
||||||
|
// 固定列列宽:默认值(后缀 50)→ 保存 → 回读;非法参数拒绝
|
||||||
|
w = authed(http.MethodGet, "/api/v1/suffix-admin/col-widths", "")
|
||||||
|
if w.Code != 200 {
|
||||||
|
t.Fatalf("读列宽 status=%d body=%s", w.Code, w.Body.String())
|
||||||
|
}
|
||||||
|
widths := getJSON(w)["data"].(map[string]any)["widths"].(map[string]any)
|
||||||
|
if widths["basic"].(map[string]any)["suffix"].(float64) != 50 {
|
||||||
|
t.Fatalf("basic.suffix 默认应为 50,got %v", widths["basic"].(map[string]any)["suffix"])
|
||||||
|
}
|
||||||
|
if _, has := widths["basic"].(map[string]any)["files"]; !has {
|
||||||
|
t.Fatal("basic 固定列应含 files")
|
||||||
|
}
|
||||||
|
w = authed(http.MethodPut, "/api/v1/suffix-admin/col-widths", `{"scope":"workspace","key":"ops","width":66}`)
|
||||||
|
if w.Code != 200 {
|
||||||
|
t.Fatalf("存列宽 status=%d body=%s", w.Code, w.Body.String())
|
||||||
|
}
|
||||||
|
w = authed(http.MethodGet, "/api/v1/suffix-admin/col-widths", "")
|
||||||
|
widths = getJSON(w)["data"].(map[string]any)["widths"].(map[string]any)
|
||||||
|
if widths["workspace"].(map[string]any)["ops"].(float64) != 66 {
|
||||||
|
t.Fatalf("workspace.ops 应为 66,got %v", widths["workspace"].(map[string]any)["ops"])
|
||||||
|
}
|
||||||
|
if widths["workspace"].(map[string]any)["suffix"].(float64) != 50 {
|
||||||
|
t.Fatalf("未保存过的 workspace.suffix 应仍为默认 50,got %v", widths["workspace"].(map[string]any)["suffix"])
|
||||||
|
}
|
||||||
|
w = authed(http.MethodPut, "/api/v1/suffix-admin/col-widths", `{"scope":"nope","key":"ops","width":66}`)
|
||||||
|
if w.Code != 400 {
|
||||||
|
t.Fatalf("非法 scope status=%d, want 400", w.Code)
|
||||||
|
}
|
||||||
|
w = authed(http.MethodPut, "/api/v1/suffix-admin/col-widths", `{"scope":"basic","key":"files","width":9999}`)
|
||||||
|
if w.Code != 400 {
|
||||||
|
t.Fatalf("列宽越界 status=%d, want 400", w.Code)
|
||||||
|
}
|
||||||
|
w = authed(http.MethodPut, "/api/v1/suffix-admin/col-widths", `{"scope":"basic","key":"nope","width":10}`)
|
||||||
|
if w.Code != 400 {
|
||||||
|
t.Fatalf("未知列 key status=%d, want 400", w.Code)
|
||||||
|
}
|
||||||
|
|
||||||
|
// 锚定行存值:保存 → 回读;空值清除;超长拒绝
|
||||||
w = authed(http.MethodPost, fmt.Sprintf("/api/v1/suffix-admin/dirs/%d/anchor", dirID),
|
w = authed(http.MethodPost, fmt.Sprintf("/api/v1/suffix-admin/dirs/%d/anchor", dirID),
|
||||||
fmt.Sprintf(`{"suffix_id":%d,"on":true}`, suffixID))
|
fmt.Sprintf(`{"suffix_id":%d,"value":"3"}`, suffixID))
|
||||||
if w.Code != 200 {
|
if w.Code != 200 {
|
||||||
t.Fatalf("锚定 status=%d", w.Code)
|
t.Fatalf("锚定 status=%d", w.Code)
|
||||||
}
|
}
|
||||||
@@ -252,8 +340,25 @@ func TestSuffixAdminIntegration(t *testing.T) {
|
|||||||
t.Fatal("找不到 cos4 行")
|
t.Fatal("找不到 cos4 行")
|
||||||
return nil
|
return nil
|
||||||
}()
|
}()
|
||||||
if !cos4["anchor"].(bool) {
|
if cos4["anchor_value"].(string) != "3" {
|
||||||
t.Fatal("锚定后 anchor 应为 true")
|
t.Fatalf("锚定后 anchor_value=%q, want 3", cos4["anchor_value"])
|
||||||
|
}
|
||||||
|
w = authed(http.MethodPost, fmt.Sprintf("/api/v1/suffix-admin/dirs/%d/anchor", dirID),
|
||||||
|
fmt.Sprintf(`{"suffix_id":%d,"value":""}`, suffixID))
|
||||||
|
if w.Code != 200 {
|
||||||
|
t.Fatalf("清锚定 status=%d", w.Code)
|
||||||
|
}
|
||||||
|
w = authed(http.MethodGet, fmt.Sprintf("/api/v1/suffix-admin/dirs/%d/page", dirID), "")
|
||||||
|
sfx = getJSON(w)["data"].(map[string]any)["suffixes"].([]any)
|
||||||
|
for _, line := range sfx {
|
||||||
|
if line.(map[string]any)["name"] == "cos4" && line.(map[string]any)["anchor_value"].(string) != "" {
|
||||||
|
t.Fatal("清空后 anchor_value 应为空")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
w = authed(http.MethodPost, fmt.Sprintf("/api/v1/suffix-admin/dirs/%d/anchor", dirID),
|
||||||
|
fmt.Sprintf(`{"suffix_id":%d,"value":"%s"}`, suffixID, strings.Repeat("长", 191)))
|
||||||
|
if w.Code != 400 {
|
||||||
|
t.Fatalf("超长锚定值 status=%d, want 400", w.Code)
|
||||||
}
|
}
|
||||||
|
|
||||||
// 模板上传(内容与哈希校验)→ 概览 → 删除
|
// 模板上传(内容与哈希校验)→ 概览 → 删除
|
||||||
@@ -274,6 +379,11 @@ func TestSuffixAdminIntegration(t *testing.T) {
|
|||||||
t.Fatalf("传模板 status=%d body=%s", w.Code, w.Body.String())
|
t.Fatalf("传模板 status=%d body=%s", w.Code, w.Body.String())
|
||||||
}
|
}
|
||||||
fileID := uint64(getJSON(w)["data"].(map[string]any)["id"].(float64))
|
fileID := uint64(getJSON(w)["data"].(map[string]any)["id"].(float64))
|
||||||
|
// 附件必须落盘在 attachments/<后缀id>/ 下
|
||||||
|
storedName := getJSON(w)["data"].(map[string]any)["file_name"].(string)
|
||||||
|
if _, err := os.Stat(filepath.Join(storageRoot, "attachments", strconv.FormatUint(suffixID, 10), storedName)); err != nil {
|
||||||
|
t.Fatalf("附件未落在 attachments 目录: %v", err)
|
||||||
|
}
|
||||||
badSum := sha256.Sum256([]byte("tampered"))
|
badSum := sha256.Sum256([]byte("tampered"))
|
||||||
w = authed(http.MethodPost, fmt.Sprintf("/api/v1/suffix-admin/suffixes/%d/files", suffixID),
|
w = authed(http.MethodPost, fmt.Sprintf("/api/v1/suffix-admin/suffixes/%d/files", suffixID),
|
||||||
fmt.Sprintf(`{"file_name":"坏.cos4","size":%d,"sha256":"%s","content_base64":"%s"}`,
|
fmt.Sprintf(`{"file_name":"坏.cos4","size":%d,"sha256":"%s","content_base64":"%s"}`,
|
||||||
|
|||||||
1
backend/migrations/000018_suffix_col_widths.down.sql
Normal file
1
backend/migrations/000018_suffix_col_widths.down.sql
Normal file
@@ -0,0 +1 @@
|
|||||||
|
DROP TABLE suffix_col_widths;
|
||||||
9
backend/migrations/000018_suffix_col_widths.up.sql
Normal file
9
backend/migrations/000018_suffix_col_widths.up.sql
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
-- Suffix management fixed-column widths (basic settings + directory workspace tables).
|
||||||
|
-- scope: 'basic' | 'workspace'; col_key: idx/suffix/files/ops/anchor; width 0 = auto.
|
||||||
|
CREATE TABLE suffix_col_widths (
|
||||||
|
scope VARCHAR(20) NOT NULL,
|
||||||
|
col_key VARCHAR(32) NOT NULL,
|
||||||
|
width INT NOT NULL DEFAULT 0,
|
||||||
|
updated_at TIMESTAMP(6) NOT NULL DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6),
|
||||||
|
PRIMARY KEY(scope,col_key)
|
||||||
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
|
||||||
2
backend/migrations/000019_rename_suffix_root.down.sql
Normal file
2
backend/migrations/000019_rename_suffix_root.down.sql
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
-- 回滚:恢复根目录名称
|
||||||
|
UPDATE suffix_dirs SET name='按信息价的目录' WHERE parent_id IS NULL AND name='建设项目';
|
||||||
2
backend/migrations/000019_rename_suffix_root.up.sql
Normal file
2
backend/migrations/000019_rename_suffix_root.up.sql
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
-- 根目录改名:按信息价的目录 → 建设项目(目录现已支持重命名,此处仅迁移存量数据)
|
||||||
|
UPDATE suffix_dirs SET name='建设项目' WHERE parent_id IS NULL AND name='按信息价的目录';
|
||||||
1
backend/migrations/000020_suffix_anchor_value.down.sql
Normal file
1
backend/migrations/000020_suffix_anchor_value.down.sql
Normal file
@@ -0,0 +1 @@
|
|||||||
|
ALTER TABLE suffix_dir_anchors DROP COLUMN value;
|
||||||
2
backend/migrations/000020_suffix_anchor_value.up.sql
Normal file
2
backend/migrations/000020_suffix_anchor_value.up.sql
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
-- 锚定行从 1/— 开关改为存值:value 为锚定内容(如行号),'' = 未锚定。
|
||||||
|
ALTER TABLE suffix_dir_anchors ADD COLUMN value VARCHAR(190) NOT NULL DEFAULT '';
|
||||||
1
backend/migrations/000021_suffix_file_publish.down.sql
Normal file
1
backend/migrations/000021_suffix_file_publish.down.sql
Normal file
@@ -0,0 +1 @@
|
|||||||
|
ALTER TABLE suffix_files DROP COLUMN published;
|
||||||
2
backend/migrations/000021_suffix_file_publish.up.sql
Normal file
2
backend/migrations/000021_suffix_file_publish.up.sql
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
-- 骨架文件发布状态:0=未发布,1=已发布
|
||||||
|
ALTER TABLE suffix_files ADD COLUMN published TINYINT(1) NOT NULL DEFAULT 0;
|
||||||
File diff suppressed because one or more lines are too long
@@ -4,10 +4,12 @@ import { api } from './api'
|
|||||||
|
|
||||||
export type SuffixDir = { id:number; parent_id:number; name:string; sort_order:number; children:number }
|
export type SuffixDir = { id:number; parent_id:number; name:string; sort_order:number; children:number }
|
||||||
export type SuffixColumn = { id:number; name:string; is_value:boolean; width:number }
|
export type SuffixColumn = { id:number; name:string; is_value:boolean; width:number }
|
||||||
export type SuffixLine = { id:number; group_id:number; group_name:string; name:string; anchor:boolean }
|
export type SuffixLine = { id:number; group_id:number; group_name:string; name:string; anchor_value:string }
|
||||||
export type SuffixPage = { dir_id:number; columns:SuffixColumn[]; suffixes:SuffixLine[]; cells:Record<string,string> }
|
export type SuffixPage = { dir_id:number; columns:SuffixColumn[]; suffixes:SuffixLine[]; cells:Record<string,string> }
|
||||||
export type SuffixFile = { id:number; suffix_id?:number; file_name:string; file_size:number; created_at?:string; sha256?:string }
|
export type SuffixFile = { id:number; suffix_id?:number; file_name:string; file_size:number; created_at?:string; sha256?:string; published?:boolean }
|
||||||
export type SuffixGroup = { id:number; name:string; suffixes:{ id:number; name:string; files:SuffixFile[] }[] }
|
export type SuffixGroup = { id:number; name:string; suffixes:{ id:number; name:string; files:SuffixFile[] }[] }
|
||||||
|
// 固定列列宽(basic: idx/suffix/files/ops;workspace: idx/suffix/ops/anchor),0=自适应
|
||||||
|
export type SuffixColWidths = { basic:Record<string,number>; workspace:Record<string,number> }
|
||||||
|
|
||||||
export const getSuffixTree = () => api.get<{data:{dirs:SuffixDir[]}}>('/suffix-admin/tree')
|
export const getSuffixTree = () => api.get<{data:{dirs:SuffixDir[]}}>('/suffix-admin/tree')
|
||||||
export const createSuffixDir = (parent_id:number, name:string) => api.post<{data:SuffixDir}>('/suffix-admin/dirs', { parent_id, name })
|
export const createSuffixDir = (parent_id:number, name:string) => api.post<{data:SuffixDir}>('/suffix-admin/dirs', { parent_id, name })
|
||||||
@@ -17,10 +19,13 @@ export const deleteSuffixDir = (id:number) => api.delete(`/suffix-admin/dirs/${i
|
|||||||
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, after_id = 0, width = 0) => api.post<{data:SuffixColumn}>(`/suffix-admin/dirs/${dirId}/columns`, { name, is_value, after_id, width })
|
export const createSuffixColumn = (dirId:number, name:string, is_value:boolean, after_id = 0, width = 0) => api.post<{data:SuffixColumn}>(`/suffix-admin/dirs/${dirId}/columns`, { name, is_value, after_id, width })
|
||||||
export const updateSuffixColumnWidth = (id:number, width:number) => api.patch<{data:{id:number;width:number}}>(`/suffix-admin/columns/${id}`, { width })
|
export const updateSuffixColumnWidth = (id:number, width:number) => api.patch<{data:{id:number;width:number}}>(`/suffix-admin/columns/${id}`, { width })
|
||||||
|
export const renameSuffixColumn = (id:number, name:string) => api.patch<{data:SuffixColumn}>(`/suffix-admin/columns/${id}`, { name })
|
||||||
export const reorderSuffixColumns = (dirId:number, ids:number[]) => api.post<{data:{ok:boolean;ordered:number}}>(`/suffix-admin/dirs/${dirId}/columns/order`, { ids })
|
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 getSuffixColWidths = () => api.get<{data:{widths:SuffixColWidths}}>('/suffix-admin/col-widths')
|
||||||
|
export const updateSuffixColWidth = (scope:'basic'|'workspace', key:string, width:number) => api.put<{data:{scope:string;key:string;width:number}}>('/suffix-admin/col-widths', { scope, key, width })
|
||||||
|
export const setSuffixAnchor = (dirId:number, suffix_id:number, value:string) => api.post(`/suffix-admin/dirs/${dirId}/anchor`, { suffix_id, value })
|
||||||
export const getSuffixOverview = () => api.get<{data:{groups:SuffixGroup[]}}>('/suffix-admin/overview')
|
export const getSuffixOverview = () => api.get<{data:{groups:SuffixGroup[]}}>('/suffix-admin/overview')
|
||||||
export const createSuffixGroup = (name:string, first_suffix_name = '') => api.post<{data:SuffixGroup}>('/suffix-admin/groups', { name, first_suffix_name })
|
export const createSuffixGroup = (name:string, first_suffix_name = '') => api.post<{data:SuffixGroup}>('/suffix-admin/groups', { name, first_suffix_name })
|
||||||
export const renameSuffixGroup = (id:number, name:string) => api.put(`/suffix-admin/groups/${id}`, { name })
|
export const renameSuffixGroup = (id:number, name:string) => api.put(`/suffix-admin/groups/${id}`, { name })
|
||||||
@@ -30,8 +35,10 @@ export const createSuffix = (group_id:number, name:string, after_id = 0) => api.
|
|||||||
export const renameSuffix = (id:number, name:string) => api.put(`/suffix-admin/suffixes/${id}`, { name })
|
export const renameSuffix = (id:number, name:string) => api.put(`/suffix-admin/suffixes/${id}`, { name })
|
||||||
export const moveSuffix = (id:number, dir:number) => api.post(`/suffix-admin/suffixes/${id}/move`, { dir })
|
export const moveSuffix = (id:number, dir:number) => api.post(`/suffix-admin/suffixes/${id}/move`, { dir })
|
||||||
export const deleteSuffix = (id:number) => api.delete(`/suffix-admin/suffixes/${id}`)
|
export const deleteSuffix = (id:number) => api.delete(`/suffix-admin/suffixes/${id}`)
|
||||||
export const uploadSuffixFile = (id:number, body:{file_name:string;size:number;sha256:string;content_base64:string}) => api.post<{data:SuffixFile}>(`/suffix-admin/suffixes/${id}/files`, body)
|
// 大文件 base64 上传耗时较长,单独关闭全局 8s 超时,避免被前端掐断后只剩兜底报错。
|
||||||
|
export const uploadSuffixFile = (id:number, body:{file_name:string;size:number;sha256:string;content_base64:string}) => api.post<{data:SuffixFile}>(`/suffix-admin/suffixes/${id}/files`, body, { timeout: 0 })
|
||||||
export const deleteSuffixFile = (id:number) => api.delete(`/suffix-admin/files/${id}`)
|
export const deleteSuffixFile = (id:number) => api.delete(`/suffix-admin/files/${id}`)
|
||||||
|
export const publishSuffixFile = (id:number, on:boolean) => api.post(`/suffix-admin/files/${id}/publish`, { on })
|
||||||
export const suffixFileUrl = (id:number) => `/api/v1/suffix-admin/files/${id}/download`
|
export const suffixFileUrl = (id:number) => `/api/v1/suffix-admin/files/${id}/download`
|
||||||
|
|
||||||
// 读文件:算 sha256 + 分块转 base64(与后端上传接口配对)。
|
// 读文件:算 sha256 + 分块转 base64(与后端上传接口配对)。
|
||||||
|
|||||||
@@ -134,7 +134,7 @@ async function submitRenewal() {
|
|||||||
onMounted(() => { checkConnection(); checkSession() })
|
onMounted(() => { checkConnection(); checkSession() })
|
||||||
</script>
|
</script>
|
||||||
<template>
|
<template>
|
||||||
<div class="workspace" :class="{'admin-workspace':loggedIn,'nav-collapsed':navCollapsed}"><aside v-if="loggedIn" class="sidebar"><div class="brand"><span class="brand-mark">L</span><div>{{siteSettings?.site_name || 'License Hub'}}</div></div><nav class="nav" aria-label="管理台导航"><template v-for="(item,index) in nav" :key="item.path"><div v-if="index===0||index===1||index===8" class="nav-label">{{index===0?'工作台':index===1?'业务管理':'系统'}}</div><router-link :to="item.path" :class="{active:pageView===item.view}" :title="item.name"><span class="ico">{{item.icon}}</span><span>{{item.name}}</span></router-link></template></nav><div class="sidebar-footer"><span class="user-dot">{{adminEmail.slice(0,1).toUpperCase()}}</span><span class="footer-email">{{adminEmail}}</span><button v-if="loggedIn" type="button" class="side-logout" title="退出登录" @click="signOut">退出</button></div></aside><div class="nav-fold" :class="{ collapsed: navCollapsed }" :title="navCollapsed ? '展开菜单' : '收起菜单'" @click="toggleNav">{{ navCollapsed ? '›' : '‹' }}</div><div class="main"><header class="topbar"><span v-if="loggedIn" class="crumb">{{pageView==='dashboard'?'工作台':'管理台'}} <strong>/ {{title}}</strong></span><span v-else class="wordmark"><span class="mark">L</span>License Hub</span><span v-if="pageView!=='suffixes'" class="environment">内部管理台</span></header>
|
<div class="workspace" :class="{'admin-workspace':loggedIn,'nav-collapsed':navCollapsed}"><aside v-if="loggedIn" class="sidebar"><div class="brand"><span class="brand-mark">L</span><div>{{siteSettings?.site_name || 'License Hub'}}</div></div><nav class="nav" aria-label="管理台导航"><template v-for="(item,index) in nav" :key="item.path"><div v-if="index===0||index===1||index===8" class="nav-label">{{index===0?'工作台':index===1?'业务管理':'系统'}}</div><router-link :to="item.path" :class="{active:pageView===item.view}" :title="item.name"><span class="ico">{{item.icon}}</span><span>{{item.name}}</span></router-link></template></nav><div class="sidebar-footer"><span class="user-dot">{{adminEmail.slice(0,1).toUpperCase()}}</span><span class="footer-email">{{adminEmail}}</span><button v-if="loggedIn" type="button" class="side-logout" title="退出登录" @click="signOut">退出</button></div></aside><div class="nav-fold" :class="{ collapsed: navCollapsed }" :title="navCollapsed ? '展开菜单' : '收起菜单'" @click="toggleNav">{{ navCollapsed ? '›' : '‹' }}</div><div class="main"><header v-if="pageView!=='suffixes'" class="topbar"><span v-if="loggedIn" class="crumb">{{pageView==='dashboard'?'工作台':'管理台'}} <strong>/ {{title}}</strong></span><span v-else class="wordmark"><span class="mark">L</span>License Hub</span><span v-if="pageView!=='suffixes'" class="environment">内部管理台</span></header>
|
||||||
<main class="content" v-if="!loggedIn"><section class="status-section" aria-labelledby="api-title"><div><h2 id="api-title">API 连通性</h2><p>服务状态仅表示存活端点可访问。</p></div><div><span class="status" :class="connection" role="status">{{ connection === 'checking' ? '检测中' : connection === 'online' ? '服务在线' : '服务未连接' }}</span><el-button link @click="checkConnection">重新检测</el-button></div></section><section class="login-panel"><p class="eyebrow">内部管理员</p><h1>登录管理台</h1><p class="subheading">使用管理员用户名和密码登录。</p><el-form @submit.prevent="signIn"><el-input v-model="username" aria-label="用户名" placeholder="用户名" autocomplete="username"/><el-input v-model="password" type="password" show-password placeholder="密码" autocomplete="current-password" @keyup.enter="signIn"/><el-button type="primary" :loading="loading" @click="signIn">登录</el-button></el-form><p v-if="error" class="error">{{ error }}</p></section></main>
|
<main class="content" v-if="!loggedIn"><section class="status-section" aria-labelledby="api-title"><div><h2 id="api-title">API 连通性</h2><p>服务状态仅表示存活端点可访问。</p></div><div><span class="status" :class="connection" role="status">{{ connection === 'checking' ? '检测中' : connection === 'online' ? '服务在线' : '服务未连接' }}</span><el-button link @click="checkConnection">重新检测</el-button></div></section><section class="login-panel"><p class="eyebrow">内部管理员</p><h1>登录管理台</h1><p class="subheading">使用管理员用户名和密码登录。</p><el-form @submit.prevent="signIn"><el-input v-model="username" aria-label="用户名" placeholder="用户名" autocomplete="username"/><el-input v-model="password" type="password" show-password placeholder="密码" autocomplete="current-password" @keyup.enter="signIn"/><el-button type="primary" :loading="loading" @click="signIn">登录</el-button></el-form><p v-if="error" class="error">{{ error }}</p></section></main>
|
||||||
<main class="content" v-else :class="{'content-suffix':pageView==='suffixes'}"><p v-if="siteSettings?.announcement" class="site-announcement" role="note">{{siteSettings.announcement}}</p><p v-if="siteSettings?.support_email" class="subheading">支持联系:<a :href="`mailto:${siteSettings.support_email}`">{{siteSettings.support_email}}</a></p><DashboardPanel v-if="pageView==='dashboard'" @issue="openIssue" @detail="showDetail"/><div v-else-if="pageView==='suffixes'" class="suffix-page-host"><SuffixPanel/></div><div v-else class="heading"><div><p class="eyebrow">内部管理台</p><h1>{{title}}</h1><p class="subheading">{{pageView==='payments'?'查看渠道启用状态和最近支付流水':pageView==='admins'?'管理后台账户、启停状态和密码':pageView==='audit'?'查看管理员操作记录':pageView==='settings'?'管理站点展示信息及管理员密码':'客户、订单、授权及实例状态'}}</p></div><el-button v-if="pageView!=='payments'&&pageView!=='admins'&&pageView!=='audit'&&pageView!=='settings'" :loading="loading" @click="refresh">刷新</el-button></div><p v-if="error&&pageView!=='payments'&&pageView!=='admins'&&pageView!=='audit'&&pageView!=='settings'" class="error">{{ error }}</p>
|
<main class="content" v-else :class="{'content-suffix':pageView==='suffixes'}"><p v-if="siteSettings?.announcement" class="site-announcement" role="note">{{siteSettings.announcement}}</p><p v-if="siteSettings?.support_email" class="subheading">支持联系:<a :href="`mailto:${siteSettings.support_email}`">{{siteSettings.support_email}}</a></p><DashboardPanel v-if="pageView==='dashboard'" @issue="openIssue" @detail="showDetail"/><div v-else-if="pageView==='suffixes'" class="suffix-page-host"><SuffixPanel/></div><div v-else class="heading"><div><p class="eyebrow">内部管理台</p><h1>{{title}}</h1><p class="subheading">{{pageView==='payments'?'查看渠道启用状态和最近支付流水':pageView==='admins'?'管理后台账户、启停状态和密码':pageView==='audit'?'查看管理员操作记录':pageView==='settings'?'管理站点展示信息及管理员密码':'客户、订单、授权及实例状态'}}</p></div><el-button v-if="pageView!=='payments'&&pageView!=='admins'&&pageView!=='audit'&&pageView!=='settings'" :loading="loading" @click="refresh">刷新</el-button></div><p v-if="error&&pageView!=='payments'&&pageView!=='admins'&&pageView!=='audit'&&pageView!=='settings'" class="error">{{ error }}</p>
|
||||||
<div v-if="pageView==='customers'" class="admin-module">
|
<div v-if="pageView==='customers'" class="admin-module">
|
||||||
|
|||||||
@@ -1,8 +1,9 @@
|
|||||||
import { mount, flushPromises } from '@vue/test-utils'
|
import { mount, flushPromises } from '@vue/test-utils'
|
||||||
import { afterEach, describe, expect, it, vi } from 'vitest'
|
import { afterEach, describe, expect, it, vi } from 'vitest'
|
||||||
import SuffixPanel from './SuffixPanel.vue'
|
import SuffixPanel from './SuffixPanel.vue'
|
||||||
|
import { ElMessage, ElMessageBox } from 'element-plus'
|
||||||
import {
|
import {
|
||||||
createSuffixColumn, getSuffixOverview, getSuffixPage, getSuffixTree, updateSuffixColumnWidth,
|
createSuffixColumn, deleteSuffixColumn, getSuffixColWidths, getSuffixOverview, getSuffixPage, getSuffixTree, renameSuffixColumn, setSuffixAnchor, updateSuffixColWidth, updateSuffixColumnWidth,
|
||||||
} from '../suffix-admin'
|
} from '../suffix-admin'
|
||||||
|
|
||||||
vi.mock('../suffix-admin', () => ({
|
vi.mock('../suffix-admin', () => ({
|
||||||
@@ -15,6 +16,9 @@ vi.mock('../suffix-admin', () => ({
|
|||||||
suffixFileUrl: (id: number) => `/api/v1/suffix-admin/files/${id}/download`,
|
suffixFileUrl: (id: number) => `/api/v1/suffix-admin/files/${id}/download`,
|
||||||
getSuffixTree: vi.fn(),
|
getSuffixTree: vi.fn(),
|
||||||
updateSuffixColumnWidth: vi.fn(),
|
updateSuffixColumnWidth: vi.fn(),
|
||||||
|
renameSuffixColumn: vi.fn(),
|
||||||
|
getSuffixColWidths: vi.fn(),
|
||||||
|
updateSuffixColWidth: vi.fn(),
|
||||||
createSuffixDir: vi.fn(),
|
createSuffixDir: vi.fn(),
|
||||||
renameSuffixDir: vi.fn(),
|
renameSuffixDir: vi.fn(),
|
||||||
moveSuffixDir: vi.fn(),
|
moveSuffixDir: vi.fn(),
|
||||||
@@ -52,20 +56,21 @@ const directives = { loading: () => {} }
|
|||||||
|
|
||||||
const ok = (data: unknown) => ({ data: { data } })
|
const ok = (data: unknown) => ({ data: { data } })
|
||||||
const dirs = [
|
const dirs = [
|
||||||
{ id: 1, parent_id: 0, name: '按信息价的目录', sort_order: 0, children: 1 },
|
{ id: 1, parent_id: 0, name: '建设项目', sort_order: 0, children: 1 },
|
||||||
{ id: 2, parent_id: 1, name: '一、黑色及有色金属', sort_order: 1, children: 0 },
|
{ id: 2, parent_id: 1, name: '一、黑色及有色金属', sort_order: 1, children: 0 },
|
||||||
]
|
]
|
||||||
const page = {
|
const page = {
|
||||||
dir_id: 2,
|
dir_id: 2,
|
||||||
columns: [{ id: 5, name: '招标人', is_value: false }],
|
columns: [{ id: 5, name: '招标人', is_value: false }],
|
||||||
suffixes: [{ id: 10, group_id: 1, group_name: '广东省', name: 'cos4', anchor: false }],
|
suffixes: [{ id: 10, group_id: 1, group_name: '广东省', name: 'cos4', anchor_value: '' }],
|
||||||
cells: {},
|
cells: {},
|
||||||
}
|
}
|
||||||
|
|
||||||
function setup() {
|
function setup(widths: Record<string, Record<string, number>> = {}) {
|
||||||
vi.mocked(getSuffixOverview).mockResolvedValue(ok({ groups: [{ id: 1, name: '广东省', suffixes: [{ id: 10, name: 'cos4', files: [] }] }] }) as never)
|
vi.mocked(getSuffixOverview).mockResolvedValue(ok({ groups: [{ id: 1, name: '广东省', suffixes: [{ id: 10, name: 'cos4', files: [] }] }] }) as never)
|
||||||
vi.mocked(getSuffixTree).mockResolvedValue(ok({ dirs }) as never)
|
vi.mocked(getSuffixTree).mockResolvedValue(ok({ dirs }) as never)
|
||||||
vi.mocked(getSuffixPage).mockResolvedValue(ok(page) as never)
|
vi.mocked(getSuffixPage).mockResolvedValue(ok(page) as never)
|
||||||
|
vi.mocked(getSuffixColWidths).mockResolvedValue(ok({ widths }) as never)
|
||||||
const wrapper = mount(SuffixPanel, { global: { stubs, directives } })
|
const wrapper = mount(SuffixPanel, { global: { stubs, directives } })
|
||||||
return wrapper
|
return wrapper
|
||||||
}
|
}
|
||||||
@@ -77,37 +82,134 @@ describe('SuffixPanel', () => {
|
|||||||
const wrapper = setup()
|
const wrapper = setup()
|
||||||
await flushPromises()
|
await flushPromises()
|
||||||
expect(wrapper.text()).toContain('基本设置')
|
expect(wrapper.text()).toContain('基本设置')
|
||||||
expect(wrapper.text()).toContain('按信息价的目录')
|
expect(wrapper.text()).toContain('建设项目')
|
||||||
expect(wrapper.text()).toContain('广东省')
|
expect(wrapper.text()).toContain('广东省')
|
||||||
expect(wrapper.text()).toContain('cos4')
|
expect(wrapper.text()).toContain('cos4')
|
||||||
expect(wrapper.text()).toContain('上传模板')
|
expect(wrapper.find('button[title="上传模板"]').exists()).toBe(true)
|
||||||
expect(wrapper.text()).toContain('+ 新建分组')
|
expect(wrapper.text()).toContain('+ 新建分组')
|
||||||
})
|
})
|
||||||
|
|
||||||
it('adds a column with the 值设置 flag through the dialog', async () => {
|
it('lists workspace rows flat without region group headers', async () => {
|
||||||
const wrapper = setup()
|
|
||||||
await flushPromises()
|
|
||||||
await wrapper.findAll('.side-name').find((n) => n.text() === '一、黑色及有色金属')!.trigger('click')
|
|
||||||
await flushPromises()
|
|
||||||
expect(wrapper.text()).toContain('招标人')
|
|
||||||
await wrapper.findAll('button').find((b) => b.text() === '+ 添加列')!.trigger('click')
|
|
||||||
expect(wrapper.text()).toContain('值设置')
|
|
||||||
const inputs = wrapper.findAll('.dialog-stub input')
|
|
||||||
await inputs[0].setValue('招标人')
|
|
||||||
await wrapper.find('.dialog-stub input[type="checkbox"]').setValue(true)
|
|
||||||
vi.mocked(createSuffixColumn).mockResolvedValue(ok({ id: 9, name: '招标人', is_value: true }) as never)
|
|
||||||
await wrapper.findAll('button').find((b) => b.text() === '确定')!.trigger('click')
|
|
||||||
await flushPromises()
|
|
||||||
expect(createSuffixColumn).toHaveBeenCalledWith(2, '招标人', true, 0, 0)
|
|
||||||
})
|
|
||||||
|
|
||||||
it('lists workspace rows grouped by province with fixed 锚定行 column', async () => {
|
|
||||||
const wrapper = setup()
|
const wrapper = setup()
|
||||||
await flushPromises()
|
await flushPromises()
|
||||||
await wrapper.findAll('.side-name').find((n) => n.text() === '一、黑色及有色金属')!.trigger('click')
|
await wrapper.findAll('.side-name').find((n) => n.text() === '一、黑色及有色金属')!.trigger('click')
|
||||||
await flushPromises()
|
await flushPromises()
|
||||||
expect(wrapper.text()).toContain('锚定行')
|
expect(wrapper.text()).toContain('锚定行')
|
||||||
expect(wrapper.text()).toContain('− 广东省')
|
expect(wrapper.text()).not.toContain('− 广东省')
|
||||||
|
expect(wrapper.text()).toContain('cos4')
|
||||||
expect(wrapper.findAll('td.anchor').length).toBeGreaterThan(0)
|
expect(wrapper.findAll('td.anchor').length).toBeGreaterThan(0)
|
||||||
|
expect(wrapper.findAll('tr.data-tr').length).toBe(1)
|
||||||
|
})
|
||||||
|
|
||||||
|
it('applies default widths and saves every fixed column width', async () => {
|
||||||
|
page.columns = [{ id: 5, name: '招标人', is_value: false }]
|
||||||
|
const wrapper = setup({ workspace: { suffix: 88 } })
|
||||||
|
await flushPromises()
|
||||||
|
// 基本设置表:后缀默认 50px、导入文件 0=自适应占满、操作列收窄为默认 150px
|
||||||
|
const basicCols = wrapper.findAll('table.basic col')
|
||||||
|
expect(basicCols.length).toBe(4)
|
||||||
|
expect(basicCols[0].attributes('style')).toContain('50px')
|
||||||
|
expect(basicCols[1].attributes('style')).toContain('50px')
|
||||||
|
expect(basicCols[2].attributes('style')).toBeUndefined()
|
||||||
|
expect(basicCols[3].attributes('style')).toContain('150px')
|
||||||
|
|
||||||
|
// 目录工作区表:保存过的后缀列宽生效,其余用默认;3 固定列(无操作列)+ 自定义列
|
||||||
|
await wrapper.findAll('.side-name').find((n) => n.text() === '一、黑色及有色金属')!.trigger('click')
|
||||||
|
await flushPromises()
|
||||||
|
const wsCols = wrapper.findAll('table.sheet:not(.basic)')[0].findAll('col')
|
||||||
|
expect(wsCols.length).toBe(4)
|
||||||
|
expect(wsCols[1].attributes('style')).toContain('88px')
|
||||||
|
expect(wsCols[2].attributes('style')).toContain('300px')
|
||||||
|
|
||||||
|
// 列设置弹框顶部固定列宽度可改并保存
|
||||||
|
vi.mocked(updateSuffixColWidth).mockResolvedValue(ok({ scope: 'workspace', key: 'idx', width: 66 }) as never)
|
||||||
|
await wrapper.findAll('button').find((b) => b.text() === '列设置')!.trigger('click')
|
||||||
|
const fixedInputs = wrapper.findAll('.col-order-row.fixed-row .co-width')
|
||||||
|
expect(fixedInputs.length).toBe(3)
|
||||||
|
await fixedInputs[0].setValue('66')
|
||||||
|
await fixedInputs[0].trigger('change')
|
||||||
|
await flushPromises()
|
||||||
|
expect(updateSuffixColWidth).toHaveBeenCalledWith('workspace', 'idx', 66)
|
||||||
|
|
||||||
|
// 基本设置「列宽」弹框:固定列同样可改(先关掉列设置弹框,避免两个弹框同时开着)
|
||||||
|
vi.mocked(updateSuffixColWidth).mockClear()
|
||||||
|
vi.mocked(updateSuffixColWidth).mockResolvedValue(ok({ scope: 'basic', key: 'files', width: 300 }) as never)
|
||||||
|
await wrapper.findAll('button').filter((b) => b.text() === '关闭').at(-1)!.trigger('click')
|
||||||
|
await wrapper.findAll('.side-root').find((n) => n.text() === '基本设置')!.trigger('click')
|
||||||
|
await flushPromises()
|
||||||
|
await wrapper.findAll('button').find((b) => b.text() === '列宽')!.trigger('click')
|
||||||
|
const basicInputs = wrapper.findAll('.dialog-stub .col-order-row.fixed-row .co-width')
|
||||||
|
expect(basicInputs.length).toBe(4)
|
||||||
|
await basicInputs[2].setValue('300')
|
||||||
|
await basicInputs[2].trigger('change')
|
||||||
|
await flushPromises()
|
||||||
|
expect(updateSuffixColWidth).toHaveBeenCalledWith('basic', 'files', 300)
|
||||||
|
})
|
||||||
|
|
||||||
|
it('edits the anchor value by double-clicking the cell', async () => {
|
||||||
|
const wrapper = setup()
|
||||||
|
await flushPromises()
|
||||||
|
await wrapper.findAll('.side-name').find((n) => n.text() === '一、黑色及有色金属')!.trigger('click')
|
||||||
|
await flushPromises()
|
||||||
|
// 双击锚定行 → 弹出输入框 → 填值回车保存
|
||||||
|
await wrapper.find('td.anchor').trigger('dblclick')
|
||||||
|
const input = wrapper.find('td.anchor .cell-input')
|
||||||
|
expect(input.exists()).toBe(true)
|
||||||
|
vi.mocked(setSuffixAnchor).mockResolvedValue(ok({ ok: true }) as never)
|
||||||
|
await input.setValue('3')
|
||||||
|
await input.trigger('keyup.enter')
|
||||||
|
await flushPromises()
|
||||||
|
expect(setSuffixAnchor).toHaveBeenCalledWith(2, 10, '3')
|
||||||
|
expect(wrapper.find('td.anchor').text()).toContain('3')
|
||||||
|
|
||||||
|
// 留空保存 = 清除锚定
|
||||||
|
await wrapper.find('td.anchor').trigger('dblclick')
|
||||||
|
const input2 = wrapper.find('td.anchor .cell-input')
|
||||||
|
vi.mocked(setSuffixAnchor).mockClear()
|
||||||
|
await input2.setValue('')
|
||||||
|
await input2.trigger('keyup.enter')
|
||||||
|
await flushPromises()
|
||||||
|
expect(setSuffixAnchor).toHaveBeenCalledWith(2, 10, '')
|
||||||
|
expect(wrapper.find('td.anchor').text()).toContain('—')
|
||||||
|
})
|
||||||
|
|
||||||
|
it('renames a custom column from the 列设置 dialog', async () => {
|
||||||
|
page.columns = [{ id: 5, name: '招标人', is_value: false }]
|
||||||
|
const wrapper = setup()
|
||||||
|
await flushPromises()
|
||||||
|
await wrapper.findAll('.side-name').find((n) => n.text() === '一、黑色及有色金属')!.trigger('click')
|
||||||
|
await flushPromises()
|
||||||
|
await wrapper.findAll('button').find((b) => b.text() === '列设置')!.trigger('click')
|
||||||
|
const row = wrapper.findAll('.col-order-row').find((r) => !r.classes().includes('fixed-row'))!
|
||||||
|
vi.mocked(ElMessageBox.prompt).mockResolvedValue({ value: '招标单位' } as never)
|
||||||
|
vi.mocked(renameSuffixColumn).mockResolvedValue(ok({ id: 5, name: '招标单位', is_value: false, width: 0 }) as never)
|
||||||
|
await row.find('button[title="重命名列"]').trigger('click')
|
||||||
|
await flushPromises()
|
||||||
|
expect(renameSuffixColumn).toHaveBeenCalledWith(5, '招标单位')
|
||||||
|
expect(wrapper.text()).toContain('招标单位')
|
||||||
|
})
|
||||||
|
|
||||||
|
it('refuses to delete a column that has values but deletes an empty one', async () => {
|
||||||
|
page.columns = [{ id: 5, name: '招标人', is_value: false }]
|
||||||
|
page.cells = { '10:5': '普通文本' }
|
||||||
|
const wrapper = setup()
|
||||||
|
await flushPromises()
|
||||||
|
await wrapper.findAll('.side-name').find((n) => n.text() === '一、黑色及有色金属')!.trigger('click')
|
||||||
|
await flushPromises()
|
||||||
|
await wrapper.find('.custom-th .th-x').trigger('click')
|
||||||
|
expect(ElMessage.warning).toHaveBeenCalledWith('列「招标人」已有数据,不能删除')
|
||||||
|
expect(deleteSuffixColumn).not.toHaveBeenCalled()
|
||||||
|
|
||||||
|
page.cells = {}
|
||||||
|
const empty = setup()
|
||||||
|
await flushPromises()
|
||||||
|
await empty.findAll('.side-name').find((n) => n.text() === '一、黑色及有色金属')!.trigger('click')
|
||||||
|
await flushPromises()
|
||||||
|
vi.mocked(ElMessageBox.confirm).mockResolvedValue('confirm' as never)
|
||||||
|
vi.mocked(deleteSuffixColumn).mockResolvedValue(ok({ deleted: 5 }) as never)
|
||||||
|
await empty.find('.custom-th .th-x').trigger('click')
|
||||||
|
await flushPromises()
|
||||||
|
expect(deleteSuffixColumn).toHaveBeenCalledWith(5)
|
||||||
|
expect(empty.text()).not.toContain('招标人')
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -3,10 +3,10 @@ import { computed, onMounted, reactive, ref } from 'vue'
|
|||||||
import { ElMessage, ElMessageBox } from 'element-plus'
|
import { ElMessage, ElMessageBox } from 'element-plus'
|
||||||
import {
|
import {
|
||||||
buildValueCell, createSuffix, createSuffixColumn, createSuffixDir, createSuffixGroup,
|
buildValueCell, createSuffix, createSuffixColumn, createSuffixDir, createSuffixGroup,
|
||||||
deleteSuffix, deleteSuffixColumn, deleteSuffixDir, deleteSuffixFile, deleteSuffixGroup,
|
deleteSuffix, deleteSuffixColumn, deleteSuffixDir, deleteSuffixFile, deleteSuffixGroup, publishSuffixFile,
|
||||||
updateSuffixColumnWidth, formatSuffixSize, getSuffixOverview, getSuffixPage, getSuffixTree, moveSuffix, moveSuffixDir,
|
updateSuffixColumnWidth, formatSuffixSize, getSuffixColWidths, getSuffixOverview, getSuffixPage, getSuffixTree, moveSuffix, moveSuffixDir,
|
||||||
moveSuffixGroup, parseValueCell, readSuffixFile, renameSuffixDir,
|
moveSuffixGroup, parseValueCell, readSuffixFile, renameSuffixDir,
|
||||||
renameSuffixGroup, reorderSuffixColumns, saveSuffixCell, setSuffixAnchor, suffixFileUrl, uploadSuffixFile,
|
renameSuffixGroup, reorderSuffixColumns, renameSuffixColumn, saveSuffixCell, setSuffixAnchor, suffixFileUrl, updateSuffixColWidth, uploadSuffixFile,
|
||||||
type SuffixColumn, type SuffixDir, type SuffixFile, type SuffixPage,
|
type SuffixColumn, type SuffixDir, type SuffixFile, type SuffixPage,
|
||||||
} from '../suffix-admin'
|
} from '../suffix-admin'
|
||||||
|
|
||||||
@@ -20,19 +20,64 @@ const page = ref<SuffixPage | null>(null)
|
|||||||
const pageLoading = ref(false)
|
const pageLoading = ref(false)
|
||||||
const overviewLoading = ref(false)
|
const overviewLoading = ref(false)
|
||||||
|
|
||||||
// 增加列弹框(列名 + 值设置复选框)
|
|
||||||
const colDialog = reactive({ visible: false, name: '', isValue: false, width: 0, saving: false })
|
|
||||||
const dirCollapsed = ref(localStorage.getItem('suffixDirCollapsed') === '1')
|
const dirCollapsed = ref(localStorage.getItem('suffixDirCollapsed') === '1')
|
||||||
function toggleDirFold() { dirCollapsed.value = !dirCollapsed.value; try { localStorage.setItem('suffixDirCollapsed', dirCollapsed.value ? '1' : '0') } catch {} }
|
function toggleDirFold() { dirCollapsed.value = !dirCollapsed.value; try { localStorage.setItem('suffixDirCollapsed', dirCollapsed.value ? '1' : '0') } catch {} }
|
||||||
// 单元格编辑
|
// 单元格编辑(双击任意单元格直接进入编辑)
|
||||||
const editing = reactive({ sid: 0, cid: 0, text: '', a: '', v: '' })
|
const editing = reactive({ sid: 0, cid: 0, text: '', a: '', v: '' })
|
||||||
// 行编辑态(视觉高亮,格子弹出编辑不受它限制)
|
|
||||||
const editRows = ref<Set<number>>(new Set())
|
|
||||||
// 上传
|
// 上传
|
||||||
const uploadInput = ref<HTMLInputElement | null>(null)
|
const uploadInput = ref<HTMLInputElement | null>(null)
|
||||||
const uploadTarget = ref(0)
|
const uploadTarget = ref(0)
|
||||||
const uploading = ref(false)
|
const uploading = ref(false)
|
||||||
|
|
||||||
|
// 固定列列宽(与后端 suffixColWidthDefaults 一致):0=自适应,导入文件为 0 时占满剩余宽度
|
||||||
|
const FIXED_COL_DEFAULTS: Record<string, Record<string, number>> = {
|
||||||
|
basic: { idx: 50, suffix: 50, files: 0, ops: 150 },
|
||||||
|
workspace: { idx: 50, suffix: 50, anchor: 300 },
|
||||||
|
}
|
||||||
|
const basicFixedCols = [
|
||||||
|
{ key: 'idx', name: '序号' },
|
||||||
|
{ key: 'suffix', name: '后缀' },
|
||||||
|
{ key: 'files', name: '导入文件' },
|
||||||
|
{ key: 'ops', name: '操作' },
|
||||||
|
]
|
||||||
|
const wsFixedCols = [
|
||||||
|
{ key: 'idx', name: '序号' },
|
||||||
|
{ key: 'suffix', name: '后缀' },
|
||||||
|
{ key: 'anchor', name: '锚定行' },
|
||||||
|
]
|
||||||
|
const fixedWidths = ref<Record<string, Record<string, number>>>({})
|
||||||
|
const basicWidths = reactive({ visible: false })
|
||||||
|
|
||||||
|
function wOf(scope: string, key: string): number {
|
||||||
|
const w = fixedWidths.value[scope]?.[key]
|
||||||
|
return w === undefined ? FIXED_COL_DEFAULTS[scope][key] : w
|
||||||
|
}
|
||||||
|
|
||||||
|
function colW(w: number) {
|
||||||
|
return w > 0 ? { width: w + 'px' } : undefined
|
||||||
|
}
|
||||||
|
|
||||||
|
async function loadFixedWidths() {
|
||||||
|
try {
|
||||||
|
fixedWidths.value = (await getSuffixColWidths()).data.data.widths
|
||||||
|
} catch { /* 列宽读取失败时沿用默认值 */ }
|
||||||
|
}
|
||||||
|
|
||||||
|
async function setFixedColWidth(scope: 'basic' | 'workspace', key: string, event: Event) {
|
||||||
|
const w = parseInt((event.target as HTMLInputElement).value, 10)
|
||||||
|
if (Number.isNaN(w) || w < 0 || w > 2000) {
|
||||||
|
ElMessage.warning('列宽须为 0–2000(0=自适应)')
|
||||||
|
return
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
await updateSuffixColWidth(scope, key, w)
|
||||||
|
fixedWidths.value = { ...fixedWidths.value, [scope]: { ...fixedWidths.value[scope], [key]: w } }
|
||||||
|
ElMessage.success('列宽已保存')
|
||||||
|
} catch (e) {
|
||||||
|
ElMessage.error(e instanceof Error ? e.message : '列宽保存失败')
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
async function loadOverview() {
|
async function loadOverview() {
|
||||||
overviewLoading.value = true
|
overviewLoading.value = true
|
||||||
try {
|
try {
|
||||||
@@ -113,6 +158,18 @@ function isRoot(dir: SuffixDir) {
|
|||||||
return !dir.parent_id
|
return !dir.parent_id
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 统一目录操作条的目标:当前选中的目录;根目录只允许「+子」
|
||||||
|
const selectedDir = computed<SuffixDir | null>(() => {
|
||||||
|
const sel = selected.value
|
||||||
|
return sel.kind === 'dir' ? dirs.value.find((d) => d.id === sel.id) ?? null : null
|
||||||
|
})
|
||||||
|
const dirOpsLocked = computed(() => !selectedDir.value || isRoot(selectedDir.value))
|
||||||
|
function addSubToSelected() { if (selectedDir.value) addDir(selectedDir.value.id, '新建子目录') }
|
||||||
|
function addSiblingToSelected() { const d = selectedDir.value; if (d && !isRoot(d)) addDir(d.parent_id, '新建平级目录') }
|
||||||
|
function renameSelected() { const d = selectedDir.value; if (d) renameDir(d) }
|
||||||
|
function moveSelected(dirNum: number) { const d = selectedDir.value; if (d && !isRoot(d)) moveDir(d, dirNum) }
|
||||||
|
function removeSelected() { const d = selectedDir.value; if (d && !isRoot(d)) removeDir(d) }
|
||||||
|
|
||||||
async function addDir(parentId: number, title: string) {
|
async function addDir(parentId: number, title: string) {
|
||||||
const { value } = await ElMessageBox.prompt('输入目录名称', title, { inputPattern: /\S/, inputErrorMessage: '名称不能为空' }).catch(() => ({ value: '' }))
|
const { value } = await ElMessageBox.prompt('输入目录名称', title, { inputPattern: /\S/, inputErrorMessage: '名称不能为空' }).catch(() => ({ value: '' }))
|
||||||
if (!value) return
|
if (!value) return
|
||||||
@@ -300,21 +357,25 @@ async function removeFile(file: SuffixFile) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 骨架发布 / 取消发布(「更多」下拉)
|
||||||
|
async function onFilePublish(file: SuffixFile) {
|
||||||
|
const next = !file.published
|
||||||
|
try {
|
||||||
|
await publishSuffixFile(file.id, next)
|
||||||
|
file.published = next
|
||||||
|
ElMessage.success(next ? `「${file.file_name}」已发布` : `「${file.file_name}」已取消发布`)
|
||||||
|
} catch (e) {
|
||||||
|
ElMessage.error(e instanceof Error ? e.message : '操作失败')
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// ---- 目录工作区:列 / 单元格 / 锚定 ----
|
// ---- 目录工作区:列 / 单元格 / 锚定 ----
|
||||||
|
|
||||||
const pageColumns = computed<SuffixColumn[]>(() => page.value?.columns || [])
|
const pageColumns = computed<SuffixColumn[]>(() => page.value?.columns || [])
|
||||||
|
|
||||||
async function openAddColumn() {
|
// ---- 列设置(重命名 / 排序 / 列宽 / 精准插入新列) ----
|
||||||
if (selected.value.kind !== 'dir') return
|
|
||||||
colDialog.name = ''
|
|
||||||
colDialog.isValue = false
|
|
||||||
colDialog.width = 0
|
|
||||||
colDialog.visible = true
|
|
||||||
}
|
|
||||||
|
|
||||||
// ---- 列排序(可调整顺序,也可精准插入新列) ----
|
const colOrder = reactive({ visible: false, ids: [] as number[], newName: '', newValue: false, saving: false })
|
||||||
|
|
||||||
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)
|
const valColCount = computed(() => pageColumns.value.filter((c) => c.is_value).length)
|
||||||
|
|
||||||
@@ -323,7 +384,6 @@ function openColOrder() {
|
|||||||
colOrder.ids = page.value.columns.map((c) => c.id)
|
colOrder.ids = page.value.columns.map((c) => c.id)
|
||||||
colOrder.newName = ''
|
colOrder.newName = ''
|
||||||
colOrder.newValue = false
|
colOrder.newValue = false
|
||||||
colOrder.afterId = 0
|
|
||||||
colOrder.visible = true
|
colOrder.visible = true
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -347,8 +407,19 @@ async function setColWidth(id: number, event: Event) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function colStyle(col: SuffixColumn) {
|
// 重命名自定义列:成功后原地更新,表头与弹框同步变化
|
||||||
return col.width > 0 ? { width: col.width + 'px', minWidth: col.width + 'px', maxWidth: col.width + 'px' } : undefined
|
async function renameColOrder(cid: number) {
|
||||||
|
const col = pageColumns.value.find((c) => c.id === cid)
|
||||||
|
if (!col) return
|
||||||
|
const { value } = await ElMessageBox.prompt('输入新的列名', '重命名列', { inputValue: col.name, inputPattern: /\S/, inputErrorMessage: '列名不能为空' }).catch(() => ({ value: '' }))
|
||||||
|
if (!value || value.trim() === col.name) return
|
||||||
|
try {
|
||||||
|
await renameSuffixColumn(col.id, value.trim())
|
||||||
|
col.name = value.trim()
|
||||||
|
ElMessage.success('列名已更新')
|
||||||
|
} catch (e) {
|
||||||
|
ElMessage.error(e instanceof Error ? e.message : '重命名失败')
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async function moveColOrder(id: number, dir: number) {
|
async function moveColOrder(id: number, dir: number) {
|
||||||
@@ -367,20 +438,25 @@ async function moveColOrder(id: number, dir: number) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async function submitColOrder() {
|
// 用右上角工具条里的列名/值设置建列:afterId>0 插到该列后,0 加到最右;弹框保持打开方便连续添加。
|
||||||
|
async function createColAt(afterId: number) {
|
||||||
if (colOrder.saving || selected.value.kind !== 'dir' || !page.value) return
|
if (colOrder.saving || selected.value.kind !== 'dir' || !page.value) return
|
||||||
const name = colOrder.newName.trim()
|
const name = colOrder.newName.trim()
|
||||||
if (!name) {
|
if (!name) {
|
||||||
ElMessage.warning('请填写列名')
|
ElMessage.warning('请先在右上角填写列名')
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
const isValue = colOrder.newValue
|
||||||
colOrder.saving = true
|
colOrder.saving = true
|
||||||
try {
|
try {
|
||||||
const afterId = colOrder.afterId || 0
|
const created = (await createSuffixColumn(selected.value.id, name, isValue, afterId)).data.data
|
||||||
const created = (await createSuffixColumn(selected.value.id, name, colOrder.newValue, afterId)).data.data
|
colOrder.newName = ''
|
||||||
colOrder.visible = false
|
colOrder.newValue = false
|
||||||
await loadSheet()
|
await loadSheet()
|
||||||
ElMessage.success(colOrder.newValue ? `已在列排序位置添加值列「${created.name}」` : `已添加列「${created.name}」`)
|
if (page.value) colOrder.ids = page.value.columns.map((c) => c.id)
|
||||||
|
ElMessage.success(isValue
|
||||||
|
? (afterId ? `已在选中列后插入值列「${created.name}」` : `已添加值列「${created.name}」`)
|
||||||
|
: (afterId ? `已在选中列后插入列「${created.name}」` : `已添加列「${created.name}」`))
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
ElMessage.error(e instanceof Error ? e.message : '列创建失败')
|
ElMessage.error(e instanceof Error ? e.message : '列创建失败')
|
||||||
} finally {
|
} finally {
|
||||||
@@ -388,33 +464,23 @@ async function submitColOrder() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async function submitColumn() {
|
function submitColOrder() { createColAt(0) }
|
||||||
if (selected.value.kind !== 'dir' || colDialog.saving) return
|
|
||||||
const name = colDialog.name.trim()
|
function insertColAfter(cid: number) { createColAt(cid) }
|
||||||
if (!name) {
|
|
||||||
ElMessage.warning('请填写列名')
|
|
||||||
return
|
|
||||||
}
|
|
||||||
colDialog.saving = true
|
|
||||||
try {
|
|
||||||
const created = (await createSuffixColumn(selected.value.id, name, colDialog.isValue, 0, colDialog.width)).data.data
|
|
||||||
page.value?.columns.push(created)
|
|
||||||
colDialog.visible = false
|
|
||||||
ElMessage.success(colDialog.isValue ? `已添加值列「${created.name}」,点击它的单元格即可填写值设置` : `已添加列「${created.name}」`)
|
|
||||||
} catch (e) {
|
|
||||||
ElMessage.error(e instanceof Error ? e.message : '列创建失败')
|
|
||||||
} finally {
|
|
||||||
colDialog.saving = false
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
async function removeColumn(col: SuffixColumn) {
|
async function removeColumn(col: SuffixColumn) {
|
||||||
|
const hasValue = !!page.value?.suffixes.some((s) => (page.value?.cells[cellKey(s.id, col.id)] || '') !== '')
|
||||||
|
if (hasValue) {
|
||||||
|
ElMessage.warning(`列「${col.name}」已有数据,不能删除`)
|
||||||
|
return
|
||||||
|
}
|
||||||
try {
|
try {
|
||||||
await ElMessageBox.confirm(`删除列「${col.name}」会连同这一列已填的内容一起删除,确定吗?`, '删除列', { type: 'warning' })
|
await ElMessageBox.confirm(`列「${col.name}」暂无数据,删除后不可恢复,确定吗?`, '删除列', { type: 'warning' })
|
||||||
} catch { return }
|
} catch { return }
|
||||||
try {
|
try {
|
||||||
await deleteSuffixColumn(col.id)
|
await deleteSuffixColumn(col.id)
|
||||||
if (page.value) page.value.columns = page.value.columns.filter((c) => c.id !== col.id)
|
if (page.value) page.value.columns = page.value.columns.filter((c) => c.id !== col.id)
|
||||||
|
colOrder.ids = colOrder.ids.filter((id) => id !== col.id)
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
ElMessage.error(e instanceof Error ? e.message : '删除失败')
|
ElMessage.error(e instanceof Error ? e.message : '删除失败')
|
||||||
}
|
}
|
||||||
@@ -433,10 +499,6 @@ 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
|
||||||
@@ -469,53 +531,49 @@ async function commitCellEdit() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async function toggleAnchor(sid: number, current: boolean) {
|
// ---- 锚定行编辑(双击存值,空=未锚定) ----
|
||||||
if (selected.value.kind !== 'dir' || !page.value) return
|
|
||||||
|
const editingAnchor = reactive({ sid: 0, value: '' })
|
||||||
|
|
||||||
|
function startAnchorEdit(sid: number) {
|
||||||
|
const row = workspaceRows.value.find((r) => r.sid === sid)
|
||||||
|
editingAnchor.sid = sid
|
||||||
|
editingAnchor.value = row?.anchor || ''
|
||||||
|
}
|
||||||
|
|
||||||
|
function cancelAnchorEdit() {
|
||||||
|
editingAnchor.sid = 0
|
||||||
|
editingAnchor.value = ''
|
||||||
|
}
|
||||||
|
|
||||||
|
async function commitAnchorEdit() {
|
||||||
|
const sid = editingAnchor.sid
|
||||||
|
if (!sid || selected.value.kind !== 'dir' || !page.value) { cancelAnchorEdit(); return }
|
||||||
|
const value = editingAnchor.value.trim()
|
||||||
|
cancelAnchorEdit()
|
||||||
try {
|
try {
|
||||||
await setSuffixAnchor(selected.value.id, sid, !current)
|
await setSuffixAnchor(selected.value.id, sid, value)
|
||||||
const line = page.value.suffixes.find((s) => s.id === sid)
|
const line = page.value.suffixes.find((s) => s.id === sid)
|
||||||
if (line) line.anchor = !current
|
if (line) line.anchor_value = value
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
ElMessage.error(e instanceof Error ? e.message : '锚定失败')
|
ElMessage.error(e instanceof Error ? e.message : '锚定失败')
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function toggleRowEdit(sid: number) {
|
// 目录工作区的行:区域不再单独占一行,后缀直接平铺,把工作区让给数据
|
||||||
const next = new Set(editRows.value)
|
|
||||||
if (next.has(sid)) next.delete(sid)
|
|
||||||
else next.add(sid)
|
|
||||||
editRows.value = next
|
|
||||||
}
|
|
||||||
|
|
||||||
// 目录工作区的行(按分组分组的组头 + 后缀行)
|
|
||||||
type WorkspaceRow = { type: 'group'; key: string; name: string; count: number }
|
|
||||||
| { type: 'suffix'; key: string; sid: number; name: string; groupId: number; groupName: string; anchor: boolean }
|
|
||||||
const selectedDirName = computed(() => {
|
const selectedDirName = computed(() => {
|
||||||
const sel = selected.value
|
const sel = selected.value
|
||||||
if (sel.kind !== 'dir') return ''
|
if (sel.kind !== 'dir') return ''
|
||||||
return dirs.value.find((d) => d.id === sel.id)?.name || ''
|
return dirs.value.find((d) => d.id === sel.id)?.name || ''
|
||||||
})
|
})
|
||||||
const workspaceRows = computed(() => {
|
const workspaceRows = computed(() =>
|
||||||
const rows: WorkspaceRow[] = []
|
(page.value?.suffixes || []).map((s) => ({ key: 's:' + s.id, sid: s.id, name: s.name, anchor: s.anchor_value || '' })),
|
||||||
let lastGroup = ''
|
)
|
||||||
for (const s of page.value?.suffixes || []) {
|
|
||||||
if (s.group_name !== lastGroup) {
|
|
||||||
rows.push({ type: 'group', key: 'g:' + s.group_id, name: s.group_name, count: 0 })
|
|
||||||
lastGroup = s.group_name
|
|
||||||
}
|
|
||||||
rows.push({ type: 'suffix', key: 's:' + s.id, sid: s.id, name: s.name, groupId: s.group_id, groupName: s.group_name, anchor: s.anchor })
|
|
||||||
}
|
|
||||||
for (const row of rows) {
|
|
||||||
if (row.type === 'group') {
|
|
||||||
row.count = (page.value?.suffixes || []).filter((s) => s.group_name === row.name).length
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return rows
|
|
||||||
})
|
|
||||||
|
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
loadOverview()
|
loadOverview()
|
||||||
loadTree()
|
loadTree()
|
||||||
|
loadFixedWidths()
|
||||||
})
|
})
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
@@ -529,23 +587,24 @@ onMounted(() => {
|
|||||||
:class="{ active: selected.kind === 'dir' && selected.id === rootDir?.id }"
|
:class="{ active: selected.kind === 'dir' && selected.id === rootDir?.id }"
|
||||||
@click="rootDir && selectNode({ kind: 'dir', id: rootDir.id })"
|
@click="rootDir && selectNode({ kind: 'dir', id: rootDir.id })"
|
||||||
>
|
>
|
||||||
<span v-if="rootDir && rootDir.children > 0" class="tw" @click.stop="rootDir && toggleExpand(rootDir)">{{ expanded.has(rootDir.id) ? '▾' : '▸' }}</span>
|
<span v-if="rootDir && rootDir.children > 0" class="tw" @click.stop="rootDir && toggleExpand(rootDir)">{{ expanded.has(rootDir.id) ? '−' : '+' }}</span>
|
||||||
<span>按信息价的目录</span>
|
<span>{{ rootDir?.name }}</span>
|
||||||
<span class="side-plus" title="新建一级目录" @click.stop="rootDir && addDir(rootDir.id, '新建目录')">+</span>
|
<span class="side-plus" title="新建一级目录" @click.stop="rootDir && addDir(rootDir.id, '新建目录')">+</span>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="side-ops-bar" :title="selectedDir ? `对选中的「${selectedDir.name}」操作` : '先选择一个目录'">
|
||||||
|
<button type="button" title="新建子目录" :disabled="!selectedDir" @click="addSubToSelected">+子</button>
|
||||||
|
<button type="button" title="新建平级目录" :disabled="dirOpsLocked" @click="addSiblingToSelected">+平</button>
|
||||||
|
<button type="button" title="重命名" :disabled="!selectedDir" @click="renameSelected">✎</button>
|
||||||
|
<button type="button" title="上移" :disabled="dirOpsLocked" @click="moveSelected(-1)">↑</button>
|
||||||
|
<button type="button" title="下移" :disabled="dirOpsLocked" @click="moveSelected(1)">↓</button>
|
||||||
|
<button type="button" class="danger" title="删除" :disabled="dirOpsLocked" @click="removeSelected">×</button>
|
||||||
|
</div>
|
||||||
<template v-for="node in visibleNodes" :key="node.dir.id">
|
<template v-for="node in visibleNodes" :key="node.dir.id">
|
||||||
<div v-if="!isRoot(node.dir)" class="side-node" :style="{ paddingLeft: 14 + node.depth * 18 + 'px' }">
|
<div v-if="!isRoot(node.dir)" class="side-node" :style="{ paddingLeft: 14 + node.depth * 18 + 'px' }">
|
||||||
<span class="tw" :class="{ off: !node.dir.children }" @click.stop="node.dir.children && toggleExpand(node.dir)">{{ node.dir.children ? (expanded.has(node.dir.id) ? '▾' : '▸') : '·' }}</span>
|
<span v-for="a in node.depth - 1" :key="a" class="guide-line" :style="{ left: 21 + a * 18 + 'px' }"></span>
|
||||||
|
<span class="tw" :class="{ off: !node.dir.children }" @click.stop="node.dir.children && toggleExpand(node.dir)">{{ node.dir.children ? (expanded.has(node.dir.id) ? '−' : '+') : '·' }}</span>
|
||||||
<span class="side-name" :class="{ active: selected.kind === 'dir' && selected.id === node.dir.id }" @click="selectNode({ kind: 'dir', id: node.dir.id })">{{ node.dir.name }}</span>
|
<span class="side-name" :class="{ active: selected.kind === 'dir' && selected.id === node.dir.id }" @click="selectNode({ kind: 'dir', id: node.dir.id })">{{ node.dir.name }}</span>
|
||||||
<span class="side-count">{{ node.dir.children }}</span>
|
<span class="side-count">{{ node.dir.children }}</span>
|
||||||
<span class="side-ops">
|
|
||||||
<button type="button" title="新建子目录" @click.stop="addDir(node.dir.id, '新建子目录')">+子</button>
|
|
||||||
<button type="button" title="新建平级目录" @click.stop="addDir(node.dir.parent_id, '新建平级目录')">+平</button>
|
|
||||||
<button type="button" title="重命名" @click.stop="renameDir(node.dir)">✎</button>
|
|
||||||
<button type="button" title="上移" @click.stop="moveDir(node.dir, -1)">↑</button>
|
|
||||||
<button type="button" title="下移" @click.stop="moveDir(node.dir, 1)">↓</button>
|
|
||||||
<button type="button" class="danger" title="删除" @click.stop="removeDir(node.dir)">×</button>
|
|
||||||
</span>
|
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
</aside>
|
</aside>
|
||||||
@@ -556,12 +615,17 @@ onMounted(() => {
|
|||||||
<template v-if="selected.kind === 'basic'">
|
<template v-if="selected.kind === 'basic'">
|
||||||
<div class="bar">
|
<div class="bar">
|
||||||
<strong>基本设置</strong>
|
<strong>基本设置</strong>
|
||||||
<span class="bar-note">先在这里建分组与后缀,各目录工作区的行会跟着这里的顺序走。</span>
|
|
||||||
<span class="grow"></span>
|
<span class="grow"></span>
|
||||||
<el-button size="small" @click="addGroup">+ 新建分组</el-button>
|
<span class="bar-btns">
|
||||||
|
<el-button size="small" @click="basicWidths.visible = true">列宽</el-button>
|
||||||
|
<el-button size="small" @click="addGroup">+ 新建分组</el-button>
|
||||||
|
</span>
|
||||||
</div>
|
</div>
|
||||||
<div v-loading="overviewLoading" class="sheet-wrap">
|
<div v-loading="overviewLoading" class="sheet-wrap">
|
||||||
<table class="sheet basic">
|
<table class="sheet basic">
|
||||||
|
<colgroup>
|
||||||
|
<col v-for="fc in basicFixedCols" :key="fc.key" :style="colW(wOf('basic', fc.key))" />
|
||||||
|
</colgroup>
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
<th class="b-idx">序号</th>
|
<th class="b-idx">序号</th>
|
||||||
@@ -573,42 +637,57 @@ onMounted(() => {
|
|||||||
<tbody>
|
<tbody>
|
||||||
<template v-for="g in groups" :key="g.id">
|
<template v-for="g in groups" :key="g.id">
|
||||||
<tr class="group-tr">
|
<tr class="group-tr">
|
||||||
<td class="group-cell" colspan="2">
|
<td class="group-cell" colspan="3">
|
||||||
<span class="tw off">▾</span><strong>{{ g.name }}</strong>
|
<span class="tw off">▾</span><strong>{{ g.name }}</strong>
|
||||||
<span class="muted">{{ g.suffixes.length }} 个</span>
|
<span class="muted">{{ g.suffixes.length }} 个</span>
|
||||||
<span class="grow"></span>
|
<span class="grow"></span>
|
||||||
</td>
|
</td>
|
||||||
<td></td>
|
|
||||||
<td class="group-ops">
|
<td class="group-ops">
|
||||||
<button type="button" class="op" title="上移" @click="moveGroup(g.id, -1)">↑</button>
|
<span class="ops-btns">
|
||||||
<button type="button" class="op" title="下移" @click="moveGroup(g.id, 1)">↓</button>
|
<button type="button" class="op" title="上移" @click="moveGroup(g.id, -1)">↑</button>
|
||||||
<button type="button" class="op danger" title="删除分组(连同后缀与模板文件)" @click="removeGroup(g)">×</button>
|
<button type="button" class="op" title="下移" @click="moveGroup(g.id, 1)">↓</button>
|
||||||
|
<button type="button" class="op danger" title="删除分组(连同后缀与模板文件)" @click="removeGroup(g)">×</button>
|
||||||
|
</span>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr v-for="(s, i) in g.suffixes" :key="s.id" class="data-tr">
|
<tr v-for="(s, i) in g.suffixes" :key="s.id" class="data-tr">
|
||||||
<td class="b-idx">{{ i + 1 }}</td>
|
<td class="b-idx">{{ i + 1 }}</td>
|
||||||
<td>
|
<td :title="s.name">
|
||||||
<span class="suffix-name">{{ s.name || '—' }}</span>
|
<span class="suffix-name">{{ s.name || '—' }}</span>
|
||||||
</td>
|
</td>
|
||||||
<td class="files-cell">
|
<td class="files-cell">
|
||||||
<span v-for="f in s.files" :key="f.id" class="file-chip">
|
<span v-for="f in s.files" :key="f.id" class="file-chip">
|
||||||
<a :href="suffixFileUrl(f.id)" target="_blank" rel="noopener" :title="`下载 ${f.file_name}(${formatSuffixSize(f.file_size)})`">{{ f.file_name }}</a>
|
<a :href="suffixFileUrl(f.id)" target="_blank" rel="noopener" :title="`下载 ${f.file_name}(${formatSuffixSize(f.file_size)})`">{{ f.file_name }}</a>
|
||||||
|
<em v-if="f.published" class="pub-tag" title="已发布">已发布</em>
|
||||||
<button type="button" class="chip-x" title="删除模板" @click="removeFile(f)">×</button>
|
<button type="button" class="chip-x" title="删除模板" @click="removeFile(f)">×</button>
|
||||||
</span>
|
</span>
|
||||||
<span v-if="!s.files.length" class="muted">—</span>
|
<span v-if="!s.files.length" class="muted">—</span>
|
||||||
</td>
|
</td>
|
||||||
<td class="ops-cell">
|
<td class="ops-cell">
|
||||||
<button type="button" class="btn-main" :disabled="uploading" @click="pickUpload(s.id)">上传模板</button>
|
<span class="ops-btns">
|
||||||
<button type="button" class="op" title="在这行下面插入一行(同名自动 -1)" @click="insertSuffixRow(g.id, s.id, '插入后缀')">向下插入行</button>
|
<button type="button" class="btn-main" title="上传模板" :disabled="uploading" @click="pickUpload(s.id)">传</button>
|
||||||
<button type="button" class="op" title="上移" @click="moveSuffixRow(s.id, -1)">↑</button>
|
<button type="button" class="op" title="在这行下面插入一行(同名自动 -1)" @click="insertSuffixRow(g.id, s.id, '插入后缀')">插</button>
|
||||||
<button type="button" class="op" title="下移" @click="moveSuffixRow(s.id, 1)">↓</button>
|
<el-dropdown trigger="click" @command="onFilePublish">
|
||||||
<button type="button" class="op danger" title="删除后缀" @click="removeSuffix(s)">×</button>
|
<button type="button" class="op" title="更多(骨架发布 / 取消发布)">更多</button>
|
||||||
|
<template #dropdown>
|
||||||
|
<el-dropdown-menu>
|
||||||
|
<el-dropdown-item v-for="f in s.files" :key="f.id" :command="f">
|
||||||
|
{{ f.file_name }}({{ f.published ? '取消发布' : '发布' }})
|
||||||
|
</el-dropdown-item>
|
||||||
|
<el-dropdown-item v-if="!s.files.length" disabled>暂无骨架</el-dropdown-item>
|
||||||
|
</el-dropdown-menu>
|
||||||
|
</template>
|
||||||
|
</el-dropdown>
|
||||||
|
<button type="button" class="op" title="上移" @click="moveSuffixRow(s.id, -1)">↑</button>
|
||||||
|
<button type="button" class="op" title="下移" @click="moveSuffixRow(s.id, 1)">↓</button>
|
||||||
|
<button type="button" class="op danger" title="删除后缀" @click="removeSuffix(s)">×</button>
|
||||||
|
</span>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr v-if="!g.suffixes.length" class="data-tr">
|
<tr v-if="!g.suffixes.length" class="data-tr">
|
||||||
<td class="b-idx">—</td>
|
<td class="b-idx">—</td>
|
||||||
<td><span class="muted">这个分组还没有后缀,</span><button type="button" class="op" @click="insertSuffixRow(g.id, 0, '插入后缀')">插入后缀</button></td>
|
<td><span class="muted">—</span></td>
|
||||||
<td class="files-cell"><span class="muted">—</span></td>
|
<td class="files-cell"><span class="muted">这个分组还没有后缀,</span><button type="button" class="op" @click="insertSuffixRow(g.id, 0, '插入后缀')">插入后缀</button></td>
|
||||||
<td class="ops-cell"></td>
|
<td class="ops-cell"></td>
|
||||||
</tr>
|
</tr>
|
||||||
</template>
|
</template>
|
||||||
@@ -622,68 +701,70 @@ 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" @click="openColOrder">列设置</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">
|
||||||
<table class="sheet">
|
<table class="sheet">
|
||||||
|
<colgroup>
|
||||||
|
<col v-for="fc in wsFixedCols" :key="fc.key" :style="colW(wOf('workspace', fc.key))" />
|
||||||
|
<col v-for="col in pageColumns" :key="col.id" :style="colW(col.width || 120)" />
|
||||||
|
</colgroup>
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
<th class="fix">序号</th>
|
<th class="fix">序号</th>
|
||||||
<th class="fix">后缀</th>
|
<th class="fix">后缀</th>
|
||||||
<th class="fix">操作</th>
|
|
||||||
<th class="fix">锚定行</th>
|
<th class="fix">锚定行</th>
|
||||||
<th v-for="col in pageColumns" :key="col.id" class="custom-th" :style="colStyle(col)">
|
<th v-for="col in pageColumns" :key="col.id" class="custom-th">
|
||||||
<span :title="col.is_value ? '值列:点单元格填 锚点+值' : col.name">{{ col.name }}<em v-if="col.is_value" class="vtag">值</em></span>
|
<span :title="col.is_value ? '值列:点单元格填 锚点+值' : col.name">{{ col.name }}<em v-if="col.is_value" class="vtag">值</em></span>
|
||||||
<button type="button" class="th-x" title="删除列" @click="removeColumn(col)">×</button>
|
<button type="button" class="th-x" title="删除列" @click="removeColumn(col)">×</button>
|
||||||
</th>
|
</th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
<template v-for="row in workspaceRows" :key="row.key">
|
<tr v-for="(row, i) in workspaceRows" :key="row.key" class="data-tr" :class="{ editing: editing.sid === row.sid }">
|
||||||
<tr v-if="row.type === 'group'" class="group-tr">
|
<td class="fix idx">{{ i + 1 }}</td>
|
||||||
<td colspan="4" class="group-td">− {{ row.name }} <span class="muted">{{ row.count }} 个</span></td>
|
<td class="fix" :title="row.name">{{ row.name || '—' }}</td>
|
||||||
<td v-for="col in pageColumns" :key="col.id" class="group-td"></td>
|
<td class="fix anchor" @dblclick="startAnchorEdit(row.sid)" title="双击编辑锚定值(留空=未锚定)">
|
||||||
</tr>
|
<template v-if="editingAnchor.sid === row.sid">
|
||||||
<tr v-else class="data-tr" :class="{ editing: editRows.has(row.sid) }">
|
<span class="cell-editor" @click.stop>
|
||||||
<td class="fix idx">{{ workspaceRows.filter((r) => r.type === 'suffix').findIndex((r) => (r as any).sid === row.sid) + 1 }}</td>
|
<input v-model="editingAnchor.value" class="cell-input" placeholder="锚定值" @keyup.enter="commitAnchorEdit" @keyup.esc="cancelAnchorEdit" />
|
||||||
<td class="fix">{{ row.name || '—' }}</td>
|
<button type="button" class="op" title="确定" @click.stop="commitAnchorEdit">✓</button>
|
||||||
<td class="fix">
|
</span>
|
||||||
<button type="button" class="btn-edit" :class="{ on: editRows.has(row.sid) }" @click="toggleRowEdit(row.sid)">编辑</button>
|
</template>
|
||||||
</td>
|
<template v-else>
|
||||||
<td class="fix anchor" @click="toggleAnchor(row.sid, row.anchor)">{{ row.anchor ? '1' : '—' }}</td>
|
<span v-if="row.anchor" class="cell-text">{{ row.anchor }}</span>
|
||||||
<td
|
<span v-else class="cell-empty">—</span>
|
||||||
v-for="col in pageColumns"
|
</template>
|
||||||
:key="col.id"
|
</td>
|
||||||
class="cell"
|
<td
|
||||||
:style="colStyle(col)"
|
v-for="col in pageColumns"
|
||||||
:class="{ locked: !editRows.has(row.sid) }"
|
:key="col.id"
|
||||||
@dblclick="startCellEdit(row.sid, col)"
|
class="cell"
|
||||||
:title="editRows.has(row.sid) ? '双击编辑' : '先点这一行的「编辑」,再双击单元格'"
|
@dblclick="startCellEdit(row.sid, col)"
|
||||||
>
|
title="双击编辑"
|
||||||
<template v-if="editing.sid === row.sid && editing.cid === col.id">
|
>
|
||||||
<span class="cell-editor" @click.stop>
|
<template v-if="editing.sid === row.sid && editing.cid === col.id">
|
||||||
<template v-if="col.is_value">
|
<span class="cell-editor" @click.stop>
|
||||||
<input v-model="editing.a" class="cell-input half" placeholder="锚点" @keyup.enter="commitCellEdit" @keyup.esc="cancelCellEdit" />
|
<template v-if="col.is_value">
|
||||||
<input v-model="editing.v" class="cell-input half" placeholder="值" @keyup.enter="commitCellEdit" @keyup.esc="cancelCellEdit" />
|
<input v-model="editing.a" class="cell-input half" placeholder="锚点" @keyup.enter="commitCellEdit" @keyup.esc="cancelCellEdit" />
|
||||||
</template>
|
<input v-model="editing.v" class="cell-input half" placeholder="值" @keyup.enter="commitCellEdit" @keyup.esc="cancelCellEdit" />
|
||||||
<template v-else>
|
</template>
|
||||||
<input v-model="editing.text" class="cell-input" @keyup.enter="commitCellEdit" @keyup.esc="cancelCellEdit" />
|
<template v-else>
|
||||||
</template>
|
<input v-model="editing.text" class="cell-input" @keyup.enter="commitCellEdit" @keyup.esc="cancelCellEdit" />
|
||||||
<button type="button" class="op" title="确定" @click.stop="commitCellEdit">✓</button>
|
</template>
|
||||||
</span>
|
<button type="button" class="op" title="确定" @click.stop="commitCellEdit">✓</button>
|
||||||
</template>
|
</span>
|
||||||
<template v-else>
|
</template>
|
||||||
<span v-if="cellDisplay(row.sid, col)" class="cell-text" :class="{ value: col.is_value }">{{ cellDisplay(row.sid, col) }}</span>
|
<template v-else>
|
||||||
<span v-else class="cell-empty">—</span>
|
<span v-if="cellDisplay(row.sid, col)" class="cell-text" :class="{ value: col.is_value }">{{ cellDisplay(row.sid, col) }}</span>
|
||||||
</template>
|
<span v-else class="cell-empty">—</span>
|
||||||
</td>
|
</template>
|
||||||
</tr>
|
</td>
|
||||||
</template>
|
</tr>
|
||||||
<tr v-if="!workspaceRows.length">
|
<tr v-if="!workspaceRows.length">
|
||||||
<td :colspan="4 + pageColumns.length" class="empty-tip">先去「基本设置」建分组和后缀,这里才有行。</td>
|
<td :colspan="3 + pageColumns.length" class="empty-tip">先去「基本设置」建分组和后缀,这里才有行。</td>
|
||||||
</tr>
|
</tr>
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
@@ -693,25 +774,6 @@ onMounted(() => {
|
|||||||
|
|
||||||
<input ref="uploadInput" type="file" class="hidden-file" @change="onUploadPicked" />
|
<input ref="uploadInput" type="file" class="hidden-file" @change="onUploadPicked" />
|
||||||
|
|
||||||
<el-dialog v-model="colDialog.visible" title="添加列" width="420px">
|
|
||||||
<div class="col-form">
|
|
||||||
<label><span class="lab">列名</span>
|
|
||||||
<el-input v-model="colDialog.name" placeholder="输入列名,例如:招标人" maxlength="190" @keyup.enter="submitColumn" />
|
|
||||||
</label>
|
|
||||||
<label class="val-line">
|
|
||||||
<el-checkbox v-model="colDialog.isValue">值设置</el-checkbox>
|
|
||||||
<span class="muted">勾选后该列为值列,点击单元格可填写 锚点+值;不勾选则为普通列,不可填值设置。</span>
|
|
||||||
</label>
|
|
||||||
<label><span class="lab">列宽(px,0=自适应)</span>
|
|
||||||
<el-input v-model.number="colDialog.width" type="number" :min="0" :max="2000" />
|
|
||||||
</label>
|
|
||||||
</div>
|
|
||||||
<template #footer>
|
|
||||||
<el-button @click="colDialog.visible = false">取消</el-button>
|
|
||||||
<el-button type="primary" :loading="colDialog.saving" @click="submitColumn">确定</el-button>
|
|
||||||
</template>
|
|
||||||
</el-dialog>
|
|
||||||
|
|
||||||
<el-dialog v-model="groupDialog.visible" title="新建分组" width="440px">
|
<el-dialog v-model="groupDialog.visible" title="新建分组" width="440px">
|
||||||
<div class="col-form">
|
<div class="col-form">
|
||||||
<label><span class="lab">分组名(分类名)</span>
|
<label><span class="lab">分组名(分类名)</span>
|
||||||
@@ -728,20 +790,35 @@ onMounted(() => {
|
|||||||
</template>
|
</template>
|
||||||
</el-dialog>
|
</el-dialog>
|
||||||
|
|
||||||
<el-dialog v-model="colOrder.visible" title="列排序" width="480px">
|
<el-dialog v-model="colOrder.visible" title="列设置" width="560px">
|
||||||
<div class="col-order-hint">拖动调整列的左右顺序;值列以蓝色字体显示。也可以在这里精准添加列:填列名、勾选值设置,新列会插到选中列的后面(未选中则加到最右)。</div>
|
<div class="col-set-toolbar">
|
||||||
|
<el-input v-model="colOrder.newName" placeholder="新列名(点行内「插」插到该行后)" maxlength="190" @keyup.enter="submitColOrder" />
|
||||||
|
<el-checkbox v-model="colOrder.newValue">值设置</el-checkbox>
|
||||||
|
<el-button type="primary" :loading="colOrder.saving" @click="submitColOrder">添加列</el-button>
|
||||||
|
<el-button @click="colOrder.visible = false">关闭</el-button>
|
||||||
|
</div>
|
||||||
|
<div class="col-order-hint">固定列只调宽度;自定义列操作:✎ 重命名、↑↓ 排序、插 = 把右上角填的新列插到该行后、✕ 删除。</div>
|
||||||
<div class="col-order-list">
|
<div class="col-order-list">
|
||||||
<div
|
<div v-for="fc in wsFixedCols" :key="'f-' + fc.key" class="col-order-row fixed-row">
|
||||||
v-for="(cid, i) in colOrder.ids"
|
<span class="co-idx">固</span>
|
||||||
:key="cid"
|
<span class="co-name">{{ fc.name }}<span class="co-fixtag">固定列</span></span>
|
||||||
class="col-order-row"
|
<input
|
||||||
:class="{ selected: colOrder.afterId === cid }"
|
class="co-width"
|
||||||
@click="colOrder.afterId = cid"
|
type="number"
|
||||||
>
|
min="0"
|
||||||
|
max="2000"
|
||||||
|
:value="wOf('workspace', fc.key)"
|
||||||
|
title="列宽 px(0=自适应)"
|
||||||
|
@change="setFixedColWidth('workspace', fc.key, $event)"
|
||||||
|
/>
|
||||||
|
<span class="co-ops"></span>
|
||||||
|
</div>
|
||||||
|
<div v-for="(cid, i) in colOrder.ids" :key="cid" class="col-order-row">
|
||||||
<span class="co-idx">{{ i + 1 }}</span>
|
<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 class="co-name" :class="{ value: pageColumns.find((c) => c.id === cid)?.is_value }">
|
||||||
<span v-if="pageColumns.find((c) => c.id === cid)?.is_value" class="co-vtag">值</span>
|
{{ pageColumns.find((c) => c.id === cid)?.name }}
|
||||||
<span class="grow"></span>
|
<span v-if="pageColumns.find((c) => c.id === cid)?.is_value" class="co-vtag">值</span>
|
||||||
|
</span>
|
||||||
<input
|
<input
|
||||||
class="co-width"
|
class="co-width"
|
||||||
type="number"
|
type="number"
|
||||||
@@ -749,80 +826,103 @@ onMounted(() => {
|
|||||||
max="2000"
|
max="2000"
|
||||||
:value="colWidthOf(cid)"
|
:value="colWidthOf(cid)"
|
||||||
title="列宽 px(0=自适应)"
|
title="列宽 px(0=自适应)"
|
||||||
@click.stop
|
|
||||||
@change="setColWidth(cid, $event)"
|
@change="setColWidth(cid, $event)"
|
||||||
/>
|
/>
|
||||||
<button type="button" class="op" :disabled="i === 0" @click.stop="moveColOrder(cid, -1)">↑</button>
|
<span class="co-ops">
|
||||||
<button type="button" class="op" :disabled="i === colOrder.ids.length - 1" @click.stop="moveColOrder(cid, 1)">↓</button>
|
<button type="button" class="op" title="重命名列" @click.stop="renameColOrder(cid)">✎</button>
|
||||||
|
<button type="button" class="op" title="上移" :disabled="i === 0" @click.stop="moveColOrder(cid, -1)">↑</button>
|
||||||
|
<button type="button" class="op" title="下移" :disabled="i === colOrder.ids.length - 1" @click.stop="moveColOrder(cid, 1)">↓</button>
|
||||||
|
<button type="button" class="op" title="把右上角填的新列插到这一列后面" @click.stop="insertColAfter(cid)">插</button>
|
||||||
|
<button type="button" class="op danger" title="删除列" @click.stop="removeColumn(pageColumns.find((c) => c.id === cid)!)">✕</button>
|
||||||
|
</span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-order-add">
|
</el-dialog>
|
||||||
<el-input v-model="colOrder.newName" placeholder="新列名(精准插入到选中列之后)" maxlength="190" />
|
|
||||||
<el-checkbox v-model="colOrder.newValue">值设置</el-checkbox>
|
<el-dialog v-model="basicWidths.visible" title="列宽设置" width="480px">
|
||||||
<el-button type="primary" :loading="colOrder.saving" @click="submitColOrder">添加列</el-button>
|
<div class="col-order-hint">基本设置的所有列(含固定列)宽度均可自由设置,单位 px;0=自适应,导入文件为 0 时占满剩余宽度。</div>
|
||||||
|
<div class="col-order-list">
|
||||||
|
<div v-for="fc in basicFixedCols" :key="fc.key" class="col-order-row fixed-row">
|
||||||
|
<span class="co-idx">固</span>
|
||||||
|
<span class="co-name">{{ fc.name }}</span>
|
||||||
|
<span class="co-fixtag">固定列</span>
|
||||||
|
<span class="grow"></span>
|
||||||
|
<input
|
||||||
|
class="co-width"
|
||||||
|
type="number"
|
||||||
|
min="0"
|
||||||
|
max="2000"
|
||||||
|
:value="wOf('basic', fc.key)"
|
||||||
|
title="列宽 px(0=自适应)"
|
||||||
|
@change="setFixedColWidth('basic', fc.key, $event)"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<template #footer>
|
<template #footer>
|
||||||
<el-button @click="colOrder.visible = false">关闭</el-button>
|
<el-button @click="basicWidths.visible = false">关闭</el-button>
|
||||||
</template>
|
</template>
|
||||||
</el-dialog>
|
</el-dialog>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<style scoped>
|
<style scoped>
|
||||||
.suffix-shell{display:flex;gap:8px;height:calc(100vh - 88px);align-items:stretch;position:relative;overflow:hidden}
|
.suffix-shell{display:flex;gap:8px;height:calc(100vh - 5px);align-items:stretch;position:relative;overflow:hidden}
|
||||||
.dir-fold{position:fixed;left:527px;top:50%;transform:translateY(-50%);z-index:30;width:18px;height:52px;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:12px}
|
.dir-fold{position:fixed;left:527px;top:calc(50% + 64px);transform:translateY(-50%);z-index:30;width:18px;height:52px;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:12px}
|
||||||
.admin-workspace.nav-collapsed .dir-fold{left:285px}
|
.admin-workspace.nav-collapsed .dir-fold{left:285px}
|
||||||
.dir-fold.collapsed{left:252px}
|
.dir-fold.collapsed{left:247px;border-left:1px solid #d8dfe8}
|
||||||
.admin-workspace.nav-collapsed .dir-fold.collapsed{left:10px}
|
.admin-workspace.nav-collapsed .dir-fold.collapsed{left:5px}
|
||||||
.dir-fold:hover{color:#1769e0;border-color:#1769e0}
|
.dir-fold:hover{color:#1769e0;border-color:#1769e0}
|
||||||
.dir-fold.collapsed{left:0}
|
|
||||||
.suffix-side{flex:0 0 280px;max-width:320px;border:1px solid #e5eaf0;border-radius:6px;background:#fbfcfe;padding:10px 8px;overflow:auto;height:100%}
|
.suffix-side{flex:0 0 280px;max-width:320px;border:1px solid #e5eaf0;border-radius:6px;background:#fbfcfe;padding:10px 8px;overflow:auto;height:100%}
|
||||||
.side-root{display:flex;align-items:center;gap:6px;padding:7px 10px;border-radius:5px;cursor:pointer;font-weight:600;font-size:13.5px}
|
.side-root{display:flex;align-items:center;gap:6px;padding:7px 10px;border-radius:5px;cursor:pointer;font-weight:600;font-size:13.5px}
|
||||||
.side-root.active,.side-root:hover{background:#eaf2fd}
|
.side-root.active,.side-root:hover{background:#eaf2fd}
|
||||||
.side-sep{height:1px;background:#e5eaf0;margin:8px 4px}
|
.side-sep{height:1px;background:#e5eaf0;margin:8px 4px}
|
||||||
.side-node{display:flex;align-items:center;gap:4px;padding:4px 6px;border-radius:5px;font-size:13px;position:relative;flex-wrap:nowrap;overflow:hidden}
|
.side-node{display:flex;align-items:center;gap:4px;padding:4px 6px;border-radius:5px;font-size:13px;position:relative;flex-wrap:nowrap;overflow:hidden}
|
||||||
|
.guide-line{position:absolute;top:0;bottom:0;width:1px;background:#e5eaf0;pointer-events:none}
|
||||||
.side-node:hover{background:#f1f5fb}
|
.side-node:hover{background:#f1f5fb}
|
||||||
.side-name{cursor:pointer;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;flex:1;min-width:0}
|
.side-name{cursor:pointer;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;flex:1;min-width:0}
|
||||||
.side-name.active{color:#1769e0;font-weight:600}
|
.side-name.active{color:#1769e0;font-weight:600}
|
||||||
.side-node:hover .side-ops{visibility:visible}
|
.side-ops-bar{display:flex;align-items:center;gap:3px;flex-wrap:wrap;padding:4px 10px 5px 26px;margin-top:2px;border-bottom:1px solid #e5eaf0}
|
||||||
.side-ops{visibility:hidden;display:inline-flex;gap:2px;margin-left:auto}
|
.side-ops-bar button{border:0;background:none;cursor:pointer;font-size:11px;color:#526173;padding:1px 4px;border-radius:3px}
|
||||||
.side-ops button{border:0;background:none;cursor:pointer;font-size:11px;color:#526173;padding:1px 3px;border-radius:3px}
|
.side-ops-bar button:hover{background:#dfe9f7;color:#1769e0}
|
||||||
.side-ops button:hover{background:#dfe9f7;color:#1769e0}
|
.side-ops-bar button.danger:hover{background:#fbe0dc;color:#b44830}
|
||||||
.side-ops button.danger:hover{background:#fbe0dc;color:#b44830}
|
.side-ops-bar button:disabled{color:#c3ccd8;cursor:default;background:none}
|
||||||
.tw{width:14px;text-align:center;color:#8a97a8;cursor:pointer;user-select:none}
|
.tw{width:14px;text-align:center;color:#8a97a8;cursor:pointer;user-select:none}
|
||||||
.tw.off{cursor:default;color:#c3ccd8}
|
.tw.off{cursor:default;color:#c3ccd8}
|
||||||
.side-count{margin-left:0;color:#9aa7b6;font-size:11px;flex:0 0 auto}
|
.side-count{margin-left:0;color:#9aa7b6;font-size:11px;flex:0 0 auto}
|
||||||
.side-plus{margin-left:auto;color:#1769e0;cursor:pointer;font-weight:700}
|
.side-plus{margin-left:auto;color:#1769e0;cursor:pointer;font-weight:700}
|
||||||
.suffix-main{flex:1;min-width:0;height:100%;display:flex;flex-direction:column;overflow:hidden}
|
.suffix-main{flex:1;min-width:0;height:100%;display:flex;flex-direction:column;overflow:hidden}
|
||||||
.bar{display:flex;align-items:center;gap:8px;padding:0 0 6px}
|
.bar{display:flex;align-items:center;gap:8px;padding:0 0 6px;width:100%}
|
||||||
.bar strong{font-size:15px}
|
.bar strong{font-size:15px}
|
||||||
|
.bar-btns{display:inline-flex;align-items:center;gap:5px}
|
||||||
|
.bar-btns .el-button+.el-button{margin-left:0}
|
||||||
.bar-note{color:#8a97a8;font-size:12px}
|
.bar-note{color:#8a97a8;font-size:12px}
|
||||||
/* 列排序弹框 */
|
/* 列设置弹框 */
|
||||||
|
.col-set-toolbar{display:flex;align-items:center;justify-content:flex-end;gap:5px;margin-bottom:8px}
|
||||||
|
.col-set-toolbar .el-input{flex:0 1 210px;min-width:130px}
|
||||||
.col-order-hint{color:#8a97a8;font-size:12px;margin-bottom:10px;line-height:1.6}
|
.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-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{display:flex;align-items:center;gap:8px;padding:7px 10px;border-bottom:1px solid #eef1f5;font-size:13px}
|
||||||
.col-order-row:hover{background:#f7faff}
|
.col-order-row:hover{background:#f7faff}
|
||||||
.col-order-row.selected{background:#eaf2fd}
|
|
||||||
.co-idx{flex:0 0 24px;color:#9aa7b6;font-size:12px}
|
.co-idx{flex:0 0 24px;color:#9aa7b6;font-size:12px}
|
||||||
.co-name{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
|
.co-name{flex:1;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
|
||||||
.co-name.value{color:#1769e0;font-weight:600}
|
.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}
|
.co-vtag{font-style:normal;background:#e6f5ee;color:#16845b;border-radius:3px;font-size:10px;padding:0 4px}
|
||||||
.co-width{width:58px;text-align:center;font-size:12px;border:1px solid #d8dfe8;border-radius:3px;padding:1px 4px}
|
.co-fixtag{font-style:normal;background:#eef1f5;color:#657387;border-radius:3px;font-size:10px;padding:0 4px}
|
||||||
.col-order-add{display:flex;align-items:center;gap:10px;margin-top:12px}
|
.col-order-row.fixed-row{background:#fbfcfe}
|
||||||
.col-order-add .el-input{flex:1}
|
.co-width{flex:0 0 58px;width:58px;text-align:center;font-size:12px;border:1px solid #d8dfe8;border-radius:3px;padding:1px 4px}
|
||||||
td.cell.locked{cursor:default}
|
.co-ops{flex:0 0 auto;display:inline-flex;align-items:center;justify-content:flex-end;gap:5px;min-width:142px}
|
||||||
|
.col-order-row .op{padding:2px 5px}
|
||||||
.grow{flex:1}
|
.grow{flex:1}
|
||||||
.sheet-wrap{flex:1;min-height:0;border:1px solid #e5eaf0;border-radius:6px;overflow:auto;background:#fff}
|
.sheet-wrap{flex:1;min-height:0;border:1px solid #e5eaf0;border-radius:6px;overflow:auto;background:#fff}
|
||||||
table.sheet.basic{border-collapse:collapse;width:100%;font-size:13px}
|
table.sheet.basic{border-collapse:collapse;width:100%;font-size:13px;table-layout:fixed}
|
||||||
table.sheet.basic th,table.sheet.basic td{border:1px solid #dfe5e7;padding:2px 8px;height:26px;text-align:left;vertical-align:middle}
|
table.sheet.basic th,table.sheet.basic td{border:1px solid #dfe5e7;padding:2px 8px;height:26px;text-align:left;vertical-align:middle;overflow:hidden;text-overflow:ellipsis}
|
||||||
table.sheet.basic thead th{background:#f4f6fa;font-weight:600;height:28px}
|
table.sheet.basic thead th{background:#f4f6fa;font-weight:600;height:28px;text-align:center;overflow:hidden;text-overflow:ellipsis}
|
||||||
table.sheet.basic .b-idx{width:56px;text-align:center;color:#9aa7b6}
|
table.sheet.basic .b-idx{text-align:center;color:#9aa7b6}
|
||||||
table.sheet.basic .b-suffix{min-width:150px}
|
|
||||||
table.sheet.basic .group-tr td{background:#f4f6fa}
|
table.sheet.basic .group-tr td{background:#f4f6fa}
|
||||||
table.sheet.basic .group-cell strong{font-size:13px}
|
table.sheet.basic .group-cell strong{font-size:13px}
|
||||||
table.sheet.basic .group-ops{text-align:right;white-space:nowrap}
|
table.sheet.basic .group-ops{text-align:right;white-space:nowrap}
|
||||||
table.sheet.basic .ops-cell{white-space:nowrap}
|
table.sheet.basic .ops-cell{white-space:nowrap}
|
||||||
table.sheet.basic .files-cell{min-width:220px}
|
table.sheet.basic .files-cell{white-space:normal}
|
||||||
table.sheet.basic tr.data-tr:hover td{background:#fafcff}
|
table.sheet.basic tr.data-tr:hover td{background:#fafcff}
|
||||||
.group-block{border-bottom:1px solid #eef1f5}
|
.group-block{border-bottom:1px solid #eef1f5}
|
||||||
.group-block:last-child{border-bottom:0}
|
.group-block:last-child{border-bottom:0}
|
||||||
@@ -835,48 +935,49 @@ table.sheet.basic tr.data-tr:hover td{background:#fafcff}
|
|||||||
.btn-main{border:1px solid #1769e0;background:#1769e0;color:#fff;border-radius:4px;cursor:pointer;font-size:12px;padding:3px 10px}
|
.btn-main{border:1px solid #1769e0;background:#1769e0;color:#fff;border-radius:4px;cursor:pointer;font-size:12px;padding:3px 10px}
|
||||||
.btn-main:hover{background:#125cc4}
|
.btn-main:hover{background:#125cc4}
|
||||||
.btn-main:disabled{opacity:.6;cursor:default}
|
.btn-main:disabled{opacity:.6;cursor:default}
|
||||||
.btn-edit{border:1px solid #d8dfe8;background:#fff;border-radius:4px;cursor:pointer;font-size:12px;padding:2px 10px}
|
|
||||||
.btn-edit.on{border-color:#1769e0;color:#1769e0;background:#eaf2fd}
|
|
||||||
.suffix-row{display:flex;align-items:center;gap:10px;padding:7px 12px;border-bottom:1px solid #f2f5f8}
|
.suffix-row{display:flex;align-items:center;gap:10px;padding:7px 12px;border-bottom:1px solid #f2f5f8}
|
||||||
.suffix-row:hover{background:#fafcff}
|
.suffix-row:hover{background:#fafcff}
|
||||||
.empty-row{color:#9aa7b6}
|
.empty-row{color:#9aa7b6}
|
||||||
.c-idx{flex:0 0 34px;color:#9aa7b6;font-size:12px}
|
.c-idx{flex:0 0 34px;color:#9aa7b6;font-size:12px}
|
||||||
.c-suffix{flex:0 0 140px}
|
.c-suffix{flex:0 0 140px}
|
||||||
.suffix-name{cursor:text}
|
.suffix-name{cursor:text;display:block;overflow:hidden;text-overflow:ellipsis}
|
||||||
|
.ops-btns{display:inline-flex;align-items:center;gap:5px}
|
||||||
|
.ops-cell .op,.ops-cell .btn-main{padding:2px 5px}
|
||||||
.suffix-name.empty{color:#9aa7b6}
|
.suffix-name.empty{color:#9aa7b6}
|
||||||
.c-files{flex:1;display:flex;gap:8px;flex-wrap:wrap;min-width:0}
|
.c-files{flex:1;display:flex;gap:8px;flex-wrap:wrap;min-width:0}
|
||||||
.file-chip{display:inline-flex;align-items:center;gap:4px;border:1px solid #d8e4f5;background:#f2f7ff;border-radius:4px;padding:1px 6px;font-size:12px}
|
.file-chip{display:inline-flex;align-items:center;gap:4px;border:1px solid #d8e4f5;background:#f2f7ff;border-radius:4px;padding:1px 6px;font-size:12px}
|
||||||
|
.pub-tag{font-style:normal;background:#e6f5ee;color:#16845b;border-radius:3px;font-size:10px;padding:0 4px;flex:0 0 auto}
|
||||||
.file-chip a{color:#1769e0;text-decoration:none;max-width:220px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
|
.file-chip a{color:#1769e0;text-decoration:none;max-width:220px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
|
||||||
.chip-x{border:0;background:none;cursor:pointer;color:#8a97a8;padding:0 2px}
|
.chip-x{border:0;background:none;cursor:pointer;color:#8a97a8;padding:0 2px}
|
||||||
.chip-x:hover{color:#b44830}
|
.chip-x:hover{color:#b44830}
|
||||||
.c-ops{display:flex;gap:6px;flex:0 0 auto}
|
.c-ops{display:flex;gap:6px;flex:0 0 auto}
|
||||||
.empty-tip{padding:26px;text-align:center;color:#9aa7b6;font-size:13px}
|
.empty-tip{padding:26px;text-align:center;color:#9aa7b6;font-size:13px}
|
||||||
.hidden-file{display:none}
|
.hidden-file{display:none}
|
||||||
table.sheet{border-collapse:collapse;width:100%;font-size:12.5px}
|
/* 目录工作区表:列宽合计优先,不强行铺满;列多时在 sheet-wrap 内左右滚动 */
|
||||||
table.sheet th,table.sheet td{border-right:1px solid #eef1f5;border-bottom:1px solid #eef1f5;padding:3px 8px;text-align:left;white-space:nowrap}
|
table.sheet:not(.basic){width:max-content}
|
||||||
table.sheet thead th{background:#f4f6fa;color:#657387;font-weight:600;position:relative}
|
table.sheet{border-collapse:collapse;width:100%;font-size:12.5px;table-layout:fixed}
|
||||||
|
table.sheet th,table.sheet td{border-right:1px solid #eef1f5;border-bottom:1px solid #eef1f5;padding:3px 8px;text-align:left;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
|
||||||
|
table.sheet thead th{background:#f4f6fa;color:#657387;font-weight:600;position:relative;text-align:center;overflow:hidden;text-overflow:ellipsis}
|
||||||
.fix{background:#fff}
|
.fix{background:#fff}
|
||||||
thead .fix{background:#f4f6fa}
|
thead .fix{background:#f4f6fa}
|
||||||
th.fix{min-width:52px}
|
td.idx{color:#9aa7b6;font-size:12px;text-align:center}
|
||||||
td.idx{color:#9aa7b6;font-size:12px}
|
.custom-th>span{display:inline-block;max-width:calc(100% - 14px);overflow:hidden;text-overflow:ellipsis;vertical-align:middle}
|
||||||
table.sheet thead th:nth-child(2),table.sheet tbody td:nth-child(2){min-width:110px}
|
|
||||||
.custom-th:hover .th-x{visibility:visible}
|
.custom-th:hover .th-x{visibility:visible}
|
||||||
.th-x{visibility:hidden;border:0;background:none;cursor:pointer;color:#b44830;margin-left:6px}
|
.th-x{visibility:hidden;position:absolute;right:3px;top:50%;transform:translateY(-50%);border:0;background:none;cursor:pointer;color:#b44830;padding:0 2px;line-height:1}
|
||||||
.vtag{font-style:normal;background:#e6f5ee;color:#16845b;border-radius:3px;font-size:10px;padding:0 4px;margin-left:4px}
|
.vtag{font-style:normal;background:#e6f5ee;color:#16845b;border-radius:3px;font-size:10px;padding:0 4px;margin-left:4px}
|
||||||
.group-tr td{background:#f8fafc;color:#526173;font-size:12.5px}
|
.group-tr td{background:#f8fafc;color:#526173;font-size:12.5px}
|
||||||
.data-tr.editing td{background:#f6faff}
|
.data-tr.editing td{background:#f6faff}
|
||||||
td.cell{cursor:text;min-width:120px;max-width:320px;overflow:hidden;text-overflow:ellipsis}
|
td.cell{cursor:text;overflow:hidden;text-overflow:ellipsis}
|
||||||
td.cell:hover{background:#f7faff}
|
td.cell:hover{background:#f7faff}
|
||||||
.cell-text.value{color:#1769e0}
|
.cell-text.value{color:#1769e0}
|
||||||
.cell-empty{color:#c3ccd8}
|
.cell-empty{color:#c3ccd8}
|
||||||
.cell-editor{display:inline-flex;gap:4px;align-items:center}
|
.cell-editor{display:flex;gap:4px;align-items:center;width:100%}
|
||||||
.cell-input{font:inherit;border:1px solid #1769e0;border-radius:3px;padding:2px 6px;min-width:150px}
|
.cell-editor .op{flex:0 0 auto}
|
||||||
.cell-input.half{min-width:70px;width:70px}
|
.cell-input{font:inherit;border:1px solid #1769e0;border-radius:3px;padding:2px 6px;min-width:0;flex:1 1 auto;width:100%}
|
||||||
|
.cell-input.half{flex:1 1 0;width:auto}
|
||||||
.col-form{display:grid;gap:14px}
|
.col-form{display:grid;gap:14px}
|
||||||
.col-form label{display:grid;gap:6px}
|
.col-form > label{display:grid;gap:6px}
|
||||||
.lab{font-size:12px;font-weight:600;color:#526173}
|
.lab{font-size:12px;font-weight:600;color:#526173}
|
||||||
.val-line{display:flex !important;align-items:center;gap:8px}
|
td.anchor{cursor:text;text-align:center}
|
||||||
.val-line .muted{font-size:12px}
|
td.anchor:hover{background:#f7faff}
|
||||||
td.anchor{cursor:pointer;text-align:center;color:#9aa7b6}
|
|
||||||
td.anchor:hover{color:#1769e0}
|
|
||||||
</style>
|
</style>
|
||||||
|
|||||||
Reference in New Issue
Block a user