From 5aeded2d517adbabaafda322ec003e6955977aec Mon Sep 17 00:00:00 2001 From: tamakyi Date: Sat, 19 Sep 2026 20:13:06 +0800 Subject: [PATCH] =?UTF-8?q?=E8=A1=A5=E5=85=A8=E9=A1=B5=E6=81=A2=E5=A4=8D?= =?UTF-8?q?=E6=89=8B=E5=B7=A5=E5=A1=AB=E5=86=99=EF=BC=8C=E6=8A=8A=E3=80=8C?= =?UTF-8?q?=E4=B8=8D=E5=8A=A8=E3=80=8D=E5=8F=98=E6=88=90=E7=9C=9F=E6=AD=A3?= =?UTF-8?q?=E7=9A=84=E9=BB=98=E8=AE=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 上一版改成 select 之后有两个问题:活动和类别都只能从列表里挑,填不进去的写不了; 而且建议被强制预选,用户选「不动」再点「用高德分析」(会整页重载)就白选了, 看起来像被锁死。 现在:活动是可输入的输入框,带已有类型提示,填新名字会新建类型; 类别下拉末尾加「其它(自己写)…」,选中后露出文本框,写什么存什么—— 真机自己也存中文类别,写中文一样认得,不必强记 MKPOICategory 那串枚举名。 「不动」改成真正的默认:什么都不预选,想批量采纳就点「采纳本页建议」。 点「用高德分析」前会把本页填过的存进 sessionStorage,回来接着填,不会白改。 --- internal/web/fillup.go | 8 +- internal/web/fillup_test.go | 35 ++++++- internal/web/templates/admin/fillup.html | 114 +++++++++++++++++------ internal/web/view.go | 2 + 4 files changed, 126 insertions(+), 33 deletions(-) diff --git a/internal/web/fillup.go b/internal/web/fillup.go index be9c367..4bfa36a 100644 --- a/internal/web/fillup.go +++ b/internal/web/fillup.go @@ -344,7 +344,13 @@ func (s *Server) adminFillupApply(w http.ResponseWriter, r *http.Request) { acts += int(n) } } - if cat := strings.TrimSpace(r.PostFormValue("cat_" + strconv.FormatInt(pid, 10))); cat != "" { + key := "cat_" + strconv.FormatInt(pid, 10) + cat := strings.TrimSpace(r.PostFormValue(key)) + if cat == "__custom__" { + // 下拉里选了「其它(自己写)」,真正要写的是旁边那个文本框 + cat = strings.TrimSpace(r.PostFormValue(key + "__custom")) + } + if cat != "" { res, err := ex.ExecContext(ctx, `UPDATE places SET poi_category=$1 WHERE dataset_id=$2 AND id=$3 AND COALESCE(poi_category,'')=''`, cat, ds.ID, pid) if err != nil { diff --git a/internal/web/fillup_test.go b/internal/web/fillup_test.go index 30097ef..a4a4932 100644 --- a/internal/web/fillup_test.go +++ b/internal/web/fillup_test.go @@ -215,7 +215,8 @@ func TestFillupPagination(t *testing.T) { t.Fatalf("%s 渲染失败: %d", url, rec.Code) } body := rec.Body.String() - return strings.Count(body, `name="cat_`), strings.Count(body, `class="pager"`) + // 数类别下拉本身;旁边那个「其它(自己写)」文本框的 name 也以 cat_ 开头,得排掉 + return strings.Count(body, `
@@ -52,24 +52,21 @@ @@ -85,10 +82,12 @@
- + +
+ {{if gt .PageCount 1}}
{{if gt .PageNo 1}}上一页{{end}} @@ -104,19 +103,72 @@ {{end}}
+ + {{range .Activities}}{{end}} + + diff --git a/internal/web/view.go b/internal/web/view.go index 918bd28..613ca84 100644 --- a/internal/web/view.go +++ b/internal/web/view.go @@ -1327,6 +1327,8 @@ func templateFuncs() template.FuncMap { "dt": func(t time.Time) string { return t.Local().Format("2006-01-02 15:04") }, // actKey 给活动冲突生成表单字段名,与处理函数共用同一套键 "actKey": rond.ActivityKey, + // catName 把 MKPOICategoryXxx 翻成中文,补全页的类别下拉要用 + "catName": poiName, // dtt 接受 *time.Time,nil 返回空串,便于可选时间字段直接渲染 "dtt": func(t *time.Time) string { if t == nil {
{{$row.Missing}} {{if $row.NoAct}} - + {{else}}—{{end}} {{if $row.NoCat}} {{$hint := $row.CatHint}} - + + {{if $hint}}{{end}} + {{range $.Categories}}{{if ne .Value $hint}}{{end}}{{end}} + + {{else}}—{{end}} {{if $row.Source}}{{$row.Source}}{{else}}—{{end}}