This commit is contained in:
IT 老营长 @云轩领航-创始人 2024-09-19 20:58:47 +08:00
parent 2960e36d2b
commit df1f4a5944
8 changed files with 68 additions and 29 deletions

View File

@ -9,15 +9,16 @@ import (
type allow struct {
Table
user user
apply apply
event event
portal Portal
order string `data:"503"`
role string `data:"creator"`
create string `name:"create apply_uid* place_uid* user_uid* status*"`
reject string `name:"reject" role:"void"`
approve string `name:"approve" role:"void"`
user user
apply apply
event event
portal Portal
order string `data:"503"`
role string `data:"creator"`
create string `name:"create apply_uid* place_uid* user_uid* status*"`
reject string `name:"reject" role:"void"`
approve string `name:"approve" role:"void"`
applyQRCode string `name:"applyQRCode" role:"void"`
}
func (s allow) Create(m *ice.Message, arg ...string) {
@ -26,6 +27,9 @@ func (s allow) Create(m *ice.Message, arg ...string) {
s.SendMessage(m, m.Option(model.FROM_USER_UID), "")
s.sendTemplate(m, m.Trans("role allow process", "权限审批 请处理"))
}
func (s allow) ApplyQRCode(m *ice.Message, arg ...string) {
m.Cmdy(s.Prefix(m, qrcode{}), m.ActionKey(), arg)
}
func (s allow) List(m *ice.Message, arg ...string) {
s.Tables(m, s.apply, "left join users on applies.user_uid = users.uid").FieldsWithCreatedAT(m, s.apply,
s.AS(s.Key(s, model.UID), model.ALLOW_UID), model.ALLOW_STATUS, s.AS(s.Key(s.apply, model.ROLE), s.Keys(s.UserPlace, model.ROLE)),
@ -33,12 +37,15 @@ func (s allow) List(m *ice.Message, arg ...string) {
)
if len(arg) == 1 {
s.Select(m, s.Key(s, model.USER_UID), m.Option(model.USER_UID), s.Key(s, model.PLACE_UID), arg[0])
kit.If(m.Length() == 0, func() { m.Echo(m.Trans("wait apply", "等待申请")) })
} else if len(arg) == 2 {
s.SelectDetail(m, s.Key(s, model.USER_UID), m.Option(model.USER_UID), s.Key(s, model.PLACE_UID), arg[0], s.Key(s.apply, model.UID), arg[1])
} else {
return
}
if m.Length() == 0 {
m.Cmdy(s.Prefix(m, qrcode{}), s.ApplyQRCode, arg)
return
}
m.Table(func(value ice.Maps) {
if AllowStatus(kit.Int(value[model.ALLOW_STATUS])) == AllowCreate {
m.PushButton(s.Reject, s.Approve)
@ -46,7 +53,7 @@ func (s allow) List(m *ice.Message, arg ...string) {
m.PushButton()
s.DoneMessage(m)
}
}).Action()
}).Action(s.ApplyQRCode)
s.RenameAppend(m, model.PLACE_UID, s.Keys(s.Place, model.UID))
s.SelectJoin(m, s.Place, model.NAME, model.TYPE)
s.SelectJoinUser(m)

View File

@ -45,6 +45,7 @@ func (s apply) List(m *ice.Message, arg ...string) {
s.SelectDetail(m, model.USER_UID, m.Option(model.USER_UID), model.PLACE_UID, arg[0], s.Key(s, model.UID), arg[1])
switch ApplyStatus(kit.Int(m.Append(model.APPLY_STATUS))) {
case ApplySubmit:
m.Echo("请让管理员扫码或等待审批")
m.EchoQRCode(s.portal.Link(m, arg[0], s.Prefix(m, allow{}), arg[1]))
case ApplyRejected, ApplyApproved:
s.DoneMessage(m)

View File

@ -223,6 +223,12 @@ func (s Table) CheckRole(m *ice.Message, arg ...string) {
m.WarnNotRight(!kit.IsIn(role.String(), append(arg, UserPlaceCreator.String())...), role.String())
m.Option(model.USER_ROLE, kit.Format(role))
}
func (s Table) IsVisitor(m *ice.Message) bool {
if role := kit.Int(m.Option(model.USER_ROLE)); role == 0 {
return true
}
return false
}
func (s Table) IsLeader(m *ice.Message) bool {
if role := kit.Int(m.Option(model.USER_ROLE)); role == 1 || role == 2 {
return true
@ -233,7 +239,7 @@ func (s Table) PlaceInfo(m *ice.Message) {
m.Cmdy(s.Prefix(m, Portal{}), s.PlaceInfo)
}
func (s Table) UserPlaceRole(m *ice.Message) int {
return kit.Int(m.Cmdx(s.Prefix(m, Portal{}), s.UserPlaceRole))
return kit.Int(m.Cmdy(s.Prefix(m, Portal{}), s.UserPlaceRole).Option(model.USER_ROLE))
}
func (s Table) UserPlaceInit(m *ice.Message, arg ...string) {
if m.Option(model.PLACE_INIT) == "" {

View File

@ -29,7 +29,7 @@ type Portal struct {
command string `name:"command" role:"void"`
list string `name:"list place_uid index uid auto" role:"void"`
placeCreate string `name:"placeCreate city_name* street_name* place_name* place_type*:select address" icon:"bi bi-plus-square-dotted" role:"void"`
placeRemove string `name:"placeRemove uid*" role:"void"`
placeRemove string `name:"placeRemove" role:"void"`
placeAuth string `name:"placeAuth" role:"void"`
placeSearch string `name:"placeSearch" icon:"bi bi-search" role:"void"`
scanQRCode string `name:"scanQRCode type text" icon:"bi bi-qr-code-scan" role:"void"`
@ -72,10 +72,13 @@ func (s Portal) Run(m *ice.Message, arg ...string) {
} else if len(arg) > 1 {
if action, ok := cmd.Actions[arg[1]]; ok {
sub, role = arg[1], action.Role
} else {
m.OptionDefault(s.Keys(s.Place, model.UID), arg[1])
m.Option(s.Keys(s.Place, model.UID), arg[1])
}
}
s.UserPlaceRole(m)
if kit.IsIn(role, "", aaa.VOID, aaa.TECH, aaa.ROOT) {
m.Option(model.USER_ROLE, s.UserPlaceRole(m.Spawn()).Result())
kit.If(!ctx.PodCmd(m.Message, arg) && aaa.Right(m.Message, arg), func() { m.Cmdy(arg) })
} else {
if !m.Cmdy(arg[0], s.CheckRole, kit.Split(role)).IsErr() {
@ -132,6 +135,11 @@ func (s Portal) PlaceListOption(m *ice.Message, arg ...string) *ice.Message {
s.SelectJoinCity(msg)
s.SelectJoinAuth(msg)
}
m.Info("what %v", msg.FormatMeta())
if kit.Int(msg.Append(s.Keys(s.UserPlace, model.ROLE))) == 0 {
msg.Append(model.DASHBOARD_UID, "")
}
m.Info("what %v", msg.FormatMeta())
s.Place.RewriteAppend(msg)
m.Options(msg.AppendSimple(
s.Keys(s.Place, model.NAME), s.Keys(s.Place, model.TYPE), s.Keys(s.UserPlace, model.ROLE),
@ -262,7 +270,11 @@ func (s Portal) ValueList(m *ice.Message, arg ...string) {
} else {
return
}
m.PushAction(s.Remove)
if s.IsVisitor(m) {
m.Action()
} else {
m.PushAction(s.Remove)
}
}
func (s Portal) BeforePlaceCreate(m *ice.Message, arg ...string) {}
func (s Portal) AfterPlaceCreate(m *ice.Message, arg ...string) {}
@ -299,7 +311,9 @@ func (s Portal) StorageInsert(m *ice.Message, title, content string) {
func init() { ice.TeamCtxCmd(Portal{Table: newTable()}) }
func (s Portal) UserPlaceRole(m *ice.Message, arg ...string) *ice.Message {
m.Echo(m.Cmd(s.UserPlace, s.Table.Select, m.OptionSimple(s.Keys(s.Place, model.UID), model.USER_UID)).Append(model.ROLE))
if m.Option(model.USER_ROLE) == "" {
m.Option(model.USER_ROLE, m.Cmd(s.UserPlace, s.Table.Select, m.OptionSimple(s.Keys(s.Place, model.UID), model.USER_UID)).Append(model.ROLE))
}
return m
}
func (s Portal) UserPlaceCmd(m *ice.Message, arg ...string) {

View File

@ -7,7 +7,7 @@ Volcanos(chat.ONIMPORT, {
{view: html.TITLE, list: [value._name, can.onimport.authView(can, value),
{text: [value.__type, "", [mdb.TYPE, value._type, value._type_style]]}, value._role != "visitor" && {text: [value.__role, "", [aaa.ROLE, value._role, value._role_style]]},
]},
{view: html.STATUS, list: [value.uid.slice(0, 6), value.city_name, value._street]},
{view: html.STATUS, list: [value.uid.slice(0, 6), can.onimport.timeView(can, value), value.city_name, value._street]},
] },
myTrans: function(can, value, PLACE_UID, PLACE_NAME, PLACE_TYPE, USER_PLACE_ROLE, STREET_NAME) {
value.icons = value.icons||can.Conf(can.core.Keys("_trans.value", PLACE_TYPE, mdb.ICONS, value[PLACE_TYPE]))
@ -40,8 +40,8 @@ Volcanos(chat.ONIMPORT, {
can.onmotion.hidden(can, can.ui.myinit)
can.onmotion.hidden(can, can.ui.myallow)
function showIndex(msg) { if (msg.Length() == 0) { return }
can.onmotion.toggle(can, can.ui.mycount, true)
can.onmotion.toggle(can, can.ui.myallow, true)
// can.onmotion.toggle(can, can.ui.mycount, true)
// can.onmotion.toggle(can, can.ui.myallow, true)
can.onimport.myDebug(can, msg, can.ui.mydebug)
can.onimport.myCount(can, msg, can.ui.mycount)
can.onimport.myIndex(can, msg, can.ui.myindex, USER_PLACE_ROLE), can.onexport.index(can, can.sup.current)
@ -92,7 +92,13 @@ Volcanos(chat.ONIMPORT, {
can.onappend.plugin(can, val, function(sub) { var run = sub.run; sub.run = function(event, cmds, cb) {
can.onimport.myField(can, sub)
run(can.request(event, {place_uid: value._uid, place_init: value.init}), cmds, function(msg) {
if (cmds[1] == mdb.CREATE || cmds.length == 1 && msg.Length() > 0) { can.onmotion.clearInput(can), can.Update() } else { cb(msg) }
if (cmds[1] == mdb.CREATE || cmds.length == 1 && msg.Length() > 0) {
can._root.Inputs && can.onmotion.clear(can, can._root.Inputs)
can.onmotion.clearInput(can)
can.Update()
} else {
cb(msg)
}
})
}, can.onmotion.toggle(can, target, !!value._init) }, target)
} })
@ -116,7 +122,7 @@ Volcanos(chat.ONIMPORT, {
var output = can.page.Append(can, target, [html.OUTPUT])._target; can.onimport.myList(can, _msg, output)
},
myIndex: function(can, msg, target, USER_PLACE_ROLE) { can.onimport.myTitle(can, "My Index", "我的应用", target)
var list = ["visitor", "creator", "leader", "worker", "server"]
var list = ["visitor", "creator", "landlord", "teacher", "leader", "boss", "tenant", "student", "worker", "custom", "admin", "parent", "server"]
var _list = can.Conf("_trans.value."+USER_PLACE_ROLE)
can.core.Item(_list, function(key) { list.indexOf(key) == -1 && list.push(key) })
var role = can.page.Append(can, target, [{view: aaa.ROLE, list: can.core.List(list, function(key) {
@ -156,7 +162,9 @@ Volcanos(chat.ONACTION, {
can.user.isMobile && can.page.style(can, can._root.Action._output, html.VISIBILITY, html.HIDDEN)
sub.Option("city_name", "深圳市")
sub.Option("street_name", "航城街道")
sub.Option("school_name", "深圳中学")
sub.Option("company_name", "云境互联")
sub.Option("place_name", "易尚三维")
sub.Option("queue_name", "二楼产检")
sub.Option("reception_name", "科室1")
sub.Option("volume_amount", "100")
@ -168,7 +176,7 @@ Volcanos(chat.ONACTION, {
Volcanos(chat.ONEXPORT, {
place: function(can, value) { return can.onexport.session(can, PLACE_UID, value) },
value: function(can, value) {
if (!value || !value.uid) { return }
if (!value || !value._uid) { return }
can.sup.current = value, can.onexport.index(can, can.sup.current)
can.onexport.place(can, value._uid), can.onexport.hash(can, value._uid), can.onexport.title(can, value._name, can.ConfHelp())
can.user.agent.init(can, value.city_name+" "+value._street)

View File

@ -11,6 +11,7 @@
"autogen": "生成", "compile": "编译", "oauth": "授权", "project": "项目",
"marketInsert": "推广",
"commentCreate": "评论",
"applyQRCode": "邀请码",
"icons": {
"qrcode": "https://img.icons8.com/officel/80/qr-code.png",
"event": "https://img.icons8.com/officel/80/property-with-timer.png",
@ -44,6 +45,7 @@
"place_address": "场景地址",
"message_status": "消息状态",
"street_name": "街道名称",
"company_uid": "公司",
"company_name": "公司名称",
"city_name": "城市名称",
"auth_name": "认证主体",

View File

@ -8,15 +8,16 @@ import (
type qrcode struct {
Tables
portal Portal
order string `data:"501"`
role string `data:"creator"`
apply string `name:"apply" role:"void"`
portal Portal
order string `data:"501"`
role string `data:"creator"`
applyQRCode string `name:"applyQRCode" role:"void"`
}
func (s qrcode) Apply(m *ice.Message, arg ...string) {
func (s qrcode) ApplyQRCode(m *ice.Message, arg ...string) {
s.info(m, arg[0], "apply")
m.Option(ice.MSG_FG, "blue")
m.Echo("请让申请人扫码")
m.EchoQRCode(s.Link(m, arg[0]))
}
func (s qrcode) List(m *ice.Message, arg ...string) {
@ -28,5 +29,5 @@ func init() { ice.TeamCtxCmd(qrcode{Tables: newTables()}) }
func (s qrcode) info(m *ice.Message, place_uid, typ string) {
m.Cmdy(s.Prefix(m, s.portal), s.portal.PlaceList, m.Option(model.USER_UID), place_uid).Cut(model.CITY_NAME, s.Keys(s.Street, model.NAME), s.Keys(s.Place, model.NAME))
m.Push(model.QRCODE_TYPE, typ).Action(s.Apply)
m.Push(model.QRCODE_TYPE, typ).Action(s.ApplyQRCode)
}

View File

@ -14,7 +14,7 @@ type Portal struct {
}
func (s Portal) AfterPlaceAuth(m *ice.Message, arg ...string) {
s.DashboardCreate(m, "")
defer s.DashboardCreate(m, "")()
s.DashboardInsert(m, "1", "订单总量", Schedule{}, "", model.QUEUE_UID, m.Option(model.QUEUE_UID))
s.DashboardInsert(m, "2", "订单已预约", Schedule{}, "", model.QUEUE_UID, m.Option(model.QUEUE_UID), model.STATUS, SchedulePlan)
s.DashboardInsert(m, "3", "订单已取号", Schedule{}, "", model.QUEUE_UID, m.Option(model.QUEUE_UID), model.STATUS, ScheduleTake)