Browse Source

Merge remote-tracking branch 'origin/dev' into dev

2545307760@qq.com 4 months ago
parent
commit
3a841ee09b

+ 10 - 4
server/api/v1/storehouse/enter.go

@@ -7,11 +7,17 @@ type ApiGroup struct {
 	CommodityGenreApi
 	SupplierApi
 	WarehouseApi
+	PlaceApi
+	StorageAreaApi
+	StorageAreaGenreApi
 }
 
 var (
-	commodityService      = service.ServiceGroupApp.StorehouseServiceGroup.CommodityService
-	commodityGenreService = service.ServiceGroupApp.StorehouseServiceGroup.CommodityGenreService
-	supplierService       = service.ServiceGroupApp.StorehouseServiceGroup.SupplierService
-	warehouseService      = service.ServiceGroupApp.StorehouseServiceGroup.WarehouseService
+	commodityService        = service.ServiceGroupApp.StorehouseServiceGroup.CommodityService
+	commodityGenreService   = service.ServiceGroupApp.StorehouseServiceGroup.CommodityGenreService
+	supplierService         = service.ServiceGroupApp.StorehouseServiceGroup.SupplierService
+	warehouseService        = service.ServiceGroupApp.StorehouseServiceGroup.WarehouseService
+	placeService            = service.ServiceGroupApp.StorehouseServiceGroup.PlaceService
+	storageAreaService      = service.ServiceGroupApp.StorehouseServiceGroup.StorageAreaService
+	storageAreaGenreService = service.ServiceGroupApp.StorehouseServiceGroup.StorageAreaGenreService
 )

+ 111 - 0
server/api/v1/storehouse/place.go

@@ -0,0 +1,111 @@
+package storehouse
+
+import (
+	"github.com/gin-gonic/gin"
+	"server/dao"
+	"server/global"
+	"server/model/common/request"
+	"server/model/common/response"
+)
+
+type PlaceApi struct{}
+
+func (pa *PlaceApi) QueryAllPlace(c *gin.Context) {
+	places, err := placeService.QueryAllPlaces()
+	if err != nil {
+		response.FailWithMessage("查询失败", c)
+		global.GVA_LOG.Error("QueryAllPlace ======= " + err.Error())
+		return
+	}
+	response.OkWithData(places, c)
+}
+
+func (pa *PlaceApi) QueryPlaceList(c *gin.Context) {
+	var info request.SearchPlace
+	err := c.ShouldBindJSON(&info)
+	if err != nil {
+		response.FailWithMessage("参数解析失败", c)
+		global.GVA_LOG.Error("QueryPlaceList ======= " + err.Error())
+		return
+	}
+	list, total, err := placeService.QueryPlaceList(info)
+	if err != nil {
+		response.FailWithMessage("查询失败", c)
+		global.GVA_LOG.Error("QueryPlaceList ======= " + err.Error())
+		return
+	}
+	response.OkWithDetailed(response.PageResult{
+		List:     list,
+		Total:    total,
+		Page:     info.PageInfo.Page,
+		PageSize: info.PageInfo.PageSize,
+	}, "获取成功", c)
+}
+
+func (pa *PlaceApi) CreatePlace(c *gin.Context) {
+	var place dao.Place
+	err := c.ShouldBindJSON(&place)
+	if err != nil {
+		response.FailWithMessage("参数解析失败", c)
+		global.GVA_LOG.Error("CreatePlace ======= " + err.Error())
+		return
+	}
+	err = placeService.CreatePlace(place)
+	if err != nil {
+		response.FailWithMessage("创建失败", c)
+		global.GVA_LOG.Error("CreatePlace ======= " + err.Error())
+		return
+	}
+	response.OkWithMessage("创建成功", c)
+}
+
+func (pa *PlaceApi) UpdatePlace(c *gin.Context) {
+	var place dao.Place
+	err := c.ShouldBindJSON(&place)
+	if err != nil {
+		response.FailWithMessage("参数解析失败", c)
+		global.GVA_LOG.Error("UpdatePlace ======= " + err.Error())
+		return
+	}
+	err = placeService.UpdatePlace(place)
+	if err != nil {
+		response.FailWithMessage("更新失败", c)
+		global.GVA_LOG.Error("UpdatePlace ======= " + err.Error())
+		return
+	}
+	response.OkWithMessage("更新成功", c)
+}
+
+func (pa *PlaceApi) SwitchPlace(c *gin.Context) {
+	var place dao.Place
+	err := c.ShouldBindJSON(&place)
+	if err != nil {
+		response.FailWithMessage("参数解析失败", c)
+		global.GVA_LOG.Error("SwitchPlace ======= " + err.Error())
+		return
+	}
+	err = placeService.SwitchPlace(place)
+	if err != nil {
+		response.FailWithMessage("切换失败", c)
+		global.GVA_LOG.Error("SwitchPlace ======= " + err.Error())
+		return
+	}
+	response.OkWithMessage("切换成功", c)
+}
+
+func (pa *PlaceApi) DeletePlace(c *gin.Context) {
+	var place dao.Place
+	err := c.ShouldBindJSON(&place)
+	if err != nil {
+		response.FailWithMessage("参数解析失败", c)
+		global.GVA_LOG.Error("DeletePlace ======= " + err.Error())
+		return
+	}
+	err = placeService.DeletePlace(place)
+	if err != nil {
+		response.FailWithMessage("删除失败", c)
+		global.GVA_LOG.Error("DeletePlace ======= " + err.Error())
+		return
+	}
+	response.OkWithMessage("删除成功", c)
+}

+ 111 - 0
server/api/v1/storehouse/storageArea.go

@@ -0,0 +1,111 @@
+package storehouse
+
+import (
+	"github.com/gin-gonic/gin"
+	"server/dao"
+	"server/global"
+	"server/model/common/request"
+	"server/model/common/response"
+)
+
+type StorageAreaApi struct{}
+
+func (ssa *StorageAreaApi) QueryAllStorageAreas(c *gin.Context) {
+	area, err := storageAreaService.QueryAllStorageArea()
+	if err != nil {
+		response.FailWithMessage("查询失败", c)
+		global.GVA_LOG.Error("QueryAllStorageAreas ====== " + err.Error())
+		return
+	}
+	response.OkWithData(area, c)
+}
+
+func (ssa *StorageAreaApi) QueryStorageAreaList(c *gin.Context) {
+	var info request.SearchStorageArea
+	err := c.ShouldBindJSON(&info)
+	if err != nil {
+		response.FailWithMessage("参数解析失败", c)
+		global.GVA_LOG.Error("QueryPlaceList ======= " + err.Error())
+		return
+	}
+	list, total, err := storageAreaService.QueryStorageAreaList(info)
+	if err != nil {
+		response.FailWithMessage("查询失败", c)
+		global.GVA_LOG.Error("QueryPlaceList ======= " + err.Error())
+		return
+	}
+	response.OkWithDetailed(response.PageResult{
+		List:     list,
+		Total:    total,
+		Page:     info.PageInfo.Page,
+		PageSize: info.PageInfo.PageSize,
+	}, "获取成功", c)
+}
+
+func (ssa *StorageAreaApi) CreateStorageArea(c *gin.Context) {
+	var area dao.StorageArea
+	err := c.ShouldBindJSON(&area)
+	if err != nil {
+		response.FailWithMessage("参数解析失败", c)
+		global.GVA_LOG.Error("CreateStorageArea ====== " + err.Error())
+		return
+	}
+	err = storageAreaService.CreateStorageArea(area)
+	if err != nil {
+		response.FailWithMessage("创建失败", c)
+		global.GVA_LOG.Error("CreateStorageArea ====== " + err.Error())
+		return
+	}
+	response.OkWithMessage("创建成功", c)
+}
+
+func (ssa *StorageAreaApi) UpdateStorageArea(c *gin.Context) {
+	var area dao.StorageArea
+	err := c.ShouldBindJSON(&area)
+	if err != nil {
+		response.FailWithMessage("参数解析失败", c)
+		global.GVA_LOG.Error("UpdateStorageArea ====== " + err.Error())
+		return
+	}
+	err = storageAreaService.UpdateStorageArea(area)
+	if err != nil {
+		response.FailWithMessage("修改失败", c)
+		global.GVA_LOG.Error("UpdateStorageArea ====== " + err.Error())
+		return
+	}
+	response.OkWithMessage("修改成功", c)
+}
+
+func (ssa *StorageAreaApi) SwitchStorageArea(c *gin.Context) {
+	var area dao.StorageArea
+	err := c.ShouldBindJSON(&area)
+	if err != nil {
+		response.FailWithMessage("参数解析失败", c)
+		global.GVA_LOG.Error("SwitchStorageArea ====== " + err.Error())
+		return
+	}
+	err = storageAreaService.SwitchStorageArea(area)
+	if err != nil {
+		response.FailWithMessage("切换状态失败", c)
+		global.GVA_LOG.Error("SwitchStorageArea ====== " + err.Error())
+		return
+	}
+	response.OkWithMessage("切换状态成功", c)
+}
+
+func (ssa *StorageAreaApi) DeleteStorageArea(c *gin.Context) {
+	var area dao.StorageArea
+	err := c.ShouldBindJSON(&area)
+	if err != nil {
+		response.FailWithMessage("参数解析失败", c)
+		global.GVA_LOG.Error("DeleteStorageArea ====== " + err.Error())
+		return
+	}
+	err = storageAreaService.DeleteStorageArea(area)
+	if err != nil {
+		response.FailWithMessage("删除失败", c)
+		global.GVA_LOG.Error("DeleteStorageArea ====== " + err.Error())
+		return
+	}
+	response.OkWithMessage("删除成功", c)
+}

