Bladeren bron

feature(跟进记录): 跟进记录权限修改

ZZH-wl 2 jaren geleden
bovenliggende
commit
7519c09ff3

+ 10 - 9
opms_parent/app/dao/plat/internal/plat_followup.go

@@ -7,6 +7,7 @@ package internal
 import (
 	"context"
 	"database/sql"
+	"fmt"
 	"github.com/gogf/gf/container/garray"
 	"github.com/gogf/gf/database/gdb"
 	"github.com/gogf/gf/frame/g"
@@ -730,16 +731,16 @@ func (d *PlatFollowupDao) DataScope(ctx context.Context, args ...interface{}) *P
 		var orColumns []string
 		var orValues []interface{}
 		if ok && userIds != "-1" {
-			for _, column := range userCols {
-				if ok, _ := d.M.HasField(column); ok || specialFlag {
-					orColumns = append(orColumns, column+" IN (?) ")
+			for _, col := range userCols {
+				if ok, _ := d.M.HasField(col); ok || specialFlag {
+					orColumns = append(orColumns, fmt.Sprintf(" ( %s IN (?) )", col))
 					orValues = append(orValues, userIds)
 				}
 			}
 		}
 		for col, params := range orColsMap {
 			if ok, _ := d.M.HasField(col); ok || specialFlag {
-				orColumns = append(orColumns, col+" IN (?) ")
+				orColumns = append(orColumns, fmt.Sprintf(" ( %s IN (?) )", col))
 				orValues = append(orValues, params)
 			}
 		}
@@ -748,10 +749,10 @@ func (d *PlatFollowupDao) DataScope(ctx context.Context, args ...interface{}) *P
 		if !salesEngineerFlag {
 			var andColumns []string
 			var andValues []interface{}
-			for k, v := range dataScope {
-				if ok, _ := d.M.HasField(k); ok || specialFlag {
-					andColumns = append(andColumns, k+" IN (?) ")
-					andValues = append(andValues, v)
+			for col, params := range dataScope {
+				if ok, _ := d.M.HasField(col); ok || specialFlag {
+					andColumns = append(andColumns, fmt.Sprintf(" ( %s IN (?) )", col))
+					andValues = append(andValues, params)
 				}
 			}
 			if len(andColumns) > 0 {
@@ -797,7 +798,7 @@ func (d *PlatFollowupDao) checkColumnsName(dataScope map[string]interface{}, arg
 		if val, ok := args[0].(map[string]interface{}); ok {
 			specialFlag = true
 			colsContrast = val
-			if orcols, ok := val["orcols"]; ok && val[orcols.(string)] != "" {
+			if orcols, ok := val["orcols"]; ok {
 				if col, ok := orcols.(string); ok && gconv.String(val[col]) != "" {
 					orColsMap[col] = val[col]
 					delete(colsContrast, col)

+ 11 - 14
opms_parent/app/dao/work/internal/work_order.go

@@ -7,6 +7,7 @@ package internal
 import (
 	"context"
 	"database/sql"
+	"fmt"
 	"github.com/gogf/gf/container/garray"
 	"github.com/gogf/gf/database/gdb"
 	"github.com/gogf/gf/frame/g"
@@ -731,25 +732,21 @@ func (d *WorkOrderDao) DataScope(ctx context.Context, args ...interface{}) *Work
 			}
 		}
 		userIds, ok := dataScope["userIds"]
-		specialFlag, userCols, orColsMap := d.checkColumnsName(dataScope, args)
+		specialFlag, userCols, orColsMap := d.checkColumnsName(dataScope, args...)
 
 		var orColumns []string
 		var orValues []interface{}
 		if ok && userIds != "-1" {
-			columns := []string{"created_by"}
-			if len(userCols) > 0 {
-				columns = userCols
-			}
-			for _, column := range columns {
-				if ok, _ := d.M.HasField(column); ok || specialFlag {
-					orColumns = append(orColumns, column+" IN (?) ")
+			for _, col := range userCols {
+				if ok, _ := d.M.HasField(col); ok || specialFlag {
+					orColumns = append(orColumns, fmt.Sprintf(" ( %s IN (?) )", col))
 					orValues = append(orValues, userIds)
 				}
 			}
 		}
 		for col, params := range orColsMap {
 			if ok, _ := d.M.HasField(col); ok || specialFlag {
-				orColumns = append(orColumns, col+" IN (?) ")
+				orColumns = append(orColumns, fmt.Sprintf(" ( %s IN (?) )", col))
 				orValues = append(orValues, params)
 			}
 		}
@@ -758,10 +755,10 @@ func (d *WorkOrderDao) DataScope(ctx context.Context, args ...interface{}) *Work
 		if !salesEngineerFlag {
 			var andColumns []string
 			var andValues []interface{}
-			for k, v := range dataScope {
-				if ok, _ := d.M.HasField(k); ok || specialFlag {
-					andColumns = append(andColumns, k+" IN (?) ")
-					andValues = append(andValues, v)
+			for col, params := range dataScope {
+				if ok, _ := d.M.HasField(col); ok || specialFlag {
+					andColumns = append(andColumns, fmt.Sprintf(" ( %s IN (?) )", col))
+					andValues = append(andValues, params)
 				}
 			}
 			if len(andColumns) > 0 {
@@ -808,7 +805,7 @@ func (d *WorkOrderDao) checkColumnsName(dataScope map[string]interface{}, args .
 		if val, ok := args[0].(map[string]interface{}); ok {
 			specialFlag = true
 			colsContrast = val
-			if orcols, ok := val["orcols"]; ok && val[orcols.(string)] != "" {
+			if orcols, ok := val["orcols"]; ok {
 				if col, ok := orcols.(string); ok && gconv.String(val[col]) != "" {
 					orColsMap[col] = val[col]
 					delete(colsContrast, col)

+ 9 - 0
opms_parent/app/service/plat/plat_followup.go

@@ -6,6 +6,7 @@ import (
 	projdao "dashoo.cn/micro/app/dao/proj"
 	"dashoo.cn/opms_libary/myerrors"
 	"database/sql"
+	"github.com/gogf/gf/container/garray"
 	"github.com/gogf/gf/frame/g"
 	"github.com/gogf/gf/os/gtime"
 	"github.com/gogf/gf/util/gconv"
@@ -139,6 +140,14 @@ func (s *followupService) GetListByDay(req *model.SearchPlatFollowupReq) (total
 			"cust_id": req.CustId,
 			"orcols":  "cust_id",
 		}
+	} else if garray.NewStrArrayFrom(s.CxtUser.Roles, true).Contains("ProductLineManager") {
+		busIds, _ := projdao.NewProjBusinessDao(s.Tenant).DataScope(s.Ctx, "sale_id").Fields("id").Array()
+		custIds, _ := cust.NewCustCustomerDao(s.Tenant).DataScope(s.Ctx, "sales_id").Where("is_public", "20").Fields("id").Array()
+		filter = map[string]interface{}{
+			"target_type='20' AND target_id": busIds,
+			"target_type='10' AND target_id": custIds,
+			"orcols":                         []string{"target_type='20' AND target_id", "target_type='10' AND target_id"},
+		}
 	} else {
 		if s.DataScope["userIds"] != "-1" {
 			vals, _ := cust.NewCustCustomerDao(s.Tenant).DataScope(s.Ctx, "sales_id").Where("is_public", "20").Fields("id").Array()