feat: 4项需求实现
1. 供应商/客户编码自动生成(S001/C001...),新建表单隐藏编码字段,编辑保留 2. 财务管理"全部记录"移为第一个 tab 3. 入库单列表 tab 排除 pending 单据,提交后自动移入审核 tab 4. 出库单列表同上;出库表单按仓库+商品自动填最大可用库存数量 Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
package handler
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"net/http"
|
||||
"strconv"
|
||||
|
||||
@@ -51,6 +52,18 @@ func (h *PartnerHandler) Create(c *gin.Context) {
|
||||
return
|
||||
}
|
||||
p.ShopID = shopID
|
||||
// 编码未提供时自动生成:供应商 S001/S002…,客户 C001/C002…
|
||||
if p.Code == "" {
|
||||
prefix := "S"
|
||||
if p.Type == "customer" {
|
||||
prefix = "C"
|
||||
}
|
||||
var count int64
|
||||
h.db.Model(&model.Partner{}).
|
||||
Where("shop_id = ? AND type = ? AND deleted_at IS NULL", shopID, p.Type).
|
||||
Count(&count)
|
||||
p.Code = fmt.Sprintf("%s%03d", prefix, count+1)
|
||||
}
|
||||
if err := h.db.Create(&p).Error; err != nil {
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"error": err.Error()})
|
||||
return
|
||||
|
||||
Reference in New Issue
Block a user