From 30511ed82eb3c5fb36a877ed49e5f55e373057d7 Mon Sep 17 00:00:00 2001 From: shaoying Date: Thu, 18 Feb 2021 20:11:50 +0800 Subject: [PATCH] add count --- core/team/count.css | 22 ++++++++++++++++++++++ core/team/count.go | 46 +++++++++++++++++++++++++++++++++++++++++++++ core/team/count.js | 20 ++++++++++++++++++++ 3 files changed, 88 insertions(+) create mode 100644 core/team/count.css create mode 100644 core/team/count.go create mode 100644 core/team/count.js diff --git a/core/team/count.css b/core/team/count.css new file mode 100644 index 00000000..4c8e7aee --- /dev/null +++ b/core/team/count.css @@ -0,0 +1,22 @@ +fieldset.count div.output div.item { + margin:10px; padding:10px; + border:solid 2px green; + float:left; +} +fieldset.count div.output div.item.gone { + border:solid 2px red; +} +fieldset.count div.output div.item div.name { + font-size:38px; color:green; + font-family:cursive; + text-align:center; +} +fieldset.count div.output div.item span.day { + font-size:24px; color:green; +} +fieldset.count div.output div.item.gone div.name { + color:red; +} +fieldset.count div.output div.item.gone span.day { + color:red; +} diff --git a/core/team/count.go b/core/team/count.go new file mode 100644 index 00000000..1e669e86 --- /dev/null +++ b/core/team/count.go @@ -0,0 +1,46 @@ +package team + +import ( + ice "github.com/shylinux/icebergs" + "github.com/shylinux/icebergs/base/mdb" + kit "github.com/shylinux/toolkits" + + "strings" + "time" +) + +const COUNT = "count" + +func init() { + Index.Merge(&ice.Context{Commands: map[string]*ice.Command{ + COUNT: {Name: "count zone id auto insert", Help: "倒计时", Meta: kit.Dict(kit.MDB_DISPLAY, COUNT), Action: map[string]*ice.Action{ + mdb.INSERT: {Name: "insert zone type=once,step,week name text begin_time@date close_time@date", Help: "添加", Hand: func(m *ice.Message, arg ...string) { + m.Cmdy(TASK, mdb.INSERT, arg) + }}, + }, Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) { + if len(arg) > 0 && arg[0] == kit.MDB_ACTION { + m.Cmdy(TASK, arg) + return + } + + if _task_list(m, kit.Select("", arg, 0), kit.Select("", arg, 1)); len(arg) == 0 { + return + } + + m.SortTime(TaskField.BEGIN_TIME) + m.Table(func(index int, value map[string]string, head []string) { + if value[kit.MDB_STATUS] == TaskStatus.CANCEL { + return + } + + t := kit.Time(value[TaskField.BEGIN_TIME])/int64(time.Second) - time.Now().Unix() + m.Echo(`
距离 %v
%v
%v %v
`, + kit.Select("gone", "come", t > 0), value[kit.MDB_TEXT], + strings.Split(value[TaskField.BEGIN_TIME], " ")[0], + value[kit.MDB_NAME], + kit.Select("已经", "还有", t > 0), t/3600/24, + ) + }) + }}, + }}) +} diff --git a/core/team/count.js b/core/team/count.js new file mode 100644 index 00000000..bbd3b4f4 --- /dev/null +++ b/core/team/count.js @@ -0,0 +1,20 @@ +Volcanos("onimport", {help: "导入数据", list: [], _init: function(can, msg, list, cb, target) { + can.onmotion.clear(can) + can.onappend.table(can, msg) + can.onappend.board(can, msg.Result()) + typeof cb == "function" && cb(msg) + }, +}, ["count.css"]) +Volcanos("onaction", {help: "控件交互", list: ["播放"], + "播放": function(event, can) { + can.page.Select(can, can._output, "div.item", function(item) { + can.onmotion.hidden(can, item) + }) + can.core.Next(can.page.Select(can, can._output, "div.item"), function(item, next) { + can.onmotion.show(can, 300, next, item) + }, function() { + can.user.toast(can, "播放结束", can.Option("zone")) + }) + }, +}) +Volcanos("onexport", {help: "导出数据", list: []})