Ver código fonte

11月8日库存管理

XMLWAN 2 anos atrás
pai
commit
5b660a766d

+ 38 - 13
controllers/supply_order_api_contorller.go Ver arquivo

@@ -1386,21 +1386,42 @@ func (this *SupplyOrderApiController) GetAllGoodOderList() {
1386 1386
 func (this *SupplyOrderApiController) GetGoodOrderDetail() {
1387 1387
 
1388 1388
 	id, _ := this.GetInt64("id")
1389
+	ids := this.GetString("ids")
1389 1390
 	orgId := this.GetAdminUserInfo().CurrentOrgId
1390
-	out, err := service.GetGoodOrderDetail(id, orgId)
1391
-	list, _ := service.GetSupplyWarehouseOutById(id, orgId)
1392
-	drugList, _ := service.GetSupplyDrugList(orgId)
1393
-	goodList, _ := service.GetSupplyGoodList(orgId)
1394
-	if err == nil {
1395
-		this.ServeSuccessJSON(map[string]interface{}{
1396
-			"out":      out,
1397
-			"list":     list,
1398
-			"goodList": goodList,
1399
-			"drugList": drugList,
1400
-		})
1401
-	} else {
1402
-		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
1391
+	if len(ids) == 0 {
1392
+		out, err := service.GetGoodOrderDetail(id, orgId)
1393
+		list, _ := service.GetSupplyWarehouseOutById(id, orgId)
1394
+		drugList, _ := service.GetSupplyDrugList(orgId)
1395
+		goodList, _ := service.GetSupplyGoodList(orgId)
1396
+		if err == nil {
1397
+			this.ServeSuccessJSON(map[string]interface{}{
1398
+				"out":      out,
1399
+				"list":     list,
1400
+				"goodList": goodList,
1401
+				"drugList": drugList,
1402
+			})
1403
+		} else {
1404
+			this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
1405
+		}
1406
+	}
1407
+	if len(ids) > 0 {
1408
+		idArray := strings.Split(ids, ",")
1409
+		out, err := service.GetGoodOrderDetail(id, orgId)
1410
+		list, _ := service.GetSupplyWarehouseOutByIdOne(id, orgId, idArray)
1411
+		drugList, _ := service.GetSupplyDrugList(orgId)
1412
+		goodList, _ := service.GetSupplyGoodList(orgId)
1413
+		if err == nil {
1414
+			this.ServeSuccessJSON(map[string]interface{}{
1415
+				"out":      out,
1416
+				"list":     list,
1417
+				"goodList": goodList,
1418
+				"drugList": drugList,
1419
+			})
1420
+		} else {
1421
+			this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
1422
+		}
1403 1423
 	}
1424
+
1404 1425
 }
1405 1426
 
1406 1427
 func (this *SupplyOrderApiController) UpdateGoodOrder() {
@@ -2646,6 +2667,8 @@ func (this *SupplyOrderApiController) ModefyGoodOrder() {
2646 2667
 	//获取购货单的数据
2647 2668
 	goodOrder, _ := service.GetAllGoodOrderById(id, orgId)
2648 2669
 	drugList, _ := service.GetSupplyDrugList(orgId)
2670
+	//获取已有关联的退货单
2671
+	cancelList, _ := service.GetSupplyCancelWarehouse(id, orgId)
2649 2672
 	//查询是否存在退货单
2650 2673
 	_, errcode := service.GetSupplyCancelOrderById(id, orgId)
2651 2674
 	//无退库单
@@ -2680,6 +2703,7 @@ func (this *SupplyOrderApiController) ModefyGoodOrder() {
2680 2703
 		service.UpdateGoodSupplyFlow(id, orgId)
2681 2704
 		if err == nil {
2682 2705
 			this.ServeSuccessJSON(map[string]interface{}{
2706
+				"cancelList":   cancelList,
2683 2707
 				"purcaseOrder": purcaseOrder,
2684 2708
 				"goodOrder":    goodOrder,
2685 2709
 				"drugList":     drugList,
@@ -2691,6 +2715,7 @@ func (this *SupplyOrderApiController) ModefyGoodOrder() {
2691 2715
 		}
2692 2716
 	} else if errcode == nil {
2693 2717
 		this.ServeSuccessJSON(map[string]interface{}{
2718
+			"cancelList":   cancelList,
2694 2719
 			"purcaseOrder": purcaseOrder,
2695 2720
 			"goodOrder":    goodOrder,
2696 2721
 			"drugList":     drugList,

+ 9 - 7
models/supply.models.go Ver arquivo

@@ -391,10 +391,11 @@ func (VmSpSupplierWarehouseCancel) TableName() string {
391 391
 }
392 392
 
393 393
 type VmSpSupplierWarehousingOutOrder struct {
394
-	ProjectId      int64 `gorm:"column:project_id" json:"project_id" form:"project_id"`
395
-	IsSource       int64 `gorm:"column:is_source" json:"is_source" form:"is_source"`
396
-	Count          int64 `gorm:"column:count" json:"count" form:"count"`
397
-	WarehouseOutId int64 `gorm:"column:warehouse_out_id" json:"warehouse_out_id" form:"warehouse_out_id"`
394
+	ProjectId      int64  `gorm:"column:project_id" json:"project_id" form:"project_id"`
395
+	IsSource       int64  `gorm:"column:is_source" json:"is_source" form:"is_source"`
396
+	Count          int64  `gorm:"column:count" json:"count" form:"count"`
397
+	WarehouseOutId int64  `gorm:"column:warehouse_out_id" json:"warehouse_out_id" form:"warehouse_out_id"`
398
+	SupplyUnit     string `gorm:"column:supply_unit" json:"supply_unit" form:"supply_unit"`
398 399
 }
399 400
 
400 401
 func (VmSpSupplierWarehousingOutOrder) TableName() string {
@@ -402,9 +403,10 @@ func (VmSpSupplierWarehousingOutOrder) TableName() string {
402 403
 }
403 404
 
404 405
 type VmSpSupplierWarehousingCancelOrder struct {
405
-	ProjectId int64 `gorm:"column:project_id" json:"project_id" form:"project_id"`
406
-	IsSource  int64 `gorm:"column:is_source" json:"is_source" form:"is_source"`
407
-	Count     int64 `gorm:"column:count" json:"count" form:"count"`
406
+	ProjectId  int64  `gorm:"column:project_id" json:"project_id" form:"project_id"`
407
+	IsSource   int64  `gorm:"column:is_source" json:"is_source" form:"is_source"`
408
+	Count      int64  `gorm:"column:count" json:"count" form:"count"`
409
+	SupplyUnit string `gorm:"column:supply_unit" json:"supply_unit" form:"supply_unit"`
408 410
 }
409 411
 
410 412
 func (VmSpSupplierWarehousingCancelOrder) TableName() string {

+ 6 - 0
service/supply_service.go Ver arquivo

@@ -427,6 +427,12 @@ func GetSupplyWarehouseOutById(id int64, user_org_id int64) (order []*models.SpS
427 427
 	return order, err
428 428
 }
429 429
 
430
+func GetSupplyWarehouseOutByIdOne(id int64, user_org_id int64, ids []string) (order []*models.SpSupplierWarehousingOutOrder, err error) {
431
+
432
+	err = XTReadDB().Where("warehouse_out_id = ? and status = 1 and user_org_id = ? and project_id in(?)", id, user_org_id, ids).Find(&order).Error
433
+	return order, err
434
+}
435
+
430 436
 func GetAllGoodOderList(check_id int64, keyword string, page int64, limit int64, startime int64, endtime int64, orgid int64) (out []*models.VmSupplierWarehouseOut, total int64, err error) {
431 437
 	db := XTReadDB().Model(&out).Where("sgj_xt.xt_supplier_warehouse_out.status = 1")
432 438
 	likeKey := "%" + keyword + "%"