feat: 商品详情页、XLS导入修复、分页选择器、导出功能

后端:
- 新增 product_images 表,支持每商品最多5张图(服务端压缩至1200px/JPEG85%)
- products 表新增 public_id(UUID)、description 字段
- 新增商品详情接口、二维码接口、公开商品接口(无鉴权)
- 修复 XLS 导入:OLE2 magic bytes 检测 + 临时文件解析,兼容 extrame/xls
- 修复商品/名称/系列/规格三张表导入数据为0(LastCol()=0 bug)
- 所有导入接口返回 total/imported/skipped 统计
- config 新增 StorageConfig,支持 STORAGE_* 环境变量覆盖
- 种子数据修复:products 补 public_id、新增 product_images TRUNCATE、schema.sql 表名修正

前端:
- 商品详情页:图片上传/删除、描述内联编辑、二维码弹窗、公开链接复制
- 公开商品页:无鉴权路由 /product/:public_id,Flutter Web SPA
- 商品详情列表(批次追踪)商品名超链接跳转详情页
- 导航「商品管理」改名「商品详情」
- 所有列表表格新增每页条数选择(10/20/50/100)
- 表格列头内嵌筛选(FilterableColumnHeader)
- 导出 Excel 功能(入库/出库/库存/财务/批次/往来单位)
- 网络恢复自动刷新 + 离线缓存展示

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
wangjia
2026-04-27 00:29:51 +08:00
parent 5dd7c07138
commit 393e227de5
70 changed files with 4993 additions and 1169 deletions
+37 -2
View File
@@ -26,8 +26,11 @@ func Setup(r *gin.Engine, db *gorm.DB) {
inventoryH := handler.NewInventoryHandler(db)
importH := handler.NewImportHandler(db)
userH := handler.NewUserHandler(db)
productOptH := handler.NewProductOptionHandler(db)
productImageH := handler.NewProductImageHandler(db)
financeH := handler.NewFinanceHandler(db)
numberRuleH := handler.NewNumberRuleHandler(db)
publicH := handler.NewPublicHandler(db)
// 健康检查(无需认证,用于前端连通性探测)
r.GET("/health", func(c *gin.Context) {
@@ -46,6 +49,12 @@ func Setup(r *gin.Engine, db *gorm.DB) {
auth.POST("/refresh", authH.Refresh)
}
// 商品公开详情(无需登录)
public := v1.Group("/public")
{
public.GET("/products/:public_id", publicH.GetProduct)
}
// 需要 JWT 的路由(ReadOnly 中间件:只读用户不可执行写操作)
api := v1.Group("")
api.Use(middleware.JWT(), middleware.ReadOnly())
@@ -64,8 +73,13 @@ func Setup(r *gin.Engine, db *gorm.DB) {
{
products.GET("", productH.List)
products.POST("", productH.Create)
products.POST("/find-or-create", productH.FindOrCreate)
products.GET("/:id/detail", productH.Detail)
products.GET("/:id/qrcode", productH.QRCode)
products.PUT("/:id", productH.Update)
products.DELETE("/:id", productH.Delete)
products.POST("/:id/images", productImageH.Upload)
products.DELETE("/:id/images/:image_id", productImageH.Delete)
}
// 仓库
@@ -148,8 +162,29 @@ func Setup(r *gin.Engine, db *gorm.DB) {
// 导入
imp := api.Group("/import")
{
imp.POST("/products", importH.ImportProducts)
imp.POST("/partners", importH.ImportPartners)
imp.POST("/products", importH.ImportProducts)
imp.POST("/partners", importH.ImportPartners)
imp.POST("/product-names", importH.ImportProductNames)
imp.POST("/product-series", importH.ImportProductSeries)
imp.POST("/product-specs", importH.ImportProductSpecs)
imp.POST("/stock-in", importH.ImportStockIn)
imp.POST("/stock-out", importH.ImportStockOut)
}
// 基础数据选项(名称/系列/规格)
opts := api.Group("/product-options")
{
opts.GET("/names", productOptH.ListNames)
opts.POST("/names", productOptH.CreateName)
opts.DELETE("/names/:id", productOptH.DeleteName)
opts.GET("/series", productOptH.ListSeries)
opts.POST("/series", productOptH.CreateSeries)
opts.DELETE("/series/:id", productOptH.DeleteSeries)
opts.GET("/specs", productOptH.ListSpecs)
opts.POST("/specs", productOptH.CreateSpec)
opts.DELETE("/specs/:id", productOptH.DeleteSpec)
}
}
}