mirror of
https://shylinux.com/x/enterprise
synced 2025-04-26 01:24:06 +08:00
add some
This commit is contained in:
parent
55edf2ec3a
commit
abfd6fa7e0
@ -8,21 +8,11 @@ import (
|
|||||||
"shylinux.com/x/enterprise/src/guanlixitong/model"
|
"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 {
|
type Table struct {
|
||||||
gonganxitong.Table
|
gonganxitong.Table
|
||||||
list string `name:"list group_uid uid auto" role:"void"`
|
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) {
|
func (s Table) Inputs(m *ice.Message, arg ...string) {
|
||||||
switch arg[0] {
|
switch arg[0] {
|
||||||
case model.GROUP_TYPE:
|
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() })
|
kit.If(key == model.USER_GROUP_ROLE, func() { value = UserGroupRole(kit.Int(value)).String() })
|
||||||
return value
|
return value
|
||||||
})
|
})
|
||||||
s.Table.RewriteAppend(m)
|
return s.Table.RewriteAppend(m)
|
||||||
return m
|
|
||||||
}
|
}
|
||||||
func (s Table) SelectJoinCompany(m *ice.Message) *ice.Message {
|
func (s Table) SelectJoinCompany(m *ice.Message) *ice.Message {
|
||||||
return s.SelectJoin(m, company{}, model.NAME, model.CITY_UID)
|
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{})}
|
||||||
|
}
|
||||||
|
@ -11,19 +11,19 @@ type GroupType int
|
|||||||
const (
|
const (
|
||||||
GroupRD GroupType = iota
|
GroupRD GroupType = iota
|
||||||
GroupOP
|
GroupOP
|
||||||
GroupSales
|
GroupHR
|
||||||
GroupFinancial
|
GroupFinancial
|
||||||
GroupAdmin
|
GroupAdmin
|
||||||
GroupHR
|
GroupSales
|
||||||
)
|
)
|
||||||
|
|
||||||
var GroupTypeList = map[GroupType]string{
|
var GroupTypeList = map[GroupType]string{
|
||||||
GroupRD: "RD",
|
GroupRD: "RD",
|
||||||
GroupOP: "OP",
|
GroupOP: "OP",
|
||||||
GroupSales: "sales",
|
GroupHR: "HR",
|
||||||
GroupFinancial: "financial",
|
GroupFinancial: "financial",
|
||||||
GroupAdmin: "admin",
|
GroupAdmin: "admin",
|
||||||
GroupHR: "HR",
|
GroupSales: "sales",
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s GroupType) String() string { return GroupTypeList[s] }
|
func (s GroupType) String() string { return GroupTypeList[s] }
|
||||||
|
@ -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{}) }
|
|
@ -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)}]},
|
|
||||||
]
|
|
||||||
})
|
|
||||||
},
|
|
||||||
})
|
|
@ -7,6 +7,7 @@ const (
|
|||||||
NAME = "name"
|
NAME = "name"
|
||||||
TYPE = "type"
|
TYPE = "type"
|
||||||
ROLE = "role"
|
ROLE = "role"
|
||||||
|
TITLE = "title"
|
||||||
CONTENT = "content"
|
CONTENT = "content"
|
||||||
USER_UID = "user_uid"
|
USER_UID = "user_uid"
|
||||||
USER_GROUP_ROLE = "user_group_role"
|
USER_GROUP_ROLE = "user_group_role"
|
||||||
@ -26,20 +27,21 @@ type UserGroup struct {
|
|||||||
}
|
}
|
||||||
type Group struct {
|
type Group struct {
|
||||||
db.ModelWithUID
|
db.ModelWithUID
|
||||||
CompanyUID string `gorm:"type:char(32)"`
|
CompanyUID string `gorm:"type:char(32);index"`
|
||||||
Name string `gorm:"type:varchar(256)"`
|
Name string `gorm:"type:char(64)"`
|
||||||
Type uint8
|
Type uint8
|
||||||
}
|
}
|
||||||
type Company struct {
|
type Company struct {
|
||||||
db.ModelWithUID
|
db.ModelWithUID
|
||||||
CityUID string `gorm:"type:char(32);index"`
|
CityUID string `gorm:"type:char(32);index:idx_city"`
|
||||||
Name string `gorm:"type:varchar(256)"`
|
Name string `gorm:"type:char(64);index:idx_city"`
|
||||||
Info string
|
Info string
|
||||||
}
|
}
|
||||||
type Target struct {
|
type Target struct {
|
||||||
db.ModelWithUID
|
db.ModelWithUID
|
||||||
GroupUID string `gorm:"type:char(32);index"`
|
GroupUID string `gorm:"type:char(32);index"`
|
||||||
UserUID string `gorm:"type:char(32)"`
|
UserUID string `gorm:"type:char(32)"`
|
||||||
|
Title string `gorm:"type:char(64)"`
|
||||||
Content string
|
Content string
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2,13 +2,13 @@ package guanlixitong
|
|||||||
|
|
||||||
import "shylinux.com/x/community/src/gonganxitong"
|
import "shylinux.com/x/community/src/gonganxitong"
|
||||||
|
|
||||||
type portal struct {
|
type Portal struct {
|
||||||
gonganxitong.Portal
|
gonganxitong.Portal
|
||||||
name string `data:"管理系统"`
|
name string `data:"管理系统"`
|
||||||
list string `name:"list group_uid index uid auto" role:"void"`
|
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() {
|
func init() {
|
||||||
gonganxitong.PortalCmd(portal{Portal: gonganxitong.NewPortal(userGroup{}, group{}, company{})})
|
gonganxitong.PortalCmd(Portal{Portal: gonganxitong.NewPortal(userGroup{}, group{}, company{})})
|
||||||
}
|
}
|
||||||
|
@ -1,12 +1,10 @@
|
|||||||
{
|
{
|
||||||
"portal": "管理系统",
|
"portal": "管理系统",
|
||||||
"scanQRCode": "扫码添加",
|
|
||||||
"placeCreate": "创建团队",
|
"placeCreate": "创建团队",
|
||||||
"placeRemove": "解散团队",
|
"placeRemove": "解散团队",
|
||||||
"groupUser": "团队成员",
|
|
||||||
"target": "目标计划",
|
"target": "目标计划",
|
||||||
|
"member": "团队成员",
|
||||||
"icons": {
|
"icons": {
|
||||||
"groupUser": "https://img.icons8.com/officel/80/crowd.png",
|
|
||||||
"target": "https://img.icons8.com/officel/80/goal--v1.png"
|
"target": "https://img.icons8.com/officel/80/goal--v1.png"
|
||||||
},
|
},
|
||||||
"input": {
|
"input": {
|
||||||
@ -20,11 +18,21 @@
|
|||||||
"user_group_role": {
|
"user_group_role": {
|
||||||
"creator": "创建人",
|
"creator": "创建人",
|
||||||
"visitor": "访客",
|
"visitor": "访客",
|
||||||
"leader": "领导",
|
"leader": "管理人员",
|
||||||
"member": "组员"
|
"worker": "工作人员",
|
||||||
|
"server": "服务人员",
|
||||||
|
"style": {
|
||||||
|
"creator": "danger",
|
||||||
|
"leader": "danger"
|
||||||
|
}
|
||||||
},
|
},
|
||||||
"group_type": {
|
"group_type": {
|
||||||
"RD": "研发",
|
"RD": "研发",
|
||||||
|
"OP": "运维",
|
||||||
|
"HR": "人力",
|
||||||
|
"financial": "财务",
|
||||||
|
"Admin": "行政",
|
||||||
|
"sales": "销售",
|
||||||
"icons": {
|
"icons": {
|
||||||
"RD": "https://img.icons8.com/officel/80/code.png"
|
"RD": "https://img.icons8.com/officel/80/code.png"
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,3 @@
|
|||||||
chapter "管理系统"
|
chapter "管理系统"
|
||||||
field web.chat.wx.access
|
|
||||||
field web.code.mysql.client
|
field web.code.mysql.client
|
||||||
field web.code.mysql.query args `mysql guanlixitong`
|
field web.code.mysql.query args `mysql guanlixitong`
|
||||||
field web.code.db.database
|
|
||||||
field web.code.db.driver
|
|
||||||
field web.code.db.models
|
|
||||||
|
@ -9,17 +9,20 @@ import (
|
|||||||
|
|
||||||
type target struct {
|
type target struct {
|
||||||
Table
|
Table
|
||||||
userGroup userGroup
|
|
||||||
group group
|
group group
|
||||||
|
userGroup userGroup
|
||||||
portal string `data:"true"`
|
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) {
|
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) {
|
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{}) }
|
func init() { ice.TeamCtxCmd(target{}) }
|
||||||
|
@ -1,14 +1,9 @@
|
|||||||
Volcanos(chat.ONIMPORT, {
|
Volcanos(chat.ONIMPORT, {
|
||||||
_init: function(can, msg) {
|
_init: function(can, msg) {
|
||||||
if (msg.IsDetail()) { var value = msg.TableDetail(); msg.Option("_share_content", value.content)
|
if (msg.IsDetail()) { var value = msg.TableDetail(); msg.Option("_share_title", value.title), 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)
|
|
||||||
}
|
|
||||||
can.onimport.itemcards(can, msg, function(value) { return [
|
can.onimport.itemcards(can, msg, function(value) { return [
|
||||||
{view: html.TITLE, list: [{text: value.user_name},
|
{view: html.TITLE, list: [{text: value.title}]},
|
||||||
{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)}, {text: value.user_name}]},
|
||||||
]},
|
|
||||||
{view: html.STATUS, list: [{text: value.uid.slice(0, 6)}, {text: can.base.TimeTrim(value.created_at)},]},
|
|
||||||
{view: html.OUTPUT, list: [{text: value.content}]},
|
{view: html.OUTPUT, list: [{text: value.content}]},
|
||||||
] })
|
] })
|
||||||
},
|
},
|
||||||
|
@ -13,10 +13,11 @@ type userGroup struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (s userGroup) User(m *ice.Message, arg ...string) {
|
func (s userGroup) User(m *ice.Message, arg ...string) {
|
||||||
|
s.FieldsWithCreatedAT(m, s, model.USER_UID, model.ROLE)
|
||||||
if len(arg) == 1 {
|
if len(arg) == 1 {
|
||||||
s.Select(m, model.GROUP_UID, arg[0])
|
s.Select(m, model.GROUP_UID, arg[0])
|
||||||
} else if len(arg) == 2 {
|
} 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 {
|
} else {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@ -27,12 +28,12 @@ func (s userGroup) User(m *ice.Message, arg ...string) {
|
|||||||
func (s userGroup) List(m *ice.Message, arg ...string) {
|
func (s userGroup) List(m *ice.Message, arg ...string) {
|
||||||
s.Tables(m, s.group, s.company).FieldsWithCreatedAT(m, s,
|
s.Tables(m, s.group, s.company).FieldsWithCreatedAT(m, s,
|
||||||
model.GROUP_NAME, model.GROUP_TYPE, model.USER_GROUP_ROLE,
|
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 {
|
if len(arg) == 1 {
|
||||||
s.Select(m, model.USER_UID, arg[0])
|
s.Select(m, model.USER_UID, arg[0])
|
||||||
} else if len(arg) == 2 {
|
} 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 {
|
} else {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@ -48,14 +49,16 @@ const (
|
|||||||
UserGroupCreator UserGroupRole = iota
|
UserGroupCreator UserGroupRole = iota
|
||||||
UserGroupVisitor
|
UserGroupVisitor
|
||||||
UserGroupLeader
|
UserGroupLeader
|
||||||
UserGroupMember
|
UserGroupWorker
|
||||||
|
UserGroupServer
|
||||||
)
|
)
|
||||||
|
|
||||||
var UserGroupRoleList = map[UserGroupRole]string{
|
var UserGroupRoleList = map[UserGroupRole]string{
|
||||||
UserGroupCreator: "creator",
|
UserGroupCreator: "creator",
|
||||||
UserGroupVisitor: "visitor",
|
UserGroupVisitor: "visitor",
|
||||||
UserGroupLeader: "leader",
|
UserGroupLeader: "leader",
|
||||||
UserGroupMember: "member",
|
UserGroupWorker: "worker",
|
||||||
|
UserGroupServer: "server",
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s UserGroupRole) String() string { return UserGroupRoleList[s] }
|
func (s UserGroupRole) String() string { return UserGroupRoleList[s] }
|
||||||
|
Loading…
x
Reference in New Issue
Block a user