mirror of
https://shylinux.com/x/operation
synced 2025-07-03 14:01:20 +08:00
160 lines
4.9 KiB
Go
160 lines
4.9 KiB
Go
package production
|
|
|
|
import (
|
|
"shylinux.com/x/ice"
|
|
kit "shylinux.com/x/toolkits"
|
|
|
|
"shylinux.com/x/operation/src/production/model"
|
|
)
|
|
|
|
type Plan struct {
|
|
Table
|
|
order string `data:"1"`
|
|
fields string `data:"updated_at,title,content,version,plan_type,plan_status,score,issue_count AS issue_count,begin_time,end_time,process_time,finish_time,story_uid,user_uid"`
|
|
create string `name:"create title* content plan_type:select version:select 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"`
|
|
setType string `name:"setType plan_type:select" help:"归类" role:"leader"`
|
|
handover string `name:"handover to_user_uid*:select" role:"leader" help:"交接"`
|
|
issueCreate string `name:"issueCreate title* issue_content* price=1000 begin_time:select@date end_time:select@date" role:"worker"`
|
|
}
|
|
|
|
func (s Plan) Create(m *ice.Message, arg ...string) {
|
|
m.Options(kit.ArgDef(arg, kit.Simple(model.VERSION, "v1.0", model.BEGIN_TIME, m.Time(), model.END_TIME, m.Time("120h"))...))
|
|
s.Transaction(m, func() {
|
|
if m.WarnNotValid(s.Select(m, m.OptionSimple(model.STORY_UID, model.TITLE, model.VERSION)...).Length() > 0, "项目已经存在") {
|
|
return
|
|
}
|
|
s.ValueCreate(m, arg...)
|
|
})
|
|
msg := m.Cmd(userStory{}, s.Select, m.OptionSimple(model.STORY_UID), model.ROLE, "1")
|
|
s.SendTemplate(m, "", msg.Append(model.USER_UID), "")
|
|
s.SendMessage(m, "", "")
|
|
}
|
|
func (s Plan) List(m *ice.Message, arg ...string) {
|
|
isLeader, isWorker := s.IsLeader(m), s.IsWorker(m)
|
|
defer kit.If(!isLeader, func() {
|
|
if m.Action(); m.Length() == 0 {
|
|
m.SetResult("请等待「管理员」创建迭代计划")
|
|
}
|
|
})
|
|
s.SettingSelect(m)
|
|
issue_max_create := kit.Int(m.Option(ISSUE_MAX_CREATE))
|
|
msg := m.Cmd(Issue{}, s.Select, model.STORY_UID, arg[0], m.OptionSimple(model.USER_UID), model.STATUS, IssueCreate)
|
|
s.Orders(m, model.STATUS, model.ISSUE_COUNT, s.Desc(model.TYPE), s.Desc(model.SCORE), s.Desc(model.UPDATED_AT)).Limit(m, 300)
|
|
s.ValueList(m, arg).Table(func(value ice.Maps) {
|
|
button := []ice.Any{}
|
|
defer func() { m.PushButton(button...) }()
|
|
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 && kit.Int(value[model.ISSUE_COUNT]) == 0 && msg.Length() < issue_max_create {
|
|
button = append(button, s.IssueCreate)
|
|
}
|
|
if isLeader && m.Option(model.MARKET_UID) == "" {
|
|
button = append(button, s.MarketInsert)
|
|
}
|
|
if isLeader {
|
|
button = append(button, s.SetScore)
|
|
}
|
|
if isLeader {
|
|
button = append(button, s.SetType)
|
|
}
|
|
if isLeader {
|
|
button = append(button, s.Handover)
|
|
}
|
|
if isLeader && kit.Int(value[model.ISSUE_COUNT]) > 0 {
|
|
button = append(button, s.Finish)
|
|
}
|
|
if isLeader && kit.Int(value[model.ISSUE_COUNT]) == 0 {
|
|
button = append(button, s.Remove)
|
|
}
|
|
case PlanFinish:
|
|
if isLeader {
|
|
button = append(button, s.SetScore)
|
|
}
|
|
if isLeader {
|
|
button = append(button, s.SetType)
|
|
}
|
|
if isLeader {
|
|
button = append(button, s.Handover)
|
|
}
|
|
kit.If(m.FieldsIsDetail(), func() { s.DoneMessage(m) })
|
|
}
|
|
}).Display("").DisplayCSS("")
|
|
s.OtherListCmd(m, s.IssueList, s.DesignList, s.TaskList, s.CaseList)
|
|
}
|
|
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, Issue{}, "需求") {
|
|
return
|
|
}
|
|
if s.finishCheck(m, Design{}, "设计") {
|
|
return
|
|
}
|
|
s.changeStatus(m, PlanProcess, PlanFinish)
|
|
}
|
|
func (s Plan) SetType(m *ice.Message, arg ...string) {
|
|
s.Modify(m, m.OptionSimple(model.PLAN_TYPE)...)
|
|
m.ProcessHold()
|
|
}
|
|
func (s Plan) SetScore(m *ice.Message, arg ...string) {
|
|
s.Modify(m, arg...)
|
|
m.ProcessHold()
|
|
}
|
|
func (s Plan) Handover(m *ice.Message, arg ...string) {
|
|
m.OptionDefault(model.TO_USER_UID, m.Option(ice.MSG_USERUID))
|
|
s.Modify(m, model.USER_UID, m.Option(model.TO_USER_UID))
|
|
s.SendTemplate(m, "", "", "")
|
|
m.ProcessHold()
|
|
}
|
|
func (s Plan) IssueCreate(m *ice.Message, arg ...string) {
|
|
s.commonOtherCreate(m, Issue{}, arg...)
|
|
}
|
|
|
|
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 PlanType int
|
|
|
|
const (
|
|
PlanPlace PlanType = iota
|
|
PlanFunc
|
|
PlanMatrix
|
|
PlanSolution
|
|
)
|
|
|
|
var PlanTypeList = map[PlanType]string{
|
|
PlanPlace: "place",
|
|
PlanFunc: "func",
|
|
PlanMatrix: "matrix",
|
|
PlanSolution: "solution",
|
|
}
|
|
|
|
func (s PlanType) String() string { return PlanTypeList[s] }
|
|
|
|
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] }
|