feat(v1.11.5-L): lite 精简版——移除大屏/客户自查/多用户/小键盘,套餐仅保留按日
需求与确认(用户逐项确认): - 老数据「按次 / 通行证 / 深渊」统一迁移成按日,代码里彻底删除三种模式 - 打手归属一并移除(只剩一个人,颜色与指派没有区分意义) - 盲水印做成完全不可见:只存在于 DOM / 源码,肉眼与截图都看不到 - 拼写采用更正后的 Powered by Baka春秋 - 版本号与品牌全站统一带 -L - screen_public / portal_public 保留解析但不起作用,保证旧 ini 能直接启动 - README 同步更新 品牌与版本(全站统一): - const version = "1.11.5-L":<title>、启动横幅、日志前缀 [代打台-L]、 设置页版本号、页脚版本号全部带 -L - 左上角导航品牌 代打台 → 代打台-L(登录页、初始化页同步) - 页脚新增可见署名 Powered by Baka春秋 盲水印: - _layout.html 在 <body> 起始处注入 .wm-blind 容器(含注释与 data-wm 双标记), 覆盖包括登录/初始化在内的所有页面 - app.css 用零尺寸 + 透明 + opacity:0 + clip-path:inset(50%) 四重隐藏, 同时留同名注释;不占位、不上色、不进无障碍树、不影响打印 功能移除: - 大屏:删除 handlers_screen.go、pages/screen.html、_screen_layout.html、 static/screen.css、static/screen.js、store.Stats/ScreenStats; 导航「大屏 ↗」、页脚「大屏」、设置页「大屏刷新/大屏」行、启动横幅大屏行一并删除 - 客户自查:删除 handlers_portal.go、pages/portal.html 与 .portal-*/.pcal-* 样式, 设置页「客户自助」行删除 - 多管理员:删除 handleUserCreate/Toggle/Color/UserEditPage/UserEditSave、 pages/user_form.html、store 侧 ActiveUsers/SetUserColor/SetUserActive/ UpdateUserByAdmin/NormalizeColor/AssigneePalette;设置页「管理员」整块移除, 只保留首次启动创建的那一个账户与「修改我的密码」 - 打手归属:删除 customers.assignee_id 相关读写与 UI(客户详情指派下拉、 客户表单「归属打手」、日历格左侧打手色竖条、任务卡打手标签、套餐详情客户列) - 登录页与初始化页的说明文案同步改为单账户口径(「只有一个管理员账户」 「创建后不能再添加其他管理员」),字数与 main 对齐,卡片不换行、高度不变 - 触摸小键盘:删除 3×4 键盘、⌨/触控开关、localStorage 记忆、.keypad* 样式 - 套餐计费方式:只保留按日。删除按次/通行证/深渊的 Package 与 Subscription 字段、 domain 里的 UnitCount/StateUsedUp/CycleIndex、package_form 计费方式单选与 通行证/深渊/有效期字段、日历整段色块(has-block/cell-block/season-band)、 追加次数分支、SeasonComplete/AddCount、CountActiveSubs 的次数条件 数据库迁移(幂等,Migrate 内自动执行): - normalizeLegacyData:套餐一律 unit='day' 并清 season/abyss/cycle_days/ default_validity_days/season_*;订阅清 season/abyss/cycle_days/season_done - 通行证、深渊当年就是 unit='day' 且起止日完整,仅清标记,服务区间原样保留 - 按次按「1 次 = 1 天」折算:结束日 = 开始日 + 总次数 − 1;仍缺结束日退回开始日 - 只动数据,不删表不删列:老库的 season/abyss/cycle_days/total_count/used_count 保留但不再使用,升级可逆、不会因为 DDL 失败卡住 - 新库 schema 干净:不再创建上述列,users.color / customers.assignee_id 也不创建 - 老库 ensureColumn 保留 calendar_separate / tag / archived 三项(真增量列) 兼容: - config 仍解析 screen_public / portal_public(结构体字段注明已废弃), 默认 ini 模板里改为「已废弃,写了不报错、不生效」 测试: - go vet ./... 通过;go test ./... 全部通过 (新增 TestNormalizeLegacyTypeData 验证三模式折算成按日; TestSingleUserAccount / TestSessionLifecycle 覆盖单用户与会话; 删除按次、深渊、打手颜色、多用户等已不存在的能力的用例) - 新增 scripts/smoke-lite.ps1:起隔离实例,19 个页面级请求全部 200, 已移除的 /screen、/customer、/api/screen/day 均 404, 水印/品牌/v1.11.5-L/无残留词 12 项断言通过, 真实数据下日历出现待打任务、「剩 30 天」、今天到期徽标 4 项断言通过, 本次 0 失败 README:改为 lite 版说明,删除大屏/客户自查/通行证/深渊/按次/小键盘/多用户章节, 新增「盲水印」与「与 main 分支的差异」两节(含老数据折算规则与列保留说明)。
This commit is contained in:
@@ -26,20 +26,10 @@ type DayCell struct {
|
||||
DoneCount int
|
||||
UrgentCnt int
|
||||
Heat int
|
||||
// 通行证 / 深渊色块
|
||||
BlockColor string
|
||||
BlockDone int
|
||||
BlockTotal int
|
||||
BlockText string
|
||||
BlockTitle string
|
||||
// BlockPercent 色块底色浓度:通行证固定 18%,深渊按周期依次减淡
|
||||
BlockPercent int
|
||||
// PendingCount 当日还没完成的单数(= TaskCount - DoneCount)
|
||||
PendingCount int
|
||||
Tickets []Ticket
|
||||
More int
|
||||
// Strip 是左侧的打手色竖条(按出现顺序去重,未指派为灰)
|
||||
Strip []string
|
||||
}
|
||||
|
||||
// Ticket 是日历格里的色签。
|
||||
@@ -53,8 +43,6 @@ type Ticket struct {
|
||||
Skipped bool
|
||||
IsDue bool
|
||||
Urgent bool
|
||||
// AssigneeColor 打手颜色(未指派为空,模板用 spanAssignee 兜底)
|
||||
AssigneeColor string
|
||||
}
|
||||
|
||||
// TaskRow 是当日待打清单的一行。
|
||||
@@ -124,7 +112,6 @@ type calSub struct {
|
||||
start time.Time
|
||||
end time.Time
|
||||
hasEnd bool
|
||||
eval domain.Eval
|
||||
pauses []store.Pause
|
||||
checkins map[string]store.Checkin
|
||||
}
|
||||
@@ -141,93 +128,13 @@ func (c calSub) pausedOn(date string) bool {
|
||||
return false
|
||||
}
|
||||
|
||||
// isBlock 是否为通行证 / 深渊这种整段型订阅。
|
||||
func (c calSub) isBlock() bool { return c.sub.IsBlock() }
|
||||
|
||||
// blockCovers 只判断日期是否落在整段区间内(已完成也继续显示色块)。
|
||||
func (c calSub) blockCovers(date string) bool {
|
||||
if c.sub.Status == domain.StatusClosed || !c.hasEnd {
|
||||
return false
|
||||
}
|
||||
return date >= c.sub.StartDate && date <= c.sub.EndDate
|
||||
}
|
||||
|
||||
// blockDone 返回整段型订阅的已完成数。
|
||||
func (c calSub) blockDone() int { return c.sub.BlockDone() }
|
||||
|
||||
// blockTotal 返回整段型订阅的总数。
|
||||
func (c calSub) blockTotal() int { return c.sub.BlockTotal() }
|
||||
|
||||
// cycleBounds 返回 date 所在深渊周期的起止日。
|
||||
func (c calSub) cycleBounds(date string) (string, string, bool) {
|
||||
if !c.sub.Abyss || c.sub.CycleDays <= 0 {
|
||||
return "", "", false
|
||||
}
|
||||
d, err := domain.ParseDate(date)
|
||||
if err != nil {
|
||||
return "", "", false
|
||||
}
|
||||
idx := domain.CycleIndex(c.start, d, c.sub.CycleDays)
|
||||
if idx < 0 || idx >= c.sub.TotalCount {
|
||||
return "", "", false
|
||||
}
|
||||
return domain.Date(domain.CycleStart(c.start, c.sub.CycleDays, idx)),
|
||||
domain.Date(domain.CycleEnd(c.start, c.sub.CycleDays, idx)), true
|
||||
}
|
||||
|
||||
// cycleDone 判断 date 所在周期是否已经完成(周期内任意一天打卡即算)。
|
||||
func (c calSub) cycleDone(date string) bool {
|
||||
s, e, ok := c.cycleBounds(date)
|
||||
if !ok {
|
||||
return false
|
||||
}
|
||||
for d, ci := range c.checkins {
|
||||
if d >= s && d <= e && ci.Status == "done" {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
// blockNeedsWork 表示这一天是否需要出现在待完成清单里。
|
||||
func (c calSub) blockNeedsWork(date string) bool {
|
||||
if !c.blockCovers(date) || c.sub.Status == domain.StatusClosed {
|
||||
return false
|
||||
}
|
||||
if c.sub.Season {
|
||||
return c.sub.SeasonDone == ""
|
||||
}
|
||||
if c.sub.Abyss {
|
||||
if c.sub.TotalCount <= 0 || c.sub.UsedCount >= c.sub.TotalCount {
|
||||
return false
|
||||
}
|
||||
return !c.cycleDone(date)
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
func (c calSub) covers(date string) bool {
|
||||
if c.sub.Status == domain.StatusClosed || !c.hasEnd {
|
||||
return false
|
||||
}
|
||||
if c.sub.Season {
|
||||
if c.sub.SeasonDone != "" {
|
||||
return false
|
||||
}
|
||||
return date >= c.sub.StartDate && date <= c.sub.EndDate
|
||||
}
|
||||
if c.sub.Abyss {
|
||||
if c.sub.TotalCount > 0 && c.sub.UsedCount >= c.sub.TotalCount {
|
||||
return false
|
||||
}
|
||||
return date >= c.sub.StartDate && date <= c.sub.EndDate && !c.pausedOn(date)
|
||||
}
|
||||
if date < c.sub.StartDate || date > c.sub.EndDate {
|
||||
return false
|
||||
}
|
||||
if c.sub.Unit == domain.UnitCount && c.eval.RemainingCount <= 0 {
|
||||
return false
|
||||
}
|
||||
return !c.pausedOn(date)
|
||||
}
|
||||
|
||||
@@ -277,21 +184,6 @@ func buildCalendarTabs(pkgs []store.Package, subs []store.Subscription, total in
|
||||
return tabs, true
|
||||
}
|
||||
|
||||
// wideFrom/wideTo 把打卡查询范围放大,保证跨月的深渊周期也能判定完成。
|
||||
func wideFrom(s string) string {
|
||||
if t, err := domain.ParseDate(s); err == nil {
|
||||
return domain.Date(domain.AddDays(t, -400))
|
||||
}
|
||||
return s
|
||||
}
|
||||
|
||||
func wideTo(s string) string {
|
||||
if t, err := domain.ParseDate(s); err == nil {
|
||||
return domain.Date(domain.AddDays(t, 400))
|
||||
}
|
||||
return s
|
||||
}
|
||||
|
||||
// loadCalendarSubs 读取区间内与日历相交的订阅;pkgID>0 取该套餐,tag 非空取该标签下的所有套餐。
|
||||
func (s *Server) loadCalendarSubs(from, to string, pkgID int64, tag string) ([]store.Subscription, map[int64][]store.Pause, map[int64]map[string]store.Checkin, map[int64]map[string]bool, error) {
|
||||
subs, err := s.db.CalendarSubs(from, to)
|
||||
@@ -327,7 +219,7 @@ func (s *Server) loadCalendarSubs(from, to string, pkgID int64, tag string) ([]s
|
||||
if err != nil {
|
||||
return nil, nil, nil, nil, err
|
||||
}
|
||||
checkins, err := s.db.CheckinsBetween(wideFrom(from), wideTo(to))
|
||||
checkins, err := s.db.CheckinsBetween(from, to)
|
||||
if err != nil {
|
||||
return nil, nil, nil, nil, err
|
||||
}
|
||||
@@ -380,7 +272,6 @@ func (s *Server) handleCalendar(w http.ResponseWriter, r *http.Request) {
|
||||
cs := calSub{
|
||||
sub: sub,
|
||||
start: domain.ParseDateOr(sub.StartDate, today),
|
||||
eval: sub.Eval(today, warn),
|
||||
pauses: pauses[sub.ID],
|
||||
checkins: checkins[sub.ID],
|
||||
}
|
||||
@@ -443,20 +334,6 @@ func (s *Server) handleCalendar(w http.ResponseWriter, r *http.Request) {
|
||||
if !cell.InMonth {
|
||||
continue
|
||||
}
|
||||
if cs.isBlock() {
|
||||
if cs.blockCovers(ds) && cell.BlockText == "" {
|
||||
cell.BlockColor = cs.sub.PackageColor
|
||||
cell.BlockText = blockCellText(cs, ds)
|
||||
cell.BlockDone = 0
|
||||
if cell.BlockText == "1/1" {
|
||||
cell.BlockDone = 1
|
||||
}
|
||||
cell.BlockTotal = 1
|
||||
cell.BlockTitle = cs.sub.PackageName + " · " + cell.BlockText
|
||||
cell.BlockPercent = blockCellPercent(cs, day)
|
||||
}
|
||||
continue
|
||||
}
|
||||
if !cs.covers(ds) {
|
||||
continue
|
||||
}
|
||||
@@ -467,16 +344,15 @@ func (s *Server) handleCalendar(w http.ResponseWriter, r *http.Request) {
|
||||
cell.UrgentCnt++
|
||||
}
|
||||
t := Ticket{
|
||||
SubID: cs.sub.ID,
|
||||
Tail: cs.sub.CustomerTail,
|
||||
Name: cs.sub.CustomerName,
|
||||
Pkg: shortName(cs.sub.PackageName),
|
||||
Color: cs.sub.PackageColor,
|
||||
Done: ci.Status == "done",
|
||||
Skipped: ci.Status == "skipped",
|
||||
IsDue: cs.sub.EndDate == ds,
|
||||
Urgent: isUrgent,
|
||||
AssigneeColor: cs.sub.AssigneeColor,
|
||||
SubID: cs.sub.ID,
|
||||
Tail: cs.sub.CustomerTail,
|
||||
Name: cs.sub.CustomerName,
|
||||
Pkg: shortName(cs.sub.PackageName),
|
||||
Color: cs.sub.PackageColor,
|
||||
Done: ci.Status == "done",
|
||||
Skipped: ci.Status == "skipped",
|
||||
IsDue: cs.sub.EndDate == ds,
|
||||
Urgent: isUrgent,
|
||||
}
|
||||
if t.Done || t.Skipped {
|
||||
cell.DoneCount++
|
||||
@@ -492,8 +368,6 @@ func (s *Server) handleCalendar(w http.ResponseWriter, r *http.Request) {
|
||||
}
|
||||
return tickets[i].SubID < tickets[j].SubID
|
||||
})
|
||||
// 竖条按“当天全部任务”算,不能被色签的 3 条上限截断
|
||||
cell.Strip = assigneeStrip(tickets)
|
||||
if len(tickets) > 3 {
|
||||
cell.More = len(tickets) - 3
|
||||
tickets = tickets[:3]
|
||||
@@ -519,21 +393,6 @@ func (s *Server) handleCalendar(w http.ResponseWriter, r *http.Request) {
|
||||
if cs.sub.EndDate == sel {
|
||||
due = append(due, newSubView(cs.sub, today, warn))
|
||||
}
|
||||
if cs.isBlock() {
|
||||
if !cs.blockNeedsWork(sel) {
|
||||
continue
|
||||
}
|
||||
row := TaskRow{SubView: newSubView(cs.sub, today, warn), Urgent: urgent[cs.sub.ID][sel]}
|
||||
if ci, ok := checkins[cs.sub.ID][sel]; ok {
|
||||
row.CheckinID = ci.ID
|
||||
row.Done = ci.Status == "done"
|
||||
row.Skipped = ci.Status == "skipped"
|
||||
row.Note = ci.Note
|
||||
row.Operator = ci.OperatorName
|
||||
}
|
||||
tasks = append(tasks, row)
|
||||
continue
|
||||
}
|
||||
if !cs.covers(sel) {
|
||||
continue
|
||||
}
|
||||
@@ -642,70 +501,6 @@ func sortTasks(tasks []TaskRow) {
|
||||
})
|
||||
}
|
||||
|
||||
// assigneeStrip 把一格里所有任务的打手颜色去重后返回,未指派用灰色占位。
|
||||
func assigneeStrip(tickets []Ticket) []string {
|
||||
if len(tickets) == 0 {
|
||||
return nil
|
||||
}
|
||||
seen := map[string]bool{}
|
||||
out := make([]string, 0, 4)
|
||||
for _, t := range tickets {
|
||||
c := t.AssigneeColor
|
||||
if c == "" {
|
||||
c = "#8A8F98"
|
||||
}
|
||||
if seen[c] {
|
||||
continue
|
||||
}
|
||||
seen[c] = true
|
||||
out = append(out, c)
|
||||
}
|
||||
return out
|
||||
}
|
||||
|
||||
// blockCellText 整段型订阅在 date 所在周期的完成文本:
|
||||
// 通行证 0/1 或 1/1;深渊按 date 所在的那一个周期 0/1 或 1/1,不显示全局 x/N。
|
||||
func blockCellText(cs calSub, date string) string {
|
||||
if cs.sub.Abyss {
|
||||
if cs.cycleDone(date) {
|
||||
return "1/1"
|
||||
}
|
||||
return "0/1"
|
||||
}
|
||||
if cs.sub.SeasonDone != "" {
|
||||
return "1/1"
|
||||
}
|
||||
return "0/1"
|
||||
}
|
||||
|
||||
// blockCellPercent 整段型色块浓度:通行证 18%;深渊按所在周期 34%→4%。
|
||||
func blockCellPercent(cs calSub, day time.Time) int {
|
||||
if cs.sub.Abyss && cs.sub.CycleDays > 0 {
|
||||
idx := domain.CycleIndex(cs.start, day, cs.sub.CycleDays)
|
||||
return abyssBlockPercent(idx, cs.sub.TotalCount)
|
||||
}
|
||||
return 18
|
||||
}
|
||||
|
||||
// abyssBlockPercent 深渊色块浓度:第一个周期 34%,之后每个周期依次减淡,
|
||||
// 最后一个周期 4%(周期数大于 1 时线性过渡);跨度比 v1.11.3 的 22%→10% 明显更大。
|
||||
func abyssBlockPercent(idx, total int) int {
|
||||
if total <= 1 {
|
||||
return 34
|
||||
}
|
||||
if idx < 0 {
|
||||
idx = 0
|
||||
}
|
||||
if idx >= total {
|
||||
idx = total - 1
|
||||
}
|
||||
pct := 34 - (idx*30)/(total-1)
|
||||
if pct < 4 {
|
||||
pct = 4
|
||||
}
|
||||
return pct
|
||||
}
|
||||
|
||||
func heatLevel(n int) int {
|
||||
switch {
|
||||
case n <= 0:
|
||||
|
||||
@@ -58,13 +58,11 @@ func (s *Server) handleCustomers(w http.ResponseWriter, r *http.Request) {
|
||||
type customerFormData struct {
|
||||
Customer *store.Customer
|
||||
IsNew bool
|
||||
Users []store.User
|
||||
}
|
||||
|
||||
func (s *Server) handleCustomerNewPage(w http.ResponseWriter, r *http.Request) {
|
||||
p := s.newPage(r, "新建客户", "customers")
|
||||
users, _ := s.db.ActiveUsers()
|
||||
p.D = &customerFormData{Customer: &store.Customer{}, IsNew: true, Users: users}
|
||||
p.D = &customerFormData{Customer: &store.Customer{}, IsNew: true}
|
||||
s.render(w, r, "customer_form", p)
|
||||
}
|
||||
|
||||
@@ -78,7 +76,6 @@ func (s *Server) readCustomerForm(r *http.Request) *store.Customer {
|
||||
Tags: normalizeTags(r.PostFormValue("tags")),
|
||||
Source: strings.TrimSpace(r.PostFormValue("source")),
|
||||
Note: strings.TrimSpace(r.PostFormValue("note")),
|
||||
AssigneeID: int64(s.formInt(r, "assignee_id", 0)),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -117,8 +114,7 @@ func (s *Server) handleCustomerCreate(w http.ResponseWriter, r *http.Request) {
|
||||
c := s.readCustomerForm(r)
|
||||
p := s.newPage(r, "新建客户", "customers")
|
||||
if msg := validateCustomer(c); msg != "" {
|
||||
users, _ := s.db.ActiveUsers()
|
||||
p.D = &customerFormData{Customer: c, IsNew: true, Users: users}
|
||||
p.D = &customerFormData{Customer: c, IsNew: true}
|
||||
s.fail(w, r, "customer_form", msg, p)
|
||||
return
|
||||
}
|
||||
@@ -128,8 +124,7 @@ func (s *Server) handleCustomerCreate(w http.ResponseWriter, r *http.Request) {
|
||||
if errors.Is(err, store.ErrDuplicate) {
|
||||
msg = "该「尾号 + 姓名」的客户已存在,请直接搜索后追加订阅"
|
||||
}
|
||||
users, _ := s.db.ActiveUsers()
|
||||
p.D = &customerFormData{Customer: c, IsNew: true, Users: users}
|
||||
p.D = &customerFormData{Customer: c, IsNew: true}
|
||||
s.fail(w, r, "customer_form", msg, p)
|
||||
return
|
||||
}
|
||||
@@ -191,7 +186,6 @@ type customerDetailData struct {
|
||||
AdjSubColor map[int64]string
|
||||
Checkins []CheckinRow
|
||||
Packages []store.Package
|
||||
Users []store.User
|
||||
CustCal *custCal
|
||||
Timeline *Timeline
|
||||
Extend *ExtendPanel
|
||||
@@ -240,10 +234,10 @@ func (s *Server) buildCustomerCal(c *store.Customer, cm string, today time.Time)
|
||||
}
|
||||
pauses, _ := s.db.PausesForSubs(ids)
|
||||
checkins, _ := s.db.CheckinsBetween(domain.Date(gridStart), domain.Date(domain.AddDays(gridStart, weeks*7-1)))
|
||||
warn := s.warnDays()
|
||||
list := make([]calSub, 0, len(subs))
|
||||
for _, sub := range subs {
|
||||
cs := calSub{sub: sub, pauses: pauses[sub.ID], eval: sub.Eval(today, warn), checkins: checkins[sub.ID]}
|
||||
cs := calSub{sub: sub, pauses: pauses[sub.ID], checkins: checkins[sub.ID]}
|
||||
cs.start = domain.ParseDateOr(sub.StartDate, today)
|
||||
if sub.EndDate != "" {
|
||||
cs.hasEnd = true
|
||||
cs.end = domain.ParseDateOr(sub.EndDate, today)
|
||||
@@ -322,7 +316,6 @@ func (s *Server) handleCustomerDetail(w http.ResponseWriter, r *http.Request) {
|
||||
}
|
||||
pauses, _ := s.db.PausesForSubs(ids)
|
||||
|
||||
users, _ := s.db.ActiveUsers()
|
||||
// 已开通的套餐不再出现在「开通订阅」下拉里,延期走追加
|
||||
owned := map[int64]bool{}
|
||||
for _, sub := range subs {
|
||||
@@ -344,7 +337,6 @@ func (s *Server) handleCustomerDetail(w http.ResponseWriter, r *http.Request) {
|
||||
return sorted[i].ID < sorted[j].ID
|
||||
})
|
||||
data := &customerDetailData{
|
||||
Users: users,
|
||||
CustCal: s.buildCustomerCal(c, r.URL.Query().Get("cm"), today),
|
||||
Customer: c,
|
||||
Subs: subViews(sorted, today, warn),
|
||||
@@ -384,7 +376,7 @@ func (s *Server) handleCustomerDetail(w http.ResponseWriter, r *http.Request) {
|
||||
s.render(w, r, "customer_detail", p)
|
||||
}
|
||||
|
||||
// handleCustomerArchive 停用客户:默认从列表、日历、大屏隐藏,订阅保留。
|
||||
// handleCustomerArchive 停用客户:默认从列表与日历隐藏,订阅保留。
|
||||
func (s *Server) handleCustomerArchive(w http.ResponseWriter, r *http.Request) {
|
||||
id := pathID(r)
|
||||
c, err := s.db.Customer(id)
|
||||
@@ -436,31 +428,7 @@ func (s *Server) handleCustomerDelete(w http.ResponseWriter, r *http.Request) {
|
||||
s.redirect(w, r, "/customers", "已彻底删除客户 "+c.Tail+" "+c.Name)
|
||||
}
|
||||
|
||||
// handleCustomerAssignee 从客户详情快速指派/取消打手。
|
||||
func (s *Server) handleCustomerAssignee(w http.ResponseWriter, r *http.Request) {
|
||||
id := pathID(r)
|
||||
userID := int64(s.formInt(r, "assignee_id", 0))
|
||||
if err := s.db.SetCustomerAssignee(id, userID); err != nil {
|
||||
s.redirect(w, r, "/customers/"+itoa(id), "指派失败:"+err.Error())
|
||||
return
|
||||
}
|
||||
c, _ := s.db.Customer(id)
|
||||
word := "已取消指派"
|
||||
if userID > 0 {
|
||||
if u, err := s.db.UserByID(userID); err == nil {
|
||||
name := u.DisplayName
|
||||
if name == "" {
|
||||
name = u.Username
|
||||
}
|
||||
word = "已指派给 " + name
|
||||
}
|
||||
}
|
||||
if c != nil {
|
||||
s.logOp(r, "指派打手", "customer", id, c.Tail+" "+c.Name+" "+word)
|
||||
}
|
||||
s.redirect(w, r, "/customers/"+itoa(id), word)
|
||||
}
|
||||
|
||||
// handleSubCreate 给客户开通一个按日套餐。
|
||||
func (s *Server) handleSubCreate(w http.ResponseWriter, r *http.Request) {
|
||||
customerID := pathID(r)
|
||||
c, err := s.db.Customer(customerID)
|
||||
@@ -474,7 +442,6 @@ func (s *Server) handleSubCreate(w http.ResponseWriter, r *http.Request) {
|
||||
StartDate: r.PostFormValue("start_date"),
|
||||
EndDate: r.PostFormValue("end_date"),
|
||||
Days: s.formInt(r, "days", 0),
|
||||
TotalCount: s.formInt(r, "total_count", 0),
|
||||
Note: strings.TrimSpace(r.PostFormValue("note")),
|
||||
}
|
||||
u := s.currentUser(r)
|
||||
@@ -487,27 +454,10 @@ func (s *Server) handleSubCreate(w http.ResponseWriter, r *http.Request) {
|
||||
return
|
||||
}
|
||||
s.logOp(r, "新建订阅", "subscription", sub.ID,
|
||||
"为 "+c.Tail+" "+c.Name+" 开通 "+sub.PackageName+"("+subTypeLabel(sub)+")")
|
||||
"为 "+c.Tail+" "+c.Name+" 开通 "+sub.PackageName+"(按日)")
|
||||
s.redirect(w, r, "/customers/"+itoa(customerID), "已开通「"+sub.PackageName+"」")
|
||||
}
|
||||
|
||||
func unitLabel(u string) string {
|
||||
if u == domain.UnitCount {
|
||||
return "按次"
|
||||
}
|
||||
return "按日"
|
||||
}
|
||||
|
||||
func subTypeLabel(sub *store.Subscription) string {
|
||||
switch {
|
||||
case sub.Abyss:
|
||||
return "深渊"
|
||||
case sub.Season:
|
||||
return "通行证"
|
||||
}
|
||||
return unitLabel(sub.Unit)
|
||||
}
|
||||
|
||||
func itoa(v int64) string { return strconv.FormatInt(v, 10) }
|
||||
|
||||
func sortAdjustments(list []store.Adjustment) {
|
||||
|
||||
@@ -2,7 +2,6 @@ package web
|
||||
|
||||
import (
|
||||
"encoding/csv"
|
||||
"errors"
|
||||
"fmt"
|
||||
"net"
|
||||
"net/http"
|
||||
@@ -47,16 +46,12 @@ func (s *Server) handleLogs(w http.ResponseWriter, r *http.Request) {
|
||||
|
||||
type settingsData struct {
|
||||
WarnDays int
|
||||
ScreenRefresh int
|
||||
Users []store.User
|
||||
Backups []string
|
||||
DBPath string
|
||||
BackupDir string
|
||||
BackupKeep int
|
||||
BackupEnabled bool
|
||||
ConfigPath string
|
||||
ScreenPublic bool
|
||||
PortalPublic bool
|
||||
Addrs []string
|
||||
Port string
|
||||
Uptime string
|
||||
@@ -121,7 +116,6 @@ func LocalAddrs() []string {
|
||||
}
|
||||
|
||||
func (s *Server) handleSettings(w http.ResponseWriter, r *http.Request) {
|
||||
users, _ := s.db.ListUsers()
|
||||
backups, _ := s.db.ListBackups()
|
||||
custN, _ := s.db.CustomerCount()
|
||||
pkgs, _ := s.db.ListPackages(true)
|
||||
@@ -132,16 +126,12 @@ func (s *Server) handleSettings(w http.ResponseWriter, r *http.Request) {
|
||||
}
|
||||
data := &settingsData{
|
||||
WarnDays: s.warnDays(),
|
||||
ScreenRefresh: s.screenRefresh(),
|
||||
Users: users,
|
||||
Backups: backups,
|
||||
DBPath: s.db.Path,
|
||||
BackupDir: s.cfg.BackupDir,
|
||||
BackupKeep: s.cfg.BackupKeep,
|
||||
BackupEnabled: s.cfg.BackupEnabled,
|
||||
ConfigPath: s.cfg.ConfigPath,
|
||||
ScreenPublic: s.cfg.ScreenPublic,
|
||||
PortalPublic: s.cfg.PortalPublic,
|
||||
Addrs: LocalAddrs(),
|
||||
Port: port,
|
||||
Uptime: humanDuration(time.Since(s.started)),
|
||||
@@ -155,118 +145,6 @@ func (s *Server) handleSettings(w http.ResponseWriter, r *http.Request) {
|
||||
s.render(w, r, "settings", p)
|
||||
}
|
||||
|
||||
type userFormData struct {
|
||||
Target *store.User
|
||||
}
|
||||
|
||||
// isSuperAdmin 只有一个超级管理员(id=1)可以修改他人资料。
|
||||
func isSuperAdmin(u *store.User) bool { return u != nil && u.ID == 1 }
|
||||
|
||||
// handleUserEditPage 超管编辑其他管理员。
|
||||
func (s *Server) handleUserEditPage(w http.ResponseWriter, r *http.Request) {
|
||||
me := s.currentUser(r)
|
||||
if !isSuperAdmin(me) {
|
||||
s.redirect(w, r, "/settings", "只有初始管理员可以修改其他人的资料")
|
||||
return
|
||||
}
|
||||
id := pathID(r)
|
||||
if id == me.ID {
|
||||
s.redirect(w, r, "/settings", "自己的资料请用「修改我的密码」")
|
||||
return
|
||||
}
|
||||
u, err := s.db.UserByID(id)
|
||||
if err != nil {
|
||||
s.redirect(w, r, "/settings", "账户不存在")
|
||||
return
|
||||
}
|
||||
p := s.newPage(r, "编辑管理员", "settings")
|
||||
p.D = &userFormData{Target: u}
|
||||
s.render(w, r, "user_form", p)
|
||||
}
|
||||
|
||||
// handleUserEditSave 保存超管对其他管理员的修改。
|
||||
func (s *Server) handleUserEditSave(w http.ResponseWriter, r *http.Request) {
|
||||
me := s.currentUser(r)
|
||||
if !isSuperAdmin(me) {
|
||||
s.redirect(w, r, "/settings", "只有初始管理员可以修改其他人的资料")
|
||||
return
|
||||
}
|
||||
id := pathID(r)
|
||||
if id == me.ID {
|
||||
s.redirect(w, r, "/settings", "自己的资料请用「修改我的密码」")
|
||||
return
|
||||
}
|
||||
u, err := s.db.UserByID(id)
|
||||
if err != nil {
|
||||
s.redirect(w, r, "/settings", "账户不存在")
|
||||
return
|
||||
}
|
||||
username := strings.TrimSpace(r.PostFormValue("username"))
|
||||
displayName := strings.TrimSpace(r.PostFormValue("display_name"))
|
||||
password := r.PostFormValue("password")
|
||||
password2 := r.PostFormValue("password2")
|
||||
|
||||
back := "/settings/users/" + itoa(id) + "/edit"
|
||||
if l := len([]rune(username)); l < 3 || l > 32 {
|
||||
s.redirect(w, r, back, "用户名长度需在 3-32 个字符之间")
|
||||
return
|
||||
}
|
||||
if len([]rune(displayName)) > 32 {
|
||||
s.redirect(w, r, back, "显示名称不能超过 32 个字符")
|
||||
return
|
||||
}
|
||||
if password != "" {
|
||||
if len([]rune(password)) < 6 {
|
||||
s.redirect(w, r, back, "新密码至少 6 位")
|
||||
return
|
||||
}
|
||||
if password != password2 {
|
||||
s.redirect(w, r, back, "两次输入的新密码不一致")
|
||||
return
|
||||
}
|
||||
}
|
||||
if err := s.db.UpdateUserByAdmin(id, username, displayName, password); err != nil {
|
||||
msg := "保存失败:" + err.Error()
|
||||
if errors.Is(err, store.ErrDuplicate) {
|
||||
msg = "用户名已被占用"
|
||||
}
|
||||
s.redirect(w, r, back, msg)
|
||||
return
|
||||
}
|
||||
detail := u.Username + " → " + username
|
||||
if displayName != u.DisplayName {
|
||||
detail += ";昵称 " + u.DisplayName + " → " + displayName
|
||||
}
|
||||
if password != "" {
|
||||
detail += ";已重置密码并强制下线"
|
||||
}
|
||||
s.logOp(r, "修改管理员资料", "user", id, detail)
|
||||
s.redirect(w, r, "/settings", "已更新「"+username+"」的资料")
|
||||
}
|
||||
|
||||
// handleUserColor 设置管理员(打手)颜色。
|
||||
func (s *Server) handleUserColor(w http.ResponseWriter, r *http.Request) {
|
||||
id := pathID(r)
|
||||
color, err := store.NormalizeColor(r.PostFormValue("color"))
|
||||
if err != nil {
|
||||
s.redirect(w, r, "/settings", "颜色格式不正确")
|
||||
return
|
||||
}
|
||||
if err := s.db.SetUserColor(id, color); err != nil {
|
||||
s.redirect(w, r, "/settings", "保存颜色失败:"+err.Error())
|
||||
return
|
||||
}
|
||||
name := ""
|
||||
if u, err := s.db.UserByID(id); err == nil {
|
||||
name = u.DisplayName
|
||||
if name == "" {
|
||||
name = u.Username
|
||||
}
|
||||
}
|
||||
s.logOp(r, "设置打手颜色", "user", id, name+" → "+color)
|
||||
s.redirect(w, r, "/settings", "已更新 "+name+" 的颜色")
|
||||
}
|
||||
|
||||
func (s *Server) handleSettingsSave(w http.ResponseWriter, r *http.Request) {
|
||||
warn := s.formInt(r, "warn_days", 3)
|
||||
if warn < 0 {
|
||||
@@ -275,18 +153,8 @@ func (s *Server) handleSettingsSave(w http.ResponseWriter, r *http.Request) {
|
||||
if warn > 60 {
|
||||
warn = 60
|
||||
}
|
||||
|
||||
refresh := s.formInt(r, "screen_refresh", 30)
|
||||
if refresh < 5 {
|
||||
refresh = 5
|
||||
}
|
||||
if refresh > 600 {
|
||||
refresh = 600
|
||||
}
|
||||
_ = s.db.SetSetting("warn_days", strconv.Itoa(warn))
|
||||
_ = s.db.SetSetting("screen_refresh", strconv.Itoa(refresh))
|
||||
s.logOp(r, "修改设置", "settings", 0,
|
||||
fmt.Sprintf("预警 %d 天、大屏刷新 %d 秒", warn, refresh))
|
||||
s.logOp(r, "修改设置", "settings", 0, fmt.Sprintf("预警 %d 天", warn))
|
||||
s.redirect(w, r, "/settings", "设置已保存")
|
||||
}
|
||||
|
||||
@@ -319,58 +187,6 @@ func (s *Server) handlePasswordChange(w http.ResponseWriter, r *http.Request) {
|
||||
s.redirect(w, r, "/settings", "密码已更新")
|
||||
}
|
||||
|
||||
func (s *Server) handleUserCreate(w http.ResponseWriter, r *http.Request) {
|
||||
username := strings.TrimSpace(r.PostFormValue("username"))
|
||||
display := strings.TrimSpace(r.PostFormValue("display_name"))
|
||||
pw := r.PostFormValue("password")
|
||||
switch {
|
||||
case len(username) < 3:
|
||||
s.redirect(w, r, "/settings", "用户名至少 3 个字符")
|
||||
return
|
||||
case len(pw) < 6:
|
||||
s.redirect(w, r, "/settings", "密码至少 6 位")
|
||||
return
|
||||
}
|
||||
if display == "" {
|
||||
display = username
|
||||
}
|
||||
u, err := s.db.CreateUser(username, display, pw)
|
||||
if err != nil {
|
||||
if err == store.ErrDuplicate {
|
||||
s.redirect(w, r, "/settings", "用户名已存在")
|
||||
return
|
||||
}
|
||||
s.redirect(w, r, "/settings", "创建失败:"+err.Error())
|
||||
return
|
||||
}
|
||||
s.logOp(r, "新增管理员", "user", u.ID, "新增管理员 "+username)
|
||||
s.redirect(w, r, "/settings", "管理员 "+username+" 已创建")
|
||||
}
|
||||
|
||||
func (s *Server) handleUserToggle(w http.ResponseWriter, r *http.Request) {
|
||||
id := pathID(r)
|
||||
me := s.currentUser(r)
|
||||
if me != nil && me.ID == id {
|
||||
s.redirect(w, r, "/settings", "不能停用自己的账户")
|
||||
return
|
||||
}
|
||||
target, err := s.db.UserByID(id)
|
||||
if err != nil {
|
||||
http.NotFound(w, r)
|
||||
return
|
||||
}
|
||||
if err := s.db.SetUserActive(id, !target.IsActive); err != nil {
|
||||
s.redirect(w, r, "/settings", "操作失败:"+err.Error())
|
||||
return
|
||||
}
|
||||
action := "停用账户"
|
||||
if !target.IsActive {
|
||||
action = "启用账户"
|
||||
}
|
||||
s.logOp(r, action, "user", id, action+" "+target.Username)
|
||||
s.redirect(w, r, "/settings", action+"成功")
|
||||
}
|
||||
|
||||
func (s *Server) handleBackupNow(w http.ResponseWriter, r *http.Request) {
|
||||
path, err := s.db.BackupNow(s.cfg.BackupKeep)
|
||||
if err != nil {
|
||||
|
||||
@@ -35,7 +35,7 @@ func (s *Server) handlePackageNewPage(w http.ResponseWriter, r *http.Request) {
|
||||
p := s.newPage(r, "新增套餐", "packages")
|
||||
tags, _ := s.db.PackageTags()
|
||||
p.D = &packageFormData{
|
||||
Package: &store.Package{Unit: domain.UnitDay, DefaultAmount: 30, Color: "#3B6EA5"},
|
||||
Package: &store.Package{DefaultAmount: 30, Color: "#3B6EA5"},
|
||||
IsNew: true,
|
||||
Tags: tags,
|
||||
}
|
||||
@@ -45,7 +45,6 @@ func (s *Server) handlePackageNewPage(w http.ResponseWriter, r *http.Request) {
|
||||
func readPackageForm(r *http.Request) *store.Package {
|
||||
p := &store.Package{
|
||||
Name: strings.TrimSpace(r.PostFormValue("name")),
|
||||
Unit: strings.TrimSpace(r.PostFormValue("unit")),
|
||||
DefaultAmount: 0,
|
||||
Color: strings.TrimSpace(r.PostFormValue("color")),
|
||||
Note: strings.TrimSpace(r.PostFormValue("note")),
|
||||
@@ -63,61 +62,20 @@ func readPackageForm(r *http.Request) *store.Package {
|
||||
p.HasPrice = true
|
||||
}
|
||||
}
|
||||
if p.Unit == "" {
|
||||
p.Unit = domain.UnitDay
|
||||
}
|
||||
p.CalendarSeparate = r.PostFormValue("calendar_separate") != ""
|
||||
p.Tag = strings.TrimSpace(r.PostFormValue("tag"))
|
||||
switch p.Unit {
|
||||
case "season":
|
||||
p.Season = true
|
||||
p.Unit = domain.UnitDay
|
||||
case "abyss":
|
||||
p.Abyss = true
|
||||
p.Unit = domain.UnitDay
|
||||
}
|
||||
if v, err := strconv.Atoi(strings.TrimSpace(r.PostFormValue("cycle_days"))); err == nil {
|
||||
p.CycleDays = v
|
||||
}
|
||||
if v, err := strconv.Atoi(strings.TrimSpace(r.PostFormValue("default_validity_days"))); err == nil {
|
||||
p.DefaultValidityDays = v
|
||||
}
|
||||
p.SeasonStart = strings.TrimSpace(r.PostFormValue("season_start"))
|
||||
p.SeasonEnd = strings.TrimSpace(r.PostFormValue("season_end"))
|
||||
if p.Season && p.DefaultAmount <= 0 {
|
||||
p.DefaultAmount = 1
|
||||
}
|
||||
return p
|
||||
}
|
||||
|
||||
func validatePackage(p *store.Package) string {
|
||||
if p.Season {
|
||||
if p.SeasonStart == "" || p.SeasonEnd == "" {
|
||||
return "通行证套餐必须填写开始日和结束日"
|
||||
}
|
||||
if p.SeasonEnd < p.SeasonStart {
|
||||
return "通行证结束日不能早于开始日"
|
||||
}
|
||||
}
|
||||
if p.Abyss {
|
||||
if p.CycleDays < 1 || p.CycleDays > 365 {
|
||||
return "深渊模式的周期天数必须在 1-365 之间"
|
||||
}
|
||||
if p.DefaultAmount < 1 || p.DefaultAmount > 1000 {
|
||||
return "深渊模式的周期数必须在 1-1000 之间"
|
||||
}
|
||||
}
|
||||
if p.Name == "" {
|
||||
return "套餐名称不能为空"
|
||||
}
|
||||
if len([]rune(p.Name)) > 32 {
|
||||
return "套餐名称最长 32 字"
|
||||
}
|
||||
if p.Unit != domain.UnitDay && p.Unit != domain.UnitCount {
|
||||
return "套餐类型不正确"
|
||||
}
|
||||
if p.DefaultAmount <= 0 {
|
||||
return "默认天数/次数必须大于 0"
|
||||
return "默认天数必须大于 0"
|
||||
}
|
||||
if p.Color == "" || !strings.HasPrefix(p.Color, "#") {
|
||||
return "请选择套餐颜色"
|
||||
@@ -178,7 +136,7 @@ func (s *Server) handlePackageBatchSubscribe(w http.ResponseWriter, r *http.Requ
|
||||
return
|
||||
}
|
||||
start := strings.TrimSpace(r.PostFormValue("start_date"))
|
||||
if start == "" && !pkg.Season {
|
||||
if start == "" {
|
||||
start = domain.Date(domain.Today())
|
||||
}
|
||||
if start != "" {
|
||||
@@ -189,7 +147,6 @@ func (s *Server) handlePackageBatchSubscribe(w http.ResponseWriter, r *http.Requ
|
||||
}
|
||||
end := strings.TrimSpace(r.PostFormValue("end_date"))
|
||||
days := s.formInt(r, "days", 0)
|
||||
count := s.formInt(r, "total_count", 0)
|
||||
u := s.currentUser(r)
|
||||
var op int64
|
||||
if u != nil {
|
||||
@@ -206,7 +163,7 @@ func (s *Server) handlePackageBatchSubscribe(w http.ResponseWriter, r *http.Requ
|
||||
}
|
||||
_, err = s.db.CreateSub(store.CreateSubInput{
|
||||
CustomerID: cid, PackageID: id, StartDate: start, EndDate: end,
|
||||
Days: days, TotalCount: count, OperatorID: op,
|
||||
Days: days, OperatorID: op,
|
||||
})
|
||||
if err != nil {
|
||||
if strings.Contains(err.Error(), "已订阅") {
|
||||
|
||||
@@ -1,390 +0,0 @@
|
||||
package web
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"net"
|
||||
"net/http"
|
||||
"net/url"
|
||||
"regexp"
|
||||
"strings"
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
"daili/internal/domain"
|
||||
"daili/internal/store"
|
||||
)
|
||||
|
||||
// portalDay 客户自助月历中的一天:日常任务按 done/total 计,通行证/深渊按整段色块展示。
|
||||
type portalDay struct {
|
||||
Date string
|
||||
Day int
|
||||
InMonth bool
|
||||
Today bool
|
||||
Total int
|
||||
Done int
|
||||
// 通行证 / 深渊色块
|
||||
BlockColor string
|
||||
BlockText string
|
||||
BlockTitle string
|
||||
BlockPercent int
|
||||
// Label 是读屏用的整格描述
|
||||
Label string
|
||||
}
|
||||
|
||||
// portalSub 客户自助页里的一个订阅;复用管理端 SubView 的状态/剩余文案。
|
||||
type portalSub struct {
|
||||
SubView
|
||||
TodayLabel string
|
||||
TodayClass string
|
||||
}
|
||||
|
||||
// portalAsk 同一尾号命中多个客户时要求补姓名。
|
||||
type portalAsk struct {
|
||||
Tail string
|
||||
Count int
|
||||
Masked []string
|
||||
}
|
||||
|
||||
// portalView 客户自助查询结果。
|
||||
type portalView struct {
|
||||
Tail string
|
||||
Name string
|
||||
Game string
|
||||
Subs []portalSub
|
||||
Weeks [][]portalDay
|
||||
MonthTitle string
|
||||
Prev string
|
||||
Next string
|
||||
TodayTotal int
|
||||
TodayDone int
|
||||
TodayPending int
|
||||
TodayState string // done / pending / none
|
||||
SubCount int
|
||||
Expiring string
|
||||
Masked []string
|
||||
}
|
||||
|
||||
var portalTailRe = regexp.MustCompile(`^\d{4,8}$`)
|
||||
|
||||
const (
|
||||
portalRateLimit = 40
|
||||
portalRateWindow = time.Minute
|
||||
)
|
||||
|
||||
var portalHits = struct {
|
||||
sync.Mutex
|
||||
m map[string][]time.Time
|
||||
}{m: map[string][]time.Time{}}
|
||||
|
||||
// allowPortal 对自助查询做简单的按 IP 限流,避免尾号枚举把库打穿。
|
||||
func allowPortal(remote string) bool {
|
||||
host, _, err := net.SplitHostPort(remote)
|
||||
if err != nil || host == "" {
|
||||
host = remote
|
||||
}
|
||||
now := time.Now()
|
||||
portalHits.Lock()
|
||||
defer portalHits.Unlock()
|
||||
kept := portalHits.m[host][:0]
|
||||
for _, t := range portalHits.m[host] {
|
||||
if now.Sub(t) < portalRateWindow {
|
||||
kept = append(kept, t)
|
||||
}
|
||||
}
|
||||
if len(kept) >= portalRateLimit {
|
||||
portalHits.m[host] = kept
|
||||
return false
|
||||
}
|
||||
portalHits.m[host] = append(kept, now)
|
||||
return true
|
||||
}
|
||||
|
||||
// handleCustomerPortal 客户自助查询页(公开,无入口链接)。
|
||||
func (s *Server) handleCustomerPortal(w http.ResponseWriter, r *http.Request) {
|
||||
w.Header().Set("X-Robots-Tag", "noindex, nofollow")
|
||||
p := s.newPage(r, "排单查询", "")
|
||||
q := r.URL.Query()
|
||||
tail := strings.TrimSpace(q.Get("tail"))
|
||||
name := strings.TrimSpace(q.Get("name"))
|
||||
month := strings.TrimSpace(q.Get("cm"))
|
||||
p.Query = tail
|
||||
p.Name = name
|
||||
|
||||
if tail == "" {
|
||||
s.render(w, r, "portal", p)
|
||||
return
|
||||
}
|
||||
if !allowPortal(r.RemoteAddr) {
|
||||
p.InlineError = "查询太频繁,请稍后再试"
|
||||
s.render(w, r, "portal", p)
|
||||
return
|
||||
}
|
||||
if !portalTailRe.MatchString(tail) {
|
||||
p.InlineError = "请输入 4–8 位数字手机尾号"
|
||||
p.InvalidField = "tail"
|
||||
s.render(w, r, "portal", p)
|
||||
return
|
||||
}
|
||||
|
||||
list, err := s.db.CustomersByTailExact(tail)
|
||||
if err != nil {
|
||||
p.InlineError = "读取客户失败,请稍后再试"
|
||||
s.render(w, r, "portal", p)
|
||||
return
|
||||
}
|
||||
if len(list) == 0 {
|
||||
p.InlineError = "没有找到这个尾号的客户,请核对尾号"
|
||||
p.InvalidField = "tail"
|
||||
s.render(w, r, "portal", p)
|
||||
return
|
||||
}
|
||||
if len(list) > 1 {
|
||||
if name == "" {
|
||||
p.D = &portalAsk{Tail: tail, Count: len(list), Masked: maskNames(list)}
|
||||
s.render(w, r, "portal", p)
|
||||
return
|
||||
}
|
||||
matched := matchByName(list, name)
|
||||
if len(matched) == 0 {
|
||||
p.InlineError = "尾号对得上,但姓名不匹配,请再确认一下"
|
||||
p.InvalidField = "name"
|
||||
s.render(w, r, "portal", p)
|
||||
return
|
||||
}
|
||||
if len(matched) > 1 {
|
||||
p.D = &portalAsk{Tail: tail, Count: len(matched), Masked: maskNames(matched)}
|
||||
s.render(w, r, "portal", p)
|
||||
return
|
||||
}
|
||||
list = matched
|
||||
}
|
||||
|
||||
c := list[0]
|
||||
p.D = s.buildPortal(c, tail, name, month)
|
||||
s.render(w, r, "portal", p)
|
||||
}
|
||||
|
||||
func matchByName(list []store.Customer, name string) []store.Customer {
|
||||
needle := strings.ToLower(strings.TrimSpace(name))
|
||||
out := make([]store.Customer, 0, len(list))
|
||||
for _, c := range list {
|
||||
if strings.Contains(strings.ToLower(c.Name), needle) {
|
||||
out = append(out, c)
|
||||
}
|
||||
}
|
||||
return out
|
||||
}
|
||||
|
||||
func maskNames(list []store.Customer) []string {
|
||||
out := make([]string, 0, len(list))
|
||||
seen := map[string]bool{}
|
||||
for _, c := range list {
|
||||
m := maskName(c.Name)
|
||||
if seen[m] {
|
||||
continue
|
||||
}
|
||||
seen[m] = true
|
||||
out = append(out, m)
|
||||
}
|
||||
return out
|
||||
}
|
||||
|
||||
// maskName 只保留首字,避免多客户态直接列出全名。
|
||||
func maskName(name string) string {
|
||||
rs := []rune(strings.TrimSpace(name))
|
||||
switch len(rs) {
|
||||
case 0:
|
||||
return "*"
|
||||
case 1:
|
||||
return "*"
|
||||
}
|
||||
return string(rs[0]) + strings.Repeat("*", len(rs)-1)
|
||||
}
|
||||
|
||||
// buildPortal 组装某位客户的排单视图。
|
||||
func (s *Server) buildPortal(c store.Customer, tail, name, month string) *portalView {
|
||||
today := domain.Today()
|
||||
todayStr := domain.Date(today)
|
||||
warn := s.warnDays()
|
||||
first := time.Date(today.Year(), today.Month(), 1, 0, 0, 0, 0, time.UTC)
|
||||
if month != "" {
|
||||
if t, err := time.Parse("2006-01", month); err == nil {
|
||||
first = t
|
||||
}
|
||||
}
|
||||
year, mon := first.Year(), int(first.Month())
|
||||
firstDay := time.Date(year, time.Month(mon), 1, 0, 0, 0, 0, time.UTC)
|
||||
lastDay := firstDay.AddDate(0, 1, -1)
|
||||
start := firstDay.AddDate(0, 0, -((int(firstDay.Weekday()) + 6) % 7))
|
||||
end := lastDay.AddDate(0, 0, 6-((int(lastDay.Weekday())+6)%7))
|
||||
|
||||
allSubs, _ := s.db.SubsByCustomer(c.ID)
|
||||
subs := make([]store.Subscription, 0, len(allSubs))
|
||||
ids := make([]int64, 0, len(allSubs))
|
||||
for _, sub := range allSubs {
|
||||
if sub.Status == domain.StatusClosed {
|
||||
continue
|
||||
}
|
||||
subs = append(subs, sub)
|
||||
ids = append(ids, sub.ID)
|
||||
}
|
||||
|
||||
cks, _ := s.db.CheckinsForSubs(ids, wideFrom(domain.Date(start)), wideTo(domain.Date(end)))
|
||||
pauses, _ := s.db.PausesForSubs(ids)
|
||||
cals := make([]calSub, 0, len(subs))
|
||||
for _, sub := range subs {
|
||||
cs := calSub{
|
||||
sub: sub,
|
||||
start: domain.ParseDateOr(sub.StartDate, today),
|
||||
eval: sub.Eval(today, warn),
|
||||
pauses: pauses[sub.ID],
|
||||
checkins: cks[sub.ID],
|
||||
}
|
||||
if sub.EndDate != "" {
|
||||
cs.hasEnd = true
|
||||
cs.end = domain.ParseDateOr(sub.EndDate, today)
|
||||
}
|
||||
cals = append(cals, cs)
|
||||
}
|
||||
|
||||
v := &portalView{
|
||||
Tail: c.Tail,
|
||||
Name: c.Name,
|
||||
Game: c.GameName,
|
||||
SubCount: len(subs),
|
||||
}
|
||||
v.MonthTitle = fmt.Sprintf("%d 年 %d 月", year, mon)
|
||||
v.Prev = portalQuery(tail, name, firstDay.AddDate(0, -1, 0).Format("2006-01"))
|
||||
v.Next = portalQuery(tail, name, firstDay.AddDate(0, 1, 0).Format("2006-01"))
|
||||
|
||||
for _, cs := range cals {
|
||||
sub := cs.sub
|
||||
ev := newSubView(sub, today, warn)
|
||||
ps := portalSub{SubView: ev}
|
||||
if ev.StateClass == "active" && !sub.Season && !sub.Abyss && cs.covers(todayStr) {
|
||||
if ci, ok := cks[sub.ID][todayStr]; ok && portalDone(ci) {
|
||||
ps.TodayLabel, ps.TodayClass = "今日已完成", "active"
|
||||
} else {
|
||||
ps.TodayLabel, ps.TodayClass = "今日未完成", "plain"
|
||||
}
|
||||
}
|
||||
v.Subs = append(v.Subs, ps)
|
||||
|
||||
if sub.EndDate != "" && sub.EndDate >= todayStr {
|
||||
switch ev.Eval.State {
|
||||
case domain.StateExpired, domain.StateUsedUp, domain.StateClosed:
|
||||
default:
|
||||
if v.Expiring == "" || sub.EndDate < v.Expiring {
|
||||
v.Expiring = sub.EndDate
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 月历
|
||||
days := int(end.Sub(start).Hours()/24) + 1
|
||||
week := make([]portalDay, 0, 7)
|
||||
for i := 0; i < days; i++ {
|
||||
d := start.AddDate(0, 0, i)
|
||||
ds := domain.Date(d)
|
||||
pd := portalDay{Date: ds, Day: d.Day(), InMonth: d.Month() == time.Month(mon), Today: ds == todayStr}
|
||||
// 与主日历一致:只在本月格子里显示任务,前后月只做日期占位。
|
||||
if pd.InMonth {
|
||||
for _, cs := range cals {
|
||||
sub := cs.sub
|
||||
if cs.isBlock() {
|
||||
if cs.blockCovers(ds) && pd.BlockText == "" {
|
||||
pd.BlockColor = sub.PackageColor
|
||||
pd.BlockText = blockCellText(cs, ds)
|
||||
pd.BlockTitle = sub.PackageName + " · " + pd.BlockText
|
||||
pd.BlockPercent = blockCellPercent(cs, d)
|
||||
}
|
||||
continue
|
||||
}
|
||||
if !cs.covers(ds) {
|
||||
continue
|
||||
}
|
||||
pd.Total++
|
||||
if ci, ok := cks[sub.ID][ds]; ok && portalDone(ci) {
|
||||
pd.Done++
|
||||
}
|
||||
}
|
||||
}
|
||||
pd.Label = portalDayLabel(pd, mon)
|
||||
week = append(week, pd)
|
||||
if len(week) == 7 {
|
||||
v.Weeks = append(v.Weeks, week)
|
||||
week = make([]portalDay, 0, 7)
|
||||
}
|
||||
}
|
||||
if len(week) > 0 {
|
||||
v.Weeks = append(v.Weeks, week)
|
||||
}
|
||||
|
||||
// 今日进度:整段型订阅算 1 项,通行证看 season_done,深渊看当天所在周期。
|
||||
for _, cs := range cals {
|
||||
if cs.isBlock() {
|
||||
if cs.blockCovers(todayStr) {
|
||||
v.TodayTotal++
|
||||
if !cs.blockNeedsWork(todayStr) {
|
||||
v.TodayDone++
|
||||
}
|
||||
}
|
||||
continue
|
||||
}
|
||||
if !cs.covers(todayStr) {
|
||||
continue
|
||||
}
|
||||
v.TodayTotal++
|
||||
if ci, ok := cks[cs.sub.ID][todayStr]; ok && portalDone(ci) {
|
||||
v.TodayDone++
|
||||
}
|
||||
}
|
||||
v.TodayPending = v.TodayTotal - v.TodayDone
|
||||
switch {
|
||||
case v.TodayTotal == 0:
|
||||
v.TodayState = "none"
|
||||
case v.TodayPending <= 0:
|
||||
v.TodayState = "done"
|
||||
default:
|
||||
v.TodayState = "pending"
|
||||
}
|
||||
return v
|
||||
}
|
||||
|
||||
// portalDone 与管理端日历口径一致:done 和 skipped 都算当天已处理。
|
||||
func portalDone(ci store.Checkin) bool {
|
||||
return ci.Status == "done" || ci.Status == "skipped"
|
||||
}
|
||||
|
||||
func portalDayLabel(pd portalDay, month int) string {
|
||||
labelMonth := month
|
||||
if t, err := time.Parse("2006-01-02", pd.Date); err == nil {
|
||||
labelMonth = int(t.Month())
|
||||
}
|
||||
label := fmt.Sprintf("%d 月 %d 日", labelMonth, pd.Day)
|
||||
if pd.Today {
|
||||
label += ",今天"
|
||||
}
|
||||
if pd.BlockText != "" {
|
||||
label += "," + pd.BlockTitle
|
||||
}
|
||||
if pd.Total > 0 {
|
||||
label += fmt.Sprintf(",共 %d 单,已完成 %d 单", pd.Total, pd.Done)
|
||||
}
|
||||
if pd.BlockText == "" && pd.Total == 0 {
|
||||
label += ",无排单"
|
||||
}
|
||||
return label
|
||||
}
|
||||
|
||||
// portalQuery 用 url.Values 拼翻月链接,姓名含 & / 空格时也不会丢参数。
|
||||
func portalQuery(tail, name, month string) string {
|
||||
q := url.Values{}
|
||||
q.Set("tail", tail)
|
||||
if name != "" {
|
||||
q.Set("name", name)
|
||||
}
|
||||
q.Set("cm", month)
|
||||
return "/customer?" + q.Encode()
|
||||
}
|
||||
@@ -1,326 +0,0 @@
|
||||
package web
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"net/http"
|
||||
"net/url"
|
||||
"strings"
|
||||
|
||||
"daili/internal/domain"
|
||||
"daili/internal/store"
|
||||
)
|
||||
|
||||
type screenDay struct {
|
||||
Date string
|
||||
Day int
|
||||
InMonth bool
|
||||
IsToday bool
|
||||
IsPast bool
|
||||
Count int
|
||||
Done int
|
||||
Urgent int
|
||||
Heat int
|
||||
// 通行证 / 深渊整段色块:BlockText 是该周期的 1/1 或 0/1
|
||||
BlockColor string
|
||||
BlockText string
|
||||
BlockTitle string
|
||||
BlockPercent int
|
||||
// Strip 打手色竖条(去重)
|
||||
Strip []string
|
||||
}
|
||||
|
||||
type screenTask struct {
|
||||
TaskRow
|
||||
}
|
||||
|
||||
type screenData struct {
|
||||
Stats *store.Stats
|
||||
MonthTitle string
|
||||
Year, Month int
|
||||
Weeks [][]screenDay
|
||||
Weekdays []string
|
||||
Top []SubView
|
||||
DueToday []SubView
|
||||
TodayList []screenTask
|
||||
Recent []store.Adjustment
|
||||
TodayTasks int
|
||||
TodayDone int
|
||||
TodayUrgent int
|
||||
Refresh int
|
||||
Version string
|
||||
AssetVersion 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, 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
|
||||
}
|
||||
today := domain.Today()
|
||||
warn := s.warnDays()
|
||||
list := make([]calSub, 0, len(subs))
|
||||
for _, sub := range subs {
|
||||
cs := calSub{
|
||||
sub: sub,
|
||||
start: domain.ParseDateOr(sub.StartDate, today),
|
||||
pauses: pauses[sub.ID],
|
||||
checkins: checkins[sub.ID],
|
||||
eval: sub.Eval(today, warn),
|
||||
}
|
||||
if sub.EndDate != "" {
|
||||
cs.hasEnd = true
|
||||
cs.end = domain.ParseDateOr(sub.EndDate, today)
|
||||
}
|
||||
list = append(list, cs)
|
||||
}
|
||||
return list, checkins, urgent, nil
|
||||
}
|
||||
|
||||
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"
|
||||
}
|
||||
|
||||
stats, err := s.db.ScreenStats(today, warn)
|
||||
if err != nil {
|
||||
http.Error(w, "读取大屏数据失败", http.StatusInternalServerError)
|
||||
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,
|
||||
AssetVersion: s.assetVersion,
|
||||
HeatMode: heatMode,
|
||||
PkgID: pkgID,
|
||||
Tag: tag,
|
||||
FilterQuery: "pkg=" + itoa(pkgID),
|
||||
}
|
||||
|
||||
// 今日到期(可按套餐过滤)
|
||||
dueToday := []store.Subscription{}
|
||||
for _, sub := range stats.DueTodaySubs {
|
||||
if pkgID > 0 && sub.PackageID != pkgID {
|
||||
continue
|
||||
}
|
||||
dueToday = append(dueToday, sub)
|
||||
}
|
||||
data.DueToday = subViews(dueToday, today, warn)
|
||||
|
||||
// 本月热力:默认统计“每日待完成的单子”,可切换到“到期”
|
||||
monthStart := domain.MonthStart(today.Year(), today.Month())
|
||||
monthEnd := domain.MonthEnd(today.Year(), today.Month())
|
||||
gridStart := domain.AddDays(monthStart, -domain.WeekdayIndex(monthStart))
|
||||
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, tag)
|
||||
if err != nil {
|
||||
http.Error(w, "读取大屏日历失败", http.StatusInternalServerError)
|
||||
return
|
||||
}
|
||||
|
||||
for wi := 0; wi < weeks; wi++ {
|
||||
week := make([]screenDay, 0, 7)
|
||||
for di := 0; di < 7; di++ {
|
||||
d := domain.AddDays(gridStart, wi*7+di)
|
||||
ds := domain.Date(d)
|
||||
count, doneN, urgentN := 0, 0, 0
|
||||
strip := []string{}
|
||||
seenColor := map[string]bool{}
|
||||
sd := screenDay{
|
||||
Date: ds,
|
||||
Day: d.Day(),
|
||||
InMonth: d.Month() == today.Month(),
|
||||
IsToday: ds == domain.Date(today),
|
||||
IsPast: d.Before(today),
|
||||
}
|
||||
for _, cs := range list {
|
||||
if heatMode == "due" {
|
||||
if cs.sub.EndDate == ds {
|
||||
count++
|
||||
}
|
||||
}
|
||||
// 通行证 / 深渊是整段型:不计入每日待完成热力,但用整段色块显示周期状态。
|
||||
if cs.isBlock() {
|
||||
if cs.blockCovers(ds) && sd.BlockText == "" {
|
||||
sd.BlockColor = cs.sub.PackageColor
|
||||
sd.BlockText = blockCellText(cs, ds)
|
||||
sd.BlockTitle = cs.sub.PackageName + " · " + sd.BlockText
|
||||
sd.BlockPercent = blockCellPercent(cs, d)
|
||||
}
|
||||
continue
|
||||
}
|
||||
if heatMode == "due" {
|
||||
continue
|
||||
}
|
||||
if !cs.covers(ds) {
|
||||
continue
|
||||
}
|
||||
ci, has := checkins[cs.sub.ID][ds]
|
||||
if has && (ci.Status == "done" || ci.Status == "skipped") {
|
||||
doneN++
|
||||
continue // “待完成”热力只统计还没处理的
|
||||
}
|
||||
count++
|
||||
if urgent[cs.sub.ID][ds] {
|
||||
urgentN++
|
||||
}
|
||||
color := cs.sub.AssigneeColor
|
||||
if color == "" {
|
||||
color = "#8A8F98"
|
||||
}
|
||||
if !seenColor[color] {
|
||||
seenColor[color] = true
|
||||
strip = append(strip, color)
|
||||
}
|
||||
}
|
||||
if d.Month() == today.Month() {
|
||||
data.HeatTotal += count
|
||||
}
|
||||
sd.Count = count + doneN
|
||||
sd.Done = doneN
|
||||
sd.Urgent = urgentN
|
||||
sd.Heat = heatLevel(count)
|
||||
sd.Strip = strip
|
||||
week = append(week, sd)
|
||||
}
|
||||
data.Weeks = append(data.Weeks, week)
|
||||
}
|
||||
|
||||
// 今日待打(加急置顶)
|
||||
rows, err := s.pendingTasks(domain.Date(today), nil, pkgID, tag)
|
||||
if err == nil {
|
||||
for _, row := range rows {
|
||||
if row.Done || row.Skipped {
|
||||
continue
|
||||
}
|
||||
data.TodayList = append(data.TodayList, screenTask{TaskRow: row})
|
||||
if row.Urgent {
|
||||
data.TodayUrgent++
|
||||
}
|
||||
}
|
||||
}
|
||||
data.TodayTasks = len(data.TodayList)
|
||||
for _, row := range rows {
|
||||
if row.Done {
|
||||
data.TodayDone++
|
||||
}
|
||||
}
|
||||
|
||||
// 最近追加(底部细条)
|
||||
if adj, err := s.db.RecentAdjustments(6); err == nil {
|
||||
data.Recent = adj
|
||||
}
|
||||
|
||||
// 页签:按标签合并 + 独立显示另开;通行证 / 深渊也放进大屏,用整段色块显示周期状态
|
||||
pkgs, _ := s.db.ListPackages(true)
|
||||
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
|
||||
p.D = data
|
||||
s.render(w, r, "screen", p)
|
||||
}
|
||||
|
||||
// handleScreenDay 返回某天的待办明细,供大屏悬停浮层使用。
|
||||
func (s *Server) handleScreenDay(w http.ResponseWriter, r *http.Request) {
|
||||
date := r.URL.Query().Get("date")
|
||||
if _, err := domain.ParseDate(date); err != nil {
|
||||
http.Error(w, "日期不正确", http.StatusBadRequest)
|
||||
return
|
||||
}
|
||||
pkgID := int64(s.queryInt(r, "pkg", 0))
|
||||
rows, err := s.pendingTasks(date, nil, pkgID, strings.TrimSpace(r.URL.Query().Get("tag")))
|
||||
if err != nil {
|
||||
http.Error(w, "读取失败", http.StatusInternalServerError)
|
||||
return
|
||||
}
|
||||
type item struct {
|
||||
Tail string `json:"tail"`
|
||||
Name string `json:"name"`
|
||||
Pkg string `json:"pkg"`
|
||||
Color string `json:"color"`
|
||||
Remain string `json:"remain"`
|
||||
Urgent bool `json:"urgent"`
|
||||
Done bool `json:"done"`
|
||||
Who string `json:"who"`
|
||||
WhoCol string `json:"who_color"`
|
||||
}
|
||||
out := struct {
|
||||
Date string `json:"date"`
|
||||
Total int `json:"total"`
|
||||
Done int `json:"done"`
|
||||
Urgent int `json:"urgent"`
|
||||
More int `json:"more"`
|
||||
Items []item `json:"items"`
|
||||
}{Date: date}
|
||||
|
||||
const limit = 60
|
||||
for _, row := range rows {
|
||||
out.Total++
|
||||
if row.Done || row.Skipped {
|
||||
out.Done++
|
||||
}
|
||||
if row.Urgent {
|
||||
out.Urgent++
|
||||
}
|
||||
if len(out.Items) >= limit {
|
||||
out.More++
|
||||
continue
|
||||
}
|
||||
out.Items = append(out.Items, item{
|
||||
Tail: row.CustomerTail,
|
||||
Name: row.CustomerName,
|
||||
Pkg: row.PackageName,
|
||||
Color: row.PackageColor,
|
||||
Remain: row.RemainText,
|
||||
Urgent: row.Urgent,
|
||||
Done: row.Done || row.Skipped,
|
||||
Who: row.AssigneeLabel(),
|
||||
WhoCol: row.AssigneeHex(),
|
||||
})
|
||||
}
|
||||
w.Header().Set("Content-Type", "application/json; charset=utf-8")
|
||||
w.Header().Set("Cache-Control", "no-store")
|
||||
_ = json.NewEncoder(w).Encode(out)
|
||||
}
|
||||
@@ -72,36 +72,15 @@ func (s *Server) handleSubExtend(w http.ResponseWriter, r *http.Request) {
|
||||
note := strings.TrimSpace(r.PostFormValue("note"))
|
||||
back := backURL(r, "/customers/"+itoa(sub.CustomerID))
|
||||
|
||||
if sub.Season {
|
||||
s.redirect(w, r, back, "通行证不支持追加时长,请修改套餐或新建订阅")
|
||||
return
|
||||
}
|
||||
if sub.Abyss {
|
||||
s.redirect(w, r, back, "深渊模式按周期计数,不支持追加时长")
|
||||
return
|
||||
}
|
||||
|
||||
if sub.Unit == domain.UnitDay {
|
||||
newEnd := strings.TrimSpace(r.PostFormValue("new_end_date"))
|
||||
plan, err := s.db.ExtendDays(id, newEnd, note, opID)
|
||||
if err != nil {
|
||||
s.redirect(w, r, back+"#extend", "追加失败:"+err.Error())
|
||||
return
|
||||
}
|
||||
s.logOp(r, "追加时长", "subscription", id, fmt.Sprintf("%s 追加 %d 天:%s → %s(起点 %s)",
|
||||
sub.SubTitle(), plan.Days, sub.EndDate, domain.Date(plan.NewEnd), domain.Date(plan.Base)))
|
||||
s.redirect(w, r, back, fmt.Sprintf("已追加 %d 天,新结束日 %s", plan.Days, domain.Date(plan.NewEnd)))
|
||||
return
|
||||
}
|
||||
|
||||
add := s.formInt(r, "add_count", 0)
|
||||
optEnd := strings.TrimSpace(r.PostFormValue("new_end_opt"))
|
||||
if err := s.db.AddCount(id, add, optEnd, note, opID); err != nil {
|
||||
newEnd := strings.TrimSpace(r.PostFormValue("new_end_date"))
|
||||
plan, err := s.db.ExtendDays(id, newEnd, note, opID)
|
||||
if err != nil {
|
||||
s.redirect(w, r, back+"#extend", "追加失败:"+err.Error())
|
||||
return
|
||||
}
|
||||
s.logOp(r, "追加次数", "subscription", id, fmt.Sprintf("%s 追加 %d 次", sub.SubTitle(), add))
|
||||
s.redirect(w, r, back, fmt.Sprintf("已追加 %d 次", add))
|
||||
s.logOp(r, "追加时长", "subscription", id, fmt.Sprintf("%s 追加 %d 天:%s → %s(起点 %s)",
|
||||
sub.SubTitle(), plan.Days, sub.EndDate, domain.Date(plan.NewEnd), domain.Date(plan.Base)))
|
||||
s.redirect(w, r, back, fmt.Sprintf("已追加 %d 天,新结束日 %s", plan.Days, domain.Date(plan.NewEnd)))
|
||||
}
|
||||
|
||||
func (s *Server) handleSubAction(action string) http.HandlerFunc {
|
||||
@@ -169,19 +148,6 @@ func (s *Server) handleCheckinSave(w http.ResponseWriter, r *http.Request) {
|
||||
if u != nil {
|
||||
opID = u.ID
|
||||
}
|
||||
if sub.Season {
|
||||
if status == "skipped" {
|
||||
s.redirect(w, r, back, "通行证不能跳过,请直接完成或结束")
|
||||
return
|
||||
}
|
||||
if err := s.db.SeasonComplete(id, date); err != nil {
|
||||
s.redirect(w, r, back, "完成通行证失败:"+err.Error())
|
||||
return
|
||||
}
|
||||
s.logOp(r, "通行证完成", "subscription", id, fmt.Sprintf("%s 通行证整段完成(%s)", sub.SubTitle(), date))
|
||||
s.redirect(w, r, back, "已把 "+sub.CustomerTail+" "+sub.CustomerName+" 的通行证标记为完成")
|
||||
return
|
||||
}
|
||||
if err := s.db.SaveCheckin(id, date, status, note, opID); err != nil {
|
||||
s.redirect(w, r, back, "打卡失败:"+err.Error())
|
||||
return
|
||||
@@ -225,23 +191,3 @@ func (s *Server) handleSubDelete(w http.ResponseWriter, r *http.Request) {
|
||||
s.logOp(r, "删除订阅", "subscription", id, sub.SubTitle()+"(含打卡与追加记录)")
|
||||
s.redirect(w, r, "/customers/"+itoa(sub.CustomerID), "已删除订阅「"+sub.PackageName+"」")
|
||||
}
|
||||
|
||||
// handleSeasonDone 从订阅卡片直接完成整段通行证。
|
||||
func (s *Server) handleSeasonDone(w http.ResponseWriter, r *http.Request) {
|
||||
id := pathID(r)
|
||||
sub, err := s.db.Sub(id)
|
||||
if err != nil {
|
||||
http.NotFound(w, r)
|
||||
return
|
||||
}
|
||||
date := strings.TrimSpace(r.PostFormValue("date"))
|
||||
if _, err := domain.ParseDate(date); err != nil {
|
||||
date = domain.Date(domain.Today())
|
||||
}
|
||||
if err := s.db.SeasonComplete(id, date); err != nil {
|
||||
s.redirect(w, r, "/customers/"+itoa(sub.CustomerID), "完成失败:"+err.Error())
|
||||
return
|
||||
}
|
||||
s.logOp(r, "通行证完成", "subscription", id, sub.SubTitle()+" 整段完成("+date+")")
|
||||
s.redirect(w, r, "/customers/"+itoa(sub.CustomerID), "已把通行证标记为完成")
|
||||
}
|
||||
|
||||
@@ -9,7 +9,7 @@ import (
|
||||
"daili/internal/domain"
|
||||
)
|
||||
|
||||
// pendingTasks 返回某天“应服务”的订阅行(day 型在区间内、count 型有剩余),
|
||||
// pendingTasks 返回某天“应服务”的订阅行(在区间内且未暂停),
|
||||
// customerIDs 非空时只保留这些客户;pkgID>0 时只保留该套餐。
|
||||
func (s *Server) pendingTasks(date string, customerIDs map[int64]bool, pkgID int64, tag string) ([]TaskRow, error) {
|
||||
subs, pauses, checkins, urgent, err := s.loadCalendarSubs(date, date, pkgID, tag)
|
||||
@@ -23,26 +23,11 @@ func (s *Server) pendingTasks(date string, customerIDs map[int64]bool, pkgID int
|
||||
if customerIDs != nil && !customerIDs[sub.CustomerID] {
|
||||
continue
|
||||
}
|
||||
cs := calSub{sub: sub, pauses: pauses[sub.ID], eval: sub.Eval(today, warn), checkins: checkins[sub.ID]}
|
||||
cs := calSub{sub: sub, pauses: pauses[sub.ID], checkins: checkins[sub.ID]}
|
||||
if sub.EndDate != "" {
|
||||
cs.hasEnd = true
|
||||
cs.end = domain.ParseDateOr(sub.EndDate, today)
|
||||
}
|
||||
if cs.isBlock() {
|
||||
if !cs.blockNeedsWork(date) {
|
||||
continue
|
||||
}
|
||||
row := TaskRow{SubView: newSubView(sub, today, warn), Urgent: urgent[sub.ID][date]}
|
||||
if ci, ok := checkins[sub.ID][date]; ok {
|
||||
row.CheckinID = ci.ID
|
||||
row.Done = ci.Status == "done"
|
||||
row.Skipped = ci.Status == "skipped"
|
||||
row.Note = ci.Note
|
||||
row.Operator = ci.OperatorName
|
||||
}
|
||||
rows = append(rows, row)
|
||||
continue
|
||||
}
|
||||
if !cs.covers(date) {
|
||||
continue
|
||||
}
|
||||
@@ -60,15 +45,8 @@ func (s *Server) pendingTasks(date string, customerIDs map[int64]bool, pkgID int
|
||||
return rows, nil
|
||||
}
|
||||
|
||||
// completeTask 完成某个订阅的某一天:通行证走整段完成,其余写打卡。
|
||||
// completeTask 完成某个订阅的某一天。
|
||||
func (s *Server) completeTask(subID int64, date string, operatorID int64) error {
|
||||
sub, err := s.db.Sub(subID)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if sub.Season {
|
||||
return s.db.SeasonComplete(subID, date)
|
||||
}
|
||||
return s.db.SaveCheckin(subID, date, "done", "", operatorID)
|
||||
}
|
||||
|
||||
|
||||
+2
-45
@@ -23,7 +23,7 @@ import (
|
||||
"daili/internal/store"
|
||||
)
|
||||
|
||||
//go:embed templates/_layout.html templates/_screen_layout.html templates/_partials.html templates/pages/*.html
|
||||
//go:embed templates/_layout.html templates/_partials.html templates/pages/*.html
|
||||
var templateFS embed.FS
|
||||
|
||||
//go:embed static
|
||||
@@ -44,8 +44,6 @@ type Config struct {
|
||||
BackupKeep int
|
||||
BackupDir string
|
||||
BackupEnabled bool
|
||||
ScreenPublic bool
|
||||
PortalPublic bool
|
||||
ConfigPath string
|
||||
Version string
|
||||
}
|
||||
@@ -129,7 +127,6 @@ func (s *Server) routes() http.Handler {
|
||||
mux.HandleFunc("GET /customers/{id}", s.auth(s.handleCustomerDetail))
|
||||
mux.HandleFunc("GET /customers/{id}/edit", s.auth(s.handleCustomerEditPage))
|
||||
mux.HandleFunc("POST /customers/{id}/edit", s.auth(s.handleCustomerUpdate))
|
||||
mux.HandleFunc("POST /customers/{id}/assignee", s.auth(s.handleCustomerAssignee))
|
||||
mux.HandleFunc("POST /customers/{id}/archive", s.auth(s.handleCustomerArchive))
|
||||
mux.HandleFunc("POST /customers/{id}/restore", s.auth(s.handleCustomerRestore))
|
||||
mux.HandleFunc("POST /customers/{id}/delete", s.auth(s.handleCustomerDelete))
|
||||
@@ -141,7 +138,6 @@ func (s *Server) routes() http.Handler {
|
||||
mux.HandleFunc("POST /subscriptions/{id}/close", s.auth(s.handleSubAction("close")))
|
||||
mux.HandleFunc("POST /subscriptions/{id}/reopen", s.auth(s.handleSubAction("reopen")))
|
||||
mux.HandleFunc("POST /subscriptions/{id}/delete", s.auth(s.handleSubDelete))
|
||||
mux.HandleFunc("POST /subscriptions/{id}/season-done", s.auth(s.handleSeasonDone))
|
||||
mux.HandleFunc("POST /subscriptions/{id}/checkin", s.auth(s.handleCheckinSave))
|
||||
mux.HandleFunc("POST /checkins/{id}/delete", s.auth(s.handleCheckinDelete))
|
||||
mux.HandleFunc("POST /checkins/batch", s.auth(s.handleCheckinBatch))
|
||||
@@ -155,27 +151,10 @@ func (s *Server) routes() http.Handler {
|
||||
mux.HandleFunc("POST /packages/{id}/archive", s.auth(s.handlePackageArchive))
|
||||
mux.HandleFunc("GET /packages/{id}", s.auth(s.handlePackageDetail))
|
||||
mux.HandleFunc("POST /packages/{id}/subscribe", s.auth(s.handlePackageBatchSubscribe))
|
||||
if s.cfg.PortalPublic {
|
||||
// 客户自助查询:独立开关,不受大屏 screen_public 影响
|
||||
mux.HandleFunc("GET /customer", s.handleCustomerPortal)
|
||||
}
|
||||
if s.cfg.ScreenPublic {
|
||||
// 大屏免登录:仅局域网部署时使用,内容为只读看板
|
||||
mux.HandleFunc("GET /screen", s.handleScreen)
|
||||
mux.HandleFunc("GET /api/screen/day", s.handleScreenDay)
|
||||
} else {
|
||||
mux.HandleFunc("GET /screen", s.auth(s.handleScreen))
|
||||
mux.HandleFunc("GET /api/screen/day", s.auth(s.handleScreenDay))
|
||||
}
|
||||
mux.HandleFunc("GET /logs", s.auth(s.handleLogs))
|
||||
mux.HandleFunc("GET /settings", s.auth(s.handleSettings))
|
||||
mux.HandleFunc("POST /settings", s.auth(s.handleSettingsSave))
|
||||
mux.HandleFunc("POST /settings/password", s.auth(s.handlePasswordChange))
|
||||
mux.HandleFunc("POST /settings/users", s.auth(s.handleUserCreate))
|
||||
mux.HandleFunc("POST /settings/users/{id}/toggle", s.auth(s.handleUserToggle))
|
||||
mux.HandleFunc("POST /settings/users/{id}/color", s.auth(s.handleUserColor))
|
||||
mux.HandleFunc("GET /settings/users/{id}/edit", s.auth(s.handleUserEditPage))
|
||||
mux.HandleFunc("POST /settings/users/{id}/edit", s.auth(s.handleUserEditSave))
|
||||
mux.HandleFunc("POST /settings/backup", s.auth(s.handleBackupNow))
|
||||
mux.HandleFunc("GET /export/{kind}", s.auth(s.handleExport))
|
||||
|
||||
@@ -316,11 +295,6 @@ func newRenderer() (*renderer, error) {
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
screenBase, err := template.New("screen").Funcs(funcs).ParseFS(templateFS,
|
||||
"templates/_screen_layout.html", "templates/_partials.html")
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
pages := map[string]*template.Template{}
|
||||
entries, err := fs.Glob(templateFS, "templates/pages/*.html")
|
||||
@@ -329,13 +303,7 @@ func newRenderer() (*renderer, error) {
|
||||
}
|
||||
for _, p := range entries {
|
||||
name := strings.TrimSuffix(strings.TrimPrefix(p, "templates/pages/"), ".html")
|
||||
var baseSet *template.Template
|
||||
if name == "screen" {
|
||||
baseSet = screenBase
|
||||
} else {
|
||||
baseSet = base
|
||||
}
|
||||
clone, err := baseSet.Clone()
|
||||
clone, err := base.Clone()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -396,14 +364,6 @@ func (s *Server) warnDays() int {
|
||||
return v
|
||||
}
|
||||
|
||||
func (s *Server) screenRefresh() int {
|
||||
v, err := strconv.Atoi(s.db.Setting("screen_refresh", "30"))
|
||||
if err != nil || v < 5 {
|
||||
return 30
|
||||
}
|
||||
return v
|
||||
}
|
||||
|
||||
func (s *Server) newPage(r *http.Request, title, nav string) *page {
|
||||
u := s.currentUser(r)
|
||||
today := domain.Today()
|
||||
@@ -487,9 +447,6 @@ func (s *Server) render(w http.ResponseWriter, r *http.Request, name string, d *
|
||||
return
|
||||
}
|
||||
layout := "layout"
|
||||
if name == "screen" {
|
||||
layout = "screenlayout"
|
||||
}
|
||||
var buf bytes.Buffer
|
||||
if err := tpl.ExecuteTemplate(&buf, layout, d); err != nil {
|
||||
log.Printf("渲染 %s 失败: %v", name, err)
|
||||
|
||||
+23
-200
@@ -201,6 +201,28 @@ a:hover { color: var(--app-accent-strong); text-decoration: underline; text-unde
|
||||
.app-foot a { color: var(--app-text-3); }
|
||||
.app-foot a:hover { color: var(--app-accent); }
|
||||
.app-foot .foot-version { font-family: var(--app-mono); }
|
||||
.app-foot .foot-by { font-family: var(--app-mono); opacity: 0.85; }
|
||||
|
||||
/* ---------- 盲水印(不可见,仅供溯源;勿删) ----------
|
||||
Powered by Baka春秋
|
||||
.wm-blind 同时用零尺寸、透明、零透明度和 clip 四重手段确保任何
|
||||
渲染路径下都不占位、不上色、不进入无障碍树。 */
|
||||
.wm-blind {
|
||||
position: absolute !important;
|
||||
left: -9999px !important;
|
||||
top: 0 !important;
|
||||
width: 1px !important;
|
||||
height: 1px !important;
|
||||
overflow: hidden !important;
|
||||
opacity: 0 !important;
|
||||
color: transparent !important;
|
||||
font-size: 0 !important;
|
||||
line-height: 0 !important;
|
||||
pointer-events: none !important;
|
||||
user-select: none !important;
|
||||
clip-path: inset(50%) !important;
|
||||
white-space: nowrap !important;
|
||||
}
|
||||
|
||||
/* ---------- 4. 顶栏 ---------- */
|
||||
|
||||
@@ -239,7 +261,6 @@ a:hover { color: var(--app-accent-strong); text-decoration: underline; text-unde
|
||||
.app-navbar .nav-link.active {
|
||||
background: var(--app-accent-soft); color: var(--app-accent-ink); font-weight: 600;
|
||||
}
|
||||
.app-navbar .nav-link.nav-screen { color: var(--app-accent); }
|
||||
|
||||
.nav-search { position: relative; width: 240px; flex: 0 1 auto; margin: 0 0.5rem; }
|
||||
.nav-search .form-control { height: 32px; padding-right: 30px; }
|
||||
@@ -575,11 +596,6 @@ fieldset { border: 0; margin: 0; padding: 0; min-width: 0; }
|
||||
.dot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; margin-right: 6px; vertical-align: 1px; }
|
||||
.dot.big { width: 12px; height: 12px; margin: 0; }
|
||||
|
||||
.asg { display: inline-flex; align-items: center; gap: 4px; font-size: 0.6875rem; color: var(--app-text-2); white-space: nowrap; }
|
||||
.asg i { width: 8px; height: 8px; border-radius: 2px; display: inline-block; flex: 0 0 auto; }
|
||||
.asg.none { color: var(--app-text-3); }
|
||||
.asg.none i { opacity: 0.55; }
|
||||
|
||||
/* ---------- 9. 表格 ---------- */
|
||||
|
||||
.table-wrap {
|
||||
@@ -679,15 +695,6 @@ fieldset { border: 0; margin: 0; padding: 0; min-width: 0; }
|
||||
}
|
||||
.cust-head .page-actions { grid-column: 2; grid-row: 1; justify-content: flex-end; }
|
||||
|
||||
.assign-form { display: inline-flex; align-items: center; gap: 6px; }
|
||||
.assign-form select {
|
||||
height: 30px; padding: 0 26px 0 8px; max-width: 150px;
|
||||
border: 1px solid var(--app-border); border-radius: 7px;
|
||||
background: var(--app-surface); color: var(--app-text);
|
||||
font: inherit; font-size: 0.75rem;
|
||||
}
|
||||
.assign-form select:focus { outline: none; border-color: var(--app-accent); box-shadow: 0 0 0 3px var(--app-ring); }
|
||||
|
||||
.subgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 14px; }
|
||||
|
||||
.subcard {
|
||||
@@ -796,26 +803,6 @@ fieldset { border: 0; margin: 0; padding: 0; min-width: 0; }
|
||||
.cal-cell.heat-4 { background: color-mix(in srgb, var(--app-accent) 18%, transparent); }
|
||||
.cal-cell.heat-1:hover, .cal-cell.heat-2:hover, .cal-cell.heat-3:hover, .cal-cell.heat-4:hover { background: var(--app-surface-2); }
|
||||
|
||||
/* 通行证 / 深渊:整段连续着色,每格显示同一个「已完成/总数」 */
|
||||
.cal-cell.has-block {
|
||||
background: color-mix(in srgb, var(--block) var(--block-pct, 18%), var(--app-surface));
|
||||
border-color: color-mix(in srgb, var(--block) 24%, var(--app-border));
|
||||
}
|
||||
.cal-cell.has-block:hover { background: color-mix(in srgb, var(--block) calc(var(--block-pct, 18%) + 6%), var(--app-surface)); }
|
||||
.cal-cell.has-block.today .dnum { background: var(--block); color: #fff; }
|
||||
.cell-block {
|
||||
display: inline-flex; align-items: center; gap: 4px;
|
||||
align-self: flex-start;
|
||||
padding: 1px 7px; border-radius: 999px;
|
||||
font-family: var(--app-mono); font-size: 0.75rem; font-weight: 700;
|
||||
color: var(--app-text);
|
||||
background: color-mix(in srgb, var(--block) 20%, var(--app-surface));
|
||||
border: 1px solid color-mix(in srgb, var(--block) 48%, transparent);
|
||||
white-space: nowrap;
|
||||
}
|
||||
.cell-block::before { content: ""; width: 6px; height: 6px; border-radius: 2px; background: var(--block); }
|
||||
.cal-cell > .cell-block:last-child { margin-top: auto; margin-bottom: 2px; }
|
||||
|
||||
.cell-top { display: flex; align-items: center; justify-content: space-between; gap: 4px; min-width: 0; }
|
||||
.cell-badges { display: inline-flex; align-items: center; gap: 4px; flex: 0 0 auto; }
|
||||
.dnum { font-family: var(--app-mono); font-size: 0.8125rem; font-weight: 700; line-height: 1.4; color: var(--app-text); }
|
||||
@@ -836,22 +823,6 @@ fieldset { border: 0; margin: 0; padding: 0; min-width: 0; }
|
||||
.cell-count span { font-size: 0.75rem; color: var(--app-text-3); white-space: nowrap; }
|
||||
.cal-cell.out .cell-count b { color: var(--app-text-3); }
|
||||
|
||||
.asg-strip {
|
||||
position: absolute; left: 0; top: 0; bottom: 0;
|
||||
display: flex; flex-direction: column;
|
||||
width: 4px; overflow: hidden; border-radius: 2px 0 0 2px; z-index: 1;
|
||||
}
|
||||
.asg-strip i { display: block; flex: 1 1 0; min-height: 3px; background: var(--app-text-3); }
|
||||
.asg-strip.sm { width: 3px; }
|
||||
|
||||
.season-band {
|
||||
position: absolute; left: 0; right: 0; bottom: 0;
|
||||
height: 4px; background: var(--sc, var(--app-accent)); opacity: 0.6;
|
||||
pointer-events: none;
|
||||
}
|
||||
.season-band.start { border-top-left-radius: 3px; border-bottom-left-radius: 3px; left: 3px; }
|
||||
.season-band.end { border-top-right-radius: 3px; border-bottom-right-radius: 3px; right: 3px; }
|
||||
|
||||
.pkg-tabs { display: flex; gap: 6px; margin-bottom: 16px; flex-wrap: wrap; padding-bottom: 10px; border-bottom: 1px solid var(--app-border); }
|
||||
.pkg-tabs a {
|
||||
display: inline-flex; align-items: center; gap: 6px;
|
||||
@@ -926,29 +897,6 @@ fieldset { border: 0; margin: 0; padding: 0; min-width: 0; }
|
||||
}
|
||||
.quick-hint { margin: 0 0 10px !important; font-size: 0.6875rem; line-height: 1.45; }
|
||||
|
||||
/* 触控小键盘:3 列 4 行,底行 ⌫ 0 ✓ */
|
||||
.keypad { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; margin: 10px 0 12px; }
|
||||
.keypad .key {
|
||||
height: 46px; padding: 0;
|
||||
border: 1px solid var(--app-border); border-radius: 10px;
|
||||
background: var(--app-surface); color: var(--app-text);
|
||||
font-family: var(--app-mono); font-size: 1.0625rem; font-weight: 600;
|
||||
cursor: pointer; user-select: none;
|
||||
transition: background 0.1s ease, border-color 0.1s ease, transform 0.06s ease;
|
||||
-webkit-tap-highlight-color: transparent;
|
||||
}
|
||||
.keypad .key:hover { border-color: var(--app-accent); color: var(--app-accent); }
|
||||
.keypad .key:active { transform: translateY(1px); background: var(--app-accent-soft); }
|
||||
.keypad .key-fn { font-size: 0.9375rem; color: var(--app-text-2); background: var(--app-surface-2); }
|
||||
.keypad .key-ok { background: var(--app-accent-solid); border-color: var(--app-accent-solid); color: #fff; font-size: 1.125rem; }
|
||||
.keypad .key-ok:hover { background: var(--app-accent-solid-hover); border-color: var(--app-accent-solid-hover); color: #fff; }
|
||||
.keypad-toggle { min-width: 44px; }
|
||||
.keypad-toggle.on {
|
||||
background: var(--app-accent-soft);
|
||||
border-color: color-mix(in srgb, var(--app-accent) 40%, transparent);
|
||||
color: var(--app-accent-ink);
|
||||
}
|
||||
|
||||
.picker { margin: 8px 0 12px; padding: 10px; border: 1px solid var(--app-accent); border-radius: var(--app-radius-sm); background: var(--app-surface-2); }
|
||||
.picker-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 8px; }
|
||||
.picker-head h4 { font-size: 0.8125rem; }
|
||||
@@ -970,7 +918,7 @@ fieldset { border: 0; margin: 0; padding: 0; min-width: 0; }
|
||||
.task {
|
||||
display: flex !important; align-items: flex-start; gap: 10px; flex-wrap: nowrap;
|
||||
padding: 9px 0; border-bottom: 1px dashed var(--app-border);
|
||||
border-left: 3px solid var(--asg, transparent);
|
||||
border-left: 3px solid transparent;
|
||||
padding-left: 8px; margin-left: -3px;
|
||||
}
|
||||
.task:last-child { border-bottom: 0; }
|
||||
@@ -1213,8 +1161,6 @@ fieldset { border: 0; margin: 0; padding: 0; min-width: 0; }
|
||||
.cell-load { display: none; }
|
||||
.cell-count b { font-size: 1rem; }
|
||||
.cell-count span { font-size: 0.625rem; }
|
||||
.cell-block { font-size: 0.5625rem; padding: 1px 3px; gap: 2px; }
|
||||
.cell-block::before { width: 4px; height: 4px; }
|
||||
.cal-cell { padding-left: 6px; }
|
||||
.cal-cell.today .dnum { width: 18px; height: 18px; }
|
||||
.table { min-width: 0; }
|
||||
@@ -1232,9 +1178,6 @@ fieldset { border: 0; margin: 0; padding: 0; min-width: 0; }
|
||||
.table-adjust th:nth-child(5), .table-adjust td:nth-child(5),
|
||||
.table-adjust th:nth-child(7), .table-adjust td:nth-child(7),
|
||||
.table-adjust th:nth-child(8), .table-adjust td:nth-child(8) { display: none; }
|
||||
.table-users th:nth-child(5), .table-users td:nth-child(5),
|
||||
.table-users th:nth-child(6), .table-users td:nth-child(6),
|
||||
.table-users th:nth-child(7), .table-users td:nth-child(7) { display: none; }
|
||||
.table-wrap { -webkit-overflow-scrolling: touch; }
|
||||
.task { flex-wrap: wrap; }
|
||||
.task-actions { width: 100%; justify-content: flex-end; margin-left: 0; }
|
||||
@@ -1258,126 +1201,6 @@ fieldset { border: 0; margin: 0; padding: 0; min-width: 0; }
|
||||
}
|
||||
|
||||
|
||||
/* ---------- 客户自助查询 /customer ---------- */
|
||||
.portal-wrap { max-width: 980px; margin: 0 auto; padding: 24px 16px 56px; }
|
||||
.portal-head { margin-bottom: 18px; }
|
||||
.portal-brand {
|
||||
display: inline-flex; align-items: center; gap: 8px;
|
||||
margin-bottom: 12px; color: var(--app-text); text-decoration: none;
|
||||
font-weight: 700; font-size: .9375rem;
|
||||
}
|
||||
.portal-brand:hover { color: var(--app-text); }
|
||||
.portal-brand .brand-mark { width: 26px; height: 26px; font-size: .8125rem; }
|
||||
.portal-head h1 { font-size: 1.6rem; font-weight: 800; margin: 0 0 4px; color: var(--app-text); }
|
||||
.portal-head p { margin: 0; }
|
||||
|
||||
.portal-error { margin: 0 0 14px; }
|
||||
|
||||
.portal-search {
|
||||
border: 1px solid var(--app-border); border-radius: var(--app-radius);
|
||||
background: var(--app-surface); box-shadow: var(--app-shadow-sm);
|
||||
overflow: hidden;
|
||||
}
|
||||
.portal-search-head {
|
||||
display: flex; align-items: center; gap: 8px;
|
||||
padding: 13px 16px; cursor: pointer; list-style: none;
|
||||
font-weight: 600; color: var(--app-text);
|
||||
}
|
||||
.portal-search-head::-webkit-details-marker { display: none; }
|
||||
.portal-search-head::after { content: "▾"; margin-left: auto; color: var(--app-text-3); font-size: .75rem; }
|
||||
.portal-search[open] .portal-search-head { border-bottom: 1px solid var(--app-border); }
|
||||
.portal-search[open] .portal-search-head::after { transform: rotate(180deg); }
|
||||
.portal-form-body { padding: 14px 16px 16px; }
|
||||
.portal-form-body .form-label { font-size: .8125rem; color: var(--app-text-2); margin-bottom: 5px; }
|
||||
|
||||
.portal-client { display: flex; flex-wrap: wrap; align-items: flex-start; gap: 12px; }
|
||||
.portal-client-main { min-width: 0; }
|
||||
.portal-client-name { font-size: 1.5rem; font-weight: 800; margin: 0 0 6px; }
|
||||
.portal-client-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
|
||||
.portal-client-status { margin-left: auto; }
|
||||
.portal-client-status .chip { font-size: .8125rem; }
|
||||
|
||||
.portal-section-head { display: flex; align-items: center; gap: 8px; margin-bottom: 4px; }
|
||||
.portal-section-head h2 { font-size: 1rem; font-weight: 700; margin: 0; }
|
||||
.portal-section-count {
|
||||
display: inline-flex; align-items: center; justify-content: center;
|
||||
min-width: 20px; height: 20px; padding: 0 6px; border-radius: 999px;
|
||||
background: var(--app-surface-3); color: var(--app-text-2);
|
||||
font-size: .75rem; font-weight: 600;
|
||||
}
|
||||
|
||||
.portal-sub-list { margin-top: 2px; }
|
||||
.portal-sub { padding: 12px 0; border-top: 1px solid var(--app-border); }
|
||||
.portal-sub:first-child { border-top: 0; }
|
||||
.portal-sub-main { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
|
||||
.portal-sub-main strong { font-size: .9375rem; }
|
||||
.portal-sub-meta {
|
||||
display: flex; flex-wrap: wrap; align-items: center; gap: 6px 14px;
|
||||
margin-top: 4px; font-size: .8125rem; color: var(--app-text-2);
|
||||
}
|
||||
.portal-sub-meta .muted { color: var(--app-text-3); }
|
||||
|
||||
.portal-ask-names { font-size: .875rem; color: var(--app-text-2); }
|
||||
.portal-ask-form { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
|
||||
.portal-ask-form .form-control { flex: 1 1 200px; width: auto; }
|
||||
|
||||
.pcal-nav { display: flex; align-items: center; gap: 6px; margin-left: auto; }
|
||||
.pcal-nav b { font-size: .875rem; min-width: 92px; text-align: center; }
|
||||
.pcal-nav-btn {
|
||||
width: 44px; height: 44px; padding: 0;
|
||||
display: inline-flex; align-items: center; justify-content: center;
|
||||
font-size: 1.125rem; line-height: 1;
|
||||
}
|
||||
|
||||
.pcal { margin-top: 10px; max-width: 880px; margin-left: auto; margin-right: auto; }
|
||||
.pcal-dow { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); background: var(--app-surface-2); border-bottom: 1px solid var(--app-border); }
|
||||
.pcal-dow span { padding: 6px 0; text-align: center; font-size: .72rem; color: var(--app-text-3); }
|
||||
.pcal-row { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); }
|
||||
.pcal-cell {
|
||||
position: relative;
|
||||
display: flex; flex-direction: column; gap: 2px;
|
||||
min-width: 0; min-height: 56px; padding: 6px 8px;
|
||||
border-top: 1px solid var(--app-border); border-right: 1px solid var(--app-border);
|
||||
background: var(--app-surface);
|
||||
}
|
||||
.pcal-cell:nth-child(7) { border-right: 0; }
|
||||
.pcal-cell b { font-size: .8125rem; color: var(--app-text); }
|
||||
.pcal-cell.out { background: var(--app-surface-2); }
|
||||
.pcal-cell.out b, .pcal-cell.out span, .pcal-cell.out .pcal-count { color: var(--app-text-3); }
|
||||
.pcal-cell.today { background: var(--app-accent-soft); box-shadow: inset 0 0 0 1.5px var(--app-accent); }
|
||||
.pcal-today {
|
||||
position: absolute; top: 5px; right: 6px;
|
||||
font-style: normal; font-size: .5625rem; font-weight: 700;
|
||||
color: var(--app-accent-ink); letter-spacing: 0;
|
||||
}
|
||||
.pcal-cell.has-block {
|
||||
background: color-mix(in srgb, var(--block) var(--block-pct, 18%), var(--app-surface));
|
||||
border-color: color-mix(in srgb, var(--block) 22%, var(--app-border));
|
||||
}
|
||||
.pcal-block {
|
||||
display: inline-flex; align-items: center; gap: 4px; align-self: flex-start;
|
||||
padding: 1px 6px; border-radius: 999px;
|
||||
font-size: .6875rem; font-weight: 700; white-space: nowrap;
|
||||
color: var(--app-text);
|
||||
background: color-mix(in srgb, var(--block) 16%, var(--app-surface));
|
||||
border: 1px solid color-mix(in srgb, var(--block) 28%, transparent);
|
||||
}
|
||||
.pcal-block::before { content: ""; width: 5px; height: 5px; border-radius: 50%; background: var(--block); }
|
||||
.pcal-dot { width: 7px; height: 7px; margin-top: auto; border-radius: 50%; border: 1.5px solid var(--app-accent); }
|
||||
.pcal-dot.done { background: var(--app-accent); border-color: var(--app-accent); }
|
||||
.pcal-count { margin-top: auto; font-size: .75rem; font-weight: 700; color: var(--app-accent); }
|
||||
|
||||
@media (max-width: 575px) {
|
||||
.portal-wrap { padding: 16px 10px 40px; }
|
||||
.portal-head h1 { font-size: 1.45rem; }
|
||||
.portal-client-name { font-size: 1.3rem; }
|
||||
.portal-client-status { margin-left: 0; }
|
||||
.pcal-cell { min-height: 50px; padding: 4px 5px; }
|
||||
.pcal-today { top: 3px; right: 4px; font-size: .5rem; }
|
||||
.pcal-block { font-size: .625rem; padding: 1px 4px; }
|
||||
.pcal-nav b { min-width: 74px; }
|
||||
}
|
||||
|
||||
.tagchip, .pkg-tag {
|
||||
display: inline-flex; align-items: center; gap: 4px;
|
||||
padding: 1px 8px; border-radius: 999px;
|
||||
|
||||
+10
-218
@@ -1,12 +1,10 @@
|
||||
/* 代打台 · 交互增强(无框架,全部渐进增强) */
|
||||
/* 代打台-L · 交互增强(无框架,全部渐进增强) */
|
||||
/* Powered by Baka春秋 */
|
||||
(function () {
|
||||
'use strict';
|
||||
|
||||
/* ---------- 工具:本地日期,禁止用 toISOString 做“自然日”计算 ---------- */
|
||||
function pad2(n) { return n < 10 ? '0' + n : '' + n; }
|
||||
function parseDay(s) { return new Date(s + 'T00:00:00'); }
|
||||
function fmtDay(d) { return d.getFullYear() + '-' + pad2(d.getMonth() + 1) + '-' + pad2(d.getDate()); }
|
||||
function addDays(s, n) { var d = parseDay(s); d.setDate(d.getDate() + n); return fmtDay(d); }
|
||||
function diffDays(a, b) { return Math.round((b.getTime() - a.getTime()) / 86400000); }
|
||||
|
||||
/* ---------- 提示条:自动淡出(.flash 固定定位,不会顶动页面) ---------- */
|
||||
@@ -67,136 +65,18 @@
|
||||
if (input.value) paint(input.value);
|
||||
});
|
||||
|
||||
/* ---------- 新订阅表单:按套餐类型切换「天数 / 次数 / 终止日」 ---------- */
|
||||
/* ---------- 新订阅表单:选套餐时带出默认天数 ---------- */
|
||||
document.querySelectorAll('form[data-sub-form]').forEach(function (form) {
|
||||
var sel = form.querySelector('[data-pkg-select]');
|
||||
var daysWrap = form.querySelector('[data-days-wrap]');
|
||||
var countWrap = form.querySelector('[data-count-wrap]');
|
||||
var endWrap = form.querySelector('[data-end-wrap]');
|
||||
var startWrap = form.querySelector('[data-start-wrap]');
|
||||
var startInput = form.querySelector('input[name="start_date"]');
|
||||
var endInput = endWrap && endWrap.querySelector('input');
|
||||
var cyclesWrap = form.querySelector('[data-cycles-wrap]');
|
||||
var cyclesInput = cyclesWrap && cyclesWrap.querySelector('input');
|
||||
if (!sel) return;
|
||||
if (!sel || !daysWrap) return;
|
||||
var daysInput = daysWrap.querySelector('input');
|
||||
|
||||
/* 只覆盖“上一次自动填的”终止日,不碰用户手填的值 */
|
||||
function setAutoEnd(v) {
|
||||
if (!endInput || !v) return;
|
||||
if (!endInput.value || endInput.dataset.auto === endInput.value) {
|
||||
endInput.value = v;
|
||||
endInput.dataset.auto = v;
|
||||
}
|
||||
}
|
||||
|
||||
/* 显示/隐藏一组字段;隐藏时一并 disable,避免同名字段重复提交 */
|
||||
function setWrap(wrap, show) {
|
||||
if (!wrap) return;
|
||||
wrap.hidden = !show;
|
||||
wrap.querySelectorAll('input, select, textarea').forEach(function (el) { el.disabled = !show; });
|
||||
}
|
||||
|
||||
function sync() {
|
||||
sel.addEventListener('change', function () {
|
||||
var opt = sel.options[sel.selectedIndex];
|
||||
var unit = opt && opt.getAttribute('data-unit');
|
||||
var amount = opt && opt.getAttribute('data-amount');
|
||||
var validity = opt && parseInt(opt.getAttribute('data-validity') || '0', 10);
|
||||
|
||||
if (unit === 'season') {
|
||||
setWrap(daysWrap, false);
|
||||
setWrap(countWrap, false);
|
||||
setWrap(endWrap, false);
|
||||
setWrap(startWrap, false);
|
||||
setWrap(cyclesWrap, false);
|
||||
if (startInput) startInput.required = false;
|
||||
return;
|
||||
}
|
||||
|
||||
setWrap(startWrap, true);
|
||||
if (startInput) startInput.required = true;
|
||||
|
||||
if (unit === 'abyss') {
|
||||
setWrap(daysWrap, false);
|
||||
setWrap(countWrap, false);
|
||||
setWrap(endWrap, false);
|
||||
setWrap(cyclesWrap, true);
|
||||
if (cyclesInput) {
|
||||
cyclesInput.required = true;
|
||||
if (amount) cyclesInput.value = amount;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
setWrap(cyclesWrap, false);
|
||||
if (cyclesInput) cyclesInput.required = false;
|
||||
|
||||
if (unit === 'count') {
|
||||
setWrap(daysWrap, false);
|
||||
setWrap(countWrap, true);
|
||||
setWrap(endWrap, true);
|
||||
if (amount) countWrap.querySelector('input').value = amount;
|
||||
if (validity > 0 && startInput && startInput.value) setAutoEnd(addDays(startInput.value, validity - 1));
|
||||
} else if (unit === 'day') {
|
||||
setWrap(daysWrap, true);
|
||||
setWrap(countWrap, false);
|
||||
setWrap(endWrap, true);
|
||||
if (amount) daysWrap.querySelector('input').value = amount;
|
||||
} else {
|
||||
setWrap(daysWrap, true);
|
||||
setWrap(countWrap, false);
|
||||
setWrap(endWrap, false);
|
||||
}
|
||||
}
|
||||
|
||||
sel.addEventListener('change', sync);
|
||||
if (startInput) {
|
||||
startInput.addEventListener('change', function () {
|
||||
var opt = sel.options[sel.selectedIndex];
|
||||
var validity = opt && parseInt(opt.getAttribute('data-validity') || '0', 10);
|
||||
if (opt && opt.getAttribute('data-unit') === 'count' && validity > 0 && startInput.value) {
|
||||
setAutoEnd(addDays(startInput.value, validity - 1));
|
||||
}
|
||||
});
|
||||
}
|
||||
sync();
|
||||
});
|
||||
|
||||
/* ---------- 套餐表单:切换计费方式与对应字段 ---------- */
|
||||
document.querySelectorAll('form[data-package-form]').forEach(function (form) {
|
||||
var label = form.querySelector('[data-unit-label]');
|
||||
var amountTitle = form.querySelector('[data-amount-title]');
|
||||
var radios = form.querySelectorAll('input[name="unit"]');
|
||||
var seasonWrap = form.querySelector('[data-season-wrap]');
|
||||
var validityWrap = form.querySelector('[data-validity-wrap]');
|
||||
var abyssWrap = form.querySelector('[data-abyss-wrap]');
|
||||
var amountWrap = form.querySelector('[data-amount-wrap]');
|
||||
var cycleInput = form.querySelector('input[name="cycle_days"]');
|
||||
|
||||
function setWrap(wrap, show) {
|
||||
if (!wrap) return;
|
||||
wrap.hidden = !show;
|
||||
wrap.querySelectorAll('input, select, textarea').forEach(function (el) { el.disabled = !show; });
|
||||
}
|
||||
|
||||
function sync() {
|
||||
var v = 'day';
|
||||
radios.forEach(function (r) { if (r.checked) v = r.value; });
|
||||
|
||||
if (label) label.textContent = v === 'count' ? '次' : (v === 'abyss' ? '个' : '天');
|
||||
if (amountTitle) amountTitle.textContent = v === 'abyss' ? '周期数' : '默认量';
|
||||
|
||||
setWrap(seasonWrap, v === 'season');
|
||||
setWrap(validityWrap, v === 'count');
|
||||
setWrap(abyssWrap, v === 'abyss');
|
||||
setWrap(amountWrap, v !== 'season');
|
||||
if (seasonWrap) {
|
||||
seasonWrap.querySelectorAll('input').forEach(function (i) { i.required = v === 'season'; });
|
||||
}
|
||||
if (cycleInput) cycleInput.required = v === 'abyss';
|
||||
}
|
||||
|
||||
radios.forEach(function (r) { r.addEventListener('change', sync); });
|
||||
sync();
|
||||
var amount = opt && parseInt(opt.getAttribute('data-amount') || '0', 10);
|
||||
if (amount > 0 && daysInput) daysInput.value = amount;
|
||||
});
|
||||
});
|
||||
|
||||
/* ---------- 批量开通:表头全选 + 半选状态 ---------- */
|
||||
@@ -253,7 +133,7 @@
|
||||
paint();
|
||||
})();
|
||||
|
||||
/* ---------- 触摸小键盘 + 抽屉时钟 + 更多菜单 ---------- */
|
||||
/* ---------- 抽屉时钟 + 更多菜单 ---------- */
|
||||
(function () {
|
||||
'use strict';
|
||||
|
||||
@@ -267,51 +147,6 @@
|
||||
}
|
||||
if (clocks.length) { tick(); setInterval(tick, 1000); }
|
||||
|
||||
/* 小键盘:输入手机尾号
|
||||
关键点:鼠标按下时阻止默认行为,否则按钮会先抢走输入框焦点;
|
||||
每次按键后再把焦点和光标送回输入框末尾。 */
|
||||
document.querySelectorAll('[data-keypad]').forEach(function (pad) {
|
||||
// 键盘是表单的兄弟节点(不在 <form> 内),所以先找输入框,再用 input.form 反查表单
|
||||
var scope = pad.closest('.drawer-block') || pad.parentElement || document;
|
||||
var input = scope.querySelector('input[name="tail"]');
|
||||
if (!input) { return; }
|
||||
var form = input.form;
|
||||
if (!form) { return; }
|
||||
|
||||
function keepFocus() {
|
||||
try { input.focus({ preventScroll: true }); } catch (err) { input.focus(); }
|
||||
var end = input.value.length;
|
||||
try { input.setSelectionRange(end, end); } catch (err) { /* number 类型时忽略 */ }
|
||||
}
|
||||
|
||||
// mousedown 会触发“按钮获得焦点”,先拦下来;pointerdown 再兜底一次
|
||||
pad.addEventListener('mousedown', function (e) {
|
||||
e.preventDefault();
|
||||
keepFocus();
|
||||
});
|
||||
pad.addEventListener('pointerdown', function () {
|
||||
// 这里不能 preventDefault:会连带取消后面的 click 事件
|
||||
keepFocus();
|
||||
});
|
||||
|
||||
pad.addEventListener('click', function (e) {
|
||||
var btn = e.target.closest('button[data-key]');
|
||||
if (!btn) return;
|
||||
var key = btn.getAttribute('data-key');
|
||||
if (key === 'back') {
|
||||
input.value = input.value.slice(0, -1);
|
||||
} else if (key === 'ok') {
|
||||
if (input.value) {
|
||||
if (form.requestSubmit) { form.requestSubmit(); } else { form.submit(); }
|
||||
}
|
||||
return;
|
||||
} else if (input.value.length < 8) {
|
||||
input.value += key;
|
||||
}
|
||||
keepFocus();
|
||||
});
|
||||
});
|
||||
|
||||
/* 更多菜单:点开一个时收起其它,点空白处关闭 */
|
||||
document.addEventListener('click', function (e) {
|
||||
document.querySelectorAll('.more-actions[open]').forEach(function (d) {
|
||||
@@ -319,46 +154,3 @@
|
||||
});
|
||||
});
|
||||
})();
|
||||
|
||||
/* ---------- 触控/PC 小键盘模式 ---------- */
|
||||
(function () {
|
||||
'use strict';
|
||||
|
||||
var KEY = 'daili_keypad_mode';
|
||||
|
||||
function applyMode(touch) {
|
||||
document.querySelectorAll('[data-keypad]').forEach(function (pad) {
|
||||
pad.hidden = !touch;
|
||||
var block = pad.closest('.drawer-block') || document;
|
||||
var input = block.querySelector('input[name="tail"]');
|
||||
if (input) {
|
||||
input.readOnly = touch;
|
||||
input.setAttribute('inputmode', touch ? 'none' : 'numeric');
|
||||
input.setAttribute('placeholder', touch ? '点下方键盘输入尾号' : '输入手机尾号,回车即可完成');
|
||||
}
|
||||
var btn = block.querySelector('[data-keypad-toggle]');
|
||||
if (btn) {
|
||||
btn.textContent = touch ? '触控' : '⌨';
|
||||
btn.classList.toggle('on', touch);
|
||||
btn.title = touch ? '当前触控模式,点此切回 PC' : '当前 PC 模式,点此打开触控键盘';
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
var touchMode = false;
|
||||
try { touchMode = localStorage.getItem(KEY) === 'touch'; } catch (err) { }
|
||||
applyMode(touchMode);
|
||||
|
||||
document.querySelectorAll('[data-keypad-toggle]').forEach(function (btn) {
|
||||
btn.addEventListener('click', function () {
|
||||
touchMode = !touchMode;
|
||||
try { localStorage.setItem(KEY, touchMode ? 'touch' : 'pc'); } catch (err) { }
|
||||
applyMode(touchMode);
|
||||
if (!touchMode) {
|
||||
var block = btn.closest('.drawer-block') || document;
|
||||
var input = block.querySelector('input[name="tail"]');
|
||||
if (input) { input.focus(); }
|
||||
}
|
||||
});
|
||||
});
|
||||
})();
|
||||
|
||||
@@ -1,413 +0,0 @@
|
||||
/* ============================================================
|
||||
代打台 · 可视化大屏(v1.10)
|
||||
------------------------------------------------------------
|
||||
只认 <html data-bs-theme="light|dark">;默认由模板给 dark。
|
||||
Bootstrap 只用于重置与栅格,视觉全部在本文件内闭环。
|
||||
============================================================ */
|
||||
|
||||
:root,
|
||||
[data-bs-theme="light"] {
|
||||
--scr-bg: #eef4fb;
|
||||
--scr-panel: #ffffff;
|
||||
--scr-panel-2: #f7fafd;
|
||||
--scr-line: #dbe6f1;
|
||||
--scr-text: #0f1c29;
|
||||
--scr-text-2: #354a60;
|
||||
--scr-muted: #5d7186;
|
||||
--scr-accent: #2f5f9e;
|
||||
--scr-accent-2: #3f74b4;
|
||||
--scr-accent-solid: #2f5f9e;
|
||||
--scr-danger: #b3261e;
|
||||
--scr-warn: #8a5200;
|
||||
--scr-glow: 0 0 18px rgba(47, 95, 158, 0.12);
|
||||
--scr-shadow: 0 14px 32px -22px rgba(20, 32, 43, 0.4);
|
||||
}
|
||||
|
||||
[data-bs-theme="dark"] {
|
||||
--scr-bg: #070e16;
|
||||
--scr-panel: #0f1823;
|
||||
--scr-panel-2: #142030;
|
||||
--scr-line: #203448;
|
||||
--scr-text: #e7f0f9;
|
||||
--scr-text-2: #b6c9db;
|
||||
--scr-muted: #87a0b8;
|
||||
--scr-accent: #6fa8dc;
|
||||
--scr-accent-2: #93c4ee;
|
||||
--scr-accent-solid: #2b5d94;
|
||||
--scr-danger: #f08a82;
|
||||
--scr-warn: #e0b072;
|
||||
--scr-glow: 0 0 24px rgba(111, 168, 220, 0.16);
|
||||
--scr-shadow: 0 18px 40px -24px rgba(0, 0, 0, 0.8);
|
||||
}
|
||||
|
||||
* { box-sizing: border-box; }
|
||||
|
||||
html, body { height: 100%; margin: 0; }
|
||||
|
||||
body.screen-body {
|
||||
background:
|
||||
radial-gradient(1200px 600px at 12% -10%, color-mix(in srgb, var(--scr-accent) 14%, transparent), transparent 60%),
|
||||
radial-gradient(900px 500px at 100% 0%, color-mix(in srgb, var(--scr-accent) 8%, transparent), transparent 55%),
|
||||
var(--scr-bg);
|
||||
color: var(--scr-text);
|
||||
font-family: "Microsoft YaHei UI", "PingFang SC", "Hiragino Sans GB", "Noto Sans SC",
|
||||
system-ui, -apple-system, "Segoe UI", sans-serif;
|
||||
font-size: 14px;
|
||||
line-height: 1.45;
|
||||
overflow: hidden;
|
||||
-webkit-font-smoothing: antialiased;
|
||||
}
|
||||
|
||||
body.screen-body::before {
|
||||
content: "";
|
||||
position: fixed; inset: 0; z-index: 0; pointer-events: none;
|
||||
background:
|
||||
linear-gradient(var(--scr-line) 1px, transparent 1px) 0 0 / 100% 44px,
|
||||
linear-gradient(90deg, var(--scr-line) 1px, transparent 1px) 0 0 / 44px 100%;
|
||||
opacity: 0.35;
|
||||
}
|
||||
|
||||
.scr {
|
||||
position: relative; z-index: 1;
|
||||
display: grid;
|
||||
grid-template-rows: auto auto minmax(0, 1fr) auto auto auto;
|
||||
gap: 10px;
|
||||
height: 100vh;
|
||||
height: 100dvh;
|
||||
padding: 12px 16px 8px;
|
||||
}
|
||||
|
||||
/* ---------- 头部 ---------- */
|
||||
|
||||
.scr-head { display: flex; align-items: center; gap: 14px; min-height: 40px; flex-wrap: wrap; padding-bottom: 8px; border-bottom: 1px solid var(--scr-line); }
|
||||
|
||||
.scr-brand { display: flex; align-items: center; gap: 8px; font-size: 16px; font-weight: 800; letter-spacing: 0.06em; color: var(--scr-text); }
|
||||
.scr-brand .mark {
|
||||
display: inline-grid; place-items: center;
|
||||
width: 26px; height: 26px;
|
||||
background: var(--scr-accent-solid); color: #fff;
|
||||
font-size: 13px; font-weight: 800; border-radius: 8px;
|
||||
}
|
||||
.scr-brand em { font-style: normal; font-size: 11px; font-weight: 500; color: var(--scr-muted); letter-spacing: 0.16em; }
|
||||
|
||||
.scr-tabs { display: flex; gap: 4px; flex-wrap: wrap; }
|
||||
.scr-tabs a {
|
||||
display: inline-flex; align-items: center; gap: 5px;
|
||||
height: 28px; padding: 0 11px;
|
||||
font-size: 12px; color: var(--scr-text-2); text-decoration: none;
|
||||
border: 1px solid var(--scr-line); border-radius: 999px;
|
||||
background: var(--scr-panel);
|
||||
}
|
||||
.scr-tabs a::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--tab, var(--scr-accent)); }
|
||||
.scr-tabs a:hover { border-color: var(--scr-accent); color: var(--scr-text); text-decoration: none; }
|
||||
.scr-tabs a.on { background: var(--scr-accent-solid); border-color: var(--scr-accent-solid); color: #fff; }
|
||||
.scr-tabs a.on::before { background: #fff; }
|
||||
|
||||
.scr-tools { display: flex; align-items: center; gap: 8px; }
|
||||
.scr-switch {
|
||||
height: 28px; padding: 0 10px;
|
||||
display: inline-flex; align-items: center;
|
||||
font-size: 12px; color: var(--scr-accent); text-decoration: none;
|
||||
border: 1px solid color-mix(in srgb, var(--scr-accent) 40%, var(--scr-line));
|
||||
border-radius: 999px; background: var(--scr-panel);
|
||||
}
|
||||
.scr-switch:hover { background: color-mix(in srgb, var(--scr-accent) 12%, var(--scr-panel)); text-decoration: none; }
|
||||
|
||||
.scr-theme {
|
||||
width: 28px; height: 28px; padding: 0;
|
||||
display: inline-grid; place-items: center;
|
||||
border: 1px solid var(--scr-line); border-radius: 999px;
|
||||
background: var(--scr-panel); color: var(--scr-text-2);
|
||||
font-size: 13px; cursor: pointer;
|
||||
}
|
||||
.scr-theme:hover { border-color: var(--scr-accent); color: var(--scr-accent); }
|
||||
.scr-theme .ic-sun { display: none; }
|
||||
[data-bs-theme="dark"] .scr-theme .ic-sun { display: inline; }
|
||||
[data-bs-theme="dark"] .scr-theme .ic-moon { display: none; }
|
||||
|
||||
.scr-clock { margin-left: auto; text-align: right; line-height: 1.1; }
|
||||
.scr-clock b { font-family: "Cascadia Mono", "Consolas", ui-monospace, monospace; font-size: 22px; letter-spacing: 0.04em; font-variant-numeric: tabular-nums; color: var(--scr-text); }
|
||||
.scr-clock span { display: block; font-size: 11px; color: var(--scr-muted); }
|
||||
|
||||
.scr-links { font-size: 11px; color: var(--scr-muted); }
|
||||
.scr-links a { color: var(--scr-accent); text-decoration: none; }
|
||||
.scr-links a:hover { text-decoration: underline; }
|
||||
|
||||
/* ---------- KPI ---------- */
|
||||
|
||||
.scr-kpis { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
|
||||
.kpi {
|
||||
position: relative;
|
||||
display: flex; align-items: baseline; gap: 6px;
|
||||
padding: 10px 14px 10px 18px;
|
||||
background: var(--scr-panel);
|
||||
border: 1px solid var(--scr-line);
|
||||
border-radius: 10px;
|
||||
overflow: hidden;
|
||||
box-shadow: var(--scr-shadow);
|
||||
}
|
||||
.kpi::after {
|
||||
content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 3px;
|
||||
background: var(--scr-accent);
|
||||
}
|
||||
.kpi span { font-size: 12px; color: var(--scr-muted); margin-right: auto; }
|
||||
.kpi b { font-family: "Cascadia Mono", "Consolas", ui-monospace, monospace; font-size: 30px; font-weight: 700; line-height: 1; font-variant-numeric: tabular-nums; color: var(--scr-text); }
|
||||
.kpi i { font-style: normal; font-size: 11px; color: var(--scr-muted); }
|
||||
.kpi-hot::after { background: var(--scr-danger); }
|
||||
.kpi-hot b { color: var(--scr-danger); }
|
||||
.kpi-warm::after { background: var(--scr-warn); }
|
||||
.kpi-warm b { color: var(--scr-warn); }
|
||||
|
||||
/* ---------- 主区 ---------- */
|
||||
|
||||
.scr-main { display: grid; grid-template-columns: 1.5fr 1fr; gap: 10px; min-height: 0; }
|
||||
|
||||
.panel {
|
||||
display: flex; flex-direction: column; min-height: 0;
|
||||
background: var(--scr-panel);
|
||||
border: 1px solid var(--scr-line);
|
||||
border-radius: 10px;
|
||||
overflow: hidden;
|
||||
box-shadow: var(--scr-shadow);
|
||||
}
|
||||
.panel-head {
|
||||
display: flex; align-items: baseline; justify-content: space-between; gap: 10px;
|
||||
padding: 9px 14px;
|
||||
border-bottom: 1px solid var(--scr-line);
|
||||
background: var(--scr-panel-2);
|
||||
}
|
||||
.panel-head h2 { margin: 0; font-size: 13px; font-weight: 700; letter-spacing: 0.06em; color: var(--scr-text); }
|
||||
.panel-head span { font-size: 11px; color: var(--scr-muted); }
|
||||
|
||||
/* 热力 */
|
||||
.heat-grid { flex: 1 1 auto; display: flex; flex-direction: column; justify-content: center; padding: 8px 12px; min-height: 0; min-width: 0; overflow: hidden; }
|
||||
.heat-dow { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 4px; margin-bottom: 4px; }
|
||||
.heat-dow span { text-align: center; font-size: 10px; color: var(--scr-muted); }
|
||||
.heat-row { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 4px; margin-bottom: 4px; align-items: stretch; }
|
||||
.heat-cell {
|
||||
position: relative;
|
||||
display: flex; align-items: center; justify-content: space-between;
|
||||
min-height: 34px; min-width: 0;
|
||||
padding: 3px 7px 3px 9px;
|
||||
border: 1px solid var(--scr-line); border-radius: 6px;
|
||||
background: var(--scr-panel-2);
|
||||
font-size: 11px; color: var(--scr-muted);
|
||||
overflow: hidden;
|
||||
transition: transform 0.1s ease, border-color 0.1s ease;
|
||||
}
|
||||
.heat-cell span { font-family: "Cascadia Mono", "Consolas", ui-monospace, monospace; font-size: 11px; color: var(--scr-text-2); }
|
||||
.heat-cell b { font-family: "Cascadia Mono", "Consolas", ui-monospace, monospace; font-size: 12px; font-weight: 700; color: var(--scr-text); white-space: nowrap; }
|
||||
.heat-cell.out { background: var(--scr-panel-2); border-color: var(--scr-line); }
|
||||
.heat-cell.out span, .heat-cell.out b { color: var(--scr-text-2); }
|
||||
.heat-cell.past { opacity: 1; }
|
||||
.heat-cell.today { outline: 1px solid var(--scr-accent); outline-offset: -1px; }
|
||||
.heat-cell.today span { color: var(--scr-text); font-weight: 700; }
|
||||
.heat-cell:hover { transform: translateY(-1px); border-color: var(--scr-accent); z-index: 3; }
|
||||
|
||||
.heat-cell.h1 { background: color-mix(in srgb, var(--scr-accent) 10%, var(--scr-panel-2)); }
|
||||
.heat-cell.h2 { background: color-mix(in srgb, var(--scr-accent) 22%, var(--scr-panel-2)); }
|
||||
.heat-cell.h3 { background: color-mix(in srgb, var(--scr-accent) 36%, var(--scr-panel-2)); }
|
||||
.heat-cell.h4 { background: color-mix(in srgb, var(--scr-accent) 52%, var(--scr-panel-2)); }
|
||||
.heat-cell.h3 span, .heat-cell.h4 span { color: var(--scr-text); }
|
||||
.heat-cell.h3 b, .heat-cell.h4 b { color: var(--scr-text); }
|
||||
.heat-cell.has-block {
|
||||
background: color-mix(in srgb, var(--block) var(--block-pct, 18%), var(--scr-panel-2));
|
||||
border-color: color-mix(in srgb, var(--block) 30%, var(--scr-line));
|
||||
}
|
||||
.heat-cell b.scr-block {
|
||||
display: inline-flex; align-items: center;
|
||||
padding: 1px 5px; border-radius: 4px;
|
||||
background: color-mix(in srgb, var(--block) 20%, var(--scr-panel));
|
||||
border: 1px solid color-mix(in srgb, var(--block) 32%, transparent);
|
||||
color: var(--scr-text);
|
||||
font-size: 12px; font-weight: 700;
|
||||
}
|
||||
|
||||
.cell-urgent {
|
||||
position: absolute; top: 3px; right: 3px;
|
||||
width: 5px; height: 5px; border-radius: 50%;
|
||||
background: var(--scr-danger);
|
||||
box-shadow: 0 0 6px color-mix(in srgb, var(--scr-danger) 70%, transparent);
|
||||
}
|
||||
|
||||
.heat-legend { display: flex; align-items: center; gap: 4px; padding: 6px 14px 10px; font-size: 10px; color: var(--scr-muted); }
|
||||
.heat-legend span { margin-right: 6px; }
|
||||
.heat-legend i { width: 14px; height: 9px; border-radius: 2px; border: 1px solid var(--scr-line); display: inline-block; }
|
||||
.heat-legend i.h0 { background: var(--scr-panel-2); }
|
||||
.heat-legend i.h1 { background: color-mix(in srgb, var(--scr-accent) 10%, var(--scr-panel-2)); }
|
||||
.heat-legend i.h2 { background: color-mix(in srgb, var(--scr-accent) 22%, var(--scr-panel-2)); }
|
||||
.heat-legend i.h3 { background: color-mix(in srgb, var(--scr-accent) 36%, var(--scr-panel-2)); }
|
||||
.heat-legend i.h4 { background: color-mix(in srgb, var(--scr-accent) 52%, var(--scr-panel-2)); }
|
||||
.heat-legend .legend-hint { margin-left: auto; font-style: normal; color: var(--scr-text-2); }
|
||||
|
||||
/* TOP 10 */
|
||||
.top-list { list-style: none; margin: 0; padding: 6px 10px; overflow: auto; flex: 1 1 auto; min-height: 0; }
|
||||
.top-item {
|
||||
display: grid;
|
||||
grid-template-columns: 24px 56px minmax(0, 1fr) minmax(0, 118px) 78px 64px;
|
||||
gap: 8px; align-items: center;
|
||||
padding: 5px 4px;
|
||||
border-bottom: 1px dashed var(--scr-line);
|
||||
font-size: 12px;
|
||||
}
|
||||
.top-item:last-child { border-bottom: 0; }
|
||||
.top-item .rank { grid-column: 1; font-family: "Cascadia Mono", "Consolas", ui-monospace, monospace; font-size: 11px; color: var(--scr-muted); }
|
||||
.top-item:nth-child(-n+3) .rank { color: var(--scr-accent); font-weight: 700; }
|
||||
.top-tail { grid-column: 2; font-family: "Cascadia Mono", "Consolas", ui-monospace, monospace; font-size: 14px; font-weight: 700; letter-spacing: 0.03em; color: var(--scr-text); }
|
||||
.top-name { grid-column: 3; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--scr-text-2); }
|
||||
.top-pkg {
|
||||
grid-column: 4;
|
||||
font-size: 10px; padding: 1px 6px; border-radius: 999px;
|
||||
border-left: 2px solid var(--tag, var(--scr-accent));
|
||||
background: color-mix(in srgb, var(--tag, var(--scr-accent)) 14%, transparent);
|
||||
color: var(--scr-text-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
|
||||
}
|
||||
.top-remain { grid-column: 5; font-family: "Cascadia Mono", "Consolas", ui-monospace, monospace; font-size: 11px; color: var(--scr-text-2); white-space: nowrap; }
|
||||
.top-bar { grid-column: 6; height: 4px; background: var(--scr-line); border-radius: 999px; overflow: hidden; }
|
||||
.top-bar i { display: block; height: 100%; background: var(--scr-accent); }
|
||||
.top-item.lv-today .top-remain { color: var(--scr-danger); font-weight: 700; }
|
||||
.top-item.lv-warn .top-remain { color: var(--scr-warn); }
|
||||
.top-item.lv-today .top-bar i { background: var(--scr-danger); }
|
||||
.top-item.lv-warn .top-bar i { background: var(--scr-warn); }
|
||||
|
||||
/* ---------- 底部两块 ---------- */
|
||||
|
||||
.scr-bottom { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; min-height: 168px; max-height: 30vh; }
|
||||
.today-list { list-style: none; margin: 0; padding: 4px 10px 8px; overflow: auto; min-height: 0; }
|
||||
.today-list li {
|
||||
display: grid;
|
||||
grid-template-columns: auto minmax(0, 1fr) 86px 52px 76px;
|
||||
gap: 8px; align-items: center;
|
||||
padding: 5px 6px;
|
||||
border-bottom: 1px dashed var(--scr-line);
|
||||
font-size: 12px;
|
||||
}
|
||||
.today-list li:last-child { border-bottom: 0; }
|
||||
.today-list li.urgent {
|
||||
background: color-mix(in srgb, var(--scr-danger) 8%, transparent);
|
||||
border-left: 2px solid var(--scr-danger);
|
||||
padding-left: 8px;
|
||||
}
|
||||
.today-list .tchip { grid-column: 1; }
|
||||
.today-list .pkg { grid-column: 2; font-size: 10px; color: var(--scr-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
|
||||
.today-list .asg { grid-column: 3; }
|
||||
.today-list .tag-urgent { grid-column: 4; justify-self: start; }
|
||||
.today-list .rem { grid-column: 5; font-family: "Cascadia Mono", "Consolas", ui-monospace, monospace; font-size: 11px; color: var(--scr-text-2); white-space: nowrap; text-align: right; }
|
||||
|
||||
.tchip {
|
||||
display: inline-flex; align-items: baseline; gap: 3px;
|
||||
padding: 1px 6px;
|
||||
border-left: 2px solid var(--tag, var(--scr-accent));
|
||||
background: color-mix(in srgb, var(--tag, var(--scr-accent)) 14%, transparent);
|
||||
border-radius: 2px 6px 6px 2px; white-space: nowrap;
|
||||
color: var(--scr-text-2);
|
||||
}
|
||||
.tchip b { font-family: "Cascadia Mono", "Consolas", ui-monospace, monospace; font-size: 13px; color: var(--scr-text); }
|
||||
|
||||
.tag-urgent {
|
||||
display: inline-flex; align-items: center;
|
||||
height: 18px; padding: 0 6px;
|
||||
font-size: 10px; font-weight: 700; line-height: 1;
|
||||
background: color-mix(in srgb, var(--scr-danger) 18%, var(--scr-panel));
|
||||
color: var(--scr-danger);
|
||||
border: 1px solid color-mix(in srgb, var(--scr-danger) 32%, transparent);
|
||||
border-radius: 999px;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.scr-empty, .scr-empty-inline { color: var(--scr-muted); font-size: 12px; padding: 16px; text-align: center; margin: 0; }
|
||||
.scr-empty-inline { padding: 0; text-align: left; }
|
||||
|
||||
/* ---------- 最近追加 ---------- */
|
||||
|
||||
.scr-recent {
|
||||
display: flex; align-items: center; gap: 10px;
|
||||
padding: 5px 12px;
|
||||
background: var(--scr-panel);
|
||||
border: 1px solid var(--scr-line); border-radius: 10px;
|
||||
font-size: 11px; color: var(--scr-muted);
|
||||
overflow: hidden;
|
||||
}
|
||||
.recent-label { flex: 0 0 auto; letter-spacing: 0.12em; color: var(--scr-accent); font-size: 10px; }
|
||||
.recent-track { display: flex; gap: 18px; overflow: hidden; white-space: nowrap; }
|
||||
.recent-item { color: var(--scr-text-2); }
|
||||
.recent-item b { font-family: "Cascadia Mono", "Consolas", ui-monospace, monospace; font-size: 12px; color: var(--scr-text); margin-right: 3px; }
|
||||
.recent-item em { font-style: normal; color: var(--scr-accent); margin-left: 3px; }
|
||||
|
||||
.scr-foot { text-align: center; font-size: 10px; color: var(--scr-muted); letter-spacing: 0.06em; }
|
||||
|
||||
/* ---------- 当日明细浮层 ---------- */
|
||||
|
||||
.day-pop {
|
||||
position: fixed; z-index: 60;
|
||||
width: 340px; max-height: 62vh; overflow: auto;
|
||||
padding: 10px 12px;
|
||||
background: var(--scr-panel);
|
||||
border: 1px solid var(--scr-accent);
|
||||
border-radius: 10px;
|
||||
box-shadow: 0 18px 40px -18px rgba(0, 0, 0, 0.55), var(--scr-glow);
|
||||
font-size: 12px;
|
||||
pointer-events: auto;
|
||||
overscroll-behavior: contain;
|
||||
}
|
||||
.day-pop[hidden] { display: none; }
|
||||
.day-pop h4 { margin: 0 0 6px; display: flex; align-items: baseline; justify-content: space-between; font-size: 12px; color: var(--scr-text); }
|
||||
.day-pop h4 small { font-weight: 400; color: var(--scr-muted); font-size: 10px; }
|
||||
.day-pop .pop-meta { display: flex; gap: 10px; margin-bottom: 6px; font-size: 10px; color: var(--scr-muted); }
|
||||
.day-pop .pop-meta b { color: var(--scr-text-2); font-family: "Cascadia Mono", "Consolas", ui-monospace, monospace; }
|
||||
.day-pop ul { list-style: none; margin: 0; padding: 0; }
|
||||
.day-pop li { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 6px; align-items: center; padding: 3px 0; border-bottom: 1px dashed var(--scr-line); }
|
||||
.day-pop li:last-child { border-bottom: 0; }
|
||||
.day-pop li.urgent { color: var(--scr-danger); }
|
||||
.day-pop li.done { opacity: 0.45; text-decoration: line-through; }
|
||||
.day-pop .pop-tail { font-family: "Cascadia Mono", "Consolas", ui-monospace, monospace; font-size: 12px; font-weight: 700; }
|
||||
.day-pop .pop-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--scr-text-2); }
|
||||
.day-pop .pop-rem { font-size: 10px; color: var(--scr-muted); white-space: nowrap; }
|
||||
.day-pop .pop-more { margin-top: 6px; font-size: 10px; color: var(--scr-muted); text-align: right; }
|
||||
.day-pop .pop-empty { color: var(--scr-muted); text-align: center; padding: 8px 0; }
|
||||
|
||||
/* ---------- 打手颜色 ---------- */
|
||||
|
||||
.asg-strip {
|
||||
position: absolute; left: 0; top: 0; bottom: 0;
|
||||
display: flex; flex-direction: column;
|
||||
width: 3px; overflow: hidden; border-radius: 6px 0 0 6px;
|
||||
}
|
||||
.asg-strip i { display: block; flex: 1 1 0; min-height: 3px; }
|
||||
.asg-strip.sm { width: 3px; }
|
||||
|
||||
.asg { display: inline-flex; align-items: center; gap: 4px; font-size: 10px; color: var(--scr-text-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
|
||||
.asg i { width: 7px; height: 7px; border-radius: 2px; flex: 0 0 auto; }
|
||||
.asg.none { color: var(--scr-muted); }
|
||||
.asg.none i { opacity: 0.5; }
|
||||
|
||||
.pop-who { display: inline-block; width: 7px; height: 7px; border-radius: 2px; margin-right: 4px; vertical-align: 0; }
|
||||
|
||||
/* ---------- 小屏 / 投屏适配 ---------- */
|
||||
|
||||
@media (max-width: 1200px) {
|
||||
.scr-main { grid-template-columns: 1fr 1fr; }
|
||||
.scr-kpis .kpi b { font-size: 24px; }
|
||||
.top-item { grid-template-columns: 24px 52px minmax(0, 1fr) 78px 56px; }
|
||||
.top-item .top-pkg { display: none; }
|
||||
.top-remain { grid-column: 4; }
|
||||
.top-bar { grid-column: 5; }
|
||||
.today-list li { grid-template-columns: auto minmax(0, 1fr) 52px 76px; }
|
||||
.today-list .asg { display: none; }
|
||||
.today-list .tag-urgent { grid-column: 3; }
|
||||
.today-list .rem { grid-column: 4; }
|
||||
}
|
||||
|
||||
@media (max-width: 860px) {
|
||||
body.screen-body { overflow: auto; }
|
||||
.scr { height: auto; }
|
||||
.scr-main, .scr-bottom { grid-template-columns: 1fr; }
|
||||
.scr-bottom { max-height: none; }
|
||||
.scr-tabs, .scr-links { display: none; }
|
||||
.scr-clock { margin-left: 0; }
|
||||
.scr-kpis { grid-template-columns: 1fr 1fr; }
|
||||
}
|
||||
|
||||
@media (prefers-reduced-motion: reduce) {
|
||||
.heat-cell { transition: none; }
|
||||
}
|
||||
@@ -1,162 +0,0 @@
|
||||
/* 大屏:时钟 + 全屏 + 主题 + 日历悬停/点按明细 */
|
||||
(function () {
|
||||
'use strict';
|
||||
|
||||
function pad(n) { return n < 10 ? '0' + n : '' + n; }
|
||||
|
||||
function tick() {
|
||||
var d = new Date();
|
||||
var clock = document.querySelector('[data-clock]');
|
||||
if (clock) clock.textContent = pad(d.getHours()) + ':' + pad(d.getMinutes()) + ':' + pad(d.getSeconds());
|
||||
var dateEl = document.querySelector('[data-date]');
|
||||
if (dateEl) {
|
||||
dateEl.textContent = d.getFullYear() + '-' + pad(d.getMonth() + 1) + '-' + pad(d.getDate()) +
|
||||
' 周' + '日一二三四五六'.charAt(d.getDay());
|
||||
}
|
||||
}
|
||||
tick();
|
||||
setInterval(tick, 1000);
|
||||
|
||||
document.addEventListener('keydown', function (e) {
|
||||
if (e.key === 'f' || e.key === 'F') {
|
||||
if (document.fullscreenElement) {
|
||||
document.exitFullscreen();
|
||||
} else if (document.documentElement.requestFullscreen) {
|
||||
document.documentElement.requestFullscreen();
|
||||
}
|
||||
}
|
||||
if (e.key === 'Escape') { hide(); }
|
||||
});
|
||||
|
||||
/* ---------- 主题切换:唯一状态源 data-bs-theme ---------- */
|
||||
var THEME_KEY = 'daili_theme';
|
||||
var root = document.documentElement;
|
||||
var themeBtns = document.querySelectorAll('[data-theme-toggle]');
|
||||
|
||||
function currentTheme() {
|
||||
return root.getAttribute('data-bs-theme') === 'light' ? 'light' : 'dark';
|
||||
}
|
||||
function paintTheme() {
|
||||
var dark = currentTheme() === 'dark';
|
||||
themeBtns.forEach(function (b) { b.setAttribute('aria-pressed', dark ? 'true' : 'false'); });
|
||||
}
|
||||
|
||||
themeBtns.forEach(function (btn) {
|
||||
btn.addEventListener('click', function () {
|
||||
var next = currentTheme() === 'dark' ? 'light' : 'dark';
|
||||
root.setAttribute('data-bs-theme', next);
|
||||
document.cookie = THEME_KEY + '=' + next + '; path=/; max-age=31536000; SameSite=Lax';
|
||||
paintTheme();
|
||||
});
|
||||
});
|
||||
paintTheme();
|
||||
|
||||
/* ---------- 日历格子明细 ---------- */
|
||||
var scr = document.querySelector('.scr');
|
||||
var pop = document.getElementById('day-pop');
|
||||
if (!scr || !pop) return;
|
||||
|
||||
var api = scr.getAttribute('data-api') || '/api/screen/day';
|
||||
var pkg = scr.getAttribute('data-pkg') || '0';
|
||||
var cache = {};
|
||||
var hideTimer = null;
|
||||
var pinned = false;
|
||||
|
||||
function esc(s) {
|
||||
return String(s == null ? '' : s).replace(/[&<>"']/g, function (c) {
|
||||
return { '&': '&', '<': '<', '>': '>', '"': '"', "'": ''' }[c];
|
||||
});
|
||||
}
|
||||
|
||||
function place(cell) {
|
||||
var r = cell.getBoundingClientRect();
|
||||
var w = 340, h = Math.min(360, pop.offsetHeight || 240);
|
||||
var left = r.right + 8;
|
||||
if (left + w > window.innerWidth - 8) left = Math.max(8, r.left - w - 8);
|
||||
var top = r.top + r.height / 2 - h / 2;
|
||||
top = Math.max(8, Math.min(top, window.innerHeight - h - 8));
|
||||
pop.style.left = left + 'px';
|
||||
pop.style.top = top + 'px';
|
||||
}
|
||||
|
||||
function render(data, cell) {
|
||||
if (!data) {
|
||||
pop.innerHTML = '<div class="pop-empty">读取失败</div>';
|
||||
return;
|
||||
}
|
||||
var d = new Date(data.date + 'T00:00:00');
|
||||
var label = data.date + ' 周' + '日一二三四五六'.charAt(d.getDay());
|
||||
var html = '<h4>' + esc(label) + '<small>' + data.total + ' 单 · 已完成 ' + data.done +
|
||||
(data.urgent ? ' · <span style="color:var(--scr-danger)">加急 ' + data.urgent + '</span>' : '') + '</small></h4>';
|
||||
if (!data.items || !data.items.length) {
|
||||
html += '<div class="pop-empty">这天没有排单</div>';
|
||||
} else {
|
||||
html += '<ul>';
|
||||
data.items.forEach(function (it) {
|
||||
html += '<li class="' + (it.urgent ? 'urgent ' : '') + (it.done ? 'done' : '') + '">' +
|
||||
'<span class="pop-tail">' + esc(it.tail) + '</span>' +
|
||||
'<span class="pop-name"><i class="pop-who" style="background:' + esc(it.who_color || '#8A8F98') + '"></i>' + esc(it.who || '未指派') + ' · ' + esc(it.pkg) + '</span>' +
|
||||
'<span class="pop-rem">' + (it.urgent ? '加急 · ' : '') + esc(it.remain) + '</span>' +
|
||||
'</li>';
|
||||
});
|
||||
html += '</ul>';
|
||||
if (data.more > 0) html += '<div class="pop-more">另有 ' + data.more + ' 单未显示</div>';
|
||||
}
|
||||
pop.innerHTML = html;
|
||||
pop.hidden = false;
|
||||
place(cell);
|
||||
}
|
||||
|
||||
function show(cell) {
|
||||
clearTimeout(hideTimer);
|
||||
var date = cell.getAttribute('data-date');
|
||||
var key = date + '|' + pkg;
|
||||
pop.hidden = false;
|
||||
pop.innerHTML = '<div class="pop-empty">载入中…</div>';
|
||||
place(cell);
|
||||
if (cache[key]) {
|
||||
render(cache[key], cell);
|
||||
return;
|
||||
}
|
||||
fetch(api + '?date=' + encodeURIComponent(date) + '&pkg=' + encodeURIComponent(pkg), {
|
||||
headers: { 'Accept': 'application/json' }
|
||||
}).then(function (r) {
|
||||
if (!r.ok) throw new Error('bad');
|
||||
return r.json();
|
||||
}).then(function (data) {
|
||||
cache[key] = data;
|
||||
render(data, cell);
|
||||
}).catch(function () {
|
||||
pop.innerHTML = '<div class="pop-empty">读取失败</div>';
|
||||
});
|
||||
}
|
||||
|
||||
function hide() {
|
||||
clearTimeout(hideTimer);
|
||||
pinned = false;
|
||||
pop.hidden = true;
|
||||
}
|
||||
function hideSoon() {
|
||||
if (pinned) return;
|
||||
clearTimeout(hideTimer);
|
||||
hideTimer = setTimeout(function () { pop.hidden = true; }, 260);
|
||||
}
|
||||
function keepOpen() { clearTimeout(hideTimer); }
|
||||
|
||||
document.querySelectorAll('.heat-cell[data-date]').forEach(function (cell) {
|
||||
cell.addEventListener('mouseenter', function () { show(cell); });
|
||||
cell.addEventListener('mouseleave', hideSoon);
|
||||
cell.addEventListener('focus', function () { show(cell); });
|
||||
cell.addEventListener('click', function (e) {
|
||||
e.preventDefault();
|
||||
var openForCell = !pop.hidden && pop.dataset.date === cell.getAttribute('data-date');
|
||||
if (openForCell) { hide(); return; }
|
||||
pinned = true;
|
||||
show(cell);
|
||||
pop.dataset.date = cell.getAttribute('data-date');
|
||||
});
|
||||
});
|
||||
|
||||
pop.addEventListener('mouseenter', keepOpen);
|
||||
pop.addEventListener('mouseleave', function () { if (!pinned) hideSoon(); });
|
||||
})();
|
||||
@@ -4,7 +4,7 @@
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<meta name="color-scheme" content="light dark">
|
||||
<title>{{.Title}} · 代打台</title>
|
||||
<title>{{.Title}} · 代打台-L</title>
|
||||
<link rel="icon" href="/static/favicon.svg?v={{.AssetVersion}}" type="image/svg+xml">
|
||||
<script>
|
||||
/* 首屏主题:服务端没有写 data-bs-theme 时(还没选过主题)跟随系统,避免闪白 */
|
||||
@@ -19,10 +19,12 @@
|
||||
<link rel="stylesheet" href="/static/app.css?v={{.AssetVersion}}">
|
||||
</head>
|
||||
<body>
|
||||
<!-- Powered by Baka春秋 · 代打台-L 盲水印(不可见,勿删) -->
|
||||
<div class="wm-blind" aria-hidden="true" data-wm="Powered by Baka春秋" hidden-mark="Powered by Baka春秋">Powered by Baka春秋</div>
|
||||
{{if .User}}
|
||||
<nav class="navbar navbar-expand-xl app-navbar sticky-top">
|
||||
<div class="container-fluid">
|
||||
<a class="navbar-brand" href="/calendar"><span class="brand-mark" aria-hidden="true">代</span><span>代打台</span></a>
|
||||
<a class="navbar-brand" href="/calendar"><span class="brand-mark" aria-hidden="true">代</span><span>代打台-L</span></a>
|
||||
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#mainNav" aria-controls="mainNav" aria-expanded="false" aria-label="展开导航"><span class="navbar-toggler-icon"></span></button>
|
||||
<div class="collapse navbar-collapse" id="mainNav">
|
||||
<ul class="navbar-nav me-auto">
|
||||
@@ -30,7 +32,6 @@
|
||||
<li class="nav-item"><a class="nav-link{{if eq .Nav "customers"}} active{{end}}" href="/customers">客户</a></li>
|
||||
<li class="nav-item"><a class="nav-link{{if eq .Nav "subscriptions"}} active{{end}}" href="/subscriptions">订阅</a></li>
|
||||
<li class="nav-item"><a class="nav-link{{if eq .Nav "packages"}} active{{end}}" href="/packages">套餐</a></li>
|
||||
<li class="nav-item"><a class="nav-link nav-screen" href="/screen" target="_blank" rel="noopener">大屏 ↗</a></li>
|
||||
</ul>
|
||||
<form class="nav-search" role="search" action="/customers" method="get">
|
||||
<input class="form-control form-control-sm" type="search" name="q" value="{{.Query}}" placeholder="手机尾号 / 姓名 / 游戏名" aria-label="搜索客户" data-search>
|
||||
@@ -59,10 +60,10 @@
|
||||
{{if .Error}}<div class="notice notice-danger" role="alert">{{.Error}}</div>{{end}}
|
||||
<main class="{{if .User}}app-main{{else}}auth-main{{end}}">{{template "content" .}}</main>
|
||||
{{if .User}}<footer class="app-foot">
|
||||
<span>代打台 <span class="foot-version">v{{.Version}}</span></span>
|
||||
<span>代打台-L <span class="foot-version">v{{.Version}}</span></span>
|
||||
<span class="foot-by">Powered by Baka春秋</span>
|
||||
<a href="/logs">操作日志</a>
|
||||
<a href="/settings">设置</a>
|
||||
<a href="/screen" target="_blank" rel="noopener">大屏</a>
|
||||
</footer>{{end}}
|
||||
<script src="/static/vendor/bootstrap.bundle.min.js?v={{.AssetVersion}}" defer></script>
|
||||
<script src="/static/app.js?v={{.AssetVersion}}" defer></script>
|
||||
|
||||
@@ -41,29 +41,7 @@
|
||||
<button class="btn btn-primary btn-sm">今日打卡</button>
|
||||
</form>
|
||||
{{end}}
|
||||
{{if .Abyss}}
|
||||
{{if .CanAbyssToday}}
|
||||
<form method="post" action="/subscriptions/{{.ID}}/checkin">
|
||||
<input type="hidden" name="date" value="{{.Today}}">
|
||||
<input type="hidden" name="status" value="done">
|
||||
<button class="btn btn-primary btn-sm">完成本周期</button>
|
||||
</form>
|
||||
{{end}}
|
||||
<span class="chip chip-active">已完成 {{.UsedCount}} / {{.TotalCount}} 周期</span>
|
||||
{{else if .Season}}
|
||||
{{if .CanPassToday}}
|
||||
<form method="post" action="/subscriptions/{{.ID}}/season-done" data-confirm="标记后整段通行证完成,确认?">
|
||||
<input type="hidden" name="date" value="{{.Today}}">
|
||||
<button class="btn btn-primary btn-sm">完成通行证</button>
|
||||
</form>
|
||||
{{else if .SeasonDone}}
|
||||
<span class="chip chip-active">通行证已完成 {{.SeasonDone}}</span>
|
||||
{{else}}
|
||||
<span class="chip chip-plain">不在通行证有效期</span>
|
||||
{{end}}
|
||||
{{else}}
|
||||
<a class="btn btn-soft btn-sm" href="?extend={{.ID}}#extend">{{if eq .Unit "day"}}追加时长{{else}}追加次数{{end}}</a>
|
||||
{{end}}
|
||||
<a class="btn btn-soft btn-sm" href="?extend={{.ID}}#extend">追加时长</a>
|
||||
{{if eq .Status "active"}}
|
||||
<form method="post" action="/subscriptions/{{.ID}}/pause" data-confirm="暂停后剩余时长冻结,确认暂停?">
|
||||
<button class="btn btn-soft btn-sm">暂停</button>
|
||||
@@ -93,12 +71,11 @@
|
||||
<section class="extend" id="extend" style="--tag:{{.Sub.PackageColor}}">
|
||||
<header class="extend-head">
|
||||
<div>
|
||||
<h3>给 {{.Sub.CustomerTail}} {{.Sub.CustomerName}} 追加{{if .IsDay}}时长{{else}}次数{{end}}</h3>
|
||||
<h3>给 {{.Sub.CustomerTail}} {{.Sub.CustomerName}} 追加时长</h3>
|
||||
<p>{{.Sub.PackageName}} · {{.View.RemainText}} · {{.View.PeriodText}}</p>
|
||||
</div>
|
||||
<a class="extend-close" href="{{.Back}}" aria-label="关闭">×</a>
|
||||
</header>
|
||||
{{if .IsDay}}
|
||||
<form method="post" action="/subscriptions/{{.Sub.ID}}/extend" class="extend-form"
|
||||
data-extend data-base="{{.Base}}" data-old-end="{{.OldEnd}}" data-today="{{.Today}}">
|
||||
<input type="hidden" name="back" value="{{.Back}}">
|
||||
@@ -132,30 +109,5 @@
|
||||
<a class="btn btn-soft" href="{{.Back}}">取消</a>
|
||||
</div>
|
||||
</form>
|
||||
{{else}}
|
||||
<form method="post" action="/subscriptions/{{.Sub.ID}}/extend" class="extend-form">
|
||||
<input type="hidden" name="back" value="{{.Back}}">
|
||||
<div class="extend-preview">
|
||||
<div><span>当前剩余</span><b>{{.View.RemainText}}</b></div>
|
||||
<div><span>已用 / 总数</span><b>{{.Sub.UsedCount}} / {{.Sub.TotalCount}}</b></div>
|
||||
{{if .Sub.EndDate}}<div><span>有效期至</span><b>{{.Sub.EndDate}}</b></div>{{end}}
|
||||
</div>
|
||||
<div class="grid-2">
|
||||
<label class="field"><span>追加次数</span>
|
||||
<input type="number" name="add_count" min="1" max="10000" value="{{.DefaultAmount}}" required>
|
||||
</label>
|
||||
<label class="field"><span>新的有效期(留空不改)</span>
|
||||
<input type="date" name="new_end_opt">
|
||||
</label>
|
||||
</div>
|
||||
<label class="field"><span>备注</span>
|
||||
<input type="text" name="note" maxlength="120" placeholder="例如:加购 10 次副本">
|
||||
</label>
|
||||
<div class="actions">
|
||||
<button type="submit" class="btn btn-primary">确认追加</button>
|
||||
<a class="btn btn-soft" href="{{.Back}}">取消</a>
|
||||
</div>
|
||||
</form>
|
||||
{{end}}
|
||||
</section>
|
||||
{{end}}
|
||||
|
||||
@@ -1,18 +0,0 @@
|
||||
{{define "screenlayout"}}<!doctype html>
|
||||
<html lang="zh-CN" data-bs-theme="{{if eq .Theme "light"}}light{{else}}dark{{end}}">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<meta name="color-scheme" content="dark light">
|
||||
<meta http-equiv="refresh" content="{{.D.Refresh}}">
|
||||
<title>{{.Title}} · 代打台</title>
|
||||
<link rel="icon" href="/static/favicon.svg?v={{.D.AssetVersion}}" type="image/svg+xml">
|
||||
<link rel="stylesheet" href="/static/vendor/bootstrap.min.css?v={{.D.AssetVersion}}">
|
||||
<link rel="stylesheet" href="/static/screen.css?v={{.D.AssetVersion}}">
|
||||
</head>
|
||||
<body class="screen-body">
|
||||
{{template "content" .}}
|
||||
<script src="/static/vendor/bootstrap.bundle.min.js?v={{.D.AssetVersion}}" defer></script>
|
||||
<script src="/static/screen.js?v={{.D.AssetVersion}}" defer></script>
|
||||
</body>
|
||||
</html>{{end}}
|
||||
@@ -40,9 +40,8 @@
|
||||
{{range .D.Weeks}}
|
||||
<div class="cal-week" role="row">
|
||||
{{range .}}
|
||||
<a class="cal-cell heat-{{.Heat}}{{if not .InMonth}} out{{end}}{{if .IsToday}} today{{end}}{{if .IsSelected}} sel{{end}}{{if .IsWeekend}} weekend{{end}}{{if .DueCount}} has-due{{end}}{{if .BlockColor}} has-block{{end}}"
|
||||
href="/calendar?y={{$.D.Year}}&m={{$.D.Month}}&d={{.Date}}&{{$.D.FilterQuery}}" role="gridcell"{{if .BlockColor}} style="--block:{{.BlockColor}};--block-pct:{{.BlockPercent}}%"{{end}}>
|
||||
{{if .Strip}}<span class="asg-strip" aria-hidden="true">{{range .Strip}}<i style="background:{{.}}"></i>{{end}}</span>{{end}}
|
||||
<a class="cal-cell heat-{{.Heat}}{{if not .InMonth}} out{{end}}{{if .IsToday}} today{{end}}{{if .IsSelected}} sel{{end}}{{if .IsWeekend}} weekend{{end}}{{if .DueCount}} has-due{{end}}"
|
||||
href="/calendar?y={{$.D.Year}}&m={{$.D.Month}}&d={{.Date}}&{{$.D.FilterQuery}}" role="gridcell">
|
||||
<div class="cell-top">
|
||||
<span class="dnum">{{.Day}}</span>
|
||||
<span class="cell-badges">
|
||||
@@ -50,7 +49,6 @@
|
||||
{{if .DueCount}}<span class="due-badge"><em>到期</em>{{.DueCount}}</span>{{end}}
|
||||
</span>
|
||||
</div>
|
||||
{{if .BlockText}}<span class="cell-block" title="{{.BlockTitle}}">{{.BlockText}}</span>{{end}}
|
||||
{{if .TaskCount}}
|
||||
<div class="cell-count">
|
||||
<b>{{.DoneCount}}</b><span>/ {{.TaskCount}}</span>
|
||||
@@ -85,23 +83,8 @@
|
||||
<input type="hidden" name="back" value="{{.D.Back}}">
|
||||
<input class="form-control form-control-sm" type="text" name="tail" placeholder="输入手机尾号,回车即可完成" maxlength="8" autocomplete="off" inputmode="numeric" aria-label="手机尾号快速完成">
|
||||
<button class="btn btn-sm btn-primary" type="submit">完成</button>
|
||||
<button type="button" class="btn btn-sm btn-ghost keypad-toggle" data-keypad-toggle title="切换触控/PC 模式" aria-label="切换触控/PC 模式">⌨</button>
|
||||
</form>
|
||||
<p class="muted small quick-hint">唯一匹配直接完成;同尾号多人 / 一单多服务会列出让你勾选。</p>
|
||||
<div class="keypad" data-keypad role="group" aria-label="数字小键盘" hidden>
|
||||
<button type="button" class="key" data-key="1">1</button>
|
||||
<button type="button" class="key" data-key="2">2</button>
|
||||
<button type="button" class="key" data-key="3">3</button>
|
||||
<button type="button" class="key" data-key="4">4</button>
|
||||
<button type="button" class="key" data-key="5">5</button>
|
||||
<button type="button" class="key" data-key="6">6</button>
|
||||
<button type="button" class="key" data-key="7">7</button>
|
||||
<button type="button" class="key" data-key="8">8</button>
|
||||
<button type="button" class="key" data-key="9">9</button>
|
||||
<button type="button" class="key key-fn" data-key="back" aria-label="退格">⌫</button>
|
||||
<button type="button" class="key" data-key="0">0</button>
|
||||
<button type="button" class="key key-ok" data-key="ok" aria-label="确认完成">✓</button>
|
||||
</div>
|
||||
|
||||
{{if .D.PickTail}}
|
||||
<section class="picker">
|
||||
@@ -142,7 +125,7 @@
|
||||
<ul class="list-group list-group-flush task-list">
|
||||
{{range .D.Tasks}}
|
||||
{{if or .Done .Skipped}}
|
||||
<li class="list-group-item task task-done px-0" style="--asg:{{.AssigneeHex}}">
|
||||
<li class="list-group-item task task-done px-0">
|
||||
<details class="done-fold">
|
||||
<summary>
|
||||
<span class="ticket" style="--tag:{{.PackageColor}}"><b>{{.CustomerTail}}</b>{{.CustomerName}}</span>
|
||||
@@ -153,7 +136,6 @@
|
||||
</summary>
|
||||
<div class="done-detail">
|
||||
<div class="task-meta">
|
||||
<span class="asg{{if .AssigneeNone}} none{{end}}"><i style="background:{{.AssigneeHex}}"></i>{{.AssigneeLabel}}</span>
|
||||
<span>{{.RemainText}}</span>
|
||||
{{if .DueText}}<span class="due due-{{.Eval.Level}}">{{.DueText}}</span>{{end}}
|
||||
</div>
|
||||
@@ -173,7 +155,7 @@
|
||||
<input type="hidden" name="back" value="{{$.D.Back}}">
|
||||
<button class="btn btn-sm {{if .Urgent}}btn-urgent{{else}}btn-ghost{{end}}" type="submit">{{if .Urgent}}取消加急{{else}}标记加急{{end}}</button>
|
||||
</form>
|
||||
{{if not (or .Season .Abyss)}}<a class="btn btn-soft btn-sm" href="/calendar?y={{$.D.Year}}&m={{$.D.Month}}&d={{$.D.Selected}}&{{$.D.FilterQuery}}&extend={{.ID}}#extend">追加时长</a>{{end}}
|
||||
<a class="btn btn-soft btn-sm" href="/calendar?y={{$.D.Year}}&m={{$.D.Month}}&d={{$.D.Selected}}&{{$.D.FilterQuery}}&extend={{.ID}}#extend">追加时长</a>
|
||||
</div>
|
||||
</details>
|
||||
</div>
|
||||
@@ -181,7 +163,7 @@
|
||||
</details>
|
||||
</li>
|
||||
{{else}}
|
||||
<li class="list-group-item task{{if .Urgent}} urgent{{end}} px-0" style="--asg:{{.AssigneeHex}}">
|
||||
<li class="list-group-item task{{if .Urgent}} urgent{{end}} px-0">
|
||||
<div class="task-main">
|
||||
<a class="task-title" href="/customers/{{.CustomerID}}">
|
||||
<span class="ticket" style="--tag:{{.PackageColor}}"><b>{{.CustomerTail}}</b>{{.CustomerName}}</span>
|
||||
@@ -189,7 +171,6 @@
|
||||
{{if .Urgent}}<span class="tag-urgent">加急</span>{{end}}
|
||||
</a>
|
||||
<div class="task-meta">
|
||||
<span class="asg{{if .AssigneeNone}} none{{end}}"><i style="background:{{.AssigneeHex}}"></i>{{.AssigneeLabel}}</span>
|
||||
<span>{{.RemainText}}</span>
|
||||
{{if .DueText}}<span class="due due-{{.Eval.Level}}">{{.DueText}}</span>{{end}}
|
||||
</div>
|
||||
@@ -205,14 +186,12 @@
|
||||
<details class="more-actions">
|
||||
<summary class="btn btn-sm btn-ghost" title="更多操作" aria-label="更多操作">⋯</summary>
|
||||
<div class="more-menu">
|
||||
{{if not .Season}}
|
||||
<form method="post" action="/subscriptions/{{.ID}}/checkin">
|
||||
<input type="hidden" name="date" value="{{$.D.Selected}}">
|
||||
<input type="hidden" name="status" value="skipped">
|
||||
<input type="hidden" name="back" value="{{$.D.Back}}">
|
||||
<button class="btn btn-sm btn-ghost" type="submit">跳过这次</button>
|
||||
</form>
|
||||
{{end}}
|
||||
<form method="post" action="/tasks/urgent">
|
||||
<input type="hidden" name="sub_id" value="{{.ID}}">
|
||||
<input type="hidden" name="date" value="{{$.D.Selected}}">
|
||||
@@ -220,7 +199,7 @@
|
||||
<input type="hidden" name="back" value="{{$.D.Back}}">
|
||||
<button class="btn btn-sm {{if .Urgent}}btn-urgent{{else}}btn-ghost{{end}}" type="submit">{{if .Urgent}}取消加急{{else}}标记加急{{end}}</button>
|
||||
</form>
|
||||
{{if not (or .Season .Abyss)}}<a class="btn btn-soft btn-sm" href="/calendar?y={{$.D.Year}}&m={{$.D.Month}}&d={{$.D.Selected}}&{{$.D.FilterQuery}}&extend={{.ID}}#extend">追加时长</a>{{end}}
|
||||
<a class="btn btn-soft btn-sm" href="/calendar?y={{$.D.Year}}&m={{$.D.Month}}&d={{$.D.Selected}}&{{$.D.FilterQuery}}&extend={{.ID}}#extend">追加时长</a>
|
||||
</div>
|
||||
</details>
|
||||
</div>
|
||||
|
||||
@@ -11,18 +11,11 @@
|
||||
</div>
|
||||
</div>
|
||||
<div class="page-actions">
|
||||
<form method="post" action="/customers/{{.D.Customer.ID}}/assignee" class="assign-form">
|
||||
<select name="assignee_id" aria-label="归属打手">
|
||||
<option value="0">未指派</option>
|
||||
{{range .D.Users}}<option value="{{.ID}}"{{if eq $.D.Customer.AssigneeID .ID}} selected{{end}}>{{if .DisplayName}}{{.DisplayName}}{{else}}{{.Username}}{{end}}</option>{{end}}
|
||||
</select>
|
||||
<button class="btn btn-soft btn-sm" type="submit">保存打手</button>
|
||||
</form>
|
||||
<a class="btn btn-soft" href="/customers/{{.D.Customer.ID}}/edit">编辑资料</a>
|
||||
{{if .D.Customer.Archived}}
|
||||
<form method="post" action="/customers/{{.D.Customer.ID}}/restore"><button class="btn btn-soft" type="submit">恢复客户</button></form>
|
||||
{{else}}
|
||||
<form method="post" action="/customers/{{.D.Customer.ID}}/archive" data-confirm="停用后该客户不再出现在日历和大屏,订阅会保留。确定停用?"><button class="btn btn-ghost" type="submit">停用客户</button></form>
|
||||
<form method="post" action="/customers/{{.D.Customer.ID}}/archive" data-confirm="停用后该客户不再出现在日历,订阅会保留。确定停用?"><button class="btn btn-ghost" type="submit">停用客户</button></form>
|
||||
{{end}}
|
||||
<form method="post" action="/customers/{{.D.Customer.ID}}/delete" data-confirm="将永久删除该客户及其全部订阅、打卡与追加记录,无法恢复。确定删除?">
|
||||
<input type="hidden" name="confirm" value="delete">
|
||||
@@ -35,9 +28,6 @@
|
||||
{{if .D.Customer.GameServer}}<div><dt>区服</dt><dd>{{.D.Customer.GameServer}}</dd></div>{{end}}
|
||||
{{if .D.Customer.Contact}}<div><dt>联系</dt><dd>{{.D.Customer.Contact}}</dd></div>{{end}}
|
||||
{{if .D.Customer.Source}}<div><dt>来源</dt><dd>{{.D.Customer.Source}}</dd></div>{{end}}
|
||||
<div><dt>打手</dt><dd>
|
||||
<span class="asg{{if eq .D.Customer.AssigneeID 0}} none{{end}}"><i style="background:{{if .D.Customer.AssigneeColor}}{{.D.Customer.AssigneeColor}}{{else}}#8A8F98{{end}}"></i>{{if .D.Customer.AssigneeName}}{{.D.Customer.AssigneeName}}{{else}}未指派{{end}}</span>
|
||||
</dd></div>
|
||||
<div><dt>建档</dt><dd>{{.D.Customer.CreatedAt}}</dd></div>
|
||||
</dl>
|
||||
</header>
|
||||
@@ -89,23 +79,17 @@
|
||||
<select class="form-select form-select-sm" name="package_id" required data-pkg-select aria-label="选择套餐">
|
||||
<option value="">选择套餐…</option>
|
||||
{{range .D.Packages}}
|
||||
<option value="{{.ID}}" data-unit="{{if .Season}}season{{else if .Abyss}}abyss{{else}}{{.Unit}}{{end}}" data-amount="{{.DefaultAmount}}" data-validity="{{.DefaultValidityDays}}"{{if .Archived}} disabled{{end}}{{if .SeasonExpired $.TodayStr}} disabled{{end}}>
|
||||
{{.Name}} · {{.UnitLabel}} {{if .Season}}{{.SeasonStart}}~{{.SeasonEnd}}{{else if .Abyss}}{{.CycleDays}} 天/周期 × {{.DefaultAmount}} 周期{{else}}{{.DefaultAmount}}{{if eq .Unit "day"}}天{{else}}次{{end}}{{end}}{{if .SeasonExpired $.TodayStr}}(通行证已结束){{end}}{{if .Archived}}(已归档){{end}}
|
||||
<option value="{{.ID}}" data-amount="{{.DefaultAmount}}"{{if .Archived}} disabled{{end}}>
|
||||
{{.Name}} · {{.UnitLabel}} {{.DefaultAmount}} 天{{if .Archived}}(已归档){{end}}
|
||||
</option>
|
||||
{{end}}
|
||||
</select>
|
||||
<label class="inline-field" data-start-wrap>开始日
|
||||
<input class="form-control form-control-sm" type="date" name="start_date" value="{{.TodayStr}}" required>
|
||||
</label>
|
||||
<label class="inline-field" data-days-wrap>{{/* 默认显示 */}}
|
||||
<label class="inline-field" data-days-wrap>
|
||||
天数 <input class="form-control form-control-sm" type="number" name="days" min="1" max="3650" value="30">
|
||||
</label>
|
||||
<label class="inline-field" data-count-wrap hidden>
|
||||
次数 <input class="form-control form-control-sm" type="number" name="total_count" min="1" max="10000" value="10">
|
||||
</label>
|
||||
<label class="inline-field" data-cycles-wrap hidden>
|
||||
周期数 <input class="form-control form-control-sm" type="number" name="total_count" min="1" max="1000" value="4">
|
||||
</label>
|
||||
<label class="inline-field" data-end-wrap>
|
||||
终止日(可留空)<input class="form-control form-control-sm" type="date" name="end_date">
|
||||
</label>
|
||||
@@ -163,9 +147,7 @@
|
||||
<td class="mono small">{{if .BaseDate}}{{.BaseDate}}{{else}}—{{end}}</td>
|
||||
<td class="mono small">{{if .OldEndDate}}{{.OldEndDate}} → {{end}}{{if .NewEndDate}}{{.NewEndDate}}{{else}}—{{end}}</td>
|
||||
<td class="mono">
|
||||
{{if gt .DaysAdded 0}}<span class="plus">+{{.DaysAdded}} 天</span>{{end}}
|
||||
{{if gt .CountAdded 0}}<span class="plus">+{{.CountAdded}} 次</span>{{end}}
|
||||
{{if and (le .DaysAdded 0) (le .CountAdded 0)}}—{{end}}
|
||||
{{if gt .DaysAdded 0}}<span class="plus">+{{.DaysAdded}} 天</span>{{else}}—{{end}}
|
||||
</td>
|
||||
<td class="small">{{if .Note}}{{.Note}}{{else}}—{{end}}</td>
|
||||
<td class="small">{{if .OperatorName}}{{.OperatorName}}{{else}}—{{end}}</td>
|
||||
|
||||
@@ -29,24 +29,13 @@
|
||||
<label class="field"><span>联系方式</span>
|
||||
<input type="text" name="contact" value="{{.D.Customer.Contact}}" maxlength="64" placeholder="微信 / QQ">
|
||||
</label>
|
||||
<label class="field"><span>归属打手</span>
|
||||
<select name="assignee_id">
|
||||
<option value="0"{{if eq .D.Customer.AssigneeID 0}} selected{{end}}>未指派</option>
|
||||
{{range .D.Users}}
|
||||
<option value="{{.ID}}"{{if eq $.D.Customer.AssigneeID .ID}} selected{{end}}>{{if .DisplayName}}{{.DisplayName}}{{else}}{{.Username}}{{end}}</option>
|
||||
{{end}}
|
||||
</select>
|
||||
<small>该客户之后的所有单子都记在这个打手名下</small>
|
||||
</label>
|
||||
</div>
|
||||
<div class="grid-2">
|
||||
<label class="field"><span>来源渠道</span>
|
||||
<input type="text" name="source" value="{{.D.Customer.Source}}" maxlength="32" placeholder="抖音 / 朋友介绍">
|
||||
</label>
|
||||
<label class="field"><span>标签</span>
|
||||
<input type="text" name="tags" value="{{.D.Customer.Tags}}" maxlength="120" placeholder="老客户,包月,难缠(逗号分隔)">
|
||||
</label>
|
||||
</div>
|
||||
<label class="field"><span>标签</span>
|
||||
<input type="text" name="tags" value="{{.D.Customer.Tags}}" maxlength="120" placeholder="老客户,包月,难缠(逗号分隔)">
|
||||
</label>
|
||||
<label class="field"><span>备注</span>
|
||||
<textarea name="note" rows="3" maxlength="500" placeholder="打法偏好、沟通记录等">{{.D.Customer.Note}}</textarea>
|
||||
</label>
|
||||
|
||||
@@ -2,9 +2,9 @@
|
||||
<div class="auth">
|
||||
<button class="theme-toggle auth-theme" type="button" data-theme-toggle aria-label="切换亮色/暗色" aria-pressed="false"><span class="ic-moon" aria-hidden="true">☾</span><span class="ic-sun" aria-hidden="true">☀</span></button>
|
||||
<div class="auth-card">
|
||||
<div class="auth-brand"><span class="brand-mark" aria-hidden="true">代</span><span>代打台</span></div>
|
||||
<div class="auth-brand"><span class="brand-mark" aria-hidden="true">代</span><span>代打台-L</span></div>
|
||||
<h1>登录</h1>
|
||||
<p>所有账户均为管理员,任何操作都会留痕。</p>
|
||||
<p>只有一个管理员账户,任何操作都会留痕。</p>
|
||||
<form method="post" action="/login" class="stack">
|
||||
<input type="hidden" name="next" value="{{.Next}}">
|
||||
<label class="field"><span>用户名</span>
|
||||
@@ -15,7 +15,7 @@
|
||||
</label>
|
||||
<button type="submit" class="btn btn-primary btn-block">登录</button>
|
||||
</form>
|
||||
<p class="auth-foot">代打台 · 单文件部署 · 数据只在本机</p>
|
||||
<p class="auth-foot">代打台-L · 单文件部署 · 数据只在本机</p>
|
||||
</div>
|
||||
</div>
|
||||
{{end}}
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
<div>
|
||||
<h1>{{.D.Package.Name}}</h1>
|
||||
<p>
|
||||
{{.D.Package.UnitLabel}} · {{.D.Package.AmountText}}{{if .D.Package.CycleLabel}} · {{.D.Package.CycleLabel}}{{end}}
|
||||
{{.D.Package.UnitLabel}} · {{.D.Package.AmountText}}
|
||||
{{if .D.Package.Tag}} · 标签「{{.D.Package.Tag}}」{{end}}{{if .D.Package.CalendarSeparate}} · 独立日历{{end}}
|
||||
{{if .D.Package.Archived}}<span class="chip chip-closed">已归档</span>{{end}}
|
||||
</p>
|
||||
@@ -26,21 +26,8 @@
|
||||
|
||||
<form method="post" action="/packages/{{.D.Package.ID}}/subscribe" class="section card">
|
||||
<h2>批量开通</h2>
|
||||
<p class="muted small">勾选客户后一次开通;已经是该套餐的客户会自动跳过。{{if .D.Package.Season}}通行证从套餐区间开始,整段完成。{{else if .D.Package.Abyss}}按周期数开通,结束日自动计算。{{else}}开始日期默认今天,数量默认取套餐设置,可改。{{end}}</p>
|
||||
<p class="muted small">勾选客户后一次开通;已经是该套餐的客户会自动跳过。开始日期默认今天,天数默认取套餐设置,可改。</p>
|
||||
|
||||
{{if .D.Package.Abyss}}
|
||||
<div class="grid-2">
|
||||
<label class="field"><span>开始日期</span>
|
||||
<input type="date" name="start_date" value="{{.D.Today}}" required>
|
||||
</label>
|
||||
<label class="field"><span>周期数</span>
|
||||
<input type="number" name="total_count" min="1" max="1000" value="{{.D.Package.DefaultAmount}}">
|
||||
</label>
|
||||
</div>
|
||||
<p class="muted small">每 {{.D.Package.CycleDays}} 天一个周期,共 {{.D.Package.DefaultAmount}} 个周期;结束日按开始日自动计算。</p>
|
||||
{{else if .D.Package.Season}}
|
||||
<p class="muted small">通行证区间:{{.D.Package.SeasonStart}} → {{.D.Package.SeasonEnd}},开通后整段完成,不再按天排单。</p>
|
||||
{{else if eq .D.Package.Unit "day"}}
|
||||
<div class="grid-auto">
|
||||
<label class="field"><span>开始日期</span>
|
||||
<input type="date" name="start_date" value="{{.D.Today}}" required>
|
||||
@@ -49,19 +36,6 @@
|
||||
<input type="number" name="days" min="1" max="3650" value="{{.D.Package.DefaultAmount}}">
|
||||
</label>
|
||||
</div>
|
||||
{{else}}
|
||||
<div class="grid-auto">
|
||||
<label class="field"><span>开始日期</span>
|
||||
<input type="date" name="start_date" value="{{.D.Today}}" required>
|
||||
</label>
|
||||
<label class="field"><span>次数</span>
|
||||
<input type="number" name="total_count" min="1" max="10000" value="{{.D.Package.DefaultAmount}}">
|
||||
</label>
|
||||
<label class="field"><span>到期日(可选)</span>
|
||||
<input type="date" name="end_date">
|
||||
</label>
|
||||
</div>
|
||||
{{end}}
|
||||
|
||||
<div class="table-wrap">
|
||||
<table class="table tight">
|
||||
@@ -77,7 +51,7 @@
|
||||
<tr{{if $subscribed}} class="archived"{{end}}>
|
||||
<td>{{if $subscribed}}<span class="muted small" title="已是此套餐">—</span>{{else}}<input type="checkbox" name="customer_ids" value="{{.ID}}" aria-label="选择 {{.Name}}" checked>{{end}}</td>
|
||||
<td><a class="tail" href="/customers/{{.ID}}">{{.Tail}}</a></td>
|
||||
<td>{{.Name}}{{if .AssigneeName}} <span class="asg"><i style="background:{{.AssigneeColor}}"></i>{{.AssigneeName}}</span>{{end}}</td>
|
||||
<td>{{.Name}}</td>
|
||||
<td class="summary due-{{.Level}}">{{.Summary}}</td>
|
||||
<td>{{if $subscribed}}<span class="chip chip-closed">已是此套餐</span>{{else}}<span class="chip chip-plain">可开通</span>{{end}}</td>
|
||||
</tr>
|
||||
|
||||
@@ -3,51 +3,21 @@
|
||||
<header class="page-head">
|
||||
<div>
|
||||
<h1>{{if .D.IsNew}}新增套餐{{else}}编辑套餐{{end}}</h1>
|
||||
<p>按日套餐用起止日期计算剩余天数;按次套餐记录剩余次数;通行证整段完成;深渊按周期完成。</p>
|
||||
<p>按日套餐用起止日期计算剩余天数;给客户开通时选择开始日与天数即可。</p>
|
||||
</div>
|
||||
</header>
|
||||
|
||||
<form method="post" class="form card" data-package-form
|
||||
action="{{if .D.IsNew}}/packages{{else}}/packages/{{.D.Package.ID}}/edit{{end}}">
|
||||
<label class="field"><span>套餐名称 <i>*</i></span>
|
||||
<input type="text" name="name" required maxlength="32" value="{{.D.Package.Name}}" placeholder="例如 包月日常 / 深渊通行证 / 10 次副本">
|
||||
<input type="text" name="name" required maxlength="32" value="{{.D.Package.Name}}" placeholder="例如 包月日常 / 深渊日常">
|
||||
</label>
|
||||
|
||||
<fieldset class="field">
|
||||
<span>计费方式 <i>*</i></span>
|
||||
<div class="radios">
|
||||
<label><input type="radio" name="unit" value="day"{{if and (eq .D.Package.Unit "day") (not .D.Package.Season) (not .D.Package.Abyss)}} checked{{end}}>
|
||||
<b>按日</b><small>有开始日与结束日,每天一条待打任务,可打卡</small></label>
|
||||
<label><input type="radio" name="unit" value="count"{{if and (eq .D.Package.Unit "count") (not .D.Package.Season) (not .D.Package.Abyss)}} checked{{end}}>
|
||||
<b>按次</b><small>记录剩余次数,排期完成时自动扣 1 次,有效期可选</small></label>
|
||||
<label><input type="radio" name="unit" value="season"{{if .D.Package.Season}} checked{{end}}>
|
||||
<b>通行证</b><small>通行证有效期内整段一次完成;日历上连续着色,每天显示同一个完成数</small></label>
|
||||
<label><input type="radio" name="unit" value="abyss"{{if .D.Package.Abyss}} checked{{end}}>
|
||||
<b>深渊</b><small>N 天一个周期,周期内任意一天完成即算该周期完成;按周期数计数</small></label>
|
||||
</div>
|
||||
</fieldset>
|
||||
|
||||
<div class="grid-2" data-season-wrap hidden>
|
||||
<label class="field"><span>通行证开始日 <i>*</i></span><input type="date" name="season_start" value="{{.D.Package.SeasonStart}}"></label>
|
||||
<label class="field"><span>通行证结束日 <i>*</i></span><input type="date" name="season_end" value="{{.D.Package.SeasonEnd}}"></label>
|
||||
</div>
|
||||
|
||||
<div class="field field-narrow" data-abyss-wrap hidden>
|
||||
<span>周期天数 N <i>*</i></span>
|
||||
<input type="number" name="cycle_days" min="1" max="365" value="{{if .D.Package.Abyss}}{{.D.Package.CycleDays}}{{else}}7{{end}}" placeholder="例如 7">
|
||||
<small>N 天一个周期;下方「周期数」填 X。开通后从开始日连续排 X 个周期。</small>
|
||||
</div>
|
||||
|
||||
<div class="field field-narrow" data-validity-wrap hidden>
|
||||
<span>按次默认有效期(天,0 = 不限)</span>
|
||||
<input type="number" name="default_validity_days" min="0" max="3650" value="{{.D.Package.DefaultValidityDays}}">
|
||||
</div>
|
||||
|
||||
<div class="grid-2">
|
||||
<label class="field" data-amount-wrap><span><span data-amount-title>默认量</span> <i>*</i></span>
|
||||
<label class="field" data-amount-wrap><span><span data-amount-title>默认天数</span> <i>*</i></span>
|
||||
<div class="input-suffix">
|
||||
<input type="number" name="default_amount" min="1" max="10000" value="{{.D.Package.DefaultAmount}}" required>
|
||||
<b data-unit-label>{{if eq .D.Package.Unit "count"}}次{{else}}天{{end}}</b>
|
||||
<b data-unit-label>天</b>
|
||||
</div>
|
||||
</label>
|
||||
<label class="field"><span>参考价(元,可空)</span>
|
||||
@@ -71,7 +41,7 @@
|
||||
|
||||
<label class="check-line">
|
||||
<input type="checkbox" name="calendar_separate" value="1"{{if .D.Package.CalendarSeparate}} checked{{end}}>
|
||||
<span>在日历中独立显示<small>通行证 / 深渊建议勾选:会单独开一个标签页,按色块连续展示,和其他日常任务分开看</small></span>
|
||||
<span>在日历中独立显示<small>勾选后会单独开一个标签页,和其他日常任务分开看</small></span>
|
||||
</label>
|
||||
|
||||
<label class="field"><span>说明</span>
|
||||
|
||||
@@ -1,125 +0,0 @@
|
||||
{{define "content"}}
|
||||
<div class="portal-wrap">
|
||||
<header class="portal-head">
|
||||
<a class="portal-brand" href="/customer"><span class="brand-mark" aria-hidden="true">代</span><span>代打台</span></a>
|
||||
<h1>排单查询</h1>
|
||||
<p class="muted">输入手机尾号查看自己的排单与完成情况。</p>
|
||||
</header>
|
||||
|
||||
{{if .InlineError}}<div class="notice notice-danger portal-error" id="portal-error" role="alert">{{.InlineError}}</div>{{end}}
|
||||
|
||||
<details class="portal-search" {{if or (not .Query) .InlineError}}open{{end}}>
|
||||
<summary class="portal-search-head">{{if .InlineError}}修改查询{{else if .Query}}查询其他尾号{{else}}输入手机尾号查询{{end}}</summary>
|
||||
<form class="portal-form" method="get" action="/customer">
|
||||
<div class="portal-form-body">
|
||||
<div class="row g-2 align-items-end">
|
||||
<div class="col-12 col-sm-4">
|
||||
<label class="form-label" for="tail">手机尾号(4–8 位)</label>
|
||||
<input class="form-control" id="tail" name="tail" value="{{.Query}}" inputmode="numeric" pattern="[0-9]{4,8}" minlength="4" maxlength="8" placeholder="例如 2300" required{{if not .Query}} autofocus{{end}}{{if eq .InvalidField "tail"}} aria-invalid="true" aria-describedby="portal-error"{{end}}>
|
||||
</div>
|
||||
<div class="col-12 col-sm-4">
|
||||
<label class="form-label" for="name">客户姓名(可选)</label>
|
||||
<input class="form-control" id="name" name="name" value="{{.Name}}" maxlength="32" placeholder="尾号重复时填写"{{if eq .InvalidField "name"}} aria-invalid="true" aria-describedby="portal-error"{{end}}>
|
||||
</div>
|
||||
<div class="col-12 col-sm-4">
|
||||
<button class="btn btn-primary w-100" type="submit">查询</button>
|
||||
</div>
|
||||
</div>
|
||||
<p class="muted small mb-0 mt-2">只显示排单与完成情况,不含备注与价格。</p>
|
||||
</div>
|
||||
</form>
|
||||
</details>
|
||||
|
||||
{{with .D}}
|
||||
{{if .Masked}}
|
||||
<section class="portal-result">
|
||||
<div class="card mt-3"><div class="card-body">
|
||||
<h2 class="h5">找到 {{.Count}} 位客户</h2>
|
||||
<p class="muted mb-2">尾号 {{.Tail}} 对应多位客户,请补一个姓名后查询。</p>
|
||||
{{if .Masked}}<p class="portal-ask-names">可能是:{{range $i, $n := .Masked}}{{if $i}}、{{end}}{{$n}}{{end}}</p>{{end}}
|
||||
<form class="portal-ask-form" method="get" action="/customer">
|
||||
<input type="hidden" name="tail" value="{{.Tail}}">
|
||||
<label class="visually-hidden" for="ask-name">姓名</label>
|
||||
<input class="form-control" id="ask-name" name="name" maxlength="32" placeholder="输入姓名(可只填一部分)" required autofocus>
|
||||
<button class="btn btn-primary" type="submit">查询</button>
|
||||
</form>
|
||||
</div></div>
|
||||
</section>
|
||||
{{else}}
|
||||
<section class="portal-result">
|
||||
{{if .Subs}}
|
||||
<div class="card mt-3"><div class="card-body">
|
||||
<div class="portal-client">
|
||||
<div class="portal-client-main">
|
||||
<h2 class="portal-client-name">{{.Tail}} · {{.Name}}</h2>
|
||||
<div class="portal-client-meta">
|
||||
{{if .Game}}<span class="tagchip">{{.Game}}</span>{{end}}
|
||||
{{if .Expiring}}<span class="tagchip">最近到期 {{.Expiring}}</span>{{end}}
|
||||
</div>
|
||||
</div>
|
||||
<div class="portal-client-status">
|
||||
{{if eq .TodayState "done"}}<span class="chip chip-active">今日已清完</span>
|
||||
{{else if eq .TodayState "pending"}}<span class="chip chip-plain">今日待完成 {{.TodayPending}} / {{.TodayTotal}}</span>
|
||||
{{else}}<span class="chip chip-plain">今日无排单</span>{{end}}
|
||||
</div>
|
||||
</div>
|
||||
</div></div>
|
||||
|
||||
<div class="card mt-3"><div class="card-body">
|
||||
<div class="portal-section-head"><h2>订阅</h2><span class="portal-section-count">{{.SubCount}}</span></div>
|
||||
<div class="portal-sub-list">
|
||||
{{range .Subs}}
|
||||
<article class="portal-sub">
|
||||
<div class="portal-sub-main">
|
||||
<strong>{{.PackageName}}</strong>
|
||||
<span class="tagchip">{{.UnitLabel}}</span>
|
||||
{{if .TodayLabel}}<span class="chip chip-{{.TodayClass}}">{{.TodayLabel}}</span>{{else}}{{template "state-chip" .}}{{end}}
|
||||
</div>
|
||||
<div class="portal-sub-meta">
|
||||
<span>{{.RemainText}}</span>
|
||||
<span class="muted">{{.PeriodText}}</span>
|
||||
</div>
|
||||
</article>
|
||||
{{end}}
|
||||
</div>
|
||||
</div></div>
|
||||
|
||||
<div class="card mt-3"><div class="card-body">
|
||||
<div class="portal-section-head">
|
||||
<h2>当月排单</h2>
|
||||
<div class="pcal-nav">
|
||||
<a class="btn btn-soft pcal-nav-btn" href="{{.Prev}}" aria-label="上个月">‹</a>
|
||||
<b>{{.MonthTitle}}</b>
|
||||
<a class="btn btn-soft pcal-nav-btn" href="{{.Next}}" aria-label="下个月">›</a>
|
||||
</div>
|
||||
</div>
|
||||
<div class="pcal" role="grid" aria-label="{{.MonthTitle}}排单">
|
||||
<div class="pcal-dow" role="row">
|
||||
<span role="columnheader">一</span><span role="columnheader">二</span><span role="columnheader">三</span><span role="columnheader">四</span><span role="columnheader">五</span><span role="columnheader">六</span><span role="columnheader">日</span>
|
||||
</div>
|
||||
{{range .Weeks}}
|
||||
<div class="pcal-row" role="row">
|
||||
{{range .}}
|
||||
<div class="pcal-cell{{if not .InMonth}} out{{end}}{{if .Today}} today{{end}}{{if .BlockColor}} has-block{{end}}" role="gridcell" aria-label="{{.Label}}"{{if .BlockColor}} style="--block:{{.BlockColor}};--block-pct:{{.BlockPercent}}%"{{end}}>
|
||||
<b>{{.Day}}</b>
|
||||
{{if .Today}}<i class="pcal-today">今天</i>{{end}}
|
||||
{{if .BlockText}}<span class="pcal-block" title="{{.BlockTitle}}">{{.BlockText}}</span>{{end}}
|
||||
{{if .Total}}{{if eq .Total 1}}<span class="pcal-dot{{if .Done}} done{{end}}" title="{{.Done}}/{{.Total}} 单"></span>{{else}}<span class="pcal-count">{{.Done}}/{{.Total}}</span>{{end}}{{end}}
|
||||
</div>
|
||||
{{end}}
|
||||
</div>
|
||||
{{end}}
|
||||
</div>
|
||||
</div></div>
|
||||
{{else}}
|
||||
<div class="card mt-3"><div class="card-body">
|
||||
<h2 class="h4 mb-1">{{.Tail}} · {{.Name}}</h2>
|
||||
<div class="portal-client-meta">{{if .Game}}<span class="tagchip">{{.Game}}</span>{{end}}</div>
|
||||
<p class="muted mb-0 mt-3">还没有进行中的订阅。如需开通,请联系你的代打。</p>
|
||||
</div></div>
|
||||
{{end}}
|
||||
</section>
|
||||
{{end}}
|
||||
{{end}}
|
||||
</div>
|
||||
{{end}}
|
||||
@@ -1,157 +0,0 @@
|
||||
{{define "content"}}
|
||||
<div class="scr" data-pkg="{{.D.PkgID}}" data-heat="{{.D.HeatMode}}" data-api="/api/screen/day">
|
||||
<header class="scr-head">
|
||||
<div class="scr-brand"><span class="mark" aria-hidden="true">代</span>代打台<em>控制台</em></div>
|
||||
|
||||
{{if .D.HasTabs}}
|
||||
<nav class="scr-tabs">
|
||||
{{range .D.Tabs}}
|
||||
<a class="{{if .Active}}on{{end}}" style="--tab:{{.Color}}" href="{{.Href}}">{{.Name}}</a>
|
||||
{{end}}
|
||||
</nav>
|
||||
{{end}}
|
||||
|
||||
<div class="scr-tools">
|
||||
<a class="scr-switch" href="/screen?{{.D.FilterQuery}}&heat={{if eq .D.HeatMode "due"}}task{{else}}due{{end}}"
|
||||
title="切换热力统计口径">
|
||||
{{if eq .D.HeatMode "due"}}热力:到期{{else}}热力:待完成{{end}} ⇄
|
||||
</a>
|
||||
<button class="scr-theme" type="button" data-theme-toggle aria-label="切换亮色/暗色" aria-pressed="false">
|
||||
<span class="ic-moon" aria-hidden="true">☾</span><span class="ic-sun" aria-hidden="true">☀</span>
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<div class="scr-clock"><b data-clock>--:--:--</b><span data-date></span></div>
|
||||
<div class="scr-links">每 {{.D.Refresh}} 秒刷新 · <a href="/calendar">进入工作台</a></div>
|
||||
</header>
|
||||
|
||||
<section class="scr-kpis">
|
||||
<div class="kpi">
|
||||
<span>客户</span><b>{{.D.Stats.Customers}}</b><i>位</i>
|
||||
</div>
|
||||
<div class="kpi">
|
||||
<span>活跃订阅</span><b>{{.D.Stats.ActiveSubs}}</b><i>条</i>
|
||||
</div>
|
||||
<div class="kpi kpi-hot">
|
||||
<span>今日到期</span><b>{{.D.Stats.DueToday}}</b><i>条</i>
|
||||
</div>
|
||||
<div class="kpi kpi-warm">
|
||||
<span>7 天内到期</span><b>{{.D.Stats.Due7}}</b><i>条</i>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<section class="scr-main">
|
||||
<div class="panel panel-cal">
|
||||
<div class="panel-head">
|
||||
<h2>{{if eq .D.HeatMode "due"}}到期热力{{else}}每日待完成{{end}}</h2>
|
||||
<span>{{.D.MonthTitle}} · 本月合计 {{.D.HeatTotal}} 单</span>
|
||||
</div>
|
||||
<div class="heat-grid">
|
||||
<div class="heat-dow">{{range .D.Weekdays}}<span>{{.}}</span>{{end}}</div>
|
||||
{{range .D.Weeks}}
|
||||
<div class="heat-row">
|
||||
{{range .}}
|
||||
<div class="heat-cell h{{.Heat}}{{if not .InMonth}} out{{end}}{{if .IsToday}} today{{end}}{{if .IsPast}} past{{end}}{{if .BlockColor}} has-block{{end}}"
|
||||
data-date="{{.Date}}" title="{{if .BlockTitle}}{{.BlockTitle}} · {{end}}{{.Date}}"{{if .BlockColor}} style="--block:{{.BlockColor}};--block-pct:{{.BlockPercent}}%"{{end}}>
|
||||
{{if .Strip}}<span class="asg-strip sm" aria-hidden="true">{{range .Strip}}<i style="background:{{.}}"></i>{{end}}</span>{{end}}
|
||||
<span>{{.Day}}</span>
|
||||
{{if gt .Urgent 0}}<u class="cell-urgent"></u>{{end}}
|
||||
{{if and .BlockText (not .Count)}}<b class="scr-block">{{.BlockText}}</b>{{else if .Count}}<b>{{.Done}}/{{.Count}}</b>{{end}}
|
||||
</div>
|
||||
{{end}}
|
||||
</div>
|
||||
{{end}}
|
||||
</div>
|
||||
<div class="heat-legend">
|
||||
<span>{{if eq .D.HeatMode "due"}}到期数{{else}}待完成单量{{end}}</span>
|
||||
<i class="h0"></i><i class="h1"></i><i class="h2"></i><i class="h3"></i><i class="h4"></i>
|
||||
<em class="legend-hint">悬停格子看当日明细</em>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="panel panel-top">
|
||||
<div class="panel-head"><h2>即将到期 TOP 10</h2><span>按剩余量排序</span></div>
|
||||
{{if .D.Top}}
|
||||
<ol class="top-list">
|
||||
{{range $i, $s := .D.Top}}
|
||||
<li class="top-item lv-{{$s.Eval.Level}}">
|
||||
<span class="rank">{{add $i 1}}</span>
|
||||
<span class="top-tail">{{$s.CustomerTail}}</span>
|
||||
<span class="top-name">{{$s.CustomerName}}</span>
|
||||
<span class="top-pkg" style="--tag:{{$s.PackageColor}}">{{$s.PackageName}}</span>
|
||||
<span class="top-remain">{{$s.RemainShort}}</span>
|
||||
<span class="top-bar"><i style="width:{{$s.Progress}}%"></i></span>
|
||||
</li>
|
||||
{{end}}
|
||||
</ol>
|
||||
{{else}}
|
||||
<p class="scr-empty">暂无订阅数据</p>
|
||||
{{end}}
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<section class="scr-bottom">
|
||||
<div class="panel">
|
||||
<div class="panel-head">
|
||||
<h2>今日到期</h2>
|
||||
<span>{{len .D.DueToday}} 条</span>
|
||||
</div>
|
||||
{{if .D.DueToday}}
|
||||
<ul class="today-list">
|
||||
{{range .D.DueToday}}
|
||||
<li class="lv-{{.Eval.Level}}">
|
||||
<span class="tchip" style="--tag:{{.PackageColor}}"><b>{{.CustomerTail}}</b>{{.CustomerName}}</span>
|
||||
<span class="pkg">{{.PackageName}}</span>
|
||||
<span class="rem">{{.RemainShort}}</span>
|
||||
</li>
|
||||
{{end}}
|
||||
</ul>
|
||||
{{else}}
|
||||
<p class="scr-empty">今天没有到期</p>
|
||||
{{end}}
|
||||
</div>
|
||||
|
||||
<div class="panel">
|
||||
<div class="panel-head">
|
||||
<h2>今日待打</h2>
|
||||
<span>{{.D.TodayDone}} / {{.D.TodayTasks}} 已完成{{if gt .D.TodayUrgent 0}} · 加急 {{.D.TodayUrgent}}{{end}}</span>
|
||||
</div>
|
||||
{{if .D.TodayList}}
|
||||
<ul class="today-list">
|
||||
{{range .D.TodayList}}
|
||||
<li class="{{if .Urgent}}urgent {{end}}lv-{{.Eval.Level}}">
|
||||
<span class="tchip" style="--tag:{{.PackageColor}}"><b>{{.CustomerTail}}</b>{{.CustomerName}}</span>
|
||||
<span class="pkg">{{.PackageName}}</span>
|
||||
<span class="asg{{if .AssigneeNone}} none{{end}}"><i style="background:{{.AssigneeHex}}"></i>{{.AssigneeLabel}}</span>
|
||||
{{if .Urgent}}<span class="tag-urgent">加急</span>{{end}}
|
||||
<span class="rem">{{.RemainShort}}</span>
|
||||
</li>
|
||||
{{end}}
|
||||
</ul>
|
||||
{{else}}
|
||||
<p class="scr-empty">今天没有待打任务</p>
|
||||
{{end}}
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<section class="scr-recent">
|
||||
<span class="recent-label">最近追加</span>
|
||||
{{if .D.Recent}}
|
||||
<div class="recent-track">
|
||||
{{range .D.Recent}}
|
||||
<span class="recent-item"><b>{{.CustomerTail}}</b>{{.CustomerName}} · {{.PackageName}}
|
||||
{{if gt .DaysAdded 0}}<em>+{{.DaysAdded}} 天</em>{{end}}
|
||||
{{if gt .CountAdded 0}}<em>+{{.CountAdded}} 次</em>{{end}}
|
||||
</span>
|
||||
{{end}}
|
||||
</div>
|
||||
{{else}}
|
||||
<span class="scr-empty-inline">还没有追加记录</span>
|
||||
{{end}}
|
||||
</section>
|
||||
|
||||
<footer class="scr-foot">代打台 v{{.D.Version}} · 数据每 {{.D.Refresh}} 秒自动刷新 · 按 F 全屏</footer>
|
||||
|
||||
<div class="day-pop" id="day-pop" hidden></div>
|
||||
</div>
|
||||
{{end}}
|
||||
@@ -3,73 +3,21 @@
|
||||
<header class="page-head">
|
||||
<div>
|
||||
<h1>设置</h1>
|
||||
<p>预警天数、备份、账户与数据导出</p>
|
||||
<p>预警天数、备份与数据导出</p>
|
||||
</div>
|
||||
</header>
|
||||
|
||||
<section class="section card">
|
||||
<h2>基础设置</h2>
|
||||
<form method="post" action="/settings" class="form">
|
||||
<div class="grid-2">
|
||||
<label class="field"><span>到期预警(天)</span>
|
||||
<input type="number" name="warn_days" min="0" max="60" value="{{.D.WarnDays}}">
|
||||
</label>
|
||||
<label class="field"><span>大屏自动刷新(秒)</span>
|
||||
<input type="number" name="screen_refresh" min="5" max="600" value="{{.D.ScreenRefresh}}">
|
||||
</label>
|
||||
</div>
|
||||
<label class="field field-narrow"><span>到期预警(天)</span>
|
||||
<input type="number" name="warn_days" min="0" max="60" value="{{.D.WarnDays}}">
|
||||
</label>
|
||||
<p class="muted small">监听地址、端口、数据库、备份、日志、时区等部署参数在 <code>daili.ini</code> 里配置,改完重启生效。</p>
|
||||
<div class="actions"><button class="btn btn-primary" type="submit">保存设置</button></div>
|
||||
</form>
|
||||
</section>
|
||||
|
||||
<section class="section card">
|
||||
<h2>管理员</h2>
|
||||
<p class="muted small">所有账户权限相同,任何操作都会记在日志里。每个管理员的颜色用于日历左侧竖条和待办标识。</p>
|
||||
<p class="muted small">{{if eq .User.ID 1}}你是初始管理员,可以点「编辑」修改其他管理员的用户名、昵称和密码。{{else}}只有初始管理员(首个账号)可以修改其他管理员的资料。{{end}}</p>
|
||||
<div class="table-wrap">
|
||||
<table class="table tight table-users">
|
||||
<thead><tr><th scope="col">用户名</th><th scope="col">显示名称</th><th scope="col">打手颜色</th><th scope="col">状态</th><th scope="col">创建时间</th><th scope="col">最近登录</th><th scope="col"><span class="visually-hidden">操作</span></th></tr></thead>
|
||||
<tbody>
|
||||
{{$me := .User}}
|
||||
{{range .D.Users}}
|
||||
<tr>
|
||||
<td class="mono">{{.Username}}</td>
|
||||
<td>{{.DisplayName}}</td>
|
||||
<td>
|
||||
<form method="post" action="/settings/users/{{.ID}}/color" class="color-form">
|
||||
<input type="color" name="color" value="{{if .Color}}{{.Color}}{{else}}#8A8F98{{end}}" title="打手颜色" aria-label="打手颜色">
|
||||
<button class="btn btn-soft btn-sm" type="submit">保存</button>
|
||||
</form>
|
||||
</td>
|
||||
<td>{{if .IsActive}}<span class="chip chip-active">启用</span>{{else}}<span class="chip chip-closed">停用</span>{{end}}</td>
|
||||
<td class="mono small">{{.CreatedAt}}</td>
|
||||
<td class="mono small">{{if .LastLoginAt}}{{.LastLoginAt}}{{else}}—{{end}}</td>
|
||||
<td class="actions-cell">
|
||||
{{if eq .ID $me.ID}}
|
||||
<span class="muted small">当前账户</span>
|
||||
{{else}}
|
||||
{{if eq $me.ID 1}}
|
||||
<a class="btn btn-soft btn-sm" href="/settings/users/{{.ID}}/edit">编辑</a>
|
||||
{{end}}
|
||||
<form method="post" action="/settings/users/{{.ID}}/toggle">
|
||||
<button class="btn btn-ghost btn-sm">{{if .IsActive}}停用{{else}}启用{{end}}</button>
|
||||
</form>
|
||||
{{end}}
|
||||
</td>
|
||||
</tr>
|
||||
{{end}}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<form method="post" action="/settings/users" class="inline-form">
|
||||
<label class="inline-field">用户名 <input type="text" name="username" required minlength="3" maxlength="32" autocomplete="off"></label>
|
||||
<label class="inline-field">显示名称 <input type="text" name="display_name" maxlength="32"></label>
|
||||
<label class="inline-field">初始密码 <input type="password" name="password" required minlength="6" autocomplete="new-password"></label>
|
||||
<button class="btn btn-primary" type="submit">新增管理员</button>
|
||||
</form>
|
||||
</section>
|
||||
|
||||
<section class="section card">
|
||||
<h2>修改我的密码</h2>
|
||||
<form method="post" action="/settings/password" class="form">
|
||||
@@ -88,9 +36,7 @@
|
||||
<div><dt>配置文件</dt><dd class="mono small">{{.D.ConfigPath}} <span class="muted">(修改后重启生效)</span></dd></div>
|
||||
<div><dt>数据库</dt><dd class="mono small">{{.D.DBPath}}</dd></div>
|
||||
<div><dt>备份</dt><dd class="mono small">{{.D.BackupDir}} · 保留 {{.D.BackupKeep}} 份 · {{if .D.BackupEnabled}}自动备份已开启{{else}}自动备份已关闭{{end}}</dd></div>
|
||||
<div><dt>大屏</dt><dd class="mono small">/screen {{if .D.ScreenPublic}}免登录{{else}}需登录{{end}}</dd></div>
|
||||
<div><dt>客户自助</dt><dd class="mono small">/customer {{if .D.PortalPublic}}免登录{{else}}已关闭{{end}}</dd></div>
|
||||
<div><dt>局域网地址</dt><dd class="mono small">http://{{if .D.Addrs}}{{index .D.Addrs 0}}{{else}}127.0.0.1{{end}}:{{.D.Port}}/screen</dd></div>
|
||||
<div><dt>局域网地址</dt><dd class="mono small">http://{{if .D.Addrs}}{{index .D.Addrs 0}}{{else}}127.0.0.1{{end}}:{{.D.Port}}</dd></div>
|
||||
<div><dt>已运行</dt><dd class="mono">{{.D.Uptime}}</dd></div>
|
||||
<div><dt>数据量</dt><dd>{{.D.CustomerCount}} 位客户 · {{.D.PackageCount}} 个套餐 · {{.D.LogCount}} 条日志</dd></div>
|
||||
</dl>
|
||||
|
||||
@@ -2,17 +2,16 @@
|
||||
<div class="auth">
|
||||
<button class="theme-toggle auth-theme" type="button" data-theme-toggle aria-label="切换亮色/暗色" aria-pressed="false"><span class="ic-moon" aria-hidden="true">☾</span><span class="ic-sun" aria-hidden="true">☀</span></button>
|
||||
<div class="auth-card">
|
||||
<div class="auth-brand"><span class="brand-mark" aria-hidden="true">代</span><span>代打台</span></div>
|
||||
<h1>创建第一个管理员</h1>
|
||||
<p>数据库里还没有账户。设置好账号后即可开始录入套餐与客户。</p>
|
||||
<div class="auth-brand"><span class="brand-mark" aria-hidden="true">代</span><span>代打台-L</span></div>
|
||||
<h1>创建管理员</h1>
|
||||
<p>数据库里还没有账户。创建后不能再添加其他管理员。</p>
|
||||
<form method="post" action="/setup" class="stack">
|
||||
<label class="field"><span>用户名</span>
|
||||
<input class="form-control" id="username" type="text" name="username" required minlength="3" maxlength="32" autocomplete="username" placeholder="建议用拼音或英文名">
|
||||
</label>
|
||||
<label class="field"><span>显示名称</span>
|
||||
<input class="form-control" id="display_name" type="text" name="display_name" maxlength="32" placeholder="例如:老王(可留空)">
|
||||
</label>
|
||||
<label class="field"><span>密码(至少 6 位)</span>
|
||||
</label> <label class="field"><span>密码(至少 6 位)</span>
|
||||
<input class="form-control" id="password" type="password" name="password" required minlength="6" autocomplete="new-password">
|
||||
</label>
|
||||
<label class="field"><span>再输一次密码</span>
|
||||
|
||||
@@ -49,7 +49,7 @@
|
||||
<td class="mono small">{{.PeriodText}}</td>
|
||||
<td class="actions-cell">
|
||||
{{if ne .Status "closed"}}
|
||||
{{if not (or .Season .Abyss)}}<a class="btn btn-soft btn-sm" href="/customers/{{.CustomerID}}?extend={{.ID}}#extend">追加</a>{{end}}
|
||||
<a class="btn btn-soft btn-sm" href="/customers/{{.CustomerID}}?extend={{.ID}}#extend">追加</a>
|
||||
{{if eq .Status "active"}}
|
||||
<form method="post" action="/subscriptions/{{.ID}}/pause"><button class="btn btn-ghost btn-sm">暂停</button></form>
|
||||
{{else if eq .Status "paused"}}
|
||||
|
||||
@@ -1,39 +0,0 @@
|
||||
{{define "content"}}
|
||||
<div class="page narrow">
|
||||
<header class="page-head">
|
||||
<div>
|
||||
<h1>编辑管理员</h1>
|
||||
<p class="muted">修改 {{.D.Target.Username}} 的登录名、昵称,或重置密码。</p>
|
||||
</div>
|
||||
<div class="page-actions">
|
||||
<a class="btn btn-ghost" href="/settings">返回设置</a>
|
||||
</div>
|
||||
</header>
|
||||
|
||||
<form method="post" action="/settings/users/{{.D.Target.ID}}/edit" class="form card">
|
||||
<div class="grid-2">
|
||||
<label class="field"><span>用户名 <i>*</i></span>
|
||||
<input type="text" name="username" value="{{.D.Target.Username}}" required minlength="3" maxlength="32" autocomplete="off">
|
||||
</label>
|
||||
<label class="field"><span>显示名称</span>
|
||||
<input type="text" name="display_name" value="{{.D.Target.DisplayName}}" maxlength="32" autocomplete="off">
|
||||
</label>
|
||||
</div>
|
||||
|
||||
<div class="grid-2">
|
||||
<label class="field"><span>新密码</span>
|
||||
<input type="password" name="password" minlength="6" autocomplete="new-password" placeholder="留空则不修改">
|
||||
</label>
|
||||
<label class="field"><span>再输一次</span>
|
||||
<input type="password" name="password2" minlength="6" autocomplete="new-password" placeholder="与上面一致">
|
||||
</label>
|
||||
</div>
|
||||
<p class="muted small">重置密码后该账户的登录会话会立即失效,需要用新密码重新登录。当前账户:{{.User.Username}}</p>
|
||||
|
||||
<div class="actions">
|
||||
<button class="btn btn-primary" type="submit">保存修改</button>
|
||||
<a class="btn btn-ghost" href="/settings">取消</a>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
{{end}}
|
||||
+11
-101
@@ -29,30 +29,8 @@ type SubView struct {
|
||||
Today string
|
||||
// CanCheckinToday 表示今天可以直接打卡(订阅在有效状态与区间内)
|
||||
CanCheckinToday bool
|
||||
// CanPassToday / CanAbyssToday 整段型订阅今天能否完成(在有效区间内且未完成)
|
||||
CanPassToday bool
|
||||
CanAbyssToday bool
|
||||
}
|
||||
|
||||
// AssigneeLabel 返回打手显示名;未指派时给灰字提示。
|
||||
func (v SubView) AssigneeLabel() string {
|
||||
if v.AssigneeName == "" {
|
||||
return "未指派"
|
||||
}
|
||||
return v.AssigneeName
|
||||
}
|
||||
|
||||
// AssigneeHex 返回打手颜色;未指派用中性灰。
|
||||
func (v SubView) AssigneeHex() string {
|
||||
if v.AssigneeColor == "" {
|
||||
return "#8A8F98"
|
||||
}
|
||||
return v.AssigneeColor
|
||||
}
|
||||
|
||||
// AssigneeNone 是否未指派。
|
||||
func (v SubView) AssigneeNone() bool { return v.AssigneeName == "" }
|
||||
|
||||
func stateLabel(state string) (string, string) {
|
||||
switch state {
|
||||
case domain.StateActive:
|
||||
@@ -63,8 +41,6 @@ func stateLabel(state string) (string, string) {
|
||||
return "暂停中", "paused"
|
||||
case domain.StateExpired:
|
||||
return "已到期", "expired"
|
||||
case domain.StateUsedUp:
|
||||
return "次数用尽", "usedup"
|
||||
case domain.StateClosed:
|
||||
return "已结束", "closed"
|
||||
}
|
||||
@@ -79,51 +55,15 @@ func newSubView(s store.Subscription, today time.Time, warnDays int) SubView {
|
||||
Eval: e,
|
||||
StateLabel: label,
|
||||
StateClass: class,
|
||||
UnitLabel: "按日",
|
||||
Today: domain.Date(today),
|
||||
}
|
||||
if s.Season {
|
||||
v.UnitLabel = "通行证"
|
||||
v.PeriodText = s.StartDate + " → " + s.EndDate
|
||||
v.Progress = 0
|
||||
if s.SeasonDone != "" {
|
||||
v.RemainText = "已完成 1 / 1"
|
||||
v.RemainShort = "1/1"
|
||||
v.Progress = 100
|
||||
} else {
|
||||
v.RemainText = "已完成 0 / 1"
|
||||
v.RemainShort = "0/1"
|
||||
}
|
||||
} else if s.Abyss {
|
||||
v.UnitLabel = "深渊"
|
||||
v.PeriodText = s.StartDate + " → " + s.EndDate
|
||||
v.RemainText = fmt.Sprintf("已完成 %d / %d 周期", s.UsedCount, s.TotalCount)
|
||||
v.RemainShort = fmt.Sprintf("%d/%d 周期", s.UsedCount, s.TotalCount)
|
||||
if s.TotalCount > 0 {
|
||||
v.Progress = clampPct(s.UsedCount * 100 / s.TotalCount)
|
||||
}
|
||||
} else if s.Unit == domain.UnitDay {
|
||||
v.UnitLabel = "按日"
|
||||
v.RemainText = fmt.Sprintf("剩 %d 天", e.RemainingDays)
|
||||
v.RemainShort = fmt.Sprintf("%d 天", e.RemainingDays)
|
||||
v.PeriodText = s.StartDate + " → " + s.EndDate
|
||||
total := domain.DayDiff(domain.ParseDateOr(s.StartDate, today), domain.ParseDateOr(s.EndDate, today)) + 1
|
||||
if total > 0 {
|
||||
v.Progress = clampPct(e.RemainingDays * 100 / total)
|
||||
}
|
||||
} else {
|
||||
v.UnitLabel = "按次"
|
||||
v.RemainText = fmt.Sprintf("已完成 %d / %d 次", s.UsedCount, s.TotalCount)
|
||||
v.RemainShort = fmt.Sprintf("%d/%d 次", s.UsedCount, s.TotalCount)
|
||||
v.PeriodText = s.StartDate + " 起"
|
||||
if s.EndDate != "" {
|
||||
v.PeriodText += " · 有效期至 " + s.EndDate
|
||||
} else {
|
||||
v.PeriodText += " · 无有效期"
|
||||
}
|
||||
if s.TotalCount > 0 {
|
||||
v.Progress = clampPct(s.UsedCount * 100 / s.TotalCount)
|
||||
v.Progress = clampPct(e.RemainingCount * 100 / s.TotalCount)
|
||||
}
|
||||
v.RemainText = fmt.Sprintf("剩 %d 天", e.RemainingDays)
|
||||
v.RemainShort = fmt.Sprintf("%d 天", e.RemainingDays)
|
||||
v.PeriodText = s.StartDate + " → " + s.EndDate
|
||||
total := domain.DayDiff(domain.ParseDateOr(s.StartDate, today), domain.ParseDateOr(s.EndDate, today)) + 1
|
||||
if total > 0 {
|
||||
v.Progress = clampPct(e.RemainingDays * 100 / total)
|
||||
}
|
||||
|
||||
switch e.Level {
|
||||
@@ -135,10 +75,8 @@ func newSubView(s store.Subscription, today time.Time, warnDays int) SubView {
|
||||
v.DueText = "明天到期"
|
||||
case e.DaysLeft > 1:
|
||||
v.DueText = fmt.Sprintf("%d 天后到期", e.DaysLeft)
|
||||
case s.Unit == domain.UnitDay:
|
||||
v.DueText = fmt.Sprintf("还剩 %d 天", e.RemainingDays)
|
||||
default:
|
||||
v.DueText = fmt.Sprintf("%d 天后到期", e.DaysLeft)
|
||||
v.DueText = fmt.Sprintf("还剩 %d 天", e.RemainingDays)
|
||||
}
|
||||
case domain.LevelExpired:
|
||||
if s.EndDate != "" {
|
||||
@@ -148,33 +86,10 @@ func newSubView(s store.Subscription, today time.Time, warnDays int) SubView {
|
||||
} else {
|
||||
v.DueText = "已到期"
|
||||
}
|
||||
} else {
|
||||
v.DueText = "次数已用尽"
|
||||
}
|
||||
}
|
||||
// 整段型:完成后统一显示「已完成」,不再提示到期
|
||||
if s.Season && s.SeasonDone != "" {
|
||||
v.StateLabel = "已完成"
|
||||
v.StateClass = "active"
|
||||
v.DueText = ""
|
||||
}
|
||||
if s.Abyss && s.TotalCount > 0 && s.UsedCount >= s.TotalCount {
|
||||
v.StateLabel = "已完成"
|
||||
v.StateClass = "active"
|
||||
v.DueText = ""
|
||||
}
|
||||
// 今天能否打卡:进行中、非整段型,且(按日或有剩余次数)
|
||||
v.CanCheckinToday = !s.IsBlock() && e.State == domain.StateActive &&
|
||||
(s.Unit == domain.UnitDay || e.RemainingCount > 0)
|
||||
startT := domain.ParseDateOr(s.StartDate, today)
|
||||
endT := domain.ParseDateOr(s.EndDate, today)
|
||||
inRange := !today.Before(startT) && (s.EndDate == "" || !today.After(endT))
|
||||
if s.Season && s.SeasonDone == "" && inRange && e.State == domain.StateActive {
|
||||
v.CanPassToday = true
|
||||
}
|
||||
if s.Abyss && s.TotalCount > 0 && s.UsedCount < s.TotalCount && inRange && e.State == domain.StateActive {
|
||||
v.CanAbyssToday = true
|
||||
}
|
||||
// 今天能否打卡:进行中且在有效区间内
|
||||
v.CanCheckinToday = e.State == domain.StateActive
|
||||
return v
|
||||
}
|
||||
|
||||
@@ -198,11 +113,10 @@ func subViews(subs []store.Subscription, today time.Time, warnDays int) []SubVie
|
||||
|
||||
// ---------- 追加面板 ----------
|
||||
|
||||
// ExtendPanel 是「追加时长/次数」面板数据。
|
||||
// ExtendPanel 是「追加时长」面板数据。
|
||||
type ExtendPanel struct {
|
||||
Sub store.Subscription
|
||||
View SubView
|
||||
IsDay bool
|
||||
Today string
|
||||
OldEnd string
|
||||
Base string
|
||||
@@ -234,7 +148,6 @@ func buildExtendPanel(s *store.Subscription, pkg *store.Package, today time.Time
|
||||
p := &ExtendPanel{
|
||||
Sub: *s,
|
||||
View: newSubView(*s, today, warnDays),
|
||||
IsDay: s.Unit == domain.UnitDay,
|
||||
Today: domain.Date(today),
|
||||
Back: back,
|
||||
DefaultAmount: pkg.DefaultAmount,
|
||||
@@ -242,9 +155,6 @@ func buildExtendPanel(s *store.Subscription, pkg *store.Package, today time.Time
|
||||
if p.DefaultAmount <= 0 {
|
||||
p.DefaultAmount = 30
|
||||
}
|
||||
if s.Unit != domain.UnitDay {
|
||||
return p
|
||||
}
|
||||
oldEnd := domain.ParseDateOr(s.EndDate, today)
|
||||
plan := domain.PlanExtend(oldEnd, oldEnd, today)
|
||||
suggested := domain.AddDays(plan.Base, p.DefaultAmount-1)
|
||||
|
||||
Reference in New Issue
Block a user