diff --git a/src/guanlixitong/common.go b/src/guanlixitong/common.go index 860d036..7d9c1f4 100644 --- a/src/guanlixitong/common.go +++ b/src/guanlixitong/common.go @@ -8,21 +8,11 @@ import ( "shylinux.com/x/enterprise/src/guanlixitong/model" ) -type Tables struct { - gonganxitong.Tables - list string `name:"list group_uid uid auto" role:"void"` -} type Table struct { gonganxitong.Table list string `name:"list group_uid uid auto" role:"void"` } -func NewTables(group, userGroup gonganxitong.Tabler) Tables { - return Tables{Tables: gonganxitong.NewTables(group, userGroup, company{})} -} -func NewTable(group, userGroup gonganxitong.Tabler) Table { - return Table{Table: gonganxitong.NewTable(group, userGroup, company{})} -} func (s Table) Inputs(m *ice.Message, arg ...string) { switch arg[0] { case model.GROUP_TYPE: @@ -47,9 +37,33 @@ func (s Table) RewriteAppend(m *ice.Message, arg ...string) *ice.Message { kit.If(key == model.USER_GROUP_ROLE, func() { value = UserGroupRole(kit.Int(value)).String() }) return value }) - s.Table.RewriteAppend(m) - return m + return s.Table.RewriteAppend(m) } func (s Table) SelectJoinCompany(m *ice.Message) *ice.Message { return s.SelectJoin(m, company{}, model.NAME, model.CITY_UID) } +func (s Table) checkRole(m *ice.Message, arg ...UserGroupRole) bool { + kit.If(len(arg) == 0, func() { arg = append(arg, UserGroupLeader) }) + role := UserGroupRole(kit.Int(m.Cmd(userGroup{}, s.Select, m.OptionSimple(model.GROUP_UID, model.USER_UID)).Append(model.ROLE))) + for _, v := range append(arg, UserGroupCreator) { + if role == v { + return true + } + } + return !m.WarnNotRight(true, role.String()) +} +func (s Table) recordEvent(m *ice.Message, info string, arg ...string) *ice.Message { + s.Table.RecordEvent(m, m.Option(model.GROUP_UID), info, kit.Select(m.Option(model.UID), arg, 0)) + return m +} + +type Tables struct { + Table + portal string `data:"true"` +} + +func (s Tables) BeforeMigrate(m *ice.Message, arg ...string) {} + +func NewTable(userGroup gonganxitong.UserPlacer, group gonganxitong.Placer) Table { + return Table{Table: gonganxitong.NewTable(userGroup, group, company{})} +} diff --git a/src/guanlixitong/group.go b/src/guanlixitong/group.go index 53a5fdb..e386403 100644 --- a/src/guanlixitong/group.go +++ b/src/guanlixitong/group.go @@ -11,19 +11,19 @@ type GroupType int const ( GroupRD GroupType = iota GroupOP - GroupSales + GroupHR GroupFinancial GroupAdmin - GroupHR + GroupSales ) var GroupTypeList = map[GroupType]string{ GroupRD: "RD", GroupOP: "OP", - GroupSales: "sales", + GroupHR: "HR", GroupFinancial: "financial", GroupAdmin: "admin", - GroupHR: "HR", + GroupSales: "sales", } func (s GroupType) String() string { return GroupTypeList[s] } diff --git a/src/guanlixitong/groupUser.go b/src/guanlixitong/groupUser.go deleted file mode 100644 index b3bebcf..0000000 --- a/src/guanlixitong/groupUser.go +++ /dev/null @@ -1,14 +0,0 @@ -package guanlixitong - -import "shylinux.com/x/ice" - -type groupUser struct { - Tables - userGroup userGroup -} - -func (s groupUser) List(m *ice.Message, arg ...string) { - m.Cmdy(s.userGroup, s.userGroup.User, arg).Display("") -} - -func init() { ice.TeamCtxCmd(groupUser{}) } diff --git a/src/guanlixitong/groupUser.js b/src/guanlixitong/groupUser.js deleted file mode 100644 index 21b0165..0000000 --- a/src/guanlixitong/groupUser.js +++ /dev/null @@ -1,13 +0,0 @@ -Volcanos(chat.ONIMPORT, { - _init: function(can, msg) { var USER_GROUP_ROLE = "user_group_role" - if (msg.IsDetail()) { can.onexport.share_title(can, msg, USER_GROUP_ROLE); return msg.Show(can) } - can.onimport.itemcards(can, msg, function(value) { value._style = [value[USER_GROUP_ROLE]] - return [ - {view: html.TITLE, list: [{text: value.user_name}, - {text: [can.user.transValue(can, value, USER_GROUP_ROLE), "", [aaa.ROLE, value[USER_GROUP_ROLE]]]}, - ]}, - {view: html.STATUS, list: [{text: value.uid.slice(0, 6)}, {text: can.base.TimeTrim(value.created_at)}]}, - ] - }) - }, -}) diff --git a/src/guanlixitong/model/model.go b/src/guanlixitong/model/model.go index e8de1e5..3a9eb65 100644 --- a/src/guanlixitong/model/model.go +++ b/src/guanlixitong/model/model.go @@ -7,6 +7,7 @@ const ( NAME = "name" TYPE = "type" ROLE = "role" + TITLE = "title" CONTENT = "content" USER_UID = "user_uid" USER_GROUP_ROLE = "user_group_role" @@ -26,20 +27,21 @@ type UserGroup struct { } type Group struct { db.ModelWithUID - CompanyUID string `gorm:"type:char(32)"` - Name string `gorm:"type:varchar(256)"` + CompanyUID string `gorm:"type:char(32);index"` + Name string `gorm:"type:char(64)"` Type uint8 } type Company struct { db.ModelWithUID - CityUID string `gorm:"type:char(32);index"` - Name string `gorm:"type:varchar(256)"` + CityUID string `gorm:"type:char(32);index:idx_city"` + Name string `gorm:"type:char(64);index:idx_city"` Info string } type Target struct { db.ModelWithUID GroupUID string `gorm:"type:char(32);index"` UserUID string `gorm:"type:char(32)"` + Title string `gorm:"type:char(64)"` Content string } diff --git a/src/guanlixitong/portal.go b/src/guanlixitong/portal.go index fbb37d3..8be1114 100644 --- a/src/guanlixitong/portal.go +++ b/src/guanlixitong/portal.go @@ -2,13 +2,13 @@ package guanlixitong import "shylinux.com/x/community/src/gonganxitong" -type portal struct { +type Portal struct { gonganxitong.Portal name string `data:"管理系统"` list string `name:"list group_uid index uid auto" role:"void"` - placeCreate string `name:"placeCreate city_name* company_name* name*" role:"void"` + placeCreate string `name:"placeCreate city_name* company_name* group_name*" role:"void"` } func init() { - gonganxitong.PortalCmd(portal{Portal: gonganxitong.NewPortal(userGroup{}, group{}, company{})}) + gonganxitong.PortalCmd(Portal{Portal: gonganxitong.NewPortal(userGroup{}, group{}, company{})}) } diff --git a/src/guanlixitong/portal.json b/src/guanlixitong/portal.json index b737426..00d15b7 100644 --- a/src/guanlixitong/portal.json +++ b/src/guanlixitong/portal.json @@ -1,12 +1,10 @@ { "portal": "管理系统", - "scanQRCode": "扫码添加", "placeCreate": "创建团队", "placeRemove": "解散团队", - "groupUser": "团队成员", "target": "目标计划", + "member": "团队成员", "icons": { - "groupUser": "https://img.icons8.com/officel/80/crowd.png", "target": "https://img.icons8.com/officel/80/goal--v1.png" }, "input": { @@ -20,11 +18,21 @@ "user_group_role": { "creator": "创建人", "visitor": "访客", - "leader": "领导", - "member": "组员" + "leader": "管理人员", + "worker": "工作人员", + "server": "服务人员", + "style": { + "creator": "danger", + "leader": "danger" + } }, "group_type": { "RD": "研发", + "OP": "运维", + "HR": "人力", + "financial": "财务", + "Admin": "行政", + "sales": "销售", "icons": { "RD": "https://img.icons8.com/officel/80/code.png" } diff --git a/src/guanlixitong/portal.shy b/src/guanlixitong/portal.shy index b02861a..df955be 100644 --- a/src/guanlixitong/portal.shy +++ b/src/guanlixitong/portal.shy @@ -1,7 +1,3 @@ chapter "管理系统" -field web.chat.wx.access field web.code.mysql.client -field web.code.mysql.query args `mysql guanlixitong` -field web.code.db.database -field web.code.db.driver -field web.code.db.models +field web.code.mysql.query args `mysql guanlixitong` \ No newline at end of file diff --git a/src/guanlixitong/target.go b/src/guanlixitong/target.go index 0f0789b..10f8ef5 100644 --- a/src/guanlixitong/target.go +++ b/src/guanlixitong/target.go @@ -9,17 +9,20 @@ import ( type target struct { Table - userGroup userGroup group group + userGroup userGroup portal string `data:"true"` - create string `name:"create content*" role:"void"` + create string `name:"create title* content*" role:"void"` } func (s target) Create(m *ice.Message, arg ...string) { - s.Table.Create(m, kit.Simple(arg, m.OptionSimple(model.USER_UID, model.GROUP_UID))...) + if s.checkRole(m) { + s.Table.Create(m, kit.Simple(arg, m.OptionSimple(model.GROUP_UID, model.USER_UID))...) + s.recordEvent(m, m.Trans("create target ", "创建团队目标 ")+m.Option(model.TITLE), m.Result()) + } } func (s target) List(m *ice.Message, arg ...string) { - s.TablesWithRole(m, arg, s, s.userGroup, s.group, model.CONTENT).Display("") + s.TablesWithRole(m, arg, s.userGroup, s.group, s, model.TITLE, model.CONTENT).Display("") } func init() { ice.TeamCtxCmd(target{}) } diff --git a/src/guanlixitong/target.js b/src/guanlixitong/target.js index 28034c9..75968da 100644 --- a/src/guanlixitong/target.js +++ b/src/guanlixitong/target.js @@ -1,14 +1,9 @@ Volcanos(chat.ONIMPORT, { _init: function(can, msg) { - if (msg.IsDetail()) { var value = msg.TableDetail(); msg.Option("_share_content", value.content) - msg.Option("_share_title", can.base.trimPrefix(value.created_at.split(" ")[0], can.base.Time(null, "%y-"))) - return msg.Show(can) - } + if (msg.IsDetail()) { var value = msg.TableDetail(); msg.Option("_share_title", value.title), msg.Option("_share_content", value.content) } can.onimport.itemcards(can, msg, function(value) { return [ - {view: html.TITLE, list: [{text: value.user_name}, - {text: [can.user.transValue(can, value, "user_group_role"), "", aaa.ROLE]}, - ]}, - {view: html.STATUS, list: [{text: value.uid.slice(0, 6)}, {text: can.base.TimeTrim(value.created_at)},]}, + {view: html.TITLE, list: [{text: value.title}]}, + {view: html.STATUS, list: [{text: value.uid.slice(0, 6)}, {text: can.base.TimeTrim(value.created_at)}, {text: value.user_name}]}, {view: html.OUTPUT, list: [{text: value.content}]}, ] }) }, diff --git a/src/guanlixitong/userGroup.go b/src/guanlixitong/userGroup.go index e66d9d2..360cd2a 100644 --- a/src/guanlixitong/userGroup.go +++ b/src/guanlixitong/userGroup.go @@ -13,10 +13,11 @@ type userGroup struct { } func (s userGroup) User(m *ice.Message, arg ...string) { + s.FieldsWithCreatedAT(m, s, model.USER_UID, model.ROLE) if len(arg) == 1 { s.Select(m, model.GROUP_UID, arg[0]) } else if len(arg) == 2 { - s.Select(m, model.GROUP_UID, arg[0], model.UID, arg[1]) + s.SelectDetail(m, model.GROUP_UID, arg[0], model.UID, arg[1]) } else { return } @@ -27,12 +28,12 @@ func (s userGroup) User(m *ice.Message, arg ...string) { func (s userGroup) List(m *ice.Message, arg ...string) { s.Tables(m, s.group, s.company).FieldsWithCreatedAT(m, s, model.GROUP_NAME, model.GROUP_TYPE, model.USER_GROUP_ROLE, - model.COMPANY_NAME, model.GROUP_UID, model.CITY_UID, + model.CITY_UID, model.COMPANY_NAME, model.GROUP_UID, ) if len(arg) == 1 { s.Select(m, model.USER_UID, arg[0]) } else if len(arg) == 2 { - s.SelectDetail(m, model.USER_UID, arg[0], model.GROUP_UID, arg[1]) + s.SelectDetail(m, model.USER_UID, arg[0], s.Key(s, model.GROUP_UID), arg[1]) } else { return } @@ -48,14 +49,16 @@ const ( UserGroupCreator UserGroupRole = iota UserGroupVisitor UserGroupLeader - UserGroupMember + UserGroupWorker + UserGroupServer ) var UserGroupRoleList = map[UserGroupRole]string{ UserGroupCreator: "creator", UserGroupVisitor: "visitor", UserGroupLeader: "leader", - UserGroupMember: "member", + UserGroupWorker: "worker", + UserGroupServer: "server", } func (s UserGroupRole) String() string { return UserGroupRoleList[s] }