fix: 简化真实采购创建并恢复客户端选择 (#112)
This commit is contained in:
@@ -66,7 +66,7 @@ func (h *Handler) renderSybListWithLoginReason(c *gin.Context, keyword, pageRaw,
|
||||
"读取顺运宝同步记录失败,数据没有被改动。刷新页面重试;一直失败请把这句话报给维护者。")
|
||||
return
|
||||
}
|
||||
assignableClients, err := service.ListLivePurchaseClients(h.db, currentUser(c), h.onlineThreshold)
|
||||
purchaseClients, err := service.ListPurchaseClientOptions(h.db, currentUser(c), h.onlineThreshold)
|
||||
if err != nil {
|
||||
fail(c, http.StatusInternalServerError, "读取可分配客户端失败,数据没有被改动。")
|
||||
return
|
||||
@@ -181,9 +181,10 @@ func (h *Handler) renderSybListWithLoginReason(c *gin.Context, keyword, pageRaw,
|
||||
keyword, dateFrom, dateTo),
|
||||
"HistoryFetchPagination": sybHistoryPartialPagination(history.Page, history.TotalPages,
|
||||
keyword, dateFrom, dateTo),
|
||||
"Pagination": service.NewPaginationView(result.Page, result.TotalPages, values.Encode()),
|
||||
"DetailURL": "/syb/detail?" + detailValues.Encode(),
|
||||
"AssignableClients": assignableClients,
|
||||
"Pagination": service.NewPaginationView(result.Page, result.TotalPages, values.Encode()),
|
||||
"DetailURL": "/syb/detail?" + detailValues.Encode(),
|
||||
"AssignableClients": purchaseClients.Rows,
|
||||
"LivePurchaseClientCount": purchaseClients.SelectableCount,
|
||||
}))
|
||||
}
|
||||
|
||||
@@ -643,7 +644,7 @@ func (h *Handler) SybCreateTask(c *gin.Context) {
|
||||
}
|
||||
result, err := service.CreatePurchaseTasksWithOptions(
|
||||
h.db, currentUser(c), requests,
|
||||
purchaseTaskOptionsFromForm(c, time.Now().UTC().Add(-h.onlineThreshold).Format(model.TimeLayout)),
|
||||
purchaseTaskOptionsFromForm(c),
|
||||
)
|
||||
if err != nil {
|
||||
h.sybRedirect(c, "采购任务没有创建:"+err.Error())
|
||||
@@ -653,15 +654,12 @@ func (h *Handler) SybCreateTask(c *gin.Context) {
|
||||
h.sybRedirect(c, purchaseTaskResultMessage(result))
|
||||
}
|
||||
|
||||
func purchaseTaskOptionsFromForm(c *gin.Context, clientSeenAfter string) service.PurchaseTaskOptions {
|
||||
func purchaseTaskOptionsFromForm(c *gin.Context) service.PurchaseTaskOptions {
|
||||
return service.PurchaseTaskOptions{
|
||||
ClientID: c.PostForm("client_id"),
|
||||
// Admin 新建采购任务固定为 live。不能相信浏览器提交的 execution_mode,
|
||||
// 否则篡改表单就能绕过真实采购确认和审计。
|
||||
ExecutionMode: model.TaskExecutionLive,
|
||||
LiveAcknowledged: c.PostForm("live_acknowledged") == "1",
|
||||
LiveConfirmation: c.PostForm("live_confirmation"),
|
||||
ClientSeenAfter: clientSeenAfter,
|
||||
// 否则篡改表单就能改变任务的不可变执行模式。
|
||||
ExecutionMode: model.TaskExecutionLive,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user