1) 工作台速录 - 手机尾号输入框下方新增 3×4 触摸小键盘(1-9、0、⌫、✓),点 ✓ 直接提交;实体键盘仍可输入 - 抽屉顶部新增秒级时钟(HH:MM:SS),位于日期标题上方 2) 日历格子 - 移除排单缩略信息(客户名/套餐色签/“x/y 单”小字) - 保留左侧打手颜色竖条,中间改为大字「待完成 / 总数」,例如 1/2 = 还剩 1 单、共 2 单 - 大屏格子按此前约定保持原样 3) 客户停用 / 恢复 / 彻底删除 - customers 新增 archived 列(0/1);停用后默认从客户列表、日历、待办、大屏、到期提醒、徽标中隐藏,订阅与打卡记录原样保留 - 恢复后立即回到日历;列表右上角可切换「显示已停用」,已停用行带标记 - 彻底删除为二次确认操作,依赖外键级联清理订阅、打卡、暂停、追加记录与加急标记 - 停用/恢复/删除都会写入操作日志 4) 按钮收纳 - 任务行只露出「完成」,跳过 / 加急(取消加急)/ 追加收进「⋯」菜单;已完成行只露「撤销打卡」等,点空白处自动收起 - 加急、跳过等原有能力不变,仅入口折叠 5) 顶栏 - 在「今日到期」「3 天内到期」右侧新增「7 天内到期」徽标,固定统计未来 7 天 6) 视觉 - 移除管理端背景的横线装饰,改为纯底色;大屏网格背景保留 数据库兼容性: - 只新增 customers.archived 一列,老库启动时自动 ALTER,可重复迁移;原有表结构与接口不变 测试: - 新增单测 TestCustomerArchiveFilters:停用后日历/到期/徽标/搜索/列表全部过滤、恢复回日历、彻底删除级联清理订阅与打卡 - 功能验证 20 项(键盘、格子计数、折叠菜单、7 天徽标、时钟、停用/恢复/删除、背景)全部通过 - 原有 119 项验收回归全绿;go vet / go test ./... 通过;版本号 1.5.0
This commit is contained in:
@@ -12,12 +12,14 @@ import (
|
||||
)
|
||||
|
||||
type customersData struct {
|
||||
List []store.Customer
|
||||
Pager Pager
|
||||
Q string
|
||||
Total int
|
||||
PackageCount int
|
||||
NoPackages bool
|
||||
List []store.Customer
|
||||
Pager Pager
|
||||
Q string
|
||||
Total int
|
||||
PackageCount int
|
||||
NoPackages bool
|
||||
ShowArchived bool
|
||||
ArchivedCount int
|
||||
}
|
||||
|
||||
func (s *Server) handleCustomers(w http.ResponseWriter, r *http.Request) {
|
||||
@@ -28,21 +30,24 @@ func (s *Server) handleCustomers(w http.ResponseWriter, r *http.Request) {
|
||||
if pageNo < 1 {
|
||||
pageNo = 1
|
||||
}
|
||||
list, total, err := s.db.ListCustomers(q, pageSize, (pageNo-1)*pageSize, domain.Date(today), warn)
|
||||
showArchived := r.URL.Query().Get("archived") == "1"
|
||||
list, total, err := s.db.ListCustomers(q, pageSize, (pageNo-1)*pageSize, domain.Date(today), warn, showArchived)
|
||||
if err != nil {
|
||||
http.Error(w, "读取客户失败", http.StatusInternalServerError)
|
||||
return
|
||||
}
|
||||
pager := newPager(r, pageNo, pageSize, total)
|
||||
if pager.Page != pageNo {
|
||||
list, total, err = s.db.ListCustomers(q, pageSize, (pager.Page-1)*pageSize, domain.Date(today), warn)
|
||||
list, total, err = s.db.ListCustomers(q, pageSize, (pager.Page-1)*pageSize, domain.Date(today), warn, showArchived)
|
||||
if err != nil {
|
||||
http.Error(w, "读取客户失败", http.StatusInternalServerError)
|
||||
return
|
||||
}
|
||||
}
|
||||
pkgs, _ := s.db.ListPackages(false)
|
||||
data := &customersData{List: list, Pager: pager, Q: q, Total: total, PackageCount: len(pkgs), NoPackages: len(pkgs) == 0}
|
||||
archivedN, _ := s.db.CountArchivedCustomers()
|
||||
data := &customersData{List: list, Pager: pager, Q: q, Total: total, PackageCount: len(pkgs), NoPackages: len(pkgs) == 0,
|
||||
ShowArchived: showArchived, ArchivedCount: archivedN}
|
||||
p := s.newPage(r, "客户", "customers")
|
||||
p.D = data
|
||||
s.render(w, r, "customers", p)
|
||||
@@ -255,6 +260,58 @@ func (s *Server) handleCustomerDetail(w http.ResponseWriter, r *http.Request) {
|
||||
s.render(w, r, "customer_detail", p)
|
||||
}
|
||||
|
||||
// handleCustomerArchive 停用客户:默认从列表、日历、大屏隐藏,订阅保留。
|
||||
func (s *Server) handleCustomerArchive(w http.ResponseWriter, r *http.Request) {
|
||||
id := pathID(r)
|
||||
c, err := s.db.Customer(id)
|
||||
if err != nil {
|
||||
http.NotFound(w, r)
|
||||
return
|
||||
}
|
||||
if err := s.db.SetCustomerArchived(id, true); err != nil {
|
||||
s.redirect(w, r, "/customers/"+itoa(id), "停用失败:"+err.Error())
|
||||
return
|
||||
}
|
||||
s.logOp(r, "停用客户", "customer", id, c.Tail+" "+c.Name+"(订阅保留,不再上日历)")
|
||||
s.redirect(w, r, "/customers", "已停用客户 "+c.Tail+" "+c.Name+",可在「已停用」里恢复")
|
||||
}
|
||||
|
||||
// handleCustomerRestore 恢复客户,订单一并回到日历。
|
||||
func (s *Server) handleCustomerRestore(w http.ResponseWriter, r *http.Request) {
|
||||
id := pathID(r)
|
||||
c, err := s.db.Customer(id)
|
||||
if err != nil {
|
||||
http.NotFound(w, r)
|
||||
return
|
||||
}
|
||||
if err := s.db.SetCustomerArchived(id, false); err != nil {
|
||||
s.redirect(w, r, "/customers/"+itoa(id), "恢复失败:"+err.Error())
|
||||
return
|
||||
}
|
||||
s.logOp(r, "恢复客户", "customer", id, c.Tail+" "+c.Name)
|
||||
s.redirect(w, r, "/customers/"+itoa(id), "已恢复客户 "+c.Tail+" "+c.Name)
|
||||
}
|
||||
|
||||
// handleCustomerDelete 彻底删除客户及其订阅/打卡/追加记录(外键级联)。
|
||||
func (s *Server) handleCustomerDelete(w http.ResponseWriter, r *http.Request) {
|
||||
id := pathID(r)
|
||||
c, err := s.db.Customer(id)
|
||||
if err != nil {
|
||||
http.NotFound(w, r)
|
||||
return
|
||||
}
|
||||
if r.PostFormValue("confirm") != "delete" {
|
||||
s.redirect(w, r, "/customers/"+itoa(id), "请在弹窗里确认删除")
|
||||
return
|
||||
}
|
||||
if err := s.db.DeleteCustomer(id); err != nil {
|
||||
s.redirect(w, r, "/customers/"+itoa(id), "删除失败:"+err.Error())
|
||||
return
|
||||
}
|
||||
s.logOp(r, "删除客户", "customer", id, c.Tail+" "+c.Name+"(含订阅与打卡记录)")
|
||||
s.redirect(w, r, "/customers", "已彻底删除客户 "+c.Tail+" "+c.Name)
|
||||
}
|
||||
|
||||
// handleCustomerAssignee 从客户详情快速指派/取消打手。
|
||||
func (s *Server) handleCustomerAssignee(w http.ResponseWriter, r *http.Request) {
|
||||
id := pathID(r)
|
||||
|
||||
Reference in New Issue
Block a user