1) 日历计数口径
- 工作台与大屏的格子统一改为「已完成 / 总数」(如 2/5 = 共 5 单、做完 2 单)
2) 客户详情·当月排单
- 新增客户专属月历:每天显示 已完成/总数,可翻月,点某天跳转到日历对应日期
- 没有排单的日期淡化显示
3) 套餐标签与页签合并
- packages 新增 tag 列(可空),套餐编辑页可填
- 日历/大屏页签按标签合并:同标签套餐合成一个页签;勾了「独立显示」的套餐额外再开一个自己的页签
- 大屏同样支持标签筛选,链接参数为 tag=xxx
4) 批量开通
- 新增套餐详情页 /packages/{id}:显示套餐信息 + 客户列表
- 表头「全选」置顶,已订阅该套餐的客户置灰不可选;开始日期默认今天、天数/次数默认取套餐设置,均可改
- POST /packages/{id}/subscribe 批量开通,重复的自动跳过并汇总提示
- 修复 r.PostForm 未 ParseForm 导致拿不到勾选项的问题(批量打卡同源问题一并修正)
5) 触控 / PC 模式
- 尾号输入框右侧新增切换按钮,触控模式展开 3×4 键盘、输入框只读 + inputmode=none(不唤起系统输入法),按键直接写值
- 偏好记在 localStorage,默认 PC 模式(键盘收起)
6) 按次到期
- 按次订阅的到期日保持选填;填了到期后状态显示「已到期」且不再进日历待排(复用既有 end_date,无新列)
数据库兼容性:
- 只新增 packages.tag 一列,老库启动时自动 ALTER,可重复迁移;原有表结构与接口不变
测试:
- 无头 Chrome 实拍 5 张页面(日历/触控模式/客户月历/套餐批量/大屏)
- 功能验证 18 项全过(计数口径、标签页签、标签筛选、批量开通与重复跳过、月历翻月、触控开关、按次过期不上日历)
- 119 项验收回归全绿;go vet / go test ./... 通过;版本号 1.7.0
This commit is contained in:
@@ -4,6 +4,8 @@ import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"net/http"
|
||||
"net/url"
|
||||
"strings"
|
||||
|
||||
"daili/internal/domain"
|
||||
"daili/internal/store"
|
||||
@@ -16,6 +18,7 @@ type screenDay struct {
|
||||
IsToday bool
|
||||
IsPast bool
|
||||
Count int
|
||||
Done int
|
||||
Urgent int
|
||||
Heat int
|
||||
// Strip 打手色竖条(去重)
|
||||
@@ -42,17 +45,19 @@ type screenData struct {
|
||||
Refresh int
|
||||
Version string
|
||||
|
||||
HeatMode string // task = 每日待完成;due = 到期
|
||||
HeatTotal int
|
||||
Tabs []PkgTab
|
||||
PkgID int64
|
||||
HasTabs bool
|
||||
Theme string
|
||||
HeatMode string // task = 每日待完成;due = 到期
|
||||
Tag string
|
||||
HeatTotal int
|
||||
Tabs []PkgTab
|
||||
PkgID int64
|
||||
HasTabs bool
|
||||
FilterQuery string
|
||||
Theme string
|
||||
}
|
||||
|
||||
// screenCalSubs 读取大屏日历区间内的订阅,并带上暂停/打卡/加急。
|
||||
func (s *Server) screenCalSubs(from, to string, pkgID int64) ([]calSub, map[int64]map[string]store.Checkin, map[int64]map[string]bool, error) {
|
||||
subs, pauses, checkins, urgent, err := s.loadCalendarSubs(from, to, pkgID)
|
||||
func (s *Server) screenCalSubs(from, to string, pkgID int64, tag string) ([]calSub, map[int64]map[string]store.Checkin, map[int64]map[string]bool, error) {
|
||||
subs, pauses, checkins, urgent, err := s.loadCalendarSubs(from, to, pkgID, tag)
|
||||
if err != nil {
|
||||
return nil, nil, nil, err
|
||||
}
|
||||
@@ -74,6 +79,7 @@ func (s *Server) handleScreen(w http.ResponseWriter, r *http.Request) {
|
||||
today := domain.Today()
|
||||
warn := s.warnDays()
|
||||
pkgID := int64(s.queryInt(r, "pkg", 0))
|
||||
tag := strings.TrimSpace(r.URL.Query().Get("tag"))
|
||||
heatMode := r.URL.Query().Get("heat")
|
||||
if heatMode != "due" {
|
||||
heatMode = "task"
|
||||
@@ -85,16 +91,18 @@ func (s *Server) handleScreen(w http.ResponseWriter, r *http.Request) {
|
||||
return
|
||||
}
|
||||
data := &screenData{
|
||||
Stats: stats,
|
||||
MonthTitle: fmt.Sprintf("%d 年 %d 月", today.Year(), int(today.Month())),
|
||||
Year: today.Year(),
|
||||
Month: int(today.Month()),
|
||||
Weekdays: []string{"一", "二", "三", "四", "五", "六", "日"},
|
||||
Top: subViews(stats.Top, today, warn),
|
||||
Refresh: s.screenRefresh(),
|
||||
Version: s.cfg.Version,
|
||||
HeatMode: heatMode,
|
||||
PkgID: pkgID,
|
||||
Stats: stats,
|
||||
MonthTitle: fmt.Sprintf("%d 年 %d 月", today.Year(), int(today.Month())),
|
||||
Year: today.Year(),
|
||||
Month: int(today.Month()),
|
||||
Weekdays: []string{"一", "二", "三", "四", "五", "六", "日"},
|
||||
Top: subViews(stats.Top, today, warn),
|
||||
Refresh: s.screenRefresh(),
|
||||
Version: s.cfg.Version,
|
||||
HeatMode: heatMode,
|
||||
PkgID: pkgID,
|
||||
Tag: tag,
|
||||
FilterQuery: "pkg=" + itoa(pkgID),
|
||||
}
|
||||
|
||||
// 今日到期(可按套餐过滤)
|
||||
@@ -114,7 +122,7 @@ func (s *Server) handleScreen(w http.ResponseWriter, r *http.Request) {
|
||||
weeks := (domain.WeekdayIndex(monthStart) + monthEnd.Day() + 6) / 7
|
||||
gridEnd := domain.AddDays(gridStart, weeks*7-1)
|
||||
|
||||
list, checkins, urgent, err := s.screenCalSubs(domain.Date(gridStart), domain.Date(gridEnd), pkgID)
|
||||
list, checkins, urgent, err := s.screenCalSubs(domain.Date(gridStart), domain.Date(gridEnd), pkgID, tag)
|
||||
if err != nil {
|
||||
http.Error(w, "读取大屏日历失败", http.StatusInternalServerError)
|
||||
return
|
||||
@@ -125,7 +133,7 @@ func (s *Server) handleScreen(w http.ResponseWriter, r *http.Request) {
|
||||
for di := 0; di < 7; di++ {
|
||||
d := domain.AddDays(gridStart, wi*7+di)
|
||||
ds := domain.Date(d)
|
||||
count, urgentN := 0, 0
|
||||
count, doneN, urgentN := 0, 0, 0
|
||||
strip := []string{}
|
||||
seenColor := map[string]bool{}
|
||||
for _, cs := range list {
|
||||
@@ -140,7 +148,8 @@ func (s *Server) handleScreen(w http.ResponseWriter, r *http.Request) {
|
||||
}
|
||||
ci, has := checkins[cs.sub.ID][ds]
|
||||
if has && (ci.Status == "done" || ci.Status == "skipped") {
|
||||
continue // “待完成”只统计还没处理的
|
||||
doneN++
|
||||
continue // “待完成”热力只统计还没处理的
|
||||
}
|
||||
count++
|
||||
if urgent[cs.sub.ID][ds] {
|
||||
@@ -164,7 +173,8 @@ func (s *Server) handleScreen(w http.ResponseWriter, r *http.Request) {
|
||||
InMonth: d.Month() == today.Month(),
|
||||
IsToday: ds == domain.Date(today),
|
||||
IsPast: d.Before(today),
|
||||
Count: count,
|
||||
Count: count + doneN,
|
||||
Done: doneN,
|
||||
Urgent: urgentN,
|
||||
Heat: heatLevel(count),
|
||||
Strip: strip,
|
||||
@@ -174,7 +184,7 @@ func (s *Server) handleScreen(w http.ResponseWriter, r *http.Request) {
|
||||
}
|
||||
|
||||
// 今日待打(加急置顶)
|
||||
rows, err := s.pendingTasks(domain.Date(today), nil, pkgID)
|
||||
rows, err := s.pendingTasks(domain.Date(today), nil, pkgID, tag)
|
||||
if err == nil {
|
||||
for _, row := range rows {
|
||||
if row.Done || row.Skipped {
|
||||
@@ -198,18 +208,27 @@ func (s *Server) handleScreen(w http.ResponseWriter, r *http.Request) {
|
||||
data.Recent = adj
|
||||
}
|
||||
|
||||
// 套餐标签
|
||||
// 页签:按标签合并 + 独立显示另开
|
||||
pkgs, _ := s.db.ListPackages(true)
|
||||
for _, p := range pkgs {
|
||||
if p.CalendarSeparate && !p.Archived {
|
||||
if !data.HasTabs {
|
||||
data.HasTabs = true
|
||||
data.Tabs = append(data.Tabs, PkgTab{ID: 0, Name: "全部", Color: "#8A8F98"})
|
||||
}
|
||||
data.Tabs = append(data.Tabs, PkgTab{ID: p.ID, Name: p.Name, Color: p.Color})
|
||||
data.Tabs, data.HasTabs = buildCalendarTabs(pkgs, nil, 0)
|
||||
for i := range data.Tabs {
|
||||
t := &data.Tabs[i]
|
||||
href := "/screen?heat=" + heatMode
|
||||
if t.Tag != "" {
|
||||
href += "&tag=" + url.QueryEscape(t.Tag)
|
||||
t.Active = t.Tag == tag
|
||||
} else if t.ID > 0 {
|
||||
href += "&pkg=" + itoa(t.ID)
|
||||
t.Active = t.ID == pkgID
|
||||
} else {
|
||||
t.Active = tag == "" && pkgID == 0
|
||||
}
|
||||
t.Href = href
|
||||
}
|
||||
|
||||
if tag != "" {
|
||||
data.FilterQuery = "tag=" + url.QueryEscape(tag)
|
||||
}
|
||||
data.Theme = themeFromRequest(r)
|
||||
p := s.newPage(r, "大屏", "screen")
|
||||
p.Theme = data.Theme
|
||||
@@ -225,7 +244,7 @@ func (s *Server) handleScreenDay(w http.ResponseWriter, r *http.Request) {
|
||||
return
|
||||
}
|
||||
pkgID := int64(s.queryInt(r, "pkg", 0))
|
||||
rows, err := s.pendingTasks(date, nil, pkgID)
|
||||
rows, err := s.pendingTasks(date, nil, pkgID, strings.TrimSpace(r.URL.Query().Get("tag")))
|
||||
if err != nil {
|
||||
http.Error(w, "读取失败", http.StatusInternalServerError)
|
||||
return
|
||||
|
||||
Reference in New Issue
Block a user