Skip to content

Commit 48392c5

Browse files
committed
chore: 优化代码、新增订单详情组件
1 parent 300dcf3 commit 48392c5

18 files changed

+543
-309
lines changed

engine.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ const (
2222
AppName = "QuarkGo"
2323

2424
// 版本号
25-
Version = "3.8.2"
25+
Version = "3.8.3"
2626

2727
// 包名
2828
PkgName = "github.com/quarkcloudio/quark-go/v3"

template/admin/component/descriptions/field.go

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,22 +12,17 @@ type Field struct {
1212
// 初始化
1313
func (p *Field) Init() *Field {
1414
p.Component = "descriptionField"
15-
1615
p.SetKey(component.DEFAULT_KEY, component.DEFAULT_CRYPT)
17-
1816
return p
1917
}
2018

2119
// text组件
2220
func (p *Field) Text(params ...string) *fields.Text {
23-
2421
fields := &fields.Text{}
25-
2622
if len(params) == 1 {
2723
fields = fields.Init().SetDataIndex(params[0]).SetLabel(params[0])
2824
} else {
2925
fields = fields.Init().SetDataIndex(params[0]).SetLabel(params[1])
3026
}
31-
3227
return fields
3328
}
Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
package order
2+
3+
import "github.com/quarkcloudio/quark-go/v3/template/admin/component/component"
4+
5+
type Info struct {
6+
component.Element
7+
Title string `json:"title"`
8+
Column int `json:"column"`
9+
Layout string `json:"layout"`
10+
Colon bool `json:"colon"`
11+
DataIndex string `json:"dataIndex"`
12+
Items []Item `json:"items"`
13+
DataSource interface{} `json:"dataSource"`
14+
}
15+
16+
// 初始化组件
17+
func NewInfo() *Info {
18+
return (&Info{}).Init()
19+
}
20+
21+
// 初始化
22+
func (p *Info) Init() *Info {
23+
p.Component = "info"
24+
p.Column = 5
25+
p.Colon = true
26+
p.Layout = "horizontal"
27+
p.SetKey(component.DEFAULT_KEY, component.DEFAULT_CRYPT)
28+
return p
29+
}
30+
31+
// 设置标题
32+
func (p *Info) SetTitle(title string) *Info {
33+
p.Title = title
34+
return p
35+
}
36+
37+
// 设置列数量
38+
func (p *Info) SetColumn(column int) *Info {
39+
p.Column = column
40+
return p
41+
}
42+
43+
// 设置布局 vertical 或者 horizontal
44+
func (p *Info) SetLayout(layout string) *Info {
45+
p.Layout = layout
46+
return p
47+
}
48+
49+
// 是否有冒号分割
50+
func (p *Info) SetColon(colon bool) *Info {
51+
p.Colon = colon
52+
return p
53+
}
54+
55+
// 设置数据索引
56+
func (p *Info) SetDataIndex(dataIndex string) *Info {
57+
p.DataIndex = dataIndex
58+
return p
59+
}
60+
61+
// 设置展示项
62+
func (p *Info) SetItems(items []Item) *Info {
63+
p.Items = items
64+
return p
65+
}
66+
67+
// 设置数据源
68+
func (p *Info) SetDataSource(dataSource interface{}) *Info {
69+
p.DataSource = dataSource
70+
return p
71+
}
Lines changed: 138 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,138 @@
1+
package order
2+
3+
import "github.com/quarkcloudio/quark-go/v3/template/admin/component/component"
4+
5+
type Component struct {
6+
component.Element
7+
InitApi string `json:"initApi"`
8+
Icon string `json:"icon"`
9+
OrderNoText string `json:"orderNoText"`
10+
OrderNoName string `json:"orderNoName"`
11+
OrderDetailText string `json:"orderDetailText"`
12+
OrderItemText string `json:"orderItemText"`
13+
OrderStatusText string `json:"orderStatusText"`
14+
Info *Info `json:"info"`
15+
DetailInfo []*Info `json:"detailInfo"`
16+
ItemInfo *Table `json:"itemInfo"`
17+
StatusInfo *Table `json:"statusInfo"`
18+
}
19+
20+
type Column struct {
21+
Title string `json:"title"`
22+
DataIndex string `json:"dataIndex"`
23+
ValueType string `json:"valueType"`
24+
}
25+
26+
type Item struct {
27+
Key string `json:"key"`
28+
Label string `json:"label"`
29+
}
30+
31+
// 初始化组件
32+
func New() *Component {
33+
return (&Component{}).Init()
34+
}
35+
36+
// NewColumn("name", "标题") 或者 NewColumn("name", "标题", "image")
37+
func NewColumn(params ...string) Column {
38+
column := Column{}
39+
if len(params) == 2 {
40+
column.DataIndex = params[0]
41+
column.Title = params[1]
42+
column.ValueType = "text"
43+
}
44+
if len(params) == 3 {
45+
column.DataIndex = params[0]
46+
column.Title = params[1]
47+
column.ValueType = params[2]
48+
}
49+
return column
50+
}
51+
52+
func NewItem(key string, label string) Item {
53+
return Item{key, label}
54+
}
55+
56+
// 初始化
57+
func (p *Component) Init() *Component {
58+
p.Component = "order"
59+
p.OrderNoName = "order_no"
60+
p.OrderNoText = "订单号"
61+
p.OrderDetailText = "订单信息"
62+
p.OrderItemText = "商品信息"
63+
p.OrderStatusText = "订单记录"
64+
p.SetKey(component.DEFAULT_KEY, component.DEFAULT_CRYPT)
65+
return p
66+
}
67+
68+
// Set style.
69+
func (p *Component) SetStyle(style map[string]interface{}) *Component {
70+
p.Style = style
71+
return p
72+
}
73+
74+
// 初始化数据接口
75+
func (p *Component) SetInitApi(initApi string) *Component {
76+
p.InitApi = initApi
77+
return p
78+
}
79+
80+
// 设置图标地址
81+
func (p *Component) SetIcon(icon string) *Component {
82+
p.Icon = icon
83+
return p
84+
}
85+
86+
// 设置订单号展示文本
87+
func (p *Component) SetOrderNoText(orderNoText string) *Component {
88+
p.OrderNoText = orderNoText
89+
return p
90+
}
91+
92+
// 设置订单信息展示文本
93+
func (p *Component) SetOrderDetailText(orderDetailText string) *Component {
94+
p.OrderDetailText = orderDetailText
95+
return p
96+
}
97+
98+
// 设置商品信息展示文本
99+
func (p *Component) SetOrderItemText(orderItemText string) *Component {
100+
p.OrderItemText = orderItemText
101+
return p
102+
}
103+
104+
// 设置订单记录展示文本
105+
func (p *Component) SetOrderStatusText(orderStatusText string) *Component {
106+
p.OrderStatusText = orderStatusText
107+
return p
108+
}
109+
110+
// 设置订单号name
111+
func (p *Component) SetOrderNoName(orderNoName string) *Component {
112+
p.OrderNoName = orderNoName
113+
return p
114+
}
115+
116+
// 设置订单基本信息
117+
func (p *Component) SetInfo(info *Info) *Component {
118+
p.Info = info
119+
return p
120+
}
121+
122+
// 设置订单信息
123+
func (p *Component) SetDetailInfo(detailInfo []*Info) *Component {
124+
p.DetailInfo = detailInfo
125+
return p
126+
}
127+
128+
// 设置商品信息
129+
func (p *Component) SetItemInfo(itemInfo *Table) *Component {
130+
p.ItemInfo = itemInfo
131+
return p
132+
}
133+
134+
// 设置订单记录
135+
func (p *Component) SetStatusInfo(statusInfo *Table) *Component {
136+
p.StatusInfo = statusInfo
137+
return p
138+
}
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
package order
2+
3+
type Table struct {
4+
DataIndex string `json:"dataIndex"`
5+
Columns []Column `json:"columns"`
6+
DataSource []interface{} `json:"dataSource"`
7+
}
8+
9+
// 初始化组件
10+
func NewTable() *Table {
11+
return &Table{}
12+
}
13+
14+
// 设置数据源
15+
func (p *Table) SetColumn(columns []Column) *Table {
16+
p.Columns = columns
17+
return p
18+
}
19+
20+
// 设置数据索引
21+
func (p *Table) SetDataIndex(dataIndex string) *Table {
22+
p.DataIndex = dataIndex
23+
return p
24+
}
25+
26+
// 设置数据源
27+
func (p *Table) SetDataSource(dataSource []interface{}) *Table {
28+
p.DataSource = dataSource
29+
return p
30+
}

template/admin/resource/requests/store.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,5 +93,5 @@ func (p *StoreRequest) Handle(ctx *quark.Context, data map[string]interface{}) e
9393
// 保存后回调
9494
err = template.AfterSaved(ctx, id, data, model)
9595

96-
return template.AfterSavedRedirectTo(ctx, err)
96+
return template.AfterSavedRedirectTo(ctx, id, data, err)
9797
}

template/admin/resource/requests/update.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,5 +89,5 @@ func (p *UpdateRequest) Handle(ctx *quark.Context) error {
8989
// 保存后回调
9090
err = template.AfterSaved(ctx, int(data["id"].(float64)), data, query)
9191

92-
return template.AfterSavedRedirectTo(ctx, err)
92+
return template.AfterSavedRedirectTo(ctx, int(data["id"].(float64)), data, err)
9393
}

template/admin/resource/resource_form.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ func (p *Template) AfterSaved(ctx *quark.Context, id int, data map[string]interf
151151
}
152152

153153
// 保存数据后跳转回调
154-
func (p *Template) AfterSavedRedirectTo(ctx *quark.Context, err error) error {
154+
func (p *Template) AfterSavedRedirectTo(ctx *quark.Context, id int, data map[string]interface{}, err error) error {
155155

156156
// 返回错误信息
157157
if err != nil {

template/admin/resource/types/resourcer.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -247,7 +247,7 @@ type Resourcer interface {
247247
AfterSaved(ctx *quark.Context, id int, data map[string]interface{}, result *gorm.DB) error
248248

249249
// 保存数据后跳转回调
250-
AfterSavedRedirectTo(ctx *quark.Context, err error) error
250+
AfterSavedRedirectTo(ctx *quark.Context, id int, data map[string]interface{}, err error) error
251251

252252
// 列表页表格主体
253253
IndexTableExtraRender(ctx *quark.Context) interface{}

web/app/admin/173.async.js

Lines changed: 0 additions & 293 deletions
This file was deleted.

web/app/admin/277.async.js

Lines changed: 293 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

web/app/admin/326.async.js

Lines changed: 0 additions & 1 deletion
This file was deleted.

0 commit comments

Comments
 (0)