| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113 |
- <%@ WebHandler Language="C#" Class="tree" %>
- using System;
- using System.Web;
- using System.Web.SessionState;
- using System.Data;
- using System.Text;
- using System.Collections;
- using System.Collections.Generic;
- using Newtonsoft.Json;
- using Newtonsoft.Json.Linq;
- using Curtain.DataAccess;
- using DK.XuWei.WebMes;
- /// <summary>
- /// 导航菜单
- /// xuwei create 2019-12-28
- /// </summary>
- public class tree : IHttpHandler, IReadOnlySessionState
- {
- public void ProcessRequest(HttpContext context)
- {
- context.Response.ContentType = "text/plain";
- using(IDataAccess conn = DataAccess.Create())
- {
- //按功能权限过滤显示树菜单(有子节点权限,不具备父节点权限,也要加进来)
- DataTable dt = conn.ExecuteDatatable(@"
- SELECT
- f.FUNCTIONCODE AS id,
- f.FUNCTIONLEVEL AS code,
- f.FUNCTIONNAME AS text,
- CASE
- WHEN
- --报表类
- (SUBSTR( FUNCTIONCODE, 1, 4) = '8070'
- AND LENGTH( FUNCTIONCODE ) = 6)
- --管理类
- OR
- (SUBSTR( FUNCTIONCODE, 1, 4) IN ('8090','8091','8092','8099')
- AND LENGTH( FUNCTIONCODE ) = 4)
- THEN
- 'closed'
- ELSE
- 'open'
- END AS state,
- f.URL AS url
- FROM
- TP_SYS_FUNCTION f
- WHERE
- f.IS_WEB = '1'
- AND valueflag = '1'
- AND
- (
- (f.FUNCTIONCODE IN (SELECT FUNCTIONCODE FROM TP_MST_USERRIGHT WHERE USERID = @USERID@ AND FUNCTIONCODE LIKE '80%'))
- OR (f.FUNCTIONCODE IN (SELECT SUBSTR( FUNCTIONCODE, 1, LENGTH( FUNCTIONCODE ) - 2 ) FROM TP_MST_USERRIGHT WHERE USERID = @USERID@ AND FUNCTIONCODE LIKE '80%'))
- OR (f.FUNCTIONCODE IN (SELECT SUBSTR( FUNCTIONCODE, 1, LENGTH( FUNCTIONCODE ) - 4 ) FROM TP_MST_USERRIGHT WHERE USERID = @USERID@ AND FUNCTIONCODE LIKE '80%'))
- OR (f.FUNCTIONCODE = '80')
- )
- ORDER BY
- f.FUNCTIONLEVEL,
- f.FUNCTIONCODE
- ",
- new CDAParameter("USERID",context.Session["userId"])
- );
- //添加动态报表菜单=================================
- //使用try容错,避免没有动态报表的出错
- //try
- //{
- // DataTable dtReport = conn.ExecuteDatatable(@"
- // SELECT
- // REPORTID AS id,
- // REPORTCODE AS code,
- // REPORTNAME AS text,
- // '/mes/dr/drmain/drmain_index.html?id='||REPORTID AS url
- // FROM
- // T_MST_DR_REPORT
- // WHERE
- // VALUEFLAG = '1'
- // ORDER BY
- // REPORTCODE
- // ",
- // new CDAParameter("USERID",context.Session["userId"])
- // );
- // //dt.Merge(dtReport);
- //}
- //catch
- //{
- //}
- //================================================
- string rootId = dt.Rows[0]["id"].ToString();
- string rootCode = dt.Rows[0]["code"].ToString();
- string rootText = dt.Rows[0]["text"].ToString();
- string children = Easyui.TableToEasyUITree(dt, rootCode);
- string jsonStr = "[{\"id\":\"" + rootId + "\",\"text\":\"" + rootText + "\"" + children + "}]";
- context.Response.Write(jsonStr);
- }
- }
- public bool IsReusable
- {
- get
- {
- return false;
- }
- }
- }
|