%
Dim uid, rsRole, isAdmin, psql, rsp, arealist, arealist_arr, userGroupID0
uid = trim(request("uid"))
if Lcase(AdminName) = "admin" then
isAdmin = true
else
isAdmin = false
set userGroupID0 = conn.execute("select group_id from t_role_user where userid = '" & trim(AdminName) & "'")
psql = "select t_classid,parentpath from t_area where t_classid in (select areaid from t_dev_property where uid in (select uid from t_role_equip where group_id = " & userGroupID0(0) & "))"
set rsp = conn.execute(psql)
if rsp.bof and rsp.eof then
arealist = ""
else
do while not rsp.eof
if arealist = "" then
arealist = rsp(0) & "," & rsp(1)
else
arealist = arealist & "," & rsp(0) & "," & rsp(1)
end if
rsp.movenext
loop
end if
rsp.close
set rsp = nothing
if arealist = "" then arealist = "0"
end if
%>
<%
dim rsClass
set rsClass = conn.execute("select t_classid, classname, child, parentid, classpicurl from t_area where parentid = 0 order by rootid")
response.write "
"
if rsClass.bof and rsClass.eof then
response.write " 没有菜单"
else
call subTree(0, " |-")
end if
response.write "
"
%>
<%
sub subTree(parentid,str)
dim rsSubClass, sql
if isAdmin = false then
sql = "select t_classid, classname, child, parentid, classpicurl from t_area where parentid = " & parentid & " and t_classid in (" & arealist & ") order by rootid"
else
sql = "select t_classid, classname, child, parentid, classpicurl from t_area where parentid = " & parentid & " order by rootid"
end if
set rsSubClass = conn.execute(sql)
if rsSubClass.bof and rsSubClass.eof then
response.write "
无设备
"
else
do while not rsSubClass.eof
if isAdmin = false then
response.write "
"
if rsSubClass("child") <> 0 then
call subTree(rsSubClass("t_classid"), " " & str)
else
call devList(rsSubClass("t_classid"), " " & str)
end if
response.write "
"
if rsSubClass("parentid") = 0 then response.write "
"
rsSubClass.movenext
if rsSubClass.eof then
rsSubClass.close
exit sub
end if
end if
loop
end if
end sub
sub devList(classid, str)
if isAdmin = false then
dim rsR, iList, userGroupID
set userGroupID = conn.execute("select group_id from t_role_user where userid = '" & trim(AdminName) & "'")
set rsR = conn.execute("select uid from t_role_equip where group_id = " & userGroupID(0) & " order by uid")
if rsR.bof and rsR.eof then
response.write "
" & str & "无权限
"
else
do while not rsR.eof
dim rsdl, sqldl
sqldl = "select * from t_dev_property where areaid = " & classid & " and uid = '" & rsR(0) & "' and isuse = '1' order by uid, devicename"
set rsdl = server.CreateObject("adodb.recordset")
rsdl.open sqldl, conn, 1, 1
do while not rsdl.eof
response.write "
"
rsdl.movenext
loop
rsdl.close
set rsdl = nothing
rsR.movenext
loop
end if
rsR.close
set rsR = nothing
else
sqldl = "select * from t_dev_property where areaid = " & classid & " and isuse = '1' order by uid,devicename"
set rsdl = server.CreateObject("adodb.recordset")
rsdl.open sqldl, conn, 1, 1
if rsdl.bof and rsdl.eof then
response.write "
"
rsdl.movenext
loop
end if
rsdl.close
set rsdl = nothing
end if
end sub
%>
<%
Call CloseConn
function inArr(id,arr)
dim i
for i = lbound(arr) to ubound(arr)
if int(id) = int(arr(i)) then
inArr = true
exit function
end if
next
inArr = false
end function
%>