老师,关于一二级统计:例如我要自动统计张三团队人员一级是2人,二级是三人,李四一级是三人,二级0人。怎么统计啊,下面的表做的对么?
ID |
姓名 |
销售 |
来源 |
上级 |
ID |
1001 |
张三 |
8 |
张三 |
1001 |
1002 |
李四 |
5 |
张三 |
1001 |
1003 |
王五 |
3 |
李四 |
1002 |
1004 |
赵四 |
3 |
李四 |
1002 |
1005 |
孙起 |
5 |
张三 |
1001 |
1006 |
吴二 |
3 |
李四 |
1002 |
[此贴子已经被作者于2025/4/29 10:01:34编辑过]
0级 |
一级 |
二级 |
姓名 |
ID |
姓名 |
ID |
姓名 |
ID |
张三 |
1001 |
李四 |
1002 |
王五 |
1003 |
|
|
|
|
赵四 |
1004 |
|
|
|
|
吴二 |
1006 |
|
|
孙起 |
1005 |
|
|
-----------------------------------------------------------------------------------------------------------------------------
客户表
|
|
|
|
|
|
|
ID |
姓名 |
销售 |
来源 |
|
上级 |
ID |
|
1001 |
张三 |
8 |
张三 |
1001 |
|
1002 |
李四 |
5 |
张三 |
1001 |
|
1003 |
王五 |
3 |
李四 |
1002 |
|
1004 |
赵四 |
3 |
李四 |
1002 |
|
1005 |
孙起 |
5 |
张三 |
1001 |
|
1006 |
吴二 |
3 |
李四 |
1002 |
|
|
|
|
|
|
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
例如:张三的下面一级有2人,其中一级中孙起和李四,二级是李四下面的3人。
[此贴子已经被作者于2025/4/29 10:14:37编辑过]
这种要做递归
添加一个函数,名称“递归”
Dim dict As Dictionary(Of Integer, Integer) = args(0)
Dim dr As DataRow = args(1)
Dim level As String = args(2)
Dim drs As list(Of DataRow) = DataTables("客户表").Select("来源_id='" & dr("id") & "'")
If dict.ContainsKey(level) Then
dict(level) += drs.Count
Else
dict.Add(level, drs.Count)
End If
For Each dr1 As DataRow In drs
Functions.Execute("递归", dict, dr1, level + 1)
Next
按钮
Dim s As String = "1001"
Dim dict As New Dictionary(Of Integer, Integer)
Dim drs As list(Of DataRow) = DataTables("客户表").Select("laiy_id='" & s & "'")
dict.Add(1, drs.Count)
For Each dr As DataRow In drs
Functions.Execute("递归", dict, dr, 2)
Next
For Each key As Integer In dict.Keys
Output.Show(key & "级有" & dict(keu) & "人")
Next
老师手机端,每个人打开能看见自己的(根据openid)怎么做呢
每个表都添加这个openid,然后根据openid查询数据即可
老师我根据您的代码下进去了,包括按钮,报错
无法创建新的堆栈防护页面 后系统就退出来了
[此贴子已经被作者于2025/4/29 17:53:57编辑过]