+ 71 - 0
server/api/v1/storehouse/storageAreaGenre.go

@@ -0,0 +1,71 @@
+package storehouse
+
+import (
+	"github.com/gin-gonic/gin"
+	"server/dao"
+	"server/global"
+	"server/model/common/response"
+)
+
+type StorageAreaGenreApi struct{}
+
+func (saga *StorageAreaGenreApi) QueryAllStorageAreaGenre(c *gin.Context) {
+	genres, err := storageAreaGenreService.QueryAllStorageAreaGenres()
+	if err != nil {
+		response.FailWithMessage("查询失败", c)
+		global.GVA_LOG.Error("QueryAllStorageAreaGenre ======= " + err.Error())
+		return
+	}
+	response.OkWithData(genres, c)
+}
+
+func (saga *StorageAreaGenreApi) CreateStorageAreaGenre(c *gin.Context) {
+	var genre dao.StorageAreaGenre
+	err := c.ShouldBindJSON(&genre)
+	if err != nil {
+		response.FailWithMessage("参数错误", c)
+		global.GVA_LOG.Error("CreateStorageAreaGenre ======= " + err.Error())
+		return
+	}
+	err = storageAreaGenreService.CreateStorageAreaGenre(genre)
+	if err != nil {
+		response.FailWithMessage("创建失败", c)
+		global.GVA_LOG.Error("CreateStorageAreaGenre ======= " + err.Error())
+		return
+	}
+	response.OkWithMessage("创建成功", c)
+}
+
+func (saga *StorageAreaGenreApi) UpdateStorageAreaGenre(c *gin.Context) {
+	var genre dao.StorageAreaGenre
+	err := c.ShouldBindJSON(&genre)
+	if err != nil {
+		response.FailWithMessage("参数错误", c)
+		global.GVA_LOG.Error("UpdateStorageAreaGenre ======= " + err.Error())
+		return
+	}
+	err = storageAreaGenreService.UpdateStorageAreaGenre(genre)
+	if err != nil {
+		response.FailWithMessage("更新失败", c)
+		global.GVA_LOG.Error("UpdateStorageAreaGenre ======= " + err.Error())
+		return
+	}
+	response.OkWithMessage("更新成功", c)
+}
+
+func (saga *StorageAreaGenreApi) DeleteStorageAreaGenre(c *gin.Context) {
+	var genre dao.StorageAreaGenre
+	err := c.ShouldBindJSON(&genre)
+	if err != nil {
+		response.FailWithMessage("参数错误", c)
+		global.GVA_LOG.Error("DeleteStorageAreaGenre ======= " + err.Error())
+		return
+	}
+	err = storageAreaGenreService.DeleteStorageAreaGenre(genre)
+	if err != nil {
+		response.FailWithMessage("删除失败", c)
+		global.GVA_LOG.Error("DeleteStorageAreaGenre ======= " + err.Error())
+		return
+	}
+	response.OkWithMessage("删除成功", c)
+}

+ 20 - 3
server/api/v1/storehouse/warehouse.go

