feat(v1.11.0): 通行证/深渊模式、淡蓝配色与触控小键盘修复
- 触控小键盘补回 3×4 网格样式:上一版重写 CSS 时漏掉了 .keypad/.key, 按钮退化成行内小方块;现在恢复 46px 圆角键、⌫/✓ 功能键和「触控」开关态。 - 通行证(原「包赛季」):整段有效期在独立日历上按套餐色连续着色(18% 透明度), 每一格显示同一个「已完成 / 总单数」(0/1 或 1/1);完成后色块保留并显示 1/1。 沿用 season_done 记录完成日期,交互动线不变。 - 新增深渊模式:套餐设置周期天数 N 与周期数 X;开通时从开始日排出 X 个 N 天周期, 结束日 = 开始日 + N×X − 1。周期内任意一天完成即算该周期完成;同一周期重复完成 不重复计数;撤销该周期最后一条完成打卡会回退计数。独立日历连续着色,每格显示 同一个「已完成周期 / 总周期数」。 - 全量把「包赛季」改名为「通行证」;套餐表单新增通行证 / 深渊选项,深渊显示 N/X 字段; 客户开通表单、套餐批量开通、订阅列表、客户订阅卡片、日历待办行同步适配, 通行证 / 深渊不再显示「追加时长」(提交也会被服务端拒绝)。 - 快速完成 / 批量完成对通行证改为整段完成,对深渊走周期打卡,不再错误地按日写打卡。 - 配色改为淡蓝 / 暗蓝:亮色用暗蓝主色 + 淡蓝纸底,暗色用海军蓝底 + 淡蓝强调; 默认套餐色改为 #3B6EA5;大屏同步蓝调并修正热力图例与今日数字的对比度。 - 大屏页签排除通行证 / 深渊(它们不计每日热力,避免点开是空日历);「今日待打」 仍会列出待处理的通行证 / 深渊。 - 数据迁移:packages.abyss / packages.cycle_days / subscriptions.abyss / subscriptions.cycle_days,老库启动自动补列。 - 修复手机端整段色块把 7 列日历撑出屏幕:日历改成 minmax(0,1fr),小屏色块缩小。 - 版本号 1.10.0 → 1.11.0。 验证:gofmt / go vet / go test 全绿;亮暗两套、1440 与 390 两档截图走查; 通行证 0/1 → 1/1、深渊 1/4 → 2/4、同周期重复完成不重复计数、撤销回退均实测通过。
This commit is contained in:
@@ -19,7 +19,7 @@
|
||||
┌───────────────────────────────────────────────┐
|
||||
│ 代 打 台 · 代打管理平台 │
|
||||
└───────────────────────────────────────────────┘
|
||||
版本 1.10.0 配置文件 daili.ini
|
||||
版本 1.11.0 配置文件 daili.ini
|
||||
数据库 D:\代打台\daili.db
|
||||
访问地址:
|
||||
本机 http://127.0.0.1:17777
|
||||
@@ -154,10 +154,11 @@
|
||||
|
||||
---
|
||||
|
||||
## 4.3 包赛季与按次有效期
|
||||
## 4.3 通行证、深渊与按次有效期
|
||||
|
||||
- **包赛季**:套餐计费方式新增第三种「包赛季」,套餐上直接填赛季开始日/结束日。客户开通后,日历上用一条横向色带标出整段赛季;赛季内任意一天点「完成」即整段完成,完成后不再出现在日历与待打,客户详情显示「赛季已完成 + 日期」。
|
||||
- **赛季过期不可选**:今天已过赛季结束日的套餐,在客户开通下拉里会置灰并标「赛季已结束」,服务端也会拒绝开通。
|
||||
- **通行证**(原「包赛季」):套餐上直接填通行证开始日/结束日。客户开通后,该套餐的独立日历会把整段有效期连续着色(用套餐色签的淡化色),每一格显示同一个「已完成 / 总单数」(0/1 或 1/1)。有效期内任意一天点「完成通行证」即整段完成,完成后色块保留并显示 1/1。
|
||||
- **深渊**:套餐填「周期天数 N」与「周期数 X」。开通时从开始日连续排出 X 个 N 天周期;独立日历按周期连续着色,每一格显示同一个「已完成周期 / 总周期数」。周期内任意一天完成即算该周期完成(同周期重复完成不会重复计数),撤销该天打卡会退回该周期。
|
||||
- **通行证过期不可选**:今天已过通行证结束日的套餐,在客户开通下拉里会置灰并标「通行证已结束」,服务端也会拒绝开通。
|
||||
- **按次默认有效期**:按次套餐可设「默认有效期(天)」,开单时自动算出到期日(开始日 + 天数 − 1),仍可手动改。
|
||||
- **删除订阅**:已结束的订阅卡片上,在「重新启用」旁新增「删除」,二次确认后彻底删除该订阅及其打卡/追加记录。
|
||||
|
||||
@@ -184,7 +185,7 @@
|
||||
|
||||
- **迁移**:关闭程序 → 把 `daili.db` 复制到新电脑的新目录 → 放入 `daili.exe` 双击即可,账号、套餐、客户、订阅、追加记录、打卡、日志全部原样保留。
|
||||
- **重置**:关闭程序 → 删除 `daili.db` → 重新打开,会回到「创建第一个管理员」的全新状态。
|
||||
- 包赛季是 `packages.season/season_start/season_end` 与 `subscriptions.season/season_done`;套餐标签是 `packages.tag`;客户停用是 `customers.archived`(0/1);打手颜色存在 `users.color`,客户归属打手是 `customers.assignee_id`;加急标记存在 `daili.db` 的 `task_flags` 表;套餐的「独立日历」是 `packages.calendar_separate` 列,老版本数据库打开时会**自动加列**,不用手工迁移;
|
||||
- 通行证是 `packages.season/season_start/season_end` 与 `subscriptions.season/season_done`;深渊是 `packages.abyss/cycle_days` 与 `subscriptions.abyss/cycle_days`(`total_count` 存周期数);套餐标签是 `packages.tag`;客户停用是 `customers.archived`(0/1);打手颜色存在 `users.color`,客户归属打手是 `customers.assignee_id`;加急标记存在 `daili.db` 的 `task_flags` 表;套餐的「独立日历」是 `packages.calendar_separate` 列,老版本数据库打开时会**自动加列**,不用手工迁移;
|
||||
- `daili.ini`(监听/备份/日志配置)与 `backup/`、`logs/` 都是**独立于数据**的,迁移时可以不拷,程序会按默认值重新生成。
|
||||
|
||||
- 手动备份:`设置 → 立即备份`(同样遵守保留份数),备份文件本身也是可直接打开的单文件库;
|
||||
|
||||
@@ -74,6 +74,29 @@ const (
|
||||
UnitCount = "count"
|
||||
)
|
||||
|
||||
// CycleIndex 返回 date 在 [start, start+cycleDays*cycles) 内的周期序号(0 起)。
|
||||
// 越界或参数不合法返回 -1。
|
||||
func CycleIndex(start, date time.Time, cycleDays int) int {
|
||||
if cycleDays <= 0 {
|
||||
return -1
|
||||
}
|
||||
d := DayDiff(start, date)
|
||||
if d < 0 {
|
||||
return -1
|
||||
}
|
||||
return d / cycleDays
|
||||
}
|
||||
|
||||
// CycleStart 返回第 idx 个周期的第一天。
|
||||
func CycleStart(start time.Time, cycleDays, idx int) time.Time {
|
||||
return AddDays(start, idx*cycleDays)
|
||||
}
|
||||
|
||||
// CycleEnd 返回第 idx 个周期的最后一天。
|
||||
func CycleEnd(start time.Time, cycleDays, idx int) time.Time {
|
||||
return AddDays(start, (idx+1)*cycleDays-1)
|
||||
}
|
||||
|
||||
// 派生展示状态
|
||||
const (
|
||||
StateActive = "active" // 进行中
|
||||
|
||||
@@ -44,7 +44,35 @@ func (db *DB) SaveCheckin(subID int64, date, status, note string, operatorID int
|
||||
}
|
||||
|
||||
delta := 0
|
||||
if s.Unit == domain.UnitCount {
|
||||
if s.Abyss {
|
||||
if s.CycleDays <= 0 {
|
||||
return errors.New("该深渊套餐未设置周期天数")
|
||||
}
|
||||
d, _ := domain.ParseDate(date)
|
||||
start := domain.ParseDateOr(s.StartDate, domain.Today())
|
||||
idx := domain.CycleIndex(start, d, s.CycleDays)
|
||||
if idx < 0 || idx >= s.TotalCount {
|
||||
return errors.New("日期不在深渊周期内")
|
||||
}
|
||||
cycStart := domain.Date(domain.CycleStart(start, s.CycleDays, idx))
|
||||
cycEnd := domain.Date(domain.CycleEnd(start, s.CycleDays, idx))
|
||||
var otherDone int
|
||||
if err := tx.QueryRow(`SELECT COUNT(*) FROM checkins WHERE sub_id=? AND status='done'
|
||||
AND service_date BETWEEN ? AND ? AND service_date<>?`, subID, cycStart, cycEnd, date).Scan(&otherDone); err != nil {
|
||||
return err
|
||||
}
|
||||
oldDone := hasOld && oldStatus == "done"
|
||||
newDone := status == "done"
|
||||
switch {
|
||||
case newDone && !oldDone && otherDone == 0:
|
||||
if s.UsedCount >= s.TotalCount {
|
||||
return errors.New("所有周期已完成")
|
||||
}
|
||||
delta = 1
|
||||
case !newDone && oldDone && otherDone == 0:
|
||||
delta = -1
|
||||
}
|
||||
} else if s.Unit == domain.UnitCount {
|
||||
oldDone := hasOld && oldStatus == "done"
|
||||
newDone := status == "done"
|
||||
switch {
|
||||
@@ -103,8 +131,29 @@ func (db *DB) DeleteCheckin(id, operatorID int64) (int64, error) {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
delta := 0
|
||||
if s.Unit == domain.UnitCount && status == "done" {
|
||||
newUsed := s.UsedCount - 1
|
||||
delta = -1
|
||||
}
|
||||
if s.Abyss && status == "done" && s.CycleDays > 0 {
|
||||
d, _ := domain.ParseDate(date)
|
||||
start := domain.ParseDateOr(s.StartDate, domain.Today())
|
||||
idx := domain.CycleIndex(start, d, s.CycleDays)
|
||||
if idx >= 0 {
|
||||
cycStart := domain.Date(domain.CycleStart(start, s.CycleDays, idx))
|
||||
cycEnd := domain.Date(domain.CycleEnd(start, s.CycleDays, idx))
|
||||
var remain int
|
||||
if err := tx.QueryRow(`SELECT COUNT(*) FROM checkins WHERE sub_id=? AND status='done'
|
||||
AND service_date BETWEEN ? AND ?`, subID, cycStart, cycEnd).Scan(&remain); err != nil {
|
||||
return err
|
||||
}
|
||||
if remain == 0 {
|
||||
delta = -1
|
||||
}
|
||||
}
|
||||
}
|
||||
if delta != 0 {
|
||||
newUsed := s.UsedCount + delta
|
||||
if newUsed < 0 {
|
||||
newUsed = 0
|
||||
}
|
||||
|
||||
@@ -172,7 +172,25 @@ func summarizeSubs(subs []Subscription, today string, warnDays int) (string, str
|
||||
continue
|
||||
}
|
||||
var text string
|
||||
if s.Unit == domain.UnitDay {
|
||||
if s.Season {
|
||||
switch {
|
||||
case s.SeasonDone != "":
|
||||
text = s.PackageName + " 通行证已完成"
|
||||
case e.State == domain.StateExpired:
|
||||
text = s.PackageName + " 通行证已结束"
|
||||
default:
|
||||
text = fmt.Sprintf("%s 通行证 %d/%d", s.PackageName, s.BlockDone(), s.BlockTotal())
|
||||
}
|
||||
} else if s.Abyss {
|
||||
switch {
|
||||
case s.TotalCount > 0 && s.UsedCount >= s.TotalCount:
|
||||
text = fmt.Sprintf("%s %d/%d 周期", s.PackageName, s.UsedCount, s.TotalCount)
|
||||
case e.State == domain.StateExpired:
|
||||
text = fmt.Sprintf("%s %d/%d 周期 已过期", s.PackageName, s.UsedCount, s.TotalCount)
|
||||
default:
|
||||
text = fmt.Sprintf("%s %d/%d 周期", s.PackageName, s.UsedCount, s.TotalCount)
|
||||
}
|
||||
} else if s.Unit == domain.UnitDay {
|
||||
switch {
|
||||
case e.State == domain.StateExpired:
|
||||
text = s.PackageName + " 已过期"
|
||||
|
||||
+22
-1
@@ -164,6 +164,23 @@ func (db *DB) Migrate() error {
|
||||
"ALTER TABLE subscriptions ADD COLUMN season_done TEXT NOT NULL DEFAULT ''"); err != nil {
|
||||
return err
|
||||
}
|
||||
// v1.11:深渊模式(N 天一个周期)与通行证改名的数据字段
|
||||
if err := db.ensureColumn("packages", "abyss",
|
||||
"ALTER TABLE packages ADD COLUMN abyss INTEGER NOT NULL DEFAULT 0"); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := db.ensureColumn("packages", "cycle_days",
|
||||
"ALTER TABLE packages ADD COLUMN cycle_days INTEGER NOT NULL DEFAULT 0"); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := db.ensureColumn("subscriptions", "abyss",
|
||||
"ALTER TABLE subscriptions ADD COLUMN abyss INTEGER NOT NULL DEFAULT 0"); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := db.ensureColumn("subscriptions", "cycle_days",
|
||||
"ALTER TABLE subscriptions ADD COLUMN cycle_days INTEGER NOT NULL DEFAULT 0"); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -221,7 +238,7 @@ var schemaStatements = []string{
|
||||
unit TEXT NOT NULL CHECK (unit IN ('day','count')),
|
||||
default_amount INTEGER NOT NULL DEFAULT 30,
|
||||
price_cents INTEGER,
|
||||
color TEXT NOT NULL DEFAULT '#2F5D50',
|
||||
color TEXT NOT NULL DEFAULT '#3B6EA5',
|
||||
note TEXT NOT NULL DEFAULT '',
|
||||
archived INTEGER NOT NULL DEFAULT 0,
|
||||
sort_order INTEGER NOT NULL DEFAULT 0,
|
||||
@@ -231,6 +248,8 @@ var schemaStatements = []string{
|
||||
default_validity_days INTEGER NOT NULL DEFAULT 0,
|
||||
season_start TEXT NOT NULL DEFAULT '',
|
||||
season_end TEXT NOT NULL DEFAULT '',
|
||||
abyss INTEGER NOT NULL DEFAULT 0,
|
||||
cycle_days INTEGER NOT NULL DEFAULT 0,
|
||||
created_at TEXT NOT NULL,
|
||||
updated_at TEXT NOT NULL
|
||||
)`,
|
||||
@@ -262,6 +281,8 @@ var schemaStatements = []string{
|
||||
used_count INTEGER NOT NULL DEFAULT 0,
|
||||
season INTEGER NOT NULL DEFAULT 0,
|
||||
season_done TEXT NOT NULL DEFAULT '',
|
||||
abyss INTEGER NOT NULL DEFAULT 0,
|
||||
cycle_days INTEGER NOT NULL DEFAULT 0,
|
||||
note TEXT NOT NULL DEFAULT '',
|
||||
created_by INTEGER REFERENCES users(id),
|
||||
created_at TEXT NOT NULL,
|
||||
|
||||
+51
-16
@@ -3,6 +3,7 @@ package store
|
||||
import (
|
||||
"database/sql"
|
||||
"errors"
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
"daili/internal/domain"
|
||||
@@ -24,11 +25,14 @@ type Package struct {
|
||||
CalendarSeparate bool
|
||||
// Tag 套餐标签:相同标签的套餐在日历里合并显示
|
||||
Tag string
|
||||
// Season 包赛季模式:开始~结束之间任意一天可整段完成
|
||||
// Season 通行证模式:开始~结束之间任意一天可整段完成
|
||||
Season bool
|
||||
// Abyss 深渊模式:CycleDays 天一个周期,共 DefaultAmount 个周期
|
||||
Abyss bool
|
||||
CycleDays int
|
||||
// DefaultValidityDays 按次套餐默认有效期(天),0 不限
|
||||
DefaultValidityDays int
|
||||
// 包赛季的固定区间(套餐级)
|
||||
// 通行证的固定区间(套餐级)
|
||||
SeasonStart string
|
||||
SeasonEnd string
|
||||
CreatedAt string
|
||||
@@ -39,8 +43,11 @@ type Package struct {
|
||||
|
||||
// UnitLabel 返回类型中文名。
|
||||
func (p *Package) UnitLabel() string {
|
||||
if p.Abyss {
|
||||
return "深渊"
|
||||
}
|
||||
if p.Season {
|
||||
return "包赛季"
|
||||
return "通行证"
|
||||
}
|
||||
if p.Unit == domain.UnitCount {
|
||||
return "按次"
|
||||
@@ -48,12 +55,35 @@ func (p *Package) UnitLabel() string {
|
||||
return "按日"
|
||||
}
|
||||
|
||||
// AmountText 返回「默认量」列的中文描述。
|
||||
func (p *Package) AmountText() string {
|
||||
if p.Abyss {
|
||||
return strconv.Itoa(p.DefaultAmount) + " 周期"
|
||||
}
|
||||
if p.Season {
|
||||
return "整段"
|
||||
}
|
||||
if p.Unit == domain.UnitCount {
|
||||
return strconv.Itoa(p.DefaultAmount) + " 次"
|
||||
}
|
||||
return strconv.Itoa(p.DefaultAmount) + " 天"
|
||||
}
|
||||
|
||||
// CycleLabel 返回深渊模式的人话描述。
|
||||
func (p *Package) CycleLabel() string {
|
||||
if !p.Abyss || p.CycleDays <= 0 {
|
||||
return ""
|
||||
}
|
||||
return strconv.Itoa(p.CycleDays) + " 天/周期"
|
||||
}
|
||||
|
||||
func scanPackage(row interface{ Scan(dest ...any) error }) (*Package, error) {
|
||||
var p Package
|
||||
var price sql.NullInt64
|
||||
var archived, separate, season, validity int
|
||||
var archived, separate, season, validity, abyss, cycleDays int
|
||||
err := row.Scan(&p.ID, &p.Name, &p.Unit, &p.DefaultAmount, &price, &p.Color, &p.Note,
|
||||
&archived, &p.SortOrder, &separate, &p.Tag, &season, &validity, &p.SeasonStart, &p.SeasonEnd, &p.CreatedAt, &p.UpdatedAt)
|
||||
&archived, &p.SortOrder, &separate, &p.Tag, &season, &validity, &p.SeasonStart, &p.SeasonEnd,
|
||||
&abyss, &cycleDays, &p.CreatedAt, &p.UpdatedAt)
|
||||
if err != nil {
|
||||
if errors.Is(err, sql.ErrNoRows) {
|
||||
return nil, ErrNotFound
|
||||
@@ -63,6 +93,8 @@ func scanPackage(row interface{ Scan(dest ...any) error }) (*Package, error) {
|
||||
p.Archived = archived == 1
|
||||
p.CalendarSeparate = separate == 1
|
||||
p.Season = season == 1
|
||||
p.Abyss = abyss == 1
|
||||
p.CycleDays = cycleDays
|
||||
p.DefaultValidityDays = validity
|
||||
if price.Valid {
|
||||
p.PriceCents = int(price.Int64)
|
||||
@@ -73,7 +105,7 @@ func scanPackage(row interface{ Scan(dest ...any) error }) (*Package, error) {
|
||||
|
||||
// ListPackages 列出套餐(含订阅计数)。
|
||||
func (db *DB) ListPackages(includeArchived bool) ([]Package, error) {
|
||||
q := `SELECT p.id,p.name,p.unit,p.default_amount,p.price_cents,p.color,p.note,p.archived,p.sort_order,p.calendar_separate,p.tag,p.season,p.default_validity_days,p.season_start,p.season_end,p.created_at,p.updated_at,
|
||||
q := `SELECT p.id,p.name,p.unit,p.default_amount,p.price_cents,p.color,p.note,p.archived,p.sort_order,p.calendar_separate,p.tag,p.season,p.default_validity_days,p.season_start,p.season_end,p.abyss,p.cycle_days,p.created_at,p.updated_at,
|
||||
(SELECT COUNT(*) FROM subscriptions s WHERE s.package_id=p.id),
|
||||
(SELECT COUNT(*) FROM subscriptions s WHERE s.package_id=p.id AND s.status<>'closed')
|
||||
FROM packages p`
|
||||
@@ -90,14 +122,17 @@ func (db *DB) ListPackages(includeArchived bool) ([]Package, error) {
|
||||
for rows.Next() {
|
||||
var p Package
|
||||
var price sql.NullInt64
|
||||
var archived, separate, season, validity int
|
||||
var archived, separate, season, validity, abyss, cycleDays int
|
||||
if err := rows.Scan(&p.ID, &p.Name, &p.Unit, &p.DefaultAmount, &price, &p.Color, &p.Note,
|
||||
&archived, &p.SortOrder, &separate, &p.Tag, &season, &validity, &p.SeasonStart, &p.SeasonEnd, &p.CreatedAt, &p.UpdatedAt, &p.SubCount, &p.ActiveCount); err != nil {
|
||||
&archived, &p.SortOrder, &separate, &p.Tag, &season, &validity, &p.SeasonStart, &p.SeasonEnd,
|
||||
&abyss, &cycleDays, &p.CreatedAt, &p.UpdatedAt, &p.SubCount, &p.ActiveCount); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
p.Archived = archived == 1
|
||||
p.CalendarSeparate = separate == 1
|
||||
p.Season = season == 1
|
||||
p.Abyss = abyss == 1
|
||||
p.CycleDays = cycleDays
|
||||
p.DefaultValidityDays = validity
|
||||
if price.Valid {
|
||||
p.PriceCents = int(price.Int64)
|
||||
@@ -110,7 +145,7 @@ func (db *DB) ListPackages(includeArchived bool) ([]Package, error) {
|
||||
|
||||
// Package 取单个套餐。
|
||||
func (db *DB) Package(id int64) (*Package, error) {
|
||||
return scanPackage(db.sql.QueryRow(`SELECT id,name,unit,default_amount,price_cents,color,note,archived,sort_order,calendar_separate,tag,season,default_validity_days,season_start,season_end,created_at,updated_at
|
||||
return scanPackage(db.sql.QueryRow(`SELECT id,name,unit,default_amount,price_cents,color,note,archived,sort_order,calendar_separate,tag,season,default_validity_days,season_start,season_end,abyss,cycle_days,created_at,updated_at
|
||||
FROM packages WHERE id=?`, id))
|
||||
}
|
||||
|
||||
@@ -122,15 +157,15 @@ func (db *DB) CreatePackage(p *Package) (int64, error) {
|
||||
p.DefaultAmount = 30
|
||||
}
|
||||
if strings.TrimSpace(p.Color) == "" {
|
||||
p.Color = "#2F5D50"
|
||||
p.Color = "#3B6EA5"
|
||||
}
|
||||
var price any
|
||||
if p.HasPrice {
|
||||
price = p.PriceCents
|
||||
}
|
||||
res, err := db.sql.Exec(`INSERT INTO packages(name,unit,default_amount,price_cents,color,note,archived,sort_order,calendar_separate,tag,season,default_validity_days,season_start,season_end,created_at,updated_at)
|
||||
VALUES(?,?,?,?,?,?,0,?,?,?,?,?,?,?,?,?)`,
|
||||
p.Name, p.Unit, p.DefaultAmount, price, p.Color, p.Note, p.SortOrder, b2i(p.CalendarSeparate), strings.TrimSpace(p.Tag), b2i(p.Season), p.DefaultValidityDays, p.SeasonStart, p.SeasonEnd, now, now)
|
||||
res, err := db.sql.Exec(`INSERT INTO packages(name,unit,default_amount,price_cents,color,note,archived,sort_order,calendar_separate,tag,season,default_validity_days,season_start,season_end,abyss,cycle_days,created_at,updated_at)
|
||||
VALUES(?,?,?,?,?,?,0,?,?,?,?,?,?,?,?,?,?,?)`,
|
||||
p.Name, p.Unit, p.DefaultAmount, price, p.Color, p.Note, p.SortOrder, b2i(p.CalendarSeparate), strings.TrimSpace(p.Tag), b2i(p.Season), p.DefaultValidityDays, p.SeasonStart, p.SeasonEnd, b2i(p.Abyss), p.CycleDays, now, now)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
@@ -144,14 +179,14 @@ func (db *DB) UpdatePackage(p *Package) error {
|
||||
p.DefaultAmount = 30
|
||||
}
|
||||
if strings.TrimSpace(p.Color) == "" {
|
||||
p.Color = "#2F5D50"
|
||||
p.Color = "#3B6EA5"
|
||||
}
|
||||
var price any
|
||||
if p.HasPrice {
|
||||
price = p.PriceCents
|
||||
}
|
||||
_, err := db.sql.Exec(`UPDATE packages SET name=?,unit=?,default_amount=?,price_cents=?,color=?,note=?,sort_order=?,calendar_separate=?,tag=?,season=?,default_validity_days=?,season_start=?,season_end=?,updated_at=?
|
||||
WHERE id=?`, p.Name, p.Unit, p.DefaultAmount, price, p.Color, p.Note, p.SortOrder, b2i(p.CalendarSeparate), strings.TrimSpace(p.Tag), b2i(p.Season), p.DefaultValidityDays, p.SeasonStart, p.SeasonEnd, nowStamp(), p.ID)
|
||||
_, err := db.sql.Exec(`UPDATE packages SET name=?,unit=?,default_amount=?,price_cents=?,color=?,note=?,sort_order=?,calendar_separate=?,tag=?,season=?,default_validity_days=?,season_start=?,season_end=?,abyss=?,cycle_days=?,updated_at=?
|
||||
WHERE id=?`, p.Name, p.Unit, p.DefaultAmount, price, p.Color, p.Note, p.SortOrder, b2i(p.CalendarSeparate), strings.TrimSpace(p.Tag), b2i(p.Season), p.DefaultValidityDays, p.SeasonStart, p.SeasonEnd, b2i(p.Abyss), p.CycleDays, nowStamp(), p.ID)
|
||||
return err
|
||||
}
|
||||
|
||||
|
||||
@@ -26,9 +26,12 @@ type Subscription struct {
|
||||
CreatedAt string
|
||||
UpdatedAt string
|
||||
ClosedAt string
|
||||
// Season 包赛季;SeasonDone 标记整段完成的日期(空=未完成)
|
||||
// Season 通行证;SeasonDone 标记整段完成的日期(空=未完成)
|
||||
Season bool
|
||||
SeasonDone string
|
||||
// Abyss 深渊模式:CycleDays 天一个周期,TotalCount 是周期总数
|
||||
Abyss bool
|
||||
CycleDays int
|
||||
|
||||
// 联表
|
||||
PackageName string
|
||||
@@ -51,6 +54,34 @@ func (s *Subscription) Eval(today time.Time, warnDays int) domain.Eval {
|
||||
// IsCount 是否按次套餐。
|
||||
func (s *Subscription) IsCount() bool { return s.Unit == domain.UnitCount }
|
||||
|
||||
// IsBlock 是否整段型(通行证 / 深渊):日历上按连续色块展示,不按天计任务。
|
||||
func (s *Subscription) IsBlock() bool { return s.Season || s.Abyss }
|
||||
|
||||
// BlockTotal 返回整段型订阅的总单数:通行证固定 1,深渊为周期数。
|
||||
func (s *Subscription) BlockTotal() int {
|
||||
if s.Season {
|
||||
return 1
|
||||
}
|
||||
if s.Abyss {
|
||||
return s.TotalCount
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
// BlockDone 返回整段型订阅的已完成单数:通行证看完成标记,深渊看已完成周期数。
|
||||
func (s *Subscription) BlockDone() int {
|
||||
if s.Season {
|
||||
if s.SeasonDone != "" {
|
||||
return 1
|
||||
}
|
||||
return 0
|
||||
}
|
||||
if s.Abyss {
|
||||
return s.UsedCount
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
// Pause 暂停分段。
|
||||
type Pause struct {
|
||||
ID int64
|
||||
@@ -101,7 +132,7 @@ func (a *Adjustment) KindLabel() string {
|
||||
|
||||
const subSelect = `SELECT s.id,s.customer_id,s.package_id,s.unit,s.status,s.start_date,IFNULL(s.end_date,''),
|
||||
s.total_count,s.used_count,s.note,IFNULL(s.created_by,0),s.created_at,s.updated_at,IFNULL(s.closed_at,''),
|
||||
IFNULL(s.season,0),IFNULL(s.season_done,''),
|
||||
IFNULL(s.season,0),IFNULL(s.season_done,''),IFNULL(s.abyss,0),IFNULL(s.cycle_days,0),
|
||||
p.name,p.color,c.tail,c.name,IFNULL(c.contact,''),
|
||||
IFNULL(c.assignee_id,0),
|
||||
IFNULL((SELECT u.display_name FROM users u WHERE u.id=c.assignee_id),''),
|
||||
@@ -112,10 +143,10 @@ const subSelect = `SELECT s.id,s.customer_id,s.package_id,s.unit,s.status,s.star
|
||||
|
||||
func scanSub(row interface{ Scan(dest ...any) error }) (*Subscription, error) {
|
||||
var s Subscription
|
||||
var seasonInt int
|
||||
var seasonInt, abyssInt, cycleDays int
|
||||
err := row.Scan(&s.ID, &s.CustomerID, &s.PackageID, &s.Unit, &s.Status, &s.StartDate, &s.EndDate,
|
||||
&s.TotalCount, &s.UsedCount, &s.Note, &s.CreatedBy, &s.CreatedAt, &s.UpdatedAt, &s.ClosedAt,
|
||||
&seasonInt, &s.SeasonDone,
|
||||
&seasonInt, &s.SeasonDone, &abyssInt, &cycleDays,
|
||||
&s.PackageName, &s.PackageColor, &s.CustomerTail, &s.CustomerName, &s.CustomerContact,
|
||||
&s.AssigneeID, &s.AssigneeName, &s.AssigneeColor)
|
||||
if err != nil {
|
||||
@@ -125,6 +156,8 @@ func scanSub(row interface{ Scan(dest ...any) error }) (*Subscription, error) {
|
||||
return nil, err
|
||||
}
|
||||
s.Season = seasonInt == 1
|
||||
s.Abyss = abyssInt == 1
|
||||
s.CycleDays = cycleDays
|
||||
return &s, nil
|
||||
}
|
||||
|
||||
@@ -323,19 +356,33 @@ func (db *DB) CreateSub(in CreateSubInput) (*Subscription, error) {
|
||||
endDate = domain.Date(domain.AddDays(start, pkg.DefaultValidityDays-1))
|
||||
}
|
||||
}
|
||||
if pkg.Season {
|
||||
if pkg.Abyss {
|
||||
if pkg.CycleDays <= 0 {
|
||||
return nil, errors.New("该深渊套餐未设置周期天数")
|
||||
}
|
||||
total = in.TotalCount
|
||||
if total <= 0 {
|
||||
total = pkg.DefaultAmount
|
||||
}
|
||||
if total <= 0 {
|
||||
total = 1
|
||||
}
|
||||
endDate = domain.Date(domain.AddDays(start, pkg.CycleDays*total-1))
|
||||
unit = domain.UnitDay
|
||||
days = pkg.CycleDays * total
|
||||
} else if pkg.Season {
|
||||
if pkg.SeasonStart == "" || pkg.SeasonEnd == "" {
|
||||
return nil, errors.New("该赛季套餐未设置起止日期")
|
||||
return nil, errors.New("该通行证套餐未设置起止日期")
|
||||
}
|
||||
end, err := domain.ParseDate(pkg.SeasonEnd)
|
||||
if err != nil {
|
||||
return nil, errors.New("赛季结束日期不正确")
|
||||
return nil, errors.New("通行证结束日期不正确")
|
||||
}
|
||||
if domain.DayDiff(domain.Today(), end) < 0 {
|
||||
return nil, errors.New("该赛季已结束,不能开通")
|
||||
return nil, errors.New("该通行证已结束,不能开通")
|
||||
}
|
||||
if domain.DayDiff(start, end) < 0 {
|
||||
return nil, errors.New("赛季结束日期早于开始日期")
|
||||
return nil, errors.New("通行证结束日期早于开始日期")
|
||||
}
|
||||
endDate = domain.Date(end)
|
||||
unit = domain.UnitDay
|
||||
@@ -354,9 +401,9 @@ func (db *DB) CreateSub(in CreateSubInput) (*Subscription, error) {
|
||||
if !errors.Is(err, sql.ErrNoRows) {
|
||||
return err
|
||||
}
|
||||
res, err := tx.Exec(`INSERT INTO subscriptions(customer_id,package_id,unit,status,start_date,end_date,total_count,used_count,note,created_by,created_at,updated_at,season)
|
||||
VALUES(?,?,?,'active',?,?,?,0,?,?,?,?,?)`,
|
||||
in.CustomerID, in.PackageID, unit, domain.Date(start), nullIfEmpty(endDate), total, in.Note, nullIfZero(in.OperatorID), now, now, b2i(pkg.Season))
|
||||
res, err := tx.Exec(`INSERT INTO subscriptions(customer_id,package_id,unit,status,start_date,end_date,total_count,used_count,note,created_by,created_at,updated_at,season,abyss,cycle_days)
|
||||
VALUES(?,?,?,'active',?,?,?,0,?,?,?,?,?,?,?)`,
|
||||
in.CustomerID, in.PackageID, unit, domain.Date(start), nullIfEmpty(endDate), total, in.Note, nullIfZero(in.OperatorID), now, now, b2i(pkg.Season), b2i(pkg.Abyss), pkg.CycleDays)
|
||||
if err != nil {
|
||||
if isUnique(err) {
|
||||
return errors.New("该客户已订阅此套餐,请改用「追加时长」")
|
||||
@@ -636,14 +683,14 @@ func (s *Subscription) SubTitle() string {
|
||||
return fmt.Sprintf("%s %s · %s", s.CustomerTail, s.CustomerName, s.PackageName)
|
||||
}
|
||||
|
||||
// SeasonComplete 把包赛季订阅整段标记为已完成。
|
||||
// SeasonComplete 把通行证订阅整段标记为已完成。
|
||||
func (db *DB) SeasonComplete(subID int64, date string) error {
|
||||
sub, err := db.Sub(subID)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if !sub.Season {
|
||||
return errors.New("不是包赛季订阅")
|
||||
return errors.New("不是通行证订阅")
|
||||
}
|
||||
_, err = db.sql.Exec(`UPDATE subscriptions SET season_done=?, updated_at=? WHERE id=?`,
|
||||
date, nowStamp(), subID)
|
||||
|
||||
@@ -26,11 +26,12 @@ type DayCell struct {
|
||||
DoneCount int
|
||||
UrgentCnt int
|
||||
Heat int
|
||||
// 赛季色带
|
||||
HasSeason bool
|
||||
SeasonColor string
|
||||
SeasonStart bool
|
||||
SeasonEnd bool
|
||||
// 通行证 / 深渊色块
|
||||
BlockColor string
|
||||
BlockDone int
|
||||
BlockTotal int
|
||||
BlockText string
|
||||
BlockTitle string
|
||||
// PendingCount 当日还没完成的单数(= TaskCount - DoneCount)
|
||||
PendingCount int
|
||||
Tickets []Ticket
|
||||
@@ -117,12 +118,13 @@ type calendarData struct {
|
||||
|
||||
// calSub 是日历计算用的订阅上下文。
|
||||
type calSub struct {
|
||||
sub store.Subscription
|
||||
start time.Time
|
||||
end time.Time
|
||||
hasEnd bool
|
||||
eval domain.Eval
|
||||
pauses []store.Pause
|
||||
sub store.Subscription
|
||||
start time.Time
|
||||
end time.Time
|
||||
hasEnd bool
|
||||
eval domain.Eval
|
||||
pauses []store.Pause
|
||||
checkins map[string]store.Checkin
|
||||
}
|
||||
|
||||
func (c calSub) pausedOn(date string) bool {
|
||||
@@ -137,6 +139,71 @@ 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
|
||||
@@ -147,6 +214,12 @@ func (c calSub) covers(date string) bool {
|
||||
}
|
||||
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
|
||||
}
|
||||
@@ -202,6 +275,21 @@ 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)
|
||||
@@ -237,7 +325,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(from, to)
|
||||
checkins, err := s.db.CheckinsBetween(wideFrom(from), wideTo(to))
|
||||
if err != nil {
|
||||
return nil, nil, nil, nil, err
|
||||
}
|
||||
@@ -288,10 +376,11 @@ func (s *Server) handleCalendar(w http.ResponseWriter, r *http.Request) {
|
||||
list := 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],
|
||||
sub: sub,
|
||||
start: domain.ParseDateOr(sub.StartDate, today),
|
||||
eval: sub.Eval(today, warn),
|
||||
pauses: pauses[sub.ID],
|
||||
checkins: checkins[sub.ID],
|
||||
}
|
||||
if sub.EndDate != "" {
|
||||
cs.end = domain.ParseDateOr(sub.EndDate, today)
|
||||
@@ -349,7 +438,20 @@ func (s *Server) handleCalendar(w http.ResponseWriter, r *http.Request) {
|
||||
if cs.sub.EndDate == ds {
|
||||
cell.DueCount++
|
||||
}
|
||||
if !cell.InMonth || !cs.covers(ds) {
|
||||
if !cell.InMonth {
|
||||
continue
|
||||
}
|
||||
if cs.isBlock() {
|
||||
if cs.blockCovers(ds) && cell.BlockText == "" {
|
||||
cell.BlockColor = cs.sub.PackageColor
|
||||
cell.BlockDone = cs.blockDone()
|
||||
cell.BlockTotal = cs.blockTotal()
|
||||
cell.BlockText = fmt.Sprintf("%d/%d", cell.BlockDone, cell.BlockTotal)
|
||||
cell.BlockTitle = cs.sub.PackageName + " · " + cell.BlockText
|
||||
}
|
||||
continue
|
||||
}
|
||||
if !cs.covers(ds) {
|
||||
continue
|
||||
}
|
||||
cell.TaskCount++
|
||||
@@ -374,16 +476,6 @@ func (s *Server) handleCalendar(w http.ResponseWriter, r *http.Request) {
|
||||
cell.DoneCount++
|
||||
}
|
||||
tickets = append(tickets, t)
|
||||
if cs.sub.Season && cs.sub.SeasonDone == "" {
|
||||
cell.HasSeason = true
|
||||
cell.SeasonColor = cs.sub.PackageColor
|
||||
if ds == cs.sub.StartDate {
|
||||
cell.SeasonStart = true
|
||||
}
|
||||
if ds == cs.sub.EndDate {
|
||||
cell.SeasonEnd = true
|
||||
}
|
||||
}
|
||||
}
|
||||
sort.SliceStable(tickets, func(i, j int) bool {
|
||||
if tickets[i].Urgent != tickets[j].Urgent {
|
||||
@@ -421,6 +513,21 @@ 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
|
||||
}
|
||||
|
||||
@@ -243,7 +243,7 @@ func (s *Server) buildCustomerCal(c *store.Customer, cm string, today time.Time)
|
||||
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)}
|
||||
cs := calSub{sub: sub, pauses: pauses[sub.ID], eval: sub.Eval(today, warn), checkins: checkins[sub.ID]}
|
||||
if sub.EndDate != "" {
|
||||
cs.hasEnd = true
|
||||
cs.end = domain.ParseDateOr(sub.EndDate, today)
|
||||
@@ -487,7 +487,7 @@ func (s *Server) handleSubCreate(w http.ResponseWriter, r *http.Request) {
|
||||
return
|
||||
}
|
||||
s.logOp(r, "新建订阅", "subscription", sub.ID,
|
||||
"为 "+c.Tail+" "+c.Name+" 开通 "+sub.PackageName+"("+unitLabel(sub.Unit)+")")
|
||||
"为 "+c.Tail+" "+c.Name+" 开通 "+sub.PackageName+"("+subTypeLabel(sub)+")")
|
||||
s.redirect(w, r, "/customers/"+itoa(customerID), "已开通「"+sub.PackageName+"」")
|
||||
}
|
||||
|
||||
@@ -498,6 +498,16 @@ func unitLabel(u string) string {
|
||||
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) {
|
||||
|
||||
@@ -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: "#2F5D50"},
|
||||
Package: &store.Package{Unit: domain.UnitDay, DefaultAmount: 30, Color: "#3B6EA5"},
|
||||
IsNew: true,
|
||||
Tags: tags,
|
||||
}
|
||||
@@ -68,25 +68,43 @@ func readPackageForm(r *http.Request) *store.Package {
|
||||
}
|
||||
p.CalendarSeparate = r.PostFormValue("calendar_separate") != ""
|
||||
p.Tag = strings.TrimSpace(r.PostFormValue("tag"))
|
||||
if p.Unit == "season" {
|
||||
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 "包赛季套餐必须填写赛季开始日和结束日"
|
||||
return "通行证套餐必须填写开始日和结束日"
|
||||
}
|
||||
if p.SeasonEnd < p.SeasonStart {
|
||||
return "赛季结束日不能早于开始日"
|
||||
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 == "" {
|
||||
@@ -160,12 +178,14 @@ func (s *Server) handlePackageBatchSubscribe(w http.ResponseWriter, r *http.Requ
|
||||
return
|
||||
}
|
||||
start := strings.TrimSpace(r.PostFormValue("start_date"))
|
||||
if start == "" {
|
||||
if start == "" && !pkg.Season {
|
||||
start = domain.Date(domain.Today())
|
||||
}
|
||||
if _, err := domain.ParseDate(start); err != nil {
|
||||
s.redirect(w, r, back, "开始日期格式不正确")
|
||||
return
|
||||
if start != "" {
|
||||
if _, err := domain.ParseDate(start); err != nil {
|
||||
s.redirect(w, r, back, "开始日期格式不正确")
|
||||
return
|
||||
}
|
||||
}
|
||||
end := strings.TrimSpace(r.PostFormValue("end_date"))
|
||||
days := s.formInt(r, "days", 0)
|
||||
|
||||
@@ -66,7 +66,7 @@ func (s *Server) screenCalSubs(from, to string, pkgID int64, tag string) ([]calS
|
||||
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)}
|
||||
cs := calSub{sub: sub, 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)
|
||||
@@ -145,6 +145,10 @@ func (s *Server) handleScreen(w http.ResponseWriter, r *http.Request) {
|
||||
}
|
||||
continue
|
||||
}
|
||||
// 通行证 / 深渊是整段型,不计入「每日待完成」热力
|
||||
if cs.isBlock() {
|
||||
continue
|
||||
}
|
||||
if !cs.covers(ds) {
|
||||
continue
|
||||
}
|
||||
@@ -210,9 +214,16 @@ func (s *Server) handleScreen(w http.ResponseWriter, r *http.Request) {
|
||||
data.Recent = adj
|
||||
}
|
||||
|
||||
// 页签:按标签合并 + 独立显示另开
|
||||
// 页签:按标签合并 + 独立显示另开;通行证/深渊不计每日热力,不放大屏页签
|
||||
pkgs, _ := s.db.ListPackages(true)
|
||||
data.Tabs, data.HasTabs = buildCalendarTabs(pkgs, nil, 0)
|
||||
screenPkgs := make([]store.Package, 0, len(pkgs))
|
||||
for _, p := range pkgs {
|
||||
if p.Season || p.Abyss {
|
||||
continue
|
||||
}
|
||||
screenPkgs = append(screenPkgs, p)
|
||||
}
|
||||
data.Tabs, data.HasTabs = buildCalendarTabs(screenPkgs, nil, 0)
|
||||
for i := range data.Tabs {
|
||||
t := &data.Tabs[i]
|
||||
href := "/screen?heat=" + heatMode
|
||||
|
||||
@@ -72,6 +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)
|
||||
@@ -162,15 +171,15 @@ func (s *Server) handleCheckinSave(w http.ResponseWriter, r *http.Request) {
|
||||
}
|
||||
if sub.Season {
|
||||
if status == "skipped" {
|
||||
s.redirect(w, r, back, "包赛季不能跳过,请直接完成或结束")
|
||||
s.redirect(w, r, back, "通行证不能跳过,请直接完成或结束")
|
||||
return
|
||||
}
|
||||
if err := s.db.SeasonComplete(id, date); err != nil {
|
||||
s.redirect(w, r, back, "完成赛季失败:"+err.Error())
|
||||
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+" 的赛季标记为完成")
|
||||
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 {
|
||||
@@ -217,7 +226,7 @@ func (s *Server) handleSubDelete(w http.ResponseWriter, r *http.Request) {
|
||||
s.redirect(w, r, "/customers/"+itoa(sub.CustomerID), "已删除订阅「"+sub.PackageName+"」")
|
||||
}
|
||||
|
||||
// handleSeasonDone 从订阅卡片直接完成整段赛季。
|
||||
// handleSeasonDone 从订阅卡片直接完成整段通行证。
|
||||
func (s *Server) handleSeasonDone(w http.ResponseWriter, r *http.Request) {
|
||||
id := pathID(r)
|
||||
sub, err := s.db.Sub(id)
|
||||
@@ -233,6 +242,6 @@ func (s *Server) handleSeasonDone(w http.ResponseWriter, r *http.Request) {
|
||||
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), "已把赛季标记为完成")
|
||||
s.logOp(r, "通行证完成", "subscription", id, sub.SubTitle()+" 整段完成("+date+")")
|
||||
s.redirect(w, r, "/customers/"+itoa(sub.CustomerID), "已把通行证标记为完成")
|
||||
}
|
||||
|
||||
@@ -23,11 +23,26 @@ 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)}
|
||||
cs := calSub{sub: sub, pauses: pauses[sub.ID], eval: sub.Eval(today, warn), 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
|
||||
}
|
||||
@@ -45,6 +60,18 @@ func (s *Server) pendingTasks(date string, customerIDs map[int64]bool, pkgID int
|
||||
return rows, nil
|
||||
}
|
||||
|
||||
// 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)
|
||||
}
|
||||
|
||||
// handleQuickCheckin 输入手机尾号直接完成当日服务:
|
||||
// 命中 1 项直接完成;命中多项则跳到日历的选择面板。
|
||||
func (s *Server) handleQuickCheckin(w http.ResponseWriter, r *http.Request) {
|
||||
@@ -101,7 +128,7 @@ func (s *Server) handleQuickCheckin(w http.ResponseWriter, r *http.Request) {
|
||||
if u != nil {
|
||||
op = u.ID
|
||||
}
|
||||
if err := s.db.SaveCheckin(row.ID, date, "done", "", op); err != nil {
|
||||
if err := s.completeTask(row.ID, date, op); err != nil {
|
||||
s.redirect(w, r, back, "完成失败:"+err.Error())
|
||||
return
|
||||
}
|
||||
@@ -147,7 +174,7 @@ func (s *Server) handleCheckinBatch(w http.ResponseWriter, r *http.Request) {
|
||||
failed++
|
||||
continue
|
||||
}
|
||||
if err := s.db.SaveCheckin(id, date, "done", "", op); err != nil {
|
||||
if err := s.completeTask(id, date, op); err != nil {
|
||||
failed++
|
||||
lastErr = err.Error()
|
||||
continue
|
||||
|
||||
+93
-46
@@ -11,30 +11,30 @@
|
||||
|
||||
:root,
|
||||
[data-bs-theme="light"] {
|
||||
--app-bg: #f5f6f2;
|
||||
--app-bg: #f4f7fb;
|
||||
--app-surface: #ffffff;
|
||||
--app-surface-2: #f8faf7;
|
||||
--app-surface-3: #eef3ee;
|
||||
--app-border: #e2e7df;
|
||||
--app-border-strong: #cbd5cc;
|
||||
--app-text: #16211c;
|
||||
--app-text-2: #45564d;
|
||||
--app-text-3: #55675d;
|
||||
--app-accent: #1f6b52;
|
||||
--app-accent-strong: #175844;
|
||||
--app-accent-solid: #1f6b52;
|
||||
--app-accent-solid-hover: #175844;
|
||||
--app-accent-soft: #e6f1eb;
|
||||
--app-accent-ink: #124434;
|
||||
--app-surface-2: #f7f9fc;
|
||||
--app-surface-3: #e9eff7;
|
||||
--app-border: #dee6ef;
|
||||
--app-border-strong: #c6d3e2;
|
||||
--app-text: #14202b;
|
||||
--app-text-2: #3d5064;
|
||||
--app-text-3: #506478;
|
||||
--app-accent: #2f5f9e;
|
||||
--app-accent-strong: #244a7c;
|
||||
--app-accent-solid: #2f5f9e;
|
||||
--app-accent-solid-hover: #244a7c;
|
||||
--app-accent-soft: #e8eff9;
|
||||
--app-accent-ink: #1b3f6b;
|
||||
--app-danger: #b3261e;
|
||||
--app-danger-soft: #fbeae8;
|
||||
--app-warn: #8a5200;
|
||||
--app-warn-soft: #fdf3e3;
|
||||
--app-info: #3c556e;
|
||||
--app-info-soft: #eaf0f6;
|
||||
--app-ring: rgba(31, 107, 82, 0.18);
|
||||
--app-shadow-sm: 0 1px 2px rgba(16, 32, 24, 0.06);
|
||||
--app-shadow: 0 18px 40px -28px rgba(16, 32, 24, 0.45);
|
||||
--app-info: #4a5b6e;
|
||||
--app-info-soft: #edf1f6;
|
||||
--app-ring: rgba(47, 95, 158, 0.18);
|
||||
--app-shadow-sm: 0 1px 2px rgba(20, 32, 43, 0.06);
|
||||
--app-shadow: 0 18px 40px -28px rgba(20, 32, 43, 0.45);
|
||||
--app-radius: 12px;
|
||||
--app-radius-sm: 8px;
|
||||
--app-sans: "Microsoft YaHei UI", "PingFang SC", "Hiragino Sans GB", "Noto Sans SC",
|
||||
@@ -57,10 +57,10 @@
|
||||
--bs-heading-color: var(--app-text);
|
||||
--bs-link-color: var(--app-accent);
|
||||
--bs-link-hover-color: var(--app-accent-strong);
|
||||
--bs-primary: #1f6b52;
|
||||
--bs-primary-rgb: 31, 107, 82;
|
||||
--bs-success: #1f6b52;
|
||||
--bs-success-rgb: 31, 107, 82;
|
||||
--bs-primary: #2f5f9e;
|
||||
--bs-primary-rgb: 47, 95, 158;
|
||||
--bs-success: #2f5f9e;
|
||||
--bs-success-rgb: 47, 95, 158;
|
||||
--bs-border-radius: var(--app-radius);
|
||||
--bs-border-radius-sm: var(--app-radius-sm);
|
||||
--bs-border-radius-lg: 16px;
|
||||
@@ -69,28 +69,28 @@
|
||||
}
|
||||
|
||||
[data-bs-theme="dark"] {
|
||||
--app-bg: #0c1310;
|
||||
--app-surface: #131b17;
|
||||
--app-surface-2: #17211c;
|
||||
--app-surface-3: #1e2b24;
|
||||
--app-border: #26362e;
|
||||
--app-border-strong: #35493e;
|
||||
--app-text: #e6f0ea;
|
||||
--app-text-2: #b9ccc1;
|
||||
--app-text-3: #8ea69a;
|
||||
--app-accent: #5cc4a3;
|
||||
--app-accent-strong: #7bd7b8;
|
||||
--app-accent-solid: #2b7d61;
|
||||
--app-accent-solid-hover: #339374;
|
||||
--app-accent-soft: rgba(92, 196, 163, 0.14);
|
||||
--app-accent-ink: #a9ecd6;
|
||||
--app-bg: #0a111a;
|
||||
--app-surface: #101a26;
|
||||
--app-surface-2: #142131;
|
||||
--app-surface-3: #1b2b3d;
|
||||
--app-border: #223447;
|
||||
--app-border-strong: #31485f;
|
||||
--app-text: #e6eef7;
|
||||
--app-text-2: #b4c6d8;
|
||||
--app-text-3: #8aa0b6;
|
||||
--app-accent: #6fa8dc;
|
||||
--app-accent-strong: #93c4ee;
|
||||
--app-accent-solid: #2b5d94;
|
||||
--app-accent-solid-hover: #356ea9;
|
||||
--app-accent-soft: rgba(111, 168, 220, 0.15);
|
||||
--app-accent-ink: #b9dcfa;
|
||||
--app-danger: #f08a82;
|
||||
--app-danger-soft: rgba(240, 138, 130, 0.14);
|
||||
--app-warn: #e0b072;
|
||||
--app-warn-soft: rgba(224, 176, 114, 0.14);
|
||||
--app-info: #9db4cc;
|
||||
--app-info-soft: rgba(157, 180, 204, 0.14);
|
||||
--app-ring: rgba(92, 196, 163, 0.24);
|
||||
--app-ring: rgba(111, 168, 220, 0.24);
|
||||
--app-shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
|
||||
--app-shadow: 0 24px 48px -28px rgba(0, 0, 0, 0.8);
|
||||
--app-nav-h: 58px;
|
||||
@@ -109,10 +109,10 @@
|
||||
--bs-heading-color: var(--app-text);
|
||||
--bs-link-color: var(--app-accent);
|
||||
--bs-link-hover-color: var(--app-accent-strong);
|
||||
--bs-primary: #2b7d61;
|
||||
--bs-primary-rgb: 43, 125, 97;
|
||||
--bs-success: #2b7d61;
|
||||
--bs-success-rgb: 43, 125, 97;
|
||||
--bs-primary: #2b5d94;
|
||||
--bs-primary-rgb: 43, 93, 148;
|
||||
--bs-success: #2b5d94;
|
||||
--bs-success-rgb: 43, 93, 148;
|
||||
--bs-border-radius: var(--app-radius);
|
||||
--bs-border-radius-sm: var(--app-radius-sm);
|
||||
--bs-border-radius-lg: 16px;
|
||||
@@ -762,13 +762,14 @@ fieldset { border: 0; margin: 0; padding: 0; min-width: 0; }
|
||||
overflow: hidden;
|
||||
box-shadow: var(--app-shadow-sm);
|
||||
}
|
||||
.cal-dow { display: grid; grid-template-columns: repeat(7, 1fr); background: var(--app-surface-2); border-bottom: 1px solid var(--app-border); }
|
||||
.cal-dow { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); background: var(--app-surface-2); border-bottom: 1px solid var(--app-border); }
|
||||
.cal-dow span { padding: 8px 0; text-align: center; font-size: 0.75rem; color: var(--app-text-3); }
|
||||
.cal-week { display: grid; grid-template-columns: repeat(7, 1fr); }
|
||||
.cal-week { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); }
|
||||
|
||||
.cal-cell {
|
||||
position: relative;
|
||||
display: flex; flex-direction: column; gap: 4px;
|
||||
min-width: 0;
|
||||
min-height: 112px; padding: 8px 9px 10px 12px;
|
||||
border-right: 1px solid var(--app-border);
|
||||
border-bottom: 1px solid var(--app-border);
|
||||
@@ -795,6 +796,26 @@ 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) 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) 26%, 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); }
|
||||
@@ -843,7 +864,7 @@ fieldset { border: 0; margin: 0; padding: 0; min-width: 0; }
|
||||
.pkg-tabs a em { font-family: var(--app-mono); font-style: normal; font-size: 0.6875rem; color: var(--app-text-3); background: var(--app-surface-2); border-radius: 999px; padding: 0 6px; }
|
||||
.pkg-tabs a:hover { border-color: var(--app-accent); color: var(--app-text); text-decoration: none; }
|
||||
.pkg-tabs a.on { background: var(--app-accent-solid); border-color: var(--app-accent-solid); color: #fff; }
|
||||
.pkg-tabs a.on em { background: rgba(255, 255, 255, 0.2); color: #fff; }
|
||||
.pkg-tabs a.on em { background: rgba(0, 0, 0, 0.2); color: #fff; }
|
||||
.pkg-tabs a.on i { background: #fff; }
|
||||
|
||||
/* ---------- 12. 当日抽屉 ---------- */
|
||||
@@ -905,6 +926,29 @@ 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; }
|
||||
@@ -1169,6 +1213,9 @@ 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; }
|
||||
/* 手机上隐藏低优先级列,避免横向滚动 */
|
||||
|
||||
+65
-20
@@ -76,6 +76,8 @@
|
||||
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;
|
||||
|
||||
/* 只覆盖“上一次自动填的”终止日,不碰用户手填的值 */
|
||||
@@ -87,6 +89,13 @@
|
||||
}
|
||||
}
|
||||
|
||||
/* 显示/隐藏一组字段;隐藏时一并 disable,避免同名字段重复提交 */
|
||||
function setWrap(wrap, show) {
|
||||
if (!wrap) return;
|
||||
wrap.hidden = !show;
|
||||
wrap.querySelectorAll('input, select, textarea').forEach(function (el) { el.disabled = !show; });
|
||||
}
|
||||
|
||||
function sync() {
|
||||
var opt = sel.options[sel.selectedIndex];
|
||||
var unit = opt && opt.getAttribute('data-unit');
|
||||
@@ -94,30 +103,48 @@
|
||||
var validity = opt && parseInt(opt.getAttribute('data-validity') || '0', 10);
|
||||
|
||||
if (unit === 'season') {
|
||||
if (daysWrap) daysWrap.hidden = true;
|
||||
if (countWrap) countWrap.hidden = true;
|
||||
if (endWrap) endWrap.hidden = true;
|
||||
if (startWrap) startWrap.hidden = true;
|
||||
setWrap(daysWrap, false);
|
||||
setWrap(countWrap, false);
|
||||
setWrap(endWrap, false);
|
||||
setWrap(startWrap, false);
|
||||
setWrap(cyclesWrap, false);
|
||||
if (startInput) startInput.required = false;
|
||||
return;
|
||||
}
|
||||
|
||||
if (startWrap) startWrap.hidden = false;
|
||||
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') {
|
||||
if (daysWrap) daysWrap.hidden = true;
|
||||
if (countWrap) { countWrap.hidden = false; if (amount) countWrap.querySelector('input').value = amount; }
|
||||
if (endWrap) endWrap.hidden = false;
|
||||
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') {
|
||||
if (daysWrap) { daysWrap.hidden = false; if (amount) daysWrap.querySelector('input').value = amount; }
|
||||
if (countWrap) countWrap.hidden = true;
|
||||
if (endWrap) endWrap.hidden = false;
|
||||
setWrap(daysWrap, true);
|
||||
setWrap(countWrap, false);
|
||||
setWrap(endWrap, true);
|
||||
if (amount) daysWrap.querySelector('input').value = amount;
|
||||
} else {
|
||||
if (daysWrap) daysWrap.hidden = false;
|
||||
if (countWrap) countWrap.hidden = true;
|
||||
if (endWrap) endWrap.hidden = true;
|
||||
setWrap(daysWrap, true);
|
||||
setWrap(countWrap, false);
|
||||
setWrap(endWrap, false);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -134,22 +161,40 @@
|
||||
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' ? '次' : '天';
|
||||
var seasonWrap = form.querySelector('[data-season-wrap]');
|
||||
var validityWrap = form.querySelector('[data-validity-wrap]');
|
||||
|
||||
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.hidden = v !== 'season';
|
||||
seasonWrap.querySelectorAll('input').forEach(function (i) { i.required = v === 'season'; });
|
||||
}
|
||||
if (validityWrap) { validityWrap.hidden = v !== 'count'; }
|
||||
if (cycleInput) cycleInput.required = v === 'abyss';
|
||||
}
|
||||
|
||||
radios.forEach(function (r) { r.addEventListener('change', sync); });
|
||||
sync();
|
||||
});
|
||||
|
||||
@@ -7,36 +7,36 @@
|
||||
|
||||
:root,
|
||||
[data-bs-theme="light"] {
|
||||
--scr-bg: #eef3ee;
|
||||
--scr-bg: #eef4fb;
|
||||
--scr-panel: #ffffff;
|
||||
--scr-panel-2: #f7faf7;
|
||||
--scr-line: #dbe5dc;
|
||||
--scr-text: #0f241d;
|
||||
--scr-text-2: #33493f;
|
||||
--scr-muted: #5f7468;
|
||||
--scr-accent: #1f6b52;
|
||||
--scr-accent-2: #2f8a69;
|
||||
--scr-accent-solid: #1f6b52;
|
||||
--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(31, 107, 82, 0.12);
|
||||
--scr-shadow: 0 14px 32px -22px rgba(16, 32, 24, 0.4);
|
||||
--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: #0a120f;
|
||||
--scr-panel: #111a16;
|
||||
--scr-panel-2: #16211c;
|
||||
--scr-line: #24352d;
|
||||
--scr-text: #e8f2ec;
|
||||
--scr-text-2: #b5c9bd;
|
||||
--scr-muted: #87a094;
|
||||
--scr-accent: #5cc4a3;
|
||||
--scr-accent-2: #7bd7b8;
|
||||
--scr-accent-solid: #2b7d61;
|
||||
--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(92, 196, 163, 0.16);
|
||||
--scr-glow: 0 0 24px rgba(111, 168, 220, 0.16);
|
||||
--scr-shadow: 0 18px 40px -24px rgba(0, 0, 0, 0.8);
|
||||
}
|
||||
|
||||
@@ -198,10 +198,10 @@ body.screen-body::before {
|
||||
.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-muted); }
|
||||
.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-accent); font-weight: 700; }
|
||||
.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)); }
|
||||
@@ -226,7 +226,7 @@ body.screen-body::before {
|
||||
.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; opacity: 0.8; }
|
||||
.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; }
|
||||
|
||||
@@ -41,15 +41,26 @@
|
||||
<button class="btn btn-primary btn-sm">今日打卡</button>
|
||||
</form>
|
||||
{{end}}
|
||||
{{if .Season}}
|
||||
{{if eq .SeasonDone ""}}
|
||||
<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}}
|
||||
<span class="chip chip-active">赛季已完成 {{.SeasonDone}}</span>
|
||||
{{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}}
|
||||
|
||||
@@ -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}}"
|
||||
href="/calendar?y={{$.D.Year}}&m={{$.D.Month}}&d={{.Date}}&{{$.D.FilterQuery}}" role="gridcell">
|
||||
{{if .HasSeason}}<span class="season-band{{if .SeasonStart}} start{{end}}{{if .SeasonEnd}} end{{end}}" style="--sc:{{.SeasonColor}}" aria-hidden="true"></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}}{{if .BlockColor}} has-block{{end}}"
|
||||
href="/calendar?y={{$.D.Year}}&m={{$.D.Month}}&d={{.Date}}&{{$.D.FilterQuery}}" role="gridcell"{{if .BlockColor}} style="--block:{{.BlockColor}}"{{end}}>
|
||||
{{if .Strip}}<span class="asg-strip" aria-hidden="true">{{range .Strip}}<i style="background:{{.}}"></i>{{end}}</span>{{end}}
|
||||
<div class="cell-top">
|
||||
<span class="dnum">{{.Day}}</span>
|
||||
@@ -51,6 +50,7 @@
|
||||
{{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>
|
||||
@@ -173,7 +173,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>
|
||||
<a class="btn btn-soft btn-sm" href="/calendar?y={{$.D.Year}}&m={{$.D.Month}}&d={{$.D.Selected}}&{{$.D.FilterQuery}}&extend={{.ID}}#extend">追加时长</a>
|
||||
{{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}}
|
||||
</div>
|
||||
</details>
|
||||
</div>
|
||||
@@ -205,12 +205,14 @@
|
||||
<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}}">
|
||||
@@ -218,7 +220,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>
|
||||
<a class="btn btn-soft btn-sm" href="/calendar?y={{$.D.Year}}&m={{$.D.Month}}&d={{$.D.Selected}}&{{$.D.FilterQuery}}&extend={{.ID}}#extend">追加时长</a>
|
||||
{{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}}
|
||||
</div>
|
||||
</details>
|
||||
</div>
|
||||
|
||||
@@ -89,8 +89,8 @@
|
||||
<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}}{{.Unit}}{{end}}" data-amount="{{.DefaultAmount}}" data-validity="{{.DefaultValidityDays}}"{{if .Archived}} disabled{{end}}{{if .SeasonExpired $.TodayStr}} disabled{{end}}>
|
||||
{{.Name}} · {{.UnitLabel}} {{if .Season}}{{.SeasonStart}}~{{.SeasonEnd}}{{else}}{{.DefaultAmount}}{{if eq .Unit "day"}}天{{else}}次{{end}}{{end}}{{if .SeasonExpired $.TodayStr}}(赛季已结束){{end}}{{if .Archived}}(已归档){{end}}
|
||||
<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>
|
||||
{{end}}
|
||||
</select>
|
||||
@@ -103,6 +103,9 @@
|
||||
<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>
|
||||
|
||||
@@ -4,9 +4,8 @@
|
||||
<div>
|
||||
<h1>{{.D.Package.Name}}</h1>
|
||||
<p>
|
||||
{{if eq .D.Package.Unit "day"}}按日{{else}}按次{{end}} ·
|
||||
默认 {{.D.Package.DefaultAmount}}{{if eq .D.Package.Unit "day"}} 天{{else}} 次{{end}} ·
|
||||
{{if .D.Package.Tag}}标签「{{.D.Package.Tag}}」 · {{end}}{{if .D.Package.CalendarSeparate}}独立日历 · {{end}}
|
||||
{{.D.Package.UnitLabel}} · {{.D.Package.AmountText}}{{if .D.Package.CycleLabel}} · {{.D.Package.CycleLabel}}{{end}}
|
||||
{{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>
|
||||
</div>
|
||||
@@ -27,25 +26,42 @@
|
||||
|
||||
<form method="post" action="/packages/{{.D.Package.ID}}/subscribe" class="section card">
|
||||
<h2>批量开通</h2>
|
||||
<p class="muted small">勾选客户后一次开通;已经是该套餐的客户会自动跳过。开始日期默认今天,时长/次数默认取套餐设置,可改。</p>
|
||||
<p class="muted small">勾选客户后一次开通;已经是该套餐的客户会自动跳过。{{if .D.Package.Season}}通行证从套餐区间开始,整段完成。{{else if .D.Package.Abyss}}按周期数开通,结束日自动计算。{{else}}开始日期默认今天,数量默认取套餐设置,可改。{{end}}</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>
|
||||
</label>
|
||||
{{if eq .D.Package.Unit "day"}}
|
||||
<label class="field"><span>天数</span>
|
||||
<input type="number" name="days" min="1" max="3650" value="{{.D.Package.DefaultAmount}}">
|
||||
</label>
|
||||
{{else}}
|
||||
</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>
|
||||
{{end}}
|
||||
</div>
|
||||
{{end}}
|
||||
|
||||
<div class="table-wrap">
|
||||
<table class="table tight">
|
||||
|
||||
@@ -3,39 +3,48 @@
|
||||
<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="例如 包月日常 / 深渊通行证 / 10 次副本">
|
||||
</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)}} checked{{end}}>
|
||||
<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)}} checked{{end}}>
|
||||
<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>
|
||||
<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>
|
||||
<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"><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>
|
||||
@@ -62,7 +71,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>
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
{{if .Note}}<div class="muted small">{{.Note}}</div>{{end}}
|
||||
</td>
|
||||
<td>{{.UnitLabel}}</td>
|
||||
<td class="mono">{{.DefaultAmount}}{{if eq .Unit "day"}} 天{{else}} 次{{end}}</td>
|
||||
<td class="mono">{{.AmountText}}</td>
|
||||
<td class="mono">{{if .HasPrice}}¥{{money .PriceCents}}{{else}}—{{end}}</td>
|
||||
<td class="mono">{{.ActiveCount}} / {{.SubCount}}</td>
|
||||
<td>{{if .Archived}}<span class="chip chip-closed">已归档</span>{{else}}<span class="chip chip-active">启用中</span>{{end}}</td>
|
||||
|
||||
@@ -49,7 +49,7 @@
|
||||
<td class="mono small">{{.PeriodText}}</td>
|
||||
<td class="actions-cell">
|
||||
{{if ne .Status "closed"}}
|
||||
<a class="btn btn-soft btn-sm" href="/customers/{{.CustomerID}}?extend={{.ID}}#extend">追加</a>
|
||||
{{if not (or .Season .Abyss)}}<a class="btn btn-soft btn-sm" href="/customers/{{.CustomerID}}?extend={{.ID}}#extend">追加</a>{{end}}
|
||||
{{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"}}
|
||||
|
||||
+44
-15
@@ -29,6 +29,9 @@ type SubView struct {
|
||||
Today string
|
||||
// CanCheckinToday 表示今天可以直接打卡(订阅在有效状态与区间内)
|
||||
CanCheckinToday bool
|
||||
// CanPassToday / CanAbyssToday 整段型订阅今天能否完成(在有效区间内且未完成)
|
||||
CanPassToday bool
|
||||
CanAbyssToday bool
|
||||
}
|
||||
|
||||
// AssigneeLabel 返回打手显示名;未指派时给灰字提示。
|
||||
@@ -79,20 +82,26 @@ func newSubView(s store.Subscription, today time.Time, warnDays int) SubView {
|
||||
Today: domain.Date(today),
|
||||
}
|
||||
if s.Season {
|
||||
v.UnitLabel = "赛季"
|
||||
if s.SeasonDone != "" {
|
||||
v.RemainText = "赛季已完成"
|
||||
v.RemainShort = "已完成"
|
||||
v.StateLabel = "赛季已完成"
|
||||
v.StateClass = "active"
|
||||
} else {
|
||||
v.RemainText = fmt.Sprintf("剩 %d 天", e.RemainingDays)
|
||||
v.RemainShort = fmt.Sprintf("%d 天", e.RemainingDays)
|
||||
}
|
||||
v.UnitLabel = "通行证"
|
||||
v.PeriodText = s.StartDate + " → " + s.EndDate
|
||||
return v
|
||||
}
|
||||
if s.Unit == domain.UnitDay {
|
||||
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)
|
||||
@@ -143,9 +152,29 @@ func newSubView(s store.Subscription, today time.Time, warnDays int) SubView {
|
||||
v.DueText = "次数已用尽"
|
||||
}
|
||||
}
|
||||
// 今天能否打卡:进行中且(按日或有剩余次数)
|
||||
v.CanCheckinToday = e.State == domain.StateActive &&
|
||||
// 整段型:完成后统一显示「已完成」,不再提示到期
|
||||
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
|
||||
}
|
||||
return v
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user