mirror of
https://shylinux.com/x/enterprise
synced 2025-05-09 23:18:09 +08:00
103 lines
3.0 KiB
Go
103 lines
3.0 KiB
Go
package xiangmuguanli
|
|
|
|
import (
|
|
"shylinux.com/x/ice"
|
|
kit "shylinux.com/x/toolkits"
|
|
|
|
"shylinux.com/x/enterprise/src/xiangmuguanli/model"
|
|
)
|
|
|
|
type Plan struct {
|
|
Table
|
|
order string `data:"1"`
|
|
fields string `data:"title,content,plan_status,task_count,begin_time,end_time,process_time,finish_time,user_uid"`
|
|
create string `name:"create title* content* begin_time:select@date end_time:select@date" role:"leader"`
|
|
modify string `name:"modify title* content* begin_time:select@date end_time:select@date" role:"leader"`
|
|
remove string `name:"remove" role:"leader"`
|
|
process string `name:"process" role:"leader"`
|
|
taskCreate string `name:"taskCreate title* content* begin_time:select@date end_time:select@date" role:"worker"`
|
|
}
|
|
|
|
func (s Plan) Create(m *ice.Message, arg ...string) {
|
|
s.ValueCreate(m, kit.ArgDef(arg, kit.Simple(model.BEGIN_TIME, m.Time(), model.END_TIME, m.Time("168h"))...)...)
|
|
s.SendMessage(m, "", "")
|
|
}
|
|
func (s Plan) List(m *ice.Message, arg ...string) {
|
|
isLeader, isWorker := s.IsLeader(m), s.IsWorker(m)
|
|
s.Orders(m, model.STATUS, model.TASK_COUNT, s.Desc(model.CREATED_AT))
|
|
s.ValueList(m, arg).Table(func(value ice.Maps) {
|
|
button := []ice.Any{}
|
|
switch PlanStatus(kit.Int(value[model.PLAN_STATUS])) {
|
|
case PlanCreate:
|
|
if isLeader {
|
|
button = append(button, s.Process, s.Modify, s.Remove)
|
|
}
|
|
case PlanProcess:
|
|
if isWorker {
|
|
button = append(button, s.TaskCreate)
|
|
}
|
|
if isLeader && kit.Int(value[model.TASK_COUNT]) > 0 {
|
|
button = append(button, s.Finish)
|
|
}
|
|
if isLeader && m.Option(model.MARKET_UID) == "" {
|
|
button = append(button, s.MarketInsert)
|
|
}
|
|
if isLeader && kit.Int(value[model.TASK_COUNT]) == 0 {
|
|
button = append(button, s.Remove)
|
|
}
|
|
case PlanFinish:
|
|
kit.If(m.FieldsIsDetail(), func() { s.DoneMessage(m) })
|
|
}
|
|
m.PushButton(button...)
|
|
}).Display("")
|
|
if !s.IsLeader(m) {
|
|
if m.Action(); m.Length() == 0 {
|
|
m.SetResult("请等待「管理员」创建项目计划")
|
|
}
|
|
}
|
|
m.Option("otherList", "taskList,doneList")
|
|
}
|
|
func (s Plan) Process(m *ice.Message, arg ...string) {
|
|
s.changeStatus(m, PlanCreate, PlanProcess)
|
|
}
|
|
func (s Plan) Finish(m *ice.Message, arg ...string) {
|
|
if s.finishCheck(m, Task{}, "任务") {
|
|
return
|
|
}
|
|
if s.finishCheck(m, Done{}, "提报") {
|
|
return
|
|
}
|
|
s.changeStatus(m, PlanProcess, PlanFinish)
|
|
}
|
|
func (s Plan) TaskCreate(m *ice.Message, arg ...string) {
|
|
s.OtherCreate(m, Task{}, arg...)
|
|
}
|
|
func (s Plan) TaskList(m *ice.Message, arg ...string) {
|
|
s.OtherList(m, Task{}).Display("task.js")
|
|
}
|
|
func (s Plan) DoneList(m *ice.Message, arg ...string) {
|
|
s.OtherList(m, Done{}).Display("done.js")
|
|
}
|
|
|
|
func init() { ice.TeamCtxCmd(Plan{}) }
|
|
|
|
func (s Plan) changeStatus(m *ice.Message, from, to PlanStatus) {
|
|
s.ChangeStatus(m, int(from), int(to), m.ActionKey()+"_time", m.Time())
|
|
}
|
|
|
|
type PlanStatus int
|
|
|
|
const (
|
|
PlanCreate PlanStatus = iota
|
|
PlanProcess
|
|
PlanFinish
|
|
)
|
|
|
|
var PlanStatusList = map[PlanStatus]string{
|
|
PlanCreate: "create",
|
|
PlanProcess: "process",
|
|
PlanFinish: "finish",
|
|
}
|
|
|
|
func (s PlanStatus) String() string { return PlanStatusList[s] }
|