diff --git a/src/production/case.js b/src/production/case.js index 81291e3..452a37d 100644 --- a/src/production/case.js +++ b/src/production/case.js @@ -1,7 +1,7 @@ Volcanos(chat.ONIMPORT, { _init: function(can, msg) { can.onimport.myView(can, msg, function(value) { return [ - {view: html.TITLE, list: [value.title, can.onimport.textView(can, value, "status")]}, + {view: html.TITLE, list: [value.title, can.onimport.textView(can, value, "case_status")]}, {view: html.STATUS, list: [ // can.onimport.beginTime(can, value), (value.process_time||value.begin_time).split(" ")[0], diff --git a/src/production/common.go b/src/production/common.go index 33f5d3c..3ca4b25 100644 --- a/src/production/common.go +++ b/src/production/common.go @@ -26,9 +26,11 @@ type Table struct { finish string `name:"finish" role:"leader"` reback string `name:"reback" role:"leader"` cancel string `name:"cancel" role:"leader"` + trash string `name:"trash" role:"leader"` payfor string `name:"payfor price* title* content" role:"leader"` discuss string `name:"discuss meet_type* title* content link* date* time*" role:"leader"` list string `name:"list story_uid uid auto" role:"void"` + issueList string `name:"issueList" role:"worker"` designList string `name:"designList" role:"worker"` taskList string `name:"taskList" role:"worker"` caseList string `name:"caseList" role:"worker"` @@ -110,14 +112,10 @@ func (s Table) RewriteAppend(m *ice.Message, arg ...string) *ice.Message { func (s Table) PushIssueButton(m *ice.Message, value ice.Maps, user_uid string, arg ...ice.Any) { button := []ice.Any{} defer func() { m.PushButton(button...) }() - if PlanStatus(kit.Int(value[model.PLAN_STATUS])) == PlanFinish { - kit.If(m.FieldsIsDetail(), func() { s.DoneMessage(m) }) - return - } isCreator, isLeader, isWorker := s.IsCreator(m), s.IsLeader(m), s.IsWorker(m) switch IssueStatus(kit.Int(value[model.STATUS])) { case IssueCreate: - if isLeader { + if isCreator { button = append(button, s.Discuss, s.Payfor) } if isCreator { @@ -126,22 +124,27 @@ func (s Table) PushIssueButton(m *ice.Message, value ice.Maps, user_uid string, if user_uid == value[model.USER_UID] { button = append(button, s.Modify, s.Remove) } + case IssueRejected: + if isLeader { + button = append(button, s.Trash) + } case IssueApproved: if user_uid == value[model.USER_UID] { button = append(button, s.Process) } case IssueProcess: - if isLeader { + if isCreator { button = append(button, s.Discuss, s.Payfor) } if user_uid == value[model.USER_UID] { button = append(button, s.Submit) } + // button = append(button, s.Remove) case IssueSubmit: if isWorker { button = append(button, s.Preview) } - if isLeader { + if isCreator { button = append(button, s.Discuss, s.Payfor) } if isCreator { @@ -151,18 +154,26 @@ func (s Table) PushIssueButton(m *ice.Message, value ice.Maps, user_uid string, if isWorker { button = append(button, s.Preview) } - if isLeader { - button = append(button, s.Discuss, s.Payfor) + if PlanStatus(kit.Int(value[model.PLAN_STATUS])) != PlanFinish { + if isCreator { + button = append(button, s.Discuss, s.Payfor) + } } if isWorker { button = append(button, arg...) } kit.If(m.FieldsIsDetail(), func() { s.DoneMessage(m) }) + case IssueCancel: + if isLeader { + button = append(button, s.Trash) + } } } func (s Table) PushTaskButton(m *ice.Message, value ice.Maps, user_uid string, arg ...ice.Any) { button := []ice.Any{} isWorker := s.IsWorker(m) + // isCreator, isLeader, isWorker := s.IsCreator(m), s.IsLeader(m), s.IsWorker(m) + // _ = isLeader switch IssueStatus(kit.Int(value[model.STATUS])) { case IssueCreate: if user_uid == value[model.USER_UID] { @@ -231,6 +242,11 @@ func (s Table) Reback(m *ice.Message, arg ...string) { func (s Table) Cancel(m *ice.Message, arg ...string) { s.ChangeStatus(m, int(IssueSubmit), int(IssueCancel)) } +func (s Table) Trash(m *ice.Message, arg ...string) { + if s.IsLeader(m) { + s.Delete(m, m.OptionSimple(model.UID, model.STORY_UID)...) + } +} func (s Table) Program(m *ice.Message, arg ...string) { p := path.Base(m.Option(nfs.PATH)) m.ProcessOpen(kit.MergeURL(web.S(m.Option(web.SPACE))+web.C(web.VIMER), nfs.PATH, nfs.SRC, nfs.FILE, path.Join(p, "portal.go"))) @@ -281,7 +297,11 @@ func (s Table) otherListButton(m *ice.Message, arg ...string) { m.Table(func(value ice.Maps) { switch IssueStatus(kit.Int(value[model.STATUS])) { case IssueSubmit, IssueFinish: - m.PushButton(s.Preview) + if value[web.LINK] != "" { + m.PushButton(s.Preview) + break + } + fallthrough default: m.PushButton() } @@ -297,11 +317,13 @@ func (s Table) DesignList(m *ice.Message, arg ...string) { } func (s Table) TaskList(m *ice.Message, arg ...string) { s.OtherList(m, Task{}).Display("task.js") - s.otherListButton(m) + m.RenameAppend(model.STATUS, model.TASK_STATUS) + m.PushAction(s.Program) } func (s Table) CaseList(m *ice.Message, arg ...string) { s.OtherList(m, Case{}).Display("case.js") - s.otherListButton(m) + m.RenameAppend(model.STATUS, model.CASE_STATUS) + m.PushAction(s.Preview) } func (s Table) MeetList(m *ice.Message, arg ...string) { s.OtherList(m, meet{}).Display("meet.js") @@ -312,8 +334,7 @@ func (s Table) DealList(m *ice.Message, arg ...string) { } func (s Table) finishCheck(m *ice.Message, target ice.Any, name string, arg ...string) bool { - count := m.Cmd(target, s.Select, m.CommandKey()+"_uid = ? AND status != ? AND status != ? AND status != ?", - m.Option(model.UID), IssueRejected, IssueFinish, IssueCancel).Length() + count := m.Cmd(target, s.Select, m.CommandKey()+"_uid = ? AND status != ? AND status != ? AND status != ?", m.Option(model.UID), IssueRejected, IssueFinish, IssueCancel).Length() if m.WarnNotValid(count > 0, kit.Format("还有 %v 个未完成的%s", count, name)) { return true } diff --git a/src/production/design.go b/src/production/design.go index bd0a099..b6d3b63 100644 --- a/src/production/design.go +++ b/src/production/design.go @@ -12,7 +12,7 @@ type Design struct { order string `data:"3"` fields string `data:"title,content,status,price,link,begin_time,end_time,process_time,finish_time,issue_uid,plan_uid,user_uid"` create string `name:"create issue_uid* title* content* price*=1000 begin_time:select@date end_time:select@date" role:"worker"` - modify string `name:"modify title* content* price* begin_time*:select@date end_time*:select@date" role:"worker"` + modify string `name:"modify title* content* price* link begin_time*:select@date end_time*:select@date" role:"worker"` } func (s Design) Create(m *ice.Message, arg ...string) { diff --git a/src/production/issue.go b/src/production/issue.go index 5b10069..c3ea823 100644 --- a/src/production/issue.go +++ b/src/production/issue.go @@ -12,10 +12,9 @@ type Issue struct { order string `data:"2"` fields string `data:"title,content,issue_type,level,status,price,link,design_count,task_count,begin_time,end_time,process_time,finish_time,plan_uid,user_uid"` create string `name:"create plan_uid* title* content* issue_type:select level:select price=1000 begin_time:select@date end_time:select@date" role:"worker"` - modify string `name:"modify title* content* price* begin_time:select@date end_time:select@date" role:"worker"` + modify string `name:"modify title* content* price* link begin_time:select@date end_time:select@date" role:"worker"` designCreate string `name:"designCreate title* content* price=1000 begin_time:select@date end_time:select@date" role:"worker"` taskCreate string `name:"taskCreate title* content* space path begin_time:select@date end_time:select@date" role:"worker"` - applyCreate string `name:"applyCreate" role:"void"` } func (s Issue) Create(m *ice.Message, arg ...string) { @@ -41,13 +40,22 @@ func (s Issue) List(m *ice.Message, arg ...string) { s.ApplyCheck(m, arg...) return } - user_uid := m.Option(model.USER_UID) + user_uid, isCreator, isWorker := m.Option(model.USER_UID), s.IsCreator(m), s.IsWorker(m) s.Orders(m, model.STATUS, model.DESIGN_COUNT, model.TASK_COUNT, s.Desc(model.CREATED_AT)) s.ValueList(m, arg) s.SelectJoinPlan(m) s.StatusCount(m, arg...) m.Table(func(value ice.Maps) { - s.PushIssueButton(m, value, user_uid, s.DesignCreate, s.TaskCreate) + button := []ice.Any{} + if PlanStatus(kit.Int(value[model.PLAN_STATUS])) != PlanFinish { + if isWorker && kit.Int(value[model.DESIGN_COUNT]) == 0 { + button = append(button, s.DesignCreate) + } + } + if isCreator { + button = append(button, s.TaskCreate) + } + s.PushIssueButton(m, value, user_uid, button...) }).Display("").Option("otherList", "designList,taskList,caseList,meetList,dealList") kit.If(len(arg) == 1, func() { m.Sort("plan_status,status,design_count,task_count,created_at") }) } diff --git a/src/production/plan.go b/src/production/plan.go index b6d0765..fa00fbd 100644 --- a/src/production/plan.go +++ b/src/production/plan.go @@ -16,7 +16,6 @@ type Plan struct { remove string `name:"remove" role:"leader"` process string `name:"process" role:"leader"` issueCreate string `name:"issueCreate title* content* price=1000 begin_time:select@date end_time:select@date" role:"worker"` - issueList string `name:"issueList" role:"worker"` } func (s Plan) Create(m *ice.Message, arg ...string) { @@ -27,40 +26,36 @@ 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("请等待管理员创建迭代计划") + m.SetResult("请等待「管理员」创建迭代计划") } }) s.Orders(m, model.STATUS, model.ISSUE_COUNT, s.Desc(model.CREATED_AT)) 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 { - if kit.Int(value[model.ISSUE_COUNT]) == 0 { - button = append(button, s.IssueCreate) - } - } - if isLeader && kit.Int(value[model.ISSUE_COUNT]) > 0 { - button = append(button, s.Finish) + if isWorker && kit.Int(value[model.ISSUE_COUNT]) == 0 { + button = append(button, s.IssueCreate) } if isLeader && m.Option(model.MARKET_UID) == "" { button = append(button, s.MarketInsert) } + 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 && m.Option(model.MARKET_UID) == "" { - // button = append(button, s.MarketInsert) - } - kit.If(len(arg) == 2, func() { s.DoneMessage(m) }) + kit.If(m.FieldsIsDetail(), func() { s.DoneMessage(m) }) } - m.PushButton(button...) - }).Display("").DisplayCSS("").Option("otherList", "issueList,designList,taskList,caseList,meetList,dealList") + }).Display("").DisplayCSS("") + m.Option("otherList", "issueList,designList,taskList,caseList,meetList,dealList") s.StatusCount(m, arg...) } func (s Plan) Process(m *ice.Message, arg ...string) { diff --git a/src/production/task.go b/src/production/task.go index 1e6f938..f784230 100644 --- a/src/production/task.go +++ b/src/production/task.go @@ -15,7 +15,6 @@ type Task struct { modify string `name:"modify title* content* space path begin_time*:select@date end_time*:select@date" role:"worker"` finish string `name:"finish" role:"worker"` caseCreate string `name:"caseCreate title* content* space index" role:"worker"` - caseList string `name:"caseList" role:"worker"` } func (s Task) Create(m *ice.Message, arg ...string) { diff --git a/src/production/task.js b/src/production/task.js index 71a4efb..802cd1d 100644 --- a/src/production/task.js +++ b/src/production/task.js @@ -1,7 +1,7 @@ Volcanos(chat.ONIMPORT, { _init: function(can, msg) { can.onimport.myView(can, msg, function(value) { return [ - {view: html.TITLE, list: [value.title, can.onimport.textView(can, value, "status")]}, + {view: html.TITLE, list: [value.title, can.onimport.textView(can, value, "task_status")]}, {view: html.STATUS, list: [ // can.onimport.beginTime(can, value), (value.process_time||value.begin_time).split(" ")[0],