`, strings.Join(note[1:], "\n"), note[0], len(note)-1)
} else {
note[0] = kit.Format(`%s%s`, note[0], "")
}
m.Push(head[int(day.Weekday())], note[0])
}
// 下月开头
tail := end.AddDate(0, 0, 6-int(end.Weekday())+1)
for day := end; end.Weekday() != 0 && day.Before(tail); day = day.AddDate(0, 0, 1) {
m.Push(head[int(day.Weekday())], day.Day())
}
case "year":
// 年计划
for i := 1; i < 13; i++ {
m.Push("month", kit.Format("%02d", i))
m.Push("task", "")
}
// 查询任务
match := first.Format("2006")
template := m.Conf("plan", kit.Keys("meta.template", kit.Select("year", m.Option("template"))))
m.Richs("task", nil, "*", func(key string, value map[string]interface{}) {
m.Grows("task", kit.Keys("hash", key), "", "", func(index int, value map[string]interface{}) {
if now := kit.Format(value["begin_time"]); now[0:4] == match && kit.Format(value["type"]) == "年度目标" {
b, _ := kit.Render(kit.Format(template, key), value)
m.Push("month", now[5:7])
m.Push("task", string(b))
}
})
})
m.Sort("month", "int")
case "long":
// 长计划
one := time.Unix(int64(kit.Time(kit.Select(kit.Format("%d-01-01", first.Year()-5), arg, 1))), 0)
end := time.Unix(int64(kit.Time(kit.Select(kit.Format("%d-12-31", first.Year()+5), arg, 2))), 0)
for day := one; day.Before(end); day = day.AddDate(1, 0, 0) {
m.Push("year", day.Year())
m.Push("task", "")
}
// 查询任务
template := m.Conf("plan", kit.Keys("meta.template", kit.Select("year", m.Option("template"))))
m.Richs("task", nil, "*", func(key string, value map[string]interface{}) {
m.Grows("task", kit.Keys("hash", key), "", "", func(index int, value map[string]interface{}) {
if t, e := time.ParseInLocation(ice.ICE_TIME, kit.Format(value["begin_time"]), time.Local); e == nil {
if t.After(one) && t.Before(end) && kit.Format(value["type"]) == "年度目标" {
b, _ := kit.Render(kit.Format(template, key), value)
m.Push("year", t.Year())
m.Push("task", string(b))
}
}
})
})
m.Sort("year", "int")
}
}},
"stat": {Name: "stat", Help: "统计", Meta: kit.Dict(), Hand: func(m *ice.Message, c *ice.Context, key string, arg ...string) {
m.Option("cache.limit", "10000")
m.Richs("task", nil, kit.Select("*", arg, 0), func(key string, value map[string]interface{}) {
stat := map[string]int{}
m.Grows("task", kit.Keys("hash", key), "", "", func(index int, value map[string]interface{}) {
stat[kit.Format(value["status"])] += 1
})
m.Push("zone", kit.Value(value, "meta.zone"))
for _, k := range []string{"prepare", "process", "cancel", "finish"} {
m.Push(k, stat[k])
}
})
}},
"progress": {Name: "progress", Help: "进度", Meta: kit.Dict(
"remote", "you", "display", "team/miss",
"detail", []string{"回退", "前进", "取消", "完成"},
), List: kit.List(
kit.MDB_INPUT, "text", "value", "",
kit.MDB_INPUT, "button", "value", "查看", "action", "auto",
), Hand: func(m *ice.Message, c *ice.Context, key string, arg ...string) {
hot := kit.Select(ice.FAVOR_MISS, m.Option("hot"))
if len(arg) > 0 {
m.Richs(ice.WEB_FAVOR, nil, hot, func(key string, value map[string]interface{}) {
m.Grows(ice.WEB_FAVOR, kit.Keys("hash", key), "id", arg[0], func(index int, value map[string]interface{}) {
switch value = value["extra"].(map[string]interface{}); arg[1] {
case "前进":
if value["status"] == "准备中" {
value["begin_time"] = m.Time()
value["close_time"] = m.Time("30m")
}
if next := m.Conf(ice.APP_MISS, kit.Keys("meta.fsm", value["status"], "next")); next != "" {
value["status"] = next
kit.Value(value, "change.-2", kit.Dict("time", m.Time(), "status", next))
}
case "回退":
if prev := m.Conf(ice.APP_MISS, kit.Keys("meta.fsm", value["status"], "prev")); prev != "" {
value["status"] = prev
kit.Value(value, "change.-2", kit.Dict("time", m.Time(), "status", prev))
}
case "取消":
value["status"] = "已取消"
value["close_time"] = m.Time()
case "完成":
value["status"] = "已完成"
value["close_time"] = m.Time()
}
})
})
}
m.Confm(ice.APP_MISS, "meta.mis", func(index int, value string) {
m.Push(value, "")
})
m.Richs(ice.WEB_FAVOR, nil, hot, func(key string, value map[string]interface{}) {
m.Grows(ice.WEB_FAVOR, kit.Keys("hash", key), "", "", func(index int, value map[string]interface{}) {
m.Push(kit.Format(kit.Value(value, "extra.status")),
kit.Format(`%v`,
kit.Format("%s-%s\n%s", kit.Value(value, "extra.begin_time"), kit.Value(value, "extra.close_time"), value["text"]),
value["id"], value["name"]))
})
})
}},
},
}
func init() { web.Index.Register(Index, &web.Frame{}) }