This commit is contained in:
jingganjiaoyu 2024-08-03 09:19:49 +08:00
parent fe1bc4bc60
commit a75fa32db0
11 changed files with 92 additions and 78 deletions

View File

@ -100,7 +100,7 @@ func (s apply) List(m *ice.Message, arg ...string) {
} else {
s.Table.Select(m.FieldsSetDetail(), s.Key(s, model.UID), arg[1])
if ApplyStatus(kit.Int(m.Append(model.APPLY_STATUS))) == ApplySubmit {
m.EchoQRCode(cmdurl(m, arg[0], m.Prefix("order"), arg[1]))
m.EchoQRCode(portal{}.Link(m, arg[0], m.Prefix("order"), arg[1]))
}
}
m.Table(func(value ice.Maps) {

View File

@ -43,11 +43,7 @@ func (s Table) RewriteAppend(m *ice.Message, arg ...string) *ice.Message {
}
func (s Table) SendTemplate(m *ice.Message, user_uid, title string) {
if !m.IsErr() {
m.Cmd(user{}, user{}.SendTemplate, user_uid, cmdurl(m, m.Option(model.PLACE_UID), m.PrefixKey(), m.Option(model.UID)),
m.Cmd(user{}, user{}.SendTemplate, user_uid, portal{}.Link(m, m.Option(model.PLACE_UID), m.PrefixKey(), m.Option(model.UID)),
title, m.Option(model.PLACE_NAME), kit.Cut(m.Option(model.UID), 6))
}
}
func cmdurl(m *ice.Message, arg ...string) string {
return m.MergePodCmd("", m.Prefix(web.PORTAL)) + "?debug=true" +
"#" + kit.Join([]string{arg[0], kit.Select(m.PrefixKey(), arg, 1), kit.Select("", arg, 2)}, ":")
}

View File

@ -52,7 +52,7 @@ type User struct {
type UserPlace struct {
db.ModelWithUID
UserUID string `gorm:"type:char(32);index"`
PlaceUID string `gorm:"type:char(32)"`
PlaceUID string `gorm:"type:char(32);index"`
Role uint8
BeginTime db.Time
EndTime db.Time
@ -66,8 +66,9 @@ type Place struct {
}
type Street struct {
db.ModelWithUID
CityUID string `gorm:"type:char(32)"`
CityUID string `gorm:"type:char(32);index"`
Name string `gorm:"type:char(32);index"`
Info string
}
type City struct {
db.ModelWithUID
@ -85,8 +86,8 @@ type Event struct {
}
type Apply struct {
db.ModelWithUID
UserUID string `gorm:"type:char(32);index"`
PlaceUID string `gorm:"type:char(32)"`
PlaceUID string `gorm:"type:char(32);index"`
UserUID string `gorm:"type:char(32)"`
Status uint8
Role uint8
BeginTime db.Time

View File

@ -69,7 +69,6 @@ func (s order) List(m *ice.Message, arg ...string) {
m.PushButton()
}
})
m.Info("what %v", m.FormatsMeta(nil))
s.RewriteAppend(m).Display("").DisplayCSS("")
}

View File

@ -2,30 +2,17 @@ package gonganxitong
import (
"shylinux.com/x/ice"
"shylinux.com/x/icebergs/base/ctx"
"shylinux.com/x/community/src/gonganxitong/model"
)
type place struct {
Table
user user
city city
street street
user user
}
func (s place) Inputs(m *ice.Message, arg ...string) {
switch arg[0] {
case model.CITY_NAME:
if m.Option(ctx.ACTION) == "placeCreate" {
break
}
m.Cmdy(s.city, s.city.Select).CutTo(model.NAME, arg[0])
case model.STREET_NAME:
if m.Option(ctx.ACTION) == "placeCreate" {
break
}
m.Cmdy(s.street, s.street.Select).CutTo(model.NAME, arg[0])
case model.PLACE_TYPE:
for k, v := range PlaceTypeList {
m.Push(arg[0], k).Push(model.NAME, v)

View File

@ -36,16 +36,16 @@ func (s portal) List(m *ice.Message, arg ...string) {
return
}
if len(arg) == 0 {
m.Cmdy(s.userPlace, m.Option(model.USER_UID)).Action(s.PlaceCreate, s.ScanQRCode).PushAction(s.PlaceRemove)
m.Cmdy(s.userPlace, m.Option(model.USER_UID)).PushAction(s.PlaceRemove).Action(s.PlaceCreate, s.ScanQRCode)
kit.If(!m.IsErr() && m.Length() == 0, func() {
m.EchoInfoButton(m.Trans("Please Create Your Place", "请添加场所"), s.PlaceCreate, s.ScanQRCode)
})
} else if len(arg) == 1 {
s.Hash.List(m, arg[1:]...).SortInt(mdb.ORDER)
} else if len(arg) == 2 {
msg := m.Cmd(s.place, s.place.Select, model.UID, arg[0])
m.Option(model.PLACE_NAME, msg.Append(model.NAME))
m.Cmdy(ctx.COMMAND, arg[1]).Push(ctx.ARGS, arg[0])
} else if len(arg) == 1 {
s.Hash.List(m, arg[1:]...).SortInt(mdb.ORDER)
} else {
m.FieldsSetDetail().Cmdy(arg[1], mdb.SELECT, model.UID, arg[2]).PushAction().Action()
}
@ -53,19 +53,22 @@ func (s portal) List(m *ice.Message, arg ...string) {
}
func (s portal) PlaceCreate(m *ice.Message, arg ...string) {
defer m.ToastProcess()()
s.city.FindOrCreateByName(m, arg...)
s.street.FindOrCreateByName(m, arg...)
if s.city.FindOrCreateByName(m, arg...); m.IsErr() {
return
}
if s.street.FindOrCreateByName(m, arg...); m.IsErr() {
return
}
arg = kit.TransArgKeys(arg, model.PLACE_TYPE, model.TYPE)
if m.Cmdy(s.place, s.place.Create, arg[2:]).IsErr() {
return
}
args := kit.Simple(model.USER_UID, m.Option(model.USER_UID), model.PLACE_UID, m.Result(), model.ROLE, UserPlaceCreator)
m.Cmdy(s.userPlace, s.userPlace.Create, args)
m.ProcessRefresh()
args := kit.Simple(m.OptionSimple(model.USER_UID), model.PLACE_UID, m.Result(), model.ROLE, UserPlaceCreator)
m.Cmdy(s.userPlace, s.userPlace.Create, args).ProcessRefresh()
}
func (s portal) PlaceRemove(m *ice.Message, arg ...string) {
defer m.ToastProcess()()
args := kit.Simple(model.USER_UID, m.Option(model.USER_UID), model.PLACE_UID, m.Option(model.PLACE_UID), model.ROLE, m.Option(model.USER_PLACE_ROLE))
args := kit.Simple(m.OptionSimple(model.USER_UID, model.PLACE_UID), model.ROLE, m.Option(model.USER_PLACE_ROLE))
msg := m.Cmd(s.userPlace, s.userPlace.Select, args)
if m.WarnNotFound(msg.Length() == 0, "place") {
return
@ -93,15 +96,6 @@ func (s portal) ScanQRCode(m *ice.Message, arg ...string) {
func init() { ice.TeamCtxCmd(portal{}) }
type Portal struct {
portal
export string `data:"true"`
short string `data:"index"`
field string `data:"time,name,icons,index,order,enable,type,role"`
}
func init() { ice.TeamCtxCmd(Portal{}) }
func (s portal) Show(m *ice.Message, arg ...string) {
m.GoSleep("30ms", func() {
cmd := m.GetCommand()
@ -109,3 +103,17 @@ func (s portal) Show(m *ice.Message, arg ...string) {
m.Cmd(s, s.Create, mdb.NAME, cmd.Help, mdb.ICONS, icon, ctx.INDEX, m.PrefixKey(), arg)
})
}
func (s portal) Link(m *ice.Message, arg ...string) string {
return m.MergePodCmd("", m.Prefix(web.PORTAL)) + "?debug=true" +
"#" + kit.Join([]string{arg[0], kit.Select(m.PrefixKey(), arg, 1), kit.Select("", arg, 2)}, ":")
}
type Portal struct {
portal
export string `data:"true"`
short string `data:"index"`
field string `data:"time,name,icons,index,order,enable,type,role"`
inputs string `name:"inputs" role:"void"`
}
func init() { ice.TeamCtxCmd(Portal{}) }

View File

@ -16,6 +16,7 @@ Volcanos(chat.ONIMPORT, {
]
},
myPortal: function(can, msg, PLACE_UID, PLACE_NAME, title) { can.user.isMobile && can.isCmdMode() && can.onappend.style(can, html.OUTPUT)
var PLACE_TYPE = PLACE_NAME.replace("_name", "_type")
can.isCmdMode() && (can.db.hash = can.misc.SearchHash(can))
can.sup.current = can.sup.current||{}
if (can.Option(PLACE_UID) == "") {
@ -27,8 +28,9 @@ Volcanos(chat.ONIMPORT, {
msg.Option(ice.MSG_ACTION) && can.onappend._action(can, msg.Option(ice.MSG_ACTION), target)
}}])
}}])
debugger
msg.Table(function(value) { var key = "_trans.value."+PLACE_NAME.replace("_name", "_type")+".icons."
msg.Push(mdb.ICONS, can.Conf(key+value.place_type)||can.Conf(key+"office"))
msg.Push(mdb.ICONS, can.Conf(key+value[PLACE_TYPE])||can.Conf(key+"office"))
})
var uid = can.onimport.myPlace(can, msg, can.ui.myplace, PLACE_UID, PLACE_NAME)
msg.Length() > 0 && can.run({}, [uid], function(msg) {

View File

@ -1,4 +1,4 @@
chapter "用户场所"
chapter "公安系统"
refer `
ICON https://igoutu.cn/icons/officel
GORM https://gorm.io/docs/indexes.html
@ -8,4 +8,4 @@ field web.code.mysql.client
field web.code.mysql.query args `mysql gonganxitong`
field web.code.db.database
field web.code.db.driver
field web.code.db.models
field web.code.db.models

View File

@ -10,7 +10,7 @@ import (
type qrcode struct {
portal portal
userPlace userPlace
list string `name:"list place_uid uid auto" role:"void"`
list string `name:"list place_uid auto" role:"void"`
}
func (s qrcode) Init(m *ice.Message, arg ...string) {
@ -19,12 +19,8 @@ func (s qrcode) Init(m *ice.Message, arg ...string) {
func (s qrcode) List(m *ice.Message, arg ...string) {
msg := m.Cmd(s.userPlace, m.Option(model.USER_UID), arg[0])
m.FieldsSetDetail()
kit.For([]string{
model.CITY_NAME, model.STREET_NAME, model.PLACE_NAME, model.PLACE_ADDRESS,
}, func(key string) {
m.Push(key, msg.Append(key))
})
m.EchoQRCode(cmdurl(m, arg[0], m.Prefix("apply")))
kit.For([]string{model.CITY_NAME, model.STREET_NAME, model.PLACE_NAME, model.PLACE_ADDRESS}, func(key string) { m.Push(key, msg.Append(key)) })
m.EchoQRCode(s.portal.Link(m, arg[0], m.Prefix("apply")))
}
func init() { ice.TeamCtxCmd(qrcode{}) }

View File

@ -11,25 +11,15 @@ type userPlace struct {
place place
street street
city city
create string `name:"create user_uid* place_uid* role* begin_time end_time"`
list string `name:"list user_uid place_uid auto"`
}
func (s userPlace) List(m *ice.Message, arg ...string) {
s.Tables(m, s.place, s.street, s.city).Fields(m, "user_places.created_at", "user_places.id",
s.Tables(m, s.place, s.street, s.city).Fields(m,
s.Key(s, model.CREATED_AT),
model.PLACE_NAME, model.PLACE_TYPE, model.USER_PLACE_ROLE,
model.CITY_NAME, model.STREET_NAME, model.PLACE_ADDRESS,
model.USER_UID, model.PLACE_UID,
).Orders(m, "created_at DESC")
if len(arg) == 0 {
if m.IsTech() {
s.Select(m)
}
} else if len(arg) == 1 {
s.Select(m, model.USER_UID, arg[0])
} else {
s.Select(m.FieldsSetDetail(), model.PLACE_UID, arg[1])
}
).Orders(m, s.Desc(model.CREATED_AT)).Select(m, model.USER_UID, arg[0])
s.RewriteAppend(m)
}

View File

@ -2,51 +2,86 @@
"27c6988eeb07c78cbb49aa15c577cfa4": {
"meta": {
"enable": "true",
"icons": "https://img.icons8.com/officel/80/edit-property.png",
"index": "web.team.gonganxitong.apply",
"name": "申请单",
"order": "2",
"role": "visitor,tenant",
"time": "2024-07-31 22:13:57.022"
"time": "2024-08-02 17:16:31.610"
}
},
"3c12d065a7b2fb9a8a09f47d87bd5bef": {
"meta": {
"index": "web.team.gonganxitong.express.express",
"time": "2024-08-02 22:10:41.621"
}
},
"58724bdcc3cae3e26700cb3199e0602c": {
"meta": {
"enable": "true",
"icons": "https://img.icons8.com/officel/80/person-at-home.png",
"index": "web.team.gonganxitong.placeUser",
"name": "场所用户",
"order": "4",
"role": "creator,landlord",
"time": "2024-08-02 17:16:31.610"
}
},
"6154e70009651fcae3e9be1b53580db1": {
"meta": {
"index": "web.team.express.express",
"time": "2024-08-02 13:22:54.776"
}
},
"91dd0e9590d3021944f14f3ec8653beb": {
"meta": {
"enable": "true",
"icons": "https://img.icons8.com/officel/80/receipt-approved.png",
"index": "web.team.gonganxitong.order",
"name": "审批单",
"order": "3",
"role": "creator,landlord",
"time": "2024-07-31 22:13:57.024"
"time": "2024-08-02 17:07:48.171"
}
},
"ad574b9493741774ef8cb3fd5efd8026": {
"meta": {
"enable": "true",
"icons": "https://img.icons8.com/officel/80/shipped.png",
"index": "web.team.gonganxitong.express",
"name": "寄快递",
"order": "5",
"time": "2024-08-02 12:47:45.588"
}
},
"bdec92d5849b2a60a8811cff494f2391": {
"meta": {
"enable": "true",
"enable": "false",
"icons": "https://img.icons8.com/officel/80/property-with-timer.png",
"index": "web.team.gonganxitong.event",
"name": "事件流",
"order": "4",
"role": "creator,landlord",
"time": "2024-07-31 22:13:57.027"
"role": "creator",
"time": "2024-08-02 17:16:31.613"
}
},
"e2117b53c036a72fe7e4885449488a6f": {
"meta": {
"enable": "true",
"icons": "usr/icons/Chess.png",
"icons": "https://img.icons8.com/officel/80/qr-code.png",
"index": "web.team.gonganxitong.qrcode",
"name": "场所码",
"order": "1",
"role": "creator,landlord",
"time": "2024-07-31 22:13:57.020"
"time": "2024-08-02 16:32:26.372"
}
},
"fd86aad80a667152781bb188fb1249a2": {
"meta": {
"icons": "usr/icons/Mail.png",
"enable": "false",
"icons": "https://img.icons8.com/officel/80/reading-confirmation.png",
"index": "web.team.gonganxitong.email",
"name": "邮箱配置",
"order": "5",
"time": "2024-07-31 22:13:57.027"
"role": "creator",
"time": "2024-08-02 17:16:31.613"
}
}
}