@@ -21,7 +21,7 @@ func (wa *WarehouseApi) QueryAllWarehouse(c *gin.Context) {
 }
 
 func (wa *WarehouseApi) QueryWarehouseList(c *gin.Context) {
-	var info request.PageInfo
+	var info request.SearchWarehouse
 	err := c.ShouldBindJSON(&info)
 	if err != nil {
 		response.FailWithMessage("参数解析失败", c)
@@ -37,8 +37,8 @@ func (wa *WarehouseApi) QueryWarehouseList(c *gin.Context) {
 	response.OkWithDetailed(response.PageResult{
 		List:     list,
 		Total:    total,
-		Page:     info.Page,
-		PageSize: info.PageSize,
+		Page:     info.PageInfo.Page,
+		PageSize: info.PageInfo.PageSize,
 	}, "获取成功", c)
 }
 
@@ -76,6 +76,23 @@ func (wa *WarehouseApi) UpdateWarehouse(c *gin.Context) {
 	response.OkWithMessage("更新成功", c)
 }
 
+func (wa *WarehouseApi) SwitchWarehouse(c *gin.Context) {
+	var warehouse dao.Warehouse
+	err := c.ShouldBindJSON(&warehouse)
+	if err != nil {
+		response.FailWithMessage("参数解析失败", c)
+		global.GVA_LOG.Error("SwitchWarehouse ====== " + err.Error())
+		return
+	}
+	err = warehouseService.SwitchWarehouse(warehouse)
+	if err != nil {
+		response.FailWithMessage("切换失败", c)
+		global.GVA_LOG.Error("SwitchWarehouse ====== " + err.Error())
+		return
+	}
+	response.OkWithMessage("切换成功", c)
+}
+
 func (wa *WarehouseApi) DeleteWarehouse(c *gin.Context) {
 	var warehouse dao.Warehouse
 	err := c.ShouldBindJSON(&warehouse)

+ 67 - 0
server/dao/place.go

@@ -0,0 +1,67 @@
+package dao
+
+import "server/global"
+
+type Place struct {
+	global.GVA_MODEL
+	Code             string           `json:"code" form:"code" gorm:"comment:库位编码"`
+	ShelfNumber      string           `json:"shelfNumber" form:"shelfNumber" gorm:"comment:货架号"`
+	LayerNumber      string           `json:"layerNumber" form:"layerNumber" gorm:"comment:层号"`
+	Genre            int              `json:"genre" form:"genre" gorm:"comment:库区类型"`
+	StorageAreaGenre StorageAreaGenre `json:"storageAreaGenre" form:"storageAreaGenre" gorm:"foreignKey:Genre;references:id;"`
+	StorageAreaID    int              `json:"storageAreaId" form:"storageAreaId" gorm:"comment:所属库区id"`
+	StorageArea      StorageArea      `json:"storageArea" form:"storageArea" gorm:"foreignKey:StorageAreaID;references:id;"`
+	WarehouseId      int              `json:"warehouseId" form:"warehouseId" gorm:"comment:仓库"`
+	Warehouse        Warehouse        `json:"warehouse" form:"warehouse" gorm:"foreignKey:WarehouseId;references:id;"`
+	IsEffective      bool             `json:"isEffective" form:"isEffective" gorm:"comment:是否有效;default:0"`
+}
+
+func (Place) TableName() string {
+	return "place"
+}
+
+func QueryAllPlace() (places []Place, err error) {
+	err = global.GVA_DB.Where("is_effective = true").Find(&places).Error
+	return
+}
+
+func QueryPlaceList(limit, offset, genre, warehouseId, storageAreaId int, name string) (places []Place, total int64, err error) {
+	// 创建db
+	db := global.GVA_DB.Model(&Place{})
+	// 如果有条件搜索 下方会自动创建搜索语句
+	if genre != 0 {
+		db = db.Where("genre = ?", genre)
+	}
+	if storageAreaId != 0 {
+		db = db.Where("id = ?", storageAreaId)
+	}
+	if warehouseId != 0 {
+		db = db.Where("warehouse_id = ?", warehouseId)
+	}
+	if name != "" {
+		db = db.Where("name LIKE ?", "%"+name+"%")
+	}
+
+	err = db.Count(&total).Error
+	if err != nil {
+		return
+	}
+	err = db.Order("id desc").Limit(limit).Offset(offset).Preload("StorageArea").Preload("Warehouse").Preload("StorageAreaGenre").Find(&places).Error
+	return places, total, err
+}
+
+func (p Place) CreatePlace() error {
+	return global.GVA_DB.Create(&p).Error
+}
+
+func (p Place) SwitchPlace() error {
+	return global.GVA_DB.Select("is_effective").Where("id = ?", p.ID).Updates(&p).Error
+}
+
+func (p Place) UpdatePlace() error {
+	return global.GVA_DB.Model(&Place{}).Where("id =?", p.ID).Updates(&p).Error
+}
+
+func (p Place) DeletePlace() error {
+	return global.GVA_DB.Unscoped().Delete(&p).Error
+}

+ 62 - 0
server/dao/storageArea.go

@@ -0,0 +1,62 @@
+package dao
+
+import (
+	"server/global"
+)
+
+type StorageArea struct {
+	global.GVA_MODEL
+	Name             string           `json:"name" form:"name" gorm:"comment:库区名称"`
+	Genre            int              `json:"genre" form:"genre" gorm:"comment:库区类型"`
+	StorageAreaGenre StorageAreaGenre `json:"storageAreaGenre" form:"storageAreaGenre" gorm:"foreignKey:Genre;references:id;"`
+	WarehouseId      int              `json:"warehouseId" form:"warehouseId" gorm:"comment:仓库"`
+	Warehouse        Warehouse        `json:"warehouse" form:"warehouse" gorm:"foreignKey:WarehouseId;references:id;"`
+	IsEffective      bool             `json:"isEffective" form:"isEffective" gorm:"comment:是否有效;default:0"`
+}
+
+func (StorageArea) TableName() string {
+	return "storage_area"
+}
+
+func QueryAllStorageArea() (storageAreas []StorageArea, err error) {
+	err = global.GVA_DB.Where("is_effective = true").Preload("StorageAreaGenre").Find(&storageAreas).Error
+	return storageAreas, err
+}
+
+func QueryStorageAreaList(limit, offset, genre, warehouseId int, name string) (storageAreas []StorageArea, total int64, err error) {
+	// 创建db
+	db := global.GVA_DB.Model(&StorageArea{})
+	// 如果有条件搜索 下方会自动创建搜索语句
+	if genre != 0 {
+		db = db.Where("genre = ?", genre)
+	}
+	if warehouseId != 0 {
+		db = db.Where("warehouse_id = ?", warehouseId)
+	}
+	if name != "" {
+		db = db.Where("name LIKE?", "%"+name+"%")
+	}
+
+	err = db.Count(&total).Error
+	if err != nil {
+		return
+	}
+	err = db.Order("id desc").Limit(limit).Offset(offset).Preload("Warehouse").Preload("StorageAreaGenre").Find(&storageAreas).Error
+	return storageAreas, total, err
+}
+
+func (sa StorageArea) CreateStorageArea() error {
+	return global.GVA_DB.Create(&sa).Error
+}
+
+func (sa StorageArea) UpdateStorageArea() error {
+	return global.GVA_DB.Where("id = ?", sa.ID).Updates(&sa).Error
+}
+
+func (sa StorageArea) SwitchStorageArea() error {
+	return global.GVA_DB.Select("is_effective").Where("id = ?", sa.ID).Updates(&sa).Error
+}
+
+func (sa StorageArea) DeleteStorageArea() error {
+	return global.GVA_DB.Unscoped().Delete(&sa).Error
+}

+ 31 - 0
server/dao/storageAreaGenre.go

@@ -0,0 +1,31 @@
+package dao
+
+import "server/global"
+
+type StorageAreaGenre struct {
+	global.GVA_MODEL
+	Name string `json:"name" form:"name" gorm:"comment:库位类目名称"`
+}
+
+func (StorageAreaGenre) TableName() string {
+	return "storage_area_genre"
+}
+
+func QueryAllStorageAreaGenres() (genre []StorageAreaGenre, err error) {
+	err = global.GVA_DB.Find(&genre).Error
+	return
+}
+
+func (sg StorageAreaGenre) CreateStorageAreaGenre() error {
+	return global.GVA_DB.Create(&sg).Error
+}
+
+func (sg StorageAreaGenre) UpdateStorageAreaGenre() error {
+	err := global.GVA_DB.Model(&sg).Where("id = ?", sg.ID).Updates(&sg).Error
+	return err
+}
+
+func (sg StorageAreaGenre) DeleteStorageAreaGenre() error {
+	err := global.GVA_DB.Unscoped().Delete(&sg).Error
+	return err
+}

+ 16 - 7
server/dao/warehouse.go

@@ -4,26 +4,31 @@ import "server/global"
 
 type Warehouse struct {
 	global.GVA_MODEL
-	Name     string `json:"name" form:"name" gorm:"comment:库房名称"`
-	Location string `json:"location" form:"location" gorm:"comment:库房位置"`
-	Head     string `json:"head" form:"head" gorm:"comment:负责人"`
-	Remarks  string `json:"remarks" form:"remarks" gorm:"comment:备注"`
+	Name        string `json:"name" form:"name" gorm:"comment:库房名称"`
+	Location    string `json:"location" form:"location" gorm:"comment:库房位置"`
+	Head        string `json:"head" form:"head" gorm:"comment:负责人"`
+	Remarks     string `json:"remarks" form:"remarks" gorm:"comment:备注"`
+	IsEffective bool   `json:"isEffective" form:"isEffective" gorm:"comment:是否有效;default:0"`
 }
 
 func (Warehouse) TableName() string {
-	return "storehouse"
+	return "warehouse"
 }
 
 func QueryAllWarehouse() (warehouse []Warehouse, err error) {
-	err = global.GVA_DB.Model(&Warehouse{}).Find(&warehouse).Error
+	err = global.GVA_DB.Where("is_effective = true").Model(&Warehouse{}).Find(&warehouse).Error
 	return warehouse, err
 }
 
-func QueryWarehouseList(limit, offset int) (warehouse []Warehouse, total int64, err error) {
+func QueryWarehouseList(limit, offset int, name string) (warehouse []Warehouse, total int64, err error) {
 	// 创建db
 	db := global.GVA_DB.Model(&Warehouse{})
 	// 如果有条件搜索 下方会自动创建搜索语句
 
+	if name != "" {
+		db = db.Where("name LIKE ?", "%"+name+"%")
+	}
+
 	err = db.Count(&total).Error
 	if err != nil {
 		return
@@ -40,6 +45,10 @@ func (w Warehouse) UpdateWarehouse() error {
 	return global.GVA_DB.Where("id = ?", w.ID).Updates(&w).Error
 }
 
+func (w Warehouse) SwitchWarehouse() error {
+	return global.GVA_DB.Select("is_effective").Where("id = ?", w.ID).Updates(&w).Error
+}
+
 func (w Warehouse) DeleteWarehouse() error {
 	return global.GVA_DB.Unscoped().Delete(&w).Error
 }

+ 3 - 0
server/initialize/gorm.go

@@ -80,6 +80,9 @@ func RegisterTables() {
 		dao.CommodityGenre{},
 		dao.Supplier{},
 		dao.Warehouse{},
+		dao.Place{},
+		dao.StorageArea{},
+		dao.StorageAreaGenre{},
 	)
 	if err != nil {
 		global.GVA_LOG.Error("register table failed", zap.Error(err))

+ 3 - 0
server/initialize/router.go

@@ -107,6 +107,9 @@ func Routers() *gin.Engine {
 		storehouseRouter.InitWarehouseRouter(PrivateGroup)
 		storehouseRouter.InitCommodityRouter(PrivateGroup)
 		storehouseRouter.InitCommodityGenreRouter(PrivateGroup)
+		storehouseRouter.InitPlaceRouter(PrivateGroup)
+		storehouseRouter.InitStorageAreaRouter(PrivateGroup)
+		storehouseRouter.InitStorageAreaGenreRouter(PrivateGroup)
 	}
 
 	global.GVA_LOG.Info("router register success")

+ 20 - 0
server/model/common/request/common.go

@@ -118,4 +118,24 @@ type OperateRecord struct {
 	Description    dao.Description    `json:"description" form:"description"`
 }
 
+type SearchPlace struct {
+	PageInfo      PageInfo `json:"pageInfo" form:"pageInfo"`
+	Name          string   `json:"name" form:"name"`
+	Genre         int      `json:"genre" form:"genre"`
+	WarehouseId   int      `json:"warehouseId" form:"warehouseId"`
+	StorageAreaId int      `json:"storageAreaId" form:"storageAreaId"`
+}
+
+type SearchStorageArea struct {
+	PageInfo    PageInfo `json:"pageInfo" form:"pageInfo"`
+	Name        string   `json:"name" form:"name"`
+	Genre       int      `json:"genre" form:"genre"`
+	WarehouseId int      `json:"warehouseId" form:"warehouseId"`
+}
+
+type SearchWarehouse struct {
+	PageInfo PageInfo `json:"pageInfo" form:"pageInfo"`
+	Name     string   `json:"name" form:"name"`
+}
+
 type Empty struct{}

+ 3 - 0
server/router/storehouse/enter.go

@@ -5,4 +5,7 @@ type RouterGroup struct {
 	CommodityGenreRouter
 	SupplierRouter
 	WarehouseRouter
+	PlaceRouter
+	StorageAreaRouter
+	StorageAreaGenreRouter
 }

+ 26 - 0
server/router/storehouse/place.go

@@ -0,0 +1,26 @@
+package storehouse
+
+import (
+	"github.com/gin-gonic/gin"
+	v1 "server/api/v1"
+	"server/middleware"
+)
+
+type PlaceRouter struct{}
+
+func (s *PlaceRouter) InitPlaceRouter(Router *gin.RouterGroup) {
+	placeRouter := Router.Group("place").Use(middleware.OperationRecord())
+	placeRouterWithoutRecord := Router.Group("place")
+
+	placeApi := v1.ApiGroupApp.StorehouseApiGroup.PlaceApi
+	{
+		placeRouter.POST("createPlace", placeApi.CreatePlace)
+		placeRouter.PUT("updatePlace", placeApi.UpdatePlace)
+		placeRouter.PUT("switchPlace", placeApi.SwitchPlace)
+		placeRouter.DELETE("deletePlace", placeApi.DeletePlace)
+	}
+	{
+		placeRouterWithoutRecord.GET("queryAllPlace", placeApi.QueryAllPlace)
+		placeRouterWithoutRecord.POST("queryPlaceList", placeApi.QueryPlaceList)
+	}
+}

+ 26 - 0
server/router/storehouse/storageArea.go

@@ -0,0 +1,26 @@
+package storehouse
+
+import (
+	"github.com/gin-gonic/gin"
+	v1 "server/api/v1"
+	"server/middleware"
+)
+
+type StorageAreaRouter struct{}
+
+func (sar *StorageAreaRouter) InitStorageAreaRouter(Router *gin.RouterGroup) {
+	storageAreaRouter := Router.Group("storageArea").Use(middleware.OperationRecord())
+	storageAreaRouterWithoutRecord := Router.Group("storageArea")
+
+	storageAreaApi := v1.ApiGroupApp.StorehouseApiGroup.StorageAreaApi
+	{
+		storageAreaRouter.POST("createStorageArea", storageAreaApi.CreateStorageArea)
+		storageAreaRouter.PUT("updateStorageArea", storageAreaApi.UpdateStorageArea)
+		storageAreaRouter.POST("switchStorageArea", storageAreaApi.SwitchStorageArea)
+		storageAreaRouter.DELETE("deleteStorageArea", storageAreaApi.DeleteStorageArea)
+	}
+	{
+		storageAreaRouterWithoutRecord.GET("queryAllStorageAreas", storageAreaApi.QueryAllStorageAreas)
+		storageAreaRouterWithoutRecord.POST("queryStorageAreaList", storageAreaApi.QueryStorageAreaList)
+	}
+}

+ 24 - 0
server/router/storehouse/storageAreaGenre.go

@@ -0,0 +1,24 @@
+package storehouse
+
+import (
+	"github.com/gin-gonic/gin"
+	v1 "server/api/v1"
+	"server/middleware"
+)
+
+type StorageAreaGenreRouter struct{}
+
+func (sar *StorageAreaGenreRouter) InitStorageAreaGenreRouter(Router *gin.RouterGroup) {
+	storageAreaGenreRouter := Router.Group("storageAreaGenre").Use(middleware.OperationRecord())
+	storageAreaGenreRouterWithoutRecord := Router.Group("storageAreaGenre")
+
+	storageAreaGenreApi := v1.ApiGroupApp.StorehouseApiGroup.StorageAreaGenreApi
+	{
+		storageAreaGenreRouter.POST("createStorageAreaGenre", storageAreaGenreApi.CreateStorageAreaGenre)
+		storageAreaGenreRouter.PUT("updateStorageAreaGenre", storageAreaGenreApi.UpdateStorageAreaGenre)
+		storageAreaGenreRouter.DELETE("deleteStorageAreaGenre", storageAreaGenreApi.DeleteStorageAreaGenre)
+	}
+	{
+		storageAreaGenreRouterWithoutRecord.GET("queryAllStorageAreaGenre", storageAreaGenreApi.QueryAllStorageAreaGenre)
+	}
+}

+ 2 - 1
server/router/storehouse/warehouse.go

@@ -17,10 +17,11 @@ func (r *WarehouseRouter) InitWarehouseRouter(Router *gin.RouterGroup) {
 	{
 		warehouseRouter.POST("createWarehouse", warehouseApi.CreateWarehouse)
 		warehouseRouter.PUT("updateWarehouse", warehouseApi.UpdateWarehouse)
+		warehouseRouter.PUT("switchWarehouse", warehouseApi.SwitchWarehouse)
 		warehouseRouter.DELETE("deleteWarehouse", warehouseApi.DeleteWarehouse)
 	}
 	{
 		warehouseRouterWithoutRecord.GET("queryAllWarehouse", warehouseApi.QueryAllWarehouse)
-		warehouseRouterWithoutRecord.GET("queryWarehouseList", warehouseApi.QueryWarehouseList)
+		warehouseRouterWithoutRecord.POST("queryWarehouseList", warehouseApi.QueryWarehouseList)
 	}
 }

+ 3 - 0
server/service/storehouse/enter.go

@@ -5,4 +5,7 @@ type ServiceGroup struct {
 	SupplierService
 	CommodityGenreService
 	WarehouseService
+	PlaceService
+	StorageAreaService
+	StorageAreaGenreService
 }

+ 34 - 0
server/service/storehouse/place.go

@@ -0,0 +1,34 @@
+package storehouse
+
+import (
+	"server/dao"
+	"server/model/common/request"
+)
+
+type PlaceService struct{}
+
+func (p *PlaceService) QueryAllPlaces() ([]dao.Place, error) {
+	return dao.QueryAllPlace()
+}
+
+func (p *PlaceService) QueryPlaceList(info request.SearchPlace) (list interface{}, total int64, err error) {
+	limit := info.PageInfo.PageSize
+	offset := info.PageInfo.PageSize * (info.PageInfo.Page - 1)
+	return dao.QueryPlaceList(limit, offset, info.Genre, info.WarehouseId, info.StorageAreaId, info.Name)
+}
+
+func (p *PlaceService) CreatePlace(place dao.Place) error {
+	return place.CreatePlace()
+}
+
+func (p *PlaceService) UpdatePlace(place dao.Place) error {
+	return place.UpdatePlace()
+}
+
+func (p *PlaceService) SwitchPlace(place dao.Place) error {
+	return place.SwitchPlace()
+}
+
+func (p *PlaceService) DeletePlace(place dao.Place) error {
+	return place.DeletePlace()
+}

+ 34 - 0
server/service/storehouse/storageArea.go

@@ -0,0 +1,34 @@
+package storehouse
+
+import (
+	"server/dao"
+	"server/model/common/request"
+)
+
+type StorageAreaService struct{}
+
+func (s *StorageAreaService) QueryAllStorageArea() ([]dao.StorageArea, error) {
+	return dao.QueryAllStorageArea()
+}
+
+func (s *StorageAreaService) QueryStorageAreaList(info request.SearchStorageArea) (list interface{}, total int64, err error) {
+	limit := info.PageInfo.PageSize
+	offset := info.PageInfo.PageSize * (info.PageInfo.Page - 1)
+	return dao.QueryStorageAreaList(limit, offset, info.Genre, info.WarehouseId, info.Name)
+}
+
+func (s *StorageAreaService) CreateStorageArea(storageArea dao.StorageArea) error {
+	return storageArea.CreateStorageArea()
+}
+
+func (s *StorageAreaService) UpdateStorageArea(storageArea dao.StorageArea) error {
+	return storageArea.UpdateStorageArea()
+}
+
+func (s *StorageAreaService) SwitchStorageArea(storageArea dao.StorageArea) error {
+	return storageArea.SwitchStorageArea()
+}
+
+func (s *StorageAreaService) DeleteStorageArea(storageArea dao.StorageArea) error {
+	return storageArea.DeleteStorageArea()
+}

+ 21 - 0
server/service/storehouse/storageAreaGenre.go

@@ -0,0 +1,21 @@
+package storehouse
+
+import "server/dao"
+
+type StorageAreaGenreService struct{}
+
+func (sags *StorageAreaGenreService) QueryAllStorageAreaGenres() ([]dao.StorageAreaGenre, error) {
+	return dao.QueryAllStorageAreaGenres()
+}
+
+func (sags *StorageAreaGenreService) CreateStorageAreaGenre(sg dao.StorageAreaGenre) error {
+	return sg.CreateStorageAreaGenre()
+}
+
+func (sags *StorageAreaGenreService) UpdateStorageAreaGenre(sg dao.StorageAreaGenre) error {
+	return sg.UpdateStorageAreaGenre()
+}
+
+func (sags *StorageAreaGenreService) DeleteStorageAreaGenre(sg dao.StorageAreaGenre) error {
+	return sg.DeleteStorageAreaGenre()
+}

+ 8 - 4
server/service/storehouse/warehouse.go

@@ -11,10 +11,10 @@ func (ws *WarehouseService) QueryAllWarehouse() ([]dao.Warehouse, error) {
 	return dao.QueryAllWarehouse()
 }
 
-func (ws *WarehouseService) QueryWarehouseList(info request.PageInfo) (list interface{}, total int64, err error) {
-	limit := info.PageSize
-	offset := info.PageSize * (info.Page - 1)
-	warehouse, total, err := dao.QueryWarehouseList(limit, offset)
+func (ws *WarehouseService) QueryWarehouseList(info request.SearchWarehouse) (list interface{}, total int64, err error) {
+	limit := info.PageInfo.PageSize
+	offset := info.PageInfo.PageSize * (info.PageInfo.Page - 1)
+	warehouse, total, err := dao.QueryWarehouseList(limit, offset, info.Name)
 	return warehouse, total, err
 }
 
@@ -26,6 +26,10 @@ func (ws *WarehouseService) UpdateWarehouse(warehouse dao.Warehouse) error {
 	return warehouse.UpdateWarehouse()
 }
 
+func (ws *WarehouseService) SwitchWarehouse(warehouse dao.Warehouse) error {
+	return warehouse.SwitchWarehouse()
+}
+
 func (ws *WarehouseService) DeleteWarehouse(warehouse dao.Warehouse) error {
 	return warehouse.DeleteWarehouse()
 }

+ 171 - 0
web/src/api/storehouse.js

@@ -101,3 +101,174 @@ export const deleteCommodity = (data) => {
     data: data
   })
 }
+
+export const queryAllWarehouse = () => {
+  return service({
+    url: '/warehouse/queryAllWarehouse',
+    method: 'get'
+  })
+}
+
+export const queryWarehouseList = (data) => {
+  return service({
+    url: '/warehouse/queryWarehouseList',
+    method: 'post',
+    data: data
+  })
+}
+export const createWarehouse = (data) => {
+  return service({
+    url: '/warehouse/createWarehouse',
+    method: 'post',
+    data: data
+  })
+}
+
+export const updateWarehouse = (data) => {
+  return service({
+    url: '/warehouse/updateWarehouse',
+    method: 'put',
+    data: data
+  })
+}
+
+export const switchWarehouse = (data) => {
+  return service({
+    url: '/warehouse/switchWarehouse',
+    method: 'put',
+    data: data
+  })
+}
+
+export const deleteWarehouse = (data) => {
+  return service({
+    url: '/warehouse/deleteWarehouse',
+    method: 'delete',
+    data: data
+  })
+}
+
+export const queryAllStorageArea = () => {
+  return service({
+    url: '/storageArea/queryAllStorageArea',
+    method: 'get'
+  })
+}
+
+export const queryStorageAreaList = (data) => {
+  return service({
+    url: '/storageArea/queryStorageAreaList',
+    method: 'post',
+    data: data
+  })
+}
+
+export const createStorageArea = (data) => {
+  return service({
+    url: '/storageArea/createStorageArea',
+    method: 'post',
+    data: data
+  })
+}
+
+export const updateStorageArea = (data) => {
+  return service({
+    url: '/storageArea/updateStorageArea',
+    method: 'put',
+    data: data
+  })
+}
+
+export const switchStorageArea = (data) => {
+  return service({
+    url: '/storageArea/switchStorageArea',
+    method: 'put',
+    data: data
+  })
+}
+
+export const deleteStorageArea = (data) => {
+  return service({
+    url: '/storageArea/deleteStorageArea',
+    method: 'delete',
+    data: data
+  })
+}
+
+export const queryAllStorageAreaGenre = () => {
+  return service({
+    url: '/storageAreaGenre/queryAllStorageAreaGenre',
+    method: 'get'
+  })
+}
+
+export const createStorageAreaGenre = (data) => {
+  return service({
+    url: '/storageAreaGenre/createStorageAreaGenre',
+    method: 'post',
+    data: data
+  })
+}
+
+export const updateStorageAreaGenre = (data) => {
+  return service({
+    url: '/storageAreaGenre/updateStorageAreaGenre',
+    method: 'put',
+    data: data
+  })
+}
+
+export const deleteStorageAreaGenre = (data) => {
+  return service({
+    url: '/storageAreaGenre/deleteStorageAreaGenre',
+    method: 'delete',
+    data: data
+  })
+}
+
+export const queryAllPlace = () => {
+  return service({
+    url: '/place/queryAllPlace',
+    method: 'get'
+  })
+}
+
+export const queryPlaceList = (data) => {
+  return service({
+    url: '/place/queryPlaceList',
+    method: 'post',
+    data: data
+  })
+}
+
+export const createPlace = (data) => {
+  return service({
+    url: '/place/createPlace',
+    method: 'post',
+    data: data
+  })
+}
+
+export const updatePlace = (data) => {
+  return service({
+    url: '/place/updatePlace',
+    method: 'put',
+    data: data
+  })
+}
+
+export const switchPlace = (data) => {
+  return service({
+    url: '/place/switchPlace',
+    method: 'put',
+    data: data
+  })
+}
+
+export const deletePlace = (data) => {
+  return service({
+    url: '/place/deletePlace',
+    method: 'delete',
+    data: data
+  })
+}

+ 19 - 2
web/src/view/storehouse/commodity/commodity.vue

@@ -193,7 +193,7 @@
             </el-form-item>
             <el-form-item label="单价">
               <el-input
-                v-model="commodityAddData.unitPrice"
+                v-model.number="commodityAddData.unitPrice"
                 type="number"
               />
             </el-form-item>
@@ -303,6 +303,7 @@
 <script setup>
 import { ref, onMounted, computed } from 'vue'
 import {
+  createCommodity,
   createCommodityGenre, deleteCommodity,
   deleteCommodityGenre,
   queryAllCommodityGenre, queryAllSupplier, queryCommodityList, updateCommodity,
@@ -451,6 +452,7 @@ const commoditySubmit = async() => {
     } else {
       ElMessage.error('编辑失败')
     }
+    isOpenCommodityEdit.value = false
   })
 }
 
@@ -492,7 +494,22 @@ const commodityAddData = ref({
 })
 const isOpenCommodityAdd = ref(false)
 
-const commodityAddSubmit = async() => {}
+const commodityAddSubmit = async() => {
+  if (!commodityAddData.value.name || !commodityAddData.value.genre || !commodityAddData.value.supplierId || commodityAddData.value.unitPrice === 0) {
+    ElMessage.error('数据不能为空')
+    return
+  }
+  console.log(commodityAddData.value)
+  await createCommodity(commodityAddData.value).then(res => {
+    if (res.code === 0) {
+      ElMessage.success('新增成功')
+    } else {
+      ElMessage.error('新增失败')
+    }
+    isOpenCommodityAdd.value = false
+    getData()
+  })
+}
 
 onMounted(() => {
   getData()

+ 2 - 2
web/src/view/storehouse/index.vue

@@ -2,8 +2,8 @@
   <div>
     <router-view v-slot="{ Component }">
       <transition
-          mode="out-in"
-          name="el-fade-in-linear"
+        mode="out-in"
+        name="el-fade-in-linear"
       >
         <keep-alive :include="routerStore.keepAliveRouters">
           <component :is="Component" />

+ 35 - 0
web/src/view/storehouse/warehouse/index.vue

@@ -0,0 +1,35 @@
+<template>
+  <el-tabs
+    v-model="activeName"
+    class="gva-search-box"
+  >
+    <el-tab-pane
+      label="仓库设置"
+      name="first"
+    >
+      <warehouse />
+    </el-tab-pane>
+    <el-tab-pane
+      label="库区设置"
+      name="second"
+    >
+      <StorageArea />
+    </el-tab-pane>
+    <el-tab-pane
+      label="库位设置"
+      name="third"
+    >
+      <Place />
+    </el-tab-pane>
+  </el-tabs>
+</template>
+
+<script setup>
+import { ref } from 'vue'
+import Place from '@/view/storehouse/warehouse/place/place.vue'
+import StorageArea from '@/view/storehouse/warehouse/storageArea/storageArea.vue'
+import Warehouse from '@/view/storehouse/warehouse/warehouse.vue'
+
+const activeName = ref('first')
+
+</script>

+ 6 - 0
web/src/view/storehouse/warehouse/place/place.vue

@@ -0,0 +1,6 @@
+<template>
+  <div>库位</div>
+</template>
+<script setup>
+
+</script>

+ 360 - 0
web/src/view/storehouse/warehouse/storageArea/storageArea.vue

@@ -0,0 +1,360 @@
+<template>
+  <el-container>
+    <el-header
+      class="gva-search-box"
+      style="line-height: 60px"
+    >
+      <el-row>
+        <el-col :span="16">
+          <el-form
+            inline
+            style="margin-top: 10px"
+          >
+            <el-form-item label="名称">
+              <el-input
+                v-model="searchStorageArea.name"
+                placeholder="请输入名称"
+              />
+            </el-form-item>
+            <el-form-item label="库区类型">
+              <el-select
+                v-model="searchStorageArea.genre"
+                placeholder="请选择"
+                style="width: 180px"
+              >
+                <el-option
+                  v-for="item in storageAreaGenreAllData"
+                  :key="item.ID"
+                  :label="item.name"
+                  :value="item.ID"
+                />
+              </el-select>
+            </el-form-item>
+            <el-form-item label="仓库">
+              <el-select
+                v-model="searchStorageArea.warehouseId"
+                placeholder="请选择"
+                style="width: 180px"
+              >
+                <el-option
+                  v-for="item in warehouseAllData"
+                  :key="item.ID"
+                  :label="item.name"
+                  :value="item.ID"
+                />
+              </el-select>
+            </el-form-item>
+            <el-form-item>
+              <el-button @click="getData">搜索</el-button>
+            </el-form-item>
+          </el-form>
+        </el-col>
+        <el-col :span="8">
+          <el-button
+            type="primary"
+            @click="isOpenStorageAreaAdd = true"
+          >新增仓区</el-button>
+        </el-col>
+      </el-row>
+    </el-header>
+    <el-main>
+      <el-table
+        :data="StorageAreaListData"
+        style="min-height: 550px;"
+      >
+        <el-table-column
+          prop="name"
+          label="库区名称"
+        />
+        <el-table-column
+          prop="storageAreaGenre.name"
+          label="库区类型"
+        />
+        <el-table-column
+          prop="warehouse.name"
+          label="所属仓库"
+        />
+        <el-table-column
+          label="是否启用"
+        >
+          <template #default="scope">
+            <el-switch
+              v-model="scope.row.isEffective"
+              style="--el-switch-on-color: #13ce66; --el-switch-off-color: #ff4949"
+              @change="changeIsEffective(scope.row)"
+            />
+          </template>
+        </el-table-column>
+        <el-table-column label="操作">
+          <template #default="scope">
+            <el-button
+              type="primary"
+              @click="openStorageAreaEdit(scope.row)"
+            >编辑</el-button>
+            <el-button
+              type="danger"
+              @click="StorageAreaDelete(scope.row)"
+            >删除</el-button>
+          </template>
+        </el-table-column>
+      </el-table>
+      <!--      分页-->
+      <div class="gva-pagination">
+        <el-pagination
+          :current-page="searchStorageArea.pageInfo.page"
+          :page-size="searchStorageArea.pageInfo.pageSize"
+          :page-sizes="[10, 30, 50, 100]"
+          :total="total"
+          layout="total, sizes, prev, pager, next, jumper"
+          @current-change="handleCurrentChange"
+          @size-change="handleSizeChange"
+        />
+      </div>
+      <!--      修改-->
+      <el-drawer
+        v-model="isOpenStorageAreaEdit"
+        title="修改仓库信息"
+        direction="rtl"
+        size="30%"
+      >
+        <div>
+          <el-form
+            v-model="StorageAreaEditData"
+            label-position="left"
+            label-width="auto"
+            style="max-width: 400px"
+          >
+            <el-form-item label="库区名称">
+              <el-input v-model="StorageAreaEditData.name" />
+            </el-form-item>
+            <el-form-item label="库区类型">
+              <el-select
+                v-model="StorageAreaEditData.genre"
+                placeholder="请选择"
+                style="width: 240px"
+              >
+                <el-option
+                  v-for="item in storageAreaGenreAllData"
+                  :key="item.ID"
+                  :label="item.name"
+                  :value="item.ID"
+                />
+              </el-select>
+            </el-form-item>
+            <el-form-item label="仓库">
+              <el-select
+                v-model="StorageAreaEditData.warehouseId"
+                placeholder="请选择"
+                style="width: 240px"
+              >
+                <el-option
+                  v-for="item in warehouseAllData"
+                  :key="item.ID"
+                  :label="item.name"
+                  :value="item.ID"
+                />
+              </el-select>
+            </el-form-item>
+            <el-form-item>
+              <el-button
+                type="primary"
+                @click="StorageAreaEditSubmit"
+              >提交</el-button>
+              <el-button @click="isOpenStorageAreaEdit = false">关闭</el-button>
+            </el-form-item>
+          </el-form>
+        </div>
+      </el-drawer>
+      <el-drawer
+        v-model="isOpenStorageAreaAdd"
+        title="新增仓库信息"
+        direction="rtl"
+        size="30%"
+      >
+        <div>
+          <el-form
+            v-model="StorageAreaAddData"
+            label-position="left"
+            label-width="auto"
+            style="max-width: 400px"
+          >
+            <el-form-item label="库区名称">
+              <el-input v-model="StorageAreaAddData.name" />
+            </el-form-item>
+            <el-form-item label="库区类型">
+              <el-select
+                v-model="StorageAreaAddData.genre"
+                placeholder="请选择"
+                style="width: 240px"
+              >
+                <el-option
+                  v-for="item in storageAreaGenreAllData"
+                  :key="item.ID"
+                  :label="item.name"
+                  :value="item.ID"
+                />
+              </el-select>
+            </el-form-item>
+            <el-form-item label="仓库">
+              <el-select
+                v-model="StorageAreaAddData.warehouseId"
+                placeholder="请选择"
+                style="width: 240px"
+              >
+                <el-option
+                  v-for="item in warehouseAllData"
+                  :key="item.ID"
+                  :label="item.name"
+                  :value="item.ID"
+                />
+              </el-select>
+            </el-form-item>
+            <el-form-item>
+              <el-button
+                type="primary"
+                @click="StorageAreaAddSubmit"
+              >提交</el-button>
+              <el-button @click="isOpenStorageAreaAdd = false">关闭</el-button>
+            </el-form-item>
+          </el-form>
+        </div>
+      </el-drawer>
+    </el-main>
+  </el-container>
+</template>
+<script setup>
+import { ref, onMounted } from 'vue'
+import {
+  createStorageArea,
+  deleteStorageArea, queryAllStorageAreaGenre, queryAllWarehouse,
+  queryStorageAreaList,
+  switchStorageArea,
+  updateStorageArea
+} from '@/api/storehouse'
+import { ElMessage, ElMessageBox } from 'element-plus'
+
+const searchStorageArea = ref({
+  pageInfo: {
+    page: 1,
+    pageSize: 10,
+  },
+  name: '',
+  genre: '',
+  warehouseId: '',
+})
+
+const StorageAreaListData = ref([])
+const total = ref(0)
+const warehouseAllData = ref()
+const storageAreaGenreAllData = ref()
+
+const getData = async() => {
+  // 假设有接口来获取数据
+  await queryStorageAreaList(searchStorageArea.value).then(res => {
+    StorageAreaListData.value = res.data.list
+    total.value = res.data.total
+  })
+  await queryAllWarehouse().then(res => {
+    warehouseAllData.value = res.data
+  })
+  await queryAllStorageAreaGenre().then(res => {
+    storageAreaGenreAllData.value = res.data
+  })
+}
+
+// 分页
+const handleSizeChange = (val) => {
+  searchStorageArea.value.pageSize = val
+  getData()
+}
+
+const handleCurrentChange = (val) => {
+  searchStorageArea.value.page = val
+  getData()
+}
+
+const changeIsEffective = async(row) => {
+  await switchStorageArea(row).then(res => {
+    console.log(res)
+  })
+}
+
+const isOpenStorageAreaEdit = ref(false)
+const StorageAreaEditData = ref()
+const openStorageAreaEdit = (val) => {
+  isOpenStorageAreaEdit.value = true
+  StorageAreaEditData.value = val
+}
+
+const StorageAreaEditSubmit = async() => {
+  if (StorageAreaEditData.value.name === '') {
+    ElMessage.error('库房名称不能为空')
+    return
+  }
+  await updateStorageArea(StorageAreaEditData.value).then(res => {
+    if (res.code === 0) {
+      ElMessage.success(res.msg)
+    } else {
+      ElMessage.error('编辑失败')
+    }
+    isOpenStorageAreaEdit.value = false
+    getData()
+  })
+}
+
+const StorageAreaDelete = (val) => {
+  ElMessageBox.confirm(
+    '将永久删除该信息。是否继续?',
+    '删除',
+    {
+      confirmButtonText: '确定',
+      cancelButtonText: '取消',
+      type: 'warning',
+    }
+  )
+    .then(async() => {
+      await deleteStorageArea(val).then(res => {
+        if (res.code === 0) {
+          ElMessage.success('删除成功')
+          getData()
+        } else {
+          ElMessage.error('删除失败')
+        }
+      })
+    })
+    .catch(() => {
+      ElMessage({
+        type: 'info',
+        message: '删除已取消',
+      })
+    })
+}
+
+const StorageAreaAddData = ref({
+  name: '',
+  location: '',
+  head: '',
+  remarks: '',
+})
+
+const isOpenStorageAreaAdd = ref(false)
+const StorageAreaAddSubmit = async() => {
+  if (StorageAreaAddData.value.name === '') {
+    ElMessage.error('库房名称不能为空')
+    return
+  }
+  await createStorageArea(StorageAreaAddData.value).then(res => {
+    if (res.code === 0) {
+      ElMessage.success(res.msg)
+    } else {
+      ElMessage.error(res.msg)
+    }
+    isOpenStorageAreaAdd.value = false
+    getData()
+  })
+}
+
+onMounted(() => {
+  getData()
+})
+</script>

+ 292 - 5
web/src/view/storehouse/warehouse/warehouse.vue

@@ -1,11 +1,298 @@
+<template>
+  <el-container>
+    <el-header
+      class="gva-search-box"
+      style="line-height: 60px"
+    >
+      <el-row>
+        <el-col :span="8">
+          <el-form
+            inline
+            style="margin-top: 10px"
+          >
+            <el-form-item label="名称">
+              <el-input
+                v-model="searchWarehouse.name"
+                placeholder="请输入名称"
+              />
+            </el-form-item>
+            <el-form-item>
+              <el-button @click="getData">搜索</el-button>
+            </el-form-item>
+          </el-form>
+
+        </el-col>
+        <el-col :span="8" />
+        <el-col :span="8">
+          <el-button
+            type="primary"
+            @click="isOpenWarehouseAdd = true"
+          >新增仓库</el-button>
+        </el-col>
+      </el-row>
+    </el-header>
+    <el-main>
+      <el-table
+        :data="warehouseListData"
+        style="min-height: 550px;"
+      >
+        <el-table-column
+          prop="name"
+          label="库房名称"
+        />
+        <el-table-column
+          prop="location"
+          label="库房位置"
+        />
+        <el-table-column
+          prop="head"
+          label="负责人"
+        />
+        <el-table-column
+          prop="remarks"
+          label="备注"
+        />
+        <el-table-column
+          label="是否启用"
+        >
+          <template #default="scope">
+            <el-switch
+              v-model="scope.row.isEffective"
+              style="--el-switch-on-color: #13ce66; --el-switch-off-color: #ff4949"
+              @change="changeIsEffective(scope.row)"
+            />
+          </template>
+        </el-table-column>
+        <el-table-column label="操作">
+          <template #default="scope">
+            <el-button
+              type="primary"
+              @click="openWarehouseEdit(scope.row)"
+            >编辑</el-button>
+            <el-button
+              type="danger"
+              @click="warehouseDelete(scope.row)"
+            >删除</el-button>
+          </template>
+        </el-table-column>
+      </el-table>
+      <!--      分页-->
+      <div class="gva-pagination">
+        <el-pagination
+          :current-page="searchWarehouse.pageInfo.page"
+          :page-size="searchWarehouse.pageInfo.pageSize"
+          :page-sizes="[10, 30, 50, 100]"
+          :total="total"
+          layout="total, sizes, prev, pager, next, jumper"
+          @current-change="handleCurrentChange"
+          @size-change="handleSizeChange"
+        />
+      </div>
+      <!--      修改-->
+      <el-drawer
+        v-model="isOpenWarehouseEdit"
+        title="修改仓库信息"
+        direction="rtl"
+        size="30%"
+      >
+        <div>
+          <el-form
+            v-model="warehouseEditData"
+            label-position="left"
+            label-width="auto"
+            style="max-width: 400px"
+          >
+            <el-form-item label="库房名称">
+              <el-input v-model="warehouseEditData.name" />
+            </el-form-item>
+            <el-form-item label="库房位置">
+              <el-input
+                v-model="warehouseEditData.location"
+              />
+            </el-form-item>
+            <el-form-item label="负责人">
+              <el-input
+                v-model="warehouseEditData.head"
+              />
+            </el-form-item>
+            <el-form-item label="备注">
+              <el-input v-model="warehouseEditData.remarks" />
+            </el-form-item>
+            <el-form-item>
+              <el-button
+                type="primary"
+                @click="warehouseEditSubmit"
+              >提交</el-button>
+              <el-button @click="isOpenWarehouseEdit = false">关闭</el-button>
+            </el-form-item>
+          </el-form>
+        </div>
+      </el-drawer>
+      <el-drawer
+        v-model="isOpenWarehouseAdd"
+        title="新增仓库信息"
+        direction="rtl"
+        size="30%"
+      >
+        <div>
+          <el-form
+            v-model="warehouseAddData"
+            label-position="left"
+            label-width="auto"
+            style="max-width: 400px"
+          >
+            <el-form-item label="库房名称">
+              <el-input v-model="warehouseAddData.name" />
+            </el-form-item>
+            <el-form-item label="库房位置">
+              <el-input
+                v-model="warehouseAddData.location"
+              />
+            </el-form-item>
+            <el-form-item label="负责人">
+              <el-input
+                v-model="warehouseAddData.head"
+              />
+            </el-form-item>
+            <el-form-item label="备注">
+              <el-input v-model="warehouseAddData.remarks" />
+            </el-form-item>
+            <el-form-item>
+              <el-button
+                type="primary"
+                @click="warehouseAddSubmit"
+              >提交</el-button>
+              <el-button @click="isOpenWarehouseAdd = false">关闭</el-button>
+            </el-form-item>
+          </el-form>
+        </div>
+      </el-drawer>
+    </el-main>
+  </el-container>
+</template>
 <script setup>
+import { ref, onMounted } from 'vue'
+import {
+  createWarehouse,
+  deleteWarehouse,
+  queryWarehouseList,
+  switchWarehouse,
+  updateWarehouse
+} from '@/api/storehouse'
+import { ElMessage, ElMessageBox } from 'element-plus'
 
-</script>
+const searchWarehouse = ref({
+  pageInfo: {
+    page: 1,
+    pageSize: 10,
+  },
+  name: '',
+})
 
-<template>
+const warehouseListData = ref([])
+const total = ref(0)
 
-</template>
+const getData = async() => {
+  // 假设有接口来获取数据
+  await queryWarehouseList(searchWarehouse.value).then(res => {
+    warehouseListData.value = res.data.list
+    total.value = res.data.total
+  })
+}
+
+// 分页
+const handleSizeChange = (val) => {
+  searchWarehouse.value.pageSize = val
+  getData()
+}
 
-<style scoped lang="scss">
+const handleCurrentChange = (val) => {
+  searchWarehouse.value.page = val
+  getData()
+}
 
-</style>
+const changeIsEffective = async(row) => {
+  await switchWarehouse(row).then(res => {
+    console.log(res)
+  })
+}
+
+const isOpenWarehouseEdit = ref(false)
+const warehouseEditData = ref()
+const openWarehouseEdit = (val) => {
+  isOpenWarehouseEdit.value = true
+  warehouseEditData.value = val
+}
+
+const warehouseEditSubmit = async() => {
+  if (warehouseEditData.value.name === '') {
+    ElMessage.error('库房名称不能为空')
+    return
+  }
+  await updateWarehouse(warehouseEditData.value).then(res => {
+    if (res.code === 0) {
+      ElMessage.success(res.msg)
+    } else {
+      ElMessage.error('编辑失败')
+    }
+    isOpenWarehouseEdit.value = false
+    getData()
+  })
+}
+
+const warehouseDelete = (val) => {
+  ElMessageBox.confirm(
+    '将永久删除该信息。是否继续?',
+    '删除',
+    {
+      confirmButtonText: '确定',
+      cancelButtonText: '取消',
+      type: 'warning',
+    }
+  )
+    .then(async() => {
+      await deleteWarehouse(val).then(res => {
+        if (res.code === 0) {
+          ElMessage.success('删除成功')
+          getData()
+        } else {
+          ElMessage.error('删除失败')
+        }
+      })
+    })
+    .catch(() => {
+      ElMessage({
+        type: 'info',
+        message: '删除已取消',
+      })
+    })
+}
+
+const warehouseAddData = ref({
+  name: '',
+  location: '',
+  head: '',
+  remarks: '',
+})
+
+const isOpenWarehouseAdd = ref(false)
+const warehouseAddSubmit = async() => {
+  if (warehouseAddData.value.name === '') {
+    ElMessage.error('库房名称不能为空')
+    return
+  }
+  await createWarehouse(warehouseAddData.value).then(res => {
+    if (res.code === 0) {
+      ElMessage.success(res.msg)
+    } else {
+      ElMessage.error(res.msg)
+    }
+    isOpenWarehouseAdd.value = false
+    getData()
+  })
+}
+
+onMounted(() => {
+  getData()
+})
+</script>