Ver código fonte

feature(项目管理): 项目修改

ZZH-wl 3 anos atrás
pai
commit
2333515749

+ 2 - 2
opms_admin/app/service/sys_user.go

@@ -111,7 +111,7 @@ func (s *userService) GetUserList(req *model.SysUserSearchReq) (total int, userL
 		err = gerror.New("获取总行数失败")
 		return
 	}
-	err = userModel.Fields("sys_user.*").Page(req.PageNum, req.PageSize).Order("id asc").Scan(&userList)
+	err = userModel.Fields("sys_user.*").Group("sys_user.id").Page(req.PageNum, req.PageSize).Order("id asc").Scan(&userList)
 	return
 }
 
@@ -316,7 +316,7 @@ func (s *userService) CreateUser(req *model.AddUserReq) (err error) {
 	}
 	userData.UserSalt = grand.S(10)
 	userData.Password = utils.EncryptPassword(userData.Password, userData.UserSalt)
-	g.Log("xxxxpassword",userData.Password)
+	g.Log("xxxxpassword", userData.Password)
 	SetCreatedInfo(userData, s.GetCxtUserId(), s.GetCxtUserName())
 	res, err := Model.Insert(userData)
 	if err != nil {

+ 6 - 0
opms_parent/app/dao/proj/internal/proj_business.go

@@ -27,7 +27,9 @@ type ProjBusinessDao struct {
 // ProjBusinessColumns defines and stores column names for table proj_business.
 type projBusinessColumns struct {
 	Id               string // 主键
+	NboCode          string // 项目编号
 	NboName          string // 项目名称
+	NboStatus        string // 项目状态
 	CustId           string // 关联客户
 	CustName         string // 客户名称
 	NboType          string // 项目类别(A类B类C类)
@@ -78,7 +80,9 @@ var (
 		Table: "proj_business",
 		Columns: projBusinessColumns{
 			Id:               "id",
+			NboCode:          "nbo_code",
 			NboName:          "nbo_name",
+			NboStatus:        "nbo_status",
 			CustId:           "cust_id",
 			CustName:         "cust_name",
 			NboType:          "nbo_type",
@@ -131,7 +135,9 @@ func NewProjBusinessDao(tenant string) ProjBusinessDao {
 		Table: "proj_business",
 		Columns: projBusinessColumns{
 			Id:               "id",
+			NboCode:          "nbo_code",
 			NboName:          "nbo_name",
+			NboStatus:        "nbo_status",
 			CustId:           "cust_id",
 			CustName:         "cust_name",
 			NboType:          "nbo_type",

+ 2 - 0
opms_parent/app/model/proj/internal/proj_business.go

@@ -11,7 +11,9 @@ import (
 // ProjBusiness is the golang structure for table proj_business.
 type ProjBusiness struct {
 	Id               int         `orm:"id,primary"         json:"id"`               // 主键
+	NboCode          string      `orm:"nbo_code"           json:"nboCode"`          // 项目编号
 	NboName          string      `orm:"nbo_name"           json:"nboName"`          // 项目名称
+	NboStatus        string      `orm:"nbo_status"         json:"nboStatus"`        // 项目状态
 	CustId           int         `orm:"cust_id"            json:"custId"`           // 关联客户
 	CustName         string      `orm:"cust_name"          json:"custName"`         // 客户名称
 	NboType          string      `orm:"nbo_type"           json:"nboType"`          // 项目类别(A类B类C类)

+ 1 - 1
opms_parent/app/model/proj/proj_business.go

@@ -55,7 +55,7 @@ type AddProjBusinessReq struct {
 	FollowUserName string      `json:"followUserName"`                            // 跟进负责人姓名
 	FollowContent  string      `json:"followContent"       v:"required#跟进内容不能为空"` // 跟进内容
 
-	Products []BusinessProduct `json:"products"` // 产品列表
+	Products []BusinessProduct `json:"products"      v:"required#产品列表不能为空"` // 产品列表
 }
 
 type UpdateProjBusinessReq struct {

+ 7 - 1
opms_parent/app/service/proj/business.go

@@ -200,6 +200,7 @@ func (p *businessService) UpdateById(req *model.UpdateProjBusinessReq) (err erro
 	}
 	var totalPrice float64
 	for _, v := range products {
+		v.Id = 0
 		v.TotalPrice = v.ProdPrice * float64(v.ProdNum)
 		totalPrice += v.TotalPrice
 		service.SetCreatedInfo(v, p.GetCxtUserId(), p.GetCxtUserName())
@@ -213,7 +214,12 @@ func (p *businessService) UpdateById(req *model.UpdateProjBusinessReq) (err erro
 			return err
 		}
 		// 添加项目产品
-		_, err = projDao.NewProjBusinessProductDao(p.Tenant).TX(tx).Save(products)
+		_, err = projDao.NewProjBusinessProductDao(p.Tenant).TX(tx).Where(projDao.ProjBusinessProduct.Columns.BusId, req.Id).Delete()
+		if err != nil {
+			return err
+		}
+		// 添加项目产品
+		_, err = projDao.NewProjBusinessProductDao(p.Tenant).TX(tx).Insert(products)
 		if err != nil {
 			return err
 		}

+ 1 - 1
opms_parent/app/service/proj/business_contact.go

@@ -38,7 +38,7 @@ func (p *businessContactService) GetList(req *projModel.BusinessReq) (total int,
 		return
 	}
 
-	err = db.Fields("bus.id AS id, bus.*, contact.*").Page(req.GetPage()).Order("bus.id desc").Scan(&contactList)
+	err = db.Fields("bus.*, contact.*,bus.id AS id").Page(req.GetPage()).Order("bus.id desc").Scan(&contactList)
 	return
